21 #include "mesmrlistobserver.h" |
21 #include "mesmrlistobserver.h" |
22 #include "mesmrtitlepaneobserver.h" |
22 #include "mesmrtitlepaneobserver.h" |
23 #include "mesmrmeetingrequestentry.h" |
23 #include "mesmrmeetingrequestentry.h" |
24 #include "cmrimage.h" |
24 #include "cmrimage.h" |
25 #include "nmrlayoutmanager.h" |
25 #include "nmrlayoutmanager.h" |
|
26 #include "nmrbitmapmanager.h" |
|
27 #include "cesmrglobalnote.h" |
26 |
28 |
27 #include <esmrgui.rsg> |
29 #include <esmrgui.rsg> |
28 #include <StringLoader.h> |
30 #include <stringloader.h> |
29 #include <calentry.h> |
31 #include <calentry.h> |
30 #include <AknLayout2ScalableDef.h> |
32 #include <aknlayout2scalabledef.h> |
31 |
33 |
32 // DEBUG |
34 // DEBUG |
33 #include "emailtrace.h" |
35 #include "emailtrace.h" |
34 |
36 |
35 // Unnamed namespace for local definitions and functions |
37 // Unnamed namespace for local definitions and functions |
75 // |
77 // |
76 CESMRViewerDetailedSubjectField::CESMRViewerDetailedSubjectField() |
78 CESMRViewerDetailedSubjectField::CESMRViewerDetailedSubjectField() |
77 { |
79 { |
78 FUNC_LOG; |
80 FUNC_LOG; |
79 SetFieldId ( EESMRFieldDetailedSubject ); |
81 SetFieldId ( EESMRFieldDetailedSubject ); |
|
82 SetFocusType( EESMRHighlightFocus ); |
80 } |
83 } |
81 |
84 |
82 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
83 // CESMRViewerDetailedSubjectField::~CESMRViewerDetailedSubjectField() |
86 // CESMRViewerDetailedSubjectField::~CESMRViewerDetailedSubjectField() |
84 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
85 // |
88 // |
86 CESMRViewerDetailedSubjectField::~CESMRViewerDetailedSubjectField() |
89 CESMRViewerDetailedSubjectField::~CESMRViewerDetailedSubjectField() |
87 { |
90 { |
88 FUNC_LOG; |
91 FUNC_LOG; |
89 iObserver = NULL; |
92 iObserver = NULL; |
90 delete iRichTextViewer; |
|
91 delete iFieldIcon; |
93 delete iFieldIcon; |
92 } |
94 } |
93 |
95 |
94 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
95 // CESMRViewerDetailedSubjectField::NewL() |
97 // CESMRViewerDetailedSubjectField::NewL() |
111 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
112 // |
114 // |
113 void CESMRViewerDetailedSubjectField::ConstructL() |
115 void CESMRViewerDetailedSubjectField::ConstructL() |
114 { |
116 { |
115 FUNC_LOG; |
117 FUNC_LOG; |
116 SetFocusType( EESMRHighlightFocus ); |
118 iFieldIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapOccasion ); |
117 |
|
118 iFieldIcon = CMRImage::NewL( KAknsIIDQgnFscalIndiOccasion ); |
|
119 iFieldIcon->SetParent( this ); |
119 iFieldIcon->SetParent( this ); |
120 |
120 |
121 iRichTextViewer = CESMRRichTextViewer::NewL( this ); |
121 iRichTextViewer = CESMRRichTextViewer::NewL( this ); |
|
122 CESMRField::ConstructL( iRichTextViewer ); // ownership transferred |
122 iRichTextViewer->SetEdwinSizeObserver( this ); |
123 iRichTextViewer->SetEdwinSizeObserver( this ); |
123 iRichTextViewer->SetParent( this ); |
124 iRichTextViewer->SetParent( this ); |
|
125 iRichTextViewer->SetLinkObserver( this ); |
124 } |
126 } |
125 |
127 |
126 // --------------------------------------------------------------------------- |
128 // --------------------------------------------------------------------------- |
127 // CESMRViewerDetailedSubjectField::SetTitlePaneObserver |
129 // CESMRViewerDetailedSubjectField::SetTitlePaneObserver |
128 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
138 // CESMRViewerDetailedSubjectField::MinimumSize |
140 // CESMRViewerDetailedSubjectField::MinimumSize |
139 // --------------------------------------------------------------------------- |
141 // --------------------------------------------------------------------------- |
140 // |
142 // |
141 TSize CESMRViewerDetailedSubjectField::MinimumSize() |
143 TSize CESMRViewerDetailedSubjectField::MinimumSize() |
142 { |
144 { |
143 // Let's calculate the required rect of the iRichTextViewer. |
145 TRect parentRect( Parent()->Rect() ); |
144 // We will not use directly the iRichTextViewer height, because it might |
146 |
145 // not exist, or the height of the viewer might still be incorrect |
147 TRect fieldRect = |
146 TRect richTextViewerRect = RichTextViewerRect(); |
148 NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect(); |
147 |
149 |
148 // We will use as minimum size the parents width |
150 TRect viewerRect( NMRLayoutManager::GetLayoutText( |
149 // but the calculated iRichTextViewers height |
151 fieldRect, |
150 return TSize( Parent()->Size().iWidth, richTextViewerRect.Height() ); |
152 NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() ); |
|
153 |
|
154 // Adjust field size so that there's room for expandable editor. |
|
155 fieldRect.Resize( 0, iSize.iHeight - viewerRect.Height() ); |
|
156 |
|
157 return fieldRect.Size(); |
151 } |
158 } |
152 |
159 |
153 |
160 |
154 // --------------------------------------------------------------------------- |
161 // --------------------------------------------------------------------------- |
155 // CESMRViewerDetailedSubjectField::InitializeL() |
162 // CESMRViewerDetailedSubjectField::InitializeL() |
161 // Setting Font for the rich text viewer |
168 // Setting Font for the rich text viewer |
162 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
169 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
163 Rect(), |
170 Rect(), |
164 NMRLayoutManager::EMRTextLayoutTextEditor ); |
171 NMRLayoutManager::EMRTextLayoutTextEditor ); |
165 |
172 |
166 iRichTextViewer->SetFontL( text.Font(), iLayout ); |
173 iRichTextViewer->SetFontL( text.Font() ); |
|
174 iRichTextViewer->ApplyLayoutChangesL(); |
167 |
175 |
168 // This is called so theme changes will apply when changing theme "on the fly" |
176 // This is called so theme changes will apply when changing theme "on the fly" |
169 if ( IsFocused() ) |
177 if ( IsFocused() ) |
170 { |
178 { |
171 iRichTextViewer->FocusChanged( EDrawNow ); |
179 iRichTextViewer->FocusChanged( EDrawNow ); |
172 } |
180 } |
|
181 iRichTextViewer->SetEventQueue( iEventQueue ); |
173 } |
182 } |
174 |
183 |
175 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
176 // CESMRViewerDetailedSubjectField::InternalizeL() |
185 // CESMRViewerDetailedSubjectField::InternalizeL() |
177 // --------------------------------------------------------------------------- |
186 // --------------------------------------------------------------------------- |
299 |
321 |
300 // --------------------------------------------------------------------------- |
322 // --------------------------------------------------------------------------- |
301 // CESMRViewerDetailedSubjectField::ExecuteGenericCommandL() |
323 // CESMRViewerDetailedSubjectField::ExecuteGenericCommandL() |
302 // --------------------------------------------------------------------------- |
324 // --------------------------------------------------------------------------- |
303 // |
325 // |
304 void CESMRViewerDetailedSubjectField::ExecuteGenericCommandL( TInt aCommand ) |
326 TBool CESMRViewerDetailedSubjectField::ExecuteGenericCommandL( TInt aCommand ) |
305 { |
327 { |
306 FUNC_LOG; |
328 FUNC_LOG; |
|
329 TBool isUsed( EFalse ); |
307 if (aCommand == EESMRCmdClipboardCopy) |
330 if (aCommand == EESMRCmdClipboardCopy) |
308 { |
331 { |
309 iRichTextViewer->CopyCurrentLinkToClipBoardL(); |
332 iRichTextViewer->CopyCurrentLinkToClipBoardL(); |
|
333 isUsed = ETrue; |
310 } |
334 } |
311 else if ( aCommand == EAknSoftkeySelect ) |
335 else if ( aCommand == EAknSoftkeySelect ) |
312 { |
336 { |
313 iRichTextViewer->LinkSelectedL(); |
337 iRichTextViewer->LinkSelectedL(); |
314 } |
338 isUsed = ETrue; |
|
339 } |
|
340 else if ( aCommand == EAknCmdOpen ) |
|
341 { |
|
342 if ( IsLocked() ) |
|
343 { |
|
344 HandleTactileFeedbackL(); |
|
345 |
|
346 CESMRGlobalNote::ExecuteL( |
|
347 CESMRGlobalNote::EESMRUnableToEdit ); |
|
348 isUsed = ETrue; |
|
349 } |
|
350 } |
|
351 return isUsed; |
315 } |
352 } |
316 |
353 |
317 // --------------------------------------------------------------------------- |
354 // --------------------------------------------------------------------------- |
318 // CESMRViewerDetailedSubjectField::SetOutlineFocusL() |
355 // CESMRViewerDetailedSubjectField::SetOutlineFocusL() |
319 // --------------------------------------------------------------------------- |
356 // --------------------------------------------------------------------------- |
320 // |
357 // |
321 void CESMRViewerDetailedSubjectField::SetOutlineFocusL( TBool aFocus ) |
358 void CESMRViewerDetailedSubjectField::SetOutlineFocusL( TBool aFocus ) |
322 { |
359 { |
323 FUNC_LOG; |
360 FUNC_LOG; |
324 CESMRField::SetOutlineFocusL ( aFocus ); |
361 CESMRField::SetOutlineFocusL ( aFocus ); |
325 |
|
326 iRichTextViewer->SetFocus( aFocus ); |
362 iRichTextViewer->SetFocus( aFocus ); |
327 if ( !aFocus ) |
363 |
|
364 if( aFocus ) |
|
365 { |
|
366 SetMiddleSoftkeyL(); |
|
367 } |
|
368 |
|
369 else |
328 { |
370 { |
329 //need to tell action menu that focus has changed |
371 //need to tell action menu that focus has changed |
330 iRichTextViewer->ResetActionMenuL(); |
372 iRichTextViewer->ResetActionMenuL(); |
331 } |
373 } |
332 } |
374 } |
333 |
375 |
334 // --------------------------------------------------------------------------- |
376 // --------------------------------------------------------------------------- |
|
377 // CESMRViewerDetailedSubjectField::GetCursorLineVerticalPos |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 void CESMRViewerDetailedSubjectField::GetCursorLineVerticalPos( |
|
381 TInt& aUpper, |
|
382 TInt& aLower ) |
|
383 { |
|
384 FUNC_LOG; |
|
385 |
|
386 aLower = iRichTextViewer->CurrentLineNumber() * iRichTextViewer->RowHeight(); |
|
387 aUpper = aLower - iRichTextViewer->RowHeight(); |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // CESMRViewerDetailedSubjectField::HandleLongtapEventL |
|
392 // --------------------------------------------------------------------------- |
|
393 // |
|
394 void CESMRViewerDetailedSubjectField::HandleLongtapEventL( |
|
395 const TPoint& aPosition ) |
|
396 { |
|
397 FUNC_LOG; |
|
398 |
|
399 if ( iRichTextViewer->Rect().Contains( aPosition ) ) |
|
400 { |
|
401 iRichTextViewer->LinkSelectedL(); |
|
402 } |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CESMRViewerDetailedSubjectField::LockL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CESMRViewerDetailedSubjectField::LockL() |
|
410 { |
|
411 FUNC_LOG; |
|
412 if( IsLocked() ) |
|
413 { |
|
414 return; |
|
415 } |
|
416 |
|
417 CESMRField::LockL(); |
|
418 |
|
419 delete iPriorityIcon; |
|
420 iPriorityIcon = NULL; |
|
421 iPriorityIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapLockField, ETrue ); |
|
422 iPriorityIcon->SetParent( this ); |
|
423 } |
|
424 |
|
425 // --------------------------------------------------------------------------- |
|
426 // CESMRViewerDetailedSubjectField::SetMiddleSoftkeyL |
|
427 // --------------------------------------------------------------------------- |
|
428 // |
|
429 void CESMRViewerDetailedSubjectField::SetMiddleSoftkeyL() |
|
430 { |
|
431 FUNC_LOG; |
|
432 const CESMRRichTextLink* link = iRichTextViewer->GetSelectedLink(); |
|
433 if( link ) |
|
434 { |
|
435 if ( ( link->Type() == CESMRRichTextLink::ETypeURL ) || |
|
436 ( link->Type() == CESMRRichTextLink::ETypeEmail ) || |
|
437 ( link->Type() == CESMRRichTextLink::ETypePhoneNumber ) ) |
|
438 { |
|
439 SetMiddleSoftKeyVisible( ETrue ); |
|
440 } |
|
441 else |
|
442 { |
|
443 RestoreMiddleSoftKeyL(); |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CESMRViewerDetailedSubjectField::HandleRichTextLinkSelection |
|
451 // --------------------------------------------------------------------------- |
|
452 // |
|
453 TBool CESMRViewerDetailedSubjectField::HandleRichTextLinkSelection( |
|
454 const CESMRRichTextLink* /*aLink*/ ) |
|
455 { |
|
456 TBool result = EFalse; |
|
457 |
|
458 // No implementation yet: waiting for UI spec. |
|
459 |
|
460 return result; |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------------------------- |
335 // CESMRViewerDetailedSubjectField::CountComponentControls |
464 // CESMRViewerDetailedSubjectField::CountComponentControls |
336 // --------------------------------------------------------------------------- |
465 // --------------------------------------------------------------------------- |
337 // |
466 // |
338 TInt CESMRViewerDetailedSubjectField::CountComponentControls() const |
467 TInt CESMRViewerDetailedSubjectField::CountComponentControls() const |
339 { |
468 { |
372 // CESMRViewerDetailedSubjectField::SizeChanged |
510 // CESMRViewerDetailedSubjectField::SizeChanged |
373 // --------------------------------------------------------------------------- |
511 // --------------------------------------------------------------------------- |
374 // |
512 // |
375 void CESMRViewerDetailedSubjectField::SizeChanged( ) |
513 void CESMRViewerDetailedSubjectField::SizeChanged( ) |
376 { |
514 { |
377 TRect rect = Rect(); |
515 TRect rect( Rect() ); |
378 |
516 |
379 // LAYOUTING FIELD ICON |
517 TAknLayoutRect rowLayoutRect( |
|
518 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) ); |
|
519 TRect rowRect( rowLayoutRect.Rect() ); |
|
520 |
|
521 // Layouting field icon |
380 if( iFieldIcon ) |
522 if( iFieldIcon ) |
381 { |
523 { |
382 TAknWindowComponentLayout iconLayout = |
524 TAknWindowComponentLayout iconLayout( |
383 NMRLayoutManager::GetWindowComponentLayout( |
525 NMRLayoutManager::GetWindowComponentLayout( |
384 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
526 NMRLayoutManager::EMRLayoutSingleRowAColumnGraphic ) ); |
385 AknLayoutUtils::LayoutImage( iFieldIcon, rect, iconLayout ); |
527 AknLayoutUtils::LayoutControl( iFieldIcon, rowRect, iconLayout ); |
386 } |
528 } |
387 |
529 |
388 // LAYOUTING FIELD BACKGROUND |
530 // Layouting priority icon |
389 TAknLayoutRect bgLayoutRect = |
531 if( iPriorityIcon ) |
390 NMRLayoutManager::GetLayoutRect( |
532 { |
391 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
533 TAknWindowComponentLayout iconLayout( |
392 TRect bgRect( bgLayoutRect.Rect() ); |
534 NMRLayoutManager::GetWindowComponentLayout( |
393 // Move focus rect so that it's relative to field's position |
535 NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) ); |
|
536 AknLayoutUtils::LayoutImage( iPriorityIcon, rowRect, iconLayout ); |
|
537 } |
|
538 |
|
539 TAknLayoutText viewerLayoutText; |
|
540 |
|
541 if( iPriorityIcon ) |
|
542 { |
|
543 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
|
544 NMRLayoutManager::EMRTextLayoutSingleRowEditorText ); |
|
545 } |
|
546 else |
|
547 { |
|
548 viewerLayoutText = NMRLayoutManager::GetLayoutText( rowRect, |
|
549 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
550 } |
|
551 |
|
552 // Layouting viewer field |
|
553 TRect viewerRect( viewerLayoutText.TextRect() ); |
|
554 |
|
555 // Resize height according to actual height required by edwin. |
|
556 viewerRect.Resize( 0, iSize.iHeight - viewerRect.Height() ); |
|
557 iRichTextViewer->SetRect( viewerRect ); |
|
558 |
|
559 // Layouting focus |
|
560 TRect bgRect( viewerRect ); |
|
561 |
|
562 // Move focus rect so that it's relative to field's position. |
394 bgRect.Move( -Position() ); |
563 bgRect.Move( -Position() ); |
395 SetFocusRect( bgRect ); |
564 SetFocusRect( bgRect ); |
396 |
565 |
397 |
566 // Failures are ignored. |
398 // LAYOUTING FIELD TEXT VIEWER |
567 TRAP_IGNORE( |
399 if( iRichTextViewer ) |
568 // Try setting font |
400 { |
569 iRichTextViewer->SetFontL( viewerLayoutText.Font() ); |
401 iRichTextViewer->SetRect( RichTextViewerRect() ); |
570 // Try applying changes |
402 } |
571 iRichTextViewer->ApplyLayoutChangesL(); |
|
572 ); |
403 } |
573 } |
404 |
574 |
405 // --------------------------------------------------------------------------- |
575 // --------------------------------------------------------------------------- |
406 // CESMRViewerDetailedSubjectField::SetContainerWindowL |
576 // CESMRViewerDetailedSubjectField::SetContainerWindowL |
407 // --------------------------------------------------------------------------- |
577 // --------------------------------------------------------------------------- |
408 // |
578 // |
409 void CESMRViewerDetailedSubjectField::SetContainerWindowL( |
579 void CESMRViewerDetailedSubjectField::SetContainerWindowL( |
410 const CCoeControl& aContainer ) |
580 const CCoeControl& aContainer ) |
411 { |
581 { |
412 CCoeControl::SetContainerWindowL( aContainer ); |
582 CCoeControl::SetContainerWindowL( aContainer ); |
413 iRichTextViewer->SetContainerWindowL( aContainer ); |
583 iRichTextViewer->SetContainerWindowL( aContainer ); |
414 } |
584 iRichTextViewer->SetParent( this ); |
415 |
|
416 // --------------------------------------------------------------------------- |
|
417 // CESMRViewerDetailedSubjectField::RichTextViewerRect |
|
418 // --------------------------------------------------------------------------- |
|
419 // |
|
420 TRect CESMRViewerDetailedSubjectField::RichTextViewerRect() |
|
421 { |
|
422 TRect rect = Rect(); |
|
423 |
|
424 TAknTextComponentLayout edwinLayout = NMRLayoutManager::GetTextComponentLayout( |
|
425 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
426 |
|
427 // Text layout rect for one line viewer |
|
428 TAknLayoutText textLayout; |
|
429 textLayout.LayoutText( rect, edwinLayout ); |
|
430 TRect textLayoutRect = textLayout.TextRect(); |
|
431 |
|
432 TRect viewerRect = textLayoutRect; |
|
433 |
|
434 // If iRichTextViewer has lines and iSize has been set, |
|
435 // we will use iSize.iHeight as the viewers height |
|
436 if( iLineCount > 0 && iSize.iHeight > 0 ) |
|
437 { |
|
438 viewerRect.SetHeight( iSize.iHeight ); |
|
439 } |
|
440 // Otherwise we will use one row height as the height of the |
|
441 // iRichTextViewer |
|
442 else |
|
443 { |
|
444 TAknLayoutRect rowLayoutRect = |
|
445 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
|
446 viewerRect.SetHeight( rowLayoutRect.Rect().Height() ); |
|
447 } |
|
448 |
|
449 return viewerRect; |
|
450 } |
585 } |
451 |
586 |
452 //EOF |
587 //EOF |