|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: MsgExpandableControlEditor implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <eikappui.h> // for CEikAppUi |
|
23 #include <eikenv.h> // for CEikonEnv |
|
24 #include <txtrich.h> // for CRichText |
|
25 #include <baclipb.h> // for CClipboard |
|
26 #include <gulfont.h> // for TLogicalFont |
|
27 #include <AknUtils.h> // for AknUtils |
|
28 #include <barsread.h> // for TResourceReader |
|
29 #include <ItemFinder.h> // for automatic highlight |
|
30 |
|
31 #include <AknUtils.h> |
|
32 #include <AknsUtils.h> |
|
33 #include <AknSettingCache.h> |
|
34 #include <AknsConstants.h> |
|
35 #include <applayout.cdl.h> // LAF |
|
36 #include <aknlayoutscalable_apps.cdl.h> |
|
37 #include <aknlayoutscalable_avkon.cdl.h> |
|
38 #include <AknsFrameBackgroundControlContext.h> // FrameBackgroundControlContext |
|
39 #include <AknsDrawUtils.h> |
|
40 |
|
41 #include "MsgEditorCommon.h" // |
|
42 #include "MsgExpandableControlEditor.h" // for CMsgExpandableControlEditor |
|
43 #include "MsgExpandableControl.h" // for CMsgExpandableControl |
|
44 #include "MsgBaseControl.h" // for TMsgEditPermissionFlags |
|
45 #include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver |
|
46 #include "MsgEditorPanic.h" // for MsgEditor panics |
|
47 #include "MsgEditorLogging.h" |
|
48 #include "MsgEditorCustomDraw.h" // for CMsgEditorCustomDraw |
|
49 |
|
50 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
51 |
|
52 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
53 |
|
54 // ========== CONSTANTS ==================================== |
|
55 |
|
56 // ========== MACROS ======================================= |
|
57 |
|
58 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
59 // OPEN: |
|
60 const TInt KEdwinTopMargin = 0; |
|
61 const TInt KEdwinBottomMargin = 0; |
|
62 const TInt KEdwinLeftMargin = 0; |
|
63 const TInt KEdwinRightMargin = 0; |
|
64 const TInt KExpFullFormattingLength = 500; |
|
65 |
|
66 // ========== MODULE DATA STRUCTURES ======================= |
|
67 |
|
68 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
69 |
|
70 // ========== LOCAL FUNCTIONS ============================== |
|
71 |
|
72 // ========== MEMBER FUNCTIONS ============================= |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CMsgExpandableControlEditor::CMsgExpandableControlEditor |
|
76 // |
|
77 // Constructor. |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C CMsgExpandableControlEditor::CMsgExpandableControlEditor( |
|
81 TUint32& aFlags, |
|
82 MMsgBaseControlObserver* aBaseControlObserver) |
|
83 : |
|
84 CEikRichTextEditor( TGulBorder::ENone ), |
|
85 iFlags( aFlags ), |
|
86 iBaseControlObserver( aBaseControlObserver ) |
|
87 { |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CMsgExpandableControlEditor::CMsgExpandableControlEditor |
|
92 // |
|
93 // Constructor. |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 EXPORT_C CMsgExpandableControlEditor::CMsgExpandableControlEditor( |
|
97 const CCoeControl* aParent, |
|
98 TUint32& aFlags, |
|
99 MMsgBaseControlObserver* aBaseControlObserver ) |
|
100 : |
|
101 CEikRichTextEditor( TGulBorder::ENone ), |
|
102 iParentControl( aParent ), |
|
103 iFlags( aFlags ), |
|
104 iBaseControlObserver( aBaseControlObserver ) |
|
105 { |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CMsgExpandableControlEditor::~CMsgExpandableControlEditor |
|
110 // |
|
111 // Destructor. |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C CMsgExpandableControlEditor::~CMsgExpandableControlEditor() |
|
115 { |
|
116 delete iItemFinder; |
|
117 delete iFrameBgContext; |
|
118 delete iCustomDraw; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CMsgExpandableControlEditor::ConstructL |
|
123 // |
|
124 // Constructs and initializes this editor. |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CMsgExpandableControlEditor::ConstructL() |
|
128 { |
|
129 TInt edwinFlags = ENoHorizScrolling | |
|
130 ENoAutoSelection | |
|
131 EWidthInPixels | |
|
132 EAllowUndo | |
|
133 EResizable | |
|
134 EPasteAsPlainText; |
|
135 |
|
136 iFlags = EMsgControlModeDoNotDrawFrameBgContext; |
|
137 ResolveLayouts(); |
|
138 |
|
139 /*if ( iBaseControlObserver && |
|
140 !iBaseControlObserver->ViewInitialized() ) |
|
141 { |
|
142 SetSuppressFormatting( ETrue ); |
|
143 }*/ |
|
144 |
|
145 TInt numberOfLines( 0 ); |
|
146 |
|
147 if ( iFlags & EMsgControlModeSizeFixedToOneLine ) |
|
148 { |
|
149 // make control fixed size and allow horizontal scrolling. |
|
150 edwinFlags &= ~EResizable; |
|
151 edwinFlags &= ~ENoHorizScrolling; |
|
152 numberOfLines = 1; |
|
153 } |
|
154 |
|
155 CEikRichTextEditor::ConstructL( |
|
156 iParentControl, |
|
157 numberOfLines, |
|
158 iMaxNumberOfChars, |
|
159 edwinFlags ); |
|
160 |
|
161 // Emoticon support for MMS Subject field |
|
162 AddFlagToUserFlags(EAvkonEnableSmileySupport); |
|
163 |
|
164 // Both global text editor and edwin have it's own formatting layers. |
|
165 // CEikRichTextEditor::ConstructL call will set global formatting layers |
|
166 // into use for text. This is not correct as edwin formatting layers |
|
167 // will hold correct formatting values. Below calls will set edwin |
|
168 // formatting layers into use and prevent client based formatting from |
|
169 // being based on incorrect formatting layer. |
|
170 SetParaFormatLayer( iEikonEnv->SystemParaFormatLayerL()->CloneL() ); |
|
171 SetCharFormatLayer( iEikonEnv->SystemCharFormatLayerL()->CloneL() ); |
|
172 |
|
173 SetUpperFullFormattingLength( KExpFullFormattingLength ); |
|
174 |
|
175 SetMaximumHeight( MsgEditorCommons::MaxBodyHeight() ); |
|
176 |
|
177 // Set the wrap width to be that of the current header text pane. |
|
178 // This will make the formatting of text safer if it is performed |
|
179 // before the editor has ever had SetSize() called. WrapWidth is |
|
180 // usually set in HandleSizeChanged() |
|
181 if ( iLayout ) |
|
182 { |
|
183 iLayout->SetWrapWidth( iTextLayout.TextRect().Width() ); |
|
184 } |
|
185 |
|
186 // TODO: Get from LAF or something... Currently |
|
187 // all of these are zero. OK?! |
|
188 TMargins8 edwinMargins; |
|
189 edwinMargins.iTop = KEdwinTopMargin; |
|
190 edwinMargins.iBottom = KEdwinBottomMargin; |
|
191 edwinMargins.iLeft = KEdwinLeftMargin; |
|
192 edwinMargins.iRight = KEdwinRightMargin; |
|
193 SetBorderViewMargins( edwinMargins ); |
|
194 |
|
195 iBgContext = AknsDrawUtils::ControlContext( this ); |
|
196 |
|
197 // NOTE: iItemFinder can be created by derived class if needed. |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CMsgExpandableControlEditor::ConstructFromResourceL |
|
202 // --------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C void CMsgExpandableControlEditor::ConstructFromResourceL( |
|
205 TResourceReader& aReader ) |
|
206 { |
|
207 // This used to be font id. Not used anymore. Have to read it, though. |
|
208 /*TInt fontId =*/ aReader.ReadInt32(); |
|
209 |
|
210 ConstructL(); |
|
211 |
|
212 if ( !IsReadOnly() ) |
|
213 { |
|
214 ReadAknResourceL( aReader ); |
|
215 } |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CMsgExpandableControlEditor::SetAndGetSizeL |
|
220 // |
|
221 // Sets size for this editor. Height of given size aSize may change if the |
|
222 // editor contains text. |
|
223 // --------------------------------------------------------- |
|
224 // |
|
225 EXPORT_C void CMsgExpandableControlEditor::SetAndGetSizeL( TSize& aSize ) |
|
226 { |
|
227 TSize controlSize( aSize.iWidth, aSize.iHeight ); |
|
228 |
|
229 if( TextLayout() && TextLayout()->IsFormattingBand() ) |
|
230 { |
|
231 // Partial formatting on-going -> needs whole body height |
|
232 //controlSize.iHeight = MaximumHeight(); |
|
233 } |
|
234 else |
|
235 { |
|
236 TInt position( 0 ); |
|
237 AknLayoutUtils::GetEdwinVerticalPositionAndHeightFromLines( |
|
238 controlSize.iHeight, |
|
239 AknLayoutScalable_Apps::msg_header_pane_t2( 0 ).LayoutLine(), |
|
240 MsgEditorCommons::MsgBaseLineDelta(), |
|
241 iNumberOfLines, |
|
242 position, |
|
243 controlSize.iHeight ); |
|
244 } |
|
245 controlSize.iHeight +=iEditortop; |
|
246 if ( controlSize != iSize ) |
|
247 { |
|
248 // This may change the height if the content has changed. |
|
249 SetSize( controlSize ); |
|
250 } |
|
251 |
|
252 aSize = controlSize; |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // CMsgExpandableControlEditor::CheckEditPermission |
|
257 // |
|
258 // Checks and returns control's edit permissions. |
|
259 // --------------------------------------------------------- |
|
260 // |
|
261 EXPORT_C TUint32 CMsgExpandableControlEditor::CheckEditPermission() const |
|
262 { |
|
263 TUint32 editPermission( CMsgBaseControl::EMsgEditNone ); |
|
264 |
|
265 if ( CanUndo() ) |
|
266 { |
|
267 editPermission |= CMsgBaseControl::EMsgEditUndo; |
|
268 } |
|
269 |
|
270 if ( Selection().Length() ) |
|
271 { |
|
272 // Selection is on |
|
273 editPermission |= CMsgBaseControl::EMsgEditCopy; |
|
274 if ( !IsReadOnly() ) |
|
275 { |
|
276 editPermission |= CMsgBaseControl::EMsgEditCut; |
|
277 } |
|
278 if ( Selection().Length() == TextLength() ) |
|
279 { |
|
280 editPermission |= CMsgBaseControl::EMsgEditUnSelectAll; |
|
281 } |
|
282 } |
|
283 |
|
284 if ( TextLength() ) |
|
285 { |
|
286 editPermission |= CMsgBaseControl::EMsgEditSelectAll; |
|
287 } |
|
288 |
|
289 editPermission |= CMsgBaseControl::EMsgEditPaste; |
|
290 |
|
291 return editPermission; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------- |
|
295 // CMsgExpandableControlEditor::CursorInFirstLine |
|
296 // |
|
297 // Checks if the cursor is on the first line and return ETrue if it is. |
|
298 // --------------------------------------------------------- |
|
299 // |
|
300 EXPORT_C TBool CMsgExpandableControlEditor::CursorInFirstLine() |
|
301 { |
|
302 TBool cursorOnFirstLine = EFalse; |
|
303 TBool posFormatted = iLayout->PosIsFormatted( 0 ); |
|
304 if ( iTextView && posFormatted ) |
|
305 { |
|
306 TTmDocPos docPos; |
|
307 iTextView->GetCursorPos( docPos ); |
|
308 TTmDocPosSpec docPosSpec( docPos ); |
|
309 TTmPosInfo2 posInfo; |
|
310 TTmLineInfo lineInfo; |
|
311 if ( iLayout->FindDocPos( docPosSpec, posInfo, &lineInfo ) ) |
|
312 { |
|
313 cursorOnFirstLine = ( lineInfo.iLineNumber == 0 ); |
|
314 } |
|
315 } |
|
316 return cursorOnFirstLine; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------- |
|
320 // CMsgExpandableControlEditor::CursorInLastLine |
|
321 // |
|
322 // Checks if the cursor is on the last line and return ETrue if it is. |
|
323 // --------------------------------------------------------- |
|
324 // |
|
325 EXPORT_C TBool CMsgExpandableControlEditor::CursorInLastLine() |
|
326 { |
|
327 TBool cursorOnLastLine = EFalse; |
|
328 TBool posFormatted = iLayout->PosIsFormatted( TextLength() ); |
|
329 |
|
330 if ( iTextView && posFormatted ) |
|
331 { |
|
332 TInt numOfLines = iLayout->NumFormattedLines(); |
|
333 if ( numOfLines ) |
|
334 { |
|
335 TTmDocPos docPos; |
|
336 iTextView->GetCursorPos( docPos ); |
|
337 TTmDocPosSpec docPosSpec( docPos ); |
|
338 TTmPosInfo2 posInfo; |
|
339 TTmLineInfo lineInfo; |
|
340 if ( iLayout->FindDocPos( docPosSpec, posInfo, &lineInfo ) ) |
|
341 { |
|
342 cursorOnLastLine = ( lineInfo.iLineNumber == numOfLines - 1 ); |
|
343 } |
|
344 } |
|
345 else |
|
346 { |
|
347 // Editor is empty. |
|
348 cursorOnLastLine = ETrue; |
|
349 } |
|
350 } |
|
351 |
|
352 return cursorOnLastLine; |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------- |
|
356 // CMsgExpandableControlEditor::IsFirstLineVisible |
|
357 // |
|
358 // Checks if first text line is visible. |
|
359 // --------------------------------------------------------- |
|
360 // |
|
361 EXPORT_C TBool CMsgExpandableControlEditor::IsFirstLineVisible() |
|
362 { |
|
363 if( TextLayout() ) |
|
364 { |
|
365 TPoint dummy; |
|
366 if( TextLayout()->PosInBand( 0, dummy ) ) |
|
367 { |
|
368 if( iTextView ) |
|
369 { |
|
370 TTmDocPos docPos( 0, ETrue ); |
|
371 TTmDocPosSpec docPosSpec( docPos ); |
|
372 TTmPosInfo2 posInfo; |
|
373 TTmLineInfo lineInfo; |
|
374 |
|
375 if ( iLayout->FindDocPos( docPosSpec, posInfo, &lineInfo ) ) |
|
376 { |
|
377 // posInfo.iEdge specifies coordinate position of |
|
378 // intersection of the character edge with the baseline. |
|
379 TInt fontTop = posInfo.iEdge.iY - TextFont()->AscentInPixels(); |
|
380 return ( fontTop >= 0 && fontTop <= MsgEditorCommons::EditorViewHeigth() ); |
|
381 } |
|
382 } |
|
383 else |
|
384 { |
|
385 return ETrue; |
|
386 } |
|
387 } |
|
388 return EFalse; |
|
389 } |
|
390 |
|
391 return ETrue; |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------- |
|
395 // CMsgExpandableControlEditor::IsLastLineVisible |
|
396 // |
|
397 // Checks if last text line is visible. |
|
398 // --------------------------------------------------------- |
|
399 // |
|
400 EXPORT_C TBool CMsgExpandableControlEditor::IsLastLineVisible() |
|
401 { |
|
402 if( TextLayout() ) |
|
403 { |
|
404 TPoint dummy; |
|
405 if( TextLayout()->PosInBand( TextLength(),dummy ) ) |
|
406 { |
|
407 if ( iTextView ) |
|
408 { |
|
409 TTmDocPos docPos( TextLength(), EFalse ); |
|
410 TTmDocPosSpec docPosSpec( docPos ); |
|
411 TTmPosInfo2 posInfo; |
|
412 TTmLineInfo lineInfo; |
|
413 |
|
414 if ( iLayout->FindDocPos( docPosSpec, posInfo, &lineInfo ) ) |
|
415 { |
|
416 return ( posInfo.iEdge.iY >= 0 && |
|
417 posInfo.iEdge.iY <= MsgEditorCommons::EditorViewHeigth() ); |
|
418 } |
|
419 } |
|
420 else |
|
421 { |
|
422 return ETrue; |
|
423 } |
|
424 } |
|
425 return EFalse; |
|
426 } |
|
427 |
|
428 return ETrue; |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------- |
|
432 // CMsgExpandableControlEditor::CurrentLineRect |
|
433 // |
|
434 // Returns the current control rect. |
|
435 // --------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C TRect CMsgExpandableControlEditor::CurrentLineRectL() |
|
438 { |
|
439 if ( !iTextView ) |
|
440 { |
|
441 User::Leave( KErrGeneral ); |
|
442 } |
|
443 |
|
444 TTmDocPos docPos; |
|
445 iTextView->GetCursorPos( docPos ); |
|
446 iTextView->FinishBackgroundFormattingL(); |
|
447 |
|
448 TInt cursorPos = Min( docPos.iPos, TextLength() ); |
|
449 |
|
450 if ( !iLayout->PosIsFormatted( cursorPos ) ) |
|
451 { |
|
452 iTextView->SetDocPosL( cursorPos, Selection().Length() ); // after this cursorPos should be formatted |
|
453 ForceScrollBarUpdateL(); |
|
454 } |
|
455 |
|
456 TRect cursorPosRect; |
|
457 |
|
458 if ( iTextView->IsPictureFrameSelected( cursorPosRect, cursorPos ) ) |
|
459 { |
|
460 cursorPosRect.Move( TPoint( 0, -iTextView->ViewRect().iTl.iY ) ); |
|
461 } |
|
462 else |
|
463 { |
|
464 TTmDocPosSpec docPosSpec( docPos ); |
|
465 TTmPosInfo2 posInfo; |
|
466 TTmLineInfo lineInfo; |
|
467 if ( iLayout->FindDocPos( docPosSpec, posInfo, &lineInfo ) ) |
|
468 { |
|
469 cursorPosRect = lineInfo.iInnerRect; |
|
470 } |
|
471 //TODO: else what?! We should never get to else branch... |
|
472 } |
|
473 |
|
474 return cursorPosRect; |
|
475 } |
|
476 |
|
477 // --------------------------------------------------------- |
|
478 // CMsgExpandableControlEditor::DefaultHeight |
|
479 // |
|
480 // Returns a default one line height of the editor. |
|
481 // --------------------------------------------------------- |
|
482 // |
|
483 EXPORT_C TInt CMsgExpandableControlEditor::DefaultHeight() const |
|
484 { |
|
485 return DefaultHeight( EFalse ); |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------- |
|
489 // CMsgExpandableControlEditor::ClipboardL |
|
490 // |
|
491 // Handles a clipboard operation. |
|
492 // --------------------------------------------------------- |
|
493 // |
|
494 void CMsgExpandableControlEditor::ClipboardL( |
|
495 CEikEdwin::TClipboardFunc aClipboardFunc ) |
|
496 { |
|
497 __ASSERT_DEBUG( iTextView, Panic( EMsgNoTextView ) ); |
|
498 |
|
499 CEikRichTextEditor::ClipboardL( aClipboardFunc ); |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // CMsgExpandableControlEditor::CcpuCanCut |
|
504 // --------------------------------------------------------- |
|
505 // |
|
506 EXPORT_C TBool CMsgExpandableControlEditor::CcpuCanCut() const |
|
507 { |
|
508 TUint32 editPermission = CheckEditPermission(); |
|
509 |
|
510 if ( iBaseControlObserver ) |
|
511 { |
|
512 TRAP_IGNORE( |
|
513 { |
|
514 if ( iBaseControlObserver->HandleEditObserverEventRequestL( this, EMsgDenyCut ) ) |
|
515 { |
|
516 editPermission &= ~CMsgBaseControl::EMsgEditCut; |
|
517 } |
|
518 } ); |
|
519 } |
|
520 |
|
521 return editPermission & CMsgBaseControl::EMsgEditCut; |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------- |
|
525 // CMsgExpandableControlEditor::CcpuCanCopy |
|
526 // --------------------------------------------------------- |
|
527 // |
|
528 EXPORT_C TBool CMsgExpandableControlEditor::CcpuCanCopy() const |
|
529 { |
|
530 TUint32 editPermission = CheckEditPermission(); |
|
531 |
|
532 if (iBaseControlObserver) |
|
533 { |
|
534 TRAP_IGNORE( |
|
535 { |
|
536 if ( iBaseControlObserver->HandleEditObserverEventRequestL( this, EMsgDenyCopy ) ) |
|
537 { |
|
538 editPermission &= ~CMsgBaseControl::EMsgEditCopy; |
|
539 } |
|
540 } ); |
|
541 } |
|
542 |
|
543 return editPermission & CMsgBaseControl::EMsgEditCopy; |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------- |
|
547 // CMsgExpandableControlEditor::CcpuCanPaste |
|
548 // --------------------------------------------------------- |
|
549 // |
|
550 EXPORT_C TBool CMsgExpandableControlEditor::CcpuCanPaste() const |
|
551 { |
|
552 TUint32 editPermission = CheckEditPermission(); |
|
553 |
|
554 if ( !CEikEdwin::CcpuCanPaste() ) |
|
555 { |
|
556 editPermission &= ~CMsgBaseControl::EMsgEditPaste; |
|
557 } |
|
558 |
|
559 if ( iBaseControlObserver ) |
|
560 { |
|
561 TRAP_IGNORE( |
|
562 { |
|
563 if ( iBaseControlObserver->HandleEditObserverEventRequestL( this, EMsgDenyPaste ) ) |
|
564 { |
|
565 editPermission &= ~CMsgBaseControl::EMsgEditPaste; |
|
566 } |
|
567 } ); |
|
568 } |
|
569 |
|
570 return editPermission & CMsgBaseControl::EMsgEditPaste; |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------- |
|
574 // CMsgExpandableControlEditor::CcpuCanUndo |
|
575 // --------------------------------------------------------- |
|
576 // |
|
577 EXPORT_C TBool CMsgExpandableControlEditor::CcpuCanUndo() const |
|
578 { |
|
579 return CheckEditPermission() & CMsgBaseControl::EMsgEditUndo; |
|
580 } |
|
581 |
|
582 // --------------------------------------------------------- |
|
583 // CMsgExpandableControlEditor::CcpuCutL |
|
584 // --------------------------------------------------------- |
|
585 // |
|
586 EXPORT_C void CMsgExpandableControlEditor::CcpuCutL() |
|
587 { |
|
588 CEikRichTextEditor::ClipboardL( ECut ); |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // CMsgExpandableControlEditor::CcpuCopyL |
|
593 // --------------------------------------------------------- |
|
594 // |
|
595 EXPORT_C void CMsgExpandableControlEditor::CcpuCopyL() |
|
596 { |
|
597 CEikRichTextEditor::ClipboardL( ECopy ); |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------- |
|
601 // CMsgExpandableControlEditor::CcpuPasteL |
|
602 // --------------------------------------------------------- |
|
603 // |
|
604 EXPORT_C void CMsgExpandableControlEditor::CcpuPasteL() |
|
605 { |
|
606 CEikRichTextEditor::ClipboardL( EPaste ); |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------- |
|
610 // CMsgExpandableControlEditor::CcpuUndoL |
|
611 // --------------------------------------------------------- |
|
612 // |
|
613 EXPORT_C void CMsgExpandableControlEditor::CcpuUndoL() |
|
614 { |
|
615 UndoL(); |
|
616 } |
|
617 |
|
618 // --------------------------------------------------------- |
|
619 // CMsgExpandableControlEditor::SetMaxNumberOfChars |
|
620 // |
|
621 // Sets maximun number of characters. |
|
622 // --------------------------------------------------------- |
|
623 // |
|
624 void CMsgExpandableControlEditor::SetMaxNumberOfChars( TInt aMaxNumberOfChars ) |
|
625 { |
|
626 iMaxNumberOfChars = aMaxNumberOfChars; |
|
627 if ( Text() ) |
|
628 { |
|
629 SetTextLimit( iMaxNumberOfChars ); |
|
630 } |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------- |
|
634 // CMsgExpandableControlEditor::SetTextContentL |
|
635 // |
|
636 // Sets aText content for the editor. |
|
637 // --------------------------------------------------------- |
|
638 // |
|
639 EXPORT_C void CMsgExpandableControlEditor::SetTextContentL( CRichText& aText ) |
|
640 { |
|
641 MEBLOGGER_ENTERFN("CMsgExpandableControlEditor::SetTextContentL"); |
|
642 |
|
643 MEBLOGGER_WRITE("#1"); |
|
644 MEBLOGGER_WRITE_TIMESTAMP(""); |
|
645 |
|
646 if ( IsPlainTextMode() ) |
|
647 { |
|
648 CRichText* richText = RichText(); |
|
649 |
|
650 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: Copying text, length %d" ), aText.DocumentLength() ); |
|
651 |
|
652 // Ignore the original formatting on plain text mode and set the |
|
653 // new rich text object to use current formatting parameters. |
|
654 aText.SetGlobalParaFormat( richText->GlobalParaFormatLayer() ); |
|
655 aText.SetGlobalCharFormat( richText->GlobalCharFormatLayer() ); |
|
656 |
|
657 CEikEdwin::CopyDocumentContentL( aText, *richText ); |
|
658 TInt documentLength = richText->DocumentLength(); |
|
659 |
|
660 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: Copied text, length %d" ), documentLength ); |
|
661 |
|
662 if ( iMaxNumberOfChars && |
|
663 documentLength > iMaxNumberOfChars ) |
|
664 { |
|
665 richText->DeleteL( iMaxNumberOfChars, documentLength - iMaxNumberOfChars ); |
|
666 documentLength = richText->DocumentLength(); |
|
667 } |
|
668 |
|
669 const TChar LF( 0x0A ); |
|
670 const TChar CR( 0x0D ); |
|
671 |
|
672 TInt i = 0; |
|
673 while ( i < documentLength ) |
|
674 { |
|
675 TPtrC ptr = richText->Read( i, 1 ); |
|
676 TInt remove = 0; |
|
677 TBool addParDeli = EFalse; |
|
678 if ( ptr.Locate( CEditableText::EPictureCharacter ) != KErrNotFound ) |
|
679 { |
|
680 remove++; |
|
681 } |
|
682 else if ( ptr.Locate( CR ) != KErrNotFound ) |
|
683 { |
|
684 // "CR" |
|
685 remove++; |
|
686 addParDeli = ETrue; |
|
687 if ( i < documentLength - 1 && |
|
688 aText.Read( i + 1, 1 ).Locate( LF ) != KErrNotFound ) |
|
689 { |
|
690 // "CR+LF" |
|
691 remove++; |
|
692 } |
|
693 } |
|
694 else if ( ptr.Locate( LF ) != KErrNotFound ) |
|
695 { |
|
696 // "LF" |
|
697 remove++; |
|
698 addParDeli = ETrue; |
|
699 } |
|
700 |
|
701 if ( remove ) |
|
702 { |
|
703 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: removing %d characters" ), remove ); |
|
704 richText->DeleteL( i, remove ); |
|
705 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: removed %d characters" ), remove ); |
|
706 documentLength -= remove; |
|
707 if ( addParDeli ) |
|
708 { |
|
709 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: Inserting paragraph delimeter" ) ); |
|
710 richText->InsertL( i, CEditableText::EParagraphDelimiter ); |
|
711 MEBLOGGER_WRITEF( _L( "MEB: SetTextContentL: Inserted paragraph delimeter" ) ); |
|
712 documentLength++; |
|
713 i++; |
|
714 } |
|
715 } |
|
716 else |
|
717 { |
|
718 i++; |
|
719 } |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 CopyDocumentContentL( aText, *GlobalText() ); |
|
725 } |
|
726 |
|
727 SetAmountToFormatL( ETrue ); |
|
728 |
|
729 MEBLOGGER_WRITE("#2"); |
|
730 MEBLOGGER_WRITE_TIMESTAMP(""); |
|
731 |
|
732 MEBLOGGER_LEAVEFN("CMsgExpandableControlEditor::SetTextContentL"); |
|
733 } |
|
734 |
|
735 // --------------------------------------------------------- |
|
736 // CMsgExpandableControlEditor::MinimumDefaultHeight |
|
737 // |
|
738 // Returns a minimum one line height of the editor. |
|
739 // --------------------------------------------------------- |
|
740 // |
|
741 TInt CMsgExpandableControlEditor::MinimumDefaultHeight() const |
|
742 { |
|
743 return DefaultHeight( ETrue ); |
|
744 } |
|
745 |
|
746 // --------------------------------------------------------- |
|
747 // CMsgExpandableControlEditor::Reset |
|
748 // |
|
749 // Clear contents. |
|
750 // --------------------------------------------------------- |
|
751 // |
|
752 EXPORT_C void CMsgExpandableControlEditor::Reset() |
|
753 { |
|
754 if ( iTextView ) |
|
755 { |
|
756 TInt documentLength = RichText()->DocumentLength(); |
|
757 |
|
758 RichText()->Reset(); |
|
759 |
|
760 iTextView->SetPendingSelection( TCursorSelection( 0, 0 ) ); |
|
761 TRAP_IGNORE( iTextView->HandleInsertDeleteL( TCursorSelection( 0, 0 ), |
|
762 documentLength ) ); |
|
763 } |
|
764 else |
|
765 { |
|
766 RichText()->Reset(); |
|
767 } |
|
768 } |
|
769 |
|
770 // --------------------------------------------------------- |
|
771 // CMsgExpandableControlEditor::SetBaseControlObserver |
|
772 // |
|
773 // Sets base control observer. |
|
774 // --------------------------------------------------------- |
|
775 // |
|
776 EXPORT_C void CMsgExpandableControlEditor::SetBaseControlObserver( |
|
777 MMsgBaseControlObserver& aBaseControlObserver ) |
|
778 { |
|
779 iBaseControlObserver = &aBaseControlObserver; |
|
780 } |
|
781 |
|
782 // --------------------------------------------------------- |
|
783 // CMsgExpandableControlEditor::OfferKeyEventL |
|
784 // |
|
785 // Handles key event. |
|
786 // --------------------------------------------------------- |
|
787 // |
|
788 EXPORT_C TKeyResponse CMsgExpandableControlEditor::OfferKeyEventL( |
|
789 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
790 { |
|
791 if ( IsReadOnly() ) |
|
792 { |
|
793 TCursorPosition::TMovementType movetype; |
|
794 |
|
795 switch ( aKeyEvent.iCode ) |
|
796 { |
|
797 case EKeyUpArrow: |
|
798 movetype = TCursorPosition::EFPageUp; |
|
799 break; |
|
800 |
|
801 case EKeyDownArrow: |
|
802 movetype = TCursorPosition::EFPageDown; |
|
803 break; |
|
804 |
|
805 default: |
|
806 return CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType ); |
|
807 } |
|
808 |
|
809 iTextView->MoveCursorL( movetype, EFalse ); |
|
810 |
|
811 return EKeyWasConsumed; |
|
812 } |
|
813 else |
|
814 { |
|
815 return CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType ); |
|
816 } |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------- |
|
820 // CMsgExpandableControlEditor::HandleResourceChange |
|
821 // |
|
822 // Sets correct highlight extension. |
|
823 // --------------------------------------------------------- |
|
824 // |
|
825 void CMsgExpandableControlEditor::HandleResourceChange( TInt aType ) |
|
826 { |
|
827 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
828 { |
|
829 ResolveLayouts(); |
|
830 LayoutEdwin(); |
|
831 |
|
832 TRAP_IGNORE( |
|
833 { |
|
834 if ( iTextView ) |
|
835 { |
|
836 TCursorSelection currentSelection = iTextView->Selection() ; |
|
837 |
|
838 if ( currentSelection.Length() > 0 ) |
|
839 { |
|
840 iTextView->SetSelectionL( currentSelection ); |
|
841 } |
|
842 else |
|
843 { |
|
844 iTextView->SetDocPosL( currentSelection.iCursorPos, EFalse ); |
|
845 } |
|
846 } |
|
847 } ); |
|
848 } |
|
849 |
|
850 CEikRichTextEditor::HandleResourceChange( aType ); |
|
851 } |
|
852 |
|
853 // --------------------------------------------------------- |
|
854 // CMsgExpandableControlEditor::IsPlainTextMode |
|
855 // |
|
856 // Checks if the plain text mode is on and returns ETrue if it is. |
|
857 // --------------------------------------------------------- |
|
858 // |
|
859 TBool CMsgExpandableControlEditor::IsPlainTextMode() const |
|
860 { |
|
861 return iFlags & EMsgControlModePlainTextMode; |
|
862 } |
|
863 |
|
864 // --------------------------------------------------------- |
|
865 // CMsgExpandableControlEditor::LayoutEdwin |
|
866 // --------------------------------------------------------- |
|
867 // |
|
868 void CMsgExpandableControlEditor::LayoutEdwin() |
|
869 { |
|
870 TAknLayoutRect msgTextPane; |
|
871 msgTextPane.LayoutRect( MsgEditorCommons::MsgDataPane(), |
|
872 AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() ); |
|
873 |
|
874 TAknLayoutRect msgHeaderPane; |
|
875 msgHeaderPane.LayoutRect( msgTextPane.Rect(), |
|
876 AknLayoutScalable_Apps::msg_header_pane().LayoutLine() ); |
|
877 |
|
878 TRect parentRect( msgHeaderPane.Rect() ); |
|
879 parentRect.Move( 0, iParentControl->Position().iY ); |
|
880 |
|
881 DoLayoutEdwin( parentRect, |
|
882 AknLayoutScalable_Apps::msg_header_pane_t2( 0 ).LayoutLine() ); |
|
883 } |
|
884 |
|
885 // --------------------------------------------------------- |
|
886 // CMsgExpandableControlEditor::DoLayoutEdwin |
|
887 // |
|
888 // Performs the layout setting for edwin according to the given |
|
889 // parameters. Used from LayoutEdwin or some of it's derived versions. |
|
890 // --------------------------------------------------------- |
|
891 // |
|
892 void CMsgExpandableControlEditor::DoLayoutEdwin( const TRect& aEdwinParent, |
|
893 const TAknTextLineLayout& aLayout ) |
|
894 { |
|
895 TPoint position( iPosition ); |
|
896 |
|
897 // Layout edwin as two lines to get the base line delta override activated. |
|
898 TInt lineNumber( 0 ); |
|
899 AknLayoutUtils::LayoutEdwin( this, |
|
900 aEdwinParent, |
|
901 aLayout, |
|
902 2, |
|
903 MsgEditorCommons::MsgBaseLineDelta(), |
|
904 EAknsCIQsnTextColorsCG6, |
|
905 lineNumber ); |
|
906 |
|
907 // Resize the edwin to the correct size. Also set the original position. |
|
908 TInt notUsed( 0 ); |
|
909 TInt height( 0 ); |
|
910 AknLayoutUtils::GetEdwinVerticalPositionAndHeightFromLines( |
|
911 aEdwinParent.Size().iHeight, |
|
912 aLayout, |
|
913 MsgEditorCommons::MsgBaseLineDelta(), |
|
914 iNumberOfLines, |
|
915 notUsed, |
|
916 height ); |
|
917 |
|
918 TRect editorRect( position, TSize( iSize.iWidth, height ) ); |
|
919 SetRect( editorRect ); |
|
920 } |
|
921 |
|
922 // --------------------------------------------------------- |
|
923 // CMsgExpandableControlEditor::AdjustLineHeightL |
|
924 // --------------------------------------------------------- |
|
925 // |
|
926 EXPORT_C void CMsgExpandableControlEditor::AdjustLineHeightL() |
|
927 { |
|
928 // nop |
|
929 } |
|
930 |
|
931 // --------------------------------------------------------- |
|
932 // CMsgExpandableControlEditor::TextFont |
|
933 // --------------------------------------------------------- |
|
934 // |
|
935 EXPORT_C const CFont* CMsgExpandableControlEditor::TextFont() const |
|
936 { |
|
937 return iTextLayout.Font(); |
|
938 } |
|
939 |
|
940 // --------------------------------------------------------- |
|
941 // CMsgExpandableControlEditor::DefaultHeight |
|
942 // --------------------------------------------------------- |
|
943 // |
|
944 TInt CMsgExpandableControlEditor::DefaultHeight( TBool /*aOneToOne*/ ) const |
|
945 { |
|
946 return TextFont()->HeightInPixels(); |
|
947 } |
|
948 |
|
949 // --------------------------------------------------------- |
|
950 // CMsgExpandableControlEditor::VirtualHeight |
|
951 // |
|
952 // Returns approximate height of text. In band formatting mode |
|
953 // we have to calculate the average chars per line and |
|
954 // average line in view values by ourself as we might get called |
|
955 // in a callback when edwin does not contain up-to-date values. |
|
956 // --------------------------------------------------------- |
|
957 // |
|
958 EXPORT_C TInt CMsgExpandableControlEditor::VirtualHeight() |
|
959 { |
|
960 TInt heightInPixels( 0 ); |
|
961 TInt msgBaseLineDelta( MsgEditorCommons::MsgBaseLineDelta() ); |
|
962 |
|
963 if ( iLayout->IsFormattingBand() ) |
|
964 { |
|
965 TInt docLength = iLayout->DocumentLength(); |
|
966 |
|
967 TInt avgCharsPerLine = iLayout->FormattedLength() / iLayout->NumFormattedLines(); |
|
968 TInt avgLinesInViewRect= Max( 1, iTextView->ViewRect().Height() * |
|
969 iLayout->NumFormattedLines() / |
|
970 iLayout->FormattedHeightInPixels() ); |
|
971 |
|
972 const TInt approxTotalLines = Max( docLength / avgCharsPerLine, |
|
973 iText->ParagraphCount() ); |
|
974 const TInt approxLineHeight = iTextView->ViewRect().Height() / avgLinesInViewRect; |
|
975 heightInPixels = approxTotalLines * approxLineHeight; |
|
976 } |
|
977 else |
|
978 { |
|
979 if ( iTextView ) |
|
980 { |
|
981 // Force formatting to complete so that |
|
982 // correct height can be retrieved. |
|
983 TRAP_IGNORE( iTextView->FinishBackgroundFormattingL() ); |
|
984 } |
|
985 |
|
986 heightInPixels = iLayout->FormattedHeightInPixels(); |
|
987 } |
|
988 |
|
989 heightInPixels = Max( heightInPixels, iLayout->FormattedHeightInPixels() ); |
|
990 MsgEditorCommons::RoundToPreviousLine( heightInPixels, msgBaseLineDelta ); |
|
991 |
|
992 return heightInPixels; |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------- |
|
996 // CMsgExpandableControlEditor::VirtualVisibleTop |
|
997 // |
|
998 // Returns a topmost visible text position. In band formatting mode |
|
999 // we have to calculate the average chars per line value |
|
1000 // by ourself as we might get called in a callback when edwin |
|
1001 // does not contain up-to-date value. |
|
1002 // --------------------------------------------------------- |
|
1003 // |
|
1004 EXPORT_C TInt CMsgExpandableControlEditor::VirtualVisibleTop() |
|
1005 { |
|
1006 TInt ret( 0 ); |
|
1007 |
|
1008 TInt msgBaseLineDelta( MsgEditorCommons::MsgBaseLineDelta() ); |
|
1009 |
|
1010 if ( iLayout->IsFormattingBand() ) |
|
1011 { |
|
1012 TInt avgCharsPerLine = iLayout->FormattedLength() / iLayout->NumFormattedLines(); |
|
1013 |
|
1014 TInt topLeftDocPos = iLayout->FirstDocPosFullyInBand(); |
|
1015 TInt approxTopVisibleLine = topLeftDocPos / avgCharsPerLine; |
|
1016 |
|
1017 if ( approxTopVisibleLine == 0 && |
|
1018 topLeftDocPos > 0 ) |
|
1019 { |
|
1020 ret = iLayout->PixelsAboveBand(); |
|
1021 } |
|
1022 else |
|
1023 { |
|
1024 TInt avgLinesInViewRect= Max( 1, iTextView->ViewRect().Height() * |
|
1025 iLayout->NumFormattedLines() / |
|
1026 iLayout->FormattedHeightInPixels() ); |
|
1027 |
|
1028 TInt approxLineHeight = iTextView->ViewRect().Height() / avgLinesInViewRect; |
|
1029 ret = approxTopVisibleLine * approxLineHeight; |
|
1030 } |
|
1031 } |
|
1032 else |
|
1033 { |
|
1034 // Round to the last full line height. Division removes the fraction since |
|
1035 // result is integer (i.e. non floating point value). |
|
1036 ret = iLayout->PixelsAboveBand(); |
|
1037 } |
|
1038 |
|
1039 ret = Max( ret, iLayout->PixelsAboveBand() ); |
|
1040 MsgEditorCommons::RoundToPreviousLine( ret, msgBaseLineDelta ); |
|
1041 |
|
1042 return ret; |
|
1043 } |
|
1044 |
|
1045 // --------------------------------------------------------- |
|
1046 // CMsgExpandableControlEditor::ActivateL |
|
1047 // --------------------------------------------------------- |
|
1048 // |
|
1049 EXPORT_C void CMsgExpandableControlEditor::ActivateL() |
|
1050 { |
|
1051 if ( IsActivated() ) |
|
1052 { |
|
1053 return; |
|
1054 } |
|
1055 |
|
1056 TInt cursorPos = 0; |
|
1057 |
|
1058 if ( iTextView ) |
|
1059 { |
|
1060 cursorPos = CursorPos(); |
|
1061 } |
|
1062 |
|
1063 LayoutEdwin(); |
|
1064 SetTextSkinColorIdL(); |
|
1065 |
|
1066 CEikRichTextEditor::ActivateL(); |
|
1067 |
|
1068 iTextView->SetDocPosL( cursorPos ); |
|
1069 if ( !iCustomDraw ) |
|
1070 { |
|
1071 // Swap the custom drawer to our own to show text lines. |
|
1072 const MFormCustomDraw* customDraw = TextLayout()->CustomDraw(); |
|
1073 |
|
1074 iCustomDraw = CMsgEditorCustomDraw::NewL( customDraw, this, iControlType); |
|
1075 |
|
1076 TextLayout()->SetCustomDraw( iCustomDraw ); |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 // --------------------------------------------------------- |
|
1081 // CMsgExpandableControlEditor::ItemFinder |
|
1082 // --------------------------------------------------------- |
|
1083 // |
|
1084 EXPORT_C CItemFinder* CMsgExpandableControlEditor::ItemFinder() const |
|
1085 { |
|
1086 return iItemFinder; |
|
1087 } |
|
1088 |
|
1089 // --------------------------------------------------------- |
|
1090 // CMsgExpandableControlEditor::FocusChanged |
|
1091 // --------------------------------------------------------- |
|
1092 // |
|
1093 EXPORT_C void CMsgExpandableControlEditor::FocusChanged( TDrawNow aDrawNow ) |
|
1094 { |
|
1095 CEikEdwin::FocusChanged( aDrawNow ); |
|
1096 |
|
1097 TRAP_IGNORE( DoFocusChangedL() ); |
|
1098 } |
|
1099 |
|
1100 // --------------------------------------------------------- |
|
1101 // CMsgExpandableControlEditor::DoFocusChangedL |
|
1102 // --------------------------------------------------------- |
|
1103 // |
|
1104 void CMsgExpandableControlEditor::DoFocusChangedL() |
|
1105 { |
|
1106 SetTextSkinColorIdL(); |
|
1107 |
|
1108 if( ! ( iFlags & EMsgControlModeDoNotDrawFrameBgContext ) && |
|
1109 ! static_cast<const CMsgBaseControl*>( iParentControl )->IsReadOnly() ) |
|
1110 { |
|
1111 if( IsFocused( ) ) |
|
1112 { |
|
1113 // The focus arrives so lets so the frame |
|
1114 // It is drawn between the outer and inner rects |
|
1115 TRect outer, inner; |
|
1116 OuterAndInnerRects( outer, inner ); |
|
1117 |
|
1118 if( !iFrameBgContext ) |
|
1119 { |
|
1120 iFrameBgContext = |
|
1121 CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, |
|
1122 outer, |
|
1123 inner, |
|
1124 EFalse ); |
|
1125 iFrameBgContext->SetParentContext( iBgContext ); |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 iFrameBgContext->SetFrameRects( outer, inner ); |
|
1130 } |
|
1131 SetSkinBackgroundControlContextL( iFrameBgContext ); |
|
1132 } |
|
1133 else |
|
1134 { // Focus leaves so lets remove the skin bg control contex |
|
1135 SetSkinBackgroundControlContextL( iBgContext ); |
|
1136 } |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 // --------------------------------------------------------- |
|
1141 // CMsgExpandableControlEditor::HandleFrameSizeChangeL |
|
1142 // --------------------------------------------------------- |
|
1143 // |
|
1144 void CMsgExpandableControlEditor::HandleFrameSizeChangeL() |
|
1145 { |
|
1146 if( IsFocused( ) ) |
|
1147 { |
|
1148 // We have focus so lets resize the frame context |
|
1149 if( ! (iFlags & EMsgControlModeDoNotDrawFrameBgContext ) && |
|
1150 ! static_cast<const CMsgBaseControl*>( iParentControl )->IsReadOnly() ) |
|
1151 { |
|
1152 // The size of the frame has changed so lets find out |
|
1153 // the outer and inner rects again |
|
1154 TRect outer, inner; |
|
1155 OuterAndInnerRects( outer, inner ); |
|
1156 |
|
1157 if( !iFrameBgContext ) |
|
1158 { |
|
1159 iFrameBgContext = |
|
1160 CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, |
|
1161 outer, |
|
1162 inner, |
|
1163 EFalse ); |
|
1164 iFrameBgContext->SetParentContext( iBgContext ); |
|
1165 } |
|
1166 |
|
1167 iFrameBgContext->SetFrameRects( outer, inner ); |
|
1168 SetSkinBackgroundControlContextL( iFrameBgContext ); |
|
1169 } |
|
1170 } |
|
1171 } |
|
1172 |
|
1173 // --------------------------------------------------------- |
|
1174 // CMsgExpandableControlEditor::OuterAndInnerRects |
|
1175 // --------------------------------------------------------- |
|
1176 // |
|
1177 void CMsgExpandableControlEditor::OuterAndInnerRects( TRect& aOuter, TRect& aInner ) |
|
1178 { |
|
1179 TRect rect( Rect( ) ); |
|
1180 TRect focused ( iParentControl->Rect( ) ); |
|
1181 |
|
1182 // If we are out of screen, start it just from the baseline offset |
|
1183 TInt top = MsgEditorCommons::MsgBaseLineOffset(); |
|
1184 if ( focused.iTl.iY < top ) |
|
1185 { |
|
1186 focused.iTl.iY = top; |
|
1187 } |
|
1188 TInt maxBodyHeight( MsgEditorCommons::EditorViewHeigth() ); |
|
1189 if ( focused.iBr.iY > maxBodyHeight ) |
|
1190 { |
|
1191 focused.iBr.iY = maxBodyHeight; |
|
1192 } |
|
1193 |
|
1194 aOuter.SetRect( rect.iTl.iX-1, |
|
1195 focused.iTl.iY, |
|
1196 rect.iBr.iX, |
|
1197 focused.iBr.iY ); |
|
1198 |
|
1199 TAknLayoutRect tl; |
|
1200 TAknLayoutRect br; |
|
1201 tl.LayoutRect( aOuter, AknLayoutScalable_Avkon::input_focus_pane_g2().LayoutLine() ); |
|
1202 br.LayoutRect( aOuter, AknLayoutScalable_Avkon::input_focus_pane_g5().LayoutLine() ); |
|
1203 |
|
1204 aInner.SetRect( aOuter.iTl.iX - 1, |
|
1205 aOuter.iTl.iY + tl.Rect().Height(), |
|
1206 aOuter.iBr.iX, |
|
1207 aOuter.iBr.iY - br.Rect().Height() ); |
|
1208 } |
|
1209 |
|
1210 |
|
1211 // --------------------------------------------------------- |
|
1212 // CMsgExpandableControlEditor::ResolveLayouts |
|
1213 // |
|
1214 // |
|
1215 // --------------------------------------------------------- |
|
1216 // |
|
1217 void CMsgExpandableControlEditor::ResolveLayouts() |
|
1218 { |
|
1219 TAknLayoutRect msgTextPane; |
|
1220 msgTextPane.LayoutRect( MsgEditorCommons::MsgDataPane(), |
|
1221 AknLayoutScalable_Apps::msg_text_pane( 0 ).LayoutLine() ); |
|
1222 |
|
1223 TAknLayoutRect msgHeaderPane; |
|
1224 msgHeaderPane.LayoutRect( msgTextPane.Rect(), |
|
1225 AknLayoutScalable_Apps::msg_header_pane().LayoutLine() ); |
|
1226 |
|
1227 iTextLayout.LayoutText( msgHeaderPane.Rect(), |
|
1228 AknLayoutScalable_Apps::msg_header_pane_t2( 0 ).LayoutLine() ); |
|
1229 TRect dataPane = MsgEditorCommons::MsgDataPane(); |
|
1230 |
|
1231 |
|
1232 TAknTextLineLayout editorLineLayout; |
|
1233 TAknLayoutText editorLayout; |
|
1234 |
|
1235 editorLineLayout = AknLayoutScalable_Apps::msg_header_pane_t2( 0 ).LayoutLine(); |
|
1236 |
|
1237 editorLayout.LayoutText( msgHeaderPane.Rect(), editorLineLayout ); |
|
1238 |
|
1239 iEditortop = editorLayout.TextRect().iTl.iY - msgHeaderPane.Rect().iTl.iY; |
|
1240 if ( iCustomDraw ) |
|
1241 { |
|
1242 iCustomDraw->ResolveLayouts(); |
|
1243 } |
|
1244 } |
|
1245 |
|
1246 // --------------------------------------------------------- |
|
1247 // CMsgExpandableControlEditor::PrepareForReadOnlyL |
|
1248 // --------------------------------------------------------- |
|
1249 // |
|
1250 void CMsgExpandableControlEditor::PrepareForReadOnlyL( TBool aReadOnly ) |
|
1251 { |
|
1252 if ( IsReadOnly() == aReadOnly ) |
|
1253 { |
|
1254 return; |
|
1255 } |
|
1256 |
|
1257 SetReadOnly( aReadOnly ); |
|
1258 SetTextSkinColorIdL(); |
|
1259 |
|
1260 if ( aReadOnly ) |
|
1261 { |
|
1262 AddFlagToUserFlags( CEikEdwin::EAvkonDisableCursor ); |
|
1263 } |
|
1264 else |
|
1265 { |
|
1266 RemoveFlagFromUserFlags( CEikEdwin::EAvkonDisableCursor ); |
|
1267 } |
|
1268 |
|
1269 } |
|
1270 |
|
1271 // --------------------------------------------------------- |
|
1272 // CMsgExpandableControlEditor::SetTextSkinColorIdL |
|
1273 // --------------------------------------------------------- |
|
1274 // |
|
1275 void CMsgExpandableControlEditor::SetTextSkinColorIdL() |
|
1276 { |
|
1277 TAknsQsnTextColorsIndex colorId = EAknsCIQsnTextColorsCG6; |
|
1278 if ( !IsReadOnly() && IsFocused() ) |
|
1279 { |
|
1280 colorId = EAknsCIQsnTextColorsCG8; |
|
1281 } |
|
1282 |
|
1283 CEikEdwin::SetTextSkinColorIdL( colorId ); |
|
1284 } |
|
1285 |
|
1286 // --------------------------------------------------------- |
|
1287 // CMsgExpandableControlEditor::IsCursorVisibleL |
|
1288 // --------------------------------------------------------- |
|
1289 // |
|
1290 TBool CMsgExpandableControlEditor::IsCursorVisibleL() |
|
1291 { |
|
1292 TBool result = EFalse; |
|
1293 if ( iTextView ) |
|
1294 { |
|
1295 TPoint cursorPos; |
|
1296 |
|
1297 if ( iTextView->DocPosToXyPosL( CursorPos(), cursorPos ) && |
|
1298 iTextView->ViewRect().Contains( cursorPos ) ) |
|
1299 { |
|
1300 result = ETrue; |
|
1301 } |
|
1302 } |
|
1303 return result; |
|
1304 } |
|
1305 // --------------------------------------------------------- |
|
1306 // CMsgExpandableControlEditor::MsgEditorCustomDraw |
|
1307 // --------------------------------------------------------- |
|
1308 // |
|
1309 CMsgEditorCustomDraw* CMsgExpandableControlEditor::MsgEditorCustomDraw() const |
|
1310 { |
|
1311 return iCustomDraw; |
|
1312 } |
|
1313 |
|
1314 |
|
1315 // --------------------------------------------------------- |
|
1316 // CMsgExpandableControlEditor::SetControlType |
|
1317 // --------------------------------------------------------- |
|
1318 // |
|
1319 void CMsgExpandableControlEditor::SetControlType(TInt actrltype) |
|
1320 { |
|
1321 iControlType = actrltype; |
|
1322 } |
|
1323 // End of File |