1 /* |
1 /* |
2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
249 { |
249 { |
250 aReader.ReadInt8(); //version, not used currently |
250 aReader.ReadInt8(); //version, not used currently |
251 aReader.ReadInt8(); //lines, not used currently |
251 aReader.ReadInt8(); //lines, not used currently |
252 iFlags = aReader.ReadInt32(); |
252 iFlags = aReader.ReadInt32(); |
253 |
253 |
254 TBool enableTransparency = |
254 TBool enableTransparency = CAknEnv::Static()->TransparencyEnabled() && |
255 ( ( !( iFlags & KAknToolbarFixed ) && |
255 ( ( !( iFlags & KAknToolbarFixed ) && |
256 !( iFlags & KAknToolbarFloatingUnTransparent ) ) || |
256 !( iFlags & KAknToolbarFloatingUnTransparent ) ) || |
257 ( iFlags & KAknToolbarTransparent && iFlags & KAknToolbarFixed ) ); |
257 ( iFlags & KAknToolbarTransparent && iFlags & KAknToolbarFixed ) ); |
258 |
258 |
259 if ( enableTransparency ) |
259 |
|
260 if( enableTransparency ) |
260 { |
261 { |
261 Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW |
262 Window().SetRequiredDisplayMode( EColor16MA ); // Without this, ACT does not work in all cases in HW |
262 EnableWindowTransparency(); |
263 TInt err = Window().SetTransparencyAlphaChannel(); |
263 } |
264 |
264 |
265 if ( err == KErrNone ) // it should all ways be true in NGA |
265 TRect dummyRect( 0, 0, 0, 0 ); |
266 { |
266 iFrameContext = CAknsFrameBackgroundControlContext::NewL( |
267 // Set the window initially completely transparent. This needs to be called only once. |
267 KAknsIIDQsnFrPopupSub, |
268 Window().SetBackgroundColor(~0); |
268 dummyRect, |
269 } |
269 dummyRect, |
270 } |
270 ( iFlags & KAknToolbarFixed ) ? ETrue : EFalse ); |
271 |
|
272 |
|
273 |
|
274 iFrameContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrPopupSub, |
|
275 TRect(), TRect(), ( iFlags & KAknToolbarFixed )? ETrue : EFalse ); |
271 |
276 |
272 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
277 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
273 KAknsIIDQsnBgScreen, dummyRect, ETrue ); |
278 KAknsIIDQsnBgScreen, TRect(), ETrue ); |
274 |
279 |
275 SetWithSliding( ETrue ); |
280 SetWithSliding( ETrue ); |
276 |
281 |
277 TInt softkeyResource = aReader.ReadUint32(); //softkeys |
282 TInt softkeyResource = aReader.ReadUint32(); //softkeys |
278 |
283 |
307 |
312 |
308 // If toolbar is fixed need to set size for toolbar so that it can reduce |
313 // If toolbar is fixed need to set size for toolbar so that it can reduce |
309 // the rects correctly. |
314 // the rects correctly. |
310 if ( iFlags & KAknToolbarFixed ) |
315 if ( iFlags & KAknToolbarFixed ) |
311 { |
316 { |
312 SetFocusing( EFalse ); |
317 if ( iFlags & KAknToolbarDefault ) |
313 |
318 { |
314 // Don't set the size and position for default toolbar (never shown). |
319 SetDimmed( ETrue ); |
315 if ( !( iFlags & KAknToolbarDefault ) ) |
320 } |
316 { |
321 SetFocusing( EFalse ); |
317 SetRect( CalculateSizeAndPosition() ); |
322 SetRect( CalculateSizeAndPosition() ); |
318 } |
323 } |
319 } |
324 |
320 |
325 AdjustAllButtons(); |
321 // Unnecessary for default toolbar (never shown). |
|
322 if ( !( iFlags & KAknToolbarDefault ) ) |
|
323 { |
|
324 AdjustAllButtons(); |
|
325 } |
|
326 } |
326 } |
327 |
327 |
328 // ----------------------------------------------------------------------------- |
328 // ----------------------------------------------------------------------------- |
329 // CAknToolbar::ConstructFromResourceL |
329 // CAknToolbar::ConstructFromResourceL |
330 // Constructs controls from a resource file. |
330 // Constructs controls from a resource file. |
546 // The position of the top left corner should be set in advance. |
545 // The position of the top left corner should be set in advance. |
547 // ----------------------------------------------------------------------------- |
546 // ----------------------------------------------------------------------------- |
548 // |
547 // |
549 void CAknToolbar::ShowToolbarL() |
548 void CAknToolbar::ShowToolbarL() |
550 { |
549 { |
551 if ( iFlags & KAknToolbarFixed && iFlags & KAknToolbarDefault ) |
550 if ( iFlags & KAknToolbarFixed && |
|
551 ( !AknLayoutUtils::PenEnabled() || |
|
552 iFlags & KAknToolbarDefault ) ) |
552 { |
553 { |
553 if ( IsVisible() ) |
554 if ( IsVisible() ) |
554 { |
555 { |
555 MakeVisible( EFalse ); |
556 MakeVisible( EFalse ); |
556 } |
557 } |
589 startPos.iX = -rect.Size().iWidth; |
590 startPos.iX = -rect.Size().iWidth; |
590 } |
591 } |
591 SetExtent( startPos, rect.Size() ); |
592 SetExtent( startPos, rect.Size() ); |
592 UpdateControlPositions(); |
593 UpdateControlPositions(); |
593 |
594 |
|
595 TBool redrawStoreEnabled(EFalse); |
|
596 if( !CAknEnv::Static()->TransparencyEnabled() ) |
|
597 { |
|
598 redrawStoreEnabled = Window().IsRedrawStoreEnabled(); |
|
599 } |
|
600 |
594 CTouchToolbarData* data = CheckRegistration( this ); |
601 CTouchToolbarData* data = CheckRegistration( this ); |
595 if ( data && !(iFlags & KAknToolbarFixed) && iAvkonAppUi->IsForeground() ) |
602 if ( data && !(iFlags & KAknToolbarFixed) && iAvkonAppUi->IsForeground() ) |
596 { |
603 { |
597 data->SetBetweenRegisterAndBegin( EFalse ); |
604 data->SetBetweenRegisterAndBegin( EFalse ); |
598 |
605 |
626 else |
633 else |
627 { |
634 { |
628 CAknTransitionUtils::RemoveData( reinterpret_cast<TInt>( this ) ); |
635 CAknTransitionUtils::RemoveData( reinterpret_cast<TInt>( this ) ); |
629 delete data; |
636 delete data; |
630 GfxTransEffect::Deregister( this ); |
637 GfxTransEffect::Deregister( this ); |
|
638 } |
|
639 |
|
640 if ( !CAknEnv::Static()->TransparencyEnabled() && redrawStoreEnabled ) |
|
641 { |
|
642 Window().EnableRedrawStore( ETrue ); |
631 } |
643 } |
632 } |
644 } |
633 |
645 |
634 // notify observer, for example touch pane, that toolbar was shown |
646 // notify observer, for example touch pane, that toolbar was shown |
635 if ( Observer() ) |
647 if ( Observer() ) |
887 // |
904 // |
888 EXPORT_C void CAknToolbar::SetItemDimmed( const TInt aCommandId, |
905 EXPORT_C void CAknToolbar::SetItemDimmed( const TInt aCommandId, |
889 const TBool aDimmed, |
906 const TBool aDimmed, |
890 const TBool aDrawNow ) |
907 const TBool aDrawNow ) |
891 { |
908 { |
892 if( IsDimmed() ) |
|
893 return; |
|
894 CAknToolbarItem* item = ToolbarItemById( aCommandId ); |
909 CAknToolbarItem* item = ToolbarItemById( aCommandId ); |
895 if ( item && item->Control() ) |
910 if ( item && item->Control() ) |
896 { |
911 { |
897 item->Control()->SetDimmed( aDimmed ); |
912 item->Control()->SetDimmed( aDimmed ); |
898 if ( aDimmed && IsFocused() && item->Control()->IsFocused() ) |
913 if ( aDimmed && IsFocused() && item->Control()->IsFocused() ) |
1117 if ( ii != iDownItem && !button->IsDimmed() ) |
1132 if ( ii != iDownItem && !button->IsDimmed() ) |
1118 { |
1133 { |
1119 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
1134 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
1120 if ( feedback ) |
1135 if ( feedback ) |
1121 { |
1136 { |
1122 feedback->InstantFeedback( button, |
1137 feedback->InstantFeedback( ETouchFeedbackBasicButton ); |
1123 ETouchFeedbackBasicButton, |
|
1124 ETouchFeedbackVibra, |
|
1125 aPointerEvent ); |
|
1126 } |
1138 } |
1127 } |
1139 } |
1128 |
1140 |
1129 button->HandlePointerEventL( aPointerEvent ); |
1141 button->HandlePointerEventL( aPointerEvent ); |
1130 override = ETrue; |
1142 override = ETrue; |
1181 iInternalFlags.Clear( EFixedShown ); |
1193 iInternalFlags.Clear( EFixedShown ); |
1182 } |
1194 } |
1183 return; |
1195 return; |
1184 } |
1196 } |
1185 } |
1197 } |
1186 |
1198 |
1187 if ( aType == KAknToolbarSetVisible && !IsShown() ) |
1199 if ( aType == KAknToolbarSetVisible && iFlags & KAknToolbarDefault |
|
1200 && !AknLayoutUtils::PenEnabled() ) |
|
1201 { |
|
1202 return; |
|
1203 } |
|
1204 else if ( aType == KAknToolbarSetVisible && !IsShown() ) |
1188 { |
1205 { |
1189 iInternalFlags.Set( ECalledFromFW ); |
1206 iInternalFlags.Set( ECalledFromFW ); |
1190 iInternalFlags.Clear( EDrawBackground ); |
1207 iInternalFlags.Clear( EDrawBackground ); |
1191 SetToolbarVisibility(ETrue, EFalse); |
1208 SetToolbarVisibility(ETrue, EFalse); |
1192 iInternalFlags.Clear( ECalledFromFW ); |
1209 iInternalFlags.Clear( ECalledFromFW ); |
1208 { |
1225 { |
1209 iPreviousItem = KSelectedNone; |
1226 iPreviousItem = KSelectedNone; |
1210 for(TInt i = 0; i < iVisibleItems.Count(); i++) |
1227 for(TInt i = 0; i < iVisibleItems.Count(); i++) |
1211 { |
1228 { |
1212 CAknToolbarItem* item = iVisibleItems[ i ]; |
1229 CAknToolbarItem* item = iVisibleItems[ i ]; |
1213 if( item->ControlType() == EAknCtButton |
1230 CAknButton* button = static_cast<CAknButton*>( item->Control() ); |
1214 || item->ControlType() == EAknCtToolbarExtension ) |
1231 button->ResetState(); |
1215 { |
1232 } |
1216 CAknButton* button = static_cast<CAknButton*>( item->Control() ); |
1233 if ( iFlags & KAknToolbarDefault && !AknLayoutUtils::PenEnabled() && IsVisible() ) |
1217 button->ResetState(); |
1234 { |
1218 } |
1235 TRAP_IGNORE( HideToolbarL() ); |
1219 } |
1236 return; |
1220 |
1237 } |
1221 if ( iFlags & KAknToolbarFixed ) |
1238 else if ( iFlags & KAknToolbarFixed ) |
1222 { |
1239 { |
1223 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
1240 if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::PenEnabled() ) |
1224 { |
1241 { |
1225 iOrientation = EAknOrientationVertical; |
1242 iOrientation = EAknOrientationVertical; |
1226 if ( ( iInternalFlags.IsSet( EFixedShown ) |
1243 if ( ( iInternalFlags.IsSet( EFixedShown ) |
1227 || ( iInternalFlags.IsSet( EItemsHidden ) |
1244 || ( iInternalFlags.IsSet( EItemsHidden ) |
1228 && iInternalFlags.IsSet( EAppOverrideVisibility ) ) ) |
1245 && iInternalFlags.IsSet( EAppOverrideVisibility ) ) ) |
2023 SetOrdinalPositions(); |
2040 SetOrdinalPositions(); |
2024 } |
2041 } |
2025 |
2042 |
2026 CWindowGc& gc = SystemGc(); |
2043 CWindowGc& gc = SystemGc(); |
2027 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
2044 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
2028 |
2045 // Draw background |
2029 // |
2046 if ( iFlags & KAknToolbarFixed && |
2030 // Draw background |
|
2031 // |
|
2032 if ( iFlags & KAknToolbarFixed && !( iFlags & KAknToolbarNoBackground ) && |
|
2033 iBgRect.Height() > 0 && |
2047 iBgRect.Height() > 0 && |
2034 iBgRect.Width() > 0 ) |
2048 iBgRect.Width() > 0 ) |
2035 { |
2049 { |
2036 if ( aRect.Intersects( iBgRect ) ) |
2050 if ( aRect.Intersects( iBgRect ) ) |
2037 { |
2051 { |
2359 { |
2373 { |
2360 iFrameContext->SetCenter( KAknsIIDQgnGrafPopupTransCenter ); |
2374 iFrameContext->SetCenter( KAknsIIDQgnGrafPopupTransCenter ); |
2361 } |
2375 } |
2362 } |
2376 } |
2363 |
2377 |
2364 // Don't set the size and position for default toolbar (never shown). |
2378 TRect rect = CalculateSizeAndPosition(); |
2365 if ( !( iFlags & KAknToolbarDefault ) ) |
2379 // Set focused item again to avoid panic in a case when toolbar has more |
2366 { |
2380 // items in previous orientation and some of the items that do not |
2367 TRect rect = CalculateSizeAndPosition(); |
2381 // fit to toolbar in this orientation was focused. |
2368 // Set focused item again to avoid panic in a case when toolbar has |
2382 if ( IsFocused() ) |
2369 // more items in previous orientation and some of the items that do |
2383 { |
2370 // not fit to toolbar in this orientation was focused. |
2384 TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); |
2371 if ( IsFocused() ) |
2385 } |
2372 { |
2386 |
2373 TRAP_IGNORE( MoveHighlightL( iFocusedItem, EFalse ) ); |
2387 if ( iInternalFlags.IsSet( EShown ) ) |
2374 } |
2388 { |
2375 |
2389 if ( !( iFlags & KAknToolbarFlexiblePosition ) ) |
2376 if ( iInternalFlags.IsSet( EShown ) ) |
2390 { |
2377 { |
2391 SetPosition( rect.iTl ); |
2378 if ( !( iFlags & KAknToolbarFlexiblePosition ) ) |
2392 } |
2379 { |
2393 else |
2380 SetPosition( rect.iTl ); |
2394 { |
2381 } |
2395 UpdateControlPositions(); |
2382 else |
2396 } |
2383 { |
2397 SetSize( rect.Size() ); |
2384 UpdateControlPositions(); |
2398 DrawDeferred(); |
2385 } |
|
2386 SetSize( rect.Size() ); |
|
2387 DrawDeferred(); |
|
2388 } |
|
2389 } |
2399 } |
2390 } |
2400 } |
2391 |
2401 |
2392 // ----------------------------------------------------------------------------- |
2402 // ----------------------------------------------------------------------------- |
2393 // CAknToolbar::NotifyBackgroundChange |
2403 // CAknToolbar::NotifyBackgroundChange |
2619 // |
2629 // |
2620 void CAknToolbar::ReduceRect( TRect& aBoundingRect ) const |
2630 void CAknToolbar::ReduceRect( TRect& aBoundingRect ) const |
2621 { |
2631 { |
2622 TBool toolbarNotVisible( !IsShown() && !( iFlags & KAknToolbarDefault ) ); |
2632 TBool toolbarNotVisible( !IsShown() && !( iFlags & KAknToolbarDefault ) ); |
2623 TBool fixedToolbar( iFlags & KAknToolbarFixed ); |
2633 TBool fixedToolbar( iFlags & KAknToolbarFixed ); |
|
2634 TBool landscapeOrientation( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
2635 TBool touchEnabled( AknLayoutUtils::PenEnabled() ); |
2624 TBool defaultContent( iFlags & KAknToolbarDefault ); |
2636 TBool defaultContent( iFlags & KAknToolbarDefault ); |
2625 |
2637 |
2626 if ( toolbarNotVisible || |
2638 if ( toolbarNotVisible || |
2627 !fixedToolbar || |
2639 !fixedToolbar || |
|
2640 ( defaultContent && !landscapeOrientation ) || |
|
2641 !touchEnabled || |
2628 ( fixedToolbar && defaultContent ) ) |
2642 ( fixedToolbar && defaultContent ) ) |
2629 { |
2643 { |
2630 return; |
2644 return; |
2631 } |
2645 } |
2632 TRect appRect, toolbarRect; |
2646 TRect appRect, toolbarRect; |
3098 |
3112 |
3099 aCellPaneRect = RectFromLayout( aGridPaneRect, |
3113 aCellPaneRect = RectFromLayout( aGridPaneRect, |
3100 AknLayoutScalable_Avkon::cell_sctrl_middle_pane( 0, 0, 0 ) ); |
3114 AknLayoutScalable_Avkon::cell_sctrl_middle_pane( 0, 0, 0 ) ); |
3101 } |
3115 } |
3102 } |
3116 } |
3103 else |
3117 else |
3104 { |
3118 { |
3105 if ( iOrientation == EAknOrientationHorizontal ) |
3119 if ( iOrientation == EAknOrientationHorizontal ) |
3106 { |
3120 { |
3107 variety = 4; |
3121 variety = 4; |
3108 aToolbarRect = RectFromLayout( aMainPaneRect, |
3122 aToolbarRect = RectFromLayout( aMainPaneRect, |
3109 AknLayoutScalable_Avkon::popup_toolbar_window( variety ) ); |
3123 AknLayoutScalable_Avkon::popup_toolbar_window( variety ) ); |
3110 |
3124 |
3111 aGridPaneRect = RectFromLayout( TRect( TPoint(), aToolbarRect.Size() ), |
3125 aGridPaneRect = RectFromLayout( TRect( TPoint(), aToolbarRect.Size() ), |
3112 AknLayoutScalable_Avkon::grid_toobar_pane() ); |
3126 AknLayoutScalable_Avkon::grid_toobar_pane() ); |