|
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: Manager for numberentry |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikenv.h> |
|
21 #include <eikapp.h> |
|
22 #include <gulicon.h> |
|
23 #include <w32std.h> |
|
24 #include <baclipb.h> // CClipboard |
|
25 #include <dialer.rsg> |
|
26 #include <eikimage.h> // CEikImage |
|
27 #include <barsread.h> // TResourceReader |
|
28 #include <featmgr.h> |
|
29 #include <eiklabel.h> |
|
30 #include <aknappui.h> |
|
31 #include <AknUtils.h> |
|
32 #include <AknsDrawUtils.h> |
|
33 #include <applayout.cdl.h> |
|
34 #include <AknLayoutFont.h> |
|
35 #include <AknLayout2Def.h> |
|
36 #include <AknPhoneNumberEditor.h> |
|
37 #include <AknLayout2ScalableDef.h> |
|
38 #include <AknsBasicBackgroundControlContext.h> |
|
39 #include <AknsFrameBackgroundControlContext.h> |
|
40 #include <aknlayoutscalable_apps.cdl.h> |
|
41 #include <layoutmetadata.cdl.h> |
|
42 |
|
43 #include "cdialernumberentry.h" |
|
44 #include "dialercommon.h" |
|
45 #include "dialertrace.h" |
|
46 #include "dialer.hrh" |
|
47 #include "mnumberentry.h" |
|
48 #include <dialingextensioninterface.h> |
|
49 #include <phoneappcommands.hrh> |
|
50 |
|
51 const TInt KNumberEntryControlCount = 2; // = number entry, label |
|
52 |
|
53 _LIT( KPhoneValidChars, "0123456789*#+pwPW" ); |
|
54 _LIT( KPhoneVanityValidChars, "0123456789*#+pwABCDEFGHIJKLMNOPQRSTUVWXYZ" ); |
|
55 |
|
56 const TInt KKeyCtrlA( 1 ); |
|
57 const TInt KKeyCtrlC( 3 ); |
|
58 const TInt KKeyCtrlV( 22 ); |
|
59 const TInt KKeyCtrlX( 24 ); |
|
60 |
|
61 // ========================= MEMBER FUNCTIONS ================================ |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // NewL |
|
65 // Symbian OS two phased constructor |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CDialerNumberEntry* CDialerNumberEntry::NewL( |
|
70 const CCoeControl& aContainer ) |
|
71 { |
|
72 CDialerNumberEntry* self = |
|
73 new( ELeave )CDialerNumberEntry( aContainer ); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 CleanupStack::Pop(); // self |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // ConstructL |
|
83 // Symbian OS two phased constructor |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CDialerNumberEntry::ConstructL() |
|
88 { |
|
89 DIALER_PRINT("numberentry::ConstructL<"); |
|
90 BaseConstructL(); |
|
91 |
|
92 // Create number entry editor |
|
93 iEditor = new( ELeave ) CAknPhoneNumberEditor; |
|
94 iEditor->SetContainerWindowL( *this ); |
|
95 iEditor->SetParent( this ); |
|
96 iEditor->SetMopParent( this ); |
|
97 TResourceReader reader; |
|
98 iCoeEnv->CreateResourceReaderLC( reader, R_INPUTFIELD ); |
|
99 ConstructEditorFromResourceL( reader ); |
|
100 |
|
101 iFrameContext = CAknsFrameBackgroundControlContext::NewL( |
|
102 KAknsIIDNone, TRect(0,0,4,4), TRect(1,1,3,3), EFalse ); |
|
103 |
|
104 iFrameContext->SetFrame( KAknsIIDQsnFrInput ); |
|
105 |
|
106 iFrameContext->SetParentContext( |
|
107 AknsDrawUtils::ControlContextOfParent(this) ); |
|
108 |
|
109 CleanupStack::PopAndDestroy(); // reader |
|
110 iEditor->SetObserver( this ); |
|
111 |
|
112 iLabel = new( ELeave ) CEikLabel; |
|
113 iLabel->SetContainerWindowL( *this ); |
|
114 iLabel->SetParent( this ); |
|
115 iLabel->SetMopParent( this ); |
|
116 iLabel->SetTextL( KNullDesC ); |
|
117 iLabel->MakeVisible( EFalse ); |
|
118 CheckLabelSkinningColor(); |
|
119 |
|
120 iAppUi = iEikonEnv->EikAppUi(); |
|
121 __ASSERT_ALWAYS( iAppUi, DialerPanic( EDialerPanicNoApplicationInstance ) ); |
|
122 |
|
123 iLateFocuser = CIdle::NewL( CActive::EPriorityIdle ); |
|
124 |
|
125 ActivateL(); |
|
126 DIALER_PRINT("numberentry::ConstructL>"); |
|
127 } |
|
128 |
|
129 |
|
130 // Constructor |
|
131 CDialerNumberEntry::CDialerNumberEntry( |
|
132 const CCoeControl& aContainer ) |
|
133 : CDialerContainerBase ( const_cast<CCoeControl&>(aContainer) ) |
|
134 { |
|
135 } |
|
136 |
|
137 |
|
138 // Destructor |
|
139 CDialerNumberEntry::~CDialerNumberEntry() |
|
140 { |
|
141 AknsUtils::DeregisterControlPosition( this ); |
|
142 |
|
143 delete iEditor; |
|
144 delete iFrameContext; |
|
145 delete iLabel; |
|
146 |
|
147 if ( iLateFocuser ) |
|
148 { |
|
149 iLateFocuser->Cancel(); |
|
150 } |
|
151 delete iLateFocuser; |
|
152 |
|
153 } |
|
154 |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CDialerNumberEntry::SetNumberEntryObserver |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CDialerNumberEntry::SetNumberEntryObserver( |
|
161 MNumberEntryObserver& aObserver ) |
|
162 { |
|
163 iObserver = &aObserver; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // Delays the setting of focus or removes the focus |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CDialerNumberEntry::SetFocus( TBool aFocus, TDrawNow aDrawNow ) |
|
171 { |
|
172 DIALER_PRINT("numberentry::SetFocus<"); |
|
173 |
|
174 TBool vkbOpen = ( iEditor->AknEditorFlags() & EAknEditorFlagTouchInputModeOpened ); |
|
175 |
|
176 iLateFocuser->Cancel(); |
|
177 if ( aFocus && !vkbOpen ) |
|
178 { |
|
179 // The setting of focus needs to be delayed, because otherwise |
|
180 // editors cursor is drawn first. Cursor can be seen clearly |
|
181 // when going from landscape mode homescreen to dialer (when |
|
182 // dialer's support for landscape mode has been removed) |
|
183 // The reason behind this is that giving a focus to editor will cause |
|
184 // enabling of cursor in window server and the window server's |
|
185 // render plugin will draw the cursor first, before the |
|
186 // dialer gets drawn. The delay in dialer drawing is caused by the |
|
187 // screen rotation from landscape to portrait. |
|
188 iLateFocuser->Start( TCallBack( SetLateFocus, this ) ); |
|
189 } |
|
190 else |
|
191 { |
|
192 DoSetFocus( aFocus, aDrawNow ); |
|
193 } |
|
194 DIALER_PRINT("numberentry::SetFocus>"); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CDialerNumberEntry::SetLateFocus |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CDialerNumberEntry::SetLateFocus( TAny* aThis ) |
|
202 { |
|
203 DIALER_PRINT("numberentry::SetLateFocus<"); |
|
204 CDialerNumberEntry* self = static_cast<CDialerNumberEntry*>( aThis ); |
|
205 |
|
206 self->DoSetFocus( ETrue, ENoDrawNow ); |
|
207 |
|
208 DIALER_PRINT("numberentry::SetLateFocus>"); |
|
209 return KErrNone; |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // Set the focuss |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 void CDialerNumberEntry::DoSetFocus( TBool aFocus, TDrawNow aDrawNow ) |
|
217 { |
|
218 DIALER_PRINT("numberentry::DoSetFocus<"); |
|
219 // IsFocused() and iEditor->IsFocused() may return other values besides ETrue |
|
220 // and EFalse. This is why we need to check their return values against zero |
|
221 // and use the result in comparison against aFocus. |
|
222 if ( aFocus != (IsFocused() ? ETrue : EFalse) ) |
|
223 { |
|
224 CCoeControl::SetFocus( aFocus, aDrawNow ); |
|
225 } |
|
226 |
|
227 if ( aFocus != (iEditor-> IsFocused() ? ETrue : EFalse ) ) |
|
228 { |
|
229 iEditor->SetFocus( aFocus ); |
|
230 } |
|
231 DIALER_PRINT("numberentry::DoSetFocus>"); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // CDialerNumberEntry::TextLength |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CDialerNumberEntry::TextLength() |
|
239 { |
|
240 return iEditor->TextLength(); |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CDialerNumberEntry::GetNumberEntry |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 CCoeControl* CDialerNumberEntry::GetNumberEntry( ) const |
|
248 { |
|
249 return iEditor; |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CDialerNumberEntry::CreateNumberEntry |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 void CDialerNumberEntry::CreateNumberEntry() |
|
257 { |
|
258 iEditor->SetFocus( ETrue ); |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CDialerNumberEntry::ChangeEditorMode |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 TInt CDialerNumberEntry::ChangeEditorMode( TBool aDefaultMode ) |
|
266 { |
|
267 return iEditor->ChangeEditorMode( aDefaultMode ); |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CDialerNumberEntry::GetEditorMode |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 TInt CDialerNumberEntry::GetEditorMode() const |
|
275 { |
|
276 return iEditor->GetEditorMode(); |
|
277 } |
|
278 |
|
279 // --------------------------------------------------------------------------- |
|
280 // CDialerNumberEntry::SetTextToNumberEntry |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 void CDialerNumberEntry::SetTextToNumberEntry( const TDesC& aDesC ) |
|
284 { |
|
285 DIALER_PRINT("numberentry::SetTextToNumberEntry<"); |
|
286 |
|
287 iEditor->SetText( aDesC ); |
|
288 |
|
289 if ( iEasyDialer && iOperationMode == EModeEasyDialing ) |
|
290 { |
|
291 TRAP_IGNORE( iEasyDialer->SetInputL( aDesC ) ); |
|
292 } |
|
293 |
|
294 iEditor->DrawNow(); |
|
295 |
|
296 DIALER_PRINT("numberentry::SetTextToNumberEntry>"); |
|
297 } |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CDialerNumberEntry::GetTextFromNumberEntry |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 void CDialerNumberEntry::GetTextFromNumberEntry( TDes& aDes ) |
|
304 { |
|
305 iEditor->GetText( aDes ); |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // CDialerNumberEntry::Text |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 TPtrC CDialerNumberEntry::Text() const |
|
313 { |
|
314 return iEditor->Text(); |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CDialerNumberEntry::ResetEditorToDefaultValues |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 void CDialerNumberEntry::ResetEditorToDefaultValues() |
|
322 { |
|
323 iEditor->SetFocus( EFalse ); |
|
324 SetTextToNumberEntry( KNullDesC ); |
|
325 iEditor->ResetEditorToDefaultValues(); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CDialerNumberEntry::SetNumberEntryPromptTextL |
|
330 // |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 void CDialerNumberEntry::SetNumberEntryPromptTextL( const TDesC& aPromptText ) |
|
334 { |
|
335 if ( aPromptText.Length() ) |
|
336 { |
|
337 iLabel->MakeVisible( ETrue ); |
|
338 } |
|
339 else |
|
340 { |
|
341 iLabel->MakeVisible( EFalse ); |
|
342 } |
|
343 |
|
344 iLabel->SetTextL( aPromptText ); |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // CDialerNumberEntry::HandleCommandL |
|
349 // Handles NE specific commands. |
|
350 // ---------------------------------------------------------------------------- |
|
351 // |
|
352 TBool CDialerNumberEntry::HandleCommandL( TDialerCommandId aCommand) |
|
353 { |
|
354 DIALER_PRINTF("numberentry::HandleCommandL<:", aCommand); |
|
355 |
|
356 TBool handled( ETrue ); |
|
357 switch ( aCommand ) |
|
358 { |
|
359 case EDialerCmdTouchInput: // open touch input (VKB) |
|
360 { |
|
361 StartVirtualKeyBoard(); |
|
362 } |
|
363 break; |
|
364 default: |
|
365 { |
|
366 handled = EFalse; |
|
367 } |
|
368 break; |
|
369 } |
|
370 |
|
371 DIALER_PRINT("numberentry::HandleCommandL>"); |
|
372 return handled; |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------------------------- |
|
376 // CDialerNumberEntry::ClearEditorFlags |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 void CDialerNumberEntry::ClearEditorFlags() |
|
380 { |
|
381 iEditor->ResetEditorToDefaultValues(); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CDialerNumberEntry::HandleControlEventL |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void CDialerNumberEntry::HandleControlEventL( CCoeControl* aControl, |
|
389 TCoeEvent aEventType ) |
|
390 { |
|
391 DIALER_PRINT("numberentry::HandleControlEventL<"); |
|
392 |
|
393 if ( aControl == iEditor && aEventType == EEventStateChanged ) |
|
394 { |
|
395 HandleEditorFormatting(); |
|
396 |
|
397 InformNumberEntryState(); |
|
398 |
|
399 iEditor->DrawDeferred(); |
|
400 } |
|
401 |
|
402 DIALER_PRINT("numberentry::HandleControlEventL>"); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CDialerNumberEntry::OfferKeyEventL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 TKeyResponse CDialerNumberEntry::OfferKeyEventL( |
|
410 const TKeyEvent& aKeyEvent, |
|
411 TEventCode aType ) |
|
412 { |
|
413 TKeyResponse handled = EKeyWasNotConsumed; |
|
414 |
|
415 // First, offer keyevent to easy dialer. |
|
416 if (iEasyDialer) |
|
417 { |
|
418 handled = iEasyDialer->OfferKeyEventL(aKeyEvent, aType); |
|
419 } |
|
420 |
|
421 // Then to number entry editor. |
|
422 if (handled == EKeyWasNotConsumed) |
|
423 { |
|
424 // Clipboard support |
|
425 if ( aKeyEvent.iCode == KKeyCtrlA ) // CTRL + A |
|
426 { |
|
427 iEditor->SelectAllL(); |
|
428 handled = EKeyWasConsumed; |
|
429 } |
|
430 else if ( aKeyEvent.iCode == KKeyCtrlC ) // CTRL + C |
|
431 { |
|
432 iEditor->CcpuCopyL(); |
|
433 handled = EKeyWasConsumed; |
|
434 } |
|
435 else if ( aKeyEvent.iCode == KKeyCtrlV ) // CTRL + V |
|
436 { |
|
437 iEditor->CcpuPasteL(); |
|
438 handled = EKeyWasConsumed; |
|
439 } |
|
440 else if ( aKeyEvent.iCode == KKeyCtrlX ) // CTRL + X |
|
441 { |
|
442 iEditor->CcpuCutL(); |
|
443 handled = EKeyWasConsumed; |
|
444 } |
|
445 // Key events 1 - 28 can be generated by CTRL + key combinations. |
|
446 // Filter all unwanted key events, only BS is accepted by editor. |
|
447 else if ( aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode >= EKeySpace ) |
|
448 { |
|
449 handled = iEditor->OfferKeyEventL(aKeyEvent, aType); |
|
450 } |
|
451 } |
|
452 |
|
453 return handled; |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // CDialerNumberEntry::CountComponentControls |
|
458 // --------------------------------------------------------------------------- |
|
459 // |
|
460 TInt CDialerNumberEntry::CountComponentControls() const |
|
461 { |
|
462 return KNumberEntryControlCount; |
|
463 } |
|
464 |
|
465 // --------------------------------------------------------------------------- |
|
466 // CDialerNumberEntry::ComponentControl |
|
467 // --------------------------------------------------------------------------- |
|
468 // |
|
469 CCoeControl* CDialerNumberEntry::ComponentControl( TInt aIndex ) const |
|
470 { |
|
471 __ASSERT_DEBUG( aIndex < KNumberEntryControlCount, |
|
472 User::Panic(_L("Dialer"), KErrArgument) ); |
|
473 |
|
474 if ( aIndex == 0 ) |
|
475 { |
|
476 return iEditor; |
|
477 } |
|
478 else if ( aIndex == 1 ) |
|
479 { |
|
480 return iLabel; |
|
481 } |
|
482 return NULL; |
|
483 } |
|
484 |
|
485 // --------------------------------------------------------------------------- |
|
486 // CDialerNumberEntry::Draw |
|
487 // --------------------------------------------------------------------------- |
|
488 // |
|
489 void CDialerNumberEntry::Draw( const TRect& /*aRect*/ ) const |
|
490 { |
|
491 CWindowGc& gc = SystemGc( ); |
|
492 gc.SetBrushColor( AKN_LAF_COLOR( 0 /** White - get from layout */ )); |
|
493 TRect rect = Rect(); |
|
494 |
|
495 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
496 |
|
497 // Draw the skin background of the parent |
|
498 if ( !AknsDrawUtils::DrawFrame( skin, |
|
499 (CWindowGc&) gc, |
|
500 iOuterRect, |
|
501 iInnerRect, |
|
502 KAknsIIDQsnFrInput, |
|
503 KAknsIIDDefault )) |
|
504 { |
|
505 DIALER_PRINT("numberentry::Draw.Frame.failed"); |
|
506 } |
|
507 |
|
508 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
509 } |
|
510 |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // CDialerNumberEntry::SetVariety |
|
514 // Set variety according to status |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 void CDialerNumberEntry::SetVariety() |
|
518 { |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // CDialerNumberEntry::SetLayout |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 void CDialerNumberEntry::SetLayout() |
|
526 { |
|
527 AknsUtils::RegisterControlPosition( this ); |
|
528 |
|
529 TDialerVariety variety( EDialerVarietyLandscape ); |
|
530 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
531 { |
|
532 variety = EDialerVarietyPortrait; |
|
533 } |
|
534 |
|
535 TRect parentRect( Rect() ); |
|
536 TAknTextComponentLayout neLayout = ( iOperationMode == EModeEasyDialing ? |
|
537 AknLayoutScalable_Apps::dia3_numentry_pane_t1( variety ) : |
|
538 AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety ) ); |
|
539 |
|
540 AknLayoutUtils::LayoutControl( |
|
541 iEditor, parentRect, |
|
542 neLayout.C(), |
|
543 neLayout.l(), |
|
544 neLayout.t(), |
|
545 neLayout.r(), |
|
546 neLayout.b(), |
|
547 neLayout.W(), |
|
548 neLayout.H() |
|
549 ); |
|
550 |
|
551 RectFrameInnerOuterRects( |
|
552 parentRect, |
|
553 iOuterRect, |
|
554 iInnerRect ); |
|
555 |
|
556 UpdateNumberEntryFormats(); |
|
557 |
|
558 iFrameContext->SetFrameRects( iOuterRect, iInnerRect ); |
|
559 |
|
560 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
561 AknsDrawUtils::PrepareFrame( skin, |
|
562 iOuterRect, |
|
563 iInnerRect, |
|
564 KAknsIIDQsnFrInput, |
|
565 KAknsIIDDefault ); |
|
566 // Label layout |
|
567 |
|
568 // Portrait variety is temporarily used also in landscape. |
|
569 // Landscape layout data is now unavailable. |
|
570 TAknTextComponentLayout labelLayout = |
|
571 AknLayoutScalable_Apps::dialer2_ne_pane_t2( EDialerVarietyPortrait ); |
|
572 // Temporary solution |
|
573 labelLayout.Setl( neLayout.l() ); |
|
574 AknLayoutUtils::LayoutLabel( iLabel, parentRect, labelLayout ); |
|
575 |
|
576 HandleEditorFormatting(); |
|
577 iEditor->DrawDeferred(); |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------------------------- |
|
581 // CDialerNumberEntry::ConstructEditorFromResourceL |
|
582 // --------------------------------------------------------------------------- |
|
583 // |
|
584 void CDialerNumberEntry::ConstructEditorFromResourceL( |
|
585 TResourceReader& aReader ) |
|
586 { |
|
587 TInt maxChars = aReader.ReadInt16(); |
|
588 TInt maxLines = aReader.ReadInt16(); |
|
589 HBufC* truncation = aReader.ReadHBufCL(); |
|
590 CleanupStack::PushL( truncation ); |
|
591 TInt formatCount = aReader.ReadInt16(); |
|
592 iEditor->ConstructL( maxChars, maxLines, formatCount, *truncation ); |
|
593 CleanupStack::PopAndDestroy( truncation ); |
|
594 iFormatCount = formatCount; |
|
595 |
|
596 for ( TInt ii = 0; ii < iFormatCount; ii++ ) |
|
597 { |
|
598 CAknPhoneNumberEditor::TFormat format( aReader ); |
|
599 CalculateLayout( format, ii ); |
|
600 iEditor->AddFormat( format ); |
|
601 } |
|
602 |
|
603 iEditor->SetFormat( KDialerNELayoutLargeFont ); |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------------------------- |
|
607 // CDialerNumberEntry::UpdateNumberEntryFormats |
|
608 // --------------------------------------------------------------------------- |
|
609 // |
|
610 void CDialerNumberEntry::UpdateNumberEntryFormats( ) |
|
611 { |
|
612 DIALER_PRINT("numberentry::UpdateNumberEntryFormats<"); |
|
613 TInt currentFormat = iEditor->CurrentFormatIndex(); |
|
614 |
|
615 for ( TInt ii = 0; ii < iFormatCount; ii++ ) |
|
616 { |
|
617 CAknPhoneNumberEditor::TFormat format( iEditor->Format( ii ) ); |
|
618 CalculateLayout( format, ii ); |
|
619 iEditor->Format( ii ) = format; |
|
620 } |
|
621 |
|
622 iEditor->SetFormat( currentFormat ); |
|
623 DIALER_PRINT("numberentry::UpdateNumberEntryFormats>"); |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------------------------- |
|
627 // CDialerNumberEntry::CalculateLayout |
|
628 // --------------------------------------------------------------------------- |
|
629 // |
|
630 void CDialerNumberEntry::CalculateLayout( |
|
631 CAknPhoneNumberEditor::TFormat& aFormat, TInt aNEVariety ) |
|
632 { |
|
633 TAknLayoutText textsLine1Text; |
|
634 TAknLayoutText textsLine2Text; |
|
635 |
|
636 if ( iOperationMode == EModeEasyDialing ) |
|
637 { |
|
638 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
639 textsLine1Text.LayoutText( Rect(), AknLayoutScalable_Apps::dia3_numentry_pane_t1(variety) ); |
|
640 textsLine2Text = textsLine1Text; |
|
641 } |
|
642 else |
|
643 { |
|
644 TInt variety = 0; |
|
645 if ( aNEVariety == KDialerNELayoutLargeFont ) |
|
646 { |
|
647 variety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 0; |
|
648 } |
|
649 else |
|
650 { |
|
651 variety = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 1; |
|
652 } |
|
653 |
|
654 //Line 1 |
|
655 textsLine1Text.LayoutText( Rect(), |
|
656 AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety, 0, 0 ) ); |
|
657 //Line 2 |
|
658 textsLine2Text.LayoutText( Rect(), |
|
659 AknLayoutScalable_Apps::dialer2_ne_pane_t1( variety, 0, 1 ) ); |
|
660 } |
|
661 |
|
662 //take font from line 1 |
|
663 aFormat.iFont = textsLine1Text.Font(); |
|
664 const CAknLayoutFont* layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( aFormat.iFont ); |
|
665 aFormat.iBottomBaselineOffset = layoutFont->BaselineToTextPaneBottom(); |
|
666 |
|
667 // Calculate baselineSeparation from the difference of the second |
|
668 // line and the first line bottom right Y coordinates. |
|
669 TInt baselineSeparation = |
|
670 textsLine2Text.TextRect().iBr.iY - textsLine1Text.TextRect().iBr.iY; |
|
671 aFormat.iBaselineSeparation = baselineSeparation; |
|
672 |
|
673 // Outer rect of the text editor is the inner rect of the whole text box |
|
674 aFormat.iOuterRect = iInnerRect; |
|
675 |
|
676 aFormat.iNumLines = 1; |
|
677 |
|
678 // If multiline layout is to be used, the exact number of lines is calculated |
|
679 // based on available area and the row height (i.e. baselineSeparation) |
|
680 if ( baselineSeparation > 0 && baselineSeparation < iInnerRect.Height() ) |
|
681 { |
|
682 aFormat.iNumLines = ( iInnerRect.Height() / baselineSeparation ); |
|
683 |
|
684 // Center editor vertically to the available area. |
|
685 TInt editorHeight = aFormat.iNumLines * baselineSeparation; |
|
686 TInt deltaHeight = ( iInnerRect.Height() - editorHeight ) / 2; |
|
687 aFormat.iOuterRect.Shrink( 0, deltaHeight ); |
|
688 } |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------------------------- |
|
692 // CDialerNumberEntry::HandleResourceChange |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 void CDialerNumberEntry::HandleResourceChange( TInt aType ) |
|
696 { |
|
697 CCoeControl::HandleResourceChange( aType ); |
|
698 |
|
699 if ( aType == KAknsMessageSkinChange ) |
|
700 { |
|
701 CheckLabelSkinningColor(); |
|
702 } |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // CDialerNumberEntry::HandlePointerEventL |
|
707 // --------------------------------------------------------------------------- |
|
708 // |
|
709 void CDialerNumberEntry::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
710 { |
|
711 // Normal pointer event handling and delegation to editor component |
|
712 // happens only if we are already in focus. Otherwise we just take the |
|
713 // focus. This is to prevent accidental cursor movements as putting the |
|
714 // cursor back to the end of the text is difficult for right-aligned |
|
715 // text. |
|
716 if ( iEditor->IsFocused() ) |
|
717 { |
|
718 // If user hits the margin area between this control and the actual editor |
|
719 // control, then the event position is moved to be inside the editor region. |
|
720 // This makes it easier to move cursor with finger touch, especially in |
|
721 // both ends of the number field. |
|
722 TPoint eventPos( aPointerEvent.iPosition ); |
|
723 TRect editorRect( iEditor->Rect() ); |
|
724 editorRect.Shrink( 1, 1 ); // take rect which is fully inside the editor rect |
|
725 eventPos.iX = Min( eventPos.iX, editorRect.iBr.iX ); |
|
726 eventPos.iX = Max( eventPos.iX, editorRect.iTl.iX ); |
|
727 eventPos.iY = Min( eventPos.iY, editorRect.iBr.iY ); |
|
728 eventPos.iY = Max( eventPos.iY, editorRect.iTl.iY ); |
|
729 |
|
730 TPointerEvent modEvent( aPointerEvent ); |
|
731 modEvent.iPosition = eventPos; |
|
732 |
|
733 CCoeControl::HandlePointerEventL( modEvent ); |
|
734 } |
|
735 } |
|
736 |
|
737 // --------------------------------------------------------------------------- |
|
738 // CDialerNumberEntry::HandleEditorFormatting |
|
739 // --------------------------------------------------------------------------- |
|
740 // |
|
741 void CDialerNumberEntry::HandleEditorFormatting() |
|
742 { |
|
743 TInt format( KDialerNELayoutLargeFont ); |
|
744 |
|
745 if ( !iEditor->WouldTextFitInFormat( KDialerNELayoutLargeFont ) ) |
|
746 { |
|
747 format = KDialerNELayoutSmallFont; |
|
748 } |
|
749 |
|
750 if ( iEditor->CurrentFormatIndex() != format ) |
|
751 { |
|
752 iEditor->DrawDeferred(); |
|
753 iEditor->SetFormat( format ); |
|
754 iFrameContext->SetRect( Rect() ); |
|
755 } |
|
756 |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // CDialerNumberEntry::StartVirtualKeyBoard |
|
761 // --------------------------------------------------------------------------- |
|
762 // |
|
763 void CDialerNumberEntry::StartVirtualKeyBoard( ) |
|
764 { |
|
765 // To change focus to VKB, if not called VKB will not come visible |
|
766 iLateFocuser->Cancel(); |
|
767 DoSetFocus( ETrue, ENoDrawNow ); |
|
768 iEikonEnv->SyncNotifyFocusObserversOfChangeInFocus(); |
|
769 iEditor->OpenVKB(); |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // CDialerNumberEntry::MopSupplyObject |
|
774 // --------------------------------------------------------------------------- |
|
775 // |
|
776 TTypeUid::Ptr CDialerNumberEntry::MopSupplyObject( TTypeUid aId ) |
|
777 { |
|
778 if ( aId.iUid == MAknsControlContext::ETypeId && iFrameContext ) |
|
779 { |
|
780 return MAknsControlContext::SupplyMopObject( aId, iFrameContext ); |
|
781 } |
|
782 else |
|
783 { |
|
784 return CCoeControl::MopSupplyObject( aId ); |
|
785 } |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CDialerNumberEntry::RectFrameInnerOuterRects |
|
790 // ----------------------------------------------------------------------------- |
|
791 // |
|
792 void CDialerNumberEntry::RectFrameInnerOuterRects( const TRect& aFrameRect, |
|
793 TRect& aOuterRect, |
|
794 TRect& aInnerRect ) |
|
795 { |
|
796 if ( iOperationMode == EModeEasyDialing ) |
|
797 { |
|
798 aOuterRect = aFrameRect; |
|
799 TAknLayoutRect innerRectLayout; |
|
800 innerRectLayout.LayoutRect( aOuterRect, AknLayoutScalable_Apps::bg_dia3_numentry_pane_g1() ); |
|
801 aInnerRect = innerRectLayout.Rect(); |
|
802 |
|
803 // Add a bit of margin to left and right ends of the entry field if layout |
|
804 // doens't define enough. This is to enhance the touch usability. |
|
805 static const TInt KMinMargin( 15 ); |
|
806 aInnerRect.iTl.iX = Max( aInnerRect.iTl.iX, aOuterRect.iTl.iX + KMinMargin ); |
|
807 aInnerRect.iBr.iX = Min( aInnerRect.iBr.iX, aOuterRect.iBr.iX - KMinMargin ); |
|
808 } |
|
809 else |
|
810 { |
|
811 if ( Layout_Meta_Data::IsMirrored() ) |
|
812 { |
|
813 TAknLayoutRect frameTopRight; |
|
814 frameTopRight.LayoutRect( |
|
815 aFrameRect, |
|
816 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() ); |
|
817 |
|
818 TAknLayoutRect frameBottomLeft; |
|
819 frameBottomLeft.LayoutRect( |
|
820 aFrameRect, |
|
821 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() ); |
|
822 |
|
823 aOuterRect = TRect( frameTopRight.Rect().iTl, |
|
824 frameBottomLeft.Rect().iBr ); |
|
825 |
|
826 aInnerRect = TRect( frameTopRight.Rect().iBr, |
|
827 frameBottomLeft.Rect().iTl ); |
|
828 } |
|
829 else |
|
830 { |
|
831 TAknLayoutRect frameTopLeft; |
|
832 frameTopLeft.LayoutRect( |
|
833 aFrameRect, |
|
834 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g2().LayoutLine() ); |
|
835 |
|
836 TAknLayoutRect frameBottomRight; |
|
837 frameBottomRight.LayoutRect( |
|
838 aFrameRect, |
|
839 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g5().LayoutLine() ); |
|
840 |
|
841 aOuterRect = TRect( frameTopLeft.Rect().iTl, |
|
842 frameBottomRight.Rect().iBr ); |
|
843 aInnerRect = TRect( frameTopLeft.Rect().iBr, |
|
844 frameBottomRight.Rect().iTl ); |
|
845 } |
|
846 } |
|
847 } |
|
848 |
|
849 // ----------------------------------------------------------------------------- |
|
850 // CDialerNumberEntry::InformNumberEntryState() |
|
851 // ----------------------------------------------------------------------------- |
|
852 // |
|
853 void CDialerNumberEntry::InformNumberEntryState() |
|
854 { |
|
855 if ( !iNumberContents && iEditor->TextLength() ) |
|
856 { |
|
857 // Hide prompt text |
|
858 if ( iLabel->Text()->Length() ) |
|
859 { |
|
860 iLabel->MakeVisible( EFalse ); |
|
861 } |
|
862 iNumberContents = ETrue; |
|
863 } |
|
864 else if ( iNumberContents && !iEditor->TextLength() ) |
|
865 { |
|
866 // Show prompt text |
|
867 if ( iLabel->Text()->Length() ) |
|
868 { |
|
869 iLabel->MakeVisible( ETrue ); |
|
870 } |
|
871 iNumberContents = EFalse; |
|
872 } |
|
873 |
|
874 if ( iPreviousNumberEntryContent.Compare( iEditor->Text() ) != 0 ) |
|
875 { |
|
876 iPreviousNumberEntryContent.Zero(); |
|
877 iEditor->GetText( iPreviousNumberEntryContent ); |
|
878 |
|
879 // The following stores the information of validity of the number for normal calls. |
|
880 // This information is needed so that we don't show call items for invalid numbers. |
|
881 TBool validPhoneNumber = Validate( iEditor->Text() ); |
|
882 TInt commandId = validPhoneNumber ? EPhoneDialerValidNumber : EPhoneDialerInvalidNumber; |
|
883 |
|
884 TRAP_IGNORE( iAppUi->HandleCommandL( commandId ) ); |
|
885 |
|
886 if ( iEasyDialer && iOperationMode == EModeEasyDialing ) |
|
887 { |
|
888 TRAP_IGNORE( iEasyDialer->SetInputL( iEditor->Text() ) ); |
|
889 } |
|
890 |
|
891 if ( iObserver ) |
|
892 { |
|
893 iObserver->NumberEntryStateChanged( iNumberContents ); |
|
894 } |
|
895 } |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CDialerNumberEntry::CheckLabelSkinningColor() |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 void CDialerNumberEntry::CheckLabelSkinningColor() |
|
903 { |
|
904 // Check skinning colour for the prompt text: |
|
905 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
906 TRgb skinColor; |
|
907 TInt error = |
|
908 AknsUtils::GetCachedColor( |
|
909 skin, |
|
910 skinColor, |
|
911 KAknsIIDQsnTextColors, |
|
912 EAknsCIQsnTextColorsCG51 ); |
|
913 |
|
914 if ( error == KErrNone ) |
|
915 { |
|
916 // Ignore error |
|
917 TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, skinColor ) ); |
|
918 } |
|
919 } |
|
920 |
|
921 // ----------------------------------------------------------------------------- |
|
922 // CDialerNumberEntry::MakeVisible( TBool aVisible ) |
|
923 // ----------------------------------------------------------------------------- |
|
924 // |
|
925 void CDialerNumberEntry::MakeVisible( TBool aVisible ) |
|
926 { |
|
927 CCoeControl::MakeVisible( aVisible ); |
|
928 iEditor->MakeVisible( aVisible ); |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CDialerNumberEntry::SetEasyDialingPlugin |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 void CDialerNumberEntry::SetEasyDialingPlugin(CDialingExtensionInterface* aEasyDialer) |
|
936 { |
|
937 DIALER_PRINT("numberentry::SetEasyDialingPlugin"); |
|
938 iEasyDialer = aEasyDialer; |
|
939 } |
|
940 |
|
941 // ----------------------------------------------------------------------------- |
|
942 // CDialerNumberEntry::SetOperationMode |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 void CDialerNumberEntry::SetOperationMode( TDialerOperationMode aMode ) |
|
946 { |
|
947 iOperationMode = aMode; |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // CDialerNumberEntry::Validate |
|
952 // ----------------------------------------------------------------------------- |
|
953 // |
|
954 TBool CDialerNumberEntry::Validate( const TDesC& aString ) |
|
955 { |
|
956 DIALER_PRINT("numberentry::Validate"); |
|
957 |
|
958 if ( aString.Length() == 0 ) |
|
959 { |
|
960 return EFalse; |
|
961 } |
|
962 |
|
963 // check first character |
|
964 TPtrC valid( KPhoneValidChars ); |
|
965 if ( valid.Locate( aString[0] ) == KErrNotFound ) |
|
966 { |
|
967 return EFalse; |
|
968 } |
|
969 |
|
970 // if vanitydialing feature is enabled, also capital A-Z are accepted after first character |
|
971 if ( FeatureManager::FeatureSupported( KFeatureIdFfHomeScreenVanityDialing ) ) |
|
972 { |
|
973 valid.Set( KPhoneVanityValidChars ); |
|
974 } |
|
975 |
|
976 // check rest of the string |
|
977 for ( TInt i = 1; i < aString.Length(); i++ ) |
|
978 { |
|
979 if ( valid.Locate( aString[i] ) == KErrNotFound ) |
|
980 { |
|
981 return EFalse; |
|
982 } |
|
983 } |
|
984 |
|
985 return ETrue; |
|
986 } |
|
987 |
|
988 // End of File |