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 keypad and numberentry container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <avkon.rsg> |
|
22 #include <apgcli.h> |
|
23 #include <apacmdln.h> |
|
24 #include <eikspane.h> |
|
25 #include <aknenv.h> // AKN_LAF_COLOR |
|
26 #include <AknUtils.h> |
|
27 #include <AknsUtils.h> |
|
28 #include <aknappui.h> |
|
29 #include <aknlayoutscalable_apps.cdl.h> |
|
30 #include <layoutmetadata.cdl.h> |
|
31 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR |
|
32 #include <bautils.h> // for BaflUtils |
|
33 #include <aknedsts.h> |
|
34 |
|
35 #include "cdialer.h" |
|
36 #include "dialercommon.h" |
|
37 #include <dialer.rsg> |
|
38 #include "dialer.hrh" |
|
39 #include "cdialerkeypadcontainer.h" |
|
40 #include "cdialernumberentry.h" |
|
41 #include "dialertrace.h" |
|
42 #include "mnumberentry.h" |
|
43 |
|
44 /// ROM drive. |
|
45 _LIT( KDialerResourceFile, "dialer.rsc" ); |
|
46 // number entry, keypad area |
|
47 const TInt KContainedControlsInTelephonyMode = 2; |
|
48 |
|
49 // ========================= MEMBER FUNCTIONS ================================ |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CDialer::NewL |
|
53 // |
|
54 // Symbian OS two phased constructor for telephony phone dialer mode |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CDialer* CDialer::NewL( const CCoeControl& aContainer, |
|
58 const TRect& aRect ) |
|
59 { |
|
60 CDialer* self = new( ELeave )CDialer ( ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL( aContainer , aRect ); |
|
63 CleanupStack::Pop(); // self |
|
64 return self; |
|
65 } |
|
66 |
|
67 // Destructor |
|
68 EXPORT_C CDialer::~CDialer() |
|
69 { |
|
70 DIALER_PRINT("CDialer::~CDialer<"); |
|
71 AknsUtils::DeregisterControlPosition( this ); |
|
72 |
|
73 delete iKeypadArea; |
|
74 delete iNumberEntry; |
|
75 |
|
76 UnLoadResources(); |
|
77 DIALER_PRINT("CDialer::~CDialer>"); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CDialer::ConstructL |
|
82 // |
|
83 // Symbian OS two phased constructor for phone dialer more. |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CDialer::ConstructL( |
|
87 const CCoeControl& aContainer, |
|
88 const TRect& aRect ) |
|
89 { |
|
90 DIALER_PRINT("CDialer::ConstructL<"); |
|
91 LoadResourceL(); |
|
92 |
|
93 // set window |
|
94 SetContainerWindowL( aContainer ); |
|
95 SetParent( const_cast<CCoeControl*>(&aContainer) ); |
|
96 iParentControl = &aContainer; |
|
97 |
|
98 iNumberEntry = CDialerNumberEntry::NewL( *this ); |
|
99 |
|
100 iKeypadArea = CDialerKeyPadContainer::NewL( *this, EModeDialer ); |
|
101 |
|
102 SetRect( aRect ); |
|
103 |
|
104 SetComponentsToInheritVisibility( ETrue ); |
|
105 |
|
106 ActivateL(); |
|
107 DIALER_PRINT("CDialer::ConstructL>"); |
|
108 } |
|
109 |
|
110 // Constructor |
|
111 CDialer::CDialer( ) : |
|
112 iEikEnv( *CEikonEnv::Static() ) |
|
113 { |
|
114 // Empty |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CDialer::NumberEntry |
|
119 // |
|
120 // Return pointer to MNumberEntry interface. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C MNumberEntry* CDialer::NumberEntry() |
|
124 { |
|
125 return this; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CDialer::SetNumberEntryObserver |
|
130 // |
|
131 // |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C void CDialer::SetNumberEntryObserver( MNumberEntryObserver& aObserver ) |
|
135 { |
|
136 iNumberEntry->SetNumberEntryObserver( aObserver ); |
|
137 } |
|
138 |
|
139 // Methods from MNumberEntry |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CDialer::CreateNumberEntry |
|
143 // |
|
144 // Creates number entry in phone dialer mode. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CDialer::CreateNumberEntry() |
|
148 { |
|
149 DIALER_PRINT("CDialer::CreateNumberEntry<"); |
|
150 |
|
151 iIsUsed = ETrue; |
|
152 |
|
153 DIALER_PRINT("CDialer::CreateNumberEntry>"); |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CDialer::GetNumberEntry |
|
158 // |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CCoeControl* CDialer::GetNumberEntry( ) const |
|
162 { |
|
163 CCoeControl* control( NULL ); |
|
164 control = iNumberEntry->GetNumberEntry(); |
|
165 return control; |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // CDialer::IsNumberEntryUsed |
|
170 // |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 TBool CDialer::IsNumberEntryUsed( ) const |
|
174 { |
|
175 return iIsUsed; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CDialer::SetNumberEntryVisible |
|
180 // |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CDialer::SetNumberEntryVisible( const TBool& /*aVisibility*/ ) |
|
184 { |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CDialer::SetTextToNumberEntry |
|
189 // |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CDialer::SetTextToNumberEntry( const TDesC& aDesC ) |
|
193 { |
|
194 iNumberEntry->SetTextToNumberEntry( aDesC ); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CDialer::GetTextFromNumberEntry |
|
199 // |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CDialer::GetTextFromNumberEntry( TDes& aDesC ) |
|
203 { |
|
204 iNumberEntry->GetTextFromNumberEntry( aDesC ); |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CDialer::RemoveNumberEntry |
|
209 // |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CDialer::RemoveNumberEntry( ) |
|
213 { |
|
214 ResetEditorToDefaultValues(); |
|
215 iIsUsed = EFalse; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CDialer::ChangeEditorMode |
|
220 // |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 TInt CDialer::ChangeEditorMode( TBool aDefaultMode ) |
|
224 { |
|
225 TInt ret( KErrNotSupported ); |
|
226 ret = iNumberEntry->ChangeEditorMode( aDefaultMode ); |
|
227 return ret; |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // CDialer::OpenVKBL |
|
232 // |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CDialer::OpenVkbL() |
|
236 { |
|
237 iVirtualKeyBoardOpen = ETrue; |
|
238 UpdateVkbEditorFlagsL(); |
|
239 |
|
240 iNumberEntry->HandleCommandL( EDialerCmdTouchInput ); |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // CDialer::GetEditorMode |
|
245 // |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 TInt CDialer::GetEditorMode() const |
|
249 { |
|
250 return iVirtualKeyBoardOpen ? EAknEditorTextInputMode : |
|
251 EAknEditorNumericInputMode; |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CDialer::ResetEditorToDefaultValues |
|
256 // |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CDialer::ResetEditorToDefaultValues() |
|
260 { |
|
261 iNumberEntry->ResetEditorToDefaultValues(); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // CDialer::SetNumberEntryPromptText |
|
266 // |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CDialer::SetNumberEntryPromptText( const TDesC& aPromptText ) |
|
270 { |
|
271 TRAP_IGNORE( iNumberEntry->SetNumberEntryPromptTextL( aPromptText ) ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CDialer::EnableTactileFeedback |
|
276 // |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CDialer::EnableTactileFeedback( const TBool aEnable ) |
|
280 { |
|
281 iKeypadArea->EnableTactileFeedback( aEnable ); |
|
282 } |
|
283 |
|
284 // Functions from CCoeControl |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CDialer::SizeChanged |
|
288 // |
|
289 // Called by framework when the view size is changed |
|
290 // |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 void CDialer::SizeChanged() |
|
294 { |
|
295 AknsUtils::RegisterControlPosition( this ); |
|
296 TRect parentRect(Rect()); |
|
297 |
|
298 // Method is called before containers are created. |
|
299 if ( !iKeypadArea ) |
|
300 { |
|
301 return; |
|
302 } |
|
303 |
|
304 TDialerVariety variety( EDialerVarietyLandscape ); |
|
305 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
306 { |
|
307 variety = EDialerVarietyPortrait; |
|
308 } |
|
309 // number entry |
|
310 AknLayoutUtils::LayoutControl( |
|
311 iNumberEntry, parentRect, |
|
312 AknLayoutScalable_Apps::dialer2_ne_pane( variety ).LayoutLine() ); |
|
313 // keypad area. |
|
314 AknLayoutUtils::LayoutControl( |
|
315 iKeypadArea, parentRect, |
|
316 AknLayoutScalable_Apps::grid_dialer2_keypad_pane( variety ).LayoutLine() ); |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // CDialer::PositionChanged |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 void CDialer::PositionChanged() |
|
324 { |
|
325 AknsUtils::RegisterControlPosition( this ); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CDialer::CountComponentControls |
|
330 // |
|
331 // Returns contained controls in phone dialer mode |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 TInt CDialer::CountComponentControls() const |
|
335 { |
|
336 TInt count(0); |
|
337 count = KContainedControlsInTelephonyMode; |
|
338 return count; |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CDialer::ComponentControl(TInt aIndex) const |
|
343 // |
|
344 // Returns contained control by given index. |
|
345 // --------------------------------------------------------------------------- |
|
346 // |
|
347 CCoeControl* CDialer::ComponentControl( TInt aIndex ) const |
|
348 { |
|
349 CCoeControl* currentControl(NULL); |
|
350 currentControl = ComponentControlForDialerMode( aIndex); |
|
351 return currentControl; |
|
352 } |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // CDialer::Draw |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CDialer::Draw( const TRect& /*aRect*/ ) const |
|
359 { |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // CDialer::FocusChanged |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CDialer::FocusChanged(TDrawNow aDrawNow) |
|
367 { |
|
368 iNumberEntry->SetFocus( IsFocused(), aDrawNow ); |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CDialer::MakeVisible |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 void CDialer::MakeVisible( TBool aVisible ) |
|
376 { |
|
377 CCoeControl::MakeVisible( aVisible ); |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // CDialer::PrepareForFocusGainL |
|
382 // |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 void CDialer::PrepareForFocusGainL( ) |
|
386 { |
|
387 if ( iVirtualKeyBoardOpen ) |
|
388 { |
|
389 // Clear editor flags and report |
|
390 // edwin state changed. |
|
391 iVirtualKeyBoardOpen = EFalse; |
|
392 iNumberEntry->ClearEditorFlags(); |
|
393 EdwinState()->ReportAknEdStateEventL( |
|
394 MAknEdStateObserver::EAknEdwinStateEventStateUpdate ); |
|
395 } |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // CDialer::HandleResourceChange |
|
400 // |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 void CDialer::HandleResourceChange( TInt aType ) |
|
404 { |
|
405 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
406 { |
|
407 SizeChanged(); |
|
408 } |
|
409 CCoeControl::HandleResourceChange( aType ); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // CDialer::HandlePointerEventL |
|
414 // |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CDialer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
418 { |
|
419 // Calling base class implementation |
|
420 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
421 } |
|
422 |
|
423 // Private methods |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CDialer::LoadResourceL |
|
427 // |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CDialer::LoadResourceL() |
|
431 { |
|
432 TFileName path( KDriveZ ); |
|
433 path.Append( KDC_RESOURCE_FILES_DIR ); |
|
434 path.Append( KDialerResourceFile ); |
|
435 |
|
436 RFs &fsSession= iEikEnv.FsSession(); |
|
437 BaflUtils::NearestLanguageFile( fsSession, path ); |
|
438 iResourceOffset = iEikEnv.AddResourceFileL( path ); |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CDialer::UnLoadResources |
|
443 // |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 void CDialer::UnLoadResources() |
|
447 { |
|
448 if ( iResourceOffset > 0 ) |
|
449 { |
|
450 iEikEnv.DeleteResourceFile( iResourceOffset ); |
|
451 iResourceOffset = 0; |
|
452 } |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------------------------- |
|
456 // CDialer::ComponentControlForDialerMode |
|
457 // |
|
458 // Returns contained control by given index in ohonedialer mode. |
|
459 // |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 CCoeControl* CDialer::ComponentControlForDialerMode( const TInt aIndex ) const |
|
463 { |
|
464 CCoeControl* currentControl(NULL); |
|
465 |
|
466 switch ( aIndex ) |
|
467 { |
|
468 case 0: |
|
469 currentControl = iNumberEntry; |
|
470 break; |
|
471 case 1: |
|
472 currentControl = iKeypadArea; |
|
473 break; |
|
474 default: |
|
475 { |
|
476 __ASSERT_DEBUG( EFalse, _L("CDialer::ComponentControl no such component defined")); |
|
477 } |
|
478 } |
|
479 |
|
480 return currentControl; |
|
481 } |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // CDialer::EdwinState |
|
485 // |
|
486 // Returns edwin state of the editor. |
|
487 // |
|
488 // --------------------------------------------------------------------------- |
|
489 // |
|
490 CAknEdwinState* CDialer::EdwinState() |
|
491 { |
|
492 MCoeFepAwareTextEditor_Extension1* extension = |
|
493 static_cast<MCoeFepAwareTextEditor_Extension1*> |
|
494 ( static_cast<CAknPhoneNumberEditor*> (GetNumberEntry()) ); |
|
495 |
|
496 return static_cast< CAknEdwinState* >( extension->State( KNullUid ) ); |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CDialer::UpdateVkbEditorFlagsL |
|
501 // |
|
502 // --------------------------------------------------------------------------- |
|
503 // |
|
504 void CDialer::UpdateVkbEditorFlagsL() |
|
505 { |
|
506 CAknEdwinState* edwinState = EdwinState(); |
|
507 // Set flags, input mode, SCT, permitted modes, |
|
508 // keymapping and menu for alphanumeric virtual |
|
509 // keyboard. |
|
510 edwinState->SetCurrentInputMode( EAknEditorTextInputMode ); |
|
511 edwinState->SetSpecialCharacterTableResourceId( |
|
512 R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG ); |
|
513 edwinState->SetFlags( EAknEditorFlagNoT9 | |
|
514 EAknEditorFlagLatinInputModesOnly | |
|
515 EAknEditorFlagNoEditIndicators ); |
|
516 edwinState->SetPermittedInputModes( |
|
517 EAknEditorNumericInputMode | |
|
518 EAknEditorTextInputMode ); |
|
519 edwinState->SetNumericKeymap( EAknEditorAlphanumericNumberModeKeymap ); |
|
520 edwinState->SetMenu(); |
|
521 |
|
522 // Report state updated |
|
523 edwinState->ReportAknEdStateEventL( |
|
524 MAknEdStateObserver::EAknEdwinStateEventStateUpdate ); |
|
525 } |
|
526 |
|
527 // End of File |
|