|
1 /* |
|
2 * Copyright (c) 2005-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: Handles publishing to title pane. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikbtgpc.h> |
|
20 #include <aknappui.h> |
|
21 #include <StringLoader.h> |
|
22 #include <AiNativeUi.rsg> |
|
23 #include <gulicon.h> |
|
24 #include <AknIconUtils.h> |
|
25 #include <AknsConstants.h> |
|
26 #include <aknlayoutscalable_avkon.cdl.h> |
|
27 #include <AknStatuspaneUtils.h> |
|
28 #include <layoutmetadata.cdl.h> |
|
29 #include <AknUtils.h> |
|
30 #include <eiksoftkeyimage.h> |
|
31 #include <AknSgcc.h> |
|
32 #include <aiscutplugindomaincrkeys.h> |
|
33 |
|
34 #include "ainativeui.hrh" |
|
35 #include "aisoftkeyrenderer.h" |
|
36 #include "ainativeuiplugins.h" |
|
37 #include "aiscutdefs.h" |
|
38 |
|
39 |
|
40 using namespace AiNativeUiController; |
|
41 |
|
42 // Index for left softkey; defined in avkon |
|
43 const TInt KNativeUiLeftSoftkeyId = 0; |
|
44 |
|
45 // Index for right softkey; defined in avkon |
|
46 const TInt KNativeUiRightSoftkeyId = 2; |
|
47 |
|
48 const TInt KControlArrayCBAButton1Posn =0; |
|
49 const TInt KControlArrayCBAButton2Posn =2; |
|
50 const TInt KControlArrayCBAButtonMiddlePosn =3; |
|
51 |
|
52 const TInt KWideScreenWidth = 640; |
|
53 |
|
54 |
|
55 inline TAknWindowComponentLayout DoCompose( TAknWindowComponentLayout aLine1, |
|
56 TAknWindowComponentLayout aLine2 ) |
|
57 { |
|
58 return TAknWindowComponentLayout::Compose( aLine1, aLine2 ); |
|
59 } |
|
60 |
|
61 inline TAknTextComponentLayout DoComposeText( TAknWindowComponentLayout aLine1, |
|
62 TAknTextComponentLayout aLine2 ) |
|
63 { |
|
64 return TAknWindowComponentLayout::ComposeText( aLine1, aLine2 ); |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 // Calculate (whole) softkey area for Bottom button (landscape) |
|
71 // ----------------------------------------------------------------------------- |
|
72 static TBool HDLayoutActive() |
|
73 { |
|
74 TInt resourceId = 0; |
|
75 CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current(); |
|
76 |
|
77 if ( statusPane ) // Return the resource ID of app statuspane if it exists. |
|
78 { |
|
79 resourceId = statusPane->CurrentLayoutResId(); |
|
80 } |
|
81 else // If this app does not have statuspane, then we ask the layout from AknCapServer. |
|
82 { |
|
83 resourceId = CAknSgcClient::CurrentStatuspaneResource(); |
|
84 } |
|
85 |
|
86 TBool retVal = EFalse; |
|
87 |
|
88 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
89 { |
|
90 // Can be widescreen only in landscape orientation. |
|
91 retVal = ( resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL || |
|
92 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE || |
|
93 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT || |
|
94 resourceId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT ); |
|
95 } |
|
96 |
|
97 return retVal; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 // Calculate softkey image graphics area for Bottom button (landscape) |
|
104 // ----------------------------------------------------------------------------- |
|
105 static TRect SoftkeyRectBottomGraphics() |
|
106 { |
|
107 TRect screen; |
|
108 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
109 |
|
110 TAknWindowComponentLayout rightAreaLayout( |
|
111 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
112 |
|
113 TAknWindowComponentLayout bottomSKLayout( |
|
114 DoCompose( rightAreaLayout, |
|
115 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ) ); |
|
116 |
|
117 // Calculate softkey rects. |
|
118 // Left (bottom in landscape) softkey layout. |
|
119 TAknLayoutRect leftSoftkeyLayoutRect; |
|
120 leftSoftkeyLayoutRect.LayoutRect( screen, |
|
121 bottomSKLayout.LayoutLine() ); |
|
122 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
123 |
|
124 // Calculate softkey image layout. |
|
125 // Left (bottom in landscape) softkey layout. |
|
126 TAknWindowLineLayout leftSoftkeyImageLayout( |
|
127 DoCompose( |
|
128 bottomSKLayout, |
|
129 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane_g1() ).LayoutLine() ); |
|
130 |
|
131 |
|
132 TAknLayoutRect qgn_graf_sk_left; |
|
133 qgn_graf_sk_left.LayoutRect( screen, leftSoftkeyImageLayout ); |
|
134 |
|
135 return qgn_graf_sk_left.Rect(); |
|
136 } |
|
137 |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 // Calculate softkey image graphics area for Top button (landscape) |
|
142 // ----------------------------------------------------------------------------- |
|
143 static TRect SoftkeyRectTopGraphics() |
|
144 { |
|
145 TRect screen; |
|
146 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
147 |
|
148 TAknWindowComponentLayout rightAreaLayout( |
|
149 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
150 |
|
151 TAknWindowComponentLayout topSKLayout( |
|
152 DoCompose( rightAreaLayout, |
|
153 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ) ); |
|
154 |
|
155 // Calculate softkey rects. |
|
156 // Right (top in landscape) softkey layout. |
|
157 TAknLayoutRect rightSoftkeyLayoutRect; |
|
158 rightSoftkeyLayoutRect.LayoutRect( screen, |
|
159 topSKLayout.LayoutLine() ); |
|
160 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
161 |
|
162 // Left (bottom in landscape) softkey layout. |
|
163 // Right (top in landscape) softkey layout. |
|
164 TAknWindowLineLayout rightSoftkeyImageLayout( |
|
165 DoCompose( |
|
166 topSKLayout, |
|
167 AknLayoutScalable_Avkon::sctrl_sk_top_pane_g1() ).LayoutLine() ); |
|
168 |
|
169 TAknLayoutRect qgn_graf_sk_right; |
|
170 qgn_graf_sk_right.LayoutRect( screen, rightSoftkeyImageLayout ); |
|
171 return qgn_graf_sk_right.Rect(); |
|
172 } |
|
173 |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // SoftkeyRectL |
|
177 // Calculate soft key rect |
|
178 // ----------------------------------------------------------------------------- |
|
179 static TRect SoftkeyRectL( CEikButtonGroupContainer& aContainer, TInt aPos, TBool aImageOn ) |
|
180 { |
|
181 TRect rect; |
|
182 |
|
183 if( AknStatuspaneUtils::StaconPaneActive() ) |
|
184 { |
|
185 TInt variety( 0 ); |
|
186 |
|
187 if( AknStatuspaneUtils::StaconSoftKeysLeft() ) |
|
188 { |
|
189 variety = 1; |
|
190 } |
|
191 |
|
192 TRect parentRect( iAvkonAppUi->ApplicationRect() ); |
|
193 |
|
194 switch( aPos ) |
|
195 { |
|
196 case KControlArrayCBAButton1Posn: |
|
197 { |
|
198 TAknWindowComponentLayout layout0( AknLayoutScalable_Avkon::area_bottom_pane( 2 ) ); |
|
199 TAknWindowComponentLayout layout1( AknLayoutScalable_Avkon::stacon_bottom_pane() ); |
|
200 |
|
201 // If clock is shown in stacon, cba area is smaller. |
|
202 TInt bottomCbaVariety( variety ); |
|
203 |
|
204 if( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
205 { |
|
206 bottomCbaVariety += 2; |
|
207 } |
|
208 |
|
209 TAknWindowComponentLayout layout2( AknLayoutScalable_Avkon::control_bottom_pane_stacon( bottomCbaVariety ) ); |
|
210 |
|
211 if( aImageOn ) |
|
212 { |
|
213 // Icon layout |
|
214 TAknWindowComponentLayout iconLayout( AknLayoutScalable_Avkon::control_bottom_pane_stacon_g1() ); |
|
215 |
|
216 TAknWindowComponentLayout lskIconLayout( DoCompose( layout0, |
|
217 DoCompose( layout1, DoCompose( layout2, iconLayout ) ) ) ); |
|
218 |
|
219 TAknWindowLineLayout lskIcon( lskIconLayout.LayoutLine() ); |
|
220 |
|
221 TAknLayoutRect qgn_icon_lsk; |
|
222 |
|
223 qgn_icon_lsk.LayoutRect( parentRect, lskIcon ); |
|
224 |
|
225 rect = qgn_icon_lsk.Rect(); |
|
226 } |
|
227 else |
|
228 { |
|
229 // Text layout |
|
230 TAknTextComponentLayout textLayout( AknLayoutScalable_Avkon::control_bottom_pane_stacon_t1( variety ) ); |
|
231 |
|
232 TAknTextComponentLayout lskTextLayout( DoComposeText( layout0, |
|
233 DoComposeText( layout1, DoComposeText( layout2, textLayout ) ) ) ); |
|
234 |
|
235 TAknTextLineLayout lskText( lskTextLayout.LayoutLine() ); |
|
236 |
|
237 TAknLayoutText qgn_text_lsk; |
|
238 |
|
239 qgn_text_lsk.LayoutText( parentRect, lskText ); |
|
240 |
|
241 rect = qgn_text_lsk.TextRect(); |
|
242 } |
|
243 } |
|
244 break; |
|
245 case KControlArrayCBAButton2Posn: |
|
246 { |
|
247 TAknWindowComponentLayout layout0( AknLayoutScalable_Avkon::area_top_pane( 2 ) ); |
|
248 TAknWindowComponentLayout layout1( AknLayoutScalable_Avkon::stacon_top_pane() ); |
|
249 |
|
250 TInt topCbaVariety( variety ); |
|
251 |
|
252 if( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
253 { |
|
254 topCbaVariety += 4; |
|
255 } |
|
256 |
|
257 TAknWindowComponentLayout layout2( AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ) ); |
|
258 |
|
259 if( aImageOn ) |
|
260 { |
|
261 // Icon layout |
|
262 TAknWindowComponentLayout iconLayout( AknLayoutScalable_Avkon::control_top_pane_stacon_g1() ); |
|
263 |
|
264 TAknWindowComponentLayout rskIconLayout( DoCompose( layout0, |
|
265 DoCompose( layout1, DoCompose( layout2, iconLayout ) ) ) ); |
|
266 |
|
267 TAknWindowLineLayout rskIcon( rskIconLayout.LayoutLine() ); |
|
268 |
|
269 TAknLayoutRect qgn_icon_rsk; |
|
270 |
|
271 qgn_icon_rsk.LayoutRect( parentRect, rskIcon ); |
|
272 |
|
273 rect = qgn_icon_rsk.Rect(); |
|
274 } |
|
275 else |
|
276 { |
|
277 // Text layout |
|
278 TAknTextComponentLayout textLayout( AknLayoutScalable_Avkon::control_top_pane_stacon_t1( variety ) ); |
|
279 |
|
280 TAknTextComponentLayout rskTextLayout( DoComposeText( layout0, |
|
281 DoComposeText( layout1, DoComposeText( layout2, textLayout ) ) ) ); |
|
282 |
|
283 TAknTextLineLayout rskText( rskTextLayout.LayoutLine() ); |
|
284 |
|
285 TAknLayoutText qgn_text_rsk; |
|
286 |
|
287 qgn_text_rsk.LayoutText( parentRect, rskText ); |
|
288 |
|
289 rect = qgn_text_rsk.TextRect(); |
|
290 } |
|
291 } |
|
292 break; |
|
293 default: |
|
294 User::Leave( KErrNotSupported ); |
|
295 break; |
|
296 |
|
297 } |
|
298 } |
|
299 else |
|
300 { |
|
301 TInt textVariety( 0 ); |
|
302 TInt graphVariety( 0 ); |
|
303 |
|
304 TBool mskEnabled( AknLayoutUtils::MSKEnabled() && Layout_Meta_Data::IsMSKEnabled() ); |
|
305 |
|
306 if ( mskEnabled ) |
|
307 { |
|
308 textVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 3; |
|
309 graphVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 4; |
|
310 } |
|
311 else |
|
312 { |
|
313 textVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 0; |
|
314 graphVariety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 4; |
|
315 } |
|
316 |
|
317 CEikCba* cba( static_cast< CEikCba* >( aContainer.ButtonGroup() ) ); |
|
318 |
|
319 TRect parentRect( cba->Rect() ); |
|
320 |
|
321 switch( aPos ) |
|
322 { |
|
323 case KControlArrayCBAButton1Posn: |
|
324 { |
|
325 if( aImageOn ) |
|
326 { |
|
327 if ( HDLayoutActive() && |
|
328 AKN_LAYOUT_WINDOW_screen.iW == KWideScreenWidth ) |
|
329 { |
|
330 rect = SoftkeyRectBottomGraphics(); |
|
331 } |
|
332 else |
|
333 { |
|
334 |
|
335 TAknLayoutRect qgn_icon_lsk; |
|
336 |
|
337 qgn_icon_lsk.LayoutRect( parentRect, |
|
338 AknLayoutScalable_Avkon::control_pane_g1( graphVariety ).LayoutLine() ); |
|
339 |
|
340 rect = qgn_icon_lsk.Rect(); |
|
341 } |
|
342 } |
|
343 else |
|
344 { |
|
345 TAknLayoutText qgn_text_lsk; |
|
346 |
|
347 qgn_text_lsk.LayoutText( parentRect, |
|
348 AknLayoutScalable_Avkon::control_pane_t1( textVariety ).LayoutLine() ); |
|
349 |
|
350 rect = qgn_text_lsk.TextRect(); |
|
351 } |
|
352 } |
|
353 break; |
|
354 case KControlArrayCBAButton2Posn: |
|
355 { |
|
356 if( aImageOn ) |
|
357 { |
|
358 if ( HDLayoutActive() && |
|
359 AKN_LAYOUT_WINDOW_screen.iW == KWideScreenWidth ) |
|
360 { |
|
361 rect = SoftkeyRectTopGraphics(); |
|
362 } |
|
363 else |
|
364 { |
|
365 TAknLayoutRect qgn_icon_rsk; |
|
366 |
|
367 qgn_icon_rsk.LayoutRect( parentRect, |
|
368 AknLayoutScalable_Avkon::control_pane_g2( graphVariety ).LayoutLine() ); |
|
369 |
|
370 rect = qgn_icon_rsk.Rect(); |
|
371 } |
|
372 } |
|
373 else |
|
374 { |
|
375 TAknLayoutText qgn_text_rsk; |
|
376 |
|
377 qgn_text_rsk.LayoutText( parentRect, |
|
378 AknLayoutScalable_Avkon::control_pane_t2( textVariety ).LayoutLine() ); |
|
379 |
|
380 rect = qgn_text_rsk.TextRect(); |
|
381 } |
|
382 } |
|
383 break; |
|
384 case KControlArrayCBAButtonMiddlePosn: |
|
385 { |
|
386 if( !mskEnabled || aImageOn ) |
|
387 { |
|
388 // No msk, or asking image size for msk |
|
389 User::Leave( KErrNotSupported ); |
|
390 } |
|
391 else |
|
392 { |
|
393 TAknLayoutText qgn_text_msk; |
|
394 |
|
395 qgn_text_msk.LayoutText( parentRect, |
|
396 AknLayoutScalable_Avkon::control_pane_t3( textVariety ).LayoutLine() ); |
|
397 |
|
398 rect = qgn_text_msk.TextRect(); |
|
399 } |
|
400 } |
|
401 break; |
|
402 default: |
|
403 User::Leave( KErrNotFound ); |
|
404 break; |
|
405 } |
|
406 } |
|
407 |
|
408 return rect; |
|
409 } |
|
410 |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // SoftkeySizeL |
|
414 // Calculate soft key size |
|
415 // ----------------------------------------------------------------------------- |
|
416 static TSize SoftkeySizeL( CEikButtonGroupContainer& aContainer, TInt aPos, TBool aImageOn ) |
|
417 { |
|
418 TSize size( SoftkeyRectL( aContainer, aPos, aImageOn ).Size() ); |
|
419 |
|
420 return size; |
|
421 } |
|
422 |
|
423 |
|
424 void CAiSoftKeyRenderer::ConstructL() |
|
425 { |
|
426 // load default soft key labels from resource |
|
427 CreateDefaultSoftKeysL(); |
|
428 } |
|
429 |
|
430 |
|
431 CAiSoftKeyRenderer* CAiSoftKeyRenderer::NewLC() |
|
432 { |
|
433 CAiSoftKeyRenderer* self = new( ELeave ) CAiSoftKeyRenderer(); |
|
434 CleanupStack::PushL( self ); |
|
435 self->ConstructL(); |
|
436 return self; |
|
437 } |
|
438 |
|
439 |
|
440 CAiSoftKeyRenderer::~CAiSoftKeyRenderer() |
|
441 { |
|
442 delete iText; |
|
443 |
|
444 if ( iCba ) |
|
445 { |
|
446 CEikCba* cba = |
|
447 static_cast< CEikCba* >( iCba->ButtonGroup() ); |
|
448 iAppUi->RemoveFromStack( cba ); |
|
449 } |
|
450 delete iCba; |
|
451 } |
|
452 |
|
453 |
|
454 CAiSoftKeyRenderer::CAiSoftKeyRenderer() |
|
455 { |
|
456 iAppUi = iAvkonAppUi; |
|
457 } |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 void CAiSoftKeyRenderer::DoPublishL( MAiPropertyExtension& aPlugin, |
|
463 TInt aContent, |
|
464 const TDesC16& aText, |
|
465 TInt aIndex ) |
|
466 { |
|
467 if( aPlugin.PublisherInfoL()->iUid == KShortcutPluginUid ) |
|
468 { |
|
469 if( aContent == KAiScutContent[EAiScutContentShortcutShortCaption].id ) |
|
470 { |
|
471 HBufC* temp = aText.AllocL(); |
|
472 delete iText; |
|
473 iText = temp; |
|
474 |
|
475 UpdateSoftKeyL( aIndex, NULL ); |
|
476 } |
|
477 } |
|
478 else |
|
479 { |
|
480 User::Leave( KErrNotFound ); |
|
481 } |
|
482 } |
|
483 |
|
484 |
|
485 void CAiSoftKeyRenderer::DoPublishL( MAiPropertyExtension& aPlugin, |
|
486 TInt aContent, |
|
487 TInt aResource, |
|
488 TInt aIndex ) |
|
489 { |
|
490 if( aPlugin.PublisherInfoL()->iUid == KShortcutPluginUid ) |
|
491 { |
|
492 if( aContent == KAiScutContent[EAiScutContentShortcutShortCaption].id ) |
|
493 { |
|
494 TInt internalId = KErrNotFound; |
|
495 switch( aResource ) |
|
496 { |
|
497 case EAiScutResourceBackCaption: |
|
498 { |
|
499 internalId = R_NATIVEUI_SK_BACK; |
|
500 break; |
|
501 } |
|
502 case EAiScutResourceNewMsgShortCaption: |
|
503 { |
|
504 internalId = R_NATIVEUI_SK_NEWMSG; |
|
505 break; |
|
506 } |
|
507 case EAiScutResourceNewEmailShortCaption: |
|
508 { |
|
509 internalId = R_NATIVEUI_SK_EMAIL; |
|
510 break; |
|
511 } |
|
512 case EAiScutResourceNewSyncMLMailShortCaption: |
|
513 { |
|
514 internalId = R_NATIVEUI_SK_SYNCMLMAIL; |
|
515 break; |
|
516 } |
|
517 case EAiScutResourceNewPostcardShortCaption: |
|
518 { |
|
519 internalId = R_NATIVEUI_SK_MMSPOSTCARD; |
|
520 break; |
|
521 } |
|
522 case EAiScutResourceSelectMsgTypeShortCaption: |
|
523 { |
|
524 internalId = R_NATIVEUI_SK_MSGTYPE; |
|
525 break; |
|
526 } |
|
527 case EAiScutResourceNewAudioMsgShortCaption: |
|
528 { |
|
529 internalId = R_NATIVEUI_SK_AUDIOMSG; |
|
530 break; |
|
531 } |
|
532 case EAiScutResourceChangeThemeShortCaption: |
|
533 { |
|
534 internalId = R_NATIVEUI_SK_CHANGETHEME; |
|
535 break; |
|
536 } |
|
537 default: |
|
538 { |
|
539 User::Leave( KErrNotFound ); |
|
540 } |
|
541 } |
|
542 |
|
543 HBufC* temp = StringLoader::LoadL( internalId ); |
|
544 delete iText; |
|
545 iText = temp; |
|
546 |
|
547 UpdateSoftKeyL( aIndex, NULL ); |
|
548 } |
|
549 } |
|
550 else |
|
551 { |
|
552 User::Leave( KErrNotFound ); |
|
553 } |
|
554 } |
|
555 |
|
556 |
|
557 void CAiSoftKeyRenderer::DoPublishL( MAiPropertyExtension& aPlugin, |
|
558 TInt aContent, |
|
559 const TDesC8& aBuf, |
|
560 TInt aIndex ) |
|
561 { |
|
562 if( aPlugin.PublisherInfoL()->iUid == KShortcutPluginUid ) |
|
563 { |
|
564 if( aContent == KAiScutContent[EAiScutContentShortcutSkIcon].id ) |
|
565 { |
|
566 CGulIcon* icon = NULL; |
|
567 TPckg<CGulIcon*>( icon ).Copy( aBuf ); |
|
568 // icon ownership is transferred |
|
569 UpdateSoftKeyL( aIndex, icon ); |
|
570 } |
|
571 else |
|
572 { |
|
573 User::Leave( KErrNotSupported ); |
|
574 } |
|
575 } |
|
576 else |
|
577 { |
|
578 User::Leave( KErrNotFound ); |
|
579 } |
|
580 } |
|
581 |
|
582 |
|
583 void CAiSoftKeyRenderer::CreateDefaultSoftKeysL() |
|
584 { |
|
585 // If we already have cba, then do nothing. |
|
586 if ( iCba ) |
|
587 { |
|
588 return; |
|
589 } |
|
590 |
|
591 // Otherwise create brand new cba. |
|
592 iCba = CEikButtonGroupContainer::NewL( |
|
593 CEikButtonGroupContainer::ECba, |
|
594 CEikButtonGroupContainer::EHorizontal, |
|
595 iAppUi, |
|
596 R_NATIVEUI_SOFTKEYS_DEFAULT, |
|
597 0 ); // Does not add to stack |
|
598 |
|
599 iCba->SetBoundingRect( iAppUi->ApplicationRect() ); |
|
600 |
|
601 CCoeControl* cba = iCba->ButtonGroup()->AsControl(); |
|
602 |
|
603 static_cast<CEikCba*>(cba)->SetSkinBackgroundId( |
|
604 KAknsIIDQsnBgAreaControlIdle ); |
|
605 |
|
606 cba->MakeVisible( ETrue ); |
|
607 |
|
608 iAppUi->RemoveFromStack( cba ); // Well, it is not in stack |
|
609 iAppUi->AddToStackL( cba, |
|
610 KNativeUiCbaPriority, |
|
611 ECoeStackFlagRefusesFocus | ECoeStackFlagRefusesAllKeys ); |
|
612 } |
|
613 |
|
614 |
|
615 void CAiSoftKeyRenderer::UpdateSoftKeyL( TInt aKey, CGulIcon* aIcon ) |
|
616 { |
|
617 if( !iCba ) |
|
618 { |
|
619 iCba = iAppUi->Cba(); |
|
620 } |
|
621 |
|
622 // remove the locked flag if any |
|
623 aKey &= KScutBitMaskLocked; |
|
624 |
|
625 TInt buttonPosImage; |
|
626 TInt buttonPosText; |
|
627 TInt buttonCmd; |
|
628 |
|
629 if( aKey == KLeftSoftkeyId ) |
|
630 { |
|
631 buttonPosImage = KControlArrayCBAButton1Posn; |
|
632 buttonPosText = KNativeUiLeftSoftkeyId; |
|
633 buttonCmd = ENativeUiSoftkeyLeft; |
|
634 } |
|
635 else if(aKey == KRightSoftkeyId) |
|
636 { |
|
637 buttonPosImage = KControlArrayCBAButton2Posn; |
|
638 buttonPosText = KNativeUiRightSoftkeyId; |
|
639 buttonCmd = ENativeUiSoftkeyRight; |
|
640 } |
|
641 else |
|
642 { |
|
643 delete aIcon; |
|
644 return; |
|
645 } |
|
646 |
|
647 if( aIcon ) |
|
648 { |
|
649 CleanupStack::PushL( aIcon ); |
|
650 |
|
651 TSize size( SoftkeySizeL( *iCba, buttonPosImage, ETrue ) ); |
|
652 |
|
653 AknIconUtils::SetSize( aIcon->Bitmap(), size, EAspectRatioPreserved ); |
|
654 AknIconUtils::SetSize( aIcon->Mask(), size, EAspectRatioPreserved ); |
|
655 |
|
656 CEikImage* image = new ( ELeave ) CEikImage; |
|
657 image->SetPictureOwnedExternally( EFalse ); |
|
658 // Bitmap and mask ownerships are transferred |
|
659 image->SetPicture( aIcon->Bitmap(), aIcon->Mask() ); |
|
660 aIcon->SetBitmapsOwnedExternally( ETrue ); |
|
661 |
|
662 // Image ownership is transferred |
|
663 EikSoftkeyImage::SetImage( iCba, *image, aKey == KLeftSoftkeyId ); |
|
664 |
|
665 CleanupStack::PopAndDestroy( aIcon ); |
|
666 } |
|
667 else |
|
668 { |
|
669 EikSoftkeyImage::SetLabel( iCba, aKey == KLeftSoftkeyId ); |
|
670 iCba->SetCommandL( buttonPosText, |
|
671 buttonCmd, |
|
672 *iText ); |
|
673 } |
|
674 |
|
675 iCba->DrawDeferred(); |
|
676 } |