31 #include <AknLayout2Def.h> |
30 #include <AknLayout2Def.h> |
32 #include <aknlayoutscalable_apps.cdl.h> |
31 #include <aknlayoutscalable_apps.cdl.h> |
33 #include <layoutmetadata.cdl.h> |
32 #include <layoutmetadata.cdl.h> |
34 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR |
33 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR |
35 #include <touchfeedback.h> |
34 #include <touchfeedback.h> |
|
35 #include <aknlayoutscalable_avkon.cdl.h> |
|
36 #include <aknsframebackgroundcontrolcontext.h> |
36 |
37 |
37 #include "cdialerkeypadcontainer.h" |
38 #include "cdialerkeypadcontainer.h" |
38 #include "dialercommon.h" |
39 #include "dialercommon.h" |
39 #include "dialertrace.h" |
40 #include "dialertrace.h" |
40 |
41 |
41 #include "cdialerkeypadbutton.h" |
42 #include "cdialerkeypadbutton.h" |
42 _LIT( KDialerMifFileName, "dialer.mif" ); |
|
43 |
43 |
44 // Number of buttons in this container |
44 // Number of buttons in this container |
45 const TInt KNumberOfButtons = 12; |
45 const TInt KNumberOfButtons = 12; |
46 |
46 |
47 // Keypad button images |
47 struct TDialerButton |
48 const TMifDialer KKeyPadButtons[] = |
48 { |
49 { |
49 TMifDialer iBitmap; |
50 EMbmDialerQgn_indi_dialer_one, |
50 TMifDialer iBitmapMask; |
51 EMbmDialerQgn_indi_dialer_two, |
51 TInt iScanCode; |
52 EMbmDialerQgn_indi_dialer_three, |
52 TInt iKeyCode; |
53 EMbmDialerQgn_indi_dialer_four, |
53 }; |
54 EMbmDialerQgn_indi_dialer_five, |
54 |
55 EMbmDialerQgn_indi_dialer_six, |
55 const TDialerButton KKeyPadButtons[ KNumberOfButtons ] = |
56 EMbmDialerQgn_indi_dialer_seven, |
56 |
57 EMbmDialerQgn_indi_dialer_eight, |
57 { |
58 EMbmDialerQgn_indi_dialer_nine, |
58 { EMbmDialerQgn_indi_dialer_voicemail, |
59 EMbmDialerQgn_indi_dialer_prefix, |
59 EMbmDialerQgn_indi_dialer_voicemail_mask, |
60 EMbmDialerQgn_indi_dialer_zero, |
60 '1', |
61 EMbmDialerQgn_indi_dialer_hash |
61 '1' |
|
62 }, |
|
63 { KDialerNoIcon, KDialerNoIcon, |
|
64 '2', '2' }, |
|
65 { KDialerNoIcon, KDialerNoIcon, |
|
66 '3', '3' }, |
|
67 { KDialerNoIcon, KDialerNoIcon, |
|
68 '4', '4' }, |
|
69 { KDialerNoIcon, KDialerNoIcon, |
|
70 '5', '5' }, |
|
71 { KDialerNoIcon, KDialerNoIcon, |
|
72 '6', '6' }, |
|
73 { KDialerNoIcon, KDialerNoIcon, |
|
74 '7', '7' }, |
|
75 { KDialerNoIcon, KDialerNoIcon, |
|
76 '8', '8' }, |
|
77 { KDialerNoIcon, KDialerNoIcon, |
|
78 '9', '9' }, |
|
79 { KDialerNoIcon, KDialerNoIcon, |
|
80 EStdKeyNkpAsterisk, '*' }, |
|
81 { KDialerNoIcon, KDialerNoIcon, |
|
82 '0', '0' }, |
|
83 { KDialerNoIcon, KDialerNoIcon, |
|
84 EStdKeyHash, '#' } |
62 }; |
85 }; |
63 |
86 |
64 // Keypad button image masks |
87 |
65 const TMifDialer KKeyPadButtonsMasks[] = |
|
66 { |
|
67 EMbmDialerQgn_indi_dialer_one_mask, |
|
68 EMbmDialerQgn_indi_dialer_two_mask, |
|
69 EMbmDialerQgn_indi_dialer_three_mask, |
|
70 EMbmDialerQgn_indi_dialer_four_mask, |
|
71 EMbmDialerQgn_indi_dialer_five_mask, |
|
72 EMbmDialerQgn_indi_dialer_six_mask, |
|
73 EMbmDialerQgn_indi_dialer_seven_mask, |
|
74 EMbmDialerQgn_indi_dialer_eight_mask, |
|
75 EMbmDialerQgn_indi_dialer_nine_mask, |
|
76 EMbmDialerQgn_indi_dialer_prefix_mask, |
|
77 EMbmDialerQgn_indi_dialer_zero_mask, |
|
78 EMbmDialerQgn_indi_dialer_hash_mask |
|
79 }; |
|
80 |
|
81 // Match keypresses to keyevents send to the phone |
|
82 // |
|
83 const TInt TDialerButtonToKeypadMap[12][2] = |
|
84 { |
|
85 { 49, // ScanCode |
|
86 49 // KeyCode |
|
87 }, |
|
88 { 50, |
|
89 50 |
|
90 }, |
|
91 { 51, |
|
92 51 |
|
93 }, |
|
94 { 52, |
|
95 52 |
|
96 }, |
|
97 { 53, |
|
98 53 |
|
99 }, |
|
100 { 54, |
|
101 54 |
|
102 }, |
|
103 { 55, |
|
104 55 |
|
105 }, |
|
106 { 56, |
|
107 56 |
|
108 }, |
|
109 { 57, |
|
110 57 |
|
111 }, |
|
112 { EStdKeyNkpAsterisk, |
|
113 42 |
|
114 }, |
|
115 { '0', |
|
116 '0' |
|
117 }, |
|
118 { EStdKeyHash, |
|
119 35 |
|
120 } |
|
121 }; |
|
122 |
|
123 // Class declaration for CDialerKeyPadButton separated to cdialerkeypadbutton.h. |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // C++ default constructor |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 CDialerKeyPadButton::CDialerKeyPadButton() |
|
130 { |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // Destructor |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 CDialerKeyPadButton::~CDialerKeyPadButton() |
|
138 { |
|
139 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
140 if ( feedback ) |
|
141 { |
|
142 feedback->RemoveFeedbackForControl( iButton ); |
|
143 } |
|
144 delete iButton; |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // Creates number keypad button |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CDialerKeyPadButton::CreateButtonL( const TInt aScanCode, |
|
152 const TInt aKeyCode, |
|
153 const TMifDialer aButtonIcon, |
|
154 const TMifDialer aButtonIconMask ) |
|
155 { |
|
156 iScanCode = aScanCode; |
|
157 iKeyCode = aKeyCode; |
|
158 iButtonIcon = aButtonIcon; |
|
159 iButtonIconMask = aButtonIconMask; |
|
160 |
|
161 TFileName mifPath( KDriveZ ); |
|
162 mifPath.Append( KDC_APP_BITMAP_DIR ); |
|
163 mifPath.Append( KDialerMifFileName ); |
|
164 |
|
165 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
166 CFbsBitmap* bitmap (NULL); |
|
167 CFbsBitmap* mask (NULL); |
|
168 |
|
169 // Get icon ids. |
|
170 TAknsItemID skinItemId( KAknsIIDNone ); |
|
171 |
|
172 // Create button image. |
|
173 MapDialerIconToSkinIcon( aButtonIcon ,skinItemId ); |
|
174 AknsUtils::CreateColorIconLC( |
|
175 skin, |
|
176 skinItemId, |
|
177 KAknsIIDQsnIconColors, |
|
178 EAknsCIQsnIconColorsCG30, |
|
179 bitmap, |
|
180 mask, |
|
181 mifPath, |
|
182 aButtonIcon, |
|
183 aButtonIconMask, |
|
184 KRgbBlack |
|
185 ); |
|
186 |
|
187 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
188 CleanupStack::Pop( 2 ); |
|
189 CleanupStack::PushL( icon ); |
|
190 iButton = CAknButton::NewL( |
|
191 icon , // ownership taken |
|
192 NULL, NULL, NULL, _L(""), _L(""), 0, 0 ); |
|
193 iButton->SetButtonFlags( KAknButtonReportOnLongPress| |
|
194 KAknButtonReportOnKeyDown | |
|
195 KAknButtonRequestExitOnButtonUpEvent ); |
|
196 iButton->SetIconScaleMode( EAspectRatioPreserved ); |
|
197 iButton->SetMargins( TMargins8(0,0,0,0) ); |
|
198 CleanupStack::Pop( icon ); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CDialerKeyPadButton::ScanCode() const |
|
206 { |
|
207 return iScanCode; |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CDialerKeyPadButton::KeyCode() const |
|
215 { |
|
216 return iKeyCode; |
|
217 } |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CDialerKeyPadButton::MapDialerIconToSkinIcon( const TInt aDialerIcon, |
|
223 TAknsItemID& aItemId ) const |
|
224 { |
|
225 switch ( aDialerIcon ) |
|
226 { |
|
227 case EMbmDialerQgn_indi_dialer_one: |
|
228 aItemId = KAknsIIDQgnIndiDialerOne; |
|
229 break; |
|
230 case EMbmDialerQgn_indi_dialer_two: |
|
231 aItemId = KAknsIIDQgnIndiDialerTwo; |
|
232 break; |
|
233 case EMbmDialerQgn_indi_dialer_three: |
|
234 aItemId = KAknsIIDQgnIndiDialerThree; |
|
235 break; |
|
236 case EMbmDialerQgn_indi_dialer_four: |
|
237 aItemId = KAknsIIDQgnIndiDialerFour; |
|
238 break; |
|
239 case EMbmDialerQgn_indi_dialer_five: |
|
240 aItemId = KAknsIIDQgnIndiDialerFive; |
|
241 break; |
|
242 case EMbmDialerQgn_indi_dialer_six: |
|
243 aItemId = KAknsIIDQgnIndiDialerSix; |
|
244 break; |
|
245 case EMbmDialerQgn_indi_dialer_seven: |
|
246 aItemId = KAknsIIDQgnIndiDialerSeven; |
|
247 break; |
|
248 case EMbmDialerQgn_indi_dialer_eight: |
|
249 aItemId = KAknsIIDQgnIndiDialerEight; |
|
250 break; |
|
251 case EMbmDialerQgn_indi_dialer_nine: |
|
252 aItemId = KAknsIIDQgnIndiDialerNine; |
|
253 break; |
|
254 case EMbmDialerQgn_indi_dialer_zero: |
|
255 aItemId = KAknsIIDQgnIndiDialerZero; |
|
256 break; |
|
257 case EMbmDialerQgn_indi_dialer_prefix: |
|
258 aItemId = KAknsIIDQgnIndiDialerPrefix; |
|
259 break; |
|
260 case EMbmDialerQgn_indi_dialer_hash: |
|
261 aItemId = KAknsIIDQgnIndiDialerHash; |
|
262 break; |
|
263 default: |
|
264 break; |
|
265 } |
|
266 } |
|
267 |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 void CDialerKeyPadButton::SetIconSize( TSize& aSize ) |
|
273 { |
|
274 iButton->SetIconSize( aSize ); |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CDialerKeyPadButton::UpdateIconL() |
|
282 { |
|
283 TFileName mifPath( KDriveZ ); |
|
284 mifPath.Append( KDC_APP_BITMAP_DIR ); |
|
285 mifPath.Append( KDialerMifFileName ); |
|
286 |
|
287 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
288 CFbsBitmap* bitmap (NULL); |
|
289 CFbsBitmap* mask (NULL); |
|
290 |
|
291 // Get icon id. |
|
292 TAknsItemID skinItemId( KAknsIIDNone ); |
|
293 MapDialerIconToSkinIcon( iButtonIcon, skinItemId ); |
|
294 |
|
295 AknsUtils::CreateColorIconLC( |
|
296 skin, |
|
297 skinItemId, |
|
298 KAknsIIDQsnIconColors, |
|
299 EAknsCIQsnIconColorsCG30, |
|
300 bitmap, |
|
301 mask, |
|
302 mifPath, |
|
303 iButtonIcon, |
|
304 iButtonIconMask, |
|
305 KRgbBlack |
|
306 ); |
|
307 |
|
308 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
309 CleanupStack::Pop( 2 ); |
|
310 |
|
311 iButton->State()->SetIcon( icon ); // icon ownership transfered |
|
312 |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 // Enable or disable audio but keep vibra feedback |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 void CDialerKeyPadButton::EnableAudioFeedback( const TBool aEnable ) |
|
321 { |
|
322 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
323 if ( feedback ) |
|
324 { |
|
325 feedback->EnableFeedbackForControl( iButton, ETrue, aEnable ); |
|
326 } |
|
327 } |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CDialerKeyPadButton::HandleResourceChange( TInt aType ) |
|
333 { |
|
334 if ( aType == KAknsMessageSkinChange ) |
|
335 { |
|
336 TRAP_IGNORE( UpdateIconL() ); |
|
337 iButton->HandleResourceChange( aType ); |
|
338 } |
|
339 } |
|
340 |
88 |
341 // ========================= MEMBER FUNCTIONS ================================ |
89 // ========================= MEMBER FUNCTIONS ================================ |
342 |
90 |
343 // --------------------------------------------------------------------------- |
91 // --------------------------------------------------------------------------- |
344 // Symbian OS two phased constructor |
92 // Symbian OS two phased constructor |
495 inline TAknLayoutScalableParameterLimits cell_dialer2_keypad_pane_g1_ParamLimits() |
244 inline TAknLayoutScalableParameterLimits cell_dialer2_keypad_pane_g1_ParamLimits() |
496 */ |
245 */ |
497 |
246 |
498 TRect parentRect( Rect() ); |
247 TRect parentRect( Rect() ); |
499 |
248 |
500 // Icon size - all in same size |
|
501 TAknLayoutRect functionGraphics; |
|
502 |
|
503 functionGraphics.LayoutRect( |
|
504 parentRect, |
|
505 TAknWindowComponentLayout::Compose( |
|
506 AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety ), |
|
507 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_g1( |
|
508 iVariety ) ) ); |
|
509 TSize iconSize = functionGraphics.Rect().Size(); |
|
510 |
|
511 // Layout buttons |
249 // Layout buttons |
512 TAknLayoutScalableParameterLimits limits = |
250 TAknLayoutScalableParameterLimits limits = |
513 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety ); |
251 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety ); |
514 |
252 |
515 TInt i = 0; |
253 TInt i = 0; |
516 for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ ) |
254 for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ ) |
517 { |
255 { |
518 for ( TInt col = limits.FirstColumn(); |
256 for ( TInt col = limits.FirstColumn(); |
519 col <= limits.LastColumn(); col++ ) |
257 col <= limits.LastColumn(); col++ ) |
520 { |
258 { |
|
259 iButtons[i]->SetVariety( iVariety ); |
|
260 iButtons[i]->SetOperationMode( iOperatingMode ); |
|
261 |
|
262 AknLayoutUtils::LayoutControl( iButtons[i], parentRect, TAknWindowComponentLayout::Compose( |
|
263 AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety, col, row ), |
|
264 AknLayoutScalable_Apps::bg_button_pane_pane_cp04( iVariety ) ) ); |
|
265 i++; |
|
266 } |
|
267 } |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CDialerKeyPadContainer::SetEasyDialingLayout |
|
272 // |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 void CDialerKeyPadContainer::SetEasyDialingLayout() |
|
276 { |
|
277 TRect parentRect( Rect() ); |
|
278 |
|
279 // Layout buttons |
|
280 TAknLayoutScalableParameterLimits limits = |
|
281 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety ); |
|
282 |
|
283 // Rectangle of the first button |
|
284 TAknLayoutRect buttonLayoutRect; |
|
285 buttonLayoutRect.LayoutRect( parentRect, |
|
286 AknLayoutScalable_Apps::cell_dia3_key_num_pane( iVariety ) ); |
|
287 TRect firstButtonRect = buttonLayoutRect.Rect(); |
|
288 // Move the first button rect to top-left-corner of the keypad area, |
|
289 // the default place is wrong in mirrored layout. |
|
290 firstButtonRect.SetRect( parentRect.iTl, firstButtonRect.Size() ); |
|
291 |
|
292 TInt colCount = limits.LastColumn() - limits.FirstColumn() + 1; |
|
293 |
|
294 for ( TInt row = limits.FirstRow() ; row <= limits.LastRow() ; row++ ) |
|
295 { |
|
296 for ( TInt col = limits.FirstColumn() ; col <= limits.LastColumn() ; col++ ) |
|
297 { |
|
298 // Calculate corresponding index in iButtons array |
|
299 TInt idx = col + row * colCount; |
|
300 |
|
301 // Set mode and variety so that correct button internal layout will be used |
|
302 iButtons[idx]->SetVariety( iVariety ); |
|
303 iButtons[idx]->SetOperationMode( iOperatingMode ); |
|
304 |
521 // Layout button |
305 // Layout button |
522 AknLayoutUtils::LayoutControl( |
306 TRect buttonRect = firstButtonRect; |
523 ((CDialerKeyPadButton*)iButtons[i])->Control(), parentRect, |
307 buttonRect.Move( col * buttonRect.Width(), row * buttonRect.Height() ); |
524 TAknWindowComponentLayout::Compose( |
308 buttonRect.Shrink( 1, 1 ); // to create small gap between buttons |
525 AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety, |
309 iButtons[idx]->SetRect( buttonRect ); |
526 col, row ), |
|
527 AknLayoutScalable_Apps::bg_button_pane_pane_cp04( |
|
528 iVariety ) ) ); |
|
529 |
|
530 // Set icon size |
|
531 ((CDialerKeyPadButton*)iButtons[i++])->SetIconSize( iconSize ); |
|
532 } |
310 } |
533 } |
311 } |
|
312 |
534 } |
313 } |
535 |
314 |
536 // --------------------------------------------------------------------------- |
315 // --------------------------------------------------------------------------- |
537 // CDialerKeyPadContainer::SetVideoLayout |
316 // CDialerKeyPadContainer::SetVideoLayout |
538 // |
317 // |
588 // |
354 // |
589 void CDialerKeyPadContainer::CreateButtonsL() |
355 void CDialerKeyPadContainer::CreateButtonsL() |
590 { |
356 { |
591 DIALER_PRINT("KeyPadContainer::CreateButtonsL<"); |
357 DIALER_PRINT("KeyPadContainer::CreateButtonsL<"); |
592 |
358 |
593 for ( TInt i=0; i < KNumberOfButtons; i++ ) |
359 TInt flags ( KAknButtonReportOnLongPress| |
594 { |
360 KAknButtonReportOnKeyDown | |
595 CDialerKeyPadButton* button = new (ELeave) CDialerKeyPadButton(); |
361 KAknButtonRequestExitOnButtonUpEvent ); |
596 CleanupStack::PushL( button ); |
362 |
597 button->CreateButtonL( TDialerButtonToKeypadMap[i][0], |
363 for ( TInt i = 0; i < KNumberOfButtons; i++ ) |
598 TDialerButtonToKeypadMap[i][1], |
364 { |
599 KKeyPadButtons[i], |
365 const TPtrC numLabel = iKeyLabelManager->ButtonNumLabel( i ); |
600 KKeyPadButtonsMasks[i] ); |
366 |
|
367 const TPtrC alphaLabel = iKeyLabelManager->ButtonFirstAlphaLabel( i ); |
|
368 |
|
369 const TPtrC secondAlphaLabel = iKeyLabelManager->ButtonSecondAlphaLabel( i ); |
|
370 |
|
371 CDialerKeyPadButton* button = CDialerKeyPadButton::NewLC( |
|
372 numLabel, |
|
373 alphaLabel, |
|
374 secondAlphaLabel, |
|
375 KKeyPadButtons[i].iScanCode, |
|
376 KKeyPadButtons[i].iKeyCode, |
|
377 KKeyPadButtons[i].iBitmap, |
|
378 KKeyPadButtons[i].iBitmapMask, |
|
379 flags ); |
|
380 iButtons.AppendL( button ); |
601 CleanupStack::Pop( button ); |
381 CleanupStack::Pop( button ); |
602 iButtons.Append( button ); |
382 |
603 button->Control()->SetMopParent( this ); |
383 button->SetMopParent( this ); |
604 button->Control()->SetParent( this ); |
384 button->SetParent( this ); |
605 button->Control()->SetContainerWindowL( *this ); |
385 button->SetContainerWindowL( *this ); |
606 button->Control()->SetObserver( this ); |
386 button->SetObserver( this ); |
607 button->Control()->ActivateL(); |
387 button->ActivateL(); |
608 AknsUtils::RegisterControlPosition( button->Control() ); |
|
609 } |
388 } |
610 DIALER_PRINT("KeyPadContainer::CreateButtonsL>"); |
389 DIALER_PRINT("KeyPadContainer::CreateButtonsL>"); |
611 } |
390 } |
612 |
391 |
613 // --------------------------------------------------------------------------- |
392 // --------------------------------------------------------------------------- |
614 // CDialerKeyPadContainer::HandleControlEventL |
393 // CDialerKeyPadContainer::HandleControlEventL |
615 // |
394 // |