|
1 /* |
|
2 * Copyright (c) 2002-2009 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: Command button array implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
20 #include <uikon/eikdefmacros.h> |
|
21 #endif |
|
22 #include <barsread.h> |
|
23 #include "eikcba.h" |
|
24 #include <eiklabel.h> |
|
25 #include <eiksoftkeyimage.h> |
|
26 #include <eiksoftkeypostingtransparency.h> |
|
27 #include <eikbtgpc.h> |
|
28 #include <aknappui.h> |
|
29 #include <AknUtils.h> // LayoutUtils |
|
30 #include <aknlayoutscalable_apps.cdl.h> |
|
31 #include <AknsBasicBackgroundControlContext.h> |
|
32 #include <AknsMaskedLayerBackgroundControlContext.h> |
|
33 #include <AknsDrawUtils.h> |
|
34 #include <AknsConstants.h> |
|
35 #include <aknconsts.h> |
|
36 #include <AknSgcc.h> |
|
37 #include <AknStatuspaneUtils.h> |
|
38 #include <aknpriv.rsg> // R_ENHANCED_CBA_PRIORITIES |
|
39 #include <aknlayoutscalable_avkon.cdl.h> |
|
40 #include <layoutmetadata.cdl.h> |
|
41 #include <avkon.mbg> |
|
42 #include <centralrepository.h> |
|
43 #include <AvkonInternalCRKeys.h> // KAknMiddleSoftkeyEnabled |
|
44 #include <cenrepnotifyhandler.h> |
|
45 #include <AknSkinsInternalCRKeys.h> |
|
46 #include <aknQueryControl.h> |
|
47 #include <aknbutton.h> |
|
48 #include <akniconconfig.h> |
|
49 |
|
50 #include <akncommandbuttonstate.h> |
|
51 |
|
52 #include <AknTasHook.h> |
|
53 #include <akncbacontentobserver.h> |
|
54 #include <aknitemactionmenu.h> |
|
55 #include "akncollectionobserver.h" |
|
56 #include "aknitemactionmenuregister.h" |
|
57 |
|
58 /** |
|
59 * Color value for transparent pixel (ARGB format). |
|
60 */ |
|
61 const TUint32 KAknCbaColorKey = 0x00000000; |
|
62 |
|
63 /** |
|
64 * Mask for opaque pixel (ARGB format). |
|
65 */ |
|
66 const TUint32 KAknCbaOpaqueMask = 0xFF000000; |
|
67 |
|
68 /** |
|
69 * Mask for outline font in font id. |
|
70 */ |
|
71 const TUint32 KOutlineFontMask = 0x00000040; |
|
72 #include <touchfeedback.h> |
|
73 |
|
74 inline TAknWindowComponentLayout DoCompose(TAknWindowComponentLayout aLine1, |
|
75 TAknWindowComponentLayout aLine2) |
|
76 { |
|
77 return TAknWindowComponentLayout::Compose(aLine1, aLine2); |
|
78 } |
|
79 |
|
80 inline TAknTextComponentLayout DoComposeText(TAknWindowComponentLayout aLine1, |
|
81 TAknTextComponentLayout aLine2) |
|
82 { |
|
83 return TAknWindowComponentLayout::ComposeText(aLine1, aLine2); |
|
84 } |
|
85 |
|
86 /** |
|
87 * Checks if right side pane is active. |
|
88 * @return ETrue if right side pane is active, EFalse otherwise. |
|
89 */ |
|
90 static TBool IsAreaSideRightPaneActive() |
|
91 { |
|
92 return EFalse; |
|
93 } |
|
94 |
|
95 |
|
96 /** |
|
97 * Checks if MSK-enabled layout is in use. |
|
98 */ |
|
99 static TBool IsMskEnabledLayoutActive() |
|
100 { |
|
101 TBool result( EFalse ); |
|
102 |
|
103 if ( Layout_Meta_Data::IsMSKEnabled() ) |
|
104 { |
|
105 // First check if MSK is enabled in the layout metadata. |
|
106 result = ETrue; |
|
107 } |
|
108 else |
|
109 { |
|
110 TInt statusPaneLayout( |
|
111 AVKONENV->StatusPaneResIdForCurrentLayout( |
|
112 AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ) ); |
|
113 |
|
114 if ( statusPaneLayout == |
|
115 R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS || |
|
116 ( statusPaneLayout == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT && |
|
117 AknLayoutUtils::PenEnabled() && |
|
118 !Layout_Meta_Data::IsLandscapeOrientation() ) ) |
|
119 { |
|
120 // MSK is not enabled in the layout metadata, but for |
|
121 // these status pane layouts an exception is made. |
|
122 result = ETrue; |
|
123 } |
|
124 } |
|
125 |
|
126 return result; |
|
127 } |
|
128 |
|
129 |
|
130 /* |
|
131 * Checks if bitmap must be updated, i.e. bitmap does not exist or |
|
132 * expected size does not match with actual size. |
|
133 */ |
|
134 static TBool IsBitmapUpdateNeeded( CFbsBitmap* aOldBitmap, const TSize& aSize ) |
|
135 { |
|
136 return !aOldBitmap || ( aOldBitmap->SizeInPixels() != aSize ); |
|
137 } |
|
138 |
|
139 |
|
140 /** |
|
141 * Implementation of class CEikCba - Control button array. |
|
142 */ |
|
143 const TInt KNoResource = 0; |
|
144 const TInt KMaxSeries60Softkeys = 3; // 3 softkeys for S60 with MSK |
|
145 const TInt KControlArrayCBAButton1Posn = 0; |
|
146 const TInt KControlArrayScrollBarPosn = 1; |
|
147 const TInt KControlArrayCBAButton2Posn = 2; |
|
148 const TInt KControlArrayCBAButtonMSKPosn = 3; |
|
149 const TInt KCbaScrollBarButtonWidth = 9; // in pixels |
|
150 |
|
151 /** Alpha value used in drawing CBA button contents in pressed down state. */ |
|
152 const TInt KPressedDownAlphaValue = 127; |
|
153 |
|
154 |
|
155 /** |
|
156 * Local panic definitions. |
|
157 */ |
|
158 enum TEikPanicCBA |
|
159 { |
|
160 EEikPanicCBAControlArraySize, |
|
161 EEikPanicCBANullButton, |
|
162 EEikPanicCBACannotConvertToCEikCommandButton, |
|
163 EEikPanicCBAIsNotEnhancedCba, |
|
164 EEikPanicCBAButtonCountDiffersFromCommandTableSize |
|
165 }; |
|
166 |
|
167 /** |
|
168 * Local AknLayout definintions. |
|
169 */ |
|
170 enum TAknLayoutFlags |
|
171 { |
|
172 EAknLayoutCbaInControlPane = 0x1, |
|
173 EAknLayoutCbaInStaconPane = 0x2, |
|
174 EAknLayoutCbaInStaconPaneRight = 0x4, |
|
175 EAknLayoutCbaInStaconPaneLeft = 0x8, |
|
176 EAknLayoutCbaInStaconPaneIdle = 0x10, |
|
177 EAknLayoutCbaInRightPane = 0x20 |
|
178 }; |
|
179 |
|
180 /** |
|
181 * Enumeration for CEikCommandTable for fetching commands. |
|
182 */ |
|
183 enum TCommandTableCbaPositions |
|
184 { |
|
185 ECommandTableCommand1Posn = 0, |
|
186 ECommandTableCommand2Posn = 1, |
|
187 ECommandTableCommand3Posn = 2, |
|
188 ECommandTableCommand4Posn = 3 |
|
189 }; |
|
190 |
|
191 enum TCbaChangeRecordedFlags |
|
192 { |
|
193 ECbaChangeRecordedLayout, |
|
194 ECbaChangeRecordedSkin, |
|
195 ECbaChangeRecordedColor, |
|
196 ECbaInsideDialog, |
|
197 ECbaEmbedded, // cba is embedded in a parent control (dialog or popup) |
|
198 ECbaHasContent, // cba has content and should be visible when embedded |
|
199 ECbaParentAsControl, // cba's parent window group is treated as CCoeControl |
|
200 ECbaActivationDelayed, // activation delayed |
|
201 ECbaSingleClickEnabled, // single click enabled in appUi |
|
202 ECbaItemSoftkeyDisabled, // item specific softkey disabled |
|
203 ECbaItemSpecificSoftkeyInUse, // item specific softkey is in use |
|
204 ECbaItemSoftkeyDisabledByClient // client has disabled item specific softkey |
|
205 }; |
|
206 |
|
207 enum TCbaLayers |
|
208 { |
|
209 ECbaLayerWallpaper, |
|
210 ECbaLayerBackground, |
|
211 ECbaLayerN |
|
212 }; |
|
213 |
|
214 /** |
|
215 * Local panic routine. |
|
216 */ |
|
217 #if defined(_DEBUG) |
|
218 LOCAL_C void Panic(TEikPanicCBA aPanic) |
|
219 { |
|
220 _LIT(KPanicCat,"CBA"); |
|
221 User::Panic(KPanicCat, aPanic); |
|
222 } |
|
223 #endif |
|
224 |
|
225 |
|
226 /** |
|
227 * Internal extension class. |
|
228 */ |
|
229 class CEikCbaExtension : public CBase, |
|
230 public MCenRepNotifyHandlerCallback, |
|
231 public MAknCollectionObserver |
|
232 { |
|
233 public: |
|
234 |
|
235 CEikCbaExtension( CEikCba& aOwner ) : iOwner( aOwner ), |
|
236 iCbaBgIIDSetExt( EFalse ) |
|
237 ,iLeftFrameMask( NULL ), |
|
238 iRightFrameMask( NULL ), |
|
239 iItemActionMenu( NULL ) |
|
240 { |
|
241 }; |
|
242 |
|
243 static CEikCbaExtension* NewL( CEikCba& aOwner ) |
|
244 { |
|
245 CEikCbaExtension* self = new (ELeave) CEikCbaExtension( aOwner ); |
|
246 CleanupStack::PushL( self ); |
|
247 self->ConstructL(); |
|
248 CleanupStack::Pop( self ); |
|
249 return self; |
|
250 } |
|
251 |
|
252 void ConstructL() |
|
253 { |
|
254 // Wallpaper is not drawn by embedded CBA. |
|
255 if ( !iOwner.Flags().IsSet( ECbaEmbedded ) ) |
|
256 { |
|
257 iRepository = CRepository::NewL( KCRUidPersonalisation ); |
|
258 iRepository->Get( KPslnWallpaperType, iWallpaperInUse ); |
|
259 |
|
260 iCRListener = CCenRepNotifyHandler::NewL( *this, |
|
261 *iRepository, |
|
262 CCenRepNotifyHandler::EIntKey, |
|
263 KPslnWallpaperType ); |
|
264 iCRListener->StartListeningL(); |
|
265 } |
|
266 |
|
267 iBackgroundMaskID = KAknsIIDNone; |
|
268 iCbaRect = TRect( 0,0,0,0 ); |
|
269 iIfSkinChanged = EFalse; |
|
270 iIfMskIconSet = EFalse; |
|
271 iSemiBgID = KAknsIIDNone; |
|
272 |
|
273 if ( iOwner.Flags().IsSet( ECbaSingleClickEnabled ) ) |
|
274 { |
|
275 AknItemActionMenuRegister::RegisterCollectionObserverL( |
|
276 *this ); |
|
277 } |
|
278 } |
|
279 |
|
280 ~CEikCbaExtension() |
|
281 { |
|
282 if ( iOwner.Flags().IsSet( ECbaSingleClickEnabled ) ) |
|
283 { |
|
284 AknItemActionMenuRegister::UnregisterCollectionObserver( *this ); |
|
285 } |
|
286 if ( iCRListener ) |
|
287 { |
|
288 iCRListener->StopListening(); |
|
289 delete iCRListener; |
|
290 } |
|
291 |
|
292 delete iRepository; |
|
293 delete iPressedMSKFrameBitmap; |
|
294 delete iLeftFrameMask; |
|
295 delete iRightFrameMask; |
|
296 delete iLskPostingOverlayBitmap; |
|
297 delete iRskPostingOverlayBitmap; |
|
298 delete iBmpFile; |
|
299 } |
|
300 |
|
301 /** From base class MCenRepNotifyHandlerCallback */ |
|
302 void HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue ) |
|
303 { |
|
304 iWallpaperInUse = aNewValue; |
|
305 iOwner.SetSkinBackgroundId( KAknsIIDNone ); |
|
306 } |
|
307 |
|
308 void UpdateSoftkeyFrameL( TBool aForcedUpdate ) |
|
309 { |
|
310 if ( !AknLayoutUtils::PenEnabled() ) |
|
311 { |
|
312 return; |
|
313 } |
|
314 TAknLayoutRect cbarect; |
|
315 |
|
316 TRect screen; |
|
317 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
318 |
|
319 TAknWindowComponentLayout applicationWindow( |
|
320 AknLayoutScalable_Avkon::application_window( 0 ) ); |
|
321 |
|
322 TRect innerRect; |
|
323 TRect outerRect; |
|
324 TRect mskOuterRect; |
|
325 TRect mskInnerRect; |
|
326 |
|
327 if ( iOwner.Flags().IsSet( ECbaEmbedded ) ) |
|
328 { |
|
329 TRect rect ( iOwner.Rect() ); |
|
330 if ( rect.Width() > 0 && rect.Height() > 0 ) |
|
331 { |
|
332 TAknLayoutRect layoutRect; |
|
333 layoutRect.LayoutRect( |
|
334 rect, |
|
335 AknLayoutScalable_Avkon::popup_sk_window_g1( 0 ) ); |
|
336 |
|
337 TInt margin = layoutRect.Rect().iTl.iX - rect.iTl.iX; |
|
338 TInt buttonWidth = ( rect.Width() - margin * 2 ) / 2; |
|
339 outerRect = TRect( 0, 0, buttonWidth, |
|
340 layoutRect.Rect().Height() ); |
|
341 |
|
342 layoutRect.LayoutRect( outerRect, |
|
343 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
344 .LayoutLine() ); |
|
345 innerRect = layoutRect.Rect(); |
|
346 |
|
347 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
348 |
|
349 const TSize maskSize = outerRect.Size(); |
|
350 if (skin && ( aForcedUpdate || IsBitmapUpdateNeeded( iLeftFrameMask, maskSize ) |
|
351 || IsBitmapUpdateNeeded( iRightFrameMask, maskSize ) ) ) |
|
352 { |
|
353 delete iLeftFrameMask; |
|
354 iLeftFrameMask = NULL; |
|
355 delete iRightFrameMask; |
|
356 iRightFrameMask = NULL; |
|
357 } |
|
358 } |
|
359 } |
|
360 else |
|
361 { |
|
362 TBool rightPaneActive( IsAreaSideRightPaneActive() ); |
|
363 |
|
364 TBool bskLandscape( Layout_Meta_Data::IsLandscapeOrientation() && |
|
365 !rightPaneActive ); |
|
366 |
|
367 if ( rightPaneActive ) |
|
368 { |
|
369 cbarect.LayoutRect( |
|
370 screen, |
|
371 DoCompose( |
|
372 applicationWindow, |
|
373 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ).LayoutLine() ); |
|
374 } |
|
375 else |
|
376 { |
|
377 cbarect.LayoutRect( |
|
378 screen, |
|
379 DoCompose( |
|
380 applicationWindow, |
|
381 DoCompose( |
|
382 AknLayoutScalable_Avkon::area_bottom_pane( bskLandscape ? 2 : 1 ), |
|
383 AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() ); |
|
384 } |
|
385 |
|
386 TRect cbaRect( cbarect.Rect() ); |
|
387 |
|
388 TBool mskEnabled( IsMskEnabledLayoutActive() ); |
|
389 |
|
390 TAknWindowComponentLayout frameLayout; |
|
391 if ( rightPaneActive ) |
|
392 { |
|
393 frameLayout = AknLayoutScalable_Avkon::sctrl_sk_top_pane(); |
|
394 } |
|
395 else if ( bskLandscape || mskEnabled ) |
|
396 { |
|
397 frameLayout = AknLayoutScalable_Avkon::control_pane_g6( 0 ); |
|
398 } |
|
399 else |
|
400 { |
|
401 frameLayout = AknLayoutScalable_Avkon::bg_sctrl_sk_pane_cp1(); |
|
402 } |
|
403 |
|
404 cbarect.LayoutRect( cbaRect, frameLayout ); |
|
405 |
|
406 outerRect.SetRect( TPoint( 0, 0 ), cbarect.Rect().Size() ); |
|
407 |
|
408 if ( mskEnabled ) |
|
409 { |
|
410 cbarect.LayoutRect( |
|
411 cbaRect, |
|
412 AknLayoutScalable_Avkon::control_pane_g7( 0 ) ); |
|
413 |
|
414 mskOuterRect.SetRect( TPoint( 0, 0 ), cbarect.Rect().Size() ); |
|
415 } |
|
416 else |
|
417 { |
|
418 |
|
419 iUpdateMSKFrameOuterRect.SetRect( 0, 0, 0, 0 ); |
|
420 } |
|
421 |
|
422 TAknLayoutRect layoutRect; |
|
423 layoutRect.LayoutRect( |
|
424 outerRect, |
|
425 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1().LayoutLine() ); |
|
426 innerRect = layoutRect.Rect(); |
|
427 if ( mskEnabled ) |
|
428 { |
|
429 layoutRect.LayoutRect( |
|
430 mskOuterRect, |
|
431 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() ); |
|
432 mskInnerRect = layoutRect.Rect(); |
|
433 } |
|
434 } |
|
435 |
|
436 |
|
437 iUpdateFrameOuterRect = outerRect; |
|
438 iUpdateFrameInnerRect = innerRect; |
|
439 iUpdateMSKFrameOuterRect = mskOuterRect; |
|
440 iUpdateMskFrameInnerRect = mskInnerRect; |
|
441 } |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 /** |
|
447 * Merges mask into color bitmap. |
|
448 * @internal |
|
449 * @since S60 v5.0 |
|
450 * @param aMask mask to be merged. |
|
451 * @param aDestBitmap bitmap to merge mask with. |
|
452 */ |
|
453 static void MergeMaskInto16MA( CFbsBitmap* aMask, CFbsBitmap* aDestBitmap ) |
|
454 { |
|
455 // aMask display mode must be EGray256. |
|
456 // aMask must not be compressed in RAM. |
|
457 // aDestBitmap display mode must be EColor16MA. |
|
458 // aDestBitmap must not be compressed in RAM. |
|
459 // aMask size must equal to aDestBitmap size. |
|
460 // See UpdatePostingOverlayBitmapL. |
|
461 |
|
462 TSize size = aMask->SizeInPixels(); |
|
463 TUint32 pitch = CFbsBitmap::ScanLineLength( size.iWidth, EGray256 ); |
|
464 TUint32 destPitch = CFbsBitmap::ScanLineLength( size.iWidth, EColor16MA ) / 4; |
|
465 aMask->LockHeap(); |
|
466 aDestBitmap->LockHeap(); |
|
467 TUint8* dataAddr = |
|
468 reinterpret_cast<TUint8*>( aMask->DataAddress() ); |
|
469 TUint32* destAddr = |
|
470 reinterpret_cast<TUint32*>( aDestBitmap->DataAddress() ); |
|
471 |
|
472 for ( TUint32 y = 0; y < size.iHeight; y++ ) |
|
473 { |
|
474 for ( TUint32 x = 0; x < size.iWidth; x++ ) |
|
475 { |
|
476 TUint8 value = (TUint8)dataAddr[ y * pitch + x ]; |
|
477 // Round mask value to fully opaque or transparent |
|
478 if ( value > 0x7f ) |
|
479 { |
|
480 // Opaque pixel. |
|
481 destAddr[ y * destPitch + x ] |= KAknCbaOpaqueMask; |
|
482 } |
|
483 else |
|
484 { |
|
485 // Transparent pixel |
|
486 destAddr[ y * destPitch + x ] = KAknCbaColorKey; |
|
487 } |
|
488 } |
|
489 } |
|
490 aDestBitmap->UnlockHeap(); |
|
491 aMask->UnlockHeap(); |
|
492 } |
|
493 |
|
494 /** |
|
495 * Updates posting overlay bitmap. |
|
496 * @internal |
|
497 * @since S60 v5.0 |
|
498 * @param aBitmap Reference to bitmap pointer to get the new bitmap. |
|
499 * @param aRect Rectangle for the CBA button. |
|
500 * @param aControl CEikCba control. |
|
501 * @param aButton CEikCbaButton control for the button. |
|
502 */ |
|
503 void UpdatePostingOverlayBitmapL( |
|
504 CFbsBitmap*& aBitmap, |
|
505 const TRect& aRect, |
|
506 CEikCbaButton* aButton ) |
|
507 { |
|
508 delete aBitmap; |
|
509 aBitmap = NULL; |
|
510 |
|
511 // If you modify this method, please make sure that assumptions |
|
512 // mentioned in MergeMaskInto16MA still hold. |
|
513 |
|
514 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap(); |
|
515 CleanupStack::PushL( bitmap ); |
|
516 User::LeaveIfError( bitmap->Create( aRect.Size(), EColor16MA ) ); |
|
517 |
|
518 CFbsBitGc* bitmapContext = NULL; |
|
519 CFbsBitmapDevice* bitmapDevice = |
|
520 CFbsBitmapDevice::NewL( bitmap ); |
|
521 CleanupStack::PushL( bitmapDevice ); |
|
522 User::LeaveIfError( bitmapDevice->CreateContext( bitmapContext ) ); |
|
523 CleanupStack::PushL( bitmapContext ); |
|
524 |
|
525 // Zero alpha channel to make bitmap fully transparent |
|
526 bitmapContext->SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
527 bitmapContext->SetBrushColor( TRgb::Color16MA( 0 ) ); |
|
528 bitmapContext->Clear(); |
|
529 |
|
530 // Draw button text into bitmap |
|
531 if ( aButton ) |
|
532 { |
|
533 CFbsBitmap* textBitmapMask = new ( ELeave ) CFbsBitmap(); |
|
534 CleanupStack::PushL( textBitmapMask ); |
|
535 User::LeaveIfError( textBitmapMask->Create( aRect.Size(), EGray256 ) ); |
|
536 |
|
537 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( textBitmapMask ); |
|
538 CleanupStack::PushL( device ); |
|
539 CFbsBitGc* gc = NULL; |
|
540 User::LeaveIfError( device->CreateContext( gc ) ); |
|
541 CleanupStack::PushL( gc ); |
|
542 |
|
543 // Clear bitmap |
|
544 gc->SetBrushColor( KRgbBlack ); |
|
545 gc->Clear(); |
|
546 |
|
547 aButton->DrawToContext( *bitmapContext, *gc, aRect.iTl ); |
|
548 |
|
549 CleanupStack::PopAndDestroy( gc ); |
|
550 CleanupStack::PopAndDestroy( device ); |
|
551 |
|
552 // Merge text mask into the alpha channel to make the text fully opaque |
|
553 MergeMaskInto16MA( textBitmapMask, bitmap ); |
|
554 |
|
555 CleanupStack::PopAndDestroy( textBitmapMask ); |
|
556 } |
|
557 |
|
558 CleanupStack::PopAndDestroy( 2, bitmapDevice ); |
|
559 CleanupStack::Pop( bitmap ); |
|
560 aBitmap = bitmap; |
|
561 } |
|
562 |
|
563 /** |
|
564 * Updates posting overlay bitmaps. |
|
565 * @param aCbaRect cba rect. |
|
566 * @param aLeftButton left button. |
|
567 * @param aRightButton right button. |
|
568 */ |
|
569 void UpdatePostingOverlayBitmapsL( |
|
570 const TRect& aCbaRect, |
|
571 CEikCbaButton* aLeftButton, |
|
572 CEikCbaButton* aRightButton, |
|
573 TInt aAknLayoutFlags ) |
|
574 { |
|
575 TRect rightSoftKeyButtonRect; |
|
576 TRect leftSoftKeyButtonRect; |
|
577 if( aAknLayoutFlags & EAknLayoutCbaInRightPane ) |
|
578 { |
|
579 // Read right (top in landscape) softkey layout. |
|
580 TAknWindowLineLayout rightSoftkeyLayout( |
|
581 DoCompose( AknLayoutScalable_Avkon::area_side_right_pane( 0 ), |
|
582 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() ); |
|
583 |
|
584 TAknLayoutRect rightSoftkeyLayoutRect; |
|
585 rightSoftkeyLayoutRect.LayoutRect( aCbaRect, rightSoftkeyLayout ); |
|
586 rightSoftKeyButtonRect = rightSoftkeyLayoutRect.Rect() ; |
|
587 |
|
588 // Read left (bottom in landscape) softkey layout. |
|
589 TAknWindowLineLayout leftSoftkeyLayout( |
|
590 DoCompose( AknLayoutScalable_Avkon::area_side_right_pane( 0 ), |
|
591 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() ); |
|
592 |
|
593 TAknLayoutRect leftSoftkeyLayoutRect; |
|
594 leftSoftkeyLayoutRect.LayoutRect( aCbaRect, leftSoftkeyLayout ); |
|
595 leftSoftKeyButtonRect = leftSoftkeyLayoutRect.Rect() ; |
|
596 } |
|
597 else if( aAknLayoutFlags & EAknLayoutCbaInControlPane ) |
|
598 { |
|
599 TAknLayoutRect layoutRect; |
|
600 TRect rect( 0,0,0,0 ); |
|
601 if ( AknLayoutUtils::LayoutMirrored() ) |
|
602 { |
|
603 layoutRect.LayoutRect( |
|
604 rect, |
|
605 AknLayoutScalable_Avkon::aid_touch_ctrl_right().LayoutLine() ); |
|
606 leftSoftKeyButtonRect = layoutRect.Rect(); |
|
607 |
|
608 layoutRect.LayoutRect( |
|
609 rect, |
|
610 AknLayoutScalable_Avkon::aid_touch_ctrl_left().LayoutLine() ); |
|
611 rightSoftKeyButtonRect = layoutRect.Rect(); |
|
612 } |
|
613 else |
|
614 { |
|
615 layoutRect.LayoutRect( |
|
616 rect, |
|
617 AknLayoutScalable_Avkon::aid_touch_ctrl_left().LayoutLine() ); |
|
618 leftSoftKeyButtonRect = layoutRect.Rect(); |
|
619 |
|
620 layoutRect.LayoutRect( |
|
621 rect, |
|
622 AknLayoutScalable_Avkon::aid_touch_ctrl_right().LayoutLine() ); |
|
623 rightSoftKeyButtonRect = layoutRect.Rect(); |
|
624 } |
|
625 } |
|
626 else |
|
627 { |
|
628 TInt variety = 0; |
|
629 if ( aAknLayoutFlags & EAknLayoutCbaInStaconPaneLeft ) |
|
630 { |
|
631 variety = 1; |
|
632 } |
|
633 |
|
634 TAknWindowComponentLayout layout0; |
|
635 TAknWindowComponentLayout layout1; |
|
636 TAknWindowComponentLayout layout2; |
|
637 |
|
638 // Read right (top in landscape) softkey layout. |
|
639 layout0 = AknLayoutScalable_Avkon::area_top_pane( 2 ); |
|
640 layout1 = AknLayoutScalable_Avkon::stacon_top_pane(); |
|
641 |
|
642 // If clock is shown in stacon, cba area is smaller. |
|
643 TInt topCbaVariety = variety; |
|
644 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
645 { |
|
646 topCbaVariety += 4; |
|
647 } |
|
648 |
|
649 layout2 = AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ); |
|
650 |
|
651 TAknWindowLineLayout rightSoftkeyLayout( |
|
652 DoCompose( layout0,DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
653 |
|
654 TAknLayoutRect rightSoftkeyLayoutRect; |
|
655 rightSoftkeyLayoutRect.LayoutRect( aCbaRect, rightSoftkeyLayout ); |
|
656 rightSoftKeyButtonRect = rightSoftkeyLayoutRect.Rect(); |
|
657 |
|
658 // Read left (bottom in landscape) softkey layout. |
|
659 layout0 = AknLayoutScalable_Avkon::area_bottom_pane( 2 ); |
|
660 layout1 = AknLayoutScalable_Avkon::stacon_bottom_pane(); |
|
661 |
|
662 // If clock is shown in stacon, cba area is smaller. |
|
663 TInt bottomCbaVariety = variety; |
|
664 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
665 { |
|
666 bottomCbaVariety += 2; |
|
667 } |
|
668 |
|
669 layout2 = AknLayoutScalable_Avkon::control_bottom_pane_stacon( |
|
670 bottomCbaVariety ); |
|
671 |
|
672 TAknWindowLineLayout leftSoftkeyLayout( |
|
673 DoCompose( layout0, DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
674 |
|
675 TAknLayoutRect leftSoftkeyLayoutRect; |
|
676 leftSoftkeyLayoutRect.LayoutRect( aCbaRect, leftSoftkeyLayout ); |
|
677 leftSoftKeyButtonRect = leftSoftkeyLayoutRect.Rect(); |
|
678 } |
|
679 UpdatePostingOverlayBitmapL( |
|
680 iLskPostingOverlayBitmap, |
|
681 leftSoftKeyButtonRect, |
|
682 aLeftButton ); |
|
683 UpdatePostingOverlayBitmapL( |
|
684 iRskPostingOverlayBitmap, |
|
685 rightSoftKeyButtonRect, |
|
686 aRightButton ); |
|
687 } |
|
688 |
|
689 /** |
|
690 * From MAknCollectionObserver. |
|
691 * This method is used to set the item action menu to observer. |
|
692 * |
|
693 * @param aItemActionMenu Item action menu. |
|
694 */ |
|
695 void SetItemActionMenu( CAknItemActionMenu* aItemActionMenu ) |
|
696 { |
|
697 iItemActionMenu = aItemActionMenu; |
|
698 } |
|
699 |
|
700 /** |
|
701 * From MAknCollectionObserver. |
|
702 * This method is called when there are changes in collection state. |
|
703 * LSK should be hidden when there is no highlight in list. |
|
704 * |
|
705 * @param aCollectionVisible ETrue if changed collection is visible. |
|
706 */ |
|
707 void CollectionChanged( TBool aCollectionVisible ) |
|
708 { |
|
709 // Do not update state if invisible collection tries to enable sk |
|
710 if ( aCollectionVisible |
|
711 || iOwner.Flags().IsClear( ECbaItemSoftkeyDisabled ) ) |
|
712 { |
|
713 iOwner.UpdateItemSpecificSoftkey(); |
|
714 } |
|
715 } |
|
716 |
|
717 /** |
|
718 * From MAknCollectionObserver. |
|
719 * This method returns ETrue if collection observer is active. |
|
720 * |
|
721 * @return ETrue if observer is active. |
|
722 */ |
|
723 TBool Active() const |
|
724 { |
|
725 return iOwner.IsVisible() && !iOwner.IsEmpty(); |
|
726 } |
|
727 |
|
728 /* |
|
729 * Using the special theme Id draw background |
|
730 */ |
|
731 void DrawSemiTransparencyL(CWindowGc& aGc, |
|
732 const TRect& aRect) |
|
733 { |
|
734 //Temporary inner rectangal value |
|
735 TRect innerRect = aRect; |
|
736 innerRect.Shrink( 5, 5 ); |
|
737 if ( iSemiBgID != KAknsIIDNone ) |
|
738 { |
|
739 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
740 aGc, aRect, innerRect, iSemiBgID, iSemiBgCenterID ); |
|
741 } |
|
742 } |
|
743 |
|
744 public: |
|
745 |
|
746 CEikCba& iOwner; |
|
747 CRepository* iRepository; |
|
748 CCenRepNotifyHandler* iCRListener; |
|
749 TInt iWallpaperInUse; |
|
750 CFbsBitmap* iFrameBitmap; |
|
751 CFbsBitmap* iPressedFrameBitmap; |
|
752 CFbsBitmap* iMSKFrameBitmap; |
|
753 CFbsBitmap* iPressedMSKFrameBitmap; |
|
754 CFbsBitmap* iLskPostingOverlayBitmap; |
|
755 CFbsBitmap* iRskPostingOverlayBitmap; |
|
756 TBool iEnablePostingTransparency; |
|
757 |
|
758 TBool iCbaBgIIDSetExt; |
|
759 TBool iIfSkinChanged; |
|
760 |
|
761 CFbsBitmap* iLeftFrameMask; |
|
762 CFbsBitmap* iRightFrameMask; |
|
763 |
|
764 TAknsItemID iBackgroundMaskID; |
|
765 TRect iCbaRect; |
|
766 TBool iIfMskIconSet; |
|
767 TAknsItemID iMSKSkinID; |
|
768 HBufC* iBmpFile; |
|
769 TInt32 iBmp; |
|
770 TInt32 iBmpM; |
|
771 /** |
|
772 * Pointer to the CBA button which currently has the pointer grab. |
|
773 * Not own. |
|
774 */ |
|
775 CCoeControl* iPointerGrabbingButton; |
|
776 |
|
777 /** Rectangle in which the left (or bottom) softkey frame is drawn to. */ |
|
778 TRect iLeftFrameOuterRect; |
|
779 TRect iLeftFrameInnerRect; |
|
780 |
|
781 /** Rectangle in which the right (or top) softkey frame is drawn to. */ |
|
782 TRect iRightFrameOuterRect; |
|
783 TRect iRightFrameInnerRect; |
|
784 |
|
785 /** Rectangle in which the middle softkey frame is drawn to if used. */ |
|
786 TRect iMiddleFrameOuterRect; |
|
787 TRect iMiddleFrameInnerRect; |
|
788 |
|
789 /** |
|
790 * Content observer. |
|
791 */ |
|
792 TCallBack iContentObserver; |
|
793 |
|
794 /** |
|
795 * Outer rect used in UpdateSoftkeyFrameL method. |
|
796 */ |
|
797 TRect iUpdateFrameOuterRect; |
|
798 |
|
799 /* |
|
800 * Frame and center theme ID, using for semi-transparent |
|
801 */ |
|
802 TAknsItemID iSemiBgID; |
|
803 TAknsItemID iSemiBgCenterID; |
|
804 /** |
|
805 * Inner rect used in UpdateSoftkeyFrameL method. |
|
806 */ |
|
807 TRect iUpdateFrameInnerRect; |
|
808 |
|
809 /** |
|
810 * Outer MSK rect used in UpdateSoftkeyFrameL method. |
|
811 */ |
|
812 TRect iUpdateMSKFrameOuterRect; |
|
813 /* |
|
814 * |
|
815 */ |
|
816 TRect iUpdateMskFrameInnerRect; |
|
817 |
|
818 /** |
|
819 * Item action menu. |
|
820 * Not own. |
|
821 */ |
|
822 CAknItemActionMenu* iItemActionMenu; |
|
823 }; |
|
824 |
|
825 |
|
826 CEikCba* CEikCba::NewL(const CEikCba* aPrevious, MEikCommandObserver* aCommandObserver, |
|
827 RWindowGroup* aParentWg) |
|
828 { |
|
829 CEikCba* self = CEikCba::NewLC(aPrevious, aCommandObserver, aParentWg); // static |
|
830 CleanupStack::Pop( self ); |
|
831 return self; |
|
832 } |
|
833 |
|
834 CEikCba* CEikCba::NewL(TInt aResourceId, const CEikCba* aPrevious, |
|
835 MEikCommandObserver* aCommandObserver, RWindowGroup* aParentWg) |
|
836 { |
|
837 CEikCba* self = CEikCba::NewLC(aResourceId, aPrevious, aCommandObserver, aParentWg); // static |
|
838 CleanupStack::Pop( self ); |
|
839 return self; |
|
840 } |
|
841 |
|
842 CEikCba* CEikCba::NewLC(const CEikCba* aPrevious, MEikCommandObserver* aCommandObserver, |
|
843 RWindowGroup* aParentWg) |
|
844 { |
|
845 return CEikCba::NewLC(KNoResource, aPrevious, aCommandObserver, aParentWg); // static |
|
846 } |
|
847 |
|
848 CEikCba* CEikCba::NewLC(const CEikCba* aPrevious, |
|
849 MEikCommandObserver* aCommandObserver, RWindowGroup* aParentWg, |
|
850 TUint aFlags) |
|
851 { |
|
852 return CEikCba::NewLC(KNoResource, aPrevious, aCommandObserver, |
|
853 aParentWg, aFlags); |
|
854 } |
|
855 |
|
856 CEikCba* CEikCba::NewLC(TInt aResourceId, const CEikCba* aPrevious, |
|
857 MEikCommandObserver* aCommandObserver, RWindowGroup* aParentWg) |
|
858 { |
|
859 CEikCba* self = new(ELeave) CEikCba(aPrevious, aCommandObserver, aParentWg); // static |
|
860 CleanupStack::PushL(self); |
|
861 self->ConstructL(aResourceId); |
|
862 AKNTASHOOK_ADDL( self, "CEikCba" ); |
|
863 return self; |
|
864 } |
|
865 |
|
866 CEikCba* CEikCba::NewLC(TInt aResourceId, const CEikCba* aPrevious, |
|
867 MEikCommandObserver* aCommandObserver, RWindowGroup* aParentWg, |
|
868 TUint aFlags) |
|
869 { |
|
870 CEikCba* self = new(ELeave) CEikCba(aPrevious, aCommandObserver, |
|
871 aParentWg, aFlags); |
|
872 CleanupStack::PushL(self); |
|
873 self->ConstructL(aResourceId); |
|
874 AKNTASHOOK_ADDL( self, "CEikCba" ); |
|
875 return self; |
|
876 } |
|
877 |
|
878 |
|
879 /** |
|
880 * Destructor. |
|
881 */ |
|
882 CEikCba::~CEikCba() |
|
883 { |
|
884 AKNTASHOOK_REMOVE(); |
|
885 // Revert the clock and indicator pane area of status pane |
|
886 // to use the previous skin background. |
|
887 CEikStatusPaneBase* sp = CEikStatusPaneBase::Current(); |
|
888 if ( sp && |
|
889 iClockIndicBgIID.iMajor && |
|
890 iClockIndicBgIID.iMinor && |
|
891 iIsClockIndicBgIIDSet ) |
|
892 { |
|
893 sp->SetCbaAreaBackgroundID( iClockIndicBgIID, |
|
894 CEikStatusPaneBase::EDrawDeferred ); |
|
895 } |
|
896 |
|
897 AknsUtils::DeregisterControlPosition( this ); |
|
898 |
|
899 // Remove scroll bar from control array to prevent double deletion |
|
900 // but only if has been properly constructed. |
|
901 if (iControlArray) |
|
902 { |
|
903 if (iControlArray->Count() > KControlArrayScrollBarPosn) |
|
904 { |
|
905 iControlArray->Delete(KControlArrayScrollBarPosn); |
|
906 } |
|
907 } |
|
908 |
|
909 if(iEikonEnv && iEikonEnv->EikAppUi()) |
|
910 { |
|
911 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
912 } |
|
913 |
|
914 // Don't release font, as we are using layout utils to use SAME font every time. |
|
915 |
|
916 delete iBrushAndPenContext; |
|
917 delete iSBFrame; |
|
918 |
|
919 delete iMLBgContext; |
|
920 delete iStaconBgContextTop; |
|
921 delete iStaconBgContextBottom; |
|
922 |
|
923 #ifdef RD_ENHANCED_CBA |
|
924 delete iCommandTable; |
|
925 #endif // RD_ENHANCED_CBA |
|
926 |
|
927 delete iExtension; |
|
928 } |
|
929 |
|
930 /** |
|
931 * Constructor. |
|
932 */ |
|
933 CEikCba::CEikCba(const CEikCba* aPrevious, |
|
934 MEikCommandObserver* aCommandObserver, RWindowGroup* aParentWg, |
|
935 TUint aFlags) |
|
936 : iLink(aPrevious), iCommandObserver(aCommandObserver), iParentWg(aParentWg) |
|
937 { |
|
938 if (aFlags & CEikButtonGroupContainer::EIsEmbedded) |
|
939 { |
|
940 // CBA is embedded in another component (eg. dialog/popup/setting page |
|
941 iFlags.Set(ECbaEmbedded); |
|
942 } |
|
943 |
|
944 if ( aFlags & CEikButtonGroupContainer::EParentIsControl ) |
|
945 { |
|
946 iFlags.Set( ECbaParentAsControl ); |
|
947 } |
|
948 |
|
949 if ( aFlags & CEikButtonGroupContainer::EDelayActivation ) |
|
950 { |
|
951 iFlags.Set( ECbaActivationDelayed ); |
|
952 } |
|
953 |
|
954 CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() ); |
|
955 if ( appUi && appUi->IsSingleClickCompatible() ) |
|
956 { |
|
957 iFlags.Set( ECbaSingleClickEnabled ); |
|
958 iFlags.Set( ECbaItemSpecificSoftkeyInUse ); |
|
959 } |
|
960 |
|
961 SetNonFocusing(); |
|
962 } |
|
963 |
|
964 |
|
965 void CEikCba::SetContainerWindowL( const CCoeControl& aContainer ) |
|
966 { |
|
967 // CCoeControl::SetContainerWindowL closes the previously own window and |
|
968 // deactivates control. Therefore store the activation status and re-set |
|
969 // it after the container window has been set. |
|
970 |
|
971 // Removed to enable drawing of Query Input in one phase |
|
972 //TBool wasActivated = IsActivated(); |
|
973 // Check that this method was called from CAknQueryControl. Otherwise just |
|
974 // bail out so that previous functionality (i.e. the one before SetContainerWindowL |
|
975 // was overridded) is preserved. |
|
976 CAknQueryControl* queryControl; |
|
977 |
|
978 queryControl = const_cast<CCoeControl&>( aContainer ).MopGetObject( queryControl ); |
|
979 |
|
980 if ( queryControl == &aContainer ) |
|
981 { |
|
982 CCoeControl::SetContainerWindowL( aContainer ); |
|
983 |
|
984 // Convert all CEikCbaButtons to CAknButtons |
|
985 iFlags.Set( ECbaInsideDialog ); |
|
986 |
|
987 TAknTextComponentLayout layout = AknLayoutScalable_Apps::cell_vitu2_itu_pane_t1( 0 ); |
|
988 TAknLayoutText layoutText; |
|
989 layoutText.LayoutText(Rect(), layout.LayoutLine() ); |
|
990 |
|
991 CCoeControl *leftSoftkey = (*iControlArray)[KControlArrayCBAButton1Posn].iControl; |
|
992 CCoeControl *rightSoftkey = (*iControlArray)[KControlArrayCBAButton2Posn].iControl; |
|
993 |
|
994 TInt leftCommandId( (*iControlArray)[KControlArrayCBAButton1Posn].iId ); |
|
995 TInt rightCommandId( (*iControlArray)[KControlArrayCBAButton2Posn].iId ); |
|
996 |
|
997 TRgb color = layoutText.Color(); |
|
998 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
999 |
|
1000 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG65 ); |
|
1001 |
|
1002 |
|
1003 CAknButton* button = CAknButton::NewL(); |
|
1004 button->SetObserver( this ); |
|
1005 |
|
1006 |
|
1007 switch ( AknLayoutScalable_Apps::area_vitu2_query_pane_t1( 0 ).J() ) |
|
1008 { |
|
1009 case ELayoutAlignRight: |
|
1010 { |
|
1011 button->SetTextHorizontalAlignment( CGraphicsContext::ERight ); |
|
1012 break; |
|
1013 } |
|
1014 |
|
1015 case ELayoutAlignLeft: |
|
1016 { |
|
1017 button->SetTextHorizontalAlignment( CGraphicsContext::ELeft ); |
|
1018 break; |
|
1019 } |
|
1020 |
|
1021 case ELayoutAlignCenter: |
|
1022 default: |
|
1023 { |
|
1024 button->SetTextHorizontalAlignment( CGraphicsContext::ECenter ); |
|
1025 break; |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 if ( !static_cast<CEikCbaButton*>( leftSoftkey )->IsImageOn() ) |
|
1030 { |
|
1031 CEikLabel* label = static_cast<CEikLabel*>( leftSoftkey->ComponentControl( 0 ) ); |
|
1032 |
|
1033 const TDesC* text = label->Text(); |
|
1034 button->AddStateL( NULL, NULL, NULL, NULL, *text, KNullDesC, 0, leftCommandId ); |
|
1035 |
|
1036 if ( text->Length() == 0 || !text->Compare( _L(" ") ) ) |
|
1037 { |
|
1038 button->SetDimmed( ETrue ); |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 button->OverrideColorL( EColorButtonText, color ); |
|
1043 button->OverrideColorL( EColorButtonTextPressed, color ); |
|
1044 button->OverrideColorL( EColorButtonTextDimmed, color ); |
|
1045 |
|
1046 button->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
1047 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
1048 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
1049 |
|
1050 |
|
1051 delete leftSoftkey; |
|
1052 (*iControlArray)[KControlArrayCBAButton1Posn].iControl = button; |
|
1053 |
|
1054 button = CAknButton::NewL(); |
|
1055 button->SetObserver( this ); |
|
1056 |
|
1057 |
|
1058 switch ( AknLayoutScalable_Apps::area_vitu2_query_pane_t2( 0 ).J() ) |
|
1059 { |
|
1060 case ELayoutAlignRight: |
|
1061 { |
|
1062 button->SetTextHorizontalAlignment( CGraphicsContext::ERight ); |
|
1063 break; |
|
1064 } |
|
1065 |
|
1066 case ELayoutAlignLeft: |
|
1067 { |
|
1068 button->SetTextHorizontalAlignment( CGraphicsContext::ELeft ); |
|
1069 break; |
|
1070 } |
|
1071 |
|
1072 case ELayoutAlignCenter: |
|
1073 default: |
|
1074 { |
|
1075 button->SetTextHorizontalAlignment( CGraphicsContext::ECenter ); |
|
1076 break; |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 if ( !static_cast<CEikCbaButton*>( rightSoftkey )->IsImageOn() ) |
|
1081 { |
|
1082 CEikLabel* label = static_cast<CEikLabel*>( rightSoftkey->ComponentControl( 0 ) ); |
|
1083 |
|
1084 const TDesC* text = label->Text(); |
|
1085 button->AddStateL( NULL, NULL, NULL, NULL, *text, KNullDesC, 0, rightCommandId ); |
|
1086 |
|
1087 if ( text->Length() == 0 || !text->Compare( _L(" ") ) ) |
|
1088 { |
|
1089 button->SetDimmed( ETrue ); |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 button->OverrideColorL( EColorButtonText, color ); |
|
1094 button->OverrideColorL( EColorButtonTextPressed, color ); |
|
1095 button->OverrideColorL( EColorButtonTextDimmed, color ); |
|
1096 |
|
1097 button->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
1098 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
1099 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
1100 |
|
1101 delete rightSoftkey; |
|
1102 (*iControlArray)[KControlArrayCBAButton2Posn].iControl = button; |
|
1103 |
|
1104 // CCoeControl::ComponentControl can't be used since base class CEikControlGroup |
|
1105 // doesn't necessarily return all child controls. |
|
1106 for ( TInt i = 0; i < iControlArray->Count(); ++i ) |
|
1107 { |
|
1108 if ( (*iControlArray)[i].iControl ) |
|
1109 { |
|
1110 (*iControlArray)[i].iControl->SetContainerWindowL( *this ); |
|
1111 } |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 else if ( iFlags.IsSet( ECbaEmbedded ) && |
|
1116 !iFlags.IsSet( ECbaParentAsControl ) ) |
|
1117 { |
|
1118 if ( OwnsWindow() ) |
|
1119 { |
|
1120 CloseWindow(); |
|
1121 } |
|
1122 |
|
1123 CreateWindowL( &aContainer ); |
|
1124 EnableWindowTransparency(); |
|
1125 |
|
1126 RWindow& window = Window(); |
|
1127 window.SetPointerGrab(ETrue); |
|
1128 EnableDragEvents(); |
|
1129 window.SetShadowDisabled(ETrue); |
|
1130 |
|
1131 TBool isEmpty = IsEmpty(); |
|
1132 |
|
1133 if ( !isEmpty && !iFlags.IsSet( ECbaHasContent ) ) |
|
1134 { |
|
1135 iFlags.Set( ECbaHasContent ); |
|
1136 } |
|
1137 |
|
1138 for ( TInt i = 0; i < iControlArray->Count(); ++i ) |
|
1139 { |
|
1140 if ( (*iControlArray)[i].iControl ) |
|
1141 { |
|
1142 (*iControlArray)[i].iControl->SetContainerWindowL( *this ); |
|
1143 } |
|
1144 } |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 CCoeControl::SetContainerWindowL( aContainer ); |
|
1149 } |
|
1150 } |
|
1151 |
|
1152 void CEikCba::ActivateL() |
|
1153 { |
|
1154 CCoeControl::ActivateL(); |
|
1155 } |
|
1156 |
|
1157 void CEikCba::BaseConstructL() |
|
1158 { |
|
1159 if ( iFlags.IsSet( ECbaEmbedded ) && iFlags.IsSet( ECbaParentAsControl ) ) |
|
1160 { |
|
1161 __ASSERT_DEBUG( iParentWg, User::Invariant() ); |
|
1162 CreateWindowL( (CCoeControl*)iParentWg ); |
|
1163 EnableWindowTransparency(); |
|
1164 iParentWg = NULL; |
|
1165 iCbaFlags &= ~EEikCbaFlagTransparent; |
|
1166 } |
|
1167 else |
|
1168 { |
|
1169 CreateWindowL( iParentWg ); |
|
1170 |
|
1171 if ( ( ( iCbaFlags & EEikCbaFlagTransparent ) || |
|
1172 iCbaFlags & EEikCbaFlagSemiTransparent ) && |
|
1173 CAknEnv::Static()->TransparencyEnabled() ) |
|
1174 { |
|
1175 Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW |
|
1176 TInt err = Window().SetTransparencyAlphaChannel(); |
|
1177 |
|
1178 if ( err == KErrNone ) |
|
1179 { |
|
1180 // Set the window initially completely transparent. This needs to be called only once. |
|
1181 Window().SetBackgroundColor(~0); |
|
1182 } |
|
1183 else |
|
1184 { |
|
1185 // SetTransparencyAlphaChannel returned an error. |
|
1186 // Revert back to non-transparent CBA. |
|
1187 iCbaFlags &= ~EEikCbaFlagTransparent; |
|
1188 } |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 // Transparency not supported or not enabled |
|
1193 iCbaFlags &= ~EEikCbaFlagTransparent; |
|
1194 } |
|
1195 } |
|
1196 |
|
1197 iExtension = CEikCbaExtension::NewL( *this ); |
|
1198 //create bitmap for semi-transparent background |
|
1199 if ( iCbaFlags & EEikCbaFlagSemiTransparent && iExtension ) |
|
1200 { |
|
1201 iExtension->iSemiBgID = KAknsIIDQsnHomeBgWidget; |
|
1202 iExtension->iSemiBgCenterID = KAknsIIDQsnHomeBgWidgetCenter; |
|
1203 } |
|
1204 |
|
1205 // Skin background is not drawn by embedded CBA. |
|
1206 if ( !iFlags.IsSet( ECbaEmbedded ) ) |
|
1207 { |
|
1208 TRect screen; |
|
1209 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
1210 |
|
1211 // Construct background control context, SizeChanged will update |
|
1212 // the layout rectangle. |
|
1213 iBgIID = AknStatuspaneUtils::IdleLayoutActive() ? |
|
1214 KAknsIIDQsnBgAreaControlIdle : |
|
1215 KAknsIIDQsnBgAreaControl; |
|
1216 |
|
1217 iMLBgContext = CAknsMaskedLayerBackgroundControlContext::NewL( |
|
1218 KAknsIIDWallpaper, |
|
1219 TRect( 0, 0, 1, 1 ), |
|
1220 ETrue, |
|
1221 2 ); |
|
1222 |
|
1223 // Other context for staconpane |
|
1224 |
|
1225 // There is a need for two layers in each context: one for wallpaper, |
|
1226 // the other for skin graphics. |
|
1227 iStaconBgContextTop = CAknsMaskedLayerBackgroundControlContext::NewL( |
|
1228 KAknsIIDWallpaper, TRect( 0, 0, 1, 1 ), ETrue, ECbaLayerN ); |
|
1229 iStaconBgContextBottom = CAknsMaskedLayerBackgroundControlContext::NewL( |
|
1230 KAknsIIDWallpaper, TRect( 0, 0, 1, 1 ), ETrue, ECbaLayerN ); |
|
1231 |
|
1232 for ( TInt i = 0; i < ECbaLayerN; i++ ) |
|
1233 { |
|
1234 iStaconBgContextBottom->SetLayerImage( i, KAknsIIDNone ); |
|
1235 } |
|
1236 |
|
1237 TAknWindowLineLayout layout( AknLayoutScalable_Avkon::area_top_pane(2).LayoutLine() ); |
|
1238 TAknLayoutRect layoutRect; |
|
1239 layoutRect.LayoutRect( screen, layout ); |
|
1240 TRect staconTop( layoutRect.Rect() ); |
|
1241 |
|
1242 layout = AknLayoutScalable_Avkon::area_bottom_pane(2).LayoutLine(); |
|
1243 layoutRect.LayoutRect( screen, layout ); |
|
1244 TRect staconBottom( layoutRect.Rect() ); |
|
1245 |
|
1246 // Set layers to stacon contexts. |
|
1247 // Set bottom as parent to top, so that top is re-drawn, if bottom is drawn. |
|
1248 iStaconBgContextTop->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
1249 iStaconBgContextTop->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
1250 iStaconBgContextTop->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRt ); |
|
1251 iStaconBgContextTop->SetLayerRect( ECbaLayerBackground, staconTop ); |
|
1252 |
|
1253 iStaconBgContextBottom->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
1254 iStaconBgContextBottom->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
1255 iStaconBgContextBottom->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRb ); |
|
1256 iStaconBgContextBottom->SetLayerRect( ECbaLayerBackground, staconBottom ); |
|
1257 iStaconBgContextBottom->SetParentPos( TPoint( 0, 0 ) ); |
|
1258 |
|
1259 iStaconBgContextTop->SetParentContext( iStaconBgContextBottom ); |
|
1260 |
|
1261 TBool idle = AknLayoutFlags() & EAknLayoutCbaInStaconPaneIdle; |
|
1262 if ( idle ) |
|
1263 { |
|
1264 iStaconBgContextTop->SetLayerMaskAndSizeL( KAknsIIDQgnGrafBgLscTopMaskIcon, staconTop ); |
|
1265 iStaconBgContextBottom->SetLayerMaskAndSizeL( KAknsIIDQgnGrafBgLscBottomMaskIcon, staconBottom ); |
|
1266 } |
|
1267 |
|
1268 } |
|
1269 |
|
1270 iExtension->UpdateSoftkeyFrameL( EFalse ); |
|
1271 |
|
1272 CRepository* cenRep = NULL; |
|
1273 TRAPD(err, cenRep = CRepository::NewL( KCRUidAvkon )); |
|
1274 if (!err) |
|
1275 { |
|
1276 err = cenRep->Get( KAknMiddleSoftkeyEnabled, iMSKEnabledInPlatform ); |
|
1277 delete cenRep; |
|
1278 } |
|
1279 |
|
1280 RWindow& window = Window(); |
|
1281 window.SetPointerGrab(ETrue); |
|
1282 EnableDragEvents(); |
|
1283 window.SetShadowDisabled(ETrue); |
|
1284 if ( ! ( iCbaFlags & EEikCbaFlagTransparent ) ) |
|
1285 { |
|
1286 window.SetBackgroundColor(iEikonEnv->ControlColor(EColorToolbarBackground, *this)); |
|
1287 } |
|
1288 CEikControlGroup::ConstructL(CEikControlGroup::EFromBottomLeft, CEikControlGroup::ELayHorizontally); |
|
1289 SetLengthInPixels(iAvkonAppUi->ApplicationRect().Width()); |
|
1290 SetNumberOfLines(1, ETrue); |
|
1291 iBrushAndPenContext = CCoeBrushAndPenContext::NewL(); |
|
1292 CheckSkinAndUpdateContext(); |
|
1293 iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground, *this)); |
|
1294 iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText, *this)); |
|
1295 SetControlContext(iBrushAndPenContext); |
|
1296 iEikonEnv->EikAppUi()->AddToStackL(this, ECoeStackPriorityCba, ECoeStackFlagRefusesFocus); |
|
1297 UpdateFonts(); |
|
1298 |
|
1299 SetMSKVisibility( MskAllowed() ); |
|
1300 |
|
1301 if ( !iFlags.IsSet( ECbaEmbedded ) ) |
|
1302 { |
|
1303 if ( AknStatuspaneUtils::ExtendedFlatLayoutActive() ) |
|
1304 { |
|
1305 // Store the current skin background ID of the clock and indicator |
|
1306 // pane area to draw their background correctly if custom CBA |
|
1307 // background is used. |
|
1308 CEikStatusPaneBase* sp = CEikStatusPaneBase::Current(); |
|
1309 if ( sp ) |
|
1310 { |
|
1311 iClockIndicBgIID = sp->CbaAreaBackgroundID(); |
|
1312 if ( iClockIndicBgIID == KAknsIIDQsnBgAreaControlMp ) |
|
1313 { |
|
1314 // Skin background ID needs to be reverted back |
|
1315 // in destructor. |
|
1316 iIsClockIndicBgIIDSet = ETrue; |
|
1317 } |
|
1318 sp->SetCbaAreaBackgroundID( iBgIID, CEikStatusPaneBase::EDrawDeferred ); |
|
1319 } |
|
1320 else |
|
1321 { |
|
1322 // Default value. |
|
1323 iClockIndicBgIID = KAknsIIDQsnBgAreaControl; |
|
1324 } |
|
1325 } |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 void CEikCba::ConstructL(TInt aResourceId) |
|
1330 { |
|
1331 if (aResourceId != KNoResource) |
|
1332 { |
|
1333 TResourceReader reader; |
|
1334 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
1335 iCbaFlags = reader.ReadInt32(); // flags resource |
|
1336 |
|
1337 // If using enhanced cba. |
|
1338 if ( (iCbaFlags & EEikEnhancedButtonGroup) == EEikEnhancedButtonGroup ) |
|
1339 { |
|
1340 #ifdef RD_ENHANCED_CBA |
|
1341 iCommandTable = CEikCommandTable::NewL(); |
|
1342 BaseConstructL(); |
|
1343 CreateScrollBarFrameL(); |
|
1344 |
|
1345 iSize.iWidth = reader.ReadInt16(); |
|
1346 reader.ReadInt32(); // Skip related buttons resource. |
|
1347 TInt count( reader.ReadInt16() ); // Read the amount of enhanced cba buttons. |
|
1348 |
|
1349 for ( TInt ii = 0; ii < count; ii++ ) |
|
1350 { |
|
1351 TUint8 version( (TUint8)reader.ReadUint8() ); |
|
1352 TInt commandId( 0 ); |
|
1353 TInt longCommandId( 0 ); |
|
1354 CEikEnhancedCbaButton* button = new (ELeave) CEikEnhancedCbaButton; |
|
1355 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
1356 CleanupStack::PushL( button ); |
|
1357 |
|
1358 if( version == EEikCbaButtonLink ) |
|
1359 { |
|
1360 TInt aButtonId( reader.ReadInt32() ); // Read ENHANCED_CBA_BUTTON id from LLINK. |
|
1361 TResourceReader linkReader; // Reader for reading linked resource. |
|
1362 iCoeEnv->CreateResourceReaderLC( linkReader, aButtonId ); |
|
1363 TUint8 ver( linkReader.ReadUint8() ); |
|
1364 if( ver == EEikEnhancedCbaButton ) |
|
1365 { |
|
1366 button->ConstructFromResourceL( linkReader ); |
|
1367 } |
|
1368 CleanupStack::PopAndDestroy( ); // linkReader |
|
1369 } |
|
1370 else if( version == EEikEnhancedCbaButton ) |
|
1371 { |
|
1372 button->ConstructFromResourceL( reader ); |
|
1373 } |
|
1374 else |
|
1375 { |
|
1376 CleanupStack::PopAndDestroy( button ); |
|
1377 continue; // Jump over the rest. |
|
1378 } |
|
1379 |
|
1380 iCommandTable->AddCommandL( button ); // Transfers ownership. |
|
1381 CleanupStack::Pop( button ); |
|
1382 } |
|
1383 |
|
1384 // Set observer and add to control group if placed in the command table. |
|
1385 for ( TInt i = 0; i < KMaxButtonsInCommandTable; i++ ) |
|
1386 { |
|
1387 CEikEnhancedCbaButton* button = iCommandTable->Command( i ); |
|
1388 if( button ) |
|
1389 { |
|
1390 button->SetObserver( Observer() ); |
|
1391 button->SetLabelFont( iLabelFont ); |
|
1392 |
|
1393 TEikGroupControl groupCtrl( |
|
1394 button, |
|
1395 button->CommandId(), |
|
1396 button->Size().iWidth, |
|
1397 TEikGroupControl::ESetLength); |
|
1398 |
|
1399 groupCtrl.iLongId = 0; |
|
1400 AddControlL(groupCtrl); // Transfers ownership. |
|
1401 } |
|
1402 else |
|
1403 { |
|
1404 // Add dummy button if no command for this index. |
|
1405 button = new (ELeave) CEikEnhancedCbaButton; |
|
1406 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
1407 CleanupStack::PushL( button ); |
|
1408 button->ConstructEmptyButtonL(); |
|
1409 CleanupStack::Pop( button ); |
|
1410 |
|
1411 TEikGroupControl groupCtrl( |
|
1412 button, |
|
1413 button->CommandId(), |
|
1414 button->Size().iWidth, |
|
1415 TEikGroupControl::ESetLength); |
|
1416 |
|
1417 AddControlL(groupCtrl); |
|
1418 } |
|
1419 } |
|
1420 |
|
1421 InsertScrollBarL(); |
|
1422 |
|
1423 // This needs to be after all buttons are inserted to control group. |
|
1424 SetBoundingRect(TRect()); |
|
1425 |
|
1426 ActivateL(); |
|
1427 #else // RD_ENHANCED_CBA |
|
1428 User::Leave( KErrNotSupported ); |
|
1429 #endif // RD_ENHANCED_CBA |
|
1430 } |
|
1431 else // Not using enhanced cba. |
|
1432 { |
|
1433 reader.Rewind(4); |
|
1434 ConstructFromResourceL(reader); |
|
1435 } |
|
1436 |
|
1437 CleanupStack::PopAndDestroy(); // reader |
|
1438 } |
|
1439 else // aResourceId == KNoResource |
|
1440 { |
|
1441 BaseConstructL(); |
|
1442 CreateScrollBarFrameL(); |
|
1443 // Alignments for left, right and MSK. |
|
1444 TGulAlignmentValue anAlignment[3] = {EHLeftVCenter, EHRightVCenter, EHCenterVCenter}; |
|
1445 const TInt commands = MaxCommands(); |
|
1446 |
|
1447 for (TInt ii = 0; ii < commands; ii++) |
|
1448 { |
|
1449 CEikCbaButton* button = new(ELeave) CEikCbaButton; |
|
1450 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
1451 button->SetObserver(Observer()); |
|
1452 CleanupStack::PushL(button); |
|
1453 button->ConstructL(anAlignment[ii]); |
|
1454 |
|
1455 // Initialise button size. |
|
1456 if(Orientation() == ELayHorizontally) |
|
1457 { |
|
1458 TSize buttonSize((MinimumSize().iWidth) / commands, button->MinimumSize().iHeight); |
|
1459 button->SetSize(buttonSize); |
|
1460 } |
|
1461 |
|
1462 TEikGroupControl groupCtrl(button, ii, 0, TEikGroupControl::EAllowStretch); |
|
1463 AddControlL(groupCtrl); |
|
1464 button->SetLabelFont(iLabelFont); |
|
1465 CleanupStack::Pop( button ); |
|
1466 } |
|
1467 |
|
1468 InsertScrollBarL(); // into control group |
|
1469 iMSKset = EFalse; |
|
1470 |
|
1471 // This needs to be after all buttons are inserted to control group. |
|
1472 SetBoundingRect(TRect()); |
|
1473 |
|
1474 if ( !iFlags.IsSet( ECbaActivationDelayed ) ) |
|
1475 { |
|
1476 ActivateL(); |
|
1477 } |
|
1478 |
|
1479 // We need to activate MSK in here - it won't be otherwise activated in landscape. |
|
1480 if ( iMSKEnabledInPlatform && AknLayoutUtils::MSKEnabled() && |
|
1481 iControlArray->Count() == (MaxCommands() + 1) ) // scrollbar added |
|
1482 { |
|
1483 if ( (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ) |
|
1484 { |
|
1485 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl->ActivateL(); |
|
1486 } |
|
1487 } |
|
1488 } |
|
1489 |
|
1490 // Set CBA faded in case the softkeys are empty. |
|
1491 SetFadeState(); |
|
1492 } |
|
1493 |
|
1494 |
|
1495 void CEikCba::ConstructFromResourceL(TResourceReader& aReader) |
|
1496 { |
|
1497 BaseConstructL(); |
|
1498 CreateScrollBarFrameL(); |
|
1499 TGulAlignmentValue anAlignment[3] = {EHLeftVCenter, EHRightVCenter, EHCenterVCenter}; |
|
1500 iCbaFlags = aReader.ReadInt32(); // flags resource |
|
1501 iSize.iWidth = aReader.ReadInt16(); |
|
1502 aReader.ReadInt32(); // Skip related buttons resource. |
|
1503 |
|
1504 // Ignore any commands that won't fit on screen. |
|
1505 TInt count = Min(aReader.ReadInt16(), MaxCommands()); |
|
1506 __ASSERT_DEBUG(iControlArray->Count() <= count + 2, Panic(EEikPanicCBAControlArraySize)); |
|
1507 |
|
1508 for (TInt ii = 0; ii < count; ii++) |
|
1509 { |
|
1510 TUint8 version = (TUint8)aReader.ReadUint8(); |
|
1511 TInt commandId; |
|
1512 TInt longCommandId; |
|
1513 if (version == KAknCbaVersion) |
|
1514 { |
|
1515 commandId = aReader.ReadInt16(); |
|
1516 longCommandId = aReader.ReadInt16(); |
|
1517 } |
|
1518 else |
|
1519 { |
|
1520 commandId = aReader.ReadInt16(); |
|
1521 longCommandId = 0; |
|
1522 } |
|
1523 CEikCbaButton* button = new(ELeave) CEikCbaButton; |
|
1524 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
1525 button->SetObserver(Observer()); |
|
1526 CleanupStack::PushL(button); |
|
1527 button->ConstructFromResourceL(aReader, anAlignment[ii]); |
|
1528 // Initialise button size. |
|
1529 if(Orientation() == ELayHorizontally) |
|
1530 { |
|
1531 TSize buttonSize((MinimumSize().iWidth)/count, button->MinimumSize().iHeight); |
|
1532 button->SetSize(buttonSize); |
|
1533 } |
|
1534 TEikGroupControl groupCtrl( |
|
1535 button, |
|
1536 commandId, |
|
1537 button->Size().iWidth, |
|
1538 TEikGroupControl::ESetLength); |
|
1539 |
|
1540 groupCtrl.iLongId = longCommandId; |
|
1541 AddControlL(groupCtrl); |
|
1542 button->SetLabelFont(iLabelFont); |
|
1543 CleanupStack::Pop( button ); |
|
1544 } |
|
1545 |
|
1546 InsertScrollBarL(); // into control group |
|
1547 iMSKset = ETrue; |
|
1548 |
|
1549 // MSK is not mandatory, so add empty button if resource not found. |
|
1550 if (iControlArray->Count() < MaxCommands() + 1) // scrollbar added |
|
1551 { |
|
1552 iMSKset = EFalse; |
|
1553 CEikCbaButton* button = new (ELeave) CEikCbaButton; |
|
1554 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
1555 CleanupStack::PushL( button ); |
|
1556 button->ConstructEmptyButtonL(); |
|
1557 CleanupStack::Pop( button ); |
|
1558 TEikGroupControl groupCtrl(button, 0, button->Size().iWidth,TEikGroupControl::ESetLength); |
|
1559 AddControlL(groupCtrl); |
|
1560 } |
|
1561 |
|
1562 // This needs to be after all buttons are inserted to control group. |
|
1563 if (iMSKset) |
|
1564 { |
|
1565 SetMSKIconL(); |
|
1566 } |
|
1567 |
|
1568 SetBoundingRect(TRect()); |
|
1569 |
|
1570 if ( !iFlags.IsSet( ECbaActivationDelayed ) ) |
|
1571 { |
|
1572 ActivateL(); |
|
1573 } |
|
1574 |
|
1575 // We need to activate MSK in here - it won't be otherwise activated in landscape. |
|
1576 if ( iMSKEnabledInPlatform && AknLayoutUtils::MSKEnabled() && |
|
1577 iControlArray->Count() == (MaxCommands() + 1) ) // scrollbar added |
|
1578 { |
|
1579 if ( (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ) |
|
1580 { |
|
1581 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl->ActivateL(); |
|
1582 } |
|
1583 } |
|
1584 |
|
1585 // Set CBA faded in case the softkeys are empty. |
|
1586 SetFadeState(); |
|
1587 } |
|
1588 |
|
1589 |
|
1590 TInt CEikCba::MaxCommands() const |
|
1591 { |
|
1592 return KMaxSeries60Softkeys; |
|
1593 } |
|
1594 |
|
1595 TInt CEikCba::MSKEnabledInPlatform() const |
|
1596 { |
|
1597 return iMSKEnabledInPlatform; |
|
1598 } |
|
1599 |
|
1600 |
|
1601 // --------------------------------------------------------------------------- |
|
1602 // Sets the middle softkey icon. |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // |
|
1605 void CEikCba::SetMSKIconL() |
|
1606 { |
|
1607 // MSK is not supported by dialog-embedded CBAs. |
|
1608 if ( iFlags.IsSet( ECbaInsideDialog ) || iFlags.IsSet( ECbaEmbedded ) ) |
|
1609 { |
|
1610 return; |
|
1611 } |
|
1612 |
|
1613 if ( !MskAllowed() ) |
|
1614 { |
|
1615 return; |
|
1616 } |
|
1617 |
|
1618 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
1619 if ( !skin ) |
|
1620 { |
|
1621 return; |
|
1622 } |
|
1623 if( iExtension->iIfMskIconSet ) |
|
1624 { |
|
1625 // UpdateIconL(); |
|
1626 return; |
|
1627 } |
|
1628 TEikGroupControl &gCtrl = iControlArray->At( KControlArrayCBAButtonMSKPosn ); |
|
1629 |
|
1630 CEikCbaButton *button = static_cast<CEikCbaButton*>( gCtrl.iControl ); |
|
1631 if ( !button ) |
|
1632 { |
|
1633 return; |
|
1634 } |
|
1635 |
|
1636 CFbsBitmap *bitmap = NULL; |
|
1637 CFbsBitmap *mask = NULL; |
|
1638 |
|
1639 TAknLayoutRect qgn_graf_sk_msk; |
|
1640 TRect rect; |
|
1641 qgn_graf_sk_msk.LayoutRect( |
|
1642 rect, |
|
1643 AknLayoutScalable_Avkon::control_pane_g4( 0 ).LayoutLine() ); |
|
1644 |
|
1645 TSize iconSize( qgn_graf_sk_msk.Rect().Width(), |
|
1646 qgn_graf_sk_msk.Rect().Height() ); |
|
1647 TInt leftId = (*iControlArray)[KControlArrayCBAButton1Posn].iId; |
|
1648 |
|
1649 TRgb MSKColor; |
|
1650 TInt errorMSK; |
|
1651 |
|
1652 TInt iconColorId(0); |
|
1653 TInt leftCBAColorId(0); |
|
1654 |
|
1655 TBool idleState = AknStatuspaneUtils::IdleLayoutActive(); |
|
1656 if ( idleState ) |
|
1657 { |
|
1658 iconColorId = EAknsCIQsnIconColorsCG28; |
|
1659 leftCBAColorId = EAknsCIQsnTextColorsCG15; |
|
1660 |
|
1661 errorMSK = AknsUtils::GetCachedColor( |
|
1662 skin, |
|
1663 MSKColor, |
|
1664 KAknsIIDQsnTextColors, |
|
1665 EAknsCIQsnTextColorsCG57 ); |
|
1666 } |
|
1667 else if ( iPopupVisible ) |
|
1668 { |
|
1669 iconColorId = EAknsCIQsnIconColorsCG29; |
|
1670 leftCBAColorId = EAknsCIQsnTextColorsCG17; |
|
1671 |
|
1672 errorMSK = AknsUtils::GetCachedColor( |
|
1673 skin, |
|
1674 MSKColor, |
|
1675 KAknsIIDQsnTextColors, |
|
1676 EAknsCIQsnTextColorsCG58 ); |
|
1677 } |
|
1678 else |
|
1679 { |
|
1680 iconColorId = EAknsCIQsnIconColorsCG27; |
|
1681 leftCBAColorId = EAknsCIQsnTextColorsCG13; |
|
1682 |
|
1683 errorMSK = AknsUtils::GetCachedColor( |
|
1684 skin, |
|
1685 MSKColor, |
|
1686 KAknsIIDQsnTextColors, |
|
1687 EAknsCIQsnTextColorsCG56 ); |
|
1688 } |
|
1689 |
|
1690 if ( errorMSK ) |
|
1691 { |
|
1692 // Use black if no color specified for MSK in skin. |
|
1693 MSKColor = KRgbBlack; |
|
1694 AknsUtils::GetCachedColor( skin, |
|
1695 MSKColor, |
|
1696 KAknsIIDQsnTextColors, |
|
1697 leftCBAColorId ); |
|
1698 } |
|
1699 |
|
1700 if ( gCtrl.iId == EAknSoftkeyContextOptions ) |
|
1701 { |
|
1702 // Set context specific options menu icon. |
|
1703 AknsUtils::CreateColorIconL( |
|
1704 skin, |
|
1705 KAknsIIDQgnPropMskMenu, |
|
1706 KAknsIIDQsnIconColors, |
|
1707 iconColorId, // There is no color for icon -> use text color. |
|
1708 bitmap, |
|
1709 mask, |
|
1710 KAvkonBitmapFile, |
|
1711 EMbmAvkonQgn_prop_msk_menu, |
|
1712 EMbmAvkonQgn_prop_msk_menu_mask, |
|
1713 MSKColor ); |
|
1714 } |
|
1715 else if ( gCtrl.iId == EAknSoftkeyDialler ) |
|
1716 { |
|
1717 // Set context specific options menu icon. |
|
1718 AknsUtils::CreateColorIconL( |
|
1719 skin, |
|
1720 KAknsIIDQgnIndiTpDialler, |
|
1721 KAknsIIDQsnIconColors, |
|
1722 iconColorId, // There is no color for icon -> use text color. |
|
1723 bitmap, |
|
1724 mask, |
|
1725 KAvkonBitmapFile, |
|
1726 EMbmAvkonQgn_indi_tp_dialler, |
|
1727 EMbmAvkonQgn_indi_tp_dialler_mask, |
|
1728 MSKColor ); |
|
1729 } |
|
1730 else if ( leftId == gCtrl.iId) |
|
1731 { |
|
1732 if ( leftId != EEikBidBlank && |
|
1733 leftId != EAknSoftkeyEmpty && |
|
1734 leftId != 0 ) |
|
1735 { |
|
1736 // Same as left softkey icon. |
|
1737 AknsUtils::CreateColorIconL( |
|
1738 skin, |
|
1739 KAknsIIDQgnPropMskSelect, |
|
1740 KAknsIIDQsnIconColors, |
|
1741 iconColorId, // There is no color for icon -> use text color. |
|
1742 bitmap, |
|
1743 mask, |
|
1744 KAvkonBitmapFile, |
|
1745 EMbmAvkonQgn_prop_msk_select, |
|
1746 EMbmAvkonQgn_prop_msk_select_mask, |
|
1747 MSKColor ); |
|
1748 } |
|
1749 } |
|
1750 |
|
1751 if ( bitmap ) // Bitmap not set -> do not use image. |
|
1752 { |
|
1753 AknIconUtils::DisableCompression( bitmap ); |
|
1754 AknIconUtils::DisableCompression( mask ); |
|
1755 AknIconUtils::SetSize( bitmap, iconSize ); |
|
1756 |
|
1757 CEikImage* image = new (ELeave) CEikImage; |
|
1758 image->SetPicture( bitmap, mask ); |
|
1759 |
|
1760 // Transfers ownership of the image (image owns bitmap and mask). |
|
1761 button->SetImage( *image ); |
|
1762 } |
|
1763 else |
|
1764 { |
|
1765 button->ReplaceImageByLabel(); // remove old image |
|
1766 } |
|
1767 |
|
1768 button->SetContainerWindowL( *this ); |
|
1769 } |
|
1770 |
|
1771 EXPORT_C TBool CEikCba::UpdateMSKIconL( const TAknsItemID& aId, |
|
1772 const TDesC& aBmpFile, |
|
1773 const TInt32 aBmp, |
|
1774 const TInt32 aBmpM, |
|
1775 TBool aEnable ) |
|
1776 { |
|
1777 iExtension->iIfMskIconSet = EFalse; |
|
1778 |
|
1779 // MSK is not supported by dialog-embedded CBAs. |
|
1780 if (!aEnable) |
|
1781 { |
|
1782 SetMSKIconL(); |
|
1783 return ETrue; |
|
1784 } |
|
1785 |
|
1786 delete iExtension->iBmpFile; |
|
1787 iExtension->iBmpFile = NULL; |
|
1788 iExtension->iBmpFile = aBmpFile.AllocL(); |
|
1789 |
|
1790 iExtension->iIfMskIconSet = ETrue; |
|
1791 iExtension->iMSKSkinID = aId; |
|
1792 |
|
1793 iExtension->iBmp = aBmp; |
|
1794 iExtension->iBmpM = aBmpM; |
|
1795 |
|
1796 return UpdateIconL(); |
|
1797 } |
|
1798 |
|
1799 |
|
1800 // ---------------------------------------------------------------------------- |
|
1801 // CEikCba::EnableItemSpecificSoftkey |
|
1802 // ---------------------------------------------------------------------------- |
|
1803 // |
|
1804 EXPORT_C void CEikCba::EnableItemSpecificSoftkey( TBool aEnable ) |
|
1805 { |
|
1806 if ( iFlags.IsSet( ECbaSingleClickEnabled ) ) |
|
1807 { |
|
1808 iFlags.Assign( ECbaItemSpecificSoftkeyInUse, aEnable ); |
|
1809 |
|
1810 if ( aEnable ) |
|
1811 { |
|
1812 UpdateItemSpecificSoftkey(); |
|
1813 } |
|
1814 else |
|
1815 { |
|
1816 TEikGroupControl& leftSoftkey = |
|
1817 ( *iControlArray )[KControlArrayCBAButton1Posn]; |
|
1818 |
|
1819 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
1820 { |
|
1821 leftSoftkey.iControl->MakeVisible( ETrue ); |
|
1822 } |
|
1823 else |
|
1824 { |
|
1825 leftSoftkey.iControl->SetDimmed( EFalse ); |
|
1826 leftSoftkey.iControl->DrawDeferred(); |
|
1827 } |
|
1828 } |
|
1829 } |
|
1830 } |
|
1831 |
|
1832 |
|
1833 void CEikCba::SetMSKCommandObserver(MEikCommandObserver* aCommandObserver) |
|
1834 { |
|
1835 // aCommandObserver set to NULL when removing observer. |
|
1836 iMSKCommandObserver = aCommandObserver; |
|
1837 } |
|
1838 |
|
1839 void CEikCba::UpdateCbaLabels(TBool aScrollerOn) |
|
1840 { |
|
1841 // This method is called only from scrollbar that has nothing to do with |
|
1842 // dialog-embedded CBAs -> ignore the call. |
|
1843 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
1844 { |
|
1845 return; |
|
1846 } |
|
1847 |
|
1848 // Communicate change to CBA buttons. |
|
1849 for (TInt ii = 0; ii < iControlArray->Count(); ii++) |
|
1850 { |
|
1851 if (ii != KControlArrayScrollBarPosn) // To avoid tinkering with scrollbar. |
|
1852 { |
|
1853 TEikGroupControl& gCtrl = iControlArray->At(ii); |
|
1854 CEikCbaButton* button = STATIC_CAST(CEikCbaButton*, gCtrl.iControl); |
|
1855 TRAP_IGNORE(button->SwitchToShortTextL(aScrollerOn)); |
|
1856 } |
|
1857 } |
|
1858 // Change of text may affect layout. |
|
1859 SizeChanged(); |
|
1860 DrawDeferred() ; |
|
1861 } |
|
1862 |
|
1863 void CEikCba::SetSBFrameObserver(MEikScrollBarObserver* aObserver) |
|
1864 { |
|
1865 if(iSBFrame) |
|
1866 { |
|
1867 iSBFrame->SetScrollBarFrameObserver(aObserver); |
|
1868 } |
|
1869 } |
|
1870 |
|
1871 void CEikCba::SetScrollBarModelL(TEikScrollBarModel* aModel) |
|
1872 { |
|
1873 if(iSBFrame) |
|
1874 { |
|
1875 VScrollBarAsControl()->SetModelL(aModel); |
|
1876 } |
|
1877 } |
|
1878 |
|
1879 const CEikCbaScrollBarFrame* CEikCba::ScrollBarFrame() const |
|
1880 { |
|
1881 return STATIC_CAST(const CEikCbaScrollBarFrame*, iSBFrame); |
|
1882 } |
|
1883 |
|
1884 CAknScrollBar* CEikCba::VScrollBarAsControl() |
|
1885 { |
|
1886 return STATIC_CAST(CAknScrollBar*, VScrollBarAsGroupControl().iControl); |
|
1887 } |
|
1888 |
|
1889 void CEikCba::InsertControlL(TEikGroupControl& aGroupControl,TInt aIndex) |
|
1890 { |
|
1891 iControlArray->InsertL(aIndex,aGroupControl); // Takes ownership at this point. |
|
1892 } |
|
1893 |
|
1894 |
|
1895 void CEikCba::SetCommandL( TInt aPosition, |
|
1896 TInt aCommandId, |
|
1897 const TDesC* aText, |
|
1898 const CFbsBitmap* /*aBitmap*/, |
|
1899 const CFbsBitmap* /*aMask*/ ) |
|
1900 { |
|
1901 // We need to check if this call changes the softkeys from being |
|
1902 // empty to having a command or vice versa to be able to maintain |
|
1903 // correct fade state. |
|
1904 TBool isEmptyBefore( IsEmpty() ); |
|
1905 |
|
1906 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
1907 groupCtrl.iId = aCommandId; |
|
1908 groupCtrl.iLongId = 0; |
|
1909 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
1910 { |
|
1911 if ( aText ) |
|
1912 { |
|
1913 static_cast<CEikCbaButton*>( |
|
1914 groupCtrl.iControl )->AddCommandL( *aText ); |
|
1915 } |
|
1916 |
|
1917 if ( aPosition == KControlArrayCBAButtonMSKPosn ) |
|
1918 { |
|
1919 iMSKset = ETrue; |
|
1920 } |
|
1921 SetMSKIconL(); // If MSK or left CBA was changed, this sets MSK icon accordingly. |
|
1922 |
|
1923 // Force labels to be re-formatted... |
|
1924 SizeChanged(); |
|
1925 } |
|
1926 else if ( aPosition != KControlArrayCBAButtonMSKPosn ) |
|
1927 { |
|
1928 CAknButton* button = static_cast<CAknButton*>( groupCtrl.iControl ); |
|
1929 CAknCommandButtonState* buttonState = |
|
1930 static_cast<CAknCommandButtonState*>( button->State() ); |
|
1931 buttonState->SetTextL( *aText ); |
|
1932 buttonState->SetCommand( aCommandId ); |
|
1933 } |
|
1934 |
|
1935 TBool isEmptyAfter( IsEmpty() ); |
|
1936 |
|
1937 if ( !COMPARE_BOOLS( isEmptyBefore, isEmptyAfter ) ) |
|
1938 { |
|
1939 SetFadeState(); |
|
1940 } |
|
1941 |
|
1942 ReportContentChangedEvent(); |
|
1943 } |
|
1944 |
|
1945 |
|
1946 void CEikCba::SetCommandL(TInt aPosition,TInt aResourceId) |
|
1947 { |
|
1948 TResourceReader reader; |
|
1949 iCoeEnv->CreateResourceReaderLC(reader,aResourceId); |
|
1950 TInt version = reader.ReadInt8(); // version |
|
1951 |
|
1952 #ifdef RD_ENHANCED_CBA |
|
1953 if( version == EEikCbaButtonLink ) |
|
1954 { |
|
1955 TInt aButtonId = reader.ReadInt32(); // Read ENHANCED_CBA_BUTTON id from LLINK. |
|
1956 CleanupStack::PopAndDestroy(); // reader |
|
1957 iCoeEnv->CreateResourceReaderLC( reader, aButtonId ); |
|
1958 TUint8 aVersion = reader.ReadUint8(); |
|
1959 |
|
1960 // Panics if linked resource is not enhanced cba button. |
|
1961 __ASSERT_DEBUG( aVersion == EEikEnhancedCbaButton, Panic(EEikPanicCBAIsNotEnhancedCba) ); |
|
1962 |
|
1963 reader.ReadUint8(); // commandType |
|
1964 } |
|
1965 else if( version == EEikEnhancedCbaButton ) |
|
1966 { |
|
1967 reader.ReadUint8(); // commandType |
|
1968 } |
|
1969 #endif // RD_ENHANCED_CBA |
|
1970 TInt commandId(0); |
|
1971 if (version == KAknCbaVersion) |
|
1972 { |
|
1973 commandId = reader.ReadInt16(); |
|
1974 reader.ReadInt16(); |
|
1975 } |
|
1976 else |
|
1977 { |
|
1978 commandId = reader.ReadInt16(); |
|
1979 } |
|
1980 |
|
1981 TPtrC text = reader.ReadTPtrC(); |
|
1982 SetCommandL(aPosition, commandId, &text, NULL, NULL); |
|
1983 CleanupStack::PopAndDestroy(); // reader |
|
1984 |
|
1985 ReportContentChangedEvent(); |
|
1986 } |
|
1987 |
|
1988 /** |
|
1989 * Installs a new set of commands to be associated with the cba buttons. |
|
1990 * The previous command set is restored if there is an error while adding |
|
1991 * the new command set. |
|
1992 */ |
|
1993 void CEikCba::SetCommandSetL(TInt aResourceId) |
|
1994 { |
|
1995 TResourceReader reader; |
|
1996 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
1997 |
|
1998 iCbaFlags = reader.ReadInt32(); |
|
1999 |
|
2000 if ( ( iCbaFlags & EEikEnhancedButtonGroup ) == EEikEnhancedButtonGroup ) |
|
2001 { |
|
2002 CleanupStack::PopAndDestroy(); // reader |
|
2003 OfferCommandListL( aResourceId ); |
|
2004 return; |
|
2005 } |
|
2006 |
|
2007 SetButtonGroupFlags( iCbaFlags ); |
|
2008 reader.ReadInt16(); // Skip width resource. |
|
2009 reader.ReadInt32(); // Skip related buttons resource. |
|
2010 const TInt maxCommands = MaxCommands(); |
|
2011 |
|
2012 // Ignore any commands that won't fit on screen. |
|
2013 TInt count = Min(reader.ReadInt16(), maxCommands); |
|
2014 |
|
2015 TInt previousIds[KMaxSeries60Softkeys + 1]; // Uses 16 bytes stack, +1 for scrollbar. |
|
2016 |
|
2017 __ASSERT_DEBUG(iControlArray->Count() <= count + 2, Panic(EEikPanicCBAControlArraySize)); |
|
2018 |
|
2019 // Replace the existing command set. |
|
2020 TInt controlId = 0; |
|
2021 for (controlId = 0; controlId < count + 1; controlId++) // (+1 for scroll bar) |
|
2022 { |
|
2023 if (controlId != KControlArrayScrollBarPosn) // To avoid tinkering with scrollbar. |
|
2024 { |
|
2025 // Store the existing commands. |
|
2026 TEikGroupControl& groupCtrl = (*iControlArray)[controlId]; |
|
2027 previousIds[controlId] = groupCtrl.iId; |
|
2028 TUint8 version = (TUint8)reader.ReadUint8(); |
|
2029 TInt commandId; |
|
2030 TInt errorcode; |
|
2031 |
|
2032 if (version == KAknCbaVersion) |
|
2033 { |
|
2034 commandId = reader.ReadInt16(); |
|
2035 reader.ReadInt16(); // Skip long command id. |
|
2036 } |
|
2037 else |
|
2038 { |
|
2039 commandId = reader.ReadInt16(); |
|
2040 } |
|
2041 TPtrC text=reader.ReadTPtrC(); |
|
2042 reader.ReadTPtrC(); // bmp filename |
|
2043 reader.ReadInt16(); // bmp id |
|
2044 reader.ReadInt16(); // bmp mask id |
|
2045 |
|
2046 // Add the new commands. |
|
2047 TRAP(errorcode, AddCommandToStackWithoutSizeChangedL(controlId, commandId, &text)); |
|
2048 if (errorcode) // In case of error restore previous commands before leave. |
|
2049 { |
|
2050 if (controlId > 0) |
|
2051 { |
|
2052 for (TInt counter = 0; counter < controlId; counter++) |
|
2053 { |
|
2054 // Do not deal with the scroller as a CEikCbaButton; skip its index. |
|
2055 if (counter != KControlArrayScrollBarPosn) |
|
2056 { |
|
2057 RemoveCommandFromStack(counter,previousIds[counter]); |
|
2058 } |
|
2059 } |
|
2060 } |
|
2061 User::Leave(errorcode); |
|
2062 } |
|
2063 } |
|
2064 } |
|
2065 |
|
2066 // Remove the original commands from the temporary store. |
|
2067 for (controlId = 0; controlId < count + 1; controlId++) // +1 for scroll bar |
|
2068 { |
|
2069 if (controlId != KControlArrayScrollBarPosn) |
|
2070 { |
|
2071 TInt controlPosition = controlId; |
|
2072 if (controlId > 1) |
|
2073 { |
|
2074 controlPosition-=1; |
|
2075 } |
|
2076 RemovePreviousCommandWithoutSizeChanged(controlId); |
|
2077 } |
|
2078 } |
|
2079 SetMSKIconL(); |
|
2080 // If MSK was not defined in softkey resources, set MSK command id same as left |
|
2081 // softkey's command id and set label empty. |
|
2082 // We can't restore original commands any more, so if setting MSK fails, |
|
2083 // at least left and right softkeys are set. |
|
2084 if (count < KControlArrayCBAButtonMSKPosn) |
|
2085 { |
|
2086 TRAP_IGNORE( SetCommandL( |
|
2087 KControlArrayCBAButtonMSKPosn, |
|
2088 (*iControlArray)[KControlArrayCBAButton1Posn].iId, |
|
2089 &KNullDesC, |
|
2090 NULL, |
|
2091 NULL) ); |
|
2092 |
|
2093 iMSKset = ETrue; |
|
2094 } |
|
2095 else |
|
2096 { |
|
2097 SetMSKIconL(); // If MSK id was changed, this sets MSK icon accordingly. |
|
2098 } |
|
2099 |
|
2100 CleanupStack::PopAndDestroy(); // reader |
|
2101 |
|
2102 // Force labels to be re-formatted... |
|
2103 SizeChanged(); |
|
2104 ReportContentChangedEvent(); |
|
2105 } |
|
2106 |
|
2107 void CEikCba::AddCommandL(TInt /*aPosition*/, TInt /*aCommandId*/, const TDesC* /*aText*/, |
|
2108 const CFbsBitmap* /*aBitmap*/, const CFbsBitmap* /*aMask*/) |
|
2109 { |
|
2110 User::Leave(KErrNotSupported); |
|
2111 } |
|
2112 |
|
2113 |
|
2114 void CEikCba::AddCommandToStackWithoutSizeChangedL(TInt aPosition, |
|
2115 TInt aCommandId, |
|
2116 const TDesC* aText) |
|
2117 { |
|
2118 // We need to check if this call changes the softkeys from being |
|
2119 // empty to having a command or vice versa to be able to maintain |
|
2120 // correct fade state. |
|
2121 TBool isEmptyBefore( IsEmpty() ); |
|
2122 |
|
2123 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2124 |
|
2125 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
2126 { |
|
2127 CAknButton* button = static_cast<CAknButton*>( groupCtrl.iControl ); |
|
2128 button->AddStateL( NULL, NULL, NULL, NULL, *aText, KNullDesC, 0, aCommandId ); |
|
2129 |
|
2130 if ( aText->Length() == 0 || !aText->Compare( _L(" ") ) ) |
|
2131 { |
|
2132 button->SetDimmed( ETrue ); |
|
2133 } |
|
2134 |
|
2135 TInt state( button->StateIndex() + 1 ); |
|
2136 |
|
2137 // DrawDeferred must be used here to reduce flicker, |
|
2138 // as ECS may cause unnecessary CBA label updates in queries. |
|
2139 button->SetCurrentState( state, EFalse ); |
|
2140 button->DrawDeferred(); |
|
2141 } |
|
2142 else |
|
2143 { |
|
2144 static_cast<CEikCbaButton*>(groupCtrl.iControl)->PushCommandL(groupCtrl.iId /*aCommandId*/, |
|
2145 *aText); |
|
2146 } |
|
2147 |
|
2148 groupCtrl.iId = aCommandId; |
|
2149 groupCtrl.iLongId = 0; |
|
2150 |
|
2151 if ( aPosition == KControlArrayCBAButtonMSKPosn ) |
|
2152 { |
|
2153 iMSKset = ETrue; |
|
2154 } |
|
2155 SetMSKIconL(); // If MSK id was changed, this sets MSK icon accordingly. |
|
2156 |
|
2157 TBool isEmptyAfter( IsEmpty() ); |
|
2158 |
|
2159 if ( !COMPARE_BOOLS( isEmptyBefore, isEmptyAfter ) ) |
|
2160 { |
|
2161 SetFadeState(); |
|
2162 } |
|
2163 |
|
2164 ReportContentChangedEvent(); |
|
2165 } |
|
2166 |
|
2167 void CEikCba::AddCommandToStackL( TInt aPosition, |
|
2168 TInt aCommandId, |
|
2169 const TDesC* aText, |
|
2170 const CFbsBitmap* /*aBitmap*/, |
|
2171 const CFbsBitmap* /*aMask*/ ) |
|
2172 { |
|
2173 |
|
2174 AddCommandToStackWithoutSizeChangedL( aPosition, aCommandId, aText); |
|
2175 // Force labels to be re-formatted... |
|
2176 SizeChanged(); |
|
2177 } |
|
2178 |
|
2179 |
|
2180 void CEikCba::AddCommandToStackL(TInt aPosition, TInt aResourceId) |
|
2181 { |
|
2182 TResourceReader reader; |
|
2183 iCoeEnv->CreateResourceReaderLC(reader,aResourceId); |
|
2184 TUint8 version = (TUint8)reader.ReadInt8(); |
|
2185 TInt commandId(0); |
|
2186 if (version == KAknCbaVersion) |
|
2187 { |
|
2188 commandId = reader.ReadInt16(); |
|
2189 reader.ReadInt16(); // Skip long command id. |
|
2190 } |
|
2191 else |
|
2192 { |
|
2193 commandId = reader.ReadInt16(); |
|
2194 } |
|
2195 TPtrC text=reader.ReadTPtrC(); |
|
2196 AddCommandToStackL(aPosition, commandId, &text, NULL, NULL); |
|
2197 CleanupStack::PopAndDestroy(); // reader |
|
2198 |
|
2199 ReportContentChangedEvent(); |
|
2200 } |
|
2201 |
|
2202 void CEikCba::AddCommandSetToStackL(TInt aResourceId) |
|
2203 { |
|
2204 TResourceReader reader; |
|
2205 iCoeEnv->CreateResourceReaderLC(reader,aResourceId); |
|
2206 |
|
2207 iCbaFlags = reader.ReadInt32(); // Flags resource. |
|
2208 reader.ReadInt16(); // Skip width resource. |
|
2209 reader.ReadInt32(); // Skip related buttons resource. |
|
2210 |
|
2211 SetButtonGroupFlags( iCbaFlags ); |
|
2212 // Ignore any commands that won't fit on screen. |
|
2213 const TInt maxCommands = MaxCommands(); |
|
2214 const TInt count = Min(reader.ReadInt16(), maxCommands); |
|
2215 |
|
2216 __ASSERT_DEBUG(iControlArray->Count() <= count + 2, Panic(EEikPanicCBAControlArraySize)); |
|
2217 |
|
2218 for (TInt ii = 0; ii < count + 1; ii++) // +1 for scroll bar |
|
2219 { |
|
2220 if (ii != KControlArrayScrollBarPosn) // To avoid tinkering with the scrollbar. |
|
2221 { |
|
2222 TUint8 version = (TUint8)reader.ReadUint8(); |
|
2223 TInt commandId; |
|
2224 |
|
2225 if (version == KAknCbaVersion) |
|
2226 { |
|
2227 commandId = reader.ReadInt16(); |
|
2228 reader.ReadInt16(); // Skip long command id. |
|
2229 } |
|
2230 else |
|
2231 { |
|
2232 commandId = reader.ReadInt16(); |
|
2233 } |
|
2234 TPtrC text = reader.ReadTPtrC(); |
|
2235 reader.ReadTPtrC(); // bmp filename |
|
2236 reader.ReadInt16(); // bmp id |
|
2237 reader.ReadInt16(); // bmp mask id |
|
2238 TInt errorcode; |
|
2239 TRAP(errorcode, AddCommandToStackWithoutSizeChangedL(ii, commandId, &text)); |
|
2240 if (errorcode) // Restore previous commands before leave. |
|
2241 { |
|
2242 if (ii > 0) |
|
2243 { |
|
2244 for (TInt counter = 0; counter < ii; counter++) |
|
2245 { |
|
2246 if (counter != KControlArrayScrollBarPosn) |
|
2247 { |
|
2248 TEikGroupControl& groupCtrl = (*iControlArray)[counter]; |
|
2249 |
|
2250 groupCtrl.iId = |
|
2251 STATIC_CAST(CEikCbaButton*, groupCtrl.iControl)->PopCommand(); |
|
2252 |
|
2253 groupCtrl.iLongId = 0; |
|
2254 } |
|
2255 } |
|
2256 } |
|
2257 User::Leave(errorcode); |
|
2258 } |
|
2259 } |
|
2260 } |
|
2261 |
|
2262 if (count == KControlArrayCBAButtonMSKPosn) |
|
2263 { |
|
2264 iMSKset = ETrue; |
|
2265 } |
|
2266 SetMSKIconL(); // If MSK id was changed, this sets MSK icon accordingly. |
|
2267 |
|
2268 CleanupStack::PopAndDestroy(); // reader |
|
2269 |
|
2270 // Force labels to be re-formatted... |
|
2271 SizeChanged(); |
|
2272 ReportContentChangedEvent(); |
|
2273 } |
|
2274 |
|
2275 void CEikCba::SetDefaultCommand(TInt /*aCommandId*/) |
|
2276 { |
|
2277 } |
|
2278 |
|
2279 TSize CEikCba::CalcMinimumSizeL(TInt /*aResourceId*/) |
|
2280 { |
|
2281 return MinimumSize(); |
|
2282 } |
|
2283 |
|
2284 |
|
2285 void CEikCba::RemoveCommandFromStack( TInt aPosition, TInt aCommandId ) |
|
2286 { |
|
2287 // We need to check if this call changes the softkeys from being |
|
2288 // empty to having a command or vice versa to be able to maintain |
|
2289 // correct fade state. |
|
2290 TBool isEmptyBefore( IsEmpty() ); |
|
2291 |
|
2292 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2293 if ( groupCtrl.iId == aCommandId ) |
|
2294 { |
|
2295 // Command to be removed is topmost. |
|
2296 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
2297 { |
|
2298 CAknButton* button = static_cast<CAknButton*>( groupCtrl.iControl ); |
|
2299 button->RemoveCurrentState(); |
|
2300 |
|
2301 CAknCommandButtonState* buttonState = |
|
2302 static_cast<CAknCommandButtonState*>( button->State() ); |
|
2303 |
|
2304 groupCtrl.iId = buttonState->CommandId(); |
|
2305 groupCtrl.iLongId = 0; |
|
2306 |
|
2307 if ( buttonState->Text().Length() == 0 || |
|
2308 !buttonState->Text().Compare( _L(" ") ) ) |
|
2309 { |
|
2310 button->SetDimmed( ETrue ); |
|
2311 } |
|
2312 } |
|
2313 else |
|
2314 { |
|
2315 groupCtrl.iId = static_cast<CEikCbaButton*>( groupCtrl.iControl )->PopCommand(); |
|
2316 groupCtrl.iLongId = 0; |
|
2317 } |
|
2318 } |
|
2319 else // Command to be removed is not on the top, check the whole stack. |
|
2320 { |
|
2321 STATIC_CAST(CEikCbaButton*, groupCtrl.iControl)->RemoveCommand(aCommandId); |
|
2322 } |
|
2323 |
|
2324 // If MSK or left CBA was changed, this sets MSK icon accordingly. |
|
2325 TRAP_IGNORE( SetMSKIconL() ); |
|
2326 |
|
2327 // Force labels to be re-formatted... |
|
2328 SizeChanged(); |
|
2329 |
|
2330 TBool isEmptyAfter( IsEmpty() ); |
|
2331 |
|
2332 if ( !COMPARE_BOOLS( isEmptyBefore, isEmptyAfter ) ) |
|
2333 { |
|
2334 SetFadeState(); |
|
2335 } |
|
2336 |
|
2337 DrawDeferred(); |
|
2338 ReportContentChangedEvent(); |
|
2339 } |
|
2340 |
|
2341 void CEikCba::RemovePreviousCommandWithoutSizeChanged(TInt aPosition) |
|
2342 { |
|
2343 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2344 STATIC_CAST(CEikCbaButton*, groupCtrl.iControl)->RemovePreviousCommand(); |
|
2345 } |
|
2346 |
|
2347 void CEikCba::RemovePreviousCommand(TInt aPosition) |
|
2348 { |
|
2349 RemovePreviousCommandWithoutSizeChanged( aPosition ); |
|
2350 // If MSK or left CBA was changed, this sets MSK icon accordingly. |
|
2351 TRAP_IGNORE( SetMSKIconL() ); |
|
2352 |
|
2353 // Force labels to be re-formatted... |
|
2354 SizeChanged(); |
|
2355 ReportContentChangedEvent(); |
|
2356 } |
|
2357 |
|
2358 |
|
2359 TInt CEikCba::CommandPos(TInt aCommandId) const |
|
2360 { |
|
2361 return IndexById(aCommandId); |
|
2362 } |
|
2363 |
|
2364 void CEikCba::DimCommand(TInt aCommandId,TBool aDimmed) |
|
2365 { |
|
2366 CCoeControl* control( ButtonById( aCommandId ) ); |
|
2367 if ( control ) |
|
2368 { |
|
2369 if ( SoftkeyStatusChangeAllowed( IndexById( aCommandId ), aDimmed ) ) |
|
2370 { |
|
2371 control->SetDimmed( aDimmed ); |
|
2372 } |
|
2373 } |
|
2374 } |
|
2375 |
|
2376 TBool CEikCba::IsCommandDimmed(TInt aCommandId) const |
|
2377 { |
|
2378 if( ButtonById(aCommandId) ) |
|
2379 { |
|
2380 return ButtonById(aCommandId)->IsDimmed(); |
|
2381 } |
|
2382 return EFalse; |
|
2383 } |
|
2384 |
|
2385 void CEikCba::MakeCommandVisible(TInt aCommandId, TBool aVisible) |
|
2386 { |
|
2387 CCoeControl* control( ButtonById( aCommandId ) ); |
|
2388 if ( control ) |
|
2389 { |
|
2390 if ( SoftkeyStatusChangeAllowed( IndexById( aCommandId ), !aVisible ) ) |
|
2391 { |
|
2392 control->MakeVisible( aVisible ); |
|
2393 } |
|
2394 } |
|
2395 } |
|
2396 |
|
2397 TBool CEikCba::IsCommandVisible(TInt aCommandId) const |
|
2398 { |
|
2399 if( ButtonById(aCommandId) ) |
|
2400 { |
|
2401 return ButtonById(aCommandId)->IsVisible(); |
|
2402 } |
|
2403 return EFalse; |
|
2404 } |
|
2405 |
|
2406 void CEikCba::AnimateCommand(TInt /*aCommandId*/) |
|
2407 { |
|
2408 } |
|
2409 |
|
2410 |
|
2411 // --------------------------------------------------------------------------- |
|
2412 // Sets the dimming status of a button with the specified position. |
|
2413 // --------------------------------------------------------------------------- |
|
2414 // |
|
2415 void CEikCba::DimCommandByPosition( TInt aPosition, TBool aDimmed ) |
|
2416 { |
|
2417 if ( aPosition >= iControlArray->Count() ) |
|
2418 { |
|
2419 return; |
|
2420 } |
|
2421 |
|
2422 if ( SoftkeyStatusChangeAllowed( aPosition, aDimmed ) ) |
|
2423 { |
|
2424 TEikGroupControl& groupCtrl = ( *iControlArray )[ aPosition ]; |
|
2425 groupCtrl.iControl->SetDimmed( aDimmed ); |
|
2426 } |
|
2427 } |
|
2428 |
|
2429 |
|
2430 // --------------------------------------------------------------------------- |
|
2431 // Returns the dimming status of a button with the specified position. |
|
2432 // --------------------------------------------------------------------------- |
|
2433 // |
|
2434 TBool CEikCba::IsCommandDimmedByPosition( TInt aPosition ) const |
|
2435 { |
|
2436 if ( aPosition >= iControlArray->Count() ) |
|
2437 { |
|
2438 return EFalse; |
|
2439 } |
|
2440 |
|
2441 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2442 return groupCtrl.iControl->IsDimmed(); |
|
2443 } |
|
2444 |
|
2445 |
|
2446 // --------------------------------------------------------------------------- |
|
2447 // Sets the visibility of a button with the specified position. |
|
2448 // --------------------------------------------------------------------------- |
|
2449 // |
|
2450 void CEikCba::MakeCommandVisibleByPosition( TInt aPosition, TBool aVisible ) |
|
2451 { |
|
2452 if ( aPosition >= iControlArray->Count() ) |
|
2453 { |
|
2454 return; |
|
2455 } |
|
2456 |
|
2457 if ( SoftkeyStatusChangeAllowed( aPosition, !aVisible ) ) |
|
2458 { |
|
2459 TEikGroupControl& groupCtrl = ( *iControlArray )[ aPosition ]; |
|
2460 |
|
2461 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
2462 { |
|
2463 groupCtrl.iControl->MakeVisible( aVisible ); |
|
2464 } |
|
2465 else |
|
2466 { |
|
2467 // Just dim the button, don't hide it. |
|
2468 groupCtrl.iControl->SetDimmed( !aVisible ); |
|
2469 groupCtrl.iControl->DrawDeferred(); |
|
2470 } |
|
2471 } |
|
2472 } |
|
2473 |
|
2474 |
|
2475 TBool CEikCba::IsCommandVisibleByPosition(TInt aPosition) const |
|
2476 { |
|
2477 if (aPosition >= iControlArray->Count()) |
|
2478 { |
|
2479 return EFalse; |
|
2480 } |
|
2481 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2482 |
|
2483 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
2484 { |
|
2485 return STATIC_CAST(CEikCbaButton*, groupCtrl.iControl)->IsVisible(); |
|
2486 } |
|
2487 |
|
2488 return !groupCtrl.iControl->IsDimmed(); |
|
2489 } |
|
2490 |
|
2491 void CEikCba::AnimateCommandByPosition(TInt /*aPosition*/) |
|
2492 { |
|
2493 } |
|
2494 |
|
2495 /*CCoeControl* CEikCba::GroupControlByPosition(TInt aPosition) const |
|
2496 { |
|
2497 if (aPosition >= iControlArray->Count()) |
|
2498 { |
|
2499 return NULL; |
|
2500 } |
|
2501 TEikGroupControl& groupCtrl = (*iControlArray)[aPosition]; |
|
2502 return groupCtrl.iControl; |
|
2503 }*/ |
|
2504 |
|
2505 |
|
2506 // --------------------------------------------------------------------------- |
|
2507 // CEikCba::ButtonRectByPosition |
|
2508 // Gets a CBA button rectangle. |
|
2509 // --------------------------------------------------------------------------- |
|
2510 // |
|
2511 TRect CEikCba::ButtonRectByPosition( TInt aPosition, TBool aRelativeToScreen ) |
|
2512 { |
|
2513 TRect rect( 0, 0, 0, 0 ); |
|
2514 |
|
2515 if ( aPosition >= iControlArray->Count() || aPosition < 0 ) |
|
2516 { |
|
2517 return rect; |
|
2518 } |
|
2519 |
|
2520 if ( !AknLayoutUtils::PenEnabled() ) |
|
2521 { |
|
2522 // Button rectangle is the actual control rect. |
|
2523 rect = ( *iControlArray )[aPosition].iControl->Rect(); |
|
2524 } |
|
2525 else |
|
2526 { |
|
2527 // In touch layouts the button areas are read from the |
|
2528 // layout data because they are larger than the actual |
|
2529 // control size. |
|
2530 // Also, currently touch layouts do not support MSK, |
|
2531 // so it's ignored. |
|
2532 TRect containerRect( Rect() ); |
|
2533 TAknLayoutRect layoutRect; |
|
2534 TRect button1Rect( 0, 0, 0, 0 ); |
|
2535 TRect button2Rect( 0, 0, 0, 0 ); |
|
2536 TRect buttonMSKRect( 0, 0, 0, 0 ); |
|
2537 |
|
2538 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
2539 { |
|
2540 TRect rect ( Rect() ); |
|
2541 TAknLayoutRect layoutRect; |
|
2542 layoutRect.LayoutRect( |
|
2543 rect, |
|
2544 AknLayoutScalable_Avkon::popup_sk_window_g1( 0 ) ); |
|
2545 |
|
2546 // Button widths are calculated based on cba area width |
|
2547 // margin width is taken from layout |
|
2548 TInt margin = layoutRect.Rect().iTl.iX - rect.iTl.iX; |
|
2549 TInt buttonWidth = ( rect.Width() - margin * 2 ) / 2; |
|
2550 TSize buttonSize ( buttonWidth, layoutRect.Rect().Height() ); |
|
2551 |
|
2552 button1Rect = TRect( |
|
2553 TPoint( rect.iTl.iX + margin, layoutRect.Rect().iTl.iY ), |
|
2554 buttonSize ); |
|
2555 button2Rect = TRect( |
|
2556 TPoint( button1Rect.iBr.iX, layoutRect.Rect().iTl.iY ), |
|
2557 TPoint( rect.iBr.iX - margin, |
|
2558 layoutRect.Rect().iBr.iY ) ); |
|
2559 } |
|
2560 else if ( AknLayoutFlags() & EAknLayoutCbaInRightPane ) |
|
2561 { |
|
2562 // Landcsape nHD layout, button parent rectangle |
|
2563 // is the whole screen so aRelativeToScreen parameter |
|
2564 // is not taken into account. |
|
2565 TAknWindowComponentLayout rightAreaLayout( |
|
2566 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
2567 |
|
2568 layoutRect.LayoutRect( |
|
2569 containerRect, |
|
2570 DoCompose( |
|
2571 rightAreaLayout, |
|
2572 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() ); |
|
2573 TRect bottomSKRect( layoutRect.Rect() ); |
|
2574 |
|
2575 layoutRect.LayoutRect( |
|
2576 containerRect, |
|
2577 DoCompose( |
|
2578 rightAreaLayout, |
|
2579 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() ); |
|
2580 TRect topSKRect( layoutRect.Rect() ); |
|
2581 |
|
2582 layoutRect.LayoutRect( |
|
2583 bottomSKRect, |
|
2584 AknLayoutScalable_Avkon::aid_touch_sctrl_bottom().LayoutLine() ); |
|
2585 button1Rect = layoutRect.Rect(); |
|
2586 |
|
2587 layoutRect.LayoutRect( |
|
2588 topSKRect, |
|
2589 AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() ); |
|
2590 button2Rect = layoutRect.Rect(); |
|
2591 } |
|
2592 else if ( AknLayoutFlags() & EAknLayoutCbaInControlPane ) |
|
2593 { |
|
2594 TBool mskDisabled( !MskAllowed() ); |
|
2595 |
|
2596 TBool flatLscLayout( |
|
2597 Layout_Meta_Data::IsLandscapeOrientation() && |
|
2598 AknStatuspaneUtils::FlatLayoutActive() ); |
|
2599 |
|
2600 if ( mskDisabled && !flatLscLayout ) |
|
2601 { |
|
2602 if ( aRelativeToScreen ) |
|
2603 { |
|
2604 AknLayoutUtils::LayoutMetricsRect( |
|
2605 AknLayoutUtils::EControlPane, containerRect ); |
|
2606 } |
|
2607 |
|
2608 if ( AknLayoutUtils::LayoutMirrored() ) |
|
2609 { |
|
2610 layoutRect.LayoutRect( |
|
2611 containerRect, |
|
2612 AknLayoutScalable_Avkon::aid_touch_ctrl_right().LayoutLine() ); |
|
2613 button1Rect = layoutRect.Rect(); |
|
2614 |
|
2615 layoutRect.LayoutRect( |
|
2616 containerRect, |
|
2617 AknLayoutScalable_Avkon::aid_touch_ctrl_left().LayoutLine() ); |
|
2618 button2Rect = layoutRect.Rect(); |
|
2619 } |
|
2620 else |
|
2621 { |
|
2622 layoutRect.LayoutRect( |
|
2623 containerRect, |
|
2624 AknLayoutScalable_Avkon::aid_touch_ctrl_left().LayoutLine() ); |
|
2625 button1Rect = layoutRect.Rect(); |
|
2626 |
|
2627 layoutRect.LayoutRect( |
|
2628 containerRect, |
|
2629 AknLayoutScalable_Avkon::aid_touch_ctrl_right().LayoutLine() ); |
|
2630 button2Rect = layoutRect.Rect(); |
|
2631 } |
|
2632 } |
|
2633 else |
|
2634 { |
|
2635 layoutRect.LayoutRect( |
|
2636 containerRect, |
|
2637 AknLayoutScalable_Avkon::control_pane_g6( 0 ).LayoutLine() ); |
|
2638 button1Rect = layoutRect.Rect(); |
|
2639 |
|
2640 layoutRect.LayoutRect( |
|
2641 containerRect, |
|
2642 AknLayoutScalable_Avkon::control_pane_g8( 0 ).LayoutLine() ); |
|
2643 button2Rect = layoutRect.Rect(); |
|
2644 |
|
2645 if ( !mskDisabled ) |
|
2646 { |
|
2647 layoutRect.LayoutRect( |
|
2648 containerRect, |
|
2649 AknLayoutScalable_Avkon::control_pane_g7( 0 ).LayoutLine() ); |
|
2650 buttonMSKRect = layoutRect.Rect(); |
|
2651 } |
|
2652 else |
|
2653 { |
|
2654 buttonMSKRect.SetRect( 0, 0, 0, 0 ); |
|
2655 } |
|
2656 } |
|
2657 } |
|
2658 |
|
2659 switch ( aPosition ) |
|
2660 { |
|
2661 case KControlArrayCBAButton1Posn: |
|
2662 { |
|
2663 rect = button1Rect; |
|
2664 break; |
|
2665 } |
|
2666 |
|
2667 case KControlArrayCBAButton2Posn: |
|
2668 { |
|
2669 rect = button2Rect; |
|
2670 break; |
|
2671 } |
|
2672 |
|
2673 case KControlArrayCBAButtonMSKPosn: |
|
2674 { |
|
2675 rect = buttonMSKRect; |
|
2676 break; |
|
2677 } |
|
2678 |
|
2679 default: |
|
2680 { |
|
2681 break; |
|
2682 } |
|
2683 } |
|
2684 } |
|
2685 |
|
2686 return rect; |
|
2687 } |
|
2688 |
|
2689 |
|
2690 CCoeControl* CEikCba::AsControl() |
|
2691 { |
|
2692 return this; |
|
2693 } |
|
2694 |
|
2695 const CCoeControl* CEikCba::AsControl() const |
|
2696 { |
|
2697 return this; |
|
2698 } |
|
2699 |
|
2700 |
|
2701 void CEikCba::SetBoundingRect( const TRect& /*aBoundingRect*/ ) |
|
2702 { |
|
2703 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
2704 { |
|
2705 return; |
|
2706 } |
|
2707 |
|
2708 // If background skin id has not been set from outside CBA, |
|
2709 // update it in case status pane layout has changed |
|
2710 if ( !iExtension->iCbaBgIIDSetExt ) |
|
2711 { |
|
2712 iBgIID = AknStatuspaneUtils::IdleLayoutActive() ? |
|
2713 KAknsIIDQsnBgAreaControlIdle : |
|
2714 KAknsIIDQsnBgAreaControl; |
|
2715 } |
|
2716 |
|
2717 // If CBA is inserted into a query dialog then it is positioned by the |
|
2718 // query control. |
|
2719 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
2720 { |
|
2721 return; |
|
2722 } |
|
2723 |
|
2724 TRect oldRect( Rect() ); |
|
2725 |
|
2726 TRect screen; |
|
2727 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
2728 |
|
2729 // Enable the MSK icon if status pane layout is changed from |
|
2730 // MSK disabled to MSK enabled one. |
|
2731 TBool mskDisabled( !MskAllowed() ); |
|
2732 |
|
2733 const TInt aknLayoutFlags = AknLayoutFlags(); |
|
2734 if ( aknLayoutFlags & EAknLayoutCbaInControlPane ) |
|
2735 { |
|
2736 if ( mskDisabled ) |
|
2737 { |
|
2738 SetMSKVisibility( EFalse ); |
|
2739 } |
|
2740 else |
|
2741 { |
|
2742 SetMSKVisibility( ETrue ); |
|
2743 TRAP_IGNORE( SetMSKIconL() ); |
|
2744 } |
|
2745 |
|
2746 // We must check for landscape mode bottom sks |
|
2747 TInt bottomPaneVariety = 1; |
|
2748 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
2749 { |
|
2750 bottomPaneVariety = 6; |
|
2751 } |
|
2752 |
|
2753 TAknWindowLineLayout controlPane( DoCompose( |
|
2754 AknLayoutScalable_Avkon::application_window( 0 ), |
|
2755 DoCompose( AknLayoutScalable_Avkon::area_bottom_pane( bottomPaneVariety ), |
|
2756 AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() ); |
|
2757 |
|
2758 TAknLayoutRect cbarect; |
|
2759 cbarect.LayoutRect( screen, controlPane ); |
|
2760 |
|
2761 SetRect( cbarect.Rect() ); |
|
2762 |
|
2763 // Set correct window region incase we have been in stacon mode. |
|
2764 RRegion region; |
|
2765 region.AddRect( Rect() ); |
|
2766 |
|
2767 CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current(); |
|
2768 |
|
2769 // If status indicators and clock are shown in control pane area, |
|
2770 // then remove those areas from cba window region. |
|
2771 // |
|
2772 // NOTE: MSK is not supported in landscape. |
|
2773 // |
|
2774 if ( statusPane && |
|
2775 statusPane->IsVisible() && |
|
2776 AknStatuspaneUtils::ExtendedFlatLayoutActive() && |
|
2777 ( iBgIID == KAknsIIDQsnBgAreaControl || |
|
2778 iBgIID == KAknsIIDQsnBgAreaControlIdle || |
|
2779 iBgIID == KAknsIIDQsnBgAreaControlMp || |
|
2780 ( iBgIID == KAknsIIDWallpaper && |
|
2781 AknStatuspaneUtils::IdleLayoutActive() ) ) ) |
|
2782 { |
|
2783 TRect digitalClockRect( 0,0,0,0 ); |
|
2784 TRect indicatorRect( 0,0,0,0 ); |
|
2785 |
|
2786 if ( iBgIID == KAknsIIDQsnBgAreaControlMp ) |
|
2787 { |
|
2788 if ( !iIsClockIndicBgIIDSet ) |
|
2789 { |
|
2790 statusPane->SetCbaAreaBackgroundID( |
|
2791 iBgIID, |
|
2792 CEikStatusPaneBase::EDrawDeferred ); |
|
2793 iIsClockIndicBgIIDSet = ETrue; |
|
2794 } |
|
2795 } |
|
2796 else |
|
2797 { |
|
2798 if ( statusPane->CbaAreaBackgroundID() != iBgIID ) |
|
2799 { |
|
2800 statusPane->SetCbaAreaBackgroundID( |
|
2801 iBgIID, |
|
2802 CEikStatusPaneBase::EDrawDeferred ); |
|
2803 } |
|
2804 } |
|
2805 |
|
2806 TRAPD( err1, |
|
2807 indicatorRect = statusPane->PaneRectL( TUid::Uid( |
|
2808 EEikStatusPaneUidIndic ) ) ); |
|
2809 |
|
2810 TRAPD( err2, |
|
2811 digitalClockRect = statusPane->PaneRectL( TUid::Uid( |
|
2812 EEikStatusPaneUidDigitalClock ) ) ); |
|
2813 |
|
2814 if ( !err1 && !err2 ) |
|
2815 { |
|
2816 TPoint cbaPositionRelativeToScreen( PositionRelativeToScreen() ); |
|
2817 TRect cbaRectRelativeToScreen( cbaPositionRelativeToScreen, Size() ); |
|
2818 |
|
2819 if ( cbaRectRelativeToScreen.Intersects( indicatorRect ) ) |
|
2820 { |
|
2821 indicatorRect.Move( |
|
2822 -cbaPositionRelativeToScreen.iX, |
|
2823 -cbaPositionRelativeToScreen.iY ); |
|
2824 |
|
2825 region.SubRect( indicatorRect ); |
|
2826 } |
|
2827 |
|
2828 if ( cbaRectRelativeToScreen.Intersects( digitalClockRect ) ) |
|
2829 { |
|
2830 digitalClockRect.Move( |
|
2831 -cbaPositionRelativeToScreen.iX, |
|
2832 -cbaPositionRelativeToScreen.iY ); |
|
2833 |
|
2834 region.SubRect( digitalClockRect ); |
|
2835 } |
|
2836 } |
|
2837 } |
|
2838 |
|
2839 if ( !region.CheckError() ) |
|
2840 { |
|
2841 Window().SetShape( region ); |
|
2842 } |
|
2843 region.Close(); |
|
2844 } |
|
2845 else if ( aknLayoutFlags & EAknLayoutCbaInRightPane ) |
|
2846 { |
|
2847 // Softkeys in right pane. |
|
2848 // |
|
2849 // We set the rect to whole screen and then set window to |
|
2850 // clip other parts than softkey buttons. |
|
2851 |
|
2852 TRect rect( screen ); |
|
2853 SetRect( rect ); |
|
2854 |
|
2855 // Read right (top in landscape) softkey layout. |
|
2856 TAknWindowLineLayout rightSoftkeyLayout( |
|
2857 DoCompose( AknLayoutScalable_Avkon::area_side_right_pane( 0 ), |
|
2858 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() ); |
|
2859 |
|
2860 TAknLayoutRect rightSoftkeyLayoutRect; |
|
2861 rightSoftkeyLayoutRect.LayoutRect( rect, rightSoftkeyLayout ); |
|
2862 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
2863 |
|
2864 // Read left (bottom in landscape) softkey layout. |
|
2865 TAknWindowLineLayout leftSoftkeyLayout( |
|
2866 DoCompose( AknLayoutScalable_Avkon::area_side_right_pane( 0 ), |
|
2867 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() ); |
|
2868 |
|
2869 TAknLayoutRect leftSoftkeyLayoutRect; |
|
2870 leftSoftkeyLayoutRect.LayoutRect( rect, leftSoftkeyLayout ); |
|
2871 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
2872 |
|
2873 // Set the window shape. |
|
2874 RRegion region; |
|
2875 region.AddRect( leftSoftKeyButtonRect ); |
|
2876 region.AddRect( rightSoftKeyButtonRect ); |
|
2877 if ( !region.CheckError() ) |
|
2878 { |
|
2879 Window().SetShape( region ); |
|
2880 } |
|
2881 region.Close(); |
|
2882 } |
|
2883 else |
|
2884 { |
|
2885 // Stacon pane (combined status and control pane). |
|
2886 // |
|
2887 // Control pane is splitted. We set the rect to whole screen and then set window to |
|
2888 // clip other parts than softkey buttons. |
|
2889 |
|
2890 TRect rect( screen ); |
|
2891 SetRect( rect ); |
|
2892 |
|
2893 TInt variety = 0; |
|
2894 if ( AknLayoutFlags() & EAknLayoutCbaInStaconPaneLeft ) |
|
2895 { |
|
2896 variety = 1; |
|
2897 } |
|
2898 |
|
2899 TAknWindowComponentLayout layout0; |
|
2900 TAknWindowComponentLayout layout1; |
|
2901 TAknWindowComponentLayout layout2; |
|
2902 |
|
2903 // Read right (top in landscape) softkey layout. |
|
2904 layout0 = AknLayoutScalable_Avkon::area_top_pane( 2 ); |
|
2905 layout1 = AknLayoutScalable_Avkon::stacon_top_pane(); |
|
2906 |
|
2907 // If clock is shown in stacon, cba area is smaller. |
|
2908 TInt topCbaVariety = variety; |
|
2909 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() |
|
2910 || AknStatuspaneUtils::ExtendedLayoutActive() ) |
|
2911 { |
|
2912 topCbaVariety += 4; |
|
2913 } |
|
2914 |
|
2915 layout2 = AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ); |
|
2916 |
|
2917 TAknWindowLineLayout rightSoftkeyLayout( |
|
2918 DoCompose( layout0,DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
2919 |
|
2920 TAknLayoutRect rightSoftkeyLayoutRect; |
|
2921 rightSoftkeyLayoutRect.LayoutRect( rect, rightSoftkeyLayout ); |
|
2922 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
2923 |
|
2924 // Read left (bottom in landscape) softkey layout. |
|
2925 layout0 = AknLayoutScalable_Avkon::area_bottom_pane( 2 ); |
|
2926 layout1 = AknLayoutScalable_Avkon::stacon_bottom_pane(); |
|
2927 |
|
2928 // If clock is shown in stacon, cba area is smaller. |
|
2929 TInt bottomCbaVariety = variety; |
|
2930 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() |
|
2931 || AknStatuspaneUtils::ExtendedLayoutActive() ) |
|
2932 { |
|
2933 bottomCbaVariety += 2; |
|
2934 } |
|
2935 |
|
2936 layout2 = |
|
2937 AknLayoutScalable_Avkon::control_bottom_pane_stacon( |
|
2938 bottomCbaVariety ); |
|
2939 |
|
2940 TAknWindowLineLayout leftSoftkeyLayout( |
|
2941 DoCompose( layout0, DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
2942 |
|
2943 TAknLayoutRect leftSoftkeyLayoutRect; |
|
2944 leftSoftkeyLayoutRect.LayoutRect( rect, leftSoftkeyLayout ); |
|
2945 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
2946 |
|
2947 // Set the window shape. |
|
2948 RRegion region; |
|
2949 region.AddRect( leftSoftKeyButtonRect ); |
|
2950 region.AddRect( rightSoftKeyButtonRect ); |
|
2951 if ( !region.CheckError() ) |
|
2952 { |
|
2953 Window().SetShape( region ); |
|
2954 } |
|
2955 region.Close(); |
|
2956 } |
|
2957 |
|
2958 // The softkey frame needs to be updated if the size or |
|
2959 // position of CBA was changed. |
|
2960 if ( iExtension && Rect() != oldRect ) |
|
2961 { |
|
2962 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
2963 |
|
2964 // Finally ensure that MSK drawing is disabled if the status pane |
|
2965 // layout is changed from MSK enabled to MSK disabled one. |
|
2966 if ( mskDisabled ) |
|
2967 { |
|
2968 SetMSKVisibility( EFalse ); |
|
2969 } |
|
2970 |
|
2971 DrawDeferred(); |
|
2972 } |
|
2973 } |
|
2974 |
|
2975 |
|
2976 // --------------------------------------------------------------------------- |
|
2977 // Subtracts the area occupied by the button group from the specified |
|
2978 // bounding rectangle. |
|
2979 // --------------------------------------------------------------------------- |
|
2980 // |
|
2981 void CEikCba::ReduceRect( TRect& aBoundingRect ) const |
|
2982 { |
|
2983 // CBA inside Popup/Query Input does not reduce bounding rect |
|
2984 if ( iFlags.IsSet( ECbaEmbedded ) || iFlags.IsSet( ECbaInsideDialog ) ) |
|
2985 { |
|
2986 return; |
|
2987 } |
|
2988 |
|
2989 if ( !IsVisible() ) |
|
2990 { |
|
2991 return; |
|
2992 } |
|
2993 |
|
2994 const TInt aknLayoutFlags = AknLayoutFlags(); |
|
2995 |
|
2996 if ( aknLayoutFlags & EAknLayoutCbaInControlPane ) |
|
2997 { |
|
2998 // Cba in control pane. |
|
2999 if ( aBoundingRect.Intersects( TRect( iPosition, iSize ) ) ) |
|
3000 { |
|
3001 aBoundingRect.iBr.iY = Position().iY; |
|
3002 } |
|
3003 } |
|
3004 else if ( aknLayoutFlags & EAknLayoutCbaInRightPane ) |
|
3005 { |
|
3006 // Cba in right pane. |
|
3007 |
|
3008 TRect rect; |
|
3009 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); |
|
3010 |
|
3011 const TAknWindowLineLayout rightPaneLayout( |
|
3012 AknLayoutScalable_Avkon::area_side_right_pane( 0 ).LayoutLine() ); |
|
3013 |
|
3014 TAknLayoutRect rightPaneRect; |
|
3015 rightPaneRect.LayoutRect( rect, rightPaneLayout ); |
|
3016 |
|
3017 const TRect rightPane( rightPaneRect.Rect() ); |
|
3018 |
|
3019 if ( aBoundingRect.Intersects( rightPane ) ) |
|
3020 { |
|
3021 // Always on the right side, won't be mirrored. |
|
3022 aBoundingRect.iBr.iX = rightPane.iTl.iX; |
|
3023 } |
|
3024 } |
|
3025 else |
|
3026 { |
|
3027 // CBA in stacon pane. |
|
3028 if ( iControlArray->Count() != 0 ) |
|
3029 { |
|
3030 CCoeControl *leftSoftkey = |
|
3031 (*iControlArray)[KControlArrayCBAButton1Posn].iControl; |
|
3032 CCoeControl *rightSoftkey = |
|
3033 (*iControlArray)[KControlArrayCBAButton2Posn].iControl; |
|
3034 if ( leftSoftkey && rightSoftkey ) |
|
3035 { |
|
3036 RRegion boundingRegion; |
|
3037 TRect originalboundingRect( aBoundingRect ); |
|
3038 boundingRegion.AddRect( originalboundingRect ); |
|
3039 |
|
3040 TRect rect; |
|
3041 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, |
|
3042 rect ); |
|
3043 |
|
3044 TInt variety = 0; |
|
3045 if ( aknLayoutFlags & EAknLayoutCbaInStaconPaneLeft ) |
|
3046 { |
|
3047 variety = 1; |
|
3048 } |
|
3049 |
|
3050 TAknWindowComponentLayout layout0; |
|
3051 TAknWindowComponentLayout layout1; |
|
3052 TAknWindowComponentLayout layout2; |
|
3053 |
|
3054 // Read right (top in landscape) softkey layout. |
|
3055 layout0 = AknLayoutScalable_Avkon::area_top_pane( 2 ); |
|
3056 layout1 = AknLayoutScalable_Avkon::stacon_top_pane(); |
|
3057 |
|
3058 // If clock is shown in stacon, CBA area is smaller. |
|
3059 TInt topCbaVariety = variety; |
|
3060 TInt bottomCbaVariety = variety; |
|
3061 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
3062 { |
|
3063 topCbaVariety += 4; |
|
3064 bottomCbaVariety += 2; |
|
3065 } |
|
3066 |
|
3067 layout2 = AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ); |
|
3068 |
|
3069 TAknWindowLineLayout rightSoftkeyLayout( |
|
3070 DoCompose( layout0, |
|
3071 DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
3072 |
|
3073 TAknLayoutRect rightSoftkeyLayoutRect; |
|
3074 rightSoftkeyLayoutRect.LayoutRect( rect, rightSoftkeyLayout ); |
|
3075 TRect rightSoftKeyRect( rightSoftkeyLayoutRect.Rect() ); |
|
3076 |
|
3077 // Read left (bottom in landscape) softkey layout. |
|
3078 layout0 = AknLayoutScalable_Avkon::area_bottom_pane( 2 ); |
|
3079 layout1 = AknLayoutScalable_Avkon::stacon_bottom_pane(); |
|
3080 layout2 = AknLayoutScalable_Avkon::control_bottom_pane_stacon( bottomCbaVariety ); |
|
3081 |
|
3082 TAknWindowLineLayout leftSoftkeyLayout( |
|
3083 DoCompose( layout0, |
|
3084 DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
3085 |
|
3086 TAknLayoutRect leftSoftkeyLayoutRect; |
|
3087 leftSoftkeyLayoutRect.LayoutRect( rect, leftSoftkeyLayout ); |
|
3088 TRect leftSoftKeyRect( leftSoftkeyLayoutRect.Rect() ); |
|
3089 |
|
3090 boundingRegion.SubRect( leftSoftKeyRect ); |
|
3091 boundingRegion.SubRect( rightSoftKeyRect ); |
|
3092 |
|
3093 TInt count = boundingRegion.Count(); |
|
3094 |
|
3095 TRect largestBoundingRect( 0, 0, 0, 0 ); |
|
3096 TRect boundingRect( 0, 0, 0, 0 ); |
|
3097 for ( TInt j = 0; j < count; j++ ) |
|
3098 { |
|
3099 boundingRect = boundingRegion[j]; |
|
3100 if ( boundingRect.Height() >= largestBoundingRect.Height() ) |
|
3101 { |
|
3102 largestBoundingRect = boundingRect; |
|
3103 } |
|
3104 } |
|
3105 |
|
3106 // Return largest bounding rect. |
|
3107 aBoundingRect = largestBoundingRect; |
|
3108 boundingRegion.Close(); |
|
3109 } |
|
3110 } |
|
3111 } |
|
3112 } |
|
3113 |
|
3114 |
|
3115 CCoeControl* CEikCba::GroupControlById(TInt aCommandId) |
|
3116 { |
|
3117 return ButtonById(aCommandId); |
|
3118 } |
|
3119 |
|
3120 |
|
3121 CCoeControl* CEikCba::GroupControlById(TInt aCommandId) const |
|
3122 { |
|
3123 return ButtonById(aCommandId); |
|
3124 } |
|
3125 |
|
3126 TInt CEikCba::CommandId(TInt aCommandPos) const |
|
3127 { |
|
3128 return (*iControlArray)[aCommandPos].iId; |
|
3129 } |
|
3130 |
|
3131 TInt CEikCba::ButtonCount() const |
|
3132 { |
|
3133 return (iControlArray->Count()-1); // -1 for scroll bar; |
|
3134 } |
|
3135 |
|
3136 CEikCommandButton* CEikCba::GroupControlAsButton(TInt /*aCommandId*/) const |
|
3137 { |
|
3138 // It is not possible to convert a CBA button to a CEikCommandButton. |
|
3139 // Please use an interface that does not use a CEikCommandButton conversion, |
|
3140 // e.g. CEikButtonGroupContainer::SetCommandL(). |
|
3141 #if defined(_DEBUG) |
|
3142 Panic(EEikPanicCBACannotConvertToCEikCommandButton); |
|
3143 #endif |
|
3144 return NULL; |
|
3145 } |
|
3146 |
|
3147 TUint CEikCba::ButtonGroupFlags() const |
|
3148 { |
|
3149 return iCbaFlags ; |
|
3150 } |
|
3151 |
|
3152 EXPORT_C void CEikCba::SetButtonGroupFlags(TInt aFlags) |
|
3153 { |
|
3154 iCbaFlags = aFlags; |
|
3155 if (( iCbaFlags & EEikCbaFlagTransparent || iCbaFlags & EEikCbaFlagSemiTransparent ) && |
|
3156 CAknEnv::Static()->TransparencyEnabled() ) |
|
3157 { |
|
3158 Window().SetRequiredDisplayMode( EColor16MA ); |
|
3159 TInt err = Window().SetTransparencyAlphaChannel(); |
|
3160 if( err == KErrNone ) |
|
3161 { |
|
3162 Window().SetBackgroundColor( ~0 ); |
|
3163 if ( iExtension && iExtension->iEnablePostingTransparency ) |
|
3164 { |
|
3165 iExtension->iEnablePostingTransparency = EFalse; |
|
3166 delete iExtension->iLskPostingOverlayBitmap; |
|
3167 iExtension->iLskPostingOverlayBitmap = NULL; |
|
3168 delete iExtension->iRskPostingOverlayBitmap; |
|
3169 iExtension->iRskPostingOverlayBitmap = NULL; |
|
3170 BroadcastPostingTransparency( EFalse ); |
|
3171 } |
|
3172 } |
|
3173 else |
|
3174 { |
|
3175 iCbaFlags &= ~EEikCbaFlagTransparent; |
|
3176 } |
|
3177 } |
|
3178 else |
|
3179 { |
|
3180 iCbaFlags &= ~EEikCbaFlagTransparent; |
|
3181 } |
|
3182 if ( iCbaFlags & EEikCbaFlagSemiTransparent ) |
|
3183 { |
|
3184 if ( iExtension ) |
|
3185 { |
|
3186 iExtension->iSemiBgID = KAknsIIDQsnHomeBgWidget; |
|
3187 iExtension->iSemiBgCenterID = KAknsIIDQsnHomeBgWidgetCenter; |
|
3188 } |
|
3189 } |
|
3190 else |
|
3191 { |
|
3192 if ( iExtension ) |
|
3193 { |
|
3194 iExtension->iSemiBgID = KAknsIIDNone; |
|
3195 iExtension->iSemiBgCenterID = KAknsIIDNone; |
|
3196 } |
|
3197 } |
|
3198 |
|
3199 UpdateFonts(); |
|
3200 } |
|
3201 |
|
3202 // ----------------------------------------------------------------------------- |
|
3203 // CEikCba::SetSkinBackgroundId |
|
3204 // |
|
3205 // ----------------------------------------------------------------------------- |
|
3206 // |
|
3207 EXPORT_C void CEikCba::SetSkinBackgroundId( const TAknsItemID& aIID ) |
|
3208 { |
|
3209 // Skin background is not drawn by embedded CBA. |
|
3210 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
3211 { |
|
3212 return; |
|
3213 } |
|
3214 |
|
3215 if ( iBgIID != KAknsIIDNone ) |
|
3216 { |
|
3217 if ( iBgIID != aIID ) |
|
3218 { |
|
3219 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
3220 } |
|
3221 |
|
3222 iBgIID = aIID; |
|
3223 iExtension->iCbaBgIIDSetExt = ETrue; |
|
3224 } |
|
3225 |
|
3226 if ( iMLBgContext ) |
|
3227 { |
|
3228 DoSetLayers( aIID ); |
|
3229 |
|
3230 if ( aIID.iMajor == KAknsIIDQsnBgAreaControlPopup.iMajor && |
|
3231 aIID.iMinor == KAknsIIDQsnBgAreaControlPopup.iMinor ) |
|
3232 { |
|
3233 iPopupVisible = ETrue; |
|
3234 } |
|
3235 else |
|
3236 { |
|
3237 iPopupVisible = EFalse; |
|
3238 } |
|
3239 |
|
3240 } |
|
3241 |
|
3242 CheckSkinAndUpdateContext(); |
|
3243 |
|
3244 if ( AknStatuspaneUtils::ExtendedFlatLayoutActive() ) |
|
3245 { |
|
3246 // Clock and indicator pane area must be removed from |
|
3247 // this window in extended flat layout. |
|
3248 SetBoundingRect( TRect(0,0,0,0) ); // dummy parameter |
|
3249 } |
|
3250 |
|
3251 CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current(); |
|
3252 |
|
3253 if ( statusPane && |
|
3254 ( iIsClockIndicBgIIDSet && |
|
3255 iBgIID == KAknsIIDQsnBgAreaControlMp && |
|
3256 statusPane->CbaAreaBackgroundID() != iBgIID ) || |
|
3257 ( iBgIID == KAknsIIDQsnBgAreaControlMp && |
|
3258 AknLayoutFlags() & EAknLayoutCbaInRightPane ) ) |
|
3259 { |
|
3260 statusPane->SetCbaAreaBackgroundID( |
|
3261 iBgIID, |
|
3262 CEikStatusPaneBase::EDrawDeferred ); |
|
3263 } |
|
3264 } |
|
3265 |
|
3266 TKeyResponse CEikCba::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
3267 { |
|
3268 if (aType != EEventKey) |
|
3269 { |
|
3270 return EKeyWasNotConsumed; |
|
3271 } |
|
3272 |
|
3273 // Return immediately if the control is invisible. |
|
3274 if (!IsVisible() && !(iCbaFlags&EAknCBAFlagRespondWhenInvisible)) |
|
3275 { |
|
3276 return EKeyWasNotConsumed; |
|
3277 } |
|
3278 |
|
3279 TBool shiftControlPressed = |
|
3280 (aKeyEvent.iModifiers & EModifierShift) || |
|
3281 (aKeyEvent.iModifiers & EModifierLeftShift) || |
|
3282 (aKeyEvent.iModifiers & EModifierRightShift) || |
|
3283 (aKeyEvent.iModifiers & EModifierCtrl) || |
|
3284 (aKeyEvent.iModifiers & EModifierRightCtrl); |
|
3285 |
|
3286 TKeyResponse response(EKeyWasNotConsumed); |
|
3287 |
|
3288 // AknLaf - changed to use keys defined in AknKeys.h. |
|
3289 // Left soft key will be returned also when MSK is enabled but not defined. |
|
3290 if (aKeyEvent.iCode == EKeyCBA1) |
|
3291 { |
|
3292 if (KControlArrayCBAButton1Posn < iControlArray->Count()) |
|
3293 { |
|
3294 // Return immediately if the button is invisible |
|
3295 if ( (*iControlArray)[KControlArrayCBAButton1Posn].iControl && |
|
3296 !(*iControlArray)[KControlArrayCBAButton1Posn].iControl->IsVisible() && |
|
3297 !(iCbaFlags & EAknCBAFlagRespondWhenInvisible) ) |
|
3298 { |
|
3299 return EKeyWasConsumed; |
|
3300 } |
|
3301 TInt shortCommand = (*iControlArray)[KControlArrayCBAButton1Posn].iId; |
|
3302 TInt longCommand = (*iControlArray)[KControlArrayCBAButton1Posn].iLongId; |
|
3303 |
|
3304 // This will pass key event to application - no softkey command is processed. |
|
3305 if (shortCommand == EAknSoftkeyForwardKeyEvent) |
|
3306 { |
|
3307 return EKeyWasNotConsumed; |
|
3308 } |
|
3309 |
|
3310 if (aKeyEvent.iRepeats == 0 && shortCommand) |
|
3311 { |
|
3312 iCommandObserver->ProcessCommandL((TInt)shortCommand); |
|
3313 } |
|
3314 else if (longCommand) |
|
3315 { |
|
3316 iCommandObserver->ProcessCommandL((TInt)longCommand); |
|
3317 } |
|
3318 response = EKeyWasConsumed; |
|
3319 } |
|
3320 } |
|
3321 else if (aKeyEvent.iCode == EKeyCBA2) |
|
3322 { |
|
3323 if (KControlArrayCBAButton2Posn < iControlArray->Count()) |
|
3324 { |
|
3325 // Return immediately if the button is invisible. |
|
3326 if ( (*iControlArray)[KControlArrayCBAButton2Posn].iControl && |
|
3327 !(*iControlArray)[KControlArrayCBAButton2Posn].iControl->IsVisible() && |
|
3328 !(iCbaFlags&EAknCBAFlagRespondWhenInvisible) ) |
|
3329 { |
|
3330 return EKeyWasConsumed; |
|
3331 } |
|
3332 TInt shortCommand = (*iControlArray)[KControlArrayCBAButton2Posn].iId; |
|
3333 TInt longCommand = (*iControlArray)[KControlArrayCBAButton2Posn].iLongId; |
|
3334 |
|
3335 if (!shortCommand && (aKeyEvent.iModifiers & EModifierKeyboardExtend) |
|
3336 && (aKeyEvent.iScanCode == EStdKeyDevice1)) |
|
3337 { |
|
3338 shortCommand = EEikBidCancel; |
|
3339 } |
|
3340 |
|
3341 // This will pass key event to application - no softkey command is processed. |
|
3342 if (shortCommand == EAknSoftkeyForwardKeyEvent) |
|
3343 { |
|
3344 return EKeyWasNotConsumed; |
|
3345 } |
|
3346 |
|
3347 if (aKeyEvent.iRepeats == 0 && shortCommand) |
|
3348 { |
|
3349 iCommandObserver->ProcessCommandL((TInt)shortCommand); |
|
3350 } |
|
3351 else if (longCommand) |
|
3352 { |
|
3353 iCommandObserver->ProcessCommandL((TInt)longCommand); |
|
3354 } |
|
3355 response=EKeyWasConsumed; |
|
3356 } |
|
3357 } |
|
3358 // Only take care of MSK if there has been something set to MSK (so that this doesn't break old |
|
3359 // cbas with only left and right softkeys set). |
|
3360 |
|
3361 // Do not handle key events with middle softkey if single click is enabled |
|
3362 else if ( iFlags.IsClear( ECbaSingleClickEnabled ) |
|
3363 && AknLayoutUtils::MSKEnabled() |
|
3364 && iMSKset |
|
3365 && aKeyEvent.iCode == EKeyOK |
|
3366 && !Window().IsFaded() ) |
|
3367 { |
|
3368 if (KControlArrayCBAButtonMSKPosn < iControlArray->Count()) |
|
3369 { |
|
3370 // Return immediately if the button is invisible. |
|
3371 if ( (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl && |
|
3372 !(*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl->IsVisible() && |
|
3373 !(iCbaFlags&EAknCBAFlagRespondWhenInvisible) ) |
|
3374 { |
|
3375 return EKeyWasConsumed; |
|
3376 } |
|
3377 |
|
3378 TInt shortCommand = (*iControlArray)[KControlArrayCBAButtonMSKPosn].iId; |
|
3379 TInt longCommand = (*iControlArray)[KControlArrayCBAButtonMSKPosn].iLongId; |
|
3380 |
|
3381 // This will pass key event to application - no softkey command is processed. |
|
3382 if (shortCommand == EAknSoftkeyForwardKeyEvent) |
|
3383 { |
|
3384 return EKeyWasNotConsumed; |
|
3385 } |
|
3386 |
|
3387 if (aKeyEvent.iRepeats == 0 && shortCommand) |
|
3388 { |
|
3389 if (iMSKCommandObserver) |
|
3390 { |
|
3391 iMSKCommandObserver->ProcessCommandL(shiftControlPressed ? |
|
3392 EAknSoftkeyShiftMSK : (TInt)shortCommand); |
|
3393 } |
|
3394 // MSK observer handles shift, no normal MSK after that. |
|
3395 if (!(iMSKCommandObserver && shiftControlPressed)) |
|
3396 { |
|
3397 iCommandObserver->ProcessCommandL((TInt)shortCommand); |
|
3398 } |
|
3399 } |
|
3400 else if (longCommand) |
|
3401 { |
|
3402 if (iMSKCommandObserver) |
|
3403 { |
|
3404 iMSKCommandObserver->ProcessCommandL(shiftControlPressed ? |
|
3405 EAknSoftkeyShiftMSK : (TInt)longCommand); |
|
3406 } |
|
3407 // MSK observer handles shift, no normal MSK after that. |
|
3408 if (!(iMSKCommandObserver && shiftControlPressed)) |
|
3409 { |
|
3410 iCommandObserver->ProcessCommandL((TInt)longCommand); |
|
3411 } |
|
3412 } |
|
3413 response=EKeyWasConsumed; |
|
3414 } |
|
3415 } |
|
3416 // If MSK is enabled but not defined, we return left softkey. |
|
3417 // Do not handle key events with middle softkey if single click is enabled |
|
3418 else if ( iFlags.IsClear( ECbaSingleClickEnabled ) |
|
3419 && AknLayoutUtils::MSKEnabled() |
|
3420 && !iMSKset |
|
3421 && aKeyEvent.iCode == EKeyOK |
|
3422 && !Window().IsFaded() ) |
|
3423 { |
|
3424 if (KControlArrayCBAButton1Posn < iControlArray->Count()) |
|
3425 { |
|
3426 // Return immediately if the button is invisible. |
|
3427 if ( (*iControlArray)[KControlArrayCBAButton1Posn].iControl && |
|
3428 !(*iControlArray)[KControlArrayCBAButton1Posn].iControl->IsVisible() && |
|
3429 !(iCbaFlags&EAknCBAFlagRespondWhenInvisible) ) |
|
3430 { |
|
3431 return EKeyWasConsumed; |
|
3432 } |
|
3433 |
|
3434 TInt shortCommand = (*iControlArray)[KControlArrayCBAButton1Posn].iId; |
|
3435 TInt longCommand = (*iControlArray)[KControlArrayCBAButton1Posn].iLongId; |
|
3436 |
|
3437 // This will pass key event to application - no softkey command is processed. |
|
3438 if (shortCommand == EAknSoftkeyForwardKeyEvent) |
|
3439 { |
|
3440 return EKeyWasNotConsumed; |
|
3441 } |
|
3442 |
|
3443 if (aKeyEvent.iRepeats == 0 && shortCommand) |
|
3444 { |
|
3445 // Send shift + MSK to (listbox) observer even if MSK is not defined. |
|
3446 if (iMSKCommandObserver && shiftControlPressed) |
|
3447 { |
|
3448 iMSKCommandObserver->ProcessCommandL(EAknSoftkeyShiftMSK); |
|
3449 } |
|
3450 else |
|
3451 { |
|
3452 iCommandObserver->ProcessCommandL((TInt)shortCommand); |
|
3453 } |
|
3454 } |
|
3455 else if (longCommand) |
|
3456 { |
|
3457 // Send shift + MSK to (listbox) observer even if MSK is not defined. |
|
3458 if (iMSKCommandObserver && shiftControlPressed) |
|
3459 { |
|
3460 iMSKCommandObserver->ProcessCommandL(EAknSoftkeyShiftMSK); |
|
3461 } |
|
3462 else |
|
3463 { |
|
3464 iCommandObserver->ProcessCommandL((TInt)longCommand); |
|
3465 } |
|
3466 } |
|
3467 response = EKeyWasConsumed; |
|
3468 } |
|
3469 } |
|
3470 |
|
3471 return response; |
|
3472 } |
|
3473 |
|
3474 EXPORT_C void* CEikCba::ExtensionInterface( TUid /*aInterface*/ ) |
|
3475 { |
|
3476 return NULL; |
|
3477 } |
|
3478 |
|
3479 |
|
3480 // --------------------------------------------------------------------------- |
|
3481 // Handles pointer events by passing the event to component controls by using |
|
3482 // the base class functionality. In addition this function notifies the |
|
3483 // command observer if a cba button was tapped. |
|
3484 // --------------------------------------------------------------------------- |
|
3485 // |
|
3486 void CEikCba::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
3487 { |
|
3488 if ( !AknLayoutUtils::PenEnabled() ) |
|
3489 { |
|
3490 return; |
|
3491 } |
|
3492 else if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
3493 { |
|
3494 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
3495 return; |
|
3496 } |
|
3497 |
|
3498 // If a child control is grabbing the pointer, we store the object pointer |
|
3499 // before calling base class implementation. This is because the up event |
|
3500 // releases the pointer grab. |
|
3501 CCoeControl* grabber = GrabbingComponent(); |
|
3502 |
|
3503 // Default base class functionality passes event to child controls. |
|
3504 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
3505 |
|
3506 // If pointer up event occurred in child control which was grabbing |
|
3507 // the pointer, it means that the CBA button was clicked. |
|
3508 |
|
3509 CEikCbaButton* button1 = |
|
3510 static_cast<CEikCbaButton*>( |
|
3511 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
3512 CEikCbaButton* button2 = |
|
3513 static_cast<CEikCbaButton*>( |
|
3514 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
3515 CEikCbaButton* buttonMSK = NULL; |
|
3516 |
|
3517 if ( iMSKset && AknLayoutUtils::MSKEnabled() ) |
|
3518 { |
|
3519 buttonMSK = |
|
3520 static_cast<CEikCbaButton*>( |
|
3521 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ); |
|
3522 } |
|
3523 |
|
3524 TRect button1Rect; |
|
3525 TRect button2Rect; |
|
3526 TRect buttonMSKRect; |
|
3527 |
|
3528 if ( AknLayoutFlags() & EAknLayoutCbaInRightPane ) |
|
3529 { |
|
3530 button1Rect = ButtonRectByPosition( KControlArrayCBAButton1Posn, ETrue ); |
|
3531 button2Rect = ButtonRectByPosition( KControlArrayCBAButton2Posn, ETrue ); |
|
3532 } |
|
3533 else if ( AknLayoutFlags() & EAknLayoutCbaInControlPane ) |
|
3534 { |
|
3535 button1Rect = ButtonRectByPosition( KControlArrayCBAButton1Posn, EFalse ); |
|
3536 button2Rect = ButtonRectByPosition( KControlArrayCBAButton2Posn, EFalse ); |
|
3537 buttonMSKRect = ButtonRectByPosition( KControlArrayCBAButtonMSKPosn, EFalse ); |
|
3538 } |
|
3539 else |
|
3540 { |
|
3541 button1Rect = button1->Rect(); |
|
3542 button2Rect = button2->Rect(); |
|
3543 buttonMSKRect = TRect( 0,0,0,0 ); |
|
3544 } |
|
3545 |
|
3546 // This flag is used to determine whether a pointer hit has |
|
3547 // happened in the grabbing control. It is needed to prevent |
|
3548 // the event from passing from one softkey to another. |
|
3549 TBool noHits = EFalse; |
|
3550 |
|
3551 TBool buttonMSKDown = EFalse; |
|
3552 TBool button1Down = button1->PressedDown(); |
|
3553 TBool button2Down = button2->PressedDown(); |
|
3554 if ( buttonMSK ) |
|
3555 { |
|
3556 buttonMSKDown = buttonMSK->PressedDown(); |
|
3557 } |
|
3558 |
|
3559 TBool button1Empty = EFalse; |
|
3560 if ( !button1->IsImageOn() && button1->IsEmptyText() ) |
|
3561 { |
|
3562 button1Empty = ETrue; |
|
3563 } |
|
3564 |
|
3565 TBool button2Empty = EFalse; |
|
3566 if ( !button2->IsImageOn() && button2->IsEmptyText() ) |
|
3567 { |
|
3568 button2Empty = ETrue; |
|
3569 } |
|
3570 |
|
3571 TBool buttonMSKEmpty = EFalse; |
|
3572 if ( buttonMSK && !buttonMSK->IsImageOn() && buttonMSK->IsEmptyText() ) |
|
3573 { |
|
3574 buttonMSKEmpty = ETrue; |
|
3575 } |
|
3576 |
|
3577 // If hits the left softkey. |
|
3578 if ( button1Rect.Contains( aPointerEvent.iPosition ) && !button1Empty ) |
|
3579 { |
|
3580 if ( button1->IsVisible() ) |
|
3581 { |
|
3582 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
3583 { |
|
3584 button1->SetPressedDown( ETrue ); |
|
3585 |
|
3586 // Store the pointer of the button control to be |
|
3587 // used as the grabbing control, this is required |
|
3588 // in case the pointer events happens in the extended |
|
3589 // touch area where the button control doesn't receive |
|
3590 // the grab otherwise. |
|
3591 iExtension->iPointerGrabbingButton = button1; |
|
3592 } |
|
3593 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && |
|
3594 button1->PressedDown() ) |
|
3595 { |
|
3596 // Accept the up event only if the down event has happened |
|
3597 // in the same button. |
|
3598 button1->SetPressedDown( EFalse ); |
|
3599 grabber = iExtension->iPointerGrabbingButton; |
|
3600 |
|
3601 // Clear the grabber pointer at up event. |
|
3602 iExtension->iPointerGrabbingButton = NULL; |
|
3603 } |
|
3604 else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
3605 { |
|
3606 if ( iExtension->iPointerGrabbingButton == button1 ) |
|
3607 { |
|
3608 // Accept the drag event only if the down event has happened |
|
3609 // in the same button. |
|
3610 button1->SetPressedDown( ETrue ); |
|
3611 button2->SetPressedDown( EFalse); |
|
3612 if ( buttonMSK ) |
|
3613 { |
|
3614 buttonMSK->SetPressedDown( EFalse ); |
|
3615 } |
|
3616 } |
|
3617 else |
|
3618 { |
|
3619 // Don't transfer the event to this button. |
|
3620 noHits = ETrue; |
|
3621 } |
|
3622 } |
|
3623 else |
|
3624 { |
|
3625 // The event happened outside the button areas |
|
3626 // or up event happened inside a button which |
|
3627 // didn't get the down event. |
|
3628 noHits = ETrue; |
|
3629 } |
|
3630 } |
|
3631 else |
|
3632 { |
|
3633 // Button is inactive |
|
3634 noHits = ETrue; |
|
3635 } |
|
3636 } |
|
3637 else if ( button2Rect.Contains( aPointerEvent.iPosition ) && !button2Empty ) |
|
3638 { |
|
3639 if ( button2->IsVisible() ) |
|
3640 { |
|
3641 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
3642 { |
|
3643 button2->SetPressedDown( ETrue ); |
|
3644 |
|
3645 // Store the pointer of the button control to be |
|
3646 // used as the grabbing control, this is required |
|
3647 // in case the pointer events happens in the extended |
|
3648 // touch area where the button control doesn't receive |
|
3649 // the grab otherwise. |
|
3650 iExtension->iPointerGrabbingButton = button2; |
|
3651 } |
|
3652 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && |
|
3653 button2->PressedDown() ) |
|
3654 { |
|
3655 // Accept the up event only if the down event has happened |
|
3656 // in the same button. |
|
3657 button2->SetPressedDown( EFalse ); |
|
3658 grabber = iExtension->iPointerGrabbingButton; |
|
3659 |
|
3660 // Clear the grabber pointer at up event. |
|
3661 iExtension->iPointerGrabbingButton = NULL; |
|
3662 } |
|
3663 else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
3664 { |
|
3665 if ( iExtension->iPointerGrabbingButton == button2 ) |
|
3666 { |
|
3667 // Accept the drag event only if the down event has happened |
|
3668 // in the same button. |
|
3669 button2->SetPressedDown( ETrue ); |
|
3670 button1->SetPressedDown( EFalse); |
|
3671 if ( buttonMSK ) |
|
3672 { |
|
3673 buttonMSK->SetPressedDown( EFalse ); |
|
3674 } |
|
3675 } |
|
3676 else |
|
3677 { |
|
3678 // Don't transfer the event to this button. |
|
3679 noHits = ETrue; |
|
3680 } |
|
3681 } |
|
3682 else |
|
3683 { |
|
3684 // The event happened outside the button areas |
|
3685 // or up event happened inside a button which |
|
3686 // didn't get the down event. |
|
3687 noHits = ETrue; |
|
3688 } |
|
3689 } |
|
3690 else |
|
3691 { |
|
3692 // Button is inactive |
|
3693 noHits = ETrue; |
|
3694 } |
|
3695 } |
|
3696 else if ( buttonMSK && |
|
3697 !buttonMSKEmpty && |
|
3698 buttonMSKRect.Contains( aPointerEvent.iPosition ) ) |
|
3699 { |
|
3700 if ( buttonMSK->IsVisible() ) |
|
3701 { |
|
3702 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
3703 { |
|
3704 buttonMSK->SetPressedDown( ETrue ); |
|
3705 |
|
3706 // Store the pointer of the button control to be |
|
3707 // used as the grabbing control, this is required |
|
3708 // in case the pointer events happens in the extended |
|
3709 // touch area where the button control doesn't receive |
|
3710 // the grab otherwise. |
|
3711 iExtension->iPointerGrabbingButton = buttonMSK; |
|
3712 } |
|
3713 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && |
|
3714 buttonMSK->PressedDown() ) |
|
3715 { |
|
3716 // Accept the up event only if the down event has happened |
|
3717 // in the same button. |
|
3718 buttonMSK->SetPressedDown( EFalse ); |
|
3719 grabber = iExtension->iPointerGrabbingButton; |
|
3720 |
|
3721 // Clear the grabber pointer at up event. |
|
3722 iExtension->iPointerGrabbingButton = NULL; |
|
3723 } |
|
3724 else if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
3725 { |
|
3726 if ( iExtension->iPointerGrabbingButton == buttonMSK ) |
|
3727 { |
|
3728 // Accept the drag event only if the down event has happened |
|
3729 // in the same button. |
|
3730 buttonMSK->SetPressedDown( ETrue ); |
|
3731 button2->SetPressedDown( EFalse ); |
|
3732 button1->SetPressedDown( EFalse ); |
|
3733 } |
|
3734 else |
|
3735 { |
|
3736 // Don't transfer the event to this button. |
|
3737 noHits = ETrue; |
|
3738 } |
|
3739 } |
|
3740 else |
|
3741 { |
|
3742 // The event happened outside the button areas |
|
3743 // or up event happened inside a button which |
|
3744 // didn't get the down event. |
|
3745 noHits = ETrue; |
|
3746 } |
|
3747 } |
|
3748 else |
|
3749 { |
|
3750 // Button is inactive |
|
3751 noHits = ETrue; |
|
3752 } |
|
3753 } |
|
3754 else |
|
3755 { |
|
3756 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
3757 { |
|
3758 // Clear the grabber pointer at up event. |
|
3759 iExtension->iPointerGrabbingButton = NULL; |
|
3760 } |
|
3761 |
|
3762 noHits = ETrue; |
|
3763 } |
|
3764 |
|
3765 if ( noHits ) |
|
3766 { |
|
3767 button1->SetPressedDown( EFalse ); |
|
3768 button2->SetPressedDown( EFalse ); |
|
3769 if ( buttonMSK ) |
|
3770 { |
|
3771 buttonMSK->SetPressedDown( EFalse ); |
|
3772 } |
|
3773 } |
|
3774 else if ( aPointerEvent.iType != TPointerEvent::EDrag ) |
|
3775 { |
|
3776 // CBA button has been hit with a down or up event, play feedback |
|
3777 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
3778 if ( feedback ) |
|
3779 { |
|
3780 TTouchFeedbackType fbType = TTouchFeedbackType( ETouchFeedbackAudio | |
|
3781 ETouchFeedbackVibra ); |
|
3782 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
3783 { |
|
3784 fbType = ETouchFeedbackVibra; |
|
3785 } |
|
3786 feedback->InstantFeedback( this, |
|
3787 ETouchFeedbackBasicButton, |
|
3788 fbType, |
|
3789 aPointerEvent ); |
|
3790 } |
|
3791 } |
|
3792 |
|
3793 if (button1Down != button1->PressedDown() || |
|
3794 button2Down != button2->PressedDown() || |
|
3795 (buttonMSK && (buttonMSKDown != buttonMSK->PressedDown()))) |
|
3796 { |
|
3797 |
|
3798 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
3799 { |
|
3800 UpdateLabels( EFalse ); |
|
3801 |
|
3802 // Redraw only changed buttons. It's assumed that there's no |
|
3803 // visible MSK if softkeys are embedded. |
|
3804 TRect invalidRect( button1Rect ); |
|
3805 |
|
3806 if ( button2Down != button2->PressedDown() ) |
|
3807 { |
|
3808 invalidRect = button2Rect; |
|
3809 } |
|
3810 |
|
3811 // TODO: whole control is redrawn as a workaround for NGA bug that |
|
3812 // causes incorrect drawing of softkey labels when the second |
|
3813 // button is pressed down after the first one has already been |
|
3814 // pressed. Actually we should just redraw the invalidRect |
|
3815 // calculated above. |
|
3816 DrawNow(); |
|
3817 } |
|
3818 else |
|
3819 { |
|
3820 SizeChanged(); |
|
3821 DrawNow(); |
|
3822 } |
|
3823 } |
|
3824 |
|
3825 if ( !grabber && !noHits ) |
|
3826 { |
|
3827 // Set the correct button to claim the pointer grab if the |
|
3828 // event happened in an extended touch area of the button |
|
3829 // (the button control didn't receive the event). |
|
3830 grabber = iExtension->iPointerGrabbingButton; |
|
3831 } |
|
3832 |
|
3833 if ( aPointerEvent.iType == TPointerEvent::EButton1Up && grabber && !noHits ) |
|
3834 { |
|
3835 // This check also includes the extended touch space for a button. |
|
3836 if ( ( button1Rect.Contains( aPointerEvent.iPosition ) && |
|
3837 button1Rect.Intersects( grabber->Rect() ) ) || |
|
3838 ( button2Rect.Contains( aPointerEvent.iPosition ) && |
|
3839 button2Rect.Intersects( grabber->Rect() ) ) || |
|
3840 ( buttonMSKRect.Contains( aPointerEvent.iPosition ) && |
|
3841 buttonMSKRect.Intersects( grabber->Rect() ) ) ) |
|
3842 { |
|
3843 TInt buttoncount = iControlArray->Count(); |
|
3844 for ( TInt i = 0; i < buttoncount; i++ ) |
|
3845 { |
|
3846 if ( (*iControlArray)[i].iControl == grabber ) |
|
3847 { |
|
3848 if ( !IsVisible() ) |
|
3849 return; |
|
3850 |
|
3851 // Send the button command to command observer. |
|
3852 TInt shortCommand = (*iControlArray)[i].iId; |
|
3853 if ( shortCommand && |
|
3854 i == KControlArrayCBAButtonMSKPosn && |
|
3855 iMSKCommandObserver ) |
|
3856 { |
|
3857 iMSKCommandObserver->ProcessCommandL( shortCommand ); |
|
3858 } |
|
3859 |
|
3860 if( shortCommand ) |
|
3861 { |
|
3862 iCommandObserver->ProcessCommandL( shortCommand ); |
|
3863 } |
|
3864 |
|
3865 break; |
|
3866 } |
|
3867 } |
|
3868 } |
|
3869 } |
|
3870 } |
|
3871 |
|
3872 |
|
3873 TSize CEikCba::MinimumSize() |
|
3874 { |
|
3875 TSize size = CEikControlGroup::MinimumSize(); |
|
3876 size.iWidth = iAvkonAppUi->ApplicationRect().Width(); |
|
3877 const TInt count = iControlArray->Count(); |
|
3878 for (TInt ii = 0; ii < count; ii++) |
|
3879 { |
|
3880 size.iHeight = Max(size.iHeight, (*iControlArray)[ii].iControl->MinimumSize().iHeight); |
|
3881 } |
|
3882 if (iLink) |
|
3883 { |
|
3884 size.iHeight = Max(size.iHeight, iLink->Size().iHeight); |
|
3885 } |
|
3886 // Add a standard margin from the laf. |
|
3887 return size; |
|
3888 } |
|
3889 |
|
3890 /** |
|
3891 * Gets the list of logical colors employed in the drawing of the control, |
|
3892 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
3893 * |
|
3894 * @since ER5U |
|
3895 */ |
|
3896 void CEikCba::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
3897 { |
|
3898 CEikControlGroup::GetColorUseListL(aColorUseList); |
|
3899 |
|
3900 TInt commonAttributes = TCoeColorUse::ESurrounds|TCoeColorUse::EActive|TCoeColorUse::ENormal| |
|
3901 TCoeColorUse::ENeutral; |
|
3902 |
|
3903 TCoeColorUse colorUse; |
|
3904 |
|
3905 colorUse.SetLogicalColor(EColorToolbarText); |
|
3906 colorUse.SetUse(TCoeColorUse::EFore|commonAttributes); |
|
3907 aColorUseList.AppendL(colorUse); |
|
3908 |
|
3909 colorUse.SetLogicalColor(EColorToolbarBackground); |
|
3910 colorUse.SetUse(TCoeColorUse::EBack|commonAttributes); |
|
3911 aColorUseList.AppendL(colorUse); |
|
3912 } |
|
3913 |
|
3914 |
|
3915 // --------------------------------------------------------------------------- |
|
3916 // Handles a change to the control's resources of type aType |
|
3917 // which are shared across the environment, e.g. colors or fonts. |
|
3918 // --------------------------------------------------------------------------- |
|
3919 // |
|
3920 void CEikCba::HandleResourceChange( TInt aType ) |
|
3921 { |
|
3922 CEikControlGroup::HandleResourceChange( aType ); |
|
3923 |
|
3924 switch ( aType ) |
|
3925 { |
|
3926 case KAknsMessageSkinChange: |
|
3927 { |
|
3928 if ( IsVisible() ) |
|
3929 { |
|
3930 DoSkinChange(); |
|
3931 if( iExtension->iIfMskIconSet ) |
|
3932 { |
|
3933 TRAP_IGNORE( UpdateIconL() ); |
|
3934 } |
|
3935 } |
|
3936 else |
|
3937 { |
|
3938 iFlags.Set( ECbaChangeRecordedSkin ); |
|
3939 } |
|
3940 break; |
|
3941 } |
|
3942 |
|
3943 case KEikColorResourceChange: |
|
3944 { |
|
3945 if ( IsVisible() ) |
|
3946 { |
|
3947 DoColorChange(); |
|
3948 } |
|
3949 else |
|
3950 { |
|
3951 iFlags.Set( ECbaChangeRecordedColor ); |
|
3952 } |
|
3953 break; |
|
3954 } |
|
3955 |
|
3956 case KEikDynamicLayoutVariantSwitch: |
|
3957 { |
|
3958 if ( IsVisible() ) |
|
3959 { |
|
3960 DoLayoutChange(); |
|
3961 SetBoundingRect( TRect() ); |
|
3962 if ( iFlags.IsSet( ECbaInsideDialog ) |
|
3963 || iFlags.IsSet( ECbaEmbedded ) ) |
|
3964 { |
|
3965 DrawDeferred(); |
|
3966 } |
|
3967 else |
|
3968 { |
|
3969 DrawNow(); |
|
3970 } |
|
3971 } |
|
3972 else |
|
3973 { |
|
3974 iFlags.Set( ECbaChangeRecordedLayout ); |
|
3975 } |
|
3976 break; |
|
3977 } |
|
3978 |
|
3979 case KAknMessageFocusLost: |
|
3980 { |
|
3981 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
3982 { |
|
3983 return; |
|
3984 } |
|
3985 |
|
3986 |
|
3987 CEikCbaButton* button1 = |
|
3988 static_cast<CEikCbaButton*>( |
|
3989 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
3990 CEikCbaButton* button2 = |
|
3991 static_cast<CEikCbaButton*>( |
|
3992 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
3993 CEikCbaButton* buttonMSK = NULL; |
|
3994 |
|
3995 if ( iMSKset && AknLayoutUtils::MSKEnabled() ) |
|
3996 { |
|
3997 buttonMSK = |
|
3998 static_cast<CEikCbaButton*>( |
|
3999 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ); |
|
4000 } |
|
4001 |
|
4002 TBool redrawNeeded( EFalse ); |
|
4003 |
|
4004 if ( button1 && button1->PressedDown() ) |
|
4005 { |
|
4006 button1->SetPressedDown( EFalse ); |
|
4007 redrawNeeded = ETrue; |
|
4008 } |
|
4009 if ( button2 && button2->PressedDown() ) |
|
4010 { |
|
4011 button2->SetPressedDown( EFalse ); |
|
4012 redrawNeeded = ETrue; |
|
4013 } |
|
4014 if ( buttonMSK && buttonMSK->PressedDown() ) |
|
4015 { |
|
4016 buttonMSK->SetPressedDown( EFalse ); |
|
4017 redrawNeeded = ETrue; |
|
4018 } |
|
4019 |
|
4020 if ( buttonMSK && iExtension ) |
|
4021 { |
|
4022 SetBoundingRect( TRect( 0, 0, 0, 0 ) ); |
|
4023 redrawNeeded = ETrue; |
|
4024 } |
|
4025 if ( redrawNeeded ) |
|
4026 { |
|
4027 SizeChanged(); |
|
4028 DrawDeferred(); |
|
4029 } |
|
4030 |
|
4031 if ( iFlags.IsSet( ECbaItemSpecificSoftkeyInUse ) ) |
|
4032 { |
|
4033 UpdateItemSpecificSoftkey( EFalse ); |
|
4034 } |
|
4035 break; |
|
4036 } |
|
4037 |
|
4038 case KEikMessageUnfadeWindows: |
|
4039 { |
|
4040 DoLayoutChange(); |
|
4041 SetFadeState(); |
|
4042 |
|
4043 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
4044 { |
|
4045 DrawDeferred(); |
|
4046 } |
|
4047 else |
|
4048 { |
|
4049 //When touch unsupported,it's unnecessary to call DrawNow() |
|
4050 if ( AknLayoutUtils::PenEnabled() ) |
|
4051 { |
|
4052 DrawNow(); |
|
4053 } |
|
4054 else |
|
4055 { |
|
4056 DrawDeferred(); |
|
4057 } |
|
4058 } |
|
4059 |
|
4060 break; |
|
4061 } |
|
4062 |
|
4063 case KEikMessageFadeAllWindows: |
|
4064 { |
|
4065 if ( AknLayoutUtils::PenEnabled() && |
|
4066 AknStatuspaneUtils::IdleLayoutActive() ) |
|
4067 { |
|
4068 SetMSKVisibility( MskAllowed() ); |
|
4069 } |
|
4070 SetFadeState(); |
|
4071 break; |
|
4072 } |
|
4073 |
|
4074 default: |
|
4075 { |
|
4076 break; |
|
4077 } |
|
4078 } |
|
4079 } |
|
4080 |
|
4081 |
|
4082 void CEikCba::DoSkinChange() |
|
4083 { |
|
4084 iExtension->iIfSkinChanged = ETrue; |
|
4085 DoSetLayers( KAknsIIDNone ); |
|
4086 iExtension->iIfSkinChanged = EFalse; |
|
4087 if ( iExtension ) |
|
4088 { |
|
4089 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( ETrue ) ); |
|
4090 } |
|
4091 |
|
4092 // This is required for skin resource changes (as well as color resource change). |
|
4093 CheckSkinAndUpdateContext(); |
|
4094 TRAP_IGNORE( SetMSKIconL() ); |
|
4095 SizeChanged(); |
|
4096 |
|
4097 //Skin change uses DrawNow to flus draw cache before layoutchange. |
|
4098 DrawNow(); |
|
4099 iFlags.Clear(ECbaChangeRecordedSkin); |
|
4100 } |
|
4101 |
|
4102 void CEikCba::DoColorChange() |
|
4103 { |
|
4104 iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground, *this)); |
|
4105 iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText, *this)); |
|
4106 Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorToolbarBackground, *this)); |
|
4107 // This is required for skin resource changes (as well as color resource change). |
|
4108 CheckSkinAndUpdateContext(); |
|
4109 TRAP_IGNORE( SetMSKIconL() ); |
|
4110 SizeChanged(); |
|
4111 iFlags.Clear(ECbaChangeRecordedColor); |
|
4112 } |
|
4113 |
|
4114 |
|
4115 void CEikCba::DoLayoutChange() |
|
4116 { |
|
4117 SetBoundingRect( TRect() ); |
|
4118 |
|
4119 UpdateFonts(); |
|
4120 |
|
4121 TBool mskAllowed( MskAllowed() ); |
|
4122 if ( !mskAllowed ) |
|
4123 { |
|
4124 SetMSKVisibility( EFalse ); |
|
4125 } |
|
4126 else |
|
4127 { |
|
4128 SetMSKVisibility( ETrue ); |
|
4129 TRAP_IGNORE( SetMSKIconL() ); |
|
4130 } |
|
4131 |
|
4132 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
4133 { |
|
4134 CEikCbaButton* button1 = |
|
4135 static_cast<CEikCbaButton*>( |
|
4136 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
4137 CEikCbaButton* button2 = |
|
4138 static_cast<CEikCbaButton*>( |
|
4139 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
4140 |
|
4141 if ( button1 ) |
|
4142 { |
|
4143 button1->SetPressedDown( EFalse ); |
|
4144 } |
|
4145 |
|
4146 if ( button2 ) |
|
4147 { |
|
4148 button2->SetPressedDown( EFalse ); |
|
4149 } |
|
4150 } |
|
4151 |
|
4152 SizeChanged(); |
|
4153 |
|
4154 if ( iExtension ) |
|
4155 { |
|
4156 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
4157 } |
|
4158 |
|
4159 iFlags.Clear( ECbaChangeRecordedLayout ); |
|
4160 } |
|
4161 |
|
4162 |
|
4163 void CEikCba::HandleScrollEventL(CEikScrollBar* /*aScrollBar*/, TEikScrollEvent /*aEventType*/) |
|
4164 { |
|
4165 User::Leave(KErrNotSupported); |
|
4166 } |
|
4167 |
|
4168 TTypeUid::Ptr CEikCba::MopSupplyObject(TTypeUid aId) |
|
4169 { |
|
4170 if (aId.iUid == MAknsControlContext::ETypeId) |
|
4171 { |
|
4172 if ( AknLayoutFlags() & EAknLayoutCbaInControlPane || |
|
4173 AknLayoutFlags() & EAknLayoutCbaInRightPane ) |
|
4174 { |
|
4175 return MAknsControlContext::SupplyMopObject( aId, iMLBgContext ); |
|
4176 } |
|
4177 else |
|
4178 { |
|
4179 // Always provide top object to mop-chain. |
|
4180 // Bottom is parent of Top, so bottom is re-drawn |
|
4181 // automatically when top is drawn. |
|
4182 return MAknsControlContext::SupplyMopObject( aId, iStaconBgContextTop ); |
|
4183 } |
|
4184 } |
|
4185 |
|
4186 if ( aId.iUid == CEikCba::ETypeId ) |
|
4187 { |
|
4188 return aId.MakePtr( this ); |
|
4189 } |
|
4190 |
|
4191 return CEikControlGroup::MopSupplyObject(aId); |
|
4192 } |
|
4193 |
|
4194 |
|
4195 void CEikCba::Draw( const TRect& aRect ) const |
|
4196 { |
|
4197 // Embedded CBA doesn't draw anything |
|
4198 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
4199 { |
|
4200 return; |
|
4201 } |
|
4202 |
|
4203 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
4204 |
|
4205 const TRect rect( Rect() ); |
|
4206 CWindowGc& gc = SystemGc(); |
|
4207 |
|
4208 TRgb rgb( TRgb::Color16MA( 0 ) ); |
|
4209 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
4210 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
4211 gc.SetBrushColor( rgb ); |
|
4212 gc.Clear(); |
|
4213 |
|
4214 MAknsControlContext* cc = iMLBgContext; |
|
4215 |
|
4216 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
4217 { |
|
4218 // Embedded CBA is drawn inside dialog |
|
4219 if ( AknLayoutUtils::PenEnabled() && iExtension ) |
|
4220 { |
|
4221 if ( aRect.Intersects( iExtension->iLeftFrameOuterRect ) ) |
|
4222 { |
|
4223 DrawEmbeddedSoftkey( |
|
4224 iControlArray->At( KControlArrayCBAButton1Posn ), |
|
4225 iExtension->iLeftFrameOuterRect, |
|
4226 gc, |
|
4227 iExtension->iLeftFrameMask ); |
|
4228 } |
|
4229 |
|
4230 if ( aRect.Intersects( iExtension->iRightFrameOuterRect ) ) |
|
4231 { |
|
4232 DrawEmbeddedSoftkey( |
|
4233 iControlArray->At( KControlArrayCBAButton2Posn ), |
|
4234 iExtension->iRightFrameOuterRect, |
|
4235 gc, |
|
4236 iExtension->iRightFrameMask ); |
|
4237 } |
|
4238 } |
|
4239 } //ECbaEmbedded |
|
4240 else if ( AknLayoutFlags() & EAknLayoutCbaInControlPane ) |
|
4241 { |
|
4242 if ( AknLayoutUtils::PenEnabled() || ( iCbaFlags & EEikCbaFlagTransparent) |
|
4243 ||iExtension->iEnablePostingTransparency ) |
|
4244 { |
|
4245 TAknLayoutRect layoutRect; |
|
4246 TRect leftSKRect( iExtension->iLeftFrameOuterRect ); |
|
4247 TRect rightSKRect( iExtension->iRightFrameOuterRect ); |
|
4248 TRect middleSKRect( iExtension->iMiddleFrameOuterRect ); |
|
4249 |
|
4250 TSize leftSKSize( leftSKRect.Size() ); |
|
4251 TSize rightSKSize( rightSKRect.Size() ); |
|
4252 TSize middleSKSize( middleSKRect.Size() ); |
|
4253 |
|
4254 if ( iExtension && |
|
4255 iExtension->iLskPostingOverlayBitmap && |
|
4256 iExtension->iRskPostingOverlayBitmap ) |
|
4257 { |
|
4258 // This code may be executed if iExtension->iEnablePostingTransparency |
|
4259 // holds. Draw graphics with mask information alpha channel for |
|
4260 // transparency for posting overlay |
|
4261 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
4262 gc.BitBlt( rightSKRect.iTl, iExtension->iRskPostingOverlayBitmap, |
|
4263 TRect( rightSKSize ) ); |
|
4264 gc.BitBlt( leftSKRect.iTl, iExtension->iLskPostingOverlayBitmap, |
|
4265 TRect( leftSKSize ) ); |
|
4266 } |
|
4267 else if ( !( ( iCbaFlags & EEikCbaFlagTransparent) || ( iCbaFlags & EEikCbaFlagSemiTransparent)) ) |
|
4268 {// Old way to render |
|
4269 if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) ) |
|
4270 { |
|
4271 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
4272 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
4273 gc.SetBrushColor( AKN_LAF_COLOR( KStatusPaneBackgroundGraphicsColorUsual ) ); |
|
4274 gc.DrawRect( rect ); |
|
4275 } |
|
4276 if ( iExtension ) |
|
4277 { |
|
4278 |
|
4279 CEikCbaButton* button1 = static_cast<CEikCbaButton*>( |
|
4280 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
4281 CEikCbaButton* button2 = static_cast<CEikCbaButton*>( |
|
4282 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
4283 |
|
4284 if ( IsMskEnabledLayoutActive() ) |
|
4285 { |
|
4286 CEikCbaButton* buttonMSK = static_cast<CEikCbaButton*>( |
|
4287 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ); |
|
4288 |
|
4289 CFbsBitmap* middleMask = |
|
4290 AknsUtils::GetCachedBitmap( skin, KAknsIIDQgnIndiSctrlSkMaskMiddlePrt ); |
|
4291 AknIconUtils::SetSize( middleMask, middleSKSize, EAspectRatioNotPreserved ); |
|
4292 |
|
4293 if( buttonMSK && buttonMSK->PressedDown() ) |
|
4294 { |
|
4295 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4296 gc, |
|
4297 iExtension->iMiddleFrameOuterRect, |
|
4298 iExtension->iMiddleFrameInnerRect, |
|
4299 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4300 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4301 } |
|
4302 else |
|
4303 { |
|
4304 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4305 gc, |
|
4306 iExtension->iMiddleFrameOuterRect, |
|
4307 iExtension->iMiddleFrameInnerRect, |
|
4308 KAknsIIDQgnFrSctrlSkButton, |
|
4309 KAknsIIDQgnFrSctrlSkButtonCenter); |
|
4310 } |
|
4311 |
|
4312 } |
|
4313 |
|
4314 if( button1 && button1->PressedDown() ) |
|
4315 { |
|
4316 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4317 gc, |
|
4318 iExtension->iLeftFrameOuterRect, |
|
4319 iExtension->iLeftFrameInnerRect, |
|
4320 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4321 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4322 } |
|
4323 else |
|
4324 { |
|
4325 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4326 gc, |
|
4327 iExtension->iLeftFrameOuterRect, |
|
4328 iExtension->iLeftFrameInnerRect, |
|
4329 KAknsIIDQgnFrSctrlSkButton, |
|
4330 KAknsIIDQgnFrSctrlSkButtonCenter); |
|
4331 } |
|
4332 |
|
4333 if( button2 && button2->PressedDown() ) |
|
4334 { |
|
4335 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4336 gc, |
|
4337 iExtension->iRightFrameOuterRect, |
|
4338 iExtension->iRightFrameInnerRect, |
|
4339 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4340 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4341 } |
|
4342 else |
|
4343 { |
|
4344 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4345 gc, |
|
4346 iExtension->iRightFrameOuterRect, |
|
4347 iExtension->iRightFrameInnerRect, |
|
4348 KAknsIIDQgnFrSctrlSkButton, |
|
4349 KAknsIIDQgnFrSctrlSkButtonCenter); |
|
4350 } |
|
4351 |
|
4352 |
|
4353 } |
|
4354 } |
|
4355 } |
|
4356 else |
|
4357 { |
|
4358 if ( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) ) |
|
4359 { |
|
4360 CEikControlGroup::Draw( aRect ); |
|
4361 } |
|
4362 } |
|
4363 } |
|
4364 else if ( AknLayoutFlags() & EAknLayoutCbaInRightPane ) |
|
4365 { |
|
4366 TRect bottomSKRect; |
|
4367 TRect topSKRect; |
|
4368 if ( iExtension ) |
|
4369 { |
|
4370 bottomSKRect = iExtension->iLeftFrameOuterRect; |
|
4371 topSKRect = iExtension->iRightFrameOuterRect; |
|
4372 } |
|
4373 |
|
4374 if ( iExtension && |
|
4375 iExtension->iLskPostingOverlayBitmap && |
|
4376 iExtension->iRskPostingOverlayBitmap ) |
|
4377 { |
|
4378 // This code may be executed if iExtension->iEnablePostingTransparency |
|
4379 // holds. Draw graphics with mask information alpha channel for |
|
4380 // transparency for posting overlay |
|
4381 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
4382 gc.BitBlt( topSKRect.iTl, iExtension->iRskPostingOverlayBitmap, |
|
4383 TRect( topSKRect.Size() ) ); |
|
4384 gc.BitBlt( bottomSKRect.iTl, iExtension->iLskPostingOverlayBitmap, |
|
4385 TRect( bottomSKRect.Size() ) ); |
|
4386 } |
|
4387 else if ( !( ( iCbaFlags & EEikCbaFlagTransparent) || ( iCbaFlags & EEikCbaFlagSemiTransparent)) ) |
|
4388 { |
|
4389 // Old way to render |
|
4390 if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) ) |
|
4391 { |
|
4392 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
4393 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
4394 gc.SetBrushColor( AKN_LAF_COLOR( KStatusPaneBackgroundGraphicsColorUsual ) ); |
|
4395 gc.DrawRect( rect ); |
|
4396 } |
|
4397 |
|
4398 // Draw the softkey frames. |
|
4399 if ( iExtension ) |
|
4400 { |
|
4401 |
|
4402 CEikCbaButton* button1 = static_cast<CEikCbaButton*>( |
|
4403 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
4404 CEikCbaButton* button2 = static_cast<CEikCbaButton*>( |
|
4405 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
4406 |
|
4407 if ( button1 && button1->PressedDown() ) |
|
4408 { |
|
4409 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4410 gc, |
|
4411 iExtension->iLeftFrameOuterRect, |
|
4412 iExtension->iLeftFrameInnerRect, |
|
4413 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4414 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4415 } |
|
4416 else |
|
4417 { |
|
4418 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4419 gc, |
|
4420 iExtension->iLeftFrameOuterRect, |
|
4421 iExtension->iLeftFrameInnerRect, |
|
4422 KAknsIIDQgnFrSctrlSkButton, |
|
4423 KAknsIIDQgnFrSctrlSkButtonCenter ); |
|
4424 } |
|
4425 |
|
4426 if ( button2 && button2->PressedDown() ) |
|
4427 { |
|
4428 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4429 gc, |
|
4430 iExtension->iRightFrameOuterRect, |
|
4431 iExtension->iRightFrameInnerRect, |
|
4432 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4433 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4434 } |
|
4435 else |
|
4436 { |
|
4437 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4438 gc, |
|
4439 iExtension->iRightFrameOuterRect, |
|
4440 iExtension->iRightFrameInnerRect, |
|
4441 KAknsIIDQgnFrSctrlSkButton, |
|
4442 KAknsIIDQgnFrSctrlSkButtonCenter ); |
|
4443 } |
|
4444 } |
|
4445 } |
|
4446 else if ( ( iCbaFlags & EEikCbaFlagSemiTransparent) && iExtension ) |
|
4447 { |
|
4448 if ( iExtension->iSemiBgID != KAknsIIDNone ) |
|
4449 { |
|
4450 iExtension->DrawSemiTransparencyL( gc, rect ); |
|
4451 } |
|
4452 } |
|
4453 else |
|
4454 { |
|
4455 // No background since EEikCbaFlagTransparent is set. |
|
4456 // Do nothing. |
|
4457 } |
|
4458 } |
|
4459 else |
|
4460 { |
|
4461 // Combined statusp and control pane |
|
4462 |
|
4463 TRect screen( iAvkonAppUi->ApplicationRect() ); |
|
4464 |
|
4465 TInt variety = 0; |
|
4466 if ( AknLayoutFlags() & EAknLayoutCbaInStaconPaneLeft ) |
|
4467 { |
|
4468 variety = 1; |
|
4469 } |
|
4470 |
|
4471 TAknWindowComponentLayout layout0; |
|
4472 TAknWindowComponentLayout layout1; |
|
4473 TAknWindowComponentLayout layout2; |
|
4474 |
|
4475 // Read right (top in landscape) softkey layout. |
|
4476 layout0 = AknLayoutScalable_Avkon::area_top_pane( 2 ); |
|
4477 layout1 = AknLayoutScalable_Avkon::stacon_top_pane(); |
|
4478 |
|
4479 // If clock is shown in stacon, cba area is smaller. |
|
4480 TInt topCbaVariety = variety; |
|
4481 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
4482 { |
|
4483 topCbaVariety += 4; |
|
4484 } |
|
4485 |
|
4486 layout2 = AknLayoutScalable_Avkon::control_top_pane_stacon( topCbaVariety ); |
|
4487 |
|
4488 TAknWindowLineLayout rightSoftkeyLayout( |
|
4489 DoCompose( layout0,DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
4490 |
|
4491 TAknLayoutRect rightSoftkeyLayoutRect; |
|
4492 rightSoftkeyLayoutRect.LayoutRect( screen, rightSoftkeyLayout ); |
|
4493 |
|
4494 // Read left (bottom in landscape) softkey layout. |
|
4495 layout0 = AknLayoutScalable_Avkon::area_bottom_pane( 2 ); |
|
4496 layout1 = AknLayoutScalable_Avkon::stacon_bottom_pane(); |
|
4497 |
|
4498 // If clock is shown in stacon, cba area is smaller. |
|
4499 TInt bottomCbaVariety = variety; |
|
4500 if ( AknStatuspaneUtils::ExtendedStaconPaneActive() ) |
|
4501 { |
|
4502 bottomCbaVariety += 2; |
|
4503 } |
|
4504 |
|
4505 layout2 = |
|
4506 AknLayoutScalable_Avkon::control_bottom_pane_stacon( |
|
4507 bottomCbaVariety ); |
|
4508 |
|
4509 TAknWindowLineLayout leftSoftkeyLayout( |
|
4510 DoCompose( layout0, DoCompose( layout1, layout2 ) ).LayoutLine() ); |
|
4511 |
|
4512 TAknLayoutRect leftSoftkeyLayoutRect; |
|
4513 leftSoftkeyLayoutRect.LayoutRect( screen, leftSoftkeyLayout ); |
|
4514 |
|
4515 TRect staconBottom( leftSoftkeyLayoutRect.Rect() ); |
|
4516 |
|
4517 // First draw bottom area. |
|
4518 cc = iStaconBgContextBottom; |
|
4519 |
|
4520 if ( iExtension && iExtension->iLskPostingOverlayBitmap ) |
|
4521 { |
|
4522 // This code may be executed if iExtension->iEnablePostingTransparency |
|
4523 // holds. Draw graphics with mask information alpha channel for |
|
4524 // transparency for posting overlay |
|
4525 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
4526 |
|
4527 gc.BitBlt( staconBottom.iTl, iExtension->iLskPostingOverlayBitmap, |
|
4528 TRect( staconBottom.Size() ) ); |
|
4529 } |
|
4530 else if ( !( iCbaFlags & EEikCbaFlagTransparent) ) |
|
4531 { |
|
4532 if( !AknsDrawUtils::Background( skin, cc, this, gc, staconBottom ) ) |
|
4533 { |
|
4534 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
4535 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
4536 gc.SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundGraphicsColorUsual)); |
|
4537 gc.DrawRect(staconBottom); |
|
4538 } |
|
4539 if ( iExtension ) |
|
4540 { |
|
4541 CEikCbaButton* button1 = static_cast<CEikCbaButton*>( |
|
4542 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
4543 |
|
4544 if ( button1 && button1->PressedDown() ) |
|
4545 { |
|
4546 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4547 gc, |
|
4548 iExtension->iLeftFrameOuterRect, |
|
4549 iExtension->iLeftFrameInnerRect, |
|
4550 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4551 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4552 } |
|
4553 else |
|
4554 { |
|
4555 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4556 gc, |
|
4557 iExtension->iLeftFrameOuterRect, |
|
4558 iExtension->iLeftFrameInnerRect, |
|
4559 KAknsIIDQgnFrSctrlSkButton, |
|
4560 KAknsIIDQgnFrSctrlSkButtonCenter ); |
|
4561 } |
|
4562 } |
|
4563 } |
|
4564 // Then top area. |
|
4565 cc = iStaconBgContextTop; |
|
4566 |
|
4567 TRect staconTop( rightSoftkeyLayoutRect.Rect() ); |
|
4568 |
|
4569 if ( iExtension && iExtension->iRskPostingOverlayBitmap ) |
|
4570 { |
|
4571 // This code may be executed if iExtension->iEnablePostingTransparency |
|
4572 // holds. Draw graphics with mask information alpha channel for |
|
4573 // transparency for posting overlay |
|
4574 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
4575 |
|
4576 gc.BitBlt( staconTop.iTl, iExtension->iRskPostingOverlayBitmap, |
|
4577 TRect( staconTop.Size() ) ); |
|
4578 } |
|
4579 else if ( !( iCbaFlags & EEikCbaFlagTransparent) ) |
|
4580 { |
|
4581 if( !AknsDrawUtils::Background( skin, cc, this, gc, staconTop ) ) |
|
4582 { |
|
4583 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
4584 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
4585 gc.SetBrushColor(AKN_LAF_COLOR(KStatusPaneBackgroundGraphicsColorUsual)); |
|
4586 gc.DrawRect(staconTop); |
|
4587 } |
|
4588 if ( iExtension ) |
|
4589 { |
|
4590 |
|
4591 CEikCbaButton* button2 = static_cast<CEikCbaButton*>( |
|
4592 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
4593 |
|
4594 if ( button2 && button2->PressedDown() ) |
|
4595 { |
|
4596 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4597 gc, |
|
4598 iExtension->iRightFrameOuterRect, |
|
4599 iExtension->iRightFrameInnerRect, |
|
4600 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
4601 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
4602 } |
|
4603 else |
|
4604 { |
|
4605 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
4606 gc, |
|
4607 iExtension->iRightFrameOuterRect, |
|
4608 iExtension->iRightFrameInnerRect, |
|
4609 KAknsIIDQgnFrSctrlSkButton, |
|
4610 KAknsIIDQgnFrSctrlSkButtonCenter ); |
|
4611 } |
|
4612 } |
|
4613 } |
|
4614 } |
|
4615 gc.SetOpaque( EFalse ); |
|
4616 } |
|
4617 |
|
4618 |
|
4619 // --------------------------------------------------------------------------- |
|
4620 // Gets a button control by the specified command ID. |
|
4621 // --------------------------------------------------------------------------- |
|
4622 // |
|
4623 CCoeControl* CEikCba::ButtonById( TInt aCommandId ) const |
|
4624 { |
|
4625 return ControlById( aCommandId ); |
|
4626 } |
|
4627 |
|
4628 |
|
4629 // --------------------------------------------------------------------------- |
|
4630 // Creates the scroll bar frame & sets up the scroll bar. |
|
4631 // --------------------------------------------------------------------------- |
|
4632 // |
|
4633 void CEikCba::CreateScrollBarFrameL() |
|
4634 { |
|
4635 if ( !iSBFrame ) |
|
4636 { |
|
4637 iSBFrame = new (ELeave) CEikCbaScrollBarFrame( this, this, ETrue ); |
|
4638 } |
|
4639 iSBFrame->ConstructL(); |
|
4640 } |
|
4641 |
|
4642 |
|
4643 TEikGroupControl CEikCba::VScrollBarAsGroupControl() |
|
4644 { |
|
4645 // Extracts vertical scroll bar from the scroll bar frame. |
|
4646 TEikGroupControl groupCtrl(iSBFrame->VerticalScrollBar(), 0, |
|
4647 KCbaScrollBarButtonWidth,TEikGroupControl::ESetLength); |
|
4648 return groupCtrl; |
|
4649 } |
|
4650 |
|
4651 void CEikCba::InsertScrollBarL() |
|
4652 { |
|
4653 TEikGroupControl SBGroupCtrl = VScrollBarAsGroupControl(); |
|
4654 // Insert vertical scroll bar into cba control group. |
|
4655 InsertControlL(SBGroupCtrl, KControlArrayScrollBarPosn); |
|
4656 } |
|
4657 |
|
4658 |
|
4659 // --------------------------------------------------------------------------- |
|
4660 // Replaces empty scroll bar with actual arrow head scroll bar. |
|
4661 // --------------------------------------------------------------------------- |
|
4662 // |
|
4663 void CEikCba::CreateArrowHeadScrollBarL() |
|
4664 { |
|
4665 if ( iSBFrame ) |
|
4666 { |
|
4667 iSBFrame->SwitchToArrowHeadScrollBarL(); |
|
4668 iSBFrame->VerticalScrollBar()->SetContainingCba( this ); |
|
4669 if ( iControlArray->Count() > KControlArrayScrollBarPosn ) |
|
4670 { |
|
4671 iControlArray->Delete( KControlArrayScrollBarPosn ); |
|
4672 } |
|
4673 InsertScrollBarL(); |
|
4674 } |
|
4675 } |
|
4676 |
|
4677 |
|
4678 void CEikCba::SizeChanged() |
|
4679 { |
|
4680 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
4681 { |
|
4682 Window().SetNonFading( EFalse ); |
|
4683 SizeChangedInsideDialog(); |
|
4684 return; |
|
4685 } |
|
4686 else if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
4687 { |
|
4688 Window().SetNonFading( EFalse ); |
|
4689 SizeChangedInPopup(); |
|
4690 return; |
|
4691 } |
|
4692 |
|
4693 const TInt aknLayoutFlags = AknLayoutFlags(); |
|
4694 |
|
4695 if ( aknLayoutFlags & EAknLayoutCbaInControlPane ) |
|
4696 { |
|
4697 Window().SetNonFading( EFalse ); |
|
4698 SizeChangedInControlPane(); |
|
4699 } |
|
4700 else if ( aknLayoutFlags & EAknLayoutCbaInRightPane ) |
|
4701 { |
|
4702 Window().SetNonFading( EFalse ); |
|
4703 SizeChangedInRightPane(); |
|
4704 } |
|
4705 else |
|
4706 { |
|
4707 Window().SetNonFading(ETrue); |
|
4708 SizeChangedInStaconPane(); |
|
4709 } |
|
4710 // Set the feedback areas for the softkeys. |
|
4711 if ( iExtension && iExtension->iEnablePostingTransparency ) |
|
4712 { |
|
4713 TBool enabled = |
|
4714 // AknLayoutUtils::PenEnabled() && |
|
4715 // ( AknLayoutFlags() & EAknLayoutCbaInRightPane ) && |
|
4716 !Rect().IsEmpty(); |
|
4717 |
|
4718 if ( enabled ) |
|
4719 { |
|
4720 CEikCbaButton* button1 = |
|
4721 static_cast<CEikCbaButton*>( |
|
4722 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
4723 CEikCbaButton* button2 = |
|
4724 static_cast<CEikCbaButton*>( |
|
4725 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
4726 |
|
4727 TInt leftId = (*iControlArray)[KControlArrayCBAButton1Posn].iId; |
|
4728 |
|
4729 TRAPD( err, iExtension->UpdatePostingOverlayBitmapsL( |
|
4730 Rect(), |
|
4731 button1, |
|
4732 button2, |
|
4733 aknLayoutFlags ) ); |
|
4734 |
|
4735 if ( err ) |
|
4736 { |
|
4737 // Bitmaps may not be up-to-date. |
|
4738 enabled = EFalse; |
|
4739 } |
|
4740 } |
|
4741 |
|
4742 if ( !enabled ) |
|
4743 { |
|
4744 // Delete and disable posting overlay support. |
|
4745 delete iExtension->iLskPostingOverlayBitmap; |
|
4746 iExtension->iLskPostingOverlayBitmap = NULL; |
|
4747 delete iExtension->iRskPostingOverlayBitmap; |
|
4748 iExtension->iRskPostingOverlayBitmap = NULL; |
|
4749 } |
|
4750 |
|
4751 // Broadcast current state to CEikCbaButtons |
|
4752 BroadcastPostingTransparency( enabled ); |
|
4753 } |
|
4754 } |
|
4755 |
|
4756 // ----------------------------------------------------------------------------- |
|
4757 // CEikCba::CheckSkinAndUpdateContext |
|
4758 // |
|
4759 // ----------------------------------------------------------------------------- |
|
4760 // |
|
4761 void CEikCba::CheckSkinAndUpdateContext() |
|
4762 { |
|
4763 if (AknsUtils::SkinInstance()) |
|
4764 { |
|
4765 // Use ENullBrush if there is skin background available. |
|
4766 iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
4767 } |
|
4768 else |
|
4769 { |
|
4770 iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
4771 } |
|
4772 } |
|
4773 |
|
4774 void CEikCba::Reserved_MtsmPosition() |
|
4775 { |
|
4776 } |
|
4777 |
|
4778 void CEikCba::Reserved_MtsmObject() |
|
4779 { |
|
4780 } |
|
4781 |
|
4782 TInt CEikCba::AknLayoutFlags() const |
|
4783 { |
|
4784 TInt flags = 0; |
|
4785 |
|
4786 TBool controlPane = ETrue; |
|
4787 TBool staconPane = EFalse; |
|
4788 TBool staconPaneLeft = EFalse; |
|
4789 TBool staconPaneRight = EFalse; |
|
4790 TBool staconPaneIdle = EFalse; |
|
4791 TBool rightPane = EFalse; |
|
4792 |
|
4793 TInt currentStatusPaneLayoutResId = |
|
4794 AVKONENV->StatusPaneResIdForCurrentLayout( |
|
4795 AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ); |
|
4796 |
|
4797 staconPane = |
|
4798 ((currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT) || |
|
4799 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT) || |
|
4800 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT) || |
|
4801 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT) || |
|
4802 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT) || |
|
4803 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT)); |
|
4804 |
|
4805 staconPaneRight = |
|
4806 ((currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT) || |
|
4807 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT) || |
|
4808 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT)); |
|
4809 |
|
4810 staconPaneIdle = |
|
4811 ((currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT) || |
|
4812 (currentStatusPaneLayoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT)); |
|
4813 |
|
4814 staconPaneLeft = !staconPaneRight; |
|
4815 controlPane = !staconPane; |
|
4816 |
|
4817 if ( IsAreaSideRightPaneActive() ) |
|
4818 { |
|
4819 rightPane = ETrue; |
|
4820 controlPane = EFalse; |
|
4821 staconPane = EFalse; |
|
4822 staconPaneLeft = EFalse; |
|
4823 staconPaneRight = EFalse; |
|
4824 staconPaneIdle = EFalse; |
|
4825 } |
|
4826 |
|
4827 if (staconPane) |
|
4828 { |
|
4829 flags |= EAknLayoutCbaInStaconPane; |
|
4830 } |
|
4831 if (controlPane) |
|
4832 { |
|
4833 flags |= EAknLayoutCbaInControlPane; |
|
4834 } |
|
4835 if (staconPaneLeft) |
|
4836 { |
|
4837 flags |= EAknLayoutCbaInStaconPaneLeft; |
|
4838 } |
|
4839 if (staconPaneRight) |
|
4840 { |
|
4841 flags |= EAknLayoutCbaInStaconPaneRight; |
|
4842 } |
|
4843 if (staconPaneIdle) |
|
4844 { |
|
4845 flags |= EAknLayoutCbaInStaconPaneIdle; |
|
4846 } |
|
4847 if (rightPane) |
|
4848 { |
|
4849 flags |= EAknLayoutCbaInRightPane; |
|
4850 } |
|
4851 |
|
4852 return flags; |
|
4853 } |
|
4854 |
|
4855 |
|
4856 // --------------------------------------------------------------------------- |
|
4857 // Handles size change events in bottom softkey layout. |
|
4858 // --------------------------------------------------------------------------- |
|
4859 // |
|
4860 void CEikCba::SizeChangedInControlPane() |
|
4861 { |
|
4862 TRect screen; |
|
4863 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
4864 |
|
4865 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
4866 TBool flatLscLayout( isLandscape && |
|
4867 AknStatuspaneUtils::FlatLayoutActive() ); |
|
4868 |
|
4869 // We must check for landscape mode bottom softkeys. |
|
4870 TInt bottomPaneVariety = isLandscape ? ( flatLscLayout ? 2 : 6 ) : 1; |
|
4871 |
|
4872 TAknWindowComponentLayout controlPane( |
|
4873 DoCompose( |
|
4874 AknLayoutScalable_Avkon::application_window( 0 ), |
|
4875 DoCompose( |
|
4876 AknLayoutScalable_Avkon::area_bottom_pane( bottomPaneVariety ), |
|
4877 AknLayoutScalable_Avkon::control_pane() ) ) ); |
|
4878 |
|
4879 TAknLayoutRect cbarect; |
|
4880 cbarect.LayoutRect( screen, controlPane.LayoutLine() ); |
|
4881 TRect rect( cbarect.Rect().Size() ); |
|
4882 |
|
4883 TRect posInScreen( cbarect.Rect() ); |
|
4884 |
|
4885 TBool mskEnabledInPlatform( iMSKEnabledInPlatform && |
|
4886 IsMskEnabledLayoutActive() ); |
|
4887 |
|
4888 TBool mskEnabledInApplication( AknLayoutUtils::MSKEnabled() && iMSKset ); |
|
4889 |
|
4890 // Set the softkey frame rectangles in touch layouts. |
|
4891 if ( iExtension && AknLayoutUtils::PenEnabled() ) |
|
4892 { |
|
4893 TAknLayoutRect layoutRect; |
|
4894 TBool frameSizeChanged( EFalse ); |
|
4895 |
|
4896 if ( mskEnabledInPlatform || flatLscLayout ) |
|
4897 { |
|
4898 layoutRect.LayoutRect( |
|
4899 rect, |
|
4900 AknLayoutScalable_Avkon::control_pane_g6( 0 ).LayoutLine() ); |
|
4901 frameSizeChanged = layoutRect.Rect() != iExtension->iLeftFrameOuterRect; |
|
4902 iExtension->iLeftFrameOuterRect = layoutRect.Rect(); |
|
4903 |
|
4904 layoutRect.LayoutRect( iExtension->iLeftFrameOuterRect, |
|
4905 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4906 .LayoutLine() ); |
|
4907 iExtension->iLeftFrameInnerRect = layoutRect.Rect(); |
|
4908 layoutRect.LayoutRect( |
|
4909 rect, |
|
4910 AknLayoutScalable_Avkon::control_pane_g8( 0 ).LayoutLine() ); |
|
4911 frameSizeChanged = frameSizeChanged || layoutRect.Rect() != iExtension->iRightFrameOuterRect; |
|
4912 iExtension->iRightFrameOuterRect = layoutRect.Rect(); |
|
4913 layoutRect.LayoutRect( iExtension->iRightFrameOuterRect, |
|
4914 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4915 .LayoutLine() ); |
|
4916 iExtension->iRightFrameInnerRect = layoutRect.Rect(); |
|
4917 |
|
4918 if ( mskEnabledInPlatform ) |
|
4919 { |
|
4920 layoutRect.LayoutRect( |
|
4921 rect, |
|
4922 AknLayoutScalable_Avkon::control_pane_g7( 0 ).LayoutLine() ); |
|
4923 frameSizeChanged = frameSizeChanged || layoutRect.Rect() != iExtension->iMiddleFrameOuterRect; |
|
4924 iExtension->iMiddleFrameOuterRect = layoutRect.Rect(); |
|
4925 layoutRect.LayoutRect( iExtension->iMiddleFrameOuterRect, |
|
4926 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4927 .LayoutLine() ); |
|
4928 iExtension->iMiddleFrameInnerRect = layoutRect.Rect(); |
|
4929 } |
|
4930 else |
|
4931 { |
|
4932 iExtension->iMiddleFrameOuterRect.SetRect( 0, 0, 0, 0 ); |
|
4933 } |
|
4934 } |
|
4935 else |
|
4936 { |
|
4937 if ( AknLayoutUtils::LayoutMirrored() ) |
|
4938 { |
|
4939 layoutRect.LayoutRect( |
|
4940 rect, |
|
4941 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_cp1().LayoutLine() ); |
|
4942 frameSizeChanged = layoutRect.Rect() != iExtension->iRightFrameOuterRect; |
|
4943 iExtension->iRightFrameOuterRect = layoutRect.Rect(); |
|
4944 layoutRect.LayoutRect( iExtension->iRightFrameOuterRect, |
|
4945 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4946 .LayoutLine() ); |
|
4947 iExtension->iRightFrameInnerRect = layoutRect.Rect(); |
|
4948 |
|
4949 layoutRect.LayoutRect( |
|
4950 rect, |
|
4951 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_cp2().LayoutLine() ); |
|
4952 frameSizeChanged = frameSizeChanged || layoutRect.Rect() != iExtension->iLeftFrameOuterRect; |
|
4953 iExtension->iLeftFrameOuterRect = layoutRect.Rect(); |
|
4954 |
|
4955 layoutRect.LayoutRect( iExtension->iLeftFrameOuterRect, |
|
4956 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4957 .LayoutLine() ); |
|
4958 iExtension->iLeftFrameInnerRect = layoutRect.Rect(); |
|
4959 } |
|
4960 else |
|
4961 { |
|
4962 layoutRect.LayoutRect( |
|
4963 rect, |
|
4964 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_cp1().LayoutLine() ); |
|
4965 frameSizeChanged = layoutRect.Rect() != iExtension->iLeftFrameOuterRect; |
|
4966 iExtension->iLeftFrameOuterRect = layoutRect.Rect(); |
|
4967 |
|
4968 layoutRect.LayoutRect( iExtension->iLeftFrameOuterRect, |
|
4969 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4970 .LayoutLine() ); |
|
4971 iExtension->iLeftFrameInnerRect = layoutRect.Rect(); |
|
4972 |
|
4973 layoutRect.LayoutRect( |
|
4974 rect, |
|
4975 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_cp2().LayoutLine() ); |
|
4976 frameSizeChanged = frameSizeChanged || layoutRect.Rect() != iExtension->iRightFrameOuterRect; |
|
4977 iExtension->iRightFrameOuterRect = layoutRect.Rect(); |
|
4978 layoutRect.LayoutRect( iExtension->iRightFrameOuterRect, |
|
4979 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
4980 .LayoutLine() ); |
|
4981 iExtension->iRightFrameInnerRect = layoutRect.Rect(); |
|
4982 } |
|
4983 } |
|
4984 |
|
4985 if ( frameSizeChanged ) |
|
4986 { |
|
4987 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
4988 } |
|
4989 } |
|
4990 |
|
4991 DoSetLayers( KAknsIIDNone ); |
|
4992 |
|
4993 TInt textVariety; |
|
4994 TInt graphVariety; |
|
4995 |
|
4996 // Even if the application is not MSK enabled, |
|
4997 // use MSK layout when MSK is enabled in platform. |
|
4998 if ( isLandscape ) |
|
4999 { |
|
5000 if ( mskEnabledInPlatform ) |
|
5001 { |
|
5002 textVariety = 3; |
|
5003 graphVariety = 2; |
|
5004 } |
|
5005 else |
|
5006 { |
|
5007 TBool extendedLayout( AknStatuspaneUtils::ExtendedFlatLayoutActive() ); |
|
5008 textVariety = extendedLayout ? 3 : 2; |
|
5009 graphVariety = extendedLayout ? 3 : 2; |
|
5010 } |
|
5011 } |
|
5012 else if ( mskEnabledInPlatform ) |
|
5013 { |
|
5014 textVariety = 3; |
|
5015 graphVariety = 4; |
|
5016 } |
|
5017 else |
|
5018 { |
|
5019 textVariety = 0; |
|
5020 graphVariety = 4; |
|
5021 } |
|
5022 |
|
5023 if ( iExtension->iEnablePostingTransparency || |
|
5024 ( iCbaFlags & EEikCbaFlagTransparent ) || ( iCbaFlags & EEikCbaFlagSemiTransparent ) ) |
|
5025 { |
|
5026 textVariety = 6; // Outline font used |
|
5027 } |
|
5028 |
|
5029 // This uses correct coordinates to calculate the positions of softkey labels. |
|
5030 // Unfortunately we do not have access to the labels inside CEikCbaButtons, |
|
5031 // that's the reason for a hack with ComponentControl(). |
|
5032 // (This is the only place that knows of all softkeys ...) |
|
5033 if ( iControlArray->Count() != 0 ) |
|
5034 { |
|
5035 CCoeControl* leftSoftkey = (*iControlArray)[KControlArrayCBAButton1Posn].iControl; |
|
5036 CCoeControl* rightSoftkey = (*iControlArray)[KControlArrayCBAButton2Posn].iControl; |
|
5037 CCoeControl* MSKSoftkey = NULL; |
|
5038 |
|
5039 CEikCbaButton* leftSKButton = |
|
5040 static_cast<CEikCbaButton*>( leftSoftkey ); |
|
5041 CEikCbaButton* rightSKButton = |
|
5042 static_cast<CEikCbaButton*>( rightSoftkey ); |
|
5043 CEikCbaButton* MSKButton = NULL; |
|
5044 |
|
5045 TAknTextLineLayout controlPaneTextLayout; |
|
5046 |
|
5047 if ( !leftSKButton->IsImageOn() ) |
|
5048 { |
|
5049 controlPaneTextLayout = |
|
5050 AknLayoutScalable_Avkon::control_pane_t1( textVariety ).LayoutLine(); |
|
5051 |
|
5052 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
5053 { |
|
5054 // Sets outline font property. |
|
5055 controlPaneTextLayout.iFont |= KOutlineFontMask; |
|
5056 } |
|
5057 |
|
5058 CEikLabel* cbaLabel = |
|
5059 static_cast<CEikLabel*>( leftSoftkey->ComponentControl( 0 ) ); |
|
5060 AknLayoutUtils::LayoutLabel( cbaLabel, |
|
5061 Rect(), |
|
5062 controlPaneTextLayout ); |
|
5063 LayoutControl( leftSKButton, cbaLabel->Rect() ); |
|
5064 leftSKButton->TruncateLabelText(); |
|
5065 } |
|
5066 else |
|
5067 { |
|
5068 TAknLayoutRect qgn_graf_sk_left; |
|
5069 qgn_graf_sk_left.LayoutRect( |
|
5070 rect, |
|
5071 AknLayoutScalable_Avkon::control_pane_g1( graphVariety ).LayoutLine() ); |
|
5072 leftSoftkey->ComponentControl( 0 )->SetRect( qgn_graf_sk_left.Rect() ); |
|
5073 leftSoftkey->SetRect( qgn_graf_sk_left.Rect() ); |
|
5074 } |
|
5075 |
|
5076 if ( !rightSKButton->IsImageOn() ) |
|
5077 { |
|
5078 controlPaneTextLayout = |
|
5079 AknLayoutScalable_Avkon::control_pane_t2( textVariety ).LayoutLine(); |
|
5080 |
|
5081 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
5082 { |
|
5083 // Sets outline font property. |
|
5084 controlPaneTextLayout.iFont |= KOutlineFontMask; |
|
5085 } |
|
5086 |
|
5087 CEikLabel* cbaLabel = |
|
5088 static_cast<CEikLabel*>( rightSoftkey->ComponentControl( 0 ) ); |
|
5089 AknLayoutUtils::LayoutLabel( cbaLabel, |
|
5090 Rect(), |
|
5091 controlPaneTextLayout ); |
|
5092 LayoutControl( rightSKButton, cbaLabel->Rect() ); |
|
5093 rightSKButton->TruncateLabelText(); |
|
5094 } |
|
5095 else |
|
5096 { |
|
5097 TAknLayoutRect qgn_graf_sk_right; |
|
5098 qgn_graf_sk_right.LayoutRect( |
|
5099 rect, |
|
5100 AknLayoutScalable_Avkon::control_pane_g2( graphVariety ).LayoutLine() ); |
|
5101 rightSoftkey->ComponentControl( 0 )->SetRect( qgn_graf_sk_right.Rect() ); |
|
5102 rightSoftkey->SetRect( qgn_graf_sk_right.Rect() ); |
|
5103 } |
|
5104 |
|
5105 // Scrollbar will go over MSK!!! needs to be fixed. |
|
5106 if ( VScrollBarAsControl()->Model()->ScrollBarUseful() ) |
|
5107 { |
|
5108 CCoeControl* scroller = (*iControlArray)[KControlArrayScrollBarPosn].iControl; |
|
5109 AknLayoutUtils::LayoutControl( |
|
5110 scroller, |
|
5111 rect, |
|
5112 AKN_LAYOUT_WINDOW_Control_pane_elements_Line_1 ); |
|
5113 } |
|
5114 |
|
5115 TInt textMSKVariety = 3; |
|
5116 TInt graphicMSKVariety = 0; |
|
5117 |
|
5118 if ( mskEnabledInApplication && mskEnabledInPlatform ) |
|
5119 { |
|
5120 MSKSoftkey = (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl; |
|
5121 MSKButton = static_cast<CEikCbaButton*>( MSKSoftkey ); |
|
5122 |
|
5123 if ( !MSKButton->IsImageOn() ) |
|
5124 { |
|
5125 controlPaneTextLayout = |
|
5126 AknLayoutScalable_Avkon::control_pane_t3( |
|
5127 textMSKVariety ).LayoutLine(); |
|
5128 |
|
5129 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
5130 { |
|
5131 // Sets outline font property. |
|
5132 controlPaneTextLayout.iFont |= KOutlineFontMask; |
|
5133 } |
|
5134 |
|
5135 CEikLabel* cbaLabel = |
|
5136 static_cast<CEikLabel*>( MSKSoftkey->ComponentControl( 0 ) ); |
|
5137 AknLayoutUtils::LayoutLabel( cbaLabel, |
|
5138 Rect(), |
|
5139 controlPaneTextLayout ); |
|
5140 LayoutControl( MSKButton, cbaLabel->Rect() ); |
|
5141 MSKButton->TruncateLabelText(); |
|
5142 } |
|
5143 else |
|
5144 { |
|
5145 TAknLayoutRect qgn_graf_sk_msk; |
|
5146 qgn_graf_sk_msk.LayoutRect( |
|
5147 rect, |
|
5148 AknLayoutScalable_Avkon::control_pane_g4( |
|
5149 graphicMSKVariety ).LayoutLine() ); |
|
5150 TRect rect( qgn_graf_sk_msk.Rect() ); |
|
5151 |
|
5152 // aid_value_unit2 is 10ux10u rectangle |
|
5153 TAknWindowComponentLayout unit( AknLayoutScalable_Avkon::aid_value_unit2() ); |
|
5154 TInt delta = unit.LayoutLine().iW / 10 / 2; // half units |
|
5155 if ( MSKButton->PressedDown() ) |
|
5156 { |
|
5157 rect.Move( delta, delta ); |
|
5158 } |
|
5159 MSKSoftkey->ComponentControl( 0 )->SetRect( rect ); |
|
5160 MSKSoftkey->SetRect( rect ); |
|
5161 } |
|
5162 } |
|
5163 |
|
5164 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
5165 const TBool transparentSoftkeys = |
|
5166 iExtension->iEnablePostingTransparency || |
|
5167 ( iCbaFlags & EEikCbaFlagTransparent ) || |
|
5168 ( iCbaFlags & EEikCbaFlagSemiTransparent ); |
|
5169 TRgb leftColor; |
|
5170 TRgb rightColor; |
|
5171 TRgb MSKColor; |
|
5172 TInt errorl; |
|
5173 TInt errorr; |
|
5174 TInt errorMSK; |
|
5175 |
|
5176 TBool idleState = AknStatuspaneUtils::IdleLayoutActive(); |
|
5177 if ( idleState ) |
|
5178 { |
|
5179 errorl = AknsUtils::GetCachedColor( |
|
5180 skin, |
|
5181 leftColor, |
|
5182 KAknsIIDQsnTextColors, |
|
5183 EAknsCIQsnTextColorsCG15 ); |
|
5184 |
|
5185 errorr = AknsUtils::GetCachedColor( |
|
5186 skin, |
|
5187 rightColor, |
|
5188 KAknsIIDQsnTextColors, |
|
5189 EAknsCIQsnTextColorsCG16 ); |
|
5190 |
|
5191 errorMSK = AknsUtils::GetCachedColor( |
|
5192 skin, |
|
5193 MSKColor, |
|
5194 KAknsIIDQsnTextColors, |
|
5195 EAknsCIQsnTextColorsCG57 ); |
|
5196 } |
|
5197 else if ( iPopupVisible ) |
|
5198 { |
|
5199 errorl = AknsUtils::GetCachedColor( |
|
5200 skin, |
|
5201 leftColor, |
|
5202 KAknsIIDQsnTextColors, |
|
5203 EAknsCIQsnTextColorsCG17 ); |
|
5204 |
|
5205 errorr = AknsUtils::GetCachedColor( |
|
5206 skin, |
|
5207 rightColor, |
|
5208 KAknsIIDQsnTextColors, |
|
5209 EAknsCIQsnTextColorsCG18 ); |
|
5210 |
|
5211 errorMSK = AknsUtils::GetCachedColor( |
|
5212 skin, |
|
5213 MSKColor, |
|
5214 KAknsIIDQsnTextColors, |
|
5215 EAknsCIQsnTextColorsCG58 ); |
|
5216 } |
|
5217 else |
|
5218 { |
|
5219 errorl = AknsUtils::GetCachedColor( |
|
5220 skin, |
|
5221 leftColor, |
|
5222 KAknsIIDQsnTextColors, |
|
5223 EAknsCIQsnTextColorsCG13 ); |
|
5224 |
|
5225 errorr = AknsUtils::GetCachedColor( |
|
5226 skin, |
|
5227 rightColor, |
|
5228 KAknsIIDQsnTextColors, |
|
5229 EAknsCIQsnTextColorsCG14 ); |
|
5230 |
|
5231 errorMSK = AknsUtils::GetCachedColor( |
|
5232 skin, |
|
5233 MSKColor, |
|
5234 KAknsIIDQsnTextColors, |
|
5235 EAknsCIQsnTextColorsCG56 ); |
|
5236 } |
|
5237 |
|
5238 if ( transparentSoftkeys ) |
|
5239 { |
|
5240 rightColor = KRgbWhite; |
|
5241 leftColor = KRgbWhite; |
|
5242 } |
|
5243 if ( leftSKButton->PressedDown() ) |
|
5244 { |
|
5245 leftColor.SetAlpha( KPressedDownAlphaValue ); |
|
5246 |
|
5247 AknsUtils::GetCachedColor( |
|
5248 skin, |
|
5249 leftColor, |
|
5250 KAknsIIDQsnTextColors, |
|
5251 EAknsCIQsnTextColorsCG69 ); |
|
5252 |
|
5253 if ( transparentSoftkeys ) |
|
5254 { |
|
5255 // alpha has no effect with display posting. |
|
5256 leftColor = TRgb( 128, 128, 128 ); |
|
5257 } |
|
5258 } |
|
5259 else if ( rightSKButton->PressedDown() ) |
|
5260 { |
|
5261 rightColor.SetAlpha( KPressedDownAlphaValue ); |
|
5262 |
|
5263 AknsUtils::GetCachedColor( |
|
5264 skin, |
|
5265 rightColor, |
|
5266 KAknsIIDQsnTextColors, |
|
5267 EAknsCIQsnTextColorsCG69 ); |
|
5268 |
|
5269 if ( transparentSoftkeys ) |
|
5270 { |
|
5271 // alpha has no effect with display posting. |
|
5272 rightColor = TRgb( 128, 128, 128 ); |
|
5273 } |
|
5274 } |
|
5275 else if ( MSKButton && MSKButton->PressedDown() ) |
|
5276 { |
|
5277 MSKColor.SetAlpha( KPressedDownAlphaValue ); |
|
5278 |
|
5279 AknsUtils::GetCachedColor( |
|
5280 skin, |
|
5281 MSKColor, |
|
5282 KAknsIIDQsnTextColors, |
|
5283 EAknsCIQsnTextColorsCG69 ); |
|
5284 |
|
5285 } |
|
5286 |
|
5287 if( !errorl && !errorr ) |
|
5288 { |
|
5289 // Error ignored |
|
5290 TRAP( errorl, AknLayoutUtils::OverrideControlColorL( |
|
5291 *leftSoftkey, |
|
5292 EColorLabelText, |
|
5293 leftColor) ); |
|
5294 |
|
5295 TRAP( errorr, AknLayoutUtils::OverrideControlColorL( |
|
5296 *rightSoftkey, |
|
5297 EColorLabelText, |
|
5298 rightColor) ); |
|
5299 |
|
5300 if ( transparentSoftkeys ) |
|
5301 { |
|
5302 // Outline color is black. |
|
5303 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5304 *leftSoftkey, |
|
5305 EColorControlBackground, |
|
5306 KRgbBlack ) ); |
|
5307 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5308 *rightSoftkey, |
|
5309 EColorControlBackground, |
|
5310 KRgbBlack ) ); |
|
5311 } |
|
5312 } |
|
5313 |
|
5314 if ( mskEnabledInApplication && mskEnabledInPlatform && !errorMSK ) |
|
5315 { |
|
5316 // Error ignored. |
|
5317 TRAP( errorMSK, AknLayoutUtils::OverrideControlColorL( |
|
5318 *MSKSoftkey, |
|
5319 EColorLabelText, |
|
5320 MSKColor) ); |
|
5321 } |
|
5322 |
|
5323 // If MSK colors not set in skin, use left CBA color. |
|
5324 if ( mskEnabledInApplication && mskEnabledInPlatform && errorMSK && !errorl ) |
|
5325 { |
|
5326 // Error ignored. |
|
5327 TRAP( errorMSK, |
|
5328 { |
|
5329 AknLayoutUtils::OverrideControlColorL( |
|
5330 *MSKSoftkey, |
|
5331 EColorLabelText, |
|
5332 leftColor); |
|
5333 } ); |
|
5334 } |
|
5335 |
|
5336 DrawDeferred(); |
|
5337 } |
|
5338 |
|
5339 AknsUtils::RegisterControlPosition( this, posInScreen.iTl ); |
|
5340 } |
|
5341 |
|
5342 |
|
5343 void CEikCba::SizeChangedInStaconPane() |
|
5344 { |
|
5345 TRect screen( iAvkonAppUi->ApplicationRect() ); |
|
5346 TBool softKeysUpAndDownMirrored = EFalse; |
|
5347 |
|
5348 TInt variety = 0; |
|
5349 if (AknLayoutFlags() & EAknLayoutCbaInStaconPaneLeft) |
|
5350 { |
|
5351 variety = 1; |
|
5352 } |
|
5353 |
|
5354 TAknWindowComponentLayout layout0; |
|
5355 TAknWindowComponentLayout layout1; |
|
5356 TAknWindowComponentLayout layout2; |
|
5357 TAknWindowComponentLayout imageLayout; |
|
5358 TAknTextComponentLayout textLayout; |
|
5359 |
|
5360 // Read right (top in landscape) softkey layout. |
|
5361 layout0 = AknLayoutScalable_Avkon::area_top_pane(2); |
|
5362 layout1 = AknLayoutScalable_Avkon::stacon_top_pane(); |
|
5363 |
|
5364 // If clock is shown in stacon, cba area is smaller. |
|
5365 TInt topCbaVariety = variety; |
|
5366 if (AknStatuspaneUtils::ExtendedStaconPaneActive()) |
|
5367 { |
|
5368 topCbaVariety += 4; |
|
5369 } |
|
5370 |
|
5371 TInt textVariety = variety; |
|
5372 if ( iExtension->iEnablePostingTransparency || ( iCbaFlags & EEikCbaFlagTransparent ) ) |
|
5373 { |
|
5374 textVariety += 2; // Outline font used |
|
5375 } |
|
5376 |
|
5377 layout2 = AknLayoutScalable_Avkon::control_top_pane_stacon(topCbaVariety); |
|
5378 imageLayout = AknLayoutScalable_Avkon::control_top_pane_stacon_g1(); |
|
5379 textLayout = AknLayoutScalable_Avkon::control_top_pane_stacon_t1(textVariety); |
|
5380 |
|
5381 TAknTextComponentLayout rightSoftKeyTextLayout( |
|
5382 DoComposeText(layout0, DoComposeText(layout1, DoComposeText(layout2, textLayout))) ); |
|
5383 TAknWindowComponentLayout rightSoftKeyImageLayout( |
|
5384 DoCompose(layout0, DoCompose(layout1, DoCompose(layout2, imageLayout))) ); |
|
5385 |
|
5386 // Calculate softkey rects. |
|
5387 TAknWindowLineLayout rightSoftkeyLayout( |
|
5388 DoCompose( layout0, DoCompose(layout1, layout2)).LayoutLine() ); |
|
5389 TAknLayoutRect rightSoftkeyLayoutRect; |
|
5390 rightSoftkeyLayoutRect.LayoutRect(screen, rightSoftkeyLayout); |
|
5391 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
5392 |
|
5393 TAknTextLineLayout rightSoftkeyTextLayout( rightSoftKeyTextLayout.LayoutLine() ); |
|
5394 TAknWindowLineLayout rightSoftkeyImageLayout( rightSoftKeyImageLayout.LayoutLine() ); |
|
5395 |
|
5396 // Read left (bottom in landscape) softkey layout. |
|
5397 layout0 = AknLayoutScalable_Avkon::area_bottom_pane(2); |
|
5398 layout1 = AknLayoutScalable_Avkon::stacon_bottom_pane(); |
|
5399 |
|
5400 // If clock is shown in stacon, cba area is smaller. |
|
5401 TInt bottomCbaVariety = variety; |
|
5402 if (AknStatuspaneUtils::ExtendedStaconPaneActive()) |
|
5403 { |
|
5404 bottomCbaVariety += 2; |
|
5405 } |
|
5406 |
|
5407 layout2 = AknLayoutScalable_Avkon::control_bottom_pane_stacon(bottomCbaVariety); |
|
5408 imageLayout = AknLayoutScalable_Avkon::control_bottom_pane_stacon_g1(); |
|
5409 textLayout = AknLayoutScalable_Avkon::control_bottom_pane_stacon_t1(textVariety); |
|
5410 |
|
5411 TAknTextComponentLayout leftSoftKeyTextLayout( |
|
5412 DoComposeText(layout0, DoComposeText(layout1, DoComposeText(layout2, textLayout))) ); |
|
5413 TAknWindowComponentLayout leftSoftKeyImageLayout( |
|
5414 DoCompose(layout0, DoCompose(layout1, DoCompose(layout2, imageLayout))) ); |
|
5415 |
|
5416 // Calculate softkey rects |
|
5417 TAknWindowLineLayout leftSoftkeyLayout( |
|
5418 DoCompose( layout0, DoCompose(layout1, layout2) ).LayoutLine() ); |
|
5419 TAknLayoutRect leftSoftkeyLayoutRect; |
|
5420 leftSoftkeyLayoutRect.LayoutRect(screen, leftSoftkeyLayout); |
|
5421 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
5422 |
|
5423 TAknTextLineLayout leftSoftkeyTextLayout( leftSoftKeyTextLayout.LayoutLine() ); |
|
5424 TAknWindowLineLayout leftSoftkeyImageLayout( leftSoftKeyImageLayout.LayoutLine() ); |
|
5425 |
|
5426 // If softkeys are on the "other" side, then swap the texts and images here... |
|
5427 if (variety == 1) |
|
5428 { |
|
5429 CWsScreenDevice* dev = iEikonEnv->ScreenDevice(); |
|
5430 TPixelsAndRotation sizeAndRotation; |
|
5431 dev->GetScreenModeSizeAndRotation(dev->CurrentScreenMode(), sizeAndRotation); |
|
5432 |
|
5433 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
5434 |
|
5435 // If landscape orientation uses 270 degree rotation ( or 0 degree |
|
5436 // rotation in case of default portrait rotation uses 90 degree value), |
|
5437 // only then mirror L & R (actually upper and lower in stacon). |
|
5438 if ( isLandscape && |
|
5439 ( sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationRotated270 || |
|
5440 sizeAndRotation.iRotation == CFbsBitGc::EGraphicsOrientationNormal ) ) |
|
5441 { |
|
5442 softKeysUpAndDownMirrored = ETrue; |
|
5443 TAknTextLineLayout tmpTextLineLayout( leftSoftkeyTextLayout ); |
|
5444 TAknWindowLineLayout tmpWindowLineLayout( leftSoftkeyImageLayout ); |
|
5445 TRect tmpRect( leftSoftKeyButtonRect ); |
|
5446 |
|
5447 leftSoftKeyButtonRect = rightSoftKeyButtonRect; |
|
5448 leftSoftkeyTextLayout = rightSoftkeyTextLayout; |
|
5449 leftSoftkeyImageLayout = rightSoftkeyImageLayout; |
|
5450 |
|
5451 rightSoftKeyButtonRect = tmpRect; |
|
5452 rightSoftkeyTextLayout = tmpTextLineLayout; |
|
5453 rightSoftkeyImageLayout = tmpWindowLineLayout; |
|
5454 } |
|
5455 } |
|
5456 |
|
5457 // Set skin background. |
|
5458 TRect screenRect( iAvkonAppUi->ApplicationRect() ); |
|
5459 TAknWindowLineLayout layout( AknLayoutScalable_Avkon::area_top_pane(2).LayoutLine() ); |
|
5460 TAknLayoutRect layoutRect; |
|
5461 layoutRect.LayoutRect( screenRect, layout ); |
|
5462 TRect staconTop( layoutRect.Rect() ); |
|
5463 |
|
5464 layout = AknLayoutScalable_Avkon::area_bottom_pane(2).LayoutLine(); |
|
5465 layoutRect.LayoutRect( screenRect, layout ); |
|
5466 TRect staconBottom( layoutRect.Rect() ); |
|
5467 |
|
5468 TBool skLeft = AknLayoutFlags() & EAknLayoutCbaInStaconPaneLeft; |
|
5469 TBool idle = AknLayoutFlags() & EAknLayoutCbaInStaconPaneIdle; |
|
5470 |
|
5471 TAknsItemID topMaskIID = KAknsIIDNone; |
|
5472 TAknsItemID bottomMaskIID = KAknsIIDNone; |
|
5473 |
|
5474 if ( idle ) |
|
5475 { |
|
5476 if ( skLeft ) |
|
5477 { |
|
5478 iStaconBgContextTop->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconLtIdle ); |
|
5479 iStaconBgContextBottom->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconLbIdle ); |
|
5480 } |
|
5481 else |
|
5482 { |
|
5483 iStaconBgContextTop->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRtIdle ); |
|
5484 iStaconBgContextBottom->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRbIdle ); |
|
5485 } |
|
5486 iStaconBgContextTop->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
5487 iStaconBgContextTop->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
5488 iStaconBgContextTop->SetLayerRect( ECbaLayerBackground, staconTop ); |
|
5489 |
|
5490 topMaskIID = KAknsIIDQgnGrafBgLscTopMaskIcon; |
|
5491 |
|
5492 iStaconBgContextBottom->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
5493 iStaconBgContextBottom->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
5494 iStaconBgContextBottom->SetLayerRect( ECbaLayerBackground, staconBottom ); |
|
5495 |
|
5496 bottomMaskIID = KAknsIIDQgnGrafBgLscBottomMaskIcon; |
|
5497 } |
|
5498 else |
|
5499 { |
|
5500 // If not in idle, then there is no wallpaper, thus clear wallpaper layer. |
|
5501 if ( skLeft ) |
|
5502 { |
|
5503 iStaconBgContextTop->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconLt ); |
|
5504 iStaconBgContextBottom->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconLb ); |
|
5505 } |
|
5506 else |
|
5507 { |
|
5508 iStaconBgContextTop->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRt ); |
|
5509 iStaconBgContextBottom->SetLayerImage( ECbaLayerBackground, KAknsIIDQsnBgAreaStaconRb ); |
|
5510 } |
|
5511 iStaconBgContextTop->SetLayerRect( ECbaLayerBackground, staconTop ); |
|
5512 iStaconBgContextTop->SetLayerImage( ECbaLayerWallpaper, KAknsIIDNone ); |
|
5513 topMaskIID = KAknsIIDNone; |
|
5514 |
|
5515 iStaconBgContextBottom->SetLayerRect( ECbaLayerBackground, staconBottom ); |
|
5516 iStaconBgContextBottom->SetLayerImage( ECbaLayerWallpaper, KAknsIIDNone ); |
|
5517 bottomMaskIID = KAknsIIDNone; |
|
5518 } |
|
5519 |
|
5520 // If setting layer mask fails, ignore the error. |
|
5521 // This causes UI elements to be opaque and thus parts of the wallpaper is hidden. |
|
5522 TRAP_IGNORE( |
|
5523 iStaconBgContextBottom->SetLayerMaskAndSizeL( bottomMaskIID, staconBottom ); |
|
5524 iStaconBgContextTop->SetLayerMaskAndSizeL( topMaskIID, staconTop ); |
|
5525 ); |
|
5526 |
|
5527 TRect cba( Rect() ); |
|
5528 // This uses correct coordinates to calculate the positions of softkey labels. |
|
5529 // Unfortunately we do not have access to the labels inside CEikCbaButtons, |
|
5530 // that's the reason for a hack with ComponentControl(). |
|
5531 // (This is the only place that knows of both left and right softkey ...) |
|
5532 if (iControlArray->Count() != 0) |
|
5533 { |
|
5534 CCoeControl *leftSoftkey = (*iControlArray)[KControlArrayCBAButton1Posn].iControl; |
|
5535 CCoeControl *rightSoftkey = (*iControlArray)[KControlArrayCBAButton2Posn].iControl; |
|
5536 |
|
5537 // Left SK. |
|
5538 if (!(((CEikCbaButton*)leftSoftkey)->IsImageOn())) |
|
5539 { |
|
5540 AknLayoutUtils::LayoutLabel((CEikLabel*)leftSoftkey->ComponentControl( 0 ), |
|
5541 Rect(), |
|
5542 leftSoftkeyTextLayout ); |
|
5543 LayoutControl( (CEikCbaButton*)leftSoftkey, |
|
5544 leftSoftkey->ComponentControl( 0 )->Rect() ); |
|
5545 ((CEikCbaButton*)leftSoftkey)->TruncateLabelText(); |
|
5546 } |
|
5547 else |
|
5548 { |
|
5549 TAknLayoutRect qgn_graf_sk_left; |
|
5550 qgn_graf_sk_left.LayoutRect(cba, leftSoftkeyImageLayout); |
|
5551 leftSoftkey->ComponentControl(0)->SetRect(qgn_graf_sk_left.Rect()); |
|
5552 leftSoftkey->SetRect(leftSoftKeyButtonRect); |
|
5553 |
|
5554 // To make sure mop chain is updated, do it here. If not done, only skin background |
|
5555 // suffers. |
|
5556 TRAP_IGNORE(((CEikCbaButton*)leftSoftkey)->SetContainerWindowL(*this)); |
|
5557 } |
|
5558 |
|
5559 // Right SK. |
|
5560 if (!(((CEikCbaButton*)rightSoftkey)->IsImageOn())) |
|
5561 { |
|
5562 AknLayoutUtils::LayoutLabel((CEikLabel*)rightSoftkey->ComponentControl( 0 ), |
|
5563 Rect(), |
|
5564 rightSoftkeyTextLayout ); |
|
5565 LayoutControl( (CEikCbaButton*)rightSoftkey, |
|
5566 rightSoftkey->ComponentControl( 0 )->Rect() ); |
|
5567 ((CEikCbaButton*)rightSoftkey)->TruncateLabelText(); |
|
5568 } |
|
5569 else |
|
5570 { |
|
5571 TAknLayoutRect qgn_graf_sk_right; |
|
5572 qgn_graf_sk_right.LayoutRect(cba, rightSoftkeyImageLayout); |
|
5573 rightSoftkey->ComponentControl(0)->SetRect(qgn_graf_sk_right.Rect()); |
|
5574 rightSoftkey->SetRect(rightSoftKeyButtonRect); |
|
5575 |
|
5576 // To make sure mop chain is updated, do it here. If not done, only skin background |
|
5577 // suffers. |
|
5578 TRAP_IGNORE(((CEikCbaButton*)rightSoftkey)->SetContainerWindowL(*this)); |
|
5579 } |
|
5580 |
|
5581 // Landscape mode scrollbar layout is not set here, let application do if needed. |
|
5582 CCoeControl* scroller = (*iControlArray)[KControlArrayScrollBarPosn].iControl; |
|
5583 if (scroller) |
|
5584 { |
|
5585 scroller->SetSize(TSize(0,0)); |
|
5586 } |
|
5587 |
|
5588 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
5589 const TBool transparentSoftkeys = |
|
5590 iExtension->iEnablePostingTransparency || |
|
5591 ( iCbaFlags & EEikCbaFlagTransparent ); |
|
5592 TRgb rightSkColor; |
|
5593 TRgb leftSkColor; |
|
5594 |
|
5595 TInt error1 = 0; |
|
5596 TInt error2 = 0; |
|
5597 |
|
5598 if (idle) |
|
5599 { |
|
5600 error1 = AknsUtils::GetCachedColor( skin, rightSkColor, KAknsIIDQsnTextColors, |
|
5601 EAknsCIQsnTextColorsCG41 ); // text #41 stacon area top softkey text in idle #0 |
|
5602 |
|
5603 error2 = AknsUtils::GetCachedColor( skin, leftSkColor, KAknsIIDQsnTextColors, |
|
5604 EAknsCIQsnTextColorsCG42 ); // text #42 stacon area bottom softkey text in idle #0 |
|
5605 } |
|
5606 else |
|
5607 { |
|
5608 error1 = AknsUtils::GetCachedColor( skin, rightSkColor, KAknsIIDQsnTextColors, |
|
5609 EAknsCIQsnTextColorsCG39 ); // text #39 stacon area top softkey text #0 |
|
5610 |
|
5611 error2 = AknsUtils::GetCachedColor( skin, leftSkColor, KAknsIIDQsnTextColors, |
|
5612 EAknsCIQsnTextColorsCG40 ); // text #40 stacon area bottom softkey text #0 |
|
5613 } |
|
5614 |
|
5615 if ( transparentSoftkeys ) |
|
5616 { |
|
5617 rightSkColor = KRgbWhite; |
|
5618 leftSkColor = KRgbWhite; |
|
5619 } |
|
5620 if (softKeysUpAndDownMirrored) |
|
5621 { |
|
5622 TRgb tmp = rightSkColor; |
|
5623 rightSkColor = leftSkColor; |
|
5624 leftSkColor = tmp; |
|
5625 } |
|
5626 |
|
5627 if ( ((CEikCbaButton*)leftSoftkey)->PressedDown() ) |
|
5628 { |
|
5629 leftSkColor.SetAlpha( KPressedDownAlphaValue ); |
|
5630 |
|
5631 AknsUtils::GetCachedColor( |
|
5632 skin, |
|
5633 leftSkColor, |
|
5634 KAknsIIDQsnTextColors, |
|
5635 EAknsCIQsnTextColorsCG69 ); |
|
5636 |
|
5637 if ( transparentSoftkeys ) |
|
5638 { |
|
5639 // alpha has no effect with display posting. |
|
5640 leftSkColor = TRgb( 128, 128, 128 ); |
|
5641 } |
|
5642 } |
|
5643 else if ( ((CEikCbaButton*)rightSoftkey)->PressedDown() ) |
|
5644 { |
|
5645 rightSkColor.SetAlpha( KPressedDownAlphaValue ); |
|
5646 |
|
5647 AknsUtils::GetCachedColor( |
|
5648 skin, |
|
5649 rightSkColor, |
|
5650 KAknsIIDQsnTextColors, |
|
5651 EAknsCIQsnTextColorsCG69 ); |
|
5652 |
|
5653 if ( transparentSoftkeys ) |
|
5654 { |
|
5655 // alpha has no effect with display posting. |
|
5656 rightSkColor = TRgb( 128, 128, 128 ); |
|
5657 } |
|
5658 } |
|
5659 |
|
5660 if( !error1 && !error2 ) |
|
5661 { |
|
5662 // Error ignored. |
|
5663 TRAP( error1, AknLayoutUtils::OverrideControlColorL(*leftSoftkey, |
|
5664 EColorLabelText, |
|
5665 leftSkColor) ); |
|
5666 TRAP( error2, AknLayoutUtils::OverrideControlColorL(*rightSoftkey, |
|
5667 EColorLabelText, |
|
5668 rightSkColor) ); |
|
5669 if ( transparentSoftkeys ) |
|
5670 { |
|
5671 // outline color is black. |
|
5672 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5673 *leftSoftkey, |
|
5674 EColorControlBackground, |
|
5675 KRgbBlack ) ); |
|
5676 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5677 *rightSoftkey, |
|
5678 EColorControlBackground, |
|
5679 KRgbBlack ) ); |
|
5680 } |
|
5681 } |
|
5682 |
|
5683 if (iStaconLabelFont) |
|
5684 { |
|
5685 ((CEikCbaButton*)leftSoftkey)->SetLabelFont(iStaconLabelFont); |
|
5686 ((CEikCbaButton*)rightSoftkey)->SetLabelFont(iStaconLabelFont); |
|
5687 } |
|
5688 |
|
5689 DrawDeferred(); |
|
5690 } |
|
5691 |
|
5692 AknsUtils::RegisterControlPosition( this, TPoint(0,0) ); |
|
5693 } |
|
5694 |
|
5695 |
|
5696 //------------------------------------------------------------------------------ |
|
5697 // CEikCba::SizeChangedInRightPane() |
|
5698 //------------------------------------------------------------------------------ |
|
5699 // |
|
5700 void CEikCba::SizeChangedInRightPane() |
|
5701 { |
|
5702 TRect screen; |
|
5703 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
5704 |
|
5705 TAknWindowComponentLayout rightAreaLayout( |
|
5706 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ); |
|
5707 |
|
5708 TAknWindowComponentLayout topSKLayout( |
|
5709 DoCompose( rightAreaLayout, |
|
5710 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ) ); |
|
5711 |
|
5712 TAknWindowComponentLayout bottomSKLayout( |
|
5713 DoCompose( rightAreaLayout, |
|
5714 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ) ); |
|
5715 |
|
5716 // Calculate softkey rects. |
|
5717 |
|
5718 // Right (top in landscape) softkey layout. |
|
5719 TAknLayoutRect rightSoftkeyLayoutRect; |
|
5720 rightSoftkeyLayoutRect.LayoutRect( screen, |
|
5721 topSKLayout.LayoutLine() ); |
|
5722 TRect rightSoftKeyButtonRect( rightSoftkeyLayoutRect.Rect() ); |
|
5723 |
|
5724 // Left (bottom in landscape) softkey layout. |
|
5725 TAknLayoutRect leftSoftkeyLayoutRect; |
|
5726 leftSoftkeyLayoutRect.LayoutRect( screen, |
|
5727 bottomSKLayout.LayoutLine() ); |
|
5728 TRect leftSoftKeyButtonRect( leftSoftkeyLayoutRect.Rect() ); |
|
5729 |
|
5730 // Set the softkey frame rectangles in touch layouts. |
|
5731 if ( iExtension && AknLayoutUtils::PenEnabled() ) |
|
5732 { |
|
5733 TBool frameSizeChanged( |
|
5734 iExtension->iLeftFrameOuterRect != leftSoftKeyButtonRect || |
|
5735 iExtension->iRightFrameOuterRect != rightSoftKeyButtonRect ); |
|
5736 iExtension->iLeftFrameOuterRect = leftSoftKeyButtonRect; |
|
5737 iExtension->iRightFrameOuterRect = rightSoftKeyButtonRect; |
|
5738 if ( frameSizeChanged ) |
|
5739 { |
|
5740 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
5741 } |
|
5742 } |
|
5743 |
|
5744 // Calculate softkey image and text layouts. |
|
5745 TInt softkeyTextVariety = 0; |
|
5746 |
|
5747 if ( iExtension->iEnablePostingTransparency || ( iCbaFlags & EEikCbaFlagTransparent ) ) |
|
5748 { |
|
5749 softkeyTextVariety = 1; // Outline font used |
|
5750 } |
|
5751 |
|
5752 // Right (top in landscape) softkey layout. |
|
5753 TAknTextLineLayout rightSoftkeyTextLayout( |
|
5754 DoComposeText( |
|
5755 topSKLayout, |
|
5756 AknLayoutScalable_Avkon::sctrl_sk_top_pane_t1(softkeyTextVariety) ).LayoutLine() ); |
|
5757 |
|
5758 TAknWindowLineLayout rightSoftkeyImageLayout( |
|
5759 DoCompose( |
|
5760 topSKLayout, |
|
5761 AknLayoutScalable_Avkon::sctrl_sk_top_pane_g1() ).LayoutLine() ); |
|
5762 |
|
5763 // Left (bottom in landscape) softkey layout. |
|
5764 TAknTextLineLayout leftSoftkeyTextLayout( |
|
5765 DoComposeText( |
|
5766 bottomSKLayout, |
|
5767 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane_t1(softkeyTextVariety) ).LayoutLine() ); |
|
5768 |
|
5769 TAknWindowLineLayout leftSoftkeyImageLayout( |
|
5770 DoCompose( |
|
5771 bottomSKLayout, |
|
5772 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane_g1() ).LayoutLine() ); |
|
5773 |
|
5774 // Set skin background. |
|
5775 |
|
5776 DoSetLayers( KAknsIIDNone ); |
|
5777 |
|
5778 TRect cba( Rect() ); |
|
5779 |
|
5780 // This uses correct coordinates to calculate the positions |
|
5781 // of softkey labels. Unfortunately we do not have access to |
|
5782 // the labels inside CEikCbaButtons, that's the reason for a |
|
5783 // hack with ComponentControl(). |
|
5784 // (This is the only place that knows of both left and right softkey ...) |
|
5785 if ( iControlArray->Count() != 0 ) |
|
5786 { |
|
5787 CCoeControl* leftSoftkeyControl = |
|
5788 (*iControlArray)[KControlArrayCBAButton1Posn].iControl; |
|
5789 CCoeControl* rightSoftkeyControl = |
|
5790 (*iControlArray)[KControlArrayCBAButton2Posn].iControl; |
|
5791 |
|
5792 CEikCbaButton* leftSoftkey = |
|
5793 static_cast<CEikCbaButton*>( leftSoftkeyControl ); |
|
5794 CEikCbaButton* rightSoftkey = |
|
5795 static_cast<CEikCbaButton*>( rightSoftkeyControl ); |
|
5796 |
|
5797 // Left SK. |
|
5798 if ( !leftSoftkey->IsImageOn() ) |
|
5799 { |
|
5800 AknLayoutUtils::LayoutLabel( |
|
5801 static_cast<CEikLabel*>( leftSoftkeyControl->ComponentControl( 0 ) ), |
|
5802 cba, |
|
5803 leftSoftkeyTextLayout ); |
|
5804 LayoutControl( |
|
5805 leftSoftkey, |
|
5806 leftSoftkeyControl->ComponentControl( 0 )->Rect() ); |
|
5807 leftSoftkey->TruncateLabelText(); |
|
5808 } |
|
5809 else |
|
5810 { |
|
5811 TAknLayoutRect qgn_graf_sk_left; |
|
5812 qgn_graf_sk_left.LayoutRect( cba, leftSoftkeyImageLayout ); |
|
5813 leftSoftkeyControl->ComponentControl( 0 )->SetRect( qgn_graf_sk_left.Rect() ); |
|
5814 leftSoftkeyControl->SetRect( leftSoftKeyButtonRect ); |
|
5815 |
|
5816 // To make sure mop chain is updated, do it here. |
|
5817 // If not done, only skin background suffers. |
|
5818 TRAP_IGNORE( leftSoftkey->SetContainerWindowL( *this ) ); |
|
5819 } |
|
5820 |
|
5821 // Right SK. |
|
5822 if ( !rightSoftkey->IsImageOn() ) |
|
5823 { |
|
5824 AknLayoutUtils::LayoutLabel( |
|
5825 static_cast<CEikLabel*>( rightSoftkeyControl->ComponentControl( 0 ) ), |
|
5826 cba, |
|
5827 rightSoftkeyTextLayout ); |
|
5828 LayoutControl( |
|
5829 rightSoftkey, |
|
5830 rightSoftkeyControl->ComponentControl( 0 )->Rect() ); |
|
5831 rightSoftkey->TruncateLabelText(); |
|
5832 } |
|
5833 else |
|
5834 { |
|
5835 TAknLayoutRect qgn_graf_sk_right; |
|
5836 qgn_graf_sk_right.LayoutRect( cba, rightSoftkeyImageLayout ); |
|
5837 rightSoftkeyControl->ComponentControl( 0 )->SetRect( qgn_graf_sk_right.Rect() ); |
|
5838 rightSoftkeyControl->SetRect( rightSoftKeyButtonRect ); |
|
5839 |
|
5840 // To make sure mop chain is updated, do it here. |
|
5841 // If not done, only skin background suffers. |
|
5842 TRAP_IGNORE( rightSoftkey->SetContainerWindowL( *this ) ); |
|
5843 } |
|
5844 |
|
5845 // Landscape mode scrollbar layout is not set here, let application do if needed. |
|
5846 CCoeControl* scroller = (*iControlArray)[KControlArrayScrollBarPosn].iControl; |
|
5847 if ( scroller ) |
|
5848 { |
|
5849 scroller->SetSize( TSize( 0, 0 ) ); |
|
5850 } |
|
5851 |
|
5852 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
5853 const TBool transparentSoftkeys = |
|
5854 iExtension->iEnablePostingTransparency || |
|
5855 ( iCbaFlags & EEikCbaFlagTransparent ); |
|
5856 |
|
5857 TRgb rightSkColor; |
|
5858 TRgb leftSkColor; |
|
5859 |
|
5860 TInt error1 = 0; |
|
5861 TInt error2 = 0; |
|
5862 if ( transparentSoftkeys ) |
|
5863 { |
|
5864 rightSkColor = KRgbWhite; |
|
5865 leftSkColor = KRgbWhite; |
|
5866 } |
|
5867 else if ( AknStatuspaneUtils::IdleLayoutActive() ) |
|
5868 { |
|
5869 // Text #41 stacon area top softkey text in idle #0 |
|
5870 error1 = AknsUtils::GetCachedColor( skin, |
|
5871 rightSkColor, |
|
5872 KAknsIIDQsnTextColors, |
|
5873 EAknsCIQsnTextColorsCG41 ); |
|
5874 |
|
5875 // Text #42 stacon area bottom softkey text in idle #0 |
|
5876 error2 = AknsUtils::GetCachedColor( skin, |
|
5877 leftSkColor, |
|
5878 KAknsIIDQsnTextColors, |
|
5879 EAknsCIQsnTextColorsCG42 ); |
|
5880 } |
|
5881 else |
|
5882 { |
|
5883 // Text #39 stacon area top softkey text #0 |
|
5884 error1 = AknsUtils::GetCachedColor( skin, |
|
5885 rightSkColor, |
|
5886 KAknsIIDQsnTextColors, |
|
5887 EAknsCIQsnTextColorsCG39 ); |
|
5888 |
|
5889 // Text #40 stacon area bottom softkey text #0 |
|
5890 error2 = AknsUtils::GetCachedColor( skin, |
|
5891 leftSkColor, |
|
5892 KAknsIIDQsnTextColors, |
|
5893 EAknsCIQsnTextColorsCG40 ); |
|
5894 } |
|
5895 |
|
5896 if ( leftSoftkey->PressedDown() ) |
|
5897 { |
|
5898 leftSkColor.SetAlpha( KPressedDownAlphaValue ); |
|
5899 |
|
5900 AknsUtils::GetCachedColor( |
|
5901 skin, |
|
5902 leftSkColor, |
|
5903 KAknsIIDQsnTextColors, |
|
5904 EAknsCIQsnTextColorsCG69 ); |
|
5905 |
|
5906 |
|
5907 if ( transparentSoftkeys ) |
|
5908 { |
|
5909 // alpha has no effect with display posting. |
|
5910 leftSkColor = TRgb( 128, 128, 128 ); |
|
5911 } |
|
5912 } |
|
5913 else if ( rightSoftkey->PressedDown() ) |
|
5914 { |
|
5915 rightSkColor.SetAlpha( KPressedDownAlphaValue ); |
|
5916 |
|
5917 AknsUtils::GetCachedColor( |
|
5918 skin, |
|
5919 rightSkColor, |
|
5920 KAknsIIDQsnTextColors, |
|
5921 EAknsCIQsnTextColorsCG69 ); |
|
5922 |
|
5923 if ( transparentSoftkeys ) |
|
5924 { |
|
5925 // alpha has no effect with display posting. |
|
5926 rightSkColor = TRgb( 128, 128, 128 ); |
|
5927 } |
|
5928 } |
|
5929 |
|
5930 if( !error1 && !error2 ) |
|
5931 { |
|
5932 // Error ignored. |
|
5933 TRAP( error1, |
|
5934 AknLayoutUtils::OverrideControlColorL( *leftSoftkeyControl, |
|
5935 EColorLabelText, |
|
5936 leftSkColor ) ); |
|
5937 TRAP( error2, |
|
5938 AknLayoutUtils::OverrideControlColorL( *rightSoftkeyControl, |
|
5939 EColorLabelText, |
|
5940 rightSkColor ) ); |
|
5941 |
|
5942 if ( transparentSoftkeys ) |
|
5943 { |
|
5944 // outline color is black. |
|
5945 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5946 *leftSoftkeyControl, |
|
5947 EColorControlBackground, |
|
5948 KRgbBlack ) ); |
|
5949 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
|
5950 *rightSoftkeyControl, |
|
5951 EColorControlBackground, |
|
5952 KRgbBlack ) ); |
|
5953 } |
|
5954 } |
|
5955 |
|
5956 if ( iRightPaneLabelFont ) |
|
5957 { |
|
5958 leftSoftkey->SetLabelFont( iRightPaneLabelFont ); |
|
5959 rightSoftkey->SetLabelFont( iRightPaneLabelFont ); |
|
5960 } |
|
5961 |
|
5962 DrawDeferred(); |
|
5963 } |
|
5964 |
|
5965 AknsUtils::RegisterControlPosition( this, TPoint( 0, 0 ) ); |
|
5966 } |
|
5967 |
|
5968 |
|
5969 |
|
5970 void CEikCba::SizeChangedInsideDialog() |
|
5971 { |
|
5972 // Give both LSK and RSK buttons half of the available space. |
|
5973 // |
|
5974 if ( iControlArray ) |
|
5975 { |
|
5976 TRect buttonRect1( Rect() ); |
|
5977 TRect buttonRect2( Rect() ); |
|
5978 |
|
5979 TInt width = ( buttonRect1.iBr.iX - buttonRect1.iTl.iX ) / 2 - 4; |
|
5980 |
|
5981 buttonRect1.iBr.iX = buttonRect1.iTl.iX + width; |
|
5982 buttonRect2.iTl.iX = buttonRect2.iBr.iX - width; |
|
5983 |
|
5984 if ( (*iControlArray)[KControlArrayCBAButton1Posn].iControl ) |
|
5985 { |
|
5986 (*iControlArray)[KControlArrayCBAButton1Posn].iControl->SetRect( buttonRect1 ); |
|
5987 } |
|
5988 |
|
5989 if ( (*iControlArray)[KControlArrayCBAButton2Posn].iControl ) |
|
5990 { |
|
5991 (*iControlArray)[KControlArrayCBAButton2Posn].iControl->SetRect( buttonRect2 ); |
|
5992 } |
|
5993 } |
|
5994 } |
|
5995 |
|
5996 |
|
5997 void CEikCba::SizeChangedInPopup() |
|
5998 { |
|
5999 TRAP_IGNORE( iExtension->UpdateSoftkeyFrameL( EFalse ) ); |
|
6000 |
|
6001 TAknLayoutRect layoutRect; |
|
6002 TRect rect ( Rect() ); |
|
6003 |
|
6004 // Button widths are calculated based on cba area width |
|
6005 // margin width is taken from layout |
|
6006 layoutRect.LayoutRect( |
|
6007 rect, |
|
6008 AknLayoutScalable_Avkon::popup_sk_window_g1( 0 ) ); |
|
6009 |
|
6010 TInt margin = layoutRect.Rect().iTl.iX - rect.iTl.iX; |
|
6011 TInt buttonWidth = ( rect.Width() - margin * 2 ) / 2; |
|
6012 TSize buttonSize ( buttonWidth, layoutRect.Rect().Height() ); |
|
6013 |
|
6014 iExtension->iLeftFrameOuterRect = TRect( |
|
6015 TPoint( rect.iTl.iX + margin, layoutRect.Rect().iTl.iY ), |
|
6016 buttonSize ); |
|
6017 iExtension->iRightFrameOuterRect = TRect( |
|
6018 TPoint( iExtension->iLeftFrameOuterRect.iBr.iX, |
|
6019 layoutRect.Rect().iTl.iY ), |
|
6020 TPoint( rect.iBr.iX - margin, layoutRect.Rect().iBr.iY ) ); |
|
6021 |
|
6022 layoutRect.LayoutRect( iExtension->iLeftFrameOuterRect, |
|
6023 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
6024 .LayoutLine() ); |
|
6025 iExtension->iLeftFrameInnerRect = layoutRect.Rect(); |
|
6026 UpdateLabels( ETrue ); |
|
6027 |
|
6028 layoutRect.LayoutRect( iExtension->iRightFrameOuterRect, |
|
6029 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
6030 .LayoutLine() ); |
|
6031 iExtension->iRightFrameInnerRect = layoutRect.Rect(); |
|
6032 UpdateLabels( ETrue ); |
|
6033 |
|
6034 if ( iControlArray->Count() > KControlArrayCBAButtonMSKPosn ) |
|
6035 { |
|
6036 CCoeControl* msk = |
|
6037 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl; |
|
6038 |
|
6039 if ( msk ) |
|
6040 { |
|
6041 msk->SetRect( TRect() ); |
|
6042 } |
|
6043 } |
|
6044 } |
|
6045 |
|
6046 |
|
6047 void CEikCba::UpdateFonts() |
|
6048 { |
|
6049 // Control pane: |
|
6050 // Use the layout dll to get the right font for the CBA. |
|
6051 TAknTextLineLayout layout( |
|
6052 AknLayoutScalable_Avkon::control_pane_t1( |
|
6053 Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 0 ).LayoutLine() ); |
|
6054 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
6055 { |
|
6056 // Sets outline font property. |
|
6057 layout.iFont |= KOutlineFontMask; |
|
6058 } |
|
6059 const CFont* customfont = 0; |
|
6060 iLabelFont = AknLayoutUtils::FontFromId( layout.FontId(), customfont ); |
|
6061 |
|
6062 // Stacon pane: |
|
6063 TAknTextLineLayout staconTextLayout( |
|
6064 AknLayoutScalable_Avkon::control_bottom_pane_stacon_t1( 0 ).LayoutLine() ); |
|
6065 |
|
6066 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
6067 { |
|
6068 // Sets outline font property. |
|
6069 staconTextLayout.iFont |= KOutlineFontMask; |
|
6070 } |
|
6071 const CFont* staconCustomfont = 0; |
|
6072 iStaconLabelFont = AknLayoutUtils::FontFromId( staconTextLayout.FontId(), |
|
6073 staconCustomfont ); |
|
6074 |
|
6075 // Right pane: |
|
6076 TInt rightPaneTextVariety = 0; |
|
6077 |
|
6078 if ( iExtension->iEnablePostingTransparency || |
|
6079 ( iCbaFlags & EEikCbaFlagTransparent ) || ( iCbaFlags & EEikCbaFlagSemiTransparent ) ) |
|
6080 { |
|
6081 rightPaneTextVariety = 1; // Outline font used |
|
6082 } |
|
6083 |
|
6084 TAknTextLineLayout rightPaneTextLayout( |
|
6085 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane_t1( |
|
6086 rightPaneTextVariety ).LayoutLine() ); |
|
6087 |
|
6088 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
6089 { |
|
6090 // Sets outline font property. |
|
6091 rightPaneTextLayout.iFont |= KOutlineFontMask; |
|
6092 } |
|
6093 const CFont* rightPaneCustomFont = 0; |
|
6094 iRightPaneLabelFont = |
|
6095 AknLayoutUtils::FontFromId( |
|
6096 rightPaneTextLayout.FontId(), rightPaneCustomFont ); |
|
6097 } |
|
6098 |
|
6099 // Enhanced CBA |
|
6100 |
|
6101 // ----------------------------------------------------------------------------- |
|
6102 // Used to offer list of commands for softkeys. |
|
6103 // @param aCommandList A list of command ids to be offered for sofkeys. |
|
6104 // @since 5.0 |
|
6105 // ----------------------------------------------------------------------------- |
|
6106 #ifdef RD_ENHANCED_CBA |
|
6107 EXPORT_C void CEikCba::OfferCommandListL(const RArray<TInt>& aCommandList) |
|
6108 { |
|
6109 if( !iCommandTable ) |
|
6110 { |
|
6111 iCommandTable = CEikCommandTable::NewL(); |
|
6112 } |
|
6113 else |
|
6114 { |
|
6115 delete iCommandTable; |
|
6116 iCommandTable = NULL; |
|
6117 iCommandTable = CEikCommandTable::NewL(); |
|
6118 } |
|
6119 |
|
6120 TInt count = aCommandList.Count(); |
|
6121 |
|
6122 // Stack existing commands for possible leave while adding the new commands. |
|
6123 RArray<TInt> previousIds; |
|
6124 CleanupClosePushL( previousIds ); |
|
6125 |
|
6126 // Store the existing commands. |
|
6127 for ( TInt i = 0; i < iControlArray->Count(); i++ ) |
|
6128 { |
|
6129 TEikGroupControl& groupCtrl=(*iControlArray)[i]; |
|
6130 previousIds.AppendL( groupCtrl.iId ); |
|
6131 } |
|
6132 |
|
6133 iCommandTable->Reset(); |
|
6134 |
|
6135 for ( TInt ii = 0; ii < count; ii++ ) |
|
6136 { |
|
6137 TInt resourceId( aCommandList[ii] ); |
|
6138 |
|
6139 TResourceReader reader; |
|
6140 iCoeEnv->CreateResourceReaderLC( reader, resourceId ); |
|
6141 |
|
6142 TUint8 version( (TUint8)reader.ReadUint8() ); |
|
6143 TInt longCommandId( 0 ); |
|
6144 |
|
6145 CEikEnhancedCbaButton* button = new (ELeave) CEikEnhancedCbaButton; |
|
6146 CleanupStack::PushL( button ); |
|
6147 |
|
6148 if( version == EEikCbaButtonLink ) |
|
6149 { |
|
6150 TInt aButtonId = reader.ReadInt32(); // Read ENHANCED_CBA_BUTTON id from LLINK |
|
6151 TResourceReader linkReader; // reader for reading linked resource |
|
6152 iCoeEnv->CreateResourceReaderLC( linkReader, aButtonId ); |
|
6153 TUint8 ver( linkReader.ReadUint8() ); |
|
6154 |
|
6155 if( ver == EEikEnhancedCbaButton ) |
|
6156 { |
|
6157 button->ConstructFromResourceL( linkReader ); |
|
6158 } |
|
6159 CleanupStack::PopAndDestroy( ); // linkReader |
|
6160 } |
|
6161 else if( version == EEikEnhancedCbaButton ) |
|
6162 { |
|
6163 button->ConstructFromResourceL( reader ); |
|
6164 } |
|
6165 else // command version not regognized |
|
6166 { |
|
6167 CleanupStack::PopAndDestroy(2); // button and reader |
|
6168 continue; // go for next command |
|
6169 } |
|
6170 |
|
6171 iCommandTable->AddCommandL( button ); |
|
6172 |
|
6173 CleanupStack::Pop( button ); |
|
6174 CleanupStack::PopAndDestroy(); // reader |
|
6175 } |
|
6176 |
|
6177 for (TInt i = 0; i < KMaxButtonsInCommandTable + 1; i++) // +1 for scrollbar |
|
6178 { |
|
6179 if ( i != KControlArrayScrollBarPosn ) |
|
6180 { |
|
6181 CEikEnhancedCbaButton* button; |
|
6182 if( i > KControlArrayScrollBarPosn ) |
|
6183 { |
|
6184 button = iCommandTable->Command( i-1 ); |
|
6185 } |
|
6186 else |
|
6187 { |
|
6188 button = iCommandTable->Command( i ); |
|
6189 } |
|
6190 |
|
6191 if ( !button ) |
|
6192 { |
|
6193 button = new (ELeave) CEikEnhancedCbaButton; |
|
6194 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
6195 CleanupStack::PushL( button ); |
|
6196 button->ConstructEmptyButtonL(); |
|
6197 } |
|
6198 else |
|
6199 { |
|
6200 CleanupStack::PushL( button ); |
|
6201 } |
|
6202 |
|
6203 TRAPD( errorcode, AddCommandToStackL( i, button->CommandId(), button->LabelText(), |
|
6204 NULL, NULL ) ); |
|
6205 |
|
6206 if ( errorcode ) // In case of error restore previous commands before leave |
|
6207 { |
|
6208 for ( TInt counter = 0; counter < i; counter++ ) |
|
6209 { |
|
6210 // Do not deal with the scroller as a CEikCbaButton; skip its index. |
|
6211 if (counter != KControlArrayScrollBarPosn) |
|
6212 { |
|
6213 // Following adjusts for the fact that the scroller command is |
|
6214 // missing from the previousIds array. Same index adjust as later on. |
|
6215 TInt indexInPreviousIds = counter; |
|
6216 if ( counter > 1 ) |
|
6217 { |
|
6218 indexInPreviousIds = counter - 1; |
|
6219 } |
|
6220 RemoveCommandFromStack( counter,previousIds[indexInPreviousIds] ); |
|
6221 } |
|
6222 } |
|
6223 |
|
6224 User::Leave( errorcode ); |
|
6225 } |
|
6226 CleanupStack::PopAndDestroy( button ); |
|
6227 } |
|
6228 } |
|
6229 |
|
6230 // Remove the original commands from the temporary store. +1 for scroll bar. |
|
6231 for ( TInt controlId = 0; controlId < KMaxButtonsInCommandTable + 1; controlId++ ) |
|
6232 { |
|
6233 if ( controlId != KControlArrayScrollBarPosn ) |
|
6234 { |
|
6235 TInt controlPosition = controlId; |
|
6236 if ( controlId > 1 ) |
|
6237 { |
|
6238 controlPosition--; |
|
6239 } |
|
6240 RemovePreviousCommand( controlId ); |
|
6241 } |
|
6242 } |
|
6243 |
|
6244 CleanupStack::PopAndDestroy(); // previousIds |
|
6245 } |
|
6246 #else // !RD_ENHANCED_CBA |
|
6247 EXPORT_C void CEikCba::OfferCommandListL(const RArray<TInt>& /*aCommandList*/) |
|
6248 { |
|
6249 User::Leave( KErrNotSupported ); |
|
6250 } |
|
6251 #endif // RD_ENHANCED_CBA |
|
6252 |
|
6253 // ----------------------------------------------------------------------------- |
|
6254 // Used to offer list of commands for softkeys. |
|
6255 // @param aResourceId Id for CBA resource that defines enhanced cba buttons. |
|
6256 // @since 5.0 |
|
6257 // ----------------------------------------------------------------------------- |
|
6258 #ifdef RD_ENHANCED_CBA |
|
6259 EXPORT_C void CEikCba::OfferCommandListL(const TInt aResourceId) |
|
6260 { |
|
6261 if ( !iCommandTable ) // This is needed if cba was not constructed with enhanced cba. |
|
6262 { |
|
6263 iCommandTable = CEikCommandTable::NewL(); |
|
6264 } |
|
6265 |
|
6266 TResourceReader reader; |
|
6267 iCoeEnv->CreateResourceReaderLC(reader, aResourceId); |
|
6268 iCbaFlags = reader.ReadInt32(); |
|
6269 |
|
6270 TBool enhancedCba( EFalse ); |
|
6271 if ( ( iCbaFlags & EEikEnhancedButtonGroup ) == EEikEnhancedButtonGroup ) |
|
6272 { |
|
6273 enhancedCba = ETrue; |
|
6274 } |
|
6275 |
|
6276 __ASSERT_DEBUG( enhancedCba, Panic(EEikPanicCBAIsNotEnhancedCba) ); |
|
6277 |
|
6278 reader.ReadInt16(); // Skip width resource. |
|
6279 reader.ReadInt32(); // Skip related buttons resource. |
|
6280 |
|
6281 TInt count = reader.ReadInt16(); |
|
6282 |
|
6283 // Stack existing commands for possible leave while adding the new commands. |
|
6284 RArray<TInt> previousIds; |
|
6285 CleanupClosePushL( previousIds ); |
|
6286 |
|
6287 // Store the existing commands. |
|
6288 for ( TInt i = 0; i < iControlArray->Count(); i++ ) |
|
6289 { |
|
6290 TEikGroupControl& groupCtrl = (*iControlArray)[i]; |
|
6291 previousIds.AppendL( groupCtrl.iId ); |
|
6292 } |
|
6293 |
|
6294 iCommandTable->Reset(); |
|
6295 |
|
6296 // Get new commands. |
|
6297 for ( TInt ii = 0; ii < count; ii++ ) |
|
6298 { |
|
6299 TUint8 version( (TUint8)reader.ReadUint8() ); |
|
6300 TInt commandId( 0 ); |
|
6301 TInt longCommandId( 0 ); |
|
6302 |
|
6303 CEikEnhancedCbaButton* button = new (ELeave) CEikEnhancedCbaButton; |
|
6304 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
6305 CleanupStack::PushL( button ); |
|
6306 |
|
6307 if( version == EEikCbaButtonLink ) |
|
6308 { |
|
6309 TInt aButtonId = reader.ReadInt32(); // Read ENHANCED_CBA_BUTTON id from LLINK |
|
6310 TResourceReader linkReader; // reader for reading linked resource |
|
6311 iCoeEnv->CreateResourceReaderLC( linkReader, aButtonId ); |
|
6312 TUint8 ver( linkReader.ReadUint8() ); |
|
6313 |
|
6314 if( ver == EEikEnhancedCbaButton ) |
|
6315 { |
|
6316 button->ConstructFromResourceL( linkReader ); |
|
6317 } |
|
6318 |
|
6319 CleanupStack::PopAndDestroy(); // linkReader |
|
6320 } |
|
6321 else if( version == EEikEnhancedCbaButton ) |
|
6322 { |
|
6323 button->ConstructFromResourceL( reader ); |
|
6324 } |
|
6325 else |
|
6326 { |
|
6327 CleanupStack::PopAndDestroy( button ); |
|
6328 continue; // jump over the rest |
|
6329 } |
|
6330 |
|
6331 iCommandTable->AddCommandL( button ); |
|
6332 |
|
6333 CleanupStack::Pop( button ); |
|
6334 } |
|
6335 |
|
6336 CleanupStack::PopAndDestroy(); // reader |
|
6337 |
|
6338 for (TInt i = 0; i < KMaxButtonsInCommandTable + 1; i++) // +1 for scrollbar |
|
6339 { |
|
6340 if ( i != KControlArrayScrollBarPosn ) |
|
6341 { |
|
6342 CEikEnhancedCbaButton* button; |
|
6343 if( i > KControlArrayScrollBarPosn ) |
|
6344 { |
|
6345 button = iCommandTable->Command( i - 1 ); |
|
6346 } |
|
6347 else |
|
6348 { |
|
6349 button = iCommandTable->Command( i ); |
|
6350 } |
|
6351 |
|
6352 if ( !button ) |
|
6353 { |
|
6354 button = new (ELeave) CEikEnhancedCbaButton; |
|
6355 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
6356 CleanupStack::PushL( button ); |
|
6357 button->ConstructEmptyButtonL(); |
|
6358 } |
|
6359 else |
|
6360 { |
|
6361 CleanupStack::PushL( button ); |
|
6362 } |
|
6363 |
|
6364 TRAPD( errorcode, AddCommandToStackL( i, button->CommandId(), button->LabelText(), |
|
6365 NULL, NULL ) ); |
|
6366 |
|
6367 if ( errorcode ) // In case of error restore previous commands before leave. |
|
6368 { |
|
6369 for ( TInt counter = 0; counter < i; counter++ ) |
|
6370 { |
|
6371 // Do not deal with the scroller as a CEikCbaButton; skip its index. |
|
6372 if ( counter != KControlArrayScrollBarPosn ) |
|
6373 { |
|
6374 // Following adjusts for the fact that the scroller command is |
|
6375 // missing from the previousIds array. Same index adjust as later on. |
|
6376 TInt indexInPreviousIds = counter; |
|
6377 if ( counter > 1 ) |
|
6378 { |
|
6379 indexInPreviousIds = counter - 1; |
|
6380 } |
|
6381 RemoveCommandFromStack( counter, previousIds[indexInPreviousIds] ); |
|
6382 } |
|
6383 } |
|
6384 User::Leave( errorcode ); |
|
6385 } |
|
6386 CleanupStack::PopAndDestroy( button ); |
|
6387 } |
|
6388 } |
|
6389 |
|
6390 // Remove the original commands from the temporary store. +1 for scroll bar. |
|
6391 for ( TInt controlId = 0; controlId < KMaxButtonsInCommandTable + 1; controlId++ ) |
|
6392 { |
|
6393 if ( controlId != KControlArrayScrollBarPosn ) |
|
6394 { |
|
6395 TInt controlPosition=controlId; |
|
6396 if ( controlId > 1 ) |
|
6397 { |
|
6398 controlPosition--; |
|
6399 } |
|
6400 |
|
6401 RemovePreviousCommand( controlId ); |
|
6402 } |
|
6403 } |
|
6404 |
|
6405 CleanupStack::PopAndDestroy(); // previousIds |
|
6406 } |
|
6407 #else // !RD_ENHANCED_CBA |
|
6408 EXPORT_C void CEikCba::OfferCommandListL(const TInt /*aResourceId*/) |
|
6409 { |
|
6410 User::Leave( KErrNotSupported ); |
|
6411 } |
|
6412 #endif // RD_ENHANCED_CBA |
|
6413 |
|
6414 // ----------------------------------------------------------------------------- |
|
6415 // Used to check if a certain command have been approved to the current command set. |
|
6416 // @param aCommandId The id for command which existence should be checked. |
|
6417 // @since 5.0 |
|
6418 // ----------------------------------------------------------------------------- |
|
6419 #ifdef RD_ENHANCED_CBA |
|
6420 EXPORT_C TBool CEikCba::IsCommandInGroup(const TInt aCommandId) const |
|
6421 { |
|
6422 return ButtonById(aCommandId) ? ETrue : EFalse; // check the iControlArray |
|
6423 } |
|
6424 #else // !RD_ENHANCED_CBA |
|
6425 EXPORT_C TBool CEikCba::IsCommandInGroup(const TInt /*aCommandId*/) const |
|
6426 { |
|
6427 return EFalse; |
|
6428 } |
|
6429 #endif // RD_ENHANCED_CBA |
|
6430 |
|
6431 // ----------------------------------------------------------------------------- |
|
6432 // Replace existing command with a new command |
|
6433 // @param aCommandId Id for command that should be replaced. |
|
6434 // @param aResourceId Resource id for new enhanced cba button. |
|
6435 // @since 5.0 |
|
6436 // ----------------------------------------------------------------------------- |
|
6437 #ifdef RD_ENHANCED_CBA |
|
6438 EXPORT_C void CEikCba::ReplaceCommand(const TInt aReplaceCommandId, const TInt aResourceId) |
|
6439 { |
|
6440 TInt index = IndexById( aReplaceCommandId ); |
|
6441 TRAPD(err, SetCommandL( index, aResourceId ) ); |
|
6442 } |
|
6443 #else |
|
6444 EXPORT_C void CEikCba::ReplaceCommand(const TInt /*aReplaceCommandId*/, const TInt /*aResourceId*/) |
|
6445 { |
|
6446 } |
|
6447 #endif // RD_ENHANCED_CBA |
|
6448 |
|
6449 void CEikCba::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) |
|
6450 { |
|
6451 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
6452 { |
|
6453 //User::Panic( _L( "CBA inside dialog" ), KErrNotSupported ); |
|
6454 return; |
|
6455 } |
|
6456 |
|
6457 if ( aEventType == EEventStateChanged ) |
|
6458 { |
|
6459 TInt command = NULL; |
|
6460 |
|
6461 if ( aControl == (*iControlArray)[KControlArrayCBAButton1Posn].iControl ) |
|
6462 { |
|
6463 command = (*iControlArray)[KControlArrayCBAButton1Posn].iId; |
|
6464 } |
|
6465 else if ( aControl == (*iControlArray)[KControlArrayCBAButton2Posn].iControl ) |
|
6466 { |
|
6467 command = (*iControlArray)[KControlArrayCBAButton2Posn].iId; |
|
6468 } |
|
6469 |
|
6470 // CAknButton sends control event to CEikCba upon pointer event, |
|
6471 // while also increasing it's state value. Because of the way |
|
6472 // CAknButton is used as softkey control, and it's states as stack |
|
6473 // support, we must revert the state back here. |
|
6474 CAknButton* button = static_cast<CAknButton*>( aControl ); |
|
6475 TInt state( button->StateIndex() ); |
|
6476 if ( state > 0 ) |
|
6477 { |
|
6478 state--; |
|
6479 button->SetCurrentState( state, EFalse ); |
|
6480 } |
|
6481 |
|
6482 |
|
6483 if( command ) |
|
6484 { |
|
6485 iCommandObserver->ProcessCommandL( command ); |
|
6486 } |
|
6487 } |
|
6488 } |
|
6489 |
|
6490 |
|
6491 void CEikCba::MakeVisible( TBool aVisible ) |
|
6492 { |
|
6493 if ( aVisible ) |
|
6494 { |
|
6495 TBool redrawNeeded( EFalse ); |
|
6496 |
|
6497 if ( AknLayoutUtils::PenEnabled() ) |
|
6498 { |
|
6499 CEikCbaButton* leftSK = static_cast<CEikCbaButton*>( |
|
6500 (*iControlArray)[KControlArrayCBAButton1Posn].iControl ); |
|
6501 CEikCbaButton* rightSK = static_cast<CEikCbaButton*>( |
|
6502 (*iControlArray)[KControlArrayCBAButton2Posn].iControl ); |
|
6503 CEikCbaButton* middleSK = NULL; |
|
6504 |
|
6505 if ( iMSKset && AknLayoutUtils::MSKEnabled() ) |
|
6506 { |
|
6507 middleSK = |
|
6508 static_cast<CEikCbaButton*>( |
|
6509 (*iControlArray)[KControlArrayCBAButtonMSKPosn].iControl ); |
|
6510 } |
|
6511 |
|
6512 if ( leftSK && leftSK->PressedDown() ) |
|
6513 { |
|
6514 leftSK->SetPressedDown( EFalse ); |
|
6515 redrawNeeded = ETrue; |
|
6516 } |
|
6517 |
|
6518 if ( rightSK && rightSK->PressedDown() ) |
|
6519 { |
|
6520 rightSK->SetPressedDown( EFalse ); |
|
6521 redrawNeeded = ETrue; |
|
6522 } |
|
6523 |
|
6524 if ( middleSK && middleSK->PressedDown() ) |
|
6525 { |
|
6526 middleSK->SetPressedDown( EFalse ); |
|
6527 redrawNeeded = ETrue; |
|
6528 } |
|
6529 |
|
6530 if ( redrawNeeded ) |
|
6531 { |
|
6532 SizeChanged(); |
|
6533 } |
|
6534 } |
|
6535 |
|
6536 if ( iFlags[ECbaChangeRecordedSkin] ) |
|
6537 { |
|
6538 DoSkinChange(); |
|
6539 } |
|
6540 |
|
6541 if ( iFlags[ECbaChangeRecordedLayout] ) |
|
6542 { |
|
6543 DoLayoutChange(); |
|
6544 redrawNeeded = ETrue; |
|
6545 } |
|
6546 |
|
6547 if ( iFlags[ECbaChangeRecordedColor] ) |
|
6548 { |
|
6549 DoColorChange(); |
|
6550 } |
|
6551 |
|
6552 TBool isVisible = IsVisible(); |
|
6553 CEikControlGroup::MakeVisible( aVisible ); |
|
6554 |
|
6555 if ( redrawNeeded || !isVisible || IsEmpty() ) |
|
6556 { |
|
6557 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
6558 { |
|
6559 DrawDeferred(); |
|
6560 } |
|
6561 else |
|
6562 { |
|
6563 DrawNow(); |
|
6564 } |
|
6565 } |
|
6566 } |
|
6567 else |
|
6568 { |
|
6569 Window().ClearRedrawStore(); |
|
6570 CEikControlGroup::MakeVisible( aVisible ); |
|
6571 } |
|
6572 |
|
6573 ReportContentChangedEvent(); |
|
6574 } |
|
6575 |
|
6576 |
|
6577 // ----------------------------------------------------------------------------- |
|
6578 // Sets layer images and rects. |
|
6579 // @since 5.0 |
|
6580 // ----------------------------------------------------------------------------- |
|
6581 void CEikCba::DoSetLayers( const TAknsItemID& aIID ) |
|
6582 { |
|
6583 // Skin background is not drawn by embedded CBA. |
|
6584 if ( iFlags.IsSet( ECbaEmbedded ) ) |
|
6585 { |
|
6586 return; |
|
6587 } |
|
6588 |
|
6589 TAknLayoutRect cbarect; |
|
6590 TRect screen; |
|
6591 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
6592 |
|
6593 TAknWindowComponentLayout applicationWindow( |
|
6594 AknLayoutScalable_Avkon::application_window( 0 ) ); |
|
6595 |
|
6596 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
6597 TBool rightPaneActive( IsAreaSideRightPaneActive() ); |
|
6598 TBool idleLayout( AknStatuspaneUtils::IdleLayoutActive() ); |
|
6599 |
|
6600 if ( rightPaneActive ) |
|
6601 { |
|
6602 cbarect.LayoutRect( |
|
6603 screen, |
|
6604 DoCompose( |
|
6605 applicationWindow, |
|
6606 AknLayoutScalable_Avkon::area_side_right_pane( 0 ) ).LayoutLine() ); |
|
6607 } |
|
6608 else |
|
6609 { |
|
6610 // We must check for landscape mode bottom SKs |
|
6611 TInt bottomPaneVariety = 1; |
|
6612 |
|
6613 if ( isLandscape ) |
|
6614 { |
|
6615 // In flat iBgContext is used and flat is "landscape". |
|
6616 bottomPaneVariety = 6; |
|
6617 } |
|
6618 |
|
6619 TAknWindowComponentLayout bottomArea( |
|
6620 AknLayoutScalable_Avkon::area_bottom_pane( bottomPaneVariety ) ); |
|
6621 TAknWindowComponentLayout controlPane( |
|
6622 AknLayoutScalable_Avkon::control_pane() ); |
|
6623 controlPane = DoCompose( |
|
6624 applicationWindow, |
|
6625 DoCompose( |
|
6626 bottomArea, controlPane ) ); |
|
6627 cbarect.LayoutRect( screen, controlPane.LayoutLine() ); |
|
6628 } |
|
6629 |
|
6630 TRect cbaRect( cbarect.Rect() ); |
|
6631 |
|
6632 TAknsItemID myIID( iBgIID ); |
|
6633 TAknsItemID maskIID( KAknsIIDNone ); |
|
6634 |
|
6635 if ( AknLayoutUtils::PenEnabled() ) |
|
6636 { |
|
6637 // Widescreen landscape layout or touch portrait. |
|
6638 |
|
6639 // Empty the layers. |
|
6640 for ( TInt i = 0; i < ECbaLayerN; i++ ) |
|
6641 { |
|
6642 iMLBgContext->SetLayerImage( i, KAknsIIDNone ); |
|
6643 } |
|
6644 |
|
6645 TInt currentBgIIDMinor( aIID.iMinor ); |
|
6646 if ( aIID == KAknsIIDNone ) |
|
6647 { |
|
6648 currentBgIIDMinor = iBgIID.iMinor; |
|
6649 } |
|
6650 |
|
6651 // Right pane CBA areas don't have their own skin |
|
6652 // backgrounds, so the screen background is used |
|
6653 // and correct ID is mapped here. |
|
6654 switch ( currentBgIIDMinor ) |
|
6655 { |
|
6656 case EAknsMinorNone: |
|
6657 { |
|
6658 if ( rightPaneActive ) |
|
6659 { |
|
6660 myIID = idleLayout ? KAknsIIDQsnBgScreenIdle : |
|
6661 KAknsIIDQsnBgScreen; |
|
6662 } |
|
6663 else |
|
6664 { |
|
6665 myIID = idleLayout ? KAknsIIDQsnBgAreaControlIdle : |
|
6666 KAknsIIDQsnBgAreaControl; |
|
6667 } |
|
6668 break; |
|
6669 } |
|
6670 case EAknsMinorQsnBgAreaControl: |
|
6671 default: |
|
6672 { |
|
6673 if ( rightPaneActive ) |
|
6674 { |
|
6675 myIID = idleLayout ? KAknsIIDQsnBgScreenIdle : |
|
6676 KAknsIIDQsnBgScreen; |
|
6677 } |
|
6678 else |
|
6679 { |
|
6680 myIID = idleLayout ? KAknsIIDQsnBgAreaControlIdle : |
|
6681 KAknsIIDQsnBgAreaControl; |
|
6682 } |
|
6683 break; |
|
6684 } |
|
6685 case EAknsMinorQsnBgAreaControlPopup: |
|
6686 { |
|
6687 if ( rightPaneActive ) |
|
6688 { |
|
6689 myIID = idleLayout ? KAknsIIDQsnBgScreenIdle : |
|
6690 KAknsIIDQsnBgScreen; |
|
6691 } |
|
6692 else |
|
6693 { |
|
6694 myIID = idleLayout ? KAknsIIDQsnBgAreaControlIdle : |
|
6695 KAknsIIDQsnBgAreaControlPopup; |
|
6696 } |
|
6697 break; |
|
6698 } |
|
6699 case EAknsMinorQsnBgAreaControlIdle: |
|
6700 { |
|
6701 if ( rightPaneActive ) |
|
6702 { |
|
6703 myIID = idleLayout ? KAknsIIDQsnBgScreenIdle : |
|
6704 KAknsIIDQsnBgScreen; |
|
6705 } |
|
6706 else |
|
6707 { |
|
6708 myIID = idleLayout ? KAknsIIDQsnBgAreaControlIdle : |
|
6709 KAknsIIDQsnBgAreaControl; |
|
6710 } |
|
6711 break; |
|
6712 } |
|
6713 case EAknsMinorQsnBgAreaControlMp: |
|
6714 { |
|
6715 myIID = rightPaneActive ? KAknsIIDQsnBgScreenMp : |
|
6716 KAknsIIDQsnBgAreaControlMp; |
|
6717 break; |
|
6718 } |
|
6719 } |
|
6720 if ( idleLayout && iExtension && !( iExtension->iWallpaperInUse == 0 )) |
|
6721 { |
|
6722 maskIID = KAknsIIDQgnIndiSctrlSkMaskRightPrt; |
|
6723 } |
|
6724 else |
|
6725 { |
|
6726 maskIID = rightPaneActive ? KAknsIIDQgnGrafBgLscBottomMaskIcon : |
|
6727 KAknsIIDQgnGrafBgPrtBottomMaskIcon; |
|
6728 } |
|
6729 |
|
6730 if ( idleLayout ) |
|
6731 { |
|
6732 if ( iExtension && iExtension->iWallpaperInUse == 0 ) |
|
6733 { |
|
6734 iMLBgContext->SetLayerImage( ECbaLayerWallpaper, myIID ); |
|
6735 iMLBgContext->SetLayerRect( |
|
6736 ECbaLayerWallpaper, rightPaneActive ? screen : cbaRect ); |
|
6737 } |
|
6738 else |
|
6739 { |
|
6740 iMLBgContext->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
6741 iMLBgContext->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
6742 } |
|
6743 } |
|
6744 else |
|
6745 { |
|
6746 iMLBgContext->SetLayerImage( ECbaLayerWallpaper, KAknsIIDNone ); |
|
6747 maskIID = KAknsIIDNone; |
|
6748 } |
|
6749 |
|
6750 iMLBgContext->SetLayerImage( ECbaLayerBackground, myIID ); |
|
6751 iMLBgContext->SetLayerRect( |
|
6752 ECbaLayerBackground, rightPaneActive ? screen : cbaRect ); |
|
6753 |
|
6754 if (iExtension && |
|
6755 (!(iExtension->iBackgroundMaskID == maskIID && iExtension->iCbaRect == cbaRect) || |
|
6756 iExtension->iIfSkinChanged || |
|
6757 iExtension->iBackgroundMaskID == KAknsIIDNone)) |
|
6758 { |
|
6759 TRAP_IGNORE( iMLBgContext->SetLayerMaskAndSizeL( |
|
6760 maskIID, rightPaneActive ? screen : cbaRect ) ); |
|
6761 iExtension->iBackgroundMaskID = maskIID; |
|
6762 iExtension->iCbaRect = cbaRect; |
|
6763 } |
|
6764 } |
|
6765 else // non-nHD layout |
|
6766 { |
|
6767 if ( idleLayout ) |
|
6768 { |
|
6769 if ( aIID == KAknsIIDNone ) |
|
6770 { |
|
6771 myIID = iBgIID; |
|
6772 } |
|
6773 |
|
6774 iMLBgContext->SetLayerImage( ECbaLayerWallpaper, KAknsIIDWallpaper ); |
|
6775 iMLBgContext->SetLayerRect( ECbaLayerWallpaper, screen ); |
|
6776 iMLBgContext->SetLayerImage( ECbaLayerBackground, myIID ); |
|
6777 iMLBgContext->SetLayerRect( ECbaLayerBackground, cbaRect ); |
|
6778 |
|
6779 if ( isLandscape ) |
|
6780 { |
|
6781 maskIID = KAknsIIDQgnGrafBgLscSideRightMaskIcon; |
|
6782 } |
|
6783 else |
|
6784 { |
|
6785 maskIID = KAknsIIDQgnGrafBgPrtBottomMaskIcon; |
|
6786 } |
|
6787 } |
|
6788 else |
|
6789 { |
|
6790 if ( aIID == KAknsIIDNone ) |
|
6791 { |
|
6792 myIID = KAknsIIDQsnBgAreaControl; |
|
6793 } |
|
6794 |
|
6795 iMLBgContext->SetLayerImage( ECbaLayerBackground, myIID ); |
|
6796 iMLBgContext->SetLayerImage( ECbaLayerWallpaper, KAknsIIDNone ); |
|
6797 iMLBgContext->SetLayerRect( ECbaLayerBackground, cbaRect ); |
|
6798 } |
|
6799 |
|
6800 TRAP_IGNORE( iMLBgContext->SetLayerMaskAndSizeL( maskIID, cbaRect ) ); |
|
6801 } |
|
6802 |
|
6803 DrawDeferred(); |
|
6804 } |
|
6805 |
|
6806 |
|
6807 void CEikCba::LayoutControl( CCoeControl* aControl, const TRect& aRect ) |
|
6808 { |
|
6809 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
6810 { |
|
6811 TRect rect( aRect ); |
|
6812 // aid_value_unit2 is 10ux10u rectangle. |
|
6813 TAknWindowComponentLayout unit( AknLayoutScalable_Avkon::aid_value_unit2() ); |
|
6814 // Move 0.5 units to right and down. |
|
6815 TInt delta = unit.LayoutLine().iW / 10 / 2; |
|
6816 if ( ( (CEikCbaButton*)aControl )->PressedDown() ) |
|
6817 { |
|
6818 rect.Move( delta, delta ); |
|
6819 } |
|
6820 aControl->SetRect( rect ); |
|
6821 aControl->ComponentControl( 0 )->SetRect( rect ); |
|
6822 } |
|
6823 } |
|
6824 |
|
6825 void CEikCba::BroadcastPostingTransparency( TBool aEnable ) |
|
6826 { |
|
6827 // Communicate change to CBA buttons. |
|
6828 for ( TInt i = 0; i < iControlArray->Count(); i++ ) |
|
6829 { |
|
6830 if ( i != KControlArrayScrollBarPosn ) // To avoid tinkering with scrollbar. |
|
6831 { |
|
6832 TEikGroupControl& gCtrl = iControlArray->At( i ); |
|
6833 CEikCbaButton* button = dynamic_cast<CEikCbaButton*>( gCtrl.iControl ); |
|
6834 if ( button ) |
|
6835 { |
|
6836 button->SetTextBitmapMode( aEnable ); |
|
6837 } |
|
6838 } |
|
6839 } |
|
6840 } |
|
6841 |
|
6842 |
|
6843 // --------------------------------------------------------------------------- |
|
6844 // CEikCba::SetFadeState |
|
6845 // Sets the CBA faded if it's contents are empty. |
|
6846 // --------------------------------------------------------------------------- |
|
6847 // |
|
6848 void CEikCba::SetFadeState() |
|
6849 { |
|
6850 TBool canBeFaded = |
|
6851 IsEmpty() && !( ( iCbaFlags & EEikCbaFlagTransparent ) |
|
6852 || ( iExtension && iExtension->iEnablePostingTransparency ) ); |
|
6853 |
|
6854 // No unfading when system is faded |
|
6855 if ( !( !canBeFaded |
|
6856 && static_cast<CAknAppUi*>( iCoeEnv->AppUi() )->IsFaded() ) ) |
|
6857 { |
|
6858 Window().SetFaded( canBeFaded, RWindowTreeNode::EFadeIncludeChildren ); |
|
6859 } |
|
6860 } |
|
6861 |
|
6862 |
|
6863 // --------------------------------------------------------------------------- |
|
6864 // CEikCba::UpdateLabels |
|
6865 // Updates softkey labels in case of embedded softkeys. |
|
6866 // --------------------------------------------------------------------------- |
|
6867 // |
|
6868 void CEikCba::UpdateLabels( TBool aDrawDeferred ) |
|
6869 { |
|
6870 if ( iControlArray->Count() != 0) |
|
6871 { |
|
6872 CCoeControl *leftSoftkey = ( *iControlArray ) |
|
6873 [ KControlArrayCBAButton1Posn ].iControl; |
|
6874 CCoeControl *rightSoftkey = ( *iControlArray ) |
|
6875 [ KControlArrayCBAButton2Posn ].iControl; |
|
6876 |
|
6877 if ( !( ( ( CEikCbaButton* ) leftSoftkey )->IsImageOn() ) ) |
|
6878 { |
|
6879 TAknTextLineLayout textLayout( |
|
6880 AknLayoutScalable_Avkon::popup_sk_window_t1( 0 ).LayoutLine() ); |
|
6881 |
|
6882 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
6883 { |
|
6884 textLayout.iFont |= KOutlineFontMask; |
|
6885 } |
|
6886 |
|
6887 AknLayoutUtils::LayoutLabel( ( CEikLabel* ) |
|
6888 leftSoftkey->ComponentControl( 0 ), |
|
6889 Rect(), |
|
6890 textLayout ); |
|
6891 |
|
6892 LayoutControl( (CEikCbaButton*)leftSoftkey, |
|
6893 leftSoftkey->ComponentControl( 0 )->Rect() ); |
|
6894 ((CEikCbaButton*)leftSoftkey)->TruncateLabelText(); |
|
6895 } |
|
6896 |
|
6897 if ( !( ( ( CEikCbaButton* ) rightSoftkey )->IsImageOn() ) ) |
|
6898 { |
|
6899 TAknTextLineLayout textLayout( |
|
6900 AknLayoutScalable_Avkon::popup_sk_window_t1_copy1( 0 ).LayoutLine() ); |
|
6901 |
|
6902 if ( iCbaFlags & EEikCbaFlagOutlineFont ) |
|
6903 { |
|
6904 textLayout.iFont |= KOutlineFontMask; |
|
6905 } |
|
6906 AknLayoutUtils::LayoutLabel((CEikLabel*) |
|
6907 rightSoftkey->ComponentControl( 0 ), |
|
6908 Rect(), |
|
6909 textLayout ); |
|
6910 LayoutControl( (CEikCbaButton*)rightSoftkey, |
|
6911 rightSoftkey->ComponentControl( 0 )->Rect() ); |
|
6912 ((CEikCbaButton*)rightSoftkey)->TruncateLabelText(); |
|
6913 } |
|
6914 |
|
6915 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
6916 |
|
6917 TRgb leftColor; |
|
6918 TRgb rightColor; |
|
6919 |
|
6920 TInt errorl; |
|
6921 TInt errorr; |
|
6922 |
|
6923 if ( iPopupVisible ) |
|
6924 { |
|
6925 errorl = AknsUtils::GetCachedColor( |
|
6926 skin, |
|
6927 leftColor, |
|
6928 KAknsIIDQsnTextColors, |
|
6929 EAknsCIQsnTextColorsCG17 ); |
|
6930 |
|
6931 errorr = AknsUtils::GetCachedColor( |
|
6932 skin, |
|
6933 rightColor, |
|
6934 KAknsIIDQsnTextColors, |
|
6935 EAknsCIQsnTextColorsCG18 ); |
|
6936 } |
|
6937 else |
|
6938 { |
|
6939 errorl = AknsUtils::GetCachedColor( |
|
6940 skin, |
|
6941 leftColor, |
|
6942 KAknsIIDQsnTextColors, |
|
6943 EAknsCIQsnTextColorsCG13 ); |
|
6944 |
|
6945 errorr = AknsUtils::GetCachedColor( |
|
6946 skin, |
|
6947 rightColor, |
|
6948 KAknsIIDQsnTextColors, |
|
6949 EAknsCIQsnTextColorsCG14 ); |
|
6950 } |
|
6951 |
|
6952 if ( ((CEikCbaButton*)leftSoftkey)->PressedDown() ) |
|
6953 { |
|
6954 leftColor.SetAlpha( KPressedDownAlphaValue ); |
|
6955 |
|
6956 AknsUtils::GetCachedColor( |
|
6957 skin, |
|
6958 leftColor, |
|
6959 KAknsIIDQsnTextColors, |
|
6960 EAknsCIQsnTextColorsCG69 ); |
|
6961 } |
|
6962 else if ( ((CEikCbaButton*)rightSoftkey)->PressedDown() ) |
|
6963 { |
|
6964 rightColor.SetAlpha( KPressedDownAlphaValue ); |
|
6965 |
|
6966 AknsUtils::GetCachedColor( |
|
6967 skin, |
|
6968 rightColor, |
|
6969 KAknsIIDQsnTextColors, |
|
6970 EAknsCIQsnTextColorsCG69 ); |
|
6971 } |
|
6972 |
|
6973 if( !errorl && !errorr ) |
|
6974 { |
|
6975 // Error ignored |
|
6976 TRAP( errorl, AknLayoutUtils::OverrideControlColorL( |
|
6977 *leftSoftkey, |
|
6978 EColorLabelText, |
|
6979 leftColor) ); |
|
6980 |
|
6981 TRAP( errorr, AknLayoutUtils::OverrideControlColorL( |
|
6982 *rightSoftkey, |
|
6983 EColorLabelText, |
|
6984 rightColor) ); |
|
6985 } |
|
6986 |
|
6987 if ( aDrawDeferred ) |
|
6988 { |
|
6989 DrawDeferred(); |
|
6990 } |
|
6991 } |
|
6992 } |
|
6993 |
|
6994 |
|
6995 // ----------------------------------------------------------------------------- |
|
6996 // EikSoftkeyPostingTransparency::MakeTransparent |
|
6997 // ----------------------------------------------------------------------------- |
|
6998 // |
|
6999 EXPORT_C TInt EikSoftkeyPostingTransparency::MakeTransparent( |
|
7000 CEikButtonGroupContainer& aButtonGroupContainer, |
|
7001 TBool aEnable ) |
|
7002 { |
|
7003 CEikCba* cba = dynamic_cast<CEikCba*>( aButtonGroupContainer.ButtonGroup() ); |
|
7004 TInt ret = KErrNone; |
|
7005 if ( cba ) |
|
7006 { |
|
7007 if ( aEnable && ( cba->ButtonGroupFlags() & EEikCbaFlagTransparent ) ) |
|
7008 { |
|
7009 // EikSoftkeyPostingTransparency is not supported if |
|
7010 // EEikCbaFlagTransparent is enabled |
|
7011 ret = KErrArgument; |
|
7012 } |
|
7013 else |
|
7014 { |
|
7015 cba->EnablePostingTransparency( aEnable ); |
|
7016 } |
|
7017 } |
|
7018 return ret; |
|
7019 } |
|
7020 |
|
7021 // ----------------------------------------------------------------------------- |
|
7022 // CEikCba::EnablePostingTransparency |
|
7023 // |
|
7024 // ----------------------------------------------------------------------------- |
|
7025 // |
|
7026 void CEikCba::EnablePostingTransparency( TBool aEnable ) |
|
7027 { |
|
7028 if ( iExtension ) |
|
7029 { |
|
7030 if ( iExtension->iEnablePostingTransparency != aEnable ) |
|
7031 { |
|
7032 iExtension->iEnablePostingTransparency = aEnable; |
|
7033 |
|
7034 UpdateFonts(); |
|
7035 |
|
7036 if ( !aEnable ) |
|
7037 { |
|
7038 delete iExtension->iLskPostingOverlayBitmap; |
|
7039 iExtension->iLskPostingOverlayBitmap = NULL; |
|
7040 delete iExtension->iRskPostingOverlayBitmap; |
|
7041 iExtension->iRskPostingOverlayBitmap = NULL; |
|
7042 |
|
7043 // Update label text color. SizeChanged |
|
7044 // will not call BroadcastPostingTransparency in this case. |
|
7045 // It has to be called directly from here. |
|
7046 SizeChanged(); |
|
7047 |
|
7048 BroadcastPostingTransparency( EFalse ); |
|
7049 } |
|
7050 else |
|
7051 { |
|
7052 // Update background bitmaps. SizeChanged |
|
7053 // will also call BroadcastPostingTransparency. |
|
7054 SizeChanged(); |
|
7055 } |
|
7056 |
|
7057 DrawDeferred(); |
|
7058 } |
|
7059 } |
|
7060 } |
|
7061 |
|
7062 |
|
7063 // --------------------------------------------------------------------------- |
|
7064 // CEikCba::IsEmpty |
|
7065 // Checks if the CBA has no commands. |
|
7066 // --------------------------------------------------------------------------- |
|
7067 // |
|
7068 EXPORT_C TBool CEikCba::IsEmpty() const |
|
7069 { |
|
7070 TBool isEmpty( ETrue ); |
|
7071 |
|
7072 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
7073 { |
|
7074 // Not supported for full screen query. |
|
7075 isEmpty = EFalse; |
|
7076 } |
|
7077 else |
|
7078 { |
|
7079 for ( TInt i = 0; i < iControlArray->Count(); i++ ) |
|
7080 { |
|
7081 if ( i != KControlArrayScrollBarPosn ) // Do not take scrollbar into account. |
|
7082 { |
|
7083 TEikGroupControl& gCtrl = iControlArray->At( i ); |
|
7084 if ( gCtrl.iId != EEikBidBlank && |
|
7085 gCtrl.iId != EAknSoftkeyEmpty && |
|
7086 ( gCtrl.iId < 0 || gCtrl.iId > 2 ) ) |
|
7087 { |
|
7088 isEmpty = EFalse; |
|
7089 } |
|
7090 else |
|
7091 { |
|
7092 if ( gCtrl.iControl && |
|
7093 ( !(static_cast<CEikCbaButton*>(gCtrl.iControl))->IsEmptyText() |
|
7094 || (static_cast<CEikCbaButton*>(gCtrl.iControl))->IsImageOn() ) |
|
7095 ) |
|
7096 { |
|
7097 isEmpty = EFalse; |
|
7098 } |
|
7099 } |
|
7100 } |
|
7101 } |
|
7102 } |
|
7103 |
|
7104 return isEmpty; |
|
7105 } |
|
7106 |
|
7107 |
|
7108 // --------------------------------------------------------------------------- |
|
7109 // CEikCba::Flags |
|
7110 // Returns flags. |
|
7111 // --------------------------------------------------------------------------- |
|
7112 // |
|
7113 TBitFlags CEikCba::Flags() |
|
7114 { |
|
7115 return iFlags; |
|
7116 } |
|
7117 |
|
7118 |
|
7119 // --------------------------------------------------------------------------- |
|
7120 // CEikCba::SetContentObserver |
|
7121 // Sets content observer. |
|
7122 // --------------------------------------------------------------------------- |
|
7123 // |
|
7124 void CEikCba::SetContentObserver( TCallBack aCallBack ) |
|
7125 { |
|
7126 if ( iExtension ) |
|
7127 { |
|
7128 iExtension->iContentObserver = aCallBack; |
|
7129 } |
|
7130 } |
|
7131 |
|
7132 |
|
7133 // --------------------------------------------------------------------------- |
|
7134 // CEikCba::ReportContentChangedEvent |
|
7135 // Reports state changed event if cba changed from empty to non-empty |
|
7136 // or vice versa. |
|
7137 // --------------------------------------------------------------------------- |
|
7138 // |
|
7139 void CEikCba::ReportContentChangedEvent() |
|
7140 { |
|
7141 if ( ItemSpecificSoftkey() ) |
|
7142 { |
|
7143 UpdateItemSpecificSoftkey( |
|
7144 iExtension->Active() && !Window().IsFaded() ); |
|
7145 } |
|
7146 |
|
7147 if ( !iFlags.IsSet( ECbaEmbedded ) ) |
|
7148 { |
|
7149 return; |
|
7150 } |
|
7151 |
|
7152 TBool isEmpty( !IsVisible() || IsEmpty() ); |
|
7153 TBool reportStateChanged( EFalse ); |
|
7154 if ( !isEmpty && !iFlags.IsSet( ECbaHasContent ) ) |
|
7155 { |
|
7156 reportStateChanged = ETrue; |
|
7157 iFlags.Set( ECbaHasContent ); |
|
7158 } |
|
7159 else if ( isEmpty && iFlags.IsSet( ECbaHasContent ) ) |
|
7160 { |
|
7161 reportStateChanged = ETrue; |
|
7162 iFlags.Clear( ECbaHasContent ); |
|
7163 } |
|
7164 |
|
7165 // Report state changed event if changed from empty to non-empty |
|
7166 // or vice versa. Dialog knows to increase its height so that |
|
7167 // also cba is visible |
|
7168 if ( reportStateChanged ) |
|
7169 { |
|
7170 Window().Invalidate(); |
|
7171 if ( iExtension && iExtension->iContentObserver.iFunction ) |
|
7172 { |
|
7173 iExtension->iContentObserver.CallBack(); // return value ignored |
|
7174 } |
|
7175 } |
|
7176 } |
|
7177 |
|
7178 // --------------------------------------------------------------------------- |
|
7179 // CEikCba::DrawEmbeddedSoftkey |
|
7180 // Draws embedded softkey |
|
7181 // --------------------------------------------------------------------------- |
|
7182 // |
|
7183 void CEikCba::DrawEmbeddedSoftkey( TEikGroupControl& aGroupControl, |
|
7184 const TRect& aRect, |
|
7185 CWindowGc& aGc, |
|
7186 CFbsBitmap* /*aMask*/ ) const |
|
7187 { |
|
7188 CEikCbaButton* button = |
|
7189 static_cast<CEikCbaButton*>( aGroupControl.iControl ); |
|
7190 |
|
7191 TAknLayoutRect layoutRect; |
|
7192 TRect innerRect; |
|
7193 layoutRect.LayoutRect( aRect, |
|
7194 AknLayoutScalable_Avkon::bg_sctrl_sk_pane_g1() |
|
7195 .LayoutLine() ); |
|
7196 innerRect = layoutRect.Rect(); |
|
7197 |
|
7198 |
|
7199 if( button->PressedDown() ) // draw PressedFrame |
|
7200 { |
|
7201 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
7202 aGc, |
|
7203 aRect, |
|
7204 innerRect, |
|
7205 KAknsIIDQgnFrSctrlSkButtonPressed, |
|
7206 KAknsIIDQgnFrSctrlSkButtonCenterPressed ); |
|
7207 } |
|
7208 else // draw Frame |
|
7209 { |
|
7210 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
7211 aGc, |
|
7212 aRect, |
|
7213 innerRect, |
|
7214 KAknsIIDQgnFrSctrlSkButton, |
|
7215 KAknsIIDQgnFrSctrlSkButtonCenter); |
|
7216 } |
|
7217 } |
|
7218 |
|
7219 TBool CEikCba::UpdateIconL() |
|
7220 { |
|
7221 if ( iFlags.IsSet( ECbaInsideDialog ) ) |
|
7222 { |
|
7223 return EFalse; |
|
7224 } |
|
7225 |
|
7226 if ( !iExtension->iIfMskIconSet || |
|
7227 !MskAllowed() ) |
|
7228 { |
|
7229 return EFalse; |
|
7230 } |
|
7231 |
|
7232 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
7233 if ( !skin ) |
|
7234 { |
|
7235 return EFalse; |
|
7236 } |
|
7237 |
|
7238 TEikGroupControl &gCtrl = iControlArray->At( KControlArrayCBAButtonMSKPosn ); |
|
7239 |
|
7240 CEikCbaButton *button = static_cast<CEikCbaButton*>( gCtrl.iControl ); |
|
7241 if ( !button ) |
|
7242 { |
|
7243 return EFalse; |
|
7244 } |
|
7245 |
|
7246 CFbsBitmap *bitmap = NULL; |
|
7247 CFbsBitmap *mask = NULL; |
|
7248 |
|
7249 TAknLayoutRect qgn_graf_sk_msk; |
|
7250 TRect rect; |
|
7251 qgn_graf_sk_msk.LayoutRect( |
|
7252 rect, |
|
7253 AknLayoutScalable_Avkon::control_pane_g4( 0 ).LayoutLine() ); |
|
7254 |
|
7255 TSize iconSize( qgn_graf_sk_msk.Rect().Width(), |
|
7256 qgn_graf_sk_msk.Rect().Height() ); |
|
7257 |
|
7258 AknsUtils::CreateIconL( |
|
7259 skin, |
|
7260 iExtension->iMSKSkinID, |
|
7261 bitmap, |
|
7262 mask, |
|
7263 *iExtension->iBmpFile, |
|
7264 iExtension->iBmp, |
|
7265 iExtension->iBmpM ); |
|
7266 |
|
7267 if ( bitmap ) // Bitmap not set -> do not use image. |
|
7268 { |
|
7269 AknIconUtils::DisableCompression( bitmap ); |
|
7270 AknIconUtils::DisableCompression( mask ); |
|
7271 AknIconUtils::SetSize( bitmap, iconSize ); |
|
7272 CEikImage* image = new (ELeave) CEikImage; |
|
7273 image->SetPicture( bitmap, mask ); |
|
7274 |
|
7275 // Transfers ownership of the image (image owns bitmap and mask). |
|
7276 button->SetImage( *image ); |
|
7277 |
|
7278 SizeChanged(); |
|
7279 |
|
7280 button->DrawNow(); |
|
7281 } |
|
7282 else |
|
7283 { |
|
7284 button->ReplaceImageByLabel(); // remove old image |
|
7285 } |
|
7286 |
|
7287 button->SetContainerWindowL( *this ); |
|
7288 |
|
7289 return ETrue; |
|
7290 |
|
7291 } |
|
7292 |
|
7293 |
|
7294 // --------------------------------------------------------------------------- |
|
7295 // Checks if the middle softkey should be used. |
|
7296 // Should be used with the SetMSKVisibility-method to set MSK visibility |
|
7297 // when on layout changes etc. |
|
7298 // --------------------------------------------------------------------------- |
|
7299 // |
|
7300 TBool CEikCba::MskAllowed() const |
|
7301 { |
|
7302 return ( iMSKEnabledInPlatform && |
|
7303 AknLayoutUtils::MSKEnabled() && |
|
7304 IsMskEnabledLayoutActive() ); |
|
7305 } |
|
7306 |
|
7307 |
|
7308 // --------------------------------------------------------------------------- |
|
7309 // CEikCba::SoftkeyStatusChangeAllowed |
|
7310 // Returns ETrue if softkey status change is allowed. |
|
7311 // --------------------------------------------------------------------------- |
|
7312 // |
|
7313 TBool CEikCba::SoftkeyStatusChangeAllowed( |
|
7314 TInt aSoftkeyPosition, TBool aDisabled ) |
|
7315 { |
|
7316 TBool allowChange( ETrue ); |
|
7317 if ( aSoftkeyPosition == KControlArrayCBAButton1Posn ) |
|
7318 { |
|
7319 if ( aDisabled ) |
|
7320 { |
|
7321 iFlags.Set( ECbaItemSoftkeyDisabledByClient ); |
|
7322 } |
|
7323 else |
|
7324 { |
|
7325 iFlags.Clear( ECbaItemSoftkeyDisabledByClient ); |
|
7326 if ( iFlags.IsSet( ECbaItemSoftkeyDisabled ) ) |
|
7327 { |
|
7328 allowChange = EFalse; |
|
7329 } |
|
7330 } |
|
7331 } |
|
7332 return allowChange; |
|
7333 } |
|
7334 |
|
7335 |
|
7336 // --------------------------------------------------------------------------- |
|
7337 // CEikCba::ItemSpecificSoftkey |
|
7338 // Returns item specific softkey control if it state should be updated. |
|
7339 // --------------------------------------------------------------------------- |
|
7340 // |
|
7341 TEikGroupControl* CEikCba::ItemSpecificSoftkey() const |
|
7342 { |
|
7343 TEikGroupControl* lsk( NULL ); |
|
7344 if ( iFlags.IsSet( ECbaItemSpecificSoftkeyInUse ) ) |
|
7345 { |
|
7346 TEikGroupControl& leftSoftkey = |
|
7347 ( *iControlArray ) [ KControlArrayCBAButton1Posn ]; |
|
7348 if ( leftSoftkey.iId != EAknSoftkeyOptions |
|
7349 || iFlags.IsSet( ECbaItemSoftkeyDisabled ) ) |
|
7350 { |
|
7351 lsk = &leftSoftkey; |
|
7352 } |
|
7353 } |
|
7354 return lsk; |
|
7355 } |
|
7356 |
|
7357 |
|
7358 // --------------------------------------------------------------------------- |
|
7359 // CEikCba::UpdateItemSpecificSoftkey |
|
7360 // Updates item specific softkey. |
|
7361 // --------------------------------------------------------------------------- |
|
7362 // |
|
7363 void CEikCba::UpdateItemSpecificSoftkey( TBool aVisibleCollection ) |
|
7364 { |
|
7365 if ( iFlags.IsSet( ECbaSingleClickEnabled ) |
|
7366 && iExtension && iExtension->iItemActionMenu ) |
|
7367 { |
|
7368 TEikGroupControl* leftSk = ItemSpecificSoftkey(); |
|
7369 if ( leftSk ) |
|
7370 { |
|
7371 TBool enableSk( leftSk->iId == EAknSoftkeyOptions || |
|
7372 iExtension->iItemActionMenu->CollectionSoftkeyVisible( |
|
7373 aVisibleCollection ) ); |
|
7374 UpdateItemSpecificSoftkey( *leftSk->iControl, enableSk ); |
|
7375 } |
|
7376 } |
|
7377 } |
|
7378 |
|
7379 |
|
7380 // --------------------------------------------------------------------------- |
|
7381 // CEikCba::UpdateItemSpecificSoftkey |
|
7382 // Updates item specific softkey. |
|
7383 // --------------------------------------------------------------------------- |
|
7384 // |
|
7385 void CEikCba::UpdateItemSpecificSoftkey( CCoeControl& aControl, TBool aEnable ) |
|
7386 { |
|
7387 TBool skEnabled( aControl.IsVisible() && !aControl.IsDimmed() ); |
|
7388 TBool changeState( EFalse ); |
|
7389 if ( !aEnable ) |
|
7390 { |
|
7391 iFlags.Set( ECbaItemSoftkeyDisabled ); |
|
7392 if ( skEnabled ) |
|
7393 { |
|
7394 changeState = ETrue; |
|
7395 } |
|
7396 } |
|
7397 else |
|
7398 { |
|
7399 iFlags.Clear( ECbaItemSoftkeyDisabled ); |
|
7400 if ( !skEnabled |
|
7401 && iFlags.IsClear( ECbaItemSoftkeyDisabledByClient ) ) |
|
7402 { |
|
7403 changeState = ETrue; |
|
7404 } |
|
7405 } |
|
7406 if ( changeState ) |
|
7407 { |
|
7408 if ( !iFlags.IsSet( ECbaInsideDialog ) ) |
|
7409 { |
|
7410 aControl.MakeVisible( aEnable ); |
|
7411 } |
|
7412 else |
|
7413 { |
|
7414 aControl.SetDimmed( !aEnable ); |
|
7415 aControl.DrawDeferred(); |
|
7416 } |
|
7417 } |
|
7418 } |
|
7419 |
|
7420 |
|
7421 // |
|
7422 // class CEikCbaButton |
|
7423 // |
|
7424 |
|
7425 CEikCbaButton::~CEikCbaButton() |
|
7426 { |
|
7427 AKNTASHOOK_REMOVE(); |
|
7428 delete iLabel; |
|
7429 if ( iImage ) |
|
7430 { |
|
7431 iImage->SetMask( iMask ); |
|
7432 } |
|
7433 delete iImage; |
|
7434 delete iSfeMask; |
|
7435 delete iButtonOptions; |
|
7436 delete iText; |
|
7437 |
|
7438 } |
|
7439 |
|
7440 void CEikCbaButton::ConstructL(TGulAlignmentValue aAlignment) |
|
7441 { |
|
7442 iLabel = new(ELeave) CEikLabel; |
|
7443 iPressedDown = EFalse; |
|
7444 iLabel->SetBufferReserveLengthL(KMaxCbaLabelLength); |
|
7445 UpdateLabelText(TPtrC()); |
|
7446 iLabel->SetAlignment(aAlignment); |
|
7447 |
|
7448 iButtonOptions = new(ELeave) CArrayFixFlat<SButtonOptions>(1); |
|
7449 iText = new(ELeave) CDesCArrayFlat(1); |
|
7450 |
|
7451 if ( iUseTextBitmap ) |
|
7452 { |
|
7453 iLabel->MakeVisible( EFalse ); |
|
7454 } |
|
7455 AKNTASHOOK_ADDL( this, "CEikCbaButton" ); |
|
7456 } |
|
7457 |
|
7458 void CEikCbaButton::AddCommandL(const TDesC& aText) |
|
7459 { |
|
7460 UpdateLabelText(aText); |
|
7461 } |
|
7462 |
|
7463 struct STempCleanup |
|
7464 { |
|
7465 CDesCArray* iText; |
|
7466 CArrayFix<CEikCbaButton::SButtonOptions>* iButtonOptions; |
|
7467 }; |
|
7468 |
|
7469 LOCAL_C void CleanupTemp(TAny* aPtr) |
|
7470 { |
|
7471 STempCleanup& temp = *(STempCleanup*)aPtr; |
|
7472 const TInt count = temp.iText->Count(); |
|
7473 if (temp.iButtonOptions->Count() == count) |
|
7474 { |
|
7475 temp.iButtonOptions->Delete(count - 1); |
|
7476 } |
|
7477 temp.iText->Delete(count - 1); |
|
7478 } |
|
7479 |
|
7480 void CEikCbaButton::PushCommandL(TInt aCommandId,const TDesC& aText) |
|
7481 { |
|
7482 if (!iButtonOptions) |
|
7483 { |
|
7484 iButtonOptions = new(ELeave) CArrayFixFlat<SButtonOptions>(1); |
|
7485 } |
|
7486 if (!iText) |
|
7487 { |
|
7488 iText = new(ELeave) CDesCArrayFlat(1); |
|
7489 } |
|
7490 |
|
7491 iText->AppendL(iFullLabelText); |
|
7492 |
|
7493 STempCleanup temp; |
|
7494 SButtonOptions options; |
|
7495 temp.iText = iText; |
|
7496 temp.iButtonOptions = iButtonOptions; |
|
7497 CleanupStack::PushL(TCleanupItem(CleanupTemp,&temp)); |
|
7498 options.iCommandId = aCommandId; |
|
7499 options.iDimmed = iLabel->IsDimmed(); |
|
7500 iLabel->SetDimmed(EFalse); |
|
7501 iButtonOptions->AppendL(options); |
|
7502 UpdateLabelText(aText); |
|
7503 CleanupStack::Pop(); // temp |
|
7504 } |
|
7505 |
|
7506 TInt CEikCbaButton::PopCommand() |
|
7507 { |
|
7508 if (!iButtonOptions) |
|
7509 { |
|
7510 return -1; |
|
7511 } |
|
7512 |
|
7513 TInt count = iButtonOptions->Count(); |
|
7514 --count; |
|
7515 |
|
7516 if (count < 0) |
|
7517 { |
|
7518 return -1; |
|
7519 } |
|
7520 |
|
7521 const SButtonOptions buttonOptions = (*iButtonOptions)[count]; |
|
7522 iButtonOptions->Delete(count); |
|
7523 TPtrC text = (*iText)[count]; |
|
7524 UpdateLabelText(text); |
|
7525 iText->Delete(count); |
|
7526 if (iButtonOptions->Count() == 0) |
|
7527 { |
|
7528 delete iButtonOptions; |
|
7529 iButtonOptions = NULL; |
|
7530 delete iText; |
|
7531 iText = NULL; |
|
7532 } |
|
7533 iLabel->SetDimmed(buttonOptions.iDimmed); |
|
7534 if (!iDoImage) |
|
7535 { |
|
7536 iLabel->DrawDeferred(); |
|
7537 } |
|
7538 else |
|
7539 { |
|
7540 iImage->DrawNow(); |
|
7541 } |
|
7542 return buttonOptions.iCommandId; |
|
7543 } |
|
7544 |
|
7545 void CEikCbaButton::RemoveCommand(TInt aCommandId) |
|
7546 { |
|
7547 if (!iButtonOptions) |
|
7548 { |
|
7549 return; |
|
7550 } |
|
7551 TInt index = IndexFromCommandId(aCommandId); |
|
7552 if (index != KErrNotFound) |
|
7553 { |
|
7554 iButtonOptions->Delete(index); |
|
7555 iText->Delete(index); |
|
7556 if (iButtonOptions->Count() == 0) |
|
7557 { |
|
7558 delete iButtonOptions; |
|
7559 iButtonOptions = NULL; |
|
7560 delete iText; |
|
7561 iText = NULL; |
|
7562 } |
|
7563 } |
|
7564 } |
|
7565 |
|
7566 void CEikCbaButton::RemovePreviousCommand() |
|
7567 { |
|
7568 if (!iButtonOptions) |
|
7569 { |
|
7570 return; |
|
7571 } |
|
7572 TInt index = iButtonOptions->Count() - 2; |
|
7573 if (index >= 0) |
|
7574 { |
|
7575 iButtonOptions->Delete(index); |
|
7576 iText->Delete(index); |
|
7577 } |
|
7578 } |
|
7579 |
|
7580 TInt CEikCbaButton::IndexFromCommandId(TInt aCommandId) |
|
7581 { |
|
7582 TInt index; |
|
7583 TKeyArrayFix key(0, ECmpTInt); |
|
7584 SButtonOptions options; |
|
7585 options.iCommandId = aCommandId; |
|
7586 if (iButtonOptions->Find(options, key, index) == KErrNone) |
|
7587 { |
|
7588 return index; |
|
7589 } |
|
7590 else |
|
7591 { |
|
7592 return KErrNotFound; |
|
7593 } |
|
7594 } |
|
7595 |
|
7596 void CEikCbaButton::SetContainerWindowL(const CCoeControl& aContainer) |
|
7597 { |
|
7598 CCoeControl::SetContainerWindowL(aContainer); |
|
7599 if (!iDoImage) |
|
7600 { |
|
7601 iLabel->SetContainerWindowL(aContainer); |
|
7602 } |
|
7603 else |
|
7604 { |
|
7605 iImage->SetContainerWindowL(aContainer); |
|
7606 } |
|
7607 } |
|
7608 |
|
7609 void CEikCbaButton::ConstructFromResourceL(TResourceReader& aReader, TGulAlignmentValue anAlignment) |
|
7610 { |
|
7611 ConstructL(anAlignment); |
|
7612 UpdateLabelText(aReader.ReadTPtrC()); |
|
7613 aReader.ReadTPtrC(); // bmp filename |
|
7614 aReader.ReadInt16(); // bmp id |
|
7615 aReader.ReadInt16(); // bmp mask id |
|
7616 } |
|
7617 |
|
7618 TSize CEikCbaButton::MinimumSize() |
|
7619 { |
|
7620 if (!iDoImage) |
|
7621 { |
|
7622 return iLabel->MinimumSize(); |
|
7623 } |
|
7624 else |
|
7625 { |
|
7626 return iImage->MinimumSize(); |
|
7627 } |
|
7628 } |
|
7629 |
|
7630 TInt CEikCbaButton::CountComponentControls() const |
|
7631 { |
|
7632 return 1; |
|
7633 } |
|
7634 |
|
7635 CCoeControl* CEikCbaButton::ComponentControl(TInt aIndex) const |
|
7636 { |
|
7637 if (aIndex==0) |
|
7638 { |
|
7639 if (!iDoImage) |
|
7640 { |
|
7641 return iLabel; |
|
7642 } |
|
7643 else |
|
7644 { |
|
7645 // If SfeMask is available, then check the effect state (iPressedDown). |
|
7646 if ( iSfeMask ) |
|
7647 { |
|
7648 if ( iPressedDown ) |
|
7649 { |
|
7650 iImage->SetMask( iSfeMask ); |
|
7651 } |
|
7652 else |
|
7653 { |
|
7654 iImage->SetMask( iMask ); |
|
7655 } |
|
7656 } |
|
7657 return iImage; |
|
7658 } |
|
7659 } |
|
7660 return 0; |
|
7661 } |
|
7662 |
|
7663 |
|
7664 // --------------------------------------------------------------------------- |
|
7665 // Handles size change events for CBA button. |
|
7666 // --------------------------------------------------------------------------- |
|
7667 // |
|
7668 void CEikCbaButton::SizeChanged() |
|
7669 { |
|
7670 // Resizing is done at CEikCba::SizeChanged(). |
|
7671 // We cannot resize here because this control has wrong |
|
7672 // coordinate system available. |
|
7673 |
|
7674 } |
|
7675 |
|
7676 |
|
7677 EXPORT_C void CEikCbaButton::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
7678 { |
|
7679 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
7680 } |
|
7681 |
|
7682 EXPORT_C void* CEikCbaButton::ExtensionInterface( TUid /*aInterface*/ ) |
|
7683 { |
|
7684 return NULL; |
|
7685 } |
|
7686 |
|
7687 void CEikCbaButton::SetDimmed(TBool aDimmed) |
|
7688 { |
|
7689 CCoeControl::SetDimmed(aDimmed); |
|
7690 if (!iDoImage) |
|
7691 { |
|
7692 iLabel->SetDimmed(aDimmed); |
|
7693 } |
|
7694 else |
|
7695 { |
|
7696 // Drawing dimmed CEikImages don't work (problem in uiklaf). |
|
7697 //iImage->SetDimmed(aDimmed); |
|
7698 } |
|
7699 } |
|
7700 |
|
7701 |
|
7702 // --------------------------------------------------------------------------- |
|
7703 // Updates the softkey label. |
|
7704 // --------------------------------------------------------------------------- |
|
7705 // |
|
7706 void CEikCbaButton::UpdateLabelText( TPtrC aLabelText ) |
|
7707 { |
|
7708 // Updates the label text with the given label, using tab delimited |
|
7709 // label text to identify normal / alternative labels. |
|
7710 if ( aLabelText.Length() > KMaxCbaLabelLength ) |
|
7711 { |
|
7712 // Cannot take more chars than maximum buffer size. |
|
7713 iFullLabelText.Copy( aLabelText.Left( KMaxCbaLabelLength ) ); |
|
7714 } |
|
7715 else |
|
7716 { |
|
7717 iFullLabelText.Copy( aLabelText ); |
|
7718 } |
|
7719 |
|
7720 TInt find = aLabelText.Locate( CEditableText::ETabCharacter ); |
|
7721 if ( find == KErrNotFound ) |
|
7722 { |
|
7723 iLongLabelText.Set( iFullLabelText ); |
|
7724 iShortLabelText.Set( iFullLabelText ); |
|
7725 } |
|
7726 else |
|
7727 { |
|
7728 iLongLabelText.Set( iFullLabelText.Left( find ) ); |
|
7729 iShortLabelText.Set( |
|
7730 iFullLabelText.Right( aLabelText.Length() - find - 1 ) ); |
|
7731 } |
|
7732 |
|
7733 // Default to showing the long text. |
|
7734 // Won't leave since we've already set maximum buffer length. |
|
7735 TRAP_IGNORE( iLabel->SetTextL( iLongLabelText ) ); |
|
7736 if ( IsReadyToDraw() ) |
|
7737 { |
|
7738 TruncateLabelText(); |
|
7739 } |
|
7740 } |
|
7741 |
|
7742 |
|
7743 void CEikCbaButton::SetTextBitmapMode( TBool aEnableBitmap ) |
|
7744 { |
|
7745 iUseTextBitmap = aEnableBitmap; |
|
7746 if ( iLabel ) |
|
7747 { |
|
7748 iLabel->MakeVisible( !aEnableBitmap ); |
|
7749 } |
|
7750 } |
|
7751 |
|
7752 void CEikCbaButton::DrawToContext( CBitmapContext& aContext, CBitmapContext& aMaskContext, const TPoint& aOffset ) const |
|
7753 { |
|
7754 if ( iLabel ) |
|
7755 { |
|
7756 // Draw text into EColor16MA bitmap |
|
7757 aContext.SetOrigin( -aOffset ); |
|
7758 iLabel->DrawToContext( aContext, NULL ); |
|
7759 |
|
7760 // Update mask |
|
7761 // The mask should have a black background and the text in white. |
|
7762 TRgb maskColor = KRgbWhite; |
|
7763 aMaskContext.SetOrigin( -aOffset ); |
|
7764 iLabel->DrawToContext( aMaskContext, &maskColor ); |
|
7765 } |
|
7766 } |
|
7767 |
|
7768 void CEikCbaButton::SwitchToShortTextL(TBool aShortText) |
|
7769 { |
|
7770 if (aShortText) |
|
7771 { |
|
7772 iLabel->SetTextL(iShortLabelText); |
|
7773 } |
|
7774 else |
|
7775 { |
|
7776 iLabel->SetTextL(iLongLabelText); |
|
7777 } |
|
7778 |
|
7779 if (IsReadyToDraw()) |
|
7780 { |
|
7781 TruncateLabelText(); |
|
7782 } |
|
7783 |
|
7784 if (!iDoImage) |
|
7785 { |
|
7786 iLabel->DrawDeferred(); |
|
7787 } |
|
7788 else |
|
7789 { |
|
7790 iImage->DrawDeferred(); |
|
7791 } |
|
7792 } |
|
7793 |
|
7794 void CEikCbaButton::SetLabelFont(const CFont* aLabelFont) |
|
7795 { |
|
7796 iLabel->SetFont(aLabelFont); |
|
7797 } |
|
7798 |
|
7799 void CEikCbaButton::TruncateLabelText() |
|
7800 { |
|
7801 // Truncation removed from here, as it was not bidi-text compatible. |
|
7802 // Let CEikLabel handle truncation instead. |
|
7803 iLabel->CropText(); |
|
7804 } |
|
7805 |
|
7806 TBool CEikCbaButton::IsEmptyText() const |
|
7807 { |
|
7808 if ( iDoImage ) |
|
7809 { |
|
7810 return EFalse; |
|
7811 } |
|
7812 |
|
7813 TPtrC text( iFullLabelText ); |
|
7814 TBool allSpaces = ETrue; |
|
7815 |
|
7816 for ( TInt i = 0; i < text.Length(); ++i ) |
|
7817 { |
|
7818 if ( !TChar(text[i]).IsSpace() ) |
|
7819 { |
|
7820 allSpaces = EFalse; |
|
7821 break; |
|
7822 } |
|
7823 } |
|
7824 |
|
7825 return allSpaces; |
|
7826 } |
|
7827 |
|
7828 void CEikCbaButton::ConstructEmptyButtonL() |
|
7829 { |
|
7830 ConstructL( EHRightVCenter ); // creates label |
|
7831 _LIT(KEmptyText, ""); |
|
7832 TPtrC16 ptr(KEmptyText); |
|
7833 UpdateLabelText( ptr ); |
|
7834 } |
|
7835 |
|
7836 TBool CEikCbaButton::PressedDown() const |
|
7837 { |
|
7838 return iPressedDown; |
|
7839 } |
|
7840 |
|
7841 void CEikCbaButton::SetPressedDown( const TBool aPressedDown ) |
|
7842 { |
|
7843 iPressedDown = aPressedDown; |
|
7844 } |
|
7845 |
|
7846 // ----------------------------------------------------------------------------- |
|
7847 // EikSoftkeyImage::SetImage |
|
7848 // |
|
7849 // ----------------------------------------------------------------------------- |
|
7850 // |
|
7851 EXPORT_C void EikSoftkeyImage::SetImage( |
|
7852 CEikButtonGroupContainer* aButtonGroupContainer, |
|
7853 CEikImage& aImage, |
|
7854 TBool aLeft) |
|
7855 { // static |
|
7856 TInt commandPos = aLeft ? 0 : 2; |
|
7857 TInt commandId = aButtonGroupContainer->ButtonGroup()->CommandId(commandPos); |
|
7858 CEikCbaButton* cbaButton = (CEikCbaButton*) aButtonGroupContainer->ControlOrNull(commandId); |
|
7859 if ( cbaButton ) |
|
7860 { |
|
7861 cbaButton->SetImage(aImage); |
|
7862 // Draw button once with old size, as rect size is different with icon and text |
|
7863 cbaButton->DrawNow(); |
|
7864 |
|
7865 aButtonGroupContainer->SetRect(aButtonGroupContainer->Rect()); |
|
7866 // Draw previosly set image |
|
7867 cbaButton->DrawNow(); |
|
7868 aButtonGroupContainer->DrawNow(); |
|
7869 } |
|
7870 } |
|
7871 |
|
7872 // ----------------------------------------------------------------------------- |
|
7873 // EikSoftkeyImage::SetLabel |
|
7874 // |
|
7875 // ----------------------------------------------------------------------------- |
|
7876 // |
|
7877 EXPORT_C void EikSoftkeyImage::SetLabel( |
|
7878 CEikButtonGroupContainer* aButtonGroupContainer, |
|
7879 TBool aLeft) |
|
7880 { // static |
|
7881 TInt commandPos = aLeft ? 0 : 2; |
|
7882 TInt commandId = aButtonGroupContainer->ButtonGroup()->CommandId(commandPos); |
|
7883 CEikCbaButton* cbaButton = (CEikCbaButton*) aButtonGroupContainer->ControlOrNull(commandId); |
|
7884 if ( cbaButton ) |
|
7885 { |
|
7886 cbaButton->ReplaceImageByLabel(); |
|
7887 // Draw button once with old size, as rect size is different with icon and text |
|
7888 cbaButton->DrawNow(); |
|
7889 |
|
7890 TRect screenRect = iAvkonAppUi->ApplicationRect(); |
|
7891 aButtonGroupContainer->SetBoundingRect(screenRect); |
|
7892 // Draw previosly set label |
|
7893 cbaButton->DrawNow(); |
|
7894 aButtonGroupContainer->DrawNow(); |
|
7895 } |
|
7896 } |
|
7897 |
|
7898 // ----------------------------------------------------------------------------- |
|
7899 // CEikCbaButton::SetImage |
|
7900 // |
|
7901 // ----------------------------------------------------------------------------- |
|
7902 // |
|
7903 void CEikCbaButton::SetImage(CEikImage &aImage) |
|
7904 { |
|
7905 iDoImage = ETrue; |
|
7906 |
|
7907 if ( iImage ) |
|
7908 { |
|
7909 iImage->SetMask( iMask ); |
|
7910 } |
|
7911 delete iImage; |
|
7912 delete iSfeMask; |
|
7913 iSfeMask = NULL; |
|
7914 iImage = &aImage; |
|
7915 if ( iImage ) |
|
7916 { |
|
7917 TRAP_IGNORE( PrepareImageL() ); |
|
7918 } |
|
7919 else |
|
7920 { |
|
7921 ReplaceImageByLabel(); |
|
7922 } |
|
7923 } |
|
7924 |
|
7925 // ----------------------------------------------------------------------------- |
|
7926 // CEikCbaButton::PrepareImageL |
|
7927 // Prepares Image for softkey feedback effect. Creates needed mask for |
|
7928 // pressed down state. |
|
7929 // ----------------------------------------------------------------------------- |
|
7930 // |
|
7931 void CEikCbaButton::PrepareImageL() |
|
7932 { |
|
7933 // 50% transparent pressed down image is made with a alternative mask |
|
7934 // which is created when a image is set to CEikCbaButton. |
|
7935 // Original mask is copied and each of its pixels color components is |
|
7936 // halved. Bit-shifting to the right makes color value to half --> |
|
7937 // image looks 50% transparent with this mask |
|
7938 const CFbsBitmap* mask = iImage->Mask(); |
|
7939 iMask = mask; |
|
7940 |
|
7941 if ( !iMask ) |
|
7942 { |
|
7943 return; |
|
7944 } |
|
7945 |
|
7946 iSfeMask = new (ELeave) CFbsBitmap; |
|
7947 User::LeaveIfError( iSfeMask->Create( mask->SizeInPixels(), mask->DisplayMode() ) ); |
|
7948 |
|
7949 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( iSfeMask ); |
|
7950 CleanupStack::PushL( device ); |
|
7951 |
|
7952 CFbsBitGc* gc( NULL ); |
|
7953 User::LeaveIfError( device->CreateContext( gc ) ); |
|
7954 |
|
7955 gc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
7956 gc->BitBlt( TPoint(0,0), mask ); |
|
7957 |
|
7958 iSfeMask->LockHeap(); |
|
7959 TInt w = iSfeMask->SizeInPixels().iWidth; |
|
7960 TInt h = iSfeMask->SizeInPixels().iHeight; |
|
7961 TInt dataStride = iSfeMask->DataStride() - w; |
|
7962 TUint8* address = (TUint8*) iSfeMask->DataAddress(); |
|
7963 |
|
7964 for ( TInt i = 0; i < h; ++i ) |
|
7965 { |
|
7966 for ( TInt j = 0; j < w; j++ ) |
|
7967 { |
|
7968 *address >>= 1; |
|
7969 ++address; |
|
7970 } |
|
7971 address += dataStride; |
|
7972 } |
|
7973 |
|
7974 iSfeMask->UnlockHeap(); |
|
7975 CleanupStack::PopAndDestroy( device ); // device |
|
7976 |
|
7977 delete gc; |
|
7978 } |
|
7979 // ----------------------------------------------------------------------------- |
|
7980 // CEikCbaButton::ReplaceImageByLabel |
|
7981 // |
|
7982 // ----------------------------------------------------------------------------- |
|
7983 // |
|
7984 void CEikCbaButton::ReplaceImageByLabel() |
|
7985 { |
|
7986 iDoImage = EFalse; |
|
7987 if ( iImage ) |
|
7988 { |
|
7989 // avoid mem leak. |
|
7990 iImage->SetMask( iMask ); |
|
7991 delete iImage; |
|
7992 iImage = NULL; |
|
7993 delete iSfeMask; |
|
7994 iSfeMask = NULL; |
|
7995 } |
|
7996 } |
|
7997 |
|
7998 // |
|
7999 // CEikEnhancedCbaButton |
|
8000 // |
|
8001 |
|
8002 // ----------------------------------------------------------------------------- |
|
8003 // default constructor |
|
8004 // ----------------------------------------------------------------------------- |
|
8005 CEikEnhancedCbaButton::CEikEnhancedCbaButton() |
|
8006 { |
|
8007 } |
|
8008 |
|
8009 // ----------------------------------------------------------------------------- |
|
8010 // default destructor |
|
8011 // ----------------------------------------------------------------------------- |
|
8012 CEikEnhancedCbaButton::~CEikEnhancedCbaButton() |
|
8013 { |
|
8014 } |
|
8015 |
|
8016 // ----------------------------------------------------------------------------- |
|
8017 // Sets command type for current button |
|
8018 // @param aCommandType Command type to be set |
|
8019 // ----------------------------------------------------------------------------- |
|
8020 #ifdef RD_ENHANCED_CBA |
|
8021 void CEikEnhancedCbaButton::SetCommandType( const TInt aCommandType ) |
|
8022 { |
|
8023 iCommandType = aCommandType; |
|
8024 } |
|
8025 #else |
|
8026 void CEikEnhancedCbaButton::SetCommandType( const TInt /*aCommandType*/ ) |
|
8027 { |
|
8028 } |
|
8029 #endif // RD_ENHANCED_CBA |
|
8030 // ----------------------------------------------------------------------------- |
|
8031 // returns command's type for current button |
|
8032 // @return TInt command's type |
|
8033 // ----------------------------------------------------------------------------- |
|
8034 |
|
8035 TInt CEikEnhancedCbaButton::CommandType() const |
|
8036 { |
|
8037 #ifdef RD_ENHANCED_CBA |
|
8038 return iCommandType; |
|
8039 #else |
|
8040 return 0; |
|
8041 #endif // RD_ENHANCED_CBA |
|
8042 } |
|
8043 |
|
8044 // ----------------------------------------------------------------------------- |
|
8045 // returns command id for current button |
|
8046 // @return TInt command's id |
|
8047 // ----------------------------------------------------------------------------- |
|
8048 TInt CEikEnhancedCbaButton::CommandId() const |
|
8049 { |
|
8050 #ifdef RD_ENHANCED_CBA |
|
8051 return iCommandId; |
|
8052 #else |
|
8053 return 0; |
|
8054 #endif // RD_ENHANCED_CBA |
|
8055 } |
|
8056 |
|
8057 // ----------------------------------------------------------------------------- |
|
8058 // constructs button based on resource definition |
|
8059 // @param aReader created resource reader for reading information from resource file |
|
8060 // ----------------------------------------------------------------------------- |
|
8061 #ifdef RD_ENHANCED_CBA |
|
8062 void CEikEnhancedCbaButton::ConstructFromResourceL(TResourceReader& aReader) |
|
8063 { |
|
8064 // Alignment set to right. |
|
8065 ConstructL( EHRightVCenter ); // creates label |
|
8066 iCommandType = aReader.ReadUint8(); |
|
8067 iCommandId = aReader.ReadInt16(); |
|
8068 // iFullLabelText.Copy( aReader.ReadTPtrC() ); |
|
8069 UpdateLabelText( aReader.ReadTPtrC() ); |
|
8070 |
|
8071 aReader.ReadTPtrC(); // bmp filename |
|
8072 aReader.ReadInt16(); // bmp id |
|
8073 aReader.ReadInt16(); // bmp mask id |
|
8074 } |
|
8075 #else |
|
8076 void CEikEnhancedCbaButton::ConstructFromResourceL(TResourceReader&) |
|
8077 { |
|
8078 } |
|
8079 #endif // RD_ENHANCED_CBA |
|
8080 |
|
8081 // ----------------------------------------------------------------------------- |
|
8082 // Constructs empty button with id EAknSoftkeyEmpty |
|
8083 // ----------------------------------------------------------------------------- |
|
8084 void CEikEnhancedCbaButton::ConstructEmptyButtonL() |
|
8085 { |
|
8086 #ifdef RD_ENHANCED_CBA |
|
8087 ConstructL( EHRightVCenter ); // creates label |
|
8088 iCommandType = EEikCommandTypeAnyCommand; |
|
8089 iCommandId = EAknSoftkeyEmpty; |
|
8090 _LIT(KEmptyText, ""); |
|
8091 TPtrC16 ptr(KEmptyText); |
|
8092 UpdateLabelText( ptr ); |
|
8093 #endif |
|
8094 } |
|
8095 |
|
8096 // ----------------------------------------------------------------------------- |
|
8097 // Used to get the label's text for the button |
|
8098 // @return TPtrC label text |
|
8099 // ----------------------------------------------------------------------------- |
|
8100 TPtrC* CEikEnhancedCbaButton::LabelText() |
|
8101 { |
|
8102 #ifdef RD_ENHANCED_CBA |
|
8103 return &iLongLabelText; |
|
8104 #else |
|
8105 return NULL; |
|
8106 #endif |
|
8107 } |
|
8108 |
|
8109 // |
|
8110 // CEikCommandTable |
|
8111 // |
|
8112 |
|
8113 CEikCommandTable* CEikCommandTable::NewL() |
|
8114 { |
|
8115 #ifdef RD_ENHANCED_CBA |
|
8116 CEikCommandTable* self = CEikCommandTable::NewLC(); |
|
8117 CleanupStack::Pop( self ); |
|
8118 return self; |
|
8119 #else |
|
8120 return NULL; |
|
8121 #endif |
|
8122 } |
|
8123 |
|
8124 CEikCommandTable* CEikCommandTable::NewLC() |
|
8125 { |
|
8126 #ifdef RD_ENHANCED_CBA |
|
8127 CEikCommandTable* self = new (ELeave) CEikCommandTable; |
|
8128 CleanupStack::PushL( self ); |
|
8129 self->ConstructL(); |
|
8130 return self; |
|
8131 #else |
|
8132 return NULL; |
|
8133 #endif |
|
8134 } |
|
8135 |
|
8136 // ----------------------------------------------------------------------------- |
|
8137 // Construction for command table |
|
8138 // priority configuration is read from the resource file |
|
8139 // ----------------------------------------------------------------------------- |
|
8140 void CEikCommandTable::ConstructL() |
|
8141 { |
|
8142 #ifdef RD_ENHANCED_CBA |
|
8143 // Get the cba priority configuration |
|
8144 TResourceReader reader; |
|
8145 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_EIK_CBA_PRIORITIES ); |
|
8146 |
|
8147 // Amount of buttons (should match with KMaxButtonsInCommandTable). |
|
8148 TInt count = reader.ReadInt16(); |
|
8149 |
|
8150 __ASSERT_DEBUG( count == KMaxButtonsInCommandTable, |
|
8151 Panic(EEikPanicCBAButtonCountDiffersFromCommandTableSize) ); |
|
8152 |
|
8153 for ( TInt i = 0; i < count; i++ ) |
|
8154 { |
|
8155 TInt priorities( reader.ReadInt16() ); // Amount of priorities for current button. |
|
8156 RArray<TInt> arr; |
|
8157 for ( TInt ii = 0; ii < priorities; ii++ ) |
|
8158 { |
|
8159 TInt8 commandType( reader.ReadInt8() ); |
|
8160 arr.Append( commandType ); |
|
8161 } |
|
8162 iPriorities.Append( arr ); |
|
8163 } |
|
8164 |
|
8165 CleanupStack::PopAndDestroy(); // reader |
|
8166 #endif |
|
8167 } |
|
8168 |
|
8169 #ifdef RD_ENHANCED_CBA |
|
8170 CEikCommandTable::CEikCommandTable() : iPriorities(1) |
|
8171 #else |
|
8172 CEikCommandTable::CEikCommandTable() |
|
8173 #endif // RD_ENHANCED_CBA |
|
8174 { |
|
8175 } |
|
8176 |
|
8177 |
|
8178 CEikCommandTable::~CEikCommandTable() |
|
8179 { |
|
8180 #ifdef RD_ENHANCED_CBA |
|
8181 iCommandButtons.Reset(); // Reset array |
|
8182 for(TInt i = 0; i < iPriorities.Count(); i++) |
|
8183 { |
|
8184 iPriorities[i].Reset(); |
|
8185 } |
|
8186 iPriorities.Reset(); |
|
8187 #endif |
|
8188 } |
|
8189 |
|
8190 // ----------------------------------------------------------------------------- |
|
8191 // Used to add a command to CommandTable |
|
8192 // @param aButton button to be added |
|
8193 // ----------------------------------------------------------------------------- |
|
8194 #ifndef RD_ENHANCED_CBA |
|
8195 TInt CEikCommandTable::AddCommandL(CEikEnhancedCbaButton* /*aButton*/) |
|
8196 { |
|
8197 return KErrNone; |
|
8198 } |
|
8199 #else |
|
8200 TInt CEikCommandTable::AddCommandL(CEikEnhancedCbaButton* aButton) |
|
8201 { |
|
8202 // CommandType tells in which button this command should be placed |
|
8203 TInt commandType( aButton->CommandType() ); |
|
8204 TInt index( KErrNotFound ); |
|
8205 |
|
8206 // Find button and index for this button. |
|
8207 TInt button( 0 ); |
|
8208 for ( button = 0; button < iPriorities.Count(); button++ ) |
|
8209 { |
|
8210 index = iPriorities[button].Find( commandType ); |
|
8211 if ( index != KErrNotFound ) |
|
8212 { |
|
8213 CEikEnhancedCbaButton* existingButton = Command( button ); |
|
8214 // If command placed on this index, check if new priority is lower. |
|
8215 if( existingButton ) |
|
8216 { |
|
8217 TInt existingPriority = iPriorities[button].Find( existingButton->CommandType() ); |
|
8218 |
|
8219 // Delete existing command button if new command has higher priority (lower index). |
|
8220 if( index < existingPriority || existingPriority == KErrNotFound ) |
|
8221 { |
|
8222 delete existingButton; |
|
8223 existingButton = NULL; |
|
8224 iCommandButtons[button] = aButton; |
|
8225 break; |
|
8226 } |
|
8227 } |
|
8228 else |
|
8229 { |
|
8230 iCommandButtons[button] = aButton; |
|
8231 break; |
|
8232 } |
|
8233 } |
|
8234 } |
|
8235 |
|
8236 // Delete button if it's not placed. |
|
8237 if( button == iPriorities.Count() ) |
|
8238 { |
|
8239 delete aButton; |
|
8240 aButton = NULL; |
|
8241 } |
|
8242 return KErrNone; |
|
8243 } |
|
8244 #endif // RD_ENHANCED_CBA |
|
8245 |
|
8246 // ----------------------------------------------------------------------------- |
|
8247 // Used to check if CommandTable has a button with a certain id. |
|
8248 // @param aCommandId Id to be checked. |
|
8249 // ----------------------------------------------------------------------------- |
|
8250 #ifndef RD_ENHANCED_CBA |
|
8251 TBool CEikCommandTable::IsCommandPlaced(const TInt /*aCommandId*/) const |
|
8252 { |
|
8253 #else // !RD_ENHANCED_CBA |
|
8254 TBool CEikCommandTable::IsCommandPlaced(const TInt aCommandId) const |
|
8255 { |
|
8256 TInt count( iCommandButtons.Count() ); |
|
8257 |
|
8258 for ( TInt i = 0; i < count; i++ ) |
|
8259 { |
|
8260 if ( iCommandButtons[i] ) |
|
8261 { |
|
8262 if ( iCommandButtons[i]->CommandId() == aCommandId ) |
|
8263 { |
|
8264 return ETrue; |
|
8265 } |
|
8266 } |
|
8267 } |
|
8268 #endif // RD_ENHANCED_CBA |
|
8269 return EFalse; // if no match for command id |
|
8270 } |
|
8271 |
|
8272 // ----------------------------------------------------------------------------- |
|
8273 // Used to replace command with a new command. |
|
8274 // @param aCommandId Id for command that should be replaced. |
|
8275 // @param aResourceId Id for new ENHANCED_CBA_BUTTON resource to be placed in the CommandTable. |
|
8276 // ----------------------------------------------------------------------------- |
|
8277 #ifndef RD_ENHANCED_CBA |
|
8278 void CEikCommandTable::ReplaceCommandL( const TInt /*aCommandId*/, const TInt /*aResourceId*/ ) |
|
8279 { |
|
8280 #else // !RD_ENHANCED_CBA |
|
8281 void CEikCommandTable::ReplaceCommandL( const TInt aCommandId, const TInt aResourceId ) |
|
8282 { |
|
8283 // If the command is not in the command table, return. |
|
8284 if( !IsCommandPlaced( aCommandId ) ) |
|
8285 { |
|
8286 return; |
|
8287 } |
|
8288 |
|
8289 TInt index( iCommandButtons.Count() ); |
|
8290 |
|
8291 CEikEnhancedCbaButton* oldButton = NULL; |
|
8292 |
|
8293 for( TInt i = 0; i < index; i++ ) |
|
8294 { |
|
8295 if( iCommandButtons[i] ) |
|
8296 { |
|
8297 if( iCommandButtons[i]->CommandId() == aCommandId ) |
|
8298 { |
|
8299 oldButton = iCommandButtons[i]; |
|
8300 index = i; |
|
8301 break; // Index is the index of replacement. |
|
8302 } |
|
8303 } |
|
8304 } |
|
8305 |
|
8306 CEikEnhancedCbaButton* button = new (ELeave) CEikEnhancedCbaButton; |
|
8307 button->SetTextBitmapMode( iExtension->iEnablePostingTransparency ); |
|
8308 CleanupStack::PushL( button ); |
|
8309 TResourceReader reader; |
|
8310 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
8311 |
|
8312 // Construct new button. |
|
8313 TUint8 version( (TUint8)reader.ReadUint8() ); // version |
|
8314 button->ConstructFromResourceL( reader ); |
|
8315 CleanupStack::Pop( button ); |
|
8316 CleanupStack::PopAndDestroy(); // reader |
|
8317 |
|
8318 // Store new button to command table. |
|
8319 iCommandButtons[index] = button; // transfers ownership |
|
8320 |
|
8321 // Delete old button. |
|
8322 delete oldButton; |
|
8323 #endif // !RD_ENHANCED_CBA |
|
8324 } |
|
8325 |
|
8326 // ----------------------------------------------------------------------------- |
|
8327 // Used to get CEikEnhancedCbaButton for current control button (1-4). |
|
8328 // @param aCommandIndex Index for requested button, use enum TCommandTableCbaPositions. |
|
8329 // @return CEikCbaButton for current position, NULL if no button placed in that position. |
|
8330 // ----------------------------------------------------------------------------- |
|
8331 #ifdef RD_ENHANCED_CBA |
|
8332 CEikEnhancedCbaButton* CEikCommandTable::Command( const TInt aCommandIndex ) |
|
8333 { |
|
8334 return iCommandButtons[aCommandIndex]; |
|
8335 } |
|
8336 #else // RD_ENHANCED_CBA |
|
8337 CEikEnhancedCbaButton* CEikCommandTable::Command( const TInt /*aCommandIndex*/ ) |
|
8338 { |
|
8339 return NULL; |
|
8340 } |
|
8341 #endif // RD_ENHANCED_CBA |
|
8342 |
|
8343 // ----------------------------------------------------------------------------- |
|
8344 // Reset CommandTable |
|
8345 // ----------------------------------------------------------------------------- |
|
8346 void CEikCommandTable::Reset() |
|
8347 { |
|
8348 #ifdef RD_ENHANCED_CBA |
|
8349 iCommandButtons.Reset(); |
|
8350 #endif // RD_ENHANCED_CBA |
|
8351 } |
|
8352 |
|
8353 // ----------------------------------------------------------------------------- |
|
8354 // Sets command observer |
|
8355 // ----------------------------------------------------------------------------- |
|
8356 EXPORT_C void AknCbaContentObserver::SetContentObserver( |
|
8357 CEikCba* aCba, |
|
8358 TCallBack aCallBack ) |
|
8359 { |
|
8360 if ( aCba ) |
|
8361 { |
|
8362 aCba->SetContentObserver( aCallBack ); |
|
8363 } |
|
8364 } |
|
8365 |
|
8366 // End of file |