|
1 /* |
|
2 * Copyright (c) 2007 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: compose view container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "emailtrace.h" |
|
22 #include <AknIconUtils.h> |
|
23 #include <avkon.hrh> |
|
24 #include <aknlists.h> |
|
25 #include <aknPopup.h> |
|
26 #include <aknbutton.h> |
|
27 #include <StringLoader.h> |
|
28 #include <eiklabel.h> |
|
29 #include <eikimage.h> |
|
30 #include <eikenv.h> |
|
31 #include <AknsDrawUtils.h> |
|
32 #include <sysutil.h> |
|
33 #include <AknUtils.h> |
|
34 #include <FreestyleEmailUi.rsg> |
|
35 #include "FreestyleEmailUiAppui.h" |
|
36 #include "FreestyleEmailUiLayoutData.h" |
|
37 #include "FreestyleEmailUiLayoutHandler.h" |
|
38 #include "ncsaddressinputfield.h" |
|
39 #include "ncsconstants.h" |
|
40 #include "ncsaifeditor.h" |
|
41 #include "ncsfieldsizeobserver.h" |
|
42 #include "ncsutility.h" |
|
43 #include "ncsheadercontainer.h" |
|
44 #include "txtrich.h" |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // constructor |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CNcsAddressInputField::CNcsAddressInputField( |
|
51 TNcsInputFieldType aFieldType, |
|
52 MNcsFieldSizeObserver* aSizeObserver, |
|
53 MNcsAddressPopupList* aAddressPopupList, |
|
54 CNcsHeaderContainer* aParentControl ): |
|
55 MNcsControl( aSizeObserver ), |
|
56 // <cmail> |
|
57 iParentControl( aParentControl ), |
|
58 iAddressPopupList( aAddressPopupList ), |
|
59 // </cmail> |
|
60 iFieldType( aFieldType ) |
|
61 { |
|
62 FUNC_LOG; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CNcsAddressInputField::NewL() |
|
67 // Two-phased constructor. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CNcsAddressInputField* CNcsAddressInputField::NewL( |
|
71 TInt aLabelTextId, |
|
72 TNcsInputFieldType aFieldType, |
|
73 MNcsFieldSizeObserver* aSizeObserver, |
|
74 MNcsAddressPopupList* aAddressPopupList, |
|
75 CNcsHeaderContainer* aParentControl ) |
|
76 { |
|
77 FUNC_LOG; |
|
78 CNcsAddressInputField* self = new ( ELeave ) CNcsAddressInputField( |
|
79 aFieldType, aSizeObserver, aAddressPopupList, aParentControl ); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL( aLabelTextId ); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CNcsAddressInputField::ConstructL() |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CNcsAddressInputField::ConstructL( TInt aLabelTextId ) |
|
93 { |
|
94 FUNC_LOG; |
|
95 // Create label |
|
96 //Load the label string |
|
97 HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId ); |
|
98 //<cmail> |
|
99 CreateControlsL( aTextBuf ? aTextBuf->Des() : TPtrC() ); |
|
100 //</cmail> |
|
101 |
|
102 iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver ); |
|
103 // iTextEditor is not completely constructed until in SetContainerWindowL() |
|
104 |
|
105 iTextEditor->SetPopupList(iAddressPopupList); |
|
106 |
|
107 CleanupStack::PopAndDestroy( aTextBuf ); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Destructor |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CNcsAddressInputField::~CNcsAddressInputField() |
|
115 { |
|
116 FUNC_LOG; |
|
117 delete iTextEditor; |
|
118 delete iButton; |
|
119 delete iLabel; |
|
120 // <cmail> Platform layout change |
|
121 /*if ( iFont ) |
|
122 { |
|
123 ControlEnv()->ScreenDevice()->ReleaseFont( iFont ); |
|
124 iFont = NULL; |
|
125 }</cmail>*/ |
|
126 } |
|
127 |
|
128 //<cmail> |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CNcsHeaderContainer::CreateControlsL() |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CNcsAddressInputField::CreateControlsL( const TDesC& aControlText ) |
|
134 { |
|
135 FUNC_LOG; |
|
136 if( AknLayoutUtils::PenEnabled() ) |
|
137 { |
|
138 //Create button |
|
139 TRect buttRect( 10, 10, 70, 100 ); |
|
140 iButton = CAknButton::NewL( NULL, NULL, NULL, NULL, aControlText, TPtrC(), KAknButtonTextLeft, 0 ); |
|
141 iButton->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG63 ); |
|
142 iButton->SetContainerWindowL( *iParentControl ); |
|
143 iButton->SetObserver( this ); |
|
144 iButton->SetRect( buttRect ); |
|
145 iButton->MakeVisible( ETrue ); |
|
146 iButton->ActivateL(); |
|
147 } |
|
148 else |
|
149 { |
|
150 //Create label |
|
151 iLabel = new ( ELeave ) CNcsLabel( *this, NULL ); |
|
152 iLabel->SetTextL( aControlText ); |
|
153 iLabel->SetBrushStyle(CWindowGc::ENullBrush); |
|
154 } |
|
155 } |
|
156 //</cmail> |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // SetContainerWindow |
|
160 // Don't construct the window dependent elements until the window |
|
161 // container is set |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CNcsAddressInputField::SetContainerWindowL( const CCoeControl& aContainer ) |
|
165 { |
|
166 FUNC_LOG; |
|
167 CCoeControl::SetContainerWindowL(aContainer); |
|
168 |
|
169 InitComponentArrayL(); |
|
170 // Check if we need to construct the components |
|
171 if (Components().Count() == 2) return; |
|
172 |
|
173 // Load the controls into the compoent array |
|
174 CCoeControlArray& controls = Components(); |
|
175 controls.SetControlsOwnedExternally(ETrue); |
|
176 //<cmail> |
|
177 if( iButton ) |
|
178 { |
|
179 controls.AppendLC( iButton ); |
|
180 CleanupStack::Pop( iButton ); |
|
181 } |
|
182 else |
|
183 { |
|
184 controls.AppendLC( iLabel ); |
|
185 CleanupStack::Pop( iLabel ); |
|
186 } |
|
187 //</cmail> |
|
188 controls.AppendLC(iTextEditor); |
|
189 CleanupStack::Pop(iTextEditor); |
|
190 |
|
191 // <cmail> |
|
192 |
|
193 // Setup the text editor |
|
194 iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 ); |
|
195 // </cmail> |
|
196 |
|
197 iTextEditor->SetBorder( TGulBorder::ENone ); |
|
198 iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode ); |
|
199 iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap ); |
|
200 iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase ); |
|
201 iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
202 iTextEditor->SetEdwinSizeObserver( this ); |
|
203 iTextEditor->SetupEditorL(); |
|
204 |
|
205 // Setup the label |
|
206 UpdateFontSize(); |
|
207 |
|
208 // Setup text alignment according the mirrored/normal layout. |
|
209 if ( AknLayoutUtils::LayoutMirrored() ) |
|
210 { |
|
211 if( iLabel ) |
|
212 iLabel->SetAlignment( EHRightVCenter ); |
|
213 iTextEditor->SetAlignment( EAknEditorAlignRight ); |
|
214 } |
|
215 else |
|
216 { |
|
217 if( iLabel ) |
|
218 iLabel->SetAlignment( EHLeftVCenter ); |
|
219 iTextEditor->SetAlignment( EAknEditorAlignLeft ); |
|
220 } |
|
221 |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CNcsAddressInputField::Draw() const |
|
226 // Draws the display |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CNcsAddressInputField::Draw( const TRect& /*aRect*/ ) const |
|
230 { |
|
231 FUNC_LOG; |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CNcsAddressInputField::GetMinLabelLength() |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CNcsAddressInputField::GetMinLabelLength() const |
|
239 { |
|
240 FUNC_LOG; |
|
241 return iLabel ? iLabel->Font()->TextWidthInPixels( *iLabel->Text() ) : 0; |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CNcsAddressInputField::SizeChanged() |
|
246 // set size |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CNcsAddressInputField::SizeChanged() |
|
250 { |
|
251 FUNC_LOG; |
|
252 |
|
253 TRect rect = Rect(); |
|
254 |
|
255 if( AknLayoutUtils::PenEnabled() ) |
|
256 { |
|
257 LayoutTouch(); |
|
258 } |
|
259 else |
|
260 { |
|
261 LayoutNonTouch(); |
|
262 } |
|
263 |
|
264 UpdateFontSize(); |
|
265 |
|
266 if (iTextEditor->ScrollBarFrame()) |
|
267 { |
|
268 TRect rc = iTextEditor->Rect(); |
|
269 if (AknLayoutUtils::LayoutMirrored()) |
|
270 { |
|
271 rc.iTl.iX += iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical); |
|
272 } |
|
273 else |
|
274 { |
|
275 rc.iBr.iX -= iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical); |
|
276 } |
|
277 iTextEditor->SetRect(rc); |
|
278 } |
|
279 |
|
280 PositionChanged(); |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CNcsHeaderContainer::PositionChanged() |
|
285 // set size |
|
286 // ----------------------------------------------------------------------------- |
|
287 void CNcsAddressInputField::PositionChanged() |
|
288 { |
|
289 FUNC_LOG; |
|
290 |
|
291 // keep the button in view as long as possible |
|
292 if( iButton ) |
|
293 { |
|
294 const TRect rect( Rect() ); |
|
295 const TRect buttonRect( iButton->Rect() ); |
|
296 |
|
297 TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY ); |
|
298 |
|
299 if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY ) |
|
300 { |
|
301 iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) ); |
|
302 } |
|
303 else |
|
304 { |
|
305 iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) ); |
|
306 } |
|
307 } |
|
308 } |
|
309 |
|
310 //<cmail> |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CNcsAddressInputField::LayoutNonTouch() |
|
313 // |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 void CNcsAddressInputField::LayoutNonTouch() |
|
317 { |
|
318 const TRect rect( Rect() ); |
|
319 NcsUtility::LayoutCaptionLabel( iLabel, rect ); |
|
320 NcsUtility::LayoutDetailEdwin( iTextEditor, rect, iEditorLineCount, EFalse ); |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CNcsAddressInputField::LayoutTouch() |
|
325 // |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 void CNcsAddressInputField::LayoutTouch() |
|
329 { |
|
330 const TRect rect( Rect() ); |
|
331 NcsUtility::LayoutCaptionButton( iButton, rect ); |
|
332 NcsUtility::LayoutDetailEdwinTouch( iTextEditor, rect, iEditorLineCount, EFalse ); |
|
333 |
|
334 // save the original field positions so that we can the button in view |
|
335 iOriginalFieldPos = rect.iTl; |
|
336 iOriginalButtonPos = iButton->Position(); |
|
337 |
|
338 iTextEditor->UpdateCustomDrawer(); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CNcsAddressInputField::HandlePointerEventL() |
|
343 // Handles pointer events |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CNcsAddressInputField::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
347 { |
|
348 FUNC_LOG; |
|
349 iTextEditor->HandlePointerEventL(aPointerEvent); |
|
350 if( iButton ) |
|
351 { |
|
352 iButton->HandlePointerEventL( aPointerEvent ); |
|
353 } |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CNcsAddressInputField::HandleControlEventL() |
|
358 // |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 void CNcsAddressInputField::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) |
|
362 { |
|
363 if( aEventType == EEventStateChanged ) |
|
364 { |
|
365 if( aControl == iButton ) |
|
366 { |
|
367 iParentControl->OpenPhonebookL(); |
|
368 } |
|
369 } |
|
370 } |
|
371 //</cmail> |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CNcsAddressInputField::OfferKeyEventL() |
|
375 // Handles key events |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 TKeyResponse |
|
379 CNcsAddressInputField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
380 { |
|
381 FUNC_LOG; |
|
382 TKeyResponse ret( EKeyWasNotConsumed ); |
|
383 |
|
384 if( aKeyEvent.iCode == EKeyOK ) |
|
385 { |
|
386 iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ); |
|
387 iTextEditor->UpdateAddressListAllL(); |
|
388 } |
|
389 else |
|
390 { |
|
391 ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType ); |
|
392 } |
|
393 |
|
394 return ret; |
|
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // CNcsAddressInputField::FocusChanged() |
|
399 // ----------------------------------------------------------------------------- |
|
400 // |
|
401 void CNcsAddressInputField::FocusChanged( TDrawNow aDrawNow ) |
|
402 { |
|
403 FUNC_LOG; |
|
404 if ( IsFocused() ) |
|
405 { |
|
406 iTextEditor->SetFocus( ETrue, aDrawNow ); |
|
407 TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) ); |
|
408 |
|
409 // make sure that control is visible on screen |
|
410 if ( Rect().iTl.iY < 0 ) |
|
411 { |
|
412 TPoint pt = TPoint( 0, 0 ); |
|
413 Reposition( pt,Rect().Width() ); |
|
414 iSizeObserver->UpdateFieldPosition( this ); |
|
415 } |
|
416 else |
|
417 { |
|
418 TPoint pos = PositionRelativeToScreen(); |
|
419 pos.iY += Size().iHeight; |
|
420 CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice(); |
|
421 TPixelsAndRotation pix; |
|
422 screenDev->GetDefaultScreenSizeAndRotation( pix ); |
|
423 const TInt h = pix.iPixelSize.iHeight; |
|
424 if ( pos.iY >= h - h / 3 ) |
|
425 { |
|
426 TPoint pt = TPoint( 0, h / 3 ); |
|
427 Reposition( pt,Rect().Width() ); |
|
428 iSizeObserver->UpdateFieldPosition( this ); |
|
429 } |
|
430 } |
|
431 |
|
432 if ( iParentControl ) |
|
433 { |
|
434 TRAP_IGNORE( iParentControl->SetMskL() ); |
|
435 } |
|
436 } |
|
437 else |
|
438 { |
|
439 TRAP_IGNORE( iTextEditor->HandleTextChangedL() ); |
|
440 iTextEditor->SetFocus( EFalse ); |
|
441 TRAP_IGNORE( iAddressPopupList->ClosePopupContactListL() ); |
|
442 } |
|
443 |
|
444 if ( aDrawNow ) |
|
445 { |
|
446 DrawNow(); |
|
447 } |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CNcsAddressInputField::MinimumHeight() |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 TInt CNcsAddressInputField::MinimumHeight() const |
|
455 { |
|
456 FUNC_LOG; |
|
457 // <cmail> Platform layout changes |
|
458 /*TNcsMeasures m = NcsUtility::Measures(); |
|
459 TInt height = m.iAifHeight - m.iAifEditorHeight + iEditorMinimumHeight; |
|
460 TInt height2 = m.iAifHeight; |
|
461 return Max( height, height2 ); |
|
462 */ |
|
463 |
|
464 //return NcsUtility::MinimumHeaderSize( Rect(), iEditorLineCount ).iHeight; |
|
465 // </cmail> Platform layout changes |
|
466 return 0; |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CNcsAddressInputField::HandleEdwinSizeEventL() |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 TBool CNcsAddressInputField::HandleEdwinSizeEventL( |
|
474 CEikEdwin* /*aEdwin*/, |
|
475 TEdwinSizeEvent /*aEventType*/, |
|
476 TSize aDesirableEdwinSize ) |
|
477 { |
|
478 FUNC_LOG; |
|
479 // <cmail> Platform layout change |
|
480 /*TInt ret( EFalse ); |
|
481 TInt htLine = iTextEditor->GetLineHeightL(); |
|
482 TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine; |
|
483 |
|
484 if( numLinesDesired < KMaxAddressFieldLines && |
|
485 iEditorMinimumHeight != aDesirableEdwinSize.iHeight ) |
|
486 { |
|
487 iEditorMinimumHeight = aDesirableEdwinSize.iHeight; |
|
488 |
|
489 if( iSizeObserver ) |
|
490 ret = iSizeObserver->UpdateFieldSizeL(); |
|
491 iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
492 |
|
493 } |
|
494 else if (iEditorMinimumHeight != htLine * KMaxAddressFieldLines) |
|
495 { |
|
496 //We may still need to resize the controll. |
|
497 iEditorMinimumHeight = htLine * KMaxAddressFieldLines; |
|
498 iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn ); |
|
499 if (iSizeObserver) |
|
500 ret = iSizeObserver->UpdateFieldSizeL(); |
|
501 } |
|
502 return ret;*/ |
|
503 |
|
504 TInt ret( EFalse ); |
|
505 TInt htLine = iTextEditor->GetLineHeightL(); |
|
506 TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine; |
|
507 CEikScrollBarFrame& scrollBarFrame( *iTextEditor->CreateScrollBarFrameL() ); |
|
508 iEditorLineCount = numLinesDesired; |
|
509 scrollBarFrame.SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
510 if ( iSizeObserver ) |
|
511 { |
|
512 ret = iSizeObserver->UpdateFieldSizeL(); |
|
513 } |
|
514 return ret; |
|
515 // </cmail> |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CNcsAddressInputField::AddAddressL() |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 void CNcsAddressInputField::AddAddressL( const CNcsEmailAddressObject& aAddress ) |
|
523 { |
|
524 FUNC_LOG; |
|
525 iTextEditor->AddAddressL( aAddress ); |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // CNcsAddressInputField::AddAddressL() |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 void CNcsAddressInputField::AddAddressL( const TDesC& aEmail ) |
|
533 { |
|
534 FUNC_LOG; |
|
535 iTextEditor->AddAddressL( KNullDesC(), aEmail ); |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // CNcsAddressInputField::SelectAllTextL() |
|
540 // ----------------------------------------------------------------------------- |
|
541 // |
|
542 void CNcsAddressInputField::SelectAllTextL() |
|
543 { |
|
544 FUNC_LOG; |
|
545 iTextEditor->SelectAllL(); |
|
546 } |
|
547 |
|
548 // <cmail> Platform layout changes |
|
549 // ----------------------------------------------------------------------------- |
|
550 // CNcsAddressInputField::Reposition() |
|
551 // ----------------------------------------------------------------------------- |
|
552 // |
|
553 void CNcsAddressInputField::Reposition( TPoint& aPt, TInt /*aWidth*/ ) |
|
554 { |
|
555 FUNC_LOG; |
|
556 /* |
|
557 TSize sz( aWidth, MinimumHeight() ); |
|
558 if ( Rect() != TRect( aPt, sz ) ) |
|
559 { |
|
560 SetExtent( aPt, sz); |
|
561 } |
|
562 aPt.iY += Size().iHeight; |
|
563 */ |
|
564 SetPosition( aPt ); |
|
565 // </cmail> Platform layout changes |
|
566 } |
|
567 |
|
568 // ----------------------------------------------------------------------------- |
|
569 // CNcsAddressInputField::GetLabelText() |
|
570 // ----------------------------------------------------------------------------- |
|
571 // |
|
572 const TDesC& CNcsAddressInputField::GetLabelText() const |
|
573 { |
|
574 FUNC_LOG; |
|
575 return iLabel ? *iLabel->Text() : KEmptyReturnValue(); |
|
576 } |
|
577 |
|
578 // <cmail> Platform layout change |
|
579 // --------------------------------------------------------------------------- |
|
580 // CNcsAddressInputField::LayoutLineCount |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 TInt CNcsAddressInputField::LayoutLineCount() const |
|
584 { |
|
585 FUNC_LOG; |
|
586 if( iLabel && !AknLayoutUtils::PenEnabled() ) |
|
587 { |
|
588 return ( IsVisible() ? Max( 1, iEditorLineCount ) : 0 ) + iLabel->LayoutLineCount(); |
|
589 } |
|
590 else |
|
591 { |
|
592 return ( IsVisible() ? Max( 1, iEditorLineCount ) : 0 ); |
|
593 } |
|
594 } |
|
595 // </cmail> Platform layout change |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CNcsAddressInputField::LineCount() |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 TInt CNcsAddressInputField::LineCount() const |
|
602 { |
|
603 FUNC_LOG; |
|
604 return iTextEditor->LineCount(); |
|
605 } |
|
606 |
|
607 // ----------------------------------------------------------------------------- |
|
608 // CNcsAddressInputField::ScrollableLines() |
|
609 // ----------------------------------------------------------------------------- |
|
610 // |
|
611 TInt CNcsAddressInputField::ScrollableLines() const |
|
612 { |
|
613 FUNC_LOG; |
|
614 return iTextEditor->ScrollableLines(); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CNcsAddressInputField::GetNumChars() |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 TInt CNcsAddressInputField::GetNumChars() const |
|
622 { |
|
623 FUNC_LOG; |
|
624 return iTextEditor->GetNumChars(); |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CNcsAddressInputField::CursorLineNumber() |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TInt CNcsAddressInputField::CursorLineNumber() const |
|
632 { |
|
633 FUNC_LOG; |
|
634 return iTextEditor->CursorLineNumber(); |
|
635 } |
|
636 |
|
637 // ----------------------------------------------------------------------------- |
|
638 // CNcsAddressInputField::CursorPosition() |
|
639 // ----------------------------------------------------------------------------- |
|
640 // |
|
641 TInt CNcsAddressInputField::CursorPosition() const |
|
642 { |
|
643 FUNC_LOG; |
|
644 TInt pos = iTextEditor->CursorPosition(); |
|
645 //Add the delta between the top of the edit control |
|
646 //and the top of the parent control |
|
647 pos += iTextEditor->Rect().iTl.iY - Rect().iTl.iY ; |
|
648 return pos; |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // CNcsAddressInputField::Editor() |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 CNcsEditor* CNcsAddressInputField::Editor() const |
|
656 { |
|
657 FUNC_LOG; |
|
658 return iTextEditor; |
|
659 } |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CNcsAddressInputField::IsEmpty() |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 TBool CNcsAddressInputField::IsEmpty() const |
|
666 { |
|
667 FUNC_LOG; |
|
668 return iTextEditor->TextLength() == 0; |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CNcsAddressInputField::GetLookupTextLC() |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 HBufC* CNcsAddressInputField::GetLookupTextLC() const |
|
676 { |
|
677 FUNC_LOG; |
|
678 return iTextEditor->GetLookupTextLC(); |
|
679 } |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CNcsAddressInputField::GetAddressesL() |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 const RPointerArray<CNcsEmailAddressObject>& |
|
686 CNcsAddressInputField::GetAddressesL( TBool aParseNow ) |
|
687 { |
|
688 if ( aParseNow ) |
|
689 { |
|
690 iTextEditor->CheckAddressWhenFocusLostL(); |
|
691 } |
|
692 return iTextEditor->GetAddressesL(); |
|
693 } |
|
694 |
|
695 // ----------------------------------------------------------------------------- |
|
696 // CNcsAddressInputField::EmailAddressObjectBySelection() |
|
697 // ----------------------------------------------------------------------------- |
|
698 // |
|
699 const CNcsEmailAddressObject* CNcsAddressInputField::EmailAddressObjectBySelection() const |
|
700 { |
|
701 FUNC_LOG; |
|
702 return iTextEditor->EmailAddressObjectBySelection(); |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // CNcsAddressInputField::TextEditor() |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 CEikEdwin* CNcsAddressInputField::TextEditor() const |
|
710 { |
|
711 FUNC_LOG; |
|
712 return iTextEditor; |
|
713 } |
|
714 |
|
715 // ----------------------------------------------------------------------------- |
|
716 // CNcsAddressInputField::GetLineRectL() |
|
717 // ----------------------------------------------------------------------------- |
|
718 // |
|
719 void CNcsAddressInputField::GetLineRectL( TRect& aLineRect ) const |
|
720 { |
|
721 FUNC_LOG; |
|
722 return iTextEditor->GetLineRectL( aLineRect ); |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CNcsAddressInputField::SetMaxLabelLength() |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 void CNcsAddressInputField::SetMaxLabelLength( TInt aMaxLength ) |
|
730 { |
|
731 FUNC_LOG; |
|
732 iMaximumLabelLength = aMaxLength; |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CNcsAddressInputField::SetTextColorL() |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 void CNcsAddressInputField::SetTextColorL( TLogicalRgb aColor ) |
|
740 { |
|
741 FUNC_LOG; |
|
742 iTextEditor->SetTextColorL( aColor ); |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CNcsAddressInputField::SetAddressesL() |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CNcsAddressInputField::SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
750 { |
|
751 FUNC_LOG; |
|
752 iTextEditor->SetAddressesL( aAddresses ); |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // CNcsAddressInputField::AppendAddressesL() |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void CNcsAddressInputField::AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
760 { |
|
761 FUNC_LOG; |
|
762 iTextEditor->AppendAddressesL( aAddresses ); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CNcsAddressInputField::UpdateFontSize() |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 void CNcsAddressInputField::UpdateFontSize() |
|
770 { |
|
771 FUNC_LOG; |
|
772 // <cmail> Platform layout change |
|
773 /*if ( iFont ) |
|
774 { |
|
775 ControlEnv()->ScreenDevice()->ReleaseFont( iFont ); |
|
776 iFont = NULL; |
|
777 } |
|
778 |
|
779 TNcsMeasures m = NcsUtility::Measures(); |
|
780 if ( !iFont ) |
|
781 { |
|
782 TRAP_IGNORE( iFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont, m.iLabelFontHeightPx) ); |
|
783 }*/ |
|
784 CCoeControl* control = iButton ? ( CCoeControl* )iButton : ( CCoeControl* )iLabel; |
|
785 iFont = NcsUtility::GetLayoutFont( control->Rect(), NcsUtility::ENcsHeaderCaptionFont ); |
|
786 if( control == iButton ) |
|
787 { |
|
788 iButton->SetTextFont( iFont ); |
|
789 } |
|
790 else |
|
791 { |
|
792 iLabel->SetFont( iFont ); |
|
793 } |
|
794 iTextEditor->UpdateFontSize(); |
|
795 // </cmail> Platform layout change |
|
796 } |
|
797 |
|
798 // ----------------------------------------------------------------------------- |
|
799 // CNcsAddressInputField::HandleResourceChange() |
|
800 // ----------------------------------------------------------------------------- |
|
801 // |
|
802 void CNcsAddressInputField::HandleResourceChange( TInt aType ) |
|
803 { |
|
804 FUNC_LOG; |
|
805 CCoeControl::HandleResourceChange( aType ); |
|
806 if ( aType == KAknsMessageSkinChange || |
|
807 aType == KEikMessageColorSchemeChange ) |
|
808 { |
|
809 UpdateFontSize(); |
|
810 // <cmail> Platform layout change |
|
811 iTextEditor->HandleResourceChange( aType ); // CreateScrollBarFrameL()->DrawScrollBarsNow(); |
|
812 // </cmail> Platform layout change |
|
813 } |
|
814 } |
|
815 |
|
816 void CNcsAddressInputField::FixSemicolonAtTheEndL() |
|
817 { |
|
818 FUNC_LOG; |
|
819 |
|
820 if ( 0 != iTextEditor->TextLength() && |
|
821 !iTextEditor->HasSemicolonAtTheEndL() ) |
|
822 { |
|
823 CRichText* rt = iTextEditor->RichText(); |
|
824 if ( rt ) |
|
825 { |
|
826 rt->InsertL( rt->DocumentLength(), _L(";") ); |
|
827 iTextEditor->SetCursorPosL( rt->DocumentLength(), EFalse ); |
|
828 iTextEditor->CheckAddressWhenFocusLostL(); |
|
829 } |
|
830 } |
|
831 } |