|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Implementation of CCbsUiMsgViewContainer class. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <bldvariant.hrh> // for feature flags |
|
22 #include <eikenv.h> |
|
23 #include <AknLayoutDef.h> // enum TAknLayoutId |
|
24 #include <aknenv.h> // for iAvkonEnv |
|
25 #include <AknUtils.h> // AknLayoutUtils |
|
26 #include <sysutil.h> // FFS critical level check |
|
27 #include <eikrted.h> |
|
28 #include <barsread.h> |
|
29 #include <txtrich.h> |
|
30 #include <calslbs.h> |
|
31 #include <baclipb.h> |
|
32 #include <aknkeys.h> |
|
33 #include <applayout.cdl.h> // Multiline_Message_writing_texts_Line_3 |
|
34 #include <AknLayout2ScalableDef.h> // TAknLayoutScalableParameterLimits |
|
35 #include <aknlayoutscalable_apps.cdl.h> // list_single_mce_message_pane_ParamLimits().iRows |
|
36 #include <AknDef.h> // KEikDynamicLayoutVariantSwitch |
|
37 #include <AknsConstants.h> // KAknsMessageSkinChange |
|
38 #include <aknappui.h> |
|
39 #include <AknsBasicBackgroundControlContext.h> // CAknsBasicBackgroundControlContext |
|
40 #include <AknsUtils.h> // MAknsSkinInstance |
|
41 #include <AknsDrawUtils.h> // AknsDrawUtils |
|
42 #include <cbsuiApp.rsg> |
|
43 #include "CbsUiId.h" |
|
44 #include <csxhelp/cbs.hlp.hrh> |
|
45 #include "CCbsUIMsgViewContainer.h" |
|
46 #include "CCbsUIMsgView.h" |
|
47 #include "Cbsuiapp.hrh" |
|
48 #include "CbsUiPanic.h" |
|
49 #include <gdi.h> |
|
50 |
|
51 |
|
52 |
|
53 // LOCAL CONSTANTS AND MACROS |
|
54 const TInt KEditorNumOfLines = 7; |
|
55 const TInt KFirstScreen = 0; |
|
56 const TInt KOneScreen = 1; |
|
57 const TInt KMsgNumberOfControls = 1; |
|
58 const TInt KMsgControlIndexEditor = 0; |
|
59 |
|
60 |
|
61 // ================= MEMBER FUNCTIONS ======================= |
|
62 |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 CCbsUiMsgViewContainer::CCbsUiMsgViewContainer( CCbsUiMsgView& aMsgView ) |
|
66 : iMsgView(aMsgView) |
|
67 { |
|
68 } |
|
69 |
|
70 // Symbian OS default constructor can leave. |
|
71 void CCbsUiMsgViewContainer::ConstructL( const TRect& aRect ) |
|
72 { |
|
73 CreateWindowL(); |
|
74 SetMopParent(&iMsgView); |
|
75 |
|
76 iEditor = CreateEditorL(); |
|
77 SetReadOnly(ETrue); |
|
78 |
|
79 SetRect(aRect); |
|
80 |
|
81 // for Skin Support, Create background control context: |
|
82 iBackGroundControlContext = CAknsBasicBackgroundControlContext::NewL( |
|
83 KAknsIIDQsnBgAreaMain, // Default mainpane skinning |
|
84 Rect(), // Layout to the entire client rect |
|
85 EFalse ); |
|
86 if ( iBackGroundControlContext ) |
|
87 { |
|
88 iEditor->SetSkinBackgroundControlContextL( iBackGroundControlContext ); |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 // Two-phased constructor. |
|
94 CCbsUiMsgViewContainer* CCbsUiMsgViewContainer::NewL( CCbsUiMsgView& aMsgView, |
|
95 const TRect& aRect ) |
|
96 { |
|
97 CCbsUiMsgViewContainer* self = new (ELeave) |
|
98 CCbsUiMsgViewContainer(aMsgView); |
|
99 |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(aRect); |
|
102 CleanupStack::Pop(); |
|
103 return self; |
|
104 } |
|
105 |
|
106 // Destructor |
|
107 CCbsUiMsgViewContainer::~CCbsUiMsgViewContainer() |
|
108 { |
|
109 delete iBackGroundControlContext; |
|
110 delete iEditor; |
|
111 delete iSBFrame; |
|
112 } |
|
113 |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CCbsUiMsgViewContainer::CountComponentControls |
|
117 // |
|
118 // |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 TInt CCbsUiMsgViewContainer::CountComponentControls() const |
|
122 { |
|
123 TInt countScrollBarComponents( 0 ); |
|
124 if ( iSBFrame ) |
|
125 { |
|
126 countScrollBarComponents = iSBFrame->CountComponentControls(); |
|
127 } |
|
128 return KMsgNumberOfControls + countScrollBarComponents; |
|
129 } |
|
130 |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CCbsUiMsgViewContainer::ComponentControl |
|
134 // |
|
135 // |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 CCoeControl* CCbsUiMsgViewContainer::ComponentControl( TInt aIndex ) const |
|
139 { |
|
140 CCoeControl* control = NULL; |
|
141 |
|
142 TInt countScrollBarComponents( 0 ); |
|
143 if ( iSBFrame ) |
|
144 { |
|
145 countScrollBarComponents = iSBFrame->CountComponentControls(); |
|
146 } |
|
147 |
|
148 switch ( aIndex ) |
|
149 { |
|
150 case KMsgControlIndexEditor: |
|
151 control = iEditor; |
|
152 break; |
|
153 default: |
|
154 if ( iSBFrame |
|
155 && aIndex >= KMsgNumberOfControls |
|
156 && aIndex < countScrollBarComponents + KMsgNumberOfControls ) |
|
157 { |
|
158 control = iSBFrame->ComponentControl( aIndex - KMsgNumberOfControls ); |
|
159 } |
|
160 else |
|
161 { |
|
162 control = NULL; |
|
163 } |
|
164 break; |
|
165 } |
|
166 return control; |
|
167 } |
|
168 |
|
169 |
|
170 // --------------------------------------------------------- |
|
171 // CCbsUiMsgViewContainer::OfferKeyEventL |
|
172 // |
|
173 // |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 TKeyResponse CCbsUiMsgViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
177 TEventCode /*aType*/ ) |
|
178 { |
|
179 __ASSERT_DEBUG( iEditor, CbsUiPanic(EEditorNullError) ); |
|
180 |
|
181 switch ( aKeyEvent.iCode ) |
|
182 { |
|
183 case EKeyLeftArrow: |
|
184 { |
|
185 if( AknLayoutUtils::LayoutMirrored() ) |
|
186 { |
|
187 iMsgView.MoveToNextMessageL(); |
|
188 } |
|
189 else |
|
190 { |
|
191 iMsgView.MoveToPreviousMessageL(); |
|
192 } |
|
193 break; |
|
194 } |
|
195 case EKeyRightArrow: |
|
196 { |
|
197 if( AknLayoutUtils::LayoutMirrored() ) |
|
198 { |
|
199 iMsgView.MoveToPreviousMessageL(); |
|
200 } |
|
201 else |
|
202 { |
|
203 iMsgView.MoveToNextMessageL(); |
|
204 } |
|
205 break; |
|
206 } |
|
207 case EKeyUpArrow : |
|
208 { |
|
209 ScrollMessageUpL(); |
|
210 break; |
|
211 } |
|
212 case EKeyDownArrow: |
|
213 { |
|
214 ScrollMessageDownL(); |
|
215 break; |
|
216 } |
|
217 case EKeyOK: |
|
218 { |
|
219 iMsgView.ProcessCommandL( ECbsUiappCmdOkKey ); |
|
220 break; |
|
221 } |
|
222 case EKeyBackspace: |
|
223 { |
|
224 iMsgView.ProcessCommandL( ECbsUiappCmdMsgMenuDelete ); |
|
225 break; |
|
226 } |
|
227 default: |
|
228 { |
|
229 break; |
|
230 } |
|
231 } |
|
232 |
|
233 return EKeyWasConsumed; |
|
234 } |
|
235 |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CCbsUiMsgViewContainer::UpdateMessageL |
|
239 // |
|
240 // |
|
241 // --------------------------------------------------------- |
|
242 // |
|
243 void CCbsUiMsgViewContainer::UpdateMessageL( const TDesC& aMessage ) |
|
244 { |
|
245 SetData16L(aMessage); |
|
246 |
|
247 InitializeMessageInfoL(); |
|
248 |
|
249 CreateScrollBarFrameL(); |
|
250 UpdateScrollIndicatorL(); |
|
251 |
|
252 iEditor->DrawNow(); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------- |
|
256 // CCbsUiMsgViewContainer::SizeChanged |
|
257 // |
|
258 // |
|
259 // --------------------------------------------------------- |
|
260 // |
|
261 void CCbsUiMsgViewContainer::SizeChanged() |
|
262 { |
|
263 if ( iEditor ) |
|
264 { |
|
265 TRAPD( ignore, iEditor->SelectAllL() ); // This is needed before calling layoutedwin! |
|
266 if( ignore ) |
|
267 { |
|
268 ignore = KErrNone; //Prevent ARMV5 compilation varning |
|
269 } |
|
270 if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
271 { |
|
272 TAknLayoutScalableParameterLimits scalbleParamLimits; |
|
273 scalbleParamLimits = AknLayoutScalable_Apps::list_single_mce_message_pane_ParamLimits(); |
|
274 AknLayoutUtils::LayoutEdwin( iEditor, Rect(), AppLayout::Multiline_Message_writing_texts_Line_3(scalbleParamLimits.LastRow() ) ); |
|
275 } |
|
276 else |
|
277 { |
|
278 AknLayoutUtils::LayoutEdwin( iEditor, Rect(), AppLayout::Multiline_Message_writing_texts_Line_3( KEditorNumOfLines ) ); |
|
279 } |
|
280 if ( iBackGroundControlContext ) |
|
281 { |
|
282 TRAPD( ignore, iEditor->SetSkinBackgroundControlContextL( iBackGroundControlContext ) ); |
|
283 if( ignore ) |
|
284 { |
|
285 ignore = KErrNone; //Prevent ARMV5 compilation varning |
|
286 } |
|
287 } |
|
288 iEditor->DrawNow(); |
|
289 } |
|
290 } |
|
291 |
|
292 |
|
293 // --------------------------------------------------------- |
|
294 // CCbsUiMsgViewConctainer::CreateEditorL |
|
295 // |
|
296 // |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 CEikRichTextEditor* CCbsUiMsgViewContainer::CreateEditorL() const |
|
300 { |
|
301 TResourceReader reader; |
|
302 iCoeEnv->CreateResourceReaderLC(reader, R_MSG_READER); |
|
303 |
|
304 CEikRichTextEditor* editor = new (ELeave) CEikRichTextEditor; |
|
305 CleanupStack::PushL( editor ); |
|
306 editor->SetContainerWindowL(*this); |
|
307 editor->ConstructFromResourceL( reader ); |
|
308 CleanupStack::Pop(); // editor |
|
309 CleanupStack::PopAndDestroy(); // reader |
|
310 |
|
311 __ASSERT_DEBUG( editor, CbsUiPanic(EEditorNullError) ); |
|
312 |
|
313 return editor; |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------- |
|
317 // CCbsUiMsgViewConctainer::Draw |
|
318 // |
|
319 // |
|
320 // --------------------------------------------------------- |
|
321 // |
|
322 void CCbsUiMsgViewContainer::Draw( const TRect& aRect ) const |
|
323 { |
|
324 CWindowGc& aGc = SystemGc(); |
|
325 |
|
326 // for clearing gap between editor and the view rect |
|
327 if ( IsReadyToDraw() ) |
|
328 { |
|
329 aGc.SetBrushColor( AKN_LAF_COLOR (0) ); |
|
330 DrawUtils::ClearBetweenRects( aGc, aRect, iEditor->Rect() ); |
|
331 if ( iBackGroundControlContext ) |
|
332 {//Draw the skin background |
|
333 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
334 AknsDrawUtils::Background( skin, iBackGroundControlContext, this, aGc, aRect ); |
|
335 } |
|
336 } |
|
337 } |
|
338 |
|
339 |
|
340 // --------------------------------------------------------- |
|
341 // CCbsUiMsgViewContainer::InitializeMessageInfoL |
|
342 // |
|
343 // |
|
344 // --------------------------------------------------------- |
|
345 // |
|
346 void CCbsUiMsgViewContainer::InitializeMessageInfoL() |
|
347 { |
|
348 |
|
349 iEditor->TextLayout()->SetAmountToFormat( CTextLayout::EFFormatAllText ); |
|
350 |
|
351 iEditor->CreateTextViewL(); |
|
352 iEditor->NotifyNewFormatL(); |
|
353 TInt numberOfLines = iEditor->TextLayout()->NumFormattedLines(); |
|
354 |
|
355 if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
356 { |
|
357 TInt linesInScreen; |
|
358 TAknLayoutScalableParameterLimits scalbleParamLimits; |
|
359 scalbleParamLimits = AknLayoutScalable_Apps::list_single_mce_message_pane_ParamLimits(); |
|
360 linesInScreen = scalbleParamLimits.LastRow(); |
|
361 iNumberOfScreens = ( numberOfLines - 1 ) / linesInScreen + 1; |
|
362 } |
|
363 else |
|
364 { |
|
365 iNumberOfScreens = ( numberOfLines - 1 ) / KEditorNumOfLines + 1; |
|
366 } |
|
367 |
|
368 iCurrentScreen = KFirstScreen; |
|
369 } |
|
370 |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // CCbsUiMsgViewContainer::CreateScrollBarFrameL |
|
374 // |
|
375 // |
|
376 // --------------------------------------------------------- |
|
377 // |
|
378 void CCbsUiMsgViewContainer::CreateScrollBarFrameL() |
|
379 { |
|
380 if ( !iSBFrame ) |
|
381 { |
|
382 iSBFrame = new (ELeave) CEikScrollBarFrame( iEditor, this, ETrue ); |
|
383 } |
|
384 |
|
385 CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>( iEikonEnv->EikAppUi() ); |
|
386 if ( AknLayoutUtils::DefaultScrollBarType( appUi ) == CEikScrollBarFrame::EDoubleSpan ) |
|
387 { |
|
388 // For EDoubleSpan type scrollbar |
|
389 iSBFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse ); // non-window owning scrollbar |
|
390 iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan ); |
|
391 iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto ); |
|
392 TAknWindowLineLayout scrollPane = AknLayoutScalable_Apps::scroll_pane_cp017().LayoutLine(); |
|
393 AknLayoutUtils::LayoutVerticalScrollBar( iSBFrame, Rect(), scrollPane ); |
|
394 } |
|
395 else |
|
396 { |
|
397 // For EArrowHead type scrollbar |
|
398 iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EArrowHead ); |
|
399 iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto ); |
|
400 } |
|
401 ActivateL(); |
|
402 } |
|
403 |
|
404 |
|
405 // --------------------------------------------------------- |
|
406 // CCbsUiMsgViewContainer::UpdateScrollIndicatorL |
|
407 // |
|
408 // |
|
409 // --------------------------------------------------------- |
|
410 // |
|
411 void CCbsUiMsgViewContainer::UpdateScrollIndicatorL() const |
|
412 { |
|
413 if ( !iSBFrame ) |
|
414 { |
|
415 return; |
|
416 } |
|
417 |
|
418 |
|
419 TEikScrollBarModel hSbarModel; |
|
420 TEikScrollBarModel vSbarModel; |
|
421 vSbarModel.iThumbSpan = 1; |
|
422 |
|
423 vSbarModel.iThumbPosition = iCurrentScreen; // where is the position |
|
424 // how many items |
|
425 // if there is only one screen we don't need scroll bars (= 0) |
|
426 |
|
427 if ( iNumberOfScreens == KOneScreen ) |
|
428 { |
|
429 vSbarModel.iScrollSpan = 0; |
|
430 iSBFrame->SetScrollBarVisibilityL( |
|
431 CEikScrollBarFrame::EOff, |
|
432 CEikScrollBarFrame::EOff ); |
|
433 } |
|
434 else |
|
435 { |
|
436 vSbarModel.iScrollSpan = iNumberOfScreens; |
|
437 iSBFrame->SetScrollBarVisibilityL( |
|
438 CEikScrollBarFrame::EOff, |
|
439 CEikScrollBarFrame::EAuto ); |
|
440 } |
|
441 |
|
442 if ( iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan ) |
|
443 { |
|
444 // For EDoubleSpan type scrollbar |
|
445 TAknDoubleSpanScrollBarModel hDsSbarModel( hSbarModel ); |
|
446 TAknDoubleSpanScrollBarModel vDsSbarModel( vSbarModel ); |
|
447 |
|
448 TEikScrollBarFrameLayout layout; |
|
449 layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant; |
|
450 TRect inclusiveRect( Rect( ) ); // We need to have two of these variables |
|
451 TRect clientRect( Rect( ) ); |
|
452 |
|
453 iSBFrame->TileL( &hDsSbarModel, &vDsSbarModel, clientRect, inclusiveRect, layout ); |
|
454 iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition ); |
|
455 } |
|
456 else |
|
457 { |
|
458 iSBFrame->Tile( &vSbarModel ); |
|
459 iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition ); |
|
460 } |
|
461 iSBFrame->DrawScrollBarsNow(); |
|
462 |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------- |
|
466 // CCbsUiMsgViewContainer::UpdateCurrentScreen |
|
467 // |
|
468 // |
|
469 // --------------------------------------------------------- |
|
470 // |
|
471 void CCbsUiMsgViewContainer::UpdateCurrentScreen( TBool aIncrease ) |
|
472 { |
|
473 if ( aIncrease ) |
|
474 { |
|
475 if ( iCurrentScreen < iNumberOfScreens - 1 ) |
|
476 { |
|
477 iCurrentScreen++; |
|
478 } |
|
479 } |
|
480 else |
|
481 { |
|
482 if ( iCurrentScreen > KFirstScreen ) |
|
483 { |
|
484 iCurrentScreen--; |
|
485 } |
|
486 } |
|
487 |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------- |
|
491 // CCbsUiMsgViewContainer::SetReadOnly |
|
492 // |
|
493 // |
|
494 // --------------------------------------------------------- |
|
495 // |
|
496 void CCbsUiMsgViewContainer::SetReadOnly( TBool aReadOnly ) |
|
497 { |
|
498 __ASSERT_DEBUG(iEditor, CbsUiPanic(EErrNullPointer) ); |
|
499 iEditor->SetReadOnly(aReadOnly); |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // CCbsUiMsgViewContainer::SetDataContentL |
|
504 // |
|
505 // |
|
506 // --------------------------------------------------------- |
|
507 // |
|
508 void CCbsUiMsgViewContainer::SetDataContentL( CRichText& aText ) |
|
509 { |
|
510 iEditor->SetDocumentContentL(aText); |
|
511 iEditor->SelectAllL(); // This is needed before calling layoutedwin! |
|
512 |
|
513 |
|
514 if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
515 { |
|
516 TAknLayoutScalableParameterLimits scalbleParamLimits; |
|
517 scalbleParamLimits = AknLayoutScalable_Apps::list_single_mce_message_pane_ParamLimits(); |
|
518 AknLayoutUtils::LayoutEdwin( iEditor, Rect(), AppLayout::Multiline_Message_writing_texts_Line_3(scalbleParamLimits.LastRow() ) ); |
|
519 } |
|
520 else |
|
521 { |
|
522 AknLayoutUtils::LayoutEdwin( iEditor, Rect(), AppLayout::Multiline_Message_writing_texts_Line_3( KEditorNumOfLines ) ); |
|
523 } |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------- |
|
527 // CCbsUiMsgViewContainer::SetData16L |
|
528 // |
|
529 // |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 void CCbsUiMsgViewContainer::SetData16L( const TDesC& aBuf ) |
|
533 { |
|
534 __ASSERT_DEBUG(aBuf.Length() > 0, CbsUiPanic(EErrInvalidValue) ); |
|
535 |
|
536 CParaFormatLayer* globalParaLayer = CParaFormatLayer::NewL(); |
|
537 CleanupStack::PushL(globalParaLayer); |
|
538 |
|
539 CCharFormatLayer* globalCharLayer = NULL; |
|
540 TRgb textColor; |
|
541 |
|
542 TCharFormat charFormat; |
|
543 TCharFormatMask formatMask; |
|
544 |
|
545 ( reinterpret_cast< CGlobalText* >( iEditor->Text() ) ) |
|
546 ->GetCharFormat( charFormat, formatMask, 0, 0 ); |
|
547 |
|
548 TInt error = AknsUtils::GetCachedColor( |
|
549 AknsUtils::SkinInstance(), |
|
550 textColor, |
|
551 KAknsIIDQsnTextColors, |
|
552 EAknsCIQsnTextColorsCG6 ); |
|
553 |
|
554 if ( error != KErrNone ) |
|
555 { |
|
556 textColor = KRgbBlack; |
|
557 } |
|
558 |
|
559 charFormat.iFontPresentation.iTextColor = textColor; |
|
560 formatMask.SetAll(); |
|
561 |
|
562 globalCharLayer = CCharFormatLayer::NewL( charFormat, formatMask ); |
|
563 CleanupStack::PushL( globalCharLayer ); |
|
564 |
|
565 CRichText* richText = CRichText::NewL( globalParaLayer, globalCharLayer ); |
|
566 CleanupStack::PushL( richText ); |
|
567 |
|
568 TInt length( aBuf.Size() / 2 ); |
|
569 |
|
570 for (TInt i = 0; i < length; i++) |
|
571 { |
|
572 if ( aBuf[i] == EKeyLineFeed ) |
|
573 { |
|
574 richText->InsertL( i, CEditableText::EParagraphDelimiter ); |
|
575 } |
|
576 else |
|
577 { |
|
578 richText->InsertL( i, aBuf[i] ); |
|
579 } |
|
580 } |
|
581 |
|
582 SetDataContentL( *richText ); |
|
583 |
|
584 iEditor->SetCharFormatLayer( globalCharLayer ); |
|
585 |
|
586 CleanupStack::PopAndDestroy(); // richText |
|
587 CleanupStack::Pop(); // globalCharLayer |
|
588 CleanupStack::PopAndDestroy(); // globalParaLayer |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------- |
|
592 // CCbsUiMsgViewContainer::GetEditor |
|
593 // |
|
594 // |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 CRichText* CCbsUiMsgViewContainer::GetEditor() const |
|
598 { |
|
599 __ASSERT_DEBUG(iEditor->RichText()->LdDocumentLength() > 0, |
|
600 CbsUiPanic(EErrInvalidValue) ); |
|
601 |
|
602 return iEditor->RichText(); |
|
603 } |
|
604 |
|
605 |
|
606 // --------------------------------------------------------- |
|
607 // CCbsUiMsgViewContainer::CopyToClipboard |
|
608 // |
|
609 // |
|
610 // --------------------------------------------------------- |
|
611 // |
|
612 void CCbsUiMsgViewContainer::CopyToClipboardL() const |
|
613 { |
|
614 TInt msgLength; |
|
615 |
|
616 msgLength = iEditor->TextLength(); |
|
617 if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iCoeEnv->FsSession(), 2 * msgLength ) ) |
|
618 { |
|
619 User::Leave( KErrDiskFull ); |
|
620 } |
|
621 |
|
622 CPlainText* plainText = CPlainText::NewL(); |
|
623 |
|
624 CleanupStack::PushL(plainText); |
|
625 plainText->InsertL( 0, iEditor->RichText()->Read(0) ); |
|
626 plainText->ConvertAllFieldsToText(); |
|
627 |
|
628 CClipboard* cb = CClipboard::NewForWritingLC( iCoeEnv->FsSession() ); |
|
629 plainText->CopyToStoreL( |
|
630 cb->Store(), |
|
631 cb->StreamDictionary(), |
|
632 0, |
|
633 plainText->DocumentLength() ); |
|
634 |
|
635 cb->CommitL(); |
|
636 CleanupStack::PopAndDestroy(2); //cb, plainText |
|
637 } |
|
638 |
|
639 |
|
640 // ---------------------------------------------------- |
|
641 // CCbsUiMsgViewContainer::HandleResourceChange |
|
642 // |
|
643 // |
|
644 // ---------------------------------------------------- |
|
645 void CCbsUiMsgViewContainer::HandleResourceChange( TInt aType ) |
|
646 { |
|
647 CCoeControl::HandleResourceChange( aType ); |
|
648 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
649 { |
|
650 TRAPD( ignore, iMsgView.HandleRectChangeInContainerL() ); |
|
651 if ( iBackGroundControlContext ) |
|
652 { |
|
653 iBackGroundControlContext->SetRect( Rect() ); |
|
654 } |
|
655 |
|
656 if( ignore ) |
|
657 { |
|
658 ignore = KErrNone; //Prevent ARMV5 compilation varning |
|
659 } |
|
660 } |
|
661 else |
|
662 { |
|
663 if( ( aType == KAknsMessageSkinChange ) && ( iBackGroundControlContext ) ) |
|
664 { |
|
665 TRAPD( ignore, iEditor->SetSkinBackgroundControlContextL( iBackGroundControlContext ) ); |
|
666 if( ignore ) |
|
667 { |
|
668 ignore = KErrNone; //Prevent ARMV5 compilation varning |
|
669 } |
|
670 } |
|
671 } |
|
672 |
|
673 } |
|
674 |
|
675 |
|
676 // ---------------------------------------------------- |
|
677 // CCbsUiMsgViewContainer::HandleScrollEventL |
|
678 // ---------------------------------------------------- |
|
679 void CCbsUiMsgViewContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, |
|
680 TEikScrollEvent aEventType ) |
|
681 { |
|
682 switch( aEventType ) |
|
683 { |
|
684 case EEikScrollUp: |
|
685 case EEikScrollPageUp: |
|
686 { |
|
687 ScrollMessageUpL(); |
|
688 break; |
|
689 } |
|
690 case EEikScrollDown: |
|
691 case EEikScrollPageDown: |
|
692 { |
|
693 ScrollMessageDownL(); |
|
694 break; |
|
695 } |
|
696 case EEikScrollThumbDragVert: |
|
697 { |
|
698 if( aScrollBar->ThumbPosition() > iCurrentScreen ) |
|
699 { |
|
700 ScrollMessageDownL(); |
|
701 } |
|
702 else if ( aScrollBar->ThumbPosition() < iCurrentScreen ) |
|
703 { |
|
704 ScrollMessageUpL(); |
|
705 } |
|
706 break; |
|
707 } |
|
708 default: |
|
709 break; |
|
710 } |
|
711 } |
|
712 |
|
713 // ---------------------------------------------------- |
|
714 // CCbsUiMsgViewContainer::ScrollMessageUpL |
|
715 // ---------------------------------------------------- |
|
716 void CCbsUiMsgViewContainer::ScrollMessageUpL() |
|
717 { |
|
718 if( iCurrentScreen > 0 ) |
|
719 { |
|
720 iEditor->MoveDisplayL( TCursorPosition::EFPageUp ); |
|
721 iEditor->MoveDisplayL( TCursorPosition::EFLineUp ); |
|
722 UpdateCurrentScreen( EFalse ); |
|
723 UpdateScrollIndicatorL(); |
|
724 } |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------- |
|
728 // CCbsUiMsgViewContainer::ScrollMessageDownL |
|
729 // ---------------------------------------------------- |
|
730 void CCbsUiMsgViewContainer::ScrollMessageDownL() |
|
731 { |
|
732 if( iCurrentScreen < iNumberOfScreens-1 ) |
|
733 { |
|
734 iEditor->MoveDisplayL( TCursorPosition::EFPageDown ); |
|
735 iEditor->MoveDisplayL( TCursorPosition::EFLineDown ); |
|
736 UpdateCurrentScreen( ETrue ); |
|
737 UpdateScrollIndicatorL(); |
|
738 } |
|
739 } |
|
740 |
|
741 // --------------------------------------------------------- |
|
742 // CCbsUiMsgViewContainer::GetHelpContext |
|
743 // |
|
744 // Gets the control's help context. |
|
745 // --------------------------------------------------------- |
|
746 // |
|
747 void CCbsUiMsgViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
748 { |
|
749 aContext.iMajor = TUid::Uid(KUidCbsUiappDef); |
|
750 aContext.iContext = KCBS_HLP_MSG; |
|
751 } |
|
752 |
|
753 |
|
754 // End of File |