uifw/AvKon/src/aknindicator.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 15 c52421ed5f07
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
     1 /*
     1 /*
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-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".
   277     {
   277     {
   278     iState = aState;
   278     iState = aState;
   279     if ( iState == EAknIndicatorStateOn )
   279     if ( iState == EAknIndicatorStateOn )
   280         {
   280         {
   281         iAnimState = iCountOfAnimStates - 1;
   281         iAnimState = iCountOfAnimStates - 1;
   282         this->MakeVisible(ETrue);
       
   283         }
   282         }
   284     else if ( iState == EAknIndicatorStateOff )
   283     else if ( iState == EAknIndicatorStateOff )
   285         {
   284         {
   286         this->MakeVisible(EFalse);
       
   287         DeleteBitmaps();
   285         DeleteBitmaps();
   288         }
   286         }
   289     else if (iState == EAknIndicatorStateAnimate )
       
   290         {
       
   291         MakeVisible( ETrue );
       
   292         }
       
   293         
       
   294     SizeChanged();
   287     SizeChanged();
   295     }
   288     }
   296 
   289 
   297 
   290 
   298 void CAknIndicator::SetIndicatorValueL(const TDesC& aString)
   291 void CAknIndicator::SetIndicatorValueL(const TDesC& aString)
   613             {
   606             {
   614             layoutMode = ELayoutModeUsual;
   607             layoutMode = ELayoutModeUsual;
   615             }
   608             }
   616 
   609 
   617         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   610         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   618         
       
   619         if ( iIndicatorBitmaps[layoutMode]->Count() <= 0 || !iIndicatorBitmaps[layoutMode]->At( 0 ) )
       
   620             {
       
   621             
       
   622             __ASSERT_DEBUG( EFalse, User::Panic( _L("indicatorcount"),iIndicatorBitmaps[layoutMode]->Count()));
       
   623             return;
       
   624             }
       
   625         TSize iconSize( iIndicatorBitmaps[layoutMode]->At( 0 )->SizeInPixels() );
   611         TSize iconSize( iIndicatorBitmaps[layoutMode]->At( 0 )->SizeInPixels() );
   626         TInt iconWidth  = iconSize.iWidth;
   612         TInt iconWidth  = iconSize.iWidth;
   627         TInt iconHeight = iconSize.iHeight;
   613         TInt iconHeight = iconSize.iHeight;
   628 
   614 
   629         if ( iState != EAknIndicatorStateOff )
   615         if ( iState != EAknIndicatorStateOff )
   664                         }
   650                         }
   665                     iconWidth = progressInPixels;
   651                     iconWidth = progressInPixels;
   666                     }
   652                     }
   667                 }
   653                 }
   668 
   654 
   669              if ( ( iAnimState * 2 + 1 ) < iIndicatorBitmaps[layoutMode]->Count()
   655             if ( iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 ) &&
   670                     && iIndicatorBitmaps[layoutMode]->At(iAnimState * 2)
   656                  iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 + 1 ) )
   671                     && iIndicatorBitmaps[layoutMode]->At(iAnimState * 2 + 1))
       
   672                 {
   657                 {
   673                 CFbsBitmap* mask = iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 + 1 );
   658                 CFbsBitmap* mask = iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 + 1 );
   674                 if ( iExtension && iExtension->iFader )
   659                 if ( iExtension && iExtension->iFader )
   675                     {
   660                     {
   676                     mask = iExtension->iFader->FadeMask(
   661                     mask = iExtension->iFader->FadeMask(
   684                                  iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 ),
   669                                  iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 ),
   685                                  TRect( 0, 0, iconWidth, iconHeight),
   670                                  TRect( 0, 0, iconWidth, iconHeight),
   686                                  mask,
   671                                  mask,
   687                                  ETrue );
   672                                  ETrue );
   688                 }
   673                 }
   689              else if (( iAnimState * 2 ) < iIndicatorBitmaps[layoutMode]->Count()
   674         else if ( iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 ) )
   690                     && iIndicatorBitmaps[layoutMode]->At(iAnimState * 2) )
       
   691                 {
   675                 {
   692                 // Draw editor indicator bitmap without mask
   676                 // Draw editor indicator bitmap without mask
   693                 CFbsBitmap* mask = iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 );
   677                 CFbsBitmap* mask = iIndicatorBitmaps[layoutMode]->At( iAnimState * 2 );
   694                 if ( iExtension && iExtension->iFader )
   678                 if ( iExtension && iExtension->iFader )
   695                     {
   679                     {
   857     }
   841     }
   858 
   842 
   859 
   843 
   860 void CAknIndicator::SetSvgIconSize( CFbsBitmap*& aBitmap, TInt aLayoutMode )
   844 void CAknIndicator::SetSvgIconSize( CFbsBitmap*& aBitmap, TInt aLayoutMode )
   861     {
   845     {
       
   846     TRect rect( Rect() );
       
   847 
   862     TInt indicatorUid = iUid;
   848     TInt indicatorUid = iUid;
   863     if (indicatorUid >= EAknNaviPaneEditorIndicatorDynamicUidRangeFirst &&
   849     if (indicatorUid >= EAknNaviPaneEditorIndicatorDynamicUidRangeFirst &&
   864         indicatorUid <= EAknNaviPaneEditorIndicatorDynamicUidRangeLast)
   850         indicatorUid <= EAknNaviPaneEditorIndicatorDynamicUidRangeLast)
   865         {
   851         {
   866         indicatorUid = EAknNaviPaneEditorIndicatorDynamicUidRangeFirst;
   852         indicatorUid = EAknNaviPaneEditorIndicatorDynamicUidRangeFirst;
   867         }
   853         }
   868 
   854 
   869     TSize size(10,10); // default size (every SVG icon needs to be initialized)
   855     TSize size(10,10); // default size (every SVG icon needs to be initialized)
   870     TScaleMode aspectRatio = EAspectRatioPreservedAndUnusedSpaceRemoved;
   856     TScaleMode aspectRatio = EAspectRatioPreservedAndUnusedSpaceRemoved;
   871 
   857 
   872     switch ( indicatorUid )
   858     TRect navipaneRect(0,0,0,0);
       
   859     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   860     if (statusPane)
       
   861         {
       
   862         CCoeControl* control = NULL;
       
   863         TRAP_IGNORE(control = statusPane->ControlL(TUid::Uid( EEikStatusPaneUidNavi )));
       
   864         if (control)
       
   865             {
       
   866             navipaneRect.SetSize( control->Size() );
       
   867             }
       
   868         }
       
   869 
       
   870     // If navipane is not found, we get portrait normal navipanerect frop laf data which is usually right enough.
       
   871     if (navipaneRect.Size() == TSize(0,0))
       
   872         {
       
   873         TInt battery = 0;
       
   874         TRect statusPaneRect;
       
   875         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
   876 
       
   877         if ( AknStatuspaneUtils::IdleLayoutActive() )
       
   878             {
       
   879             if ( ( iIndicatorContext == CAknIndicatorContainer::EQueryEditorIndicators )
       
   880                 && ( statusPaneRect.Size() == TSize(0,0) ) )
       
   881                 {
       
   882                 battery = 0;
       
   883                 }
       
   884             else
       
   885                 {
       
   886                 battery = 1;
       
   887                 }
       
   888             }
       
   889 
       
   890 
       
   891         // Navi pane
       
   892         TAknWindowComponentLayout naviPaneLayout( AknLayoutScalable_Avkon::navi_pane(battery) );
       
   893         TAknLayoutRect naviPaneLayoutRect;
       
   894         naviPaneLayoutRect.LayoutRect(statusPaneRect, naviPaneLayout);
       
   895         navipaneRect.SetSize( naviPaneLayoutRect.Rect().Size() );
       
   896         }
       
   897 
       
   898     // Screen
       
   899     TRect screenRect;
       
   900     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
       
   901 
       
   902     switch (indicatorUid)
   873         {
   903         {
   874         // Status pane's indicators
   904         // Status pane's indicators
   875         case EAknIndicatorIrActive:
   905         case EAknIndicatorIrActive:
   876         case EAknIndicatorEnvelope:
   906         case EAknIndicatorEnvelope:
   877         case EAknIndicatorEmailMessage:
   907         case EAknIndicatorEmailMessage:
   934         case EAknIndicatorMissedCalendarAlarm:
   964         case EAknIndicatorMissedCalendarAlarm:
   935         case EAknIndicatorUSBMemConnected:
   965         case EAknIndicatorUSBMemConnected:
   936         case EAknIndicatorUSBMemActive:
   966         case EAknIndicatorUSBMemActive:
   937         case EAknIndicatorStopWatch:
   967         case EAknIndicatorStopWatch:
   938         case EAknIndicatorMecoServiceTab:
   968         case EAknIndicatorMecoServiceTab:
   939         case EAknIndicatorIntegratedIM:
   969             {
   940             {
   970             // Main pane
       
   971             TRect mainPaneRect;
       
   972             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   973                                                mainPaneRect );
       
   974 
       
   975             // statuspane, usual
       
   976             TRect usualStatusPaneRect;
       
   977             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   978                                                usualStatusPaneRect );
       
   979 
       
   980             // status indicator pane elements
       
   981             TRect statusIndicatorPaneElementsRect;
       
   982             AknLayoutUtils::LayoutMetricsRect(
       
   983                 AknLayoutUtils::EIndicatorPane,
       
   984                 statusIndicatorPaneElementsRect );
       
   985 
       
   986             // universal indicator pane (note statuspane as parent)
       
   987             TAknLayoutRect universalIndicatorPaneLayoutRect;
       
   988             universalIndicatorPaneLayoutRect.LayoutRect(
       
   989                 usualStatusPaneRect,
       
   990                 AknLayoutScalable_Avkon::uni_indicator_pane( 0 ) );
       
   991             TRect universalIndicatorPaneRect(
       
   992                 universalIndicatorPaneLayoutRect.Rect() );
       
   993 
       
   994             // universal indicator pane elements
       
   995             TAknLayoutRect universalIndicatorPaneElementsLayoutRect;
       
   996             universalIndicatorPaneElementsLayoutRect.LayoutRect(
       
   997                 universalIndicatorPaneRect,
       
   998                 AknLayoutScalable_Avkon::uni_indicator_pane_g1() );
       
   999             TRect universalIndicatorPaneElementsRect(
       
  1000                 universalIndicatorPaneElementsLayoutRect.Rect() );
       
  1001 
       
  1002             if ( aLayoutMode == ELayoutModeUsual )
       
  1003                 {
       
  1004                 size = universalIndicatorPaneElementsRect.Size();
       
  1005                 }
       
  1006 
       
  1007             if ( aLayoutMode == ELayoutModeWide )
       
  1008                 {
       
  1009                 size = statusIndicatorPaneElementsRect.Size();
       
  1010                 }
       
  1011 
       
  1012             // Stacon special cases
       
  1013             if ( AknStatuspaneUtils::StaconPaneActive() &&
       
  1014                  !AknStatuspaneUtils::IdleLayoutActive() &&
       
  1015                  !AknStatuspaneUtils::ExtendedStaconPaneActive())
       
  1016                 {
       
  1017                 size = Size();
       
  1018                 }
       
  1019             else if ( AknStatuspaneUtils::ExtendedStaconPaneActive() )
       
  1020                 {
       
  1021                 size = Size();
       
  1022                 }
       
  1023 
       
  1024             // Flat special cases
       
  1025             if ( AknStatuspaneUtils::FlatLayoutActive() )
       
  1026                 {
       
  1027                 size = Size();
       
  1028                 }
   941 
  1029 
   942             // Portrait extended cases
  1030             // Portrait extended cases
   943             if ( AknStatuspaneUtils::ExtendedLayoutActive() &&
  1031             if ( AknStatuspaneUtils::ExtendedLayoutActive() )
   944                  AknStatuspaneUtils::IdleLayoutActive() &&
  1032                 {
   945                  !AknStatuspaneUtils::HDLayoutActive() )
  1033                 size = Size();
   946                 {
  1034                 if ( AknStatuspaneUtils::IdleLayoutActive() &&
   947                 aspectRatio = EAspectRatioPreserved;
  1035                      !AknStatuspaneUtils::HDLayoutActive() )
   948                 }
  1036                     {
   949 
  1037                     aspectRatio = EAspectRatioPreserved;
   950             size = Size();
  1038                     }
       
  1039                 }
       
  1040 
       
  1041             // In landscape idle we use vertical indicators if parent
       
  1042             // is in vertical mode, otherwise horizontal.
       
  1043             if ( AknStatuspaneUtils::IdleLayoutActive() &&
       
  1044                  Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1045                  iParent->Size().iWidth < iParent->Size().iHeight )
       
  1046                 {
       
  1047                 size = Size();
       
  1048                 }
   951 
  1049 
   952             break;
  1050             break;
   953             }
  1051             }
   954 
  1052 
   955         // Navi pane editor indicators
  1053         // Navi pane editor indicators
  1045 #ifdef RD_INTELLIGENT_TEXT_INPUT
  1143 #ifdef RD_INTELLIGENT_TEXT_INPUT
  1046         case EAknNaviPaneEditorIndicatorFnKeyPressed:
  1144         case EAknNaviPaneEditorIndicatorFnKeyPressed:
  1047         case EAknNaviPaneEditorIndicatorFnKeyLocked:
  1145         case EAknNaviPaneEditorIndicatorFnKeyLocked:
  1048 #endif
  1146 #endif
  1049             {
  1147             {
  1050             TRect navipaneRect( 0, 0, 0, 0 );
  1148             TAknWindowComponentLayout l1 = AknLayoutScalable_Avkon::navi_icon_pane(0);
  1051             CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
  1149             TAknWindowComponentLayout l2 = AknLayoutScalable_Avkon::navi_icon_pane_g1();
  1052             if ( statusPane )
  1150             TAknWindowComponentLayout layout = TAknWindowComponentLayout::Compose( l1, l2 );
  1053                 {
       
  1054                 CCoeControl* control = NULL;
       
  1055                 TRAP_IGNORE(
       
  1056                     control = statusPane->ControlL(
       
  1057                         TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  1058                 if ( control )
       
  1059                     {
       
  1060                     navipaneRect.SetSize( control->Size() );
       
  1061                     }
       
  1062                 }
       
  1063         
       
  1064             // If navi pane is not found, we get portrait normal navi pane
       
  1065             // rect from LAF data which is usually right enough.
       
  1066             if ( navipaneRect.IsEmpty() )
       
  1067                 {
       
  1068                 TRect statusPaneRect;
       
  1069                 AknLayoutUtils::LayoutMetricsRect(
       
  1070                     AknLayoutUtils::EStatusPane, statusPaneRect );
       
  1071 
       
  1072                 // Navi pane
       
  1073                 TAknLayoutRect naviPaneLayoutRect;
       
  1074                 naviPaneLayoutRect.LayoutRect(
       
  1075                     statusPaneRect, AknLayoutScalable_Avkon::navi_pane( 6 ) );
       
  1076                 navipaneRect.SetSize( naviPaneLayoutRect.Rect().Size() );
       
  1077                 }
       
  1078             
       
  1079             TAknWindowComponentLayout l1(
       
  1080                 AknLayoutScalable_Avkon::navi_icon_pane( 0 ) );
       
  1081             TAknWindowComponentLayout l2(
       
  1082                 AknLayoutScalable_Avkon::navi_icon_pane_g1() );
       
  1083             TAknWindowComponentLayout layout(
       
  1084                 TAknWindowComponentLayout::Compose( l1, l2 ) );
       
  1085 
  1151 
  1086             TAknLayoutRect layoutRect;
  1152             TAknLayoutRect layoutRect;
  1087             layoutRect.LayoutRect( navipaneRect, layout );
  1153             layoutRect.LayoutRect( navipaneRect, layout );
  1088             TRect rect( layoutRect.Rect() );
  1154             TRect rect( layoutRect.Rect() );
  1089             size = rect.Size();
  1155             size = rect.Size();
  1093         // Extra application indicators to editor indicator pane
  1159         // Extra application indicators to editor indicator pane
  1094         // in small or nHD status pane layout.
  1160         // in small or nHD status pane layout.
  1095         case EAknNaviPaneEditorIndicatorWaitBar:
  1161         case EAknNaviPaneEditorIndicatorWaitBar:
  1096         case EAknNaviPaneEditorIndicatorProgressBar:
  1162         case EAknNaviPaneEditorIndicatorProgressBar:
  1097             {
  1163             {
  1098             TRect rect( Rect() );
       
  1099 
       
  1100             TAknLayoutRect waitPaneComponentLayoutRect;
  1164             TAknLayoutRect waitPaneComponentLayoutRect;
  1101             waitPaneComponentLayoutRect.LayoutRect(
  1165             waitPaneComponentLayoutRect.LayoutRect(
  1102                 rect,
  1166                 rect,
  1103                 AknLayoutScalable_Avkon::status_small_wait_pane_g2() );
  1167                 AknLayoutScalable_Avkon::status_small_wait_pane_g2() );
  1104             TRect waitPaneComponentRect( waitPaneComponentLayoutRect.Rect() );
  1168             TRect waitPaneComponentRect( waitPaneComponentLayoutRect.Rect() );
  1115         case EAknNaviPaneEditorIndicatorFileSize:
  1179         case EAknNaviPaneEditorIndicatorFileSize:
  1116         case EAknNaviPaneEditorIndicatorWlanAvailable:
  1180         case EAknNaviPaneEditorIndicatorWlanAvailable:
  1117         case EAknNaviPaneEditorIndicatorWlanActive:
  1181         case EAknNaviPaneEditorIndicatorWlanActive:
  1118         case EAknNaviPaneEditorIndicatorWlanActiveSecure:
  1182         case EAknNaviPaneEditorIndicatorWlanActiveSecure:
  1119             {
  1183             {
  1120             // Screen
  1184             // app window
  1121             TRect screenRect;
  1185             TAknWindowComponentLayout applicationWindowLayout( AknLayoutScalable_Avkon::application_window(0) );
  1122             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen,
  1186             TAknLayoutRect applicationWindowLayoutRect;
  1123                                                screenRect );
  1187             applicationWindowLayoutRect.LayoutRect( screenRect, applicationWindowLayout );
  1124 
  1188             TRect applicationWindowRect( applicationWindowLayoutRect.Rect() );
  1125             // top area, skip the application window as it's the same
  1189 
  1126             // size as the screen.
  1190             // top area
       
  1191             TAknWindowComponentLayout topAreaLayout( AknLayoutScalable_Avkon::area_top_pane(1) );
  1127             TAknLayoutRect topAreaLayoutRect;
  1192             TAknLayoutRect topAreaLayoutRect;
  1128             topAreaLayoutRect.LayoutRect(
  1193             topAreaLayoutRect.LayoutRect( applicationWindowRect, topAreaLayout );
  1129                 screenRect, AknLayoutScalable_Avkon::area_top_pane( 1 ) );
       
  1130             TRect topAreaRect( topAreaLayoutRect.Rect() );
  1194             TRect topAreaRect( topAreaLayoutRect.Rect() );
  1131 
  1195 
  1132             // small statuspane
  1196             // small statuspane
       
  1197             TAknWindowComponentLayout smallStatusPaneLayout( AknLayoutScalable_Avkon::status_small_pane() );
  1133             TAknLayoutRect smallStatusPaneLayoutRect;
  1198             TAknLayoutRect smallStatusPaneLayoutRect;
  1134             smallStatusPaneLayoutRect.LayoutRect(
  1199             smallStatusPaneLayoutRect.LayoutRect( topAreaRect, smallStatusPaneLayout );
  1135                 topAreaRect, AknLayoutScalable_Avkon::status_small_pane() );
       
  1136             TRect smallStatusPaneRect( smallStatusPaneLayoutRect.Rect() );
  1200             TRect smallStatusPaneRect( smallStatusPaneLayoutRect.Rect() );
  1137 
  1201 
  1138             // icon pane
  1202             // icon pane
       
  1203             TAknWindowComponentLayout iconPaneLayout( AknLayoutScalable_Avkon::status_small_icon_pane() );
  1139             TAknLayoutRect iconPaneLayoutRect;
  1204             TAknLayoutRect iconPaneLayoutRect;
  1140             iconPaneLayoutRect.LayoutRect(
  1205             iconPaneLayoutRect.LayoutRect( smallStatusPaneRect, iconPaneLayout );
  1141                 smallStatusPaneRect,
       
  1142                 AknLayoutScalable_Avkon::status_small_icon_pane() );
       
  1143 
       
  1144             TRect iconPaneRect( iconPaneLayoutRect.Rect() );
  1206             TRect iconPaneRect( iconPaneLayoutRect.Rect() );
  1145 
  1207 
  1146             size = iconPaneRect.Size();
  1208             size = iconPaneRect.Size();
  1147             break;
  1209             break;
  1148             }
  1210             }