1 /* |
1 /* |
2 * Copyright (c) 2006 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
23 #include <avkon.mbg> // Image Ids |
23 #include <avkon.mbg> // Image Ids |
24 #include <eikenv.h> // ReadResource() |
24 #include <eikenv.h> // ReadResource() |
25 #include <RichTextEditor.rsg> // Demo Text Buffer |
25 #include <RichTextEditor.rsg> // Demo Text Buffer |
26 #include "mypicture.h" // CMyPicture |
26 #include "mypicture.h" // CMyPicture |
27 #include <AknUtils.h> |
27 #include <AknUtils.h> |
28 |
|
29 #ifdef __SERIES60_3X__ |
|
30 #include <eikapp.h> |
28 #include <eikapp.h> |
31 #endif |
29 |
32 |
30 |
33 // ================= MEMBER FUNCTIONS ======================= |
31 // ================= MEMBER FUNCTIONS ======================= |
34 |
32 |
35 // Demo shows the T9 (Front End Processor) ,Scroller, |
33 // Demo shows the T9 (Front End Processor) ,Scroller, |
36 // "Insert Picture", disable Copy-Paste feature |
34 // "Insert Picture", disable Copy-Paste feature |
73 // Append Bitmap to iBitmap Array |
71 // Append Bitmap to iBitmap Array |
74 // --------------------------------------------------------- |
72 // --------------------------------------------------------- |
75 // |
73 // |
76 void CRTEContainer::PrepareBitmapL() |
74 void CRTEContainer::PrepareBitmapL() |
77 { |
75 { |
78 #ifndef __SERIES60_3X__ |
76 |
79 TFileName name(KImageBitmapFile); |
|
80 CompleteWithAppPath( name ); |
|
81 // windows build wants to install apps on rom drive ( "z:\" ) |
|
82 // but we want the data from "c:\" instead |
|
83 #ifdef __WINS__ |
|
84 name[ 0 ] = 'C'; |
|
85 #endif |
|
86 |
|
87 #else // 3rd ed |
|
88 |
|
89 RFs fsSession; |
77 RFs fsSession; |
90 User::LeaveIfError(fsSession.Connect()); |
78 User::LeaveIfError(fsSession.Connect()); |
91 CleanupClosePushL( fsSession ); |
79 CleanupClosePushL( fsSession ); |
92 TFileName name; |
80 TFileName name; |
93 fsSession.PrivatePath( name ); |
81 fsSession.PrivatePath( name ); |
98 TParsePtrC parse( |
86 TParsePtrC parse( |
99 (CEikonEnv::Static()->EikAppUi()->Application())->AppFullName() ); |
87 (CEikonEnv::Static()->EikAppUi()->Application())->AppFullName() ); |
100 name.Insert( 0, parse.Drive() ); |
88 name.Insert( 0, parse.Drive() ); |
101 #endif |
89 #endif |
102 |
90 |
103 #endif |
91 |
104 |
92 |
105 // Create and Load the Bitmap |
93 // Create and Load the Bitmap |
106 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap; |
94 CFbsBitmap* bitmap = new( ELeave )CFbsBitmap; |
107 CleanupStack::PushL(bitmap); |
95 CleanupStack::PushL(bitmap); |
108 User::LeaveIfError(bitmap->Load(name)); |
96 User::LeaveIfError(bitmap->Load(name)); |
109 //we have to free the memory at the Destructor() -> store the bitmap memory address |
97 //we have to free the memory at the Destructor() -> store the bitmap memory address |
110 iBitmap->AppendL(bitmap); |
98 iBitmap->AppendL(bitmap); |
111 |
99 |
112 CleanupStack::Pop(); //bitmap - container free bitmap at the destructor |
100 CleanupStack::Pop(); //bitmap - container free bitmap at the destructor |
113 #ifdef __SERIES60_3X__ |
101 |
114 CleanupStack::PopAndDestroy(1, &fsSession); |
102 CleanupStack::PopAndDestroy(1, &fsSession); |
115 #endif |
103 |
116 // last item in iBitmap array is ready to Insert |
104 // last item in iBitmap array is ready to Insert |
117 } |
105 } |
118 |
106 |
119 // --------------------------------------------------------- |
107 // --------------------------------------------------------- |
120 // CRTEContainer::InsertMyPictureL() |
108 // CRTEContainer::InsertMyPictureL() |
256 { |
244 { |
257 TRect rect = Rect(); |
245 TRect rect = Rect(); |
258 TInt StatusLineHeight = iStatusLine->Font()->HeightInPixels()+6; |
246 TInt StatusLineHeight = iStatusLine->Font()->HeightInPixels()+6; |
259 iStatusLine->SetExtent(TPoint(0, 0),TSize(rect.Width(), StatusLineHeight)); |
247 iStatusLine->SetExtent(TPoint(0, 0),TSize(rect.Width(), StatusLineHeight)); |
260 |
248 |
261 #ifdef __SERIES60_3X__ |
249 |
262 TRect ScrollBarRect = iRtEd->ScrollBarFrame()->VerticalScrollBar()->Rect(); |
250 TRect ScrollBarRect = iRtEd->ScrollBarFrame()->VerticalScrollBar()->Rect(); |
263 //In 3rd edition CEikRichTextEditor draw the view for the whole rect and |
251 //In 3rd edition CEikRichTextEditor draw the view for the whole rect and |
264 //the scrollbar doesn't show. That is a reason why CEikRichTextEditor Width() is |
252 //the scrollbar doesn't show. That is a reason why CEikRichTextEditor Width() is |
265 //rect.Width()-ScrollBarRect.Width() |
253 //rect.Width()-ScrollBarRect.Width() |
266 iRtEd->SetExtent(TPoint(0,StatusLineHeight), |
254 iRtEd->SetExtent(TPoint(0,StatusLineHeight), |
267 TSize(rect.Width()-ScrollBarRect.Width(), rect.Height()-StatusLineHeight)); |
255 TSize(rect.Width()-ScrollBarRect.Width(), rect.Height()-StatusLineHeight)); |
268 #else |
256 |
269 iRtEd->SetExtent(TPoint(0,StatusLineHeight), |
|
270 TSize(rect.Width(), rect.Height()-StatusLineHeight)); |
|
271 #endif |
|
272 } |
257 } |
273 |
258 |
274 // --------------------------------------------------------- |
259 // --------------------------------------------------------- |
275 // CRTEContainer::CountComponentControls() const |
260 // CRTEContainer::CountComponentControls() const |
276 // --------------------------------------------------------- |
261 // --------------------------------------------------------- |
376 { |
361 { |
377 iRtEd->BoldItalicUnderlineEventL(aFontFlags); |
362 iRtEd->BoldItalicUnderlineEventL(aFontFlags); |
378 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_CHARACTER_FORMAT); |
363 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_CHARACTER_FORMAT); |
379 } |
364 } |
380 |
365 |
381 #ifdef __SERIES60_3X__ |
366 |
382 // ---------------------------------------------------- |
367 // ---------------------------------------------------- |
383 // SetFont(TInt aFontId) |
368 // SetFont(TInt aFontId) |
384 // Change the text's font in the editor |
369 // Change the text's font in the editor |
385 // to the one specified as input parameter for the function |
370 // to the one specified as input parameter for the function |
386 // ---------------------------------------------------- |
371 // ---------------------------------------------------- |
399 |
384 |
400 iRtEd->ApplyCharFormatL(charFormat, charFormatMask); |
385 iRtEd->ApplyCharFormatL(charFormat, charFormatMask); |
401 |
386 |
402 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_FONT); |
387 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_FONT); |
403 } |
388 } |
404 #else |
|
405 // ---------------------------------------------------- |
|
406 // SetFont(const CFont *aFont) |
|
407 // Change the text's font in the editor |
|
408 // to the one specified as input parameter for the function |
|
409 // ---------------------------------------------------- |
|
410 void CRTEContainer::SetFont(const CFont *aFont) |
|
411 { |
|
412 /* |
|
413 TCursorSelection cs = iRtEd->Selection(); |
|
414 |
|
415 SetSelectionL(cs.iCursorPos, cs.iAnchorPos-1); |
|
416 */ |
|
417 TFontSpec fontspec = aFont->FontSpecInTwips(); |
|
418 TCharFormat charFormat( fontspec.iTypeface.iName, fontspec.iHeight ); |
|
419 TCharFormatMask charFormatMask; |
|
420 |
|
421 charFormatMask.SetAttrib(EAttFontTypeface); |
|
422 charFormatMask.SetAttrib(EAttFontHeight); |
|
423 iRtEd->ApplyCharFormatL(charFormat, charFormatMask); |
|
424 |
|
425 Echo(R_TYPE_DIALOG_TBUF_INDICATOR_FONT); |
|
426 } |
|
427 #endif |
|
428 // ---------------------------------------------------- |
389 // ---------------------------------------------------- |
429 // Strike() |
390 // Strike() |
430 // Toggle between strikethrough or not strikethrough text |
391 // Toggle between strikethrough or not strikethrough text |
431 // It depend only bool switch in the code, which turn to opposite in every |
392 // It depend only bool switch in the code, which turn to opposite in every |
432 // case Strikethrough selected from the menu. |
393 // case Strikethrough selected from the menu. |