uifw/AvKon/src/Aknvolumecontrol.cpp
changeset 0 2f259fa3e83a
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  Volume editor class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "Aknvolumecontrol.h"
       
    21 #include <gulicon.h>
       
    22 #include <AknPanic.h>
       
    23 #include <AknNaviObserver.h>
       
    24 #include <AknUtils.h>
       
    25 #include <barsread.h>
       
    26 #include <AknStatuspaneUtils.h>
       
    27 #include <aknnavide.h>
       
    28 #include <AknsDrawUtils.h>
       
    29 #include <AknsFrameBackgroundControlContext.h>
       
    30 #include <aknappui.h>
       
    31 #include <aknconsts.h>
       
    32 #include <aknlayoutscalable_avkon.cdl.h>
       
    33 #include <skinlayout.cdl.h>
       
    34 #include <avkon.mbg>
       
    35 #include <AknVolumePopup.h>
       
    36 
       
    37 #include <AknTasHook.h>
       
    38 #include <touchfeedback.h>
       
    39 #include <aknlayoutscalable_apps.cdl.h>
       
    40 // CONSTANTS
       
    41 const TInt KVolumeMinValue  = 1;
       
    42 const TInt KVolumeMaxValue  = 10;
       
    43 const TInt KVolumeLevels    = 10;
       
    44 
       
    45 const TInt KVolumeButtonDown        = 0x01;
       
    46 const TInt KVolumeNaviPaneMuted     = 0x02;
       
    47 const TInt KVolumeStepChange        = 0x04;
       
    48 const TInt KVolumeLevelNotFound     = 0;
       
    49 const TInt KVolumeLevelMuteTapped   = 2000;
       
    50 
       
    51 const TInt KVolumeNaviPaneMutedValue = 0;
       
    52 
       
    53 // Define the loaded icon types - this affects drawing.
       
    54 const TInt KGfxModeNotLoaded    = 0;
       
    55 const TInt KGfxModeNew          = 1;// 1 slider type icon (+mask)
       
    56 const TInt KGfxModeOld          = 2;// 10 ball icons, one for each volume level (+masks)
       
    57 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
       
    58 // ----------------------------------------------------------------------------
       
    59 // Extension class
       
    60 //
       
    61 // ----------------------------------------------------------------------------
       
    62 //
       
    63 NONSHARABLE_CLASS(CVolumeExtension) : public CBase
       
    64     {
       
    65     public:
       
    66         CVolumeExtension();
       
    67         ~CVolumeExtension();
       
    68 
       
    69         // Methods for svg drawing
       
    70         static TBool UseSvgDrawing();
       
    71         void DeleteBitmaps();
       
    72         void SetIconSizes( TInt aStyle, const TRect& aParent ) const;
       
    73 
       
    74         void LoadBitmapsL( TInt aStyle, const TRect& aParent );
       
    75         
       
    76         // Sub-methods used by LoadBitmapsL
       
    77         void TryLoadBitmapsSkinnedL( MAknsSkinInstance* aSkin );
       
    78         void TryLoadBitmapsDefaultLargeL( MAknsSkinInstance* aSkin );
       
    79         void TryLoadBitmapsDefaultSmallL( MAknsSkinInstance* aSkin );
       
    80         void TryLoadBitmapsNoSkinL();
       
    81         
       
    82         void CalculateParentRect( TInt aStyle, const TRect& aParent );
       
    83         void DrawSvgSmallVolume( TInt aStyle, const TRect& aRect,
       
    84                                 CBitmapContext& aGc, TInt aValue );
       
    85         void DrawSvgSettingsVolume( const TRect& aRect,
       
    86                                 CWindowGc& aGc, TInt aValue );
       
    87         static void CreateSvgSettingsIconL( const TRect& aRect,
       
    88                                             TInt aValue, 
       
    89                                             CGulIcon* aIcon );
       
    90         static void CreateDynRangeStyleSettingsIconL( const TRect& aRect,
       
    91                                             TInt aValue, 
       
    92                                             CGulIcon* aIcon,
       
    93                                             TInt aMinimum,
       
    94                                             TInt aMaximum );                                   
       
    95                                             
       
    96         void DrawSvgSettingsIconL( const TRect& aRect,
       
    97                                     TInt aValue,
       
    98                                     CGulIcon* aIcon );
       
    99         void DrawDynRangeStyleSettingsIconL( const TRect& aRect,
       
   100                                     TInt aValue,
       
   101                                     CGulIcon* aIcon,
       
   102                                     TInt aMinimum, 
       
   103                                     TInt aMaximum );
       
   104                                     
       
   105         TInt GetVolumeLevelByPosition( const TInt& aStyle,
       
   106                                        const TPoint& aPoint,
       
   107                                        const TRect& aAreaRect ) const;
       
   108 
       
   109         TRect RectFromLayout( const TRect& aParent,
       
   110                               const TAknWindowComponentLayout& aComponentLayout
       
   111                             ) const;
       
   112 
       
   113         CFbsBitmap* iActiveIcons[KVolumeLevels];
       
   114         CFbsBitmap* iInActiveIcons[KVolumeLevels];
       
   115         CFbsBitmap* iActiveMasks[KVolumeLevels];
       
   116         CFbsBitmap* iInActiveMasks[KVolumeLevels];
       
   117 
       
   118         TRect iParentRect;  // Volume indicator area
       
   119         TRect iMuteRect; // Mute indicator rect for tapping 
       
   120 
       
   121         TRect iVolumeLevels[ KVolumeLevels ]; // Deprecated
       
   122         TInt iFlags;
       
   123 
       
   124         // Volume icons will be loaded the first time they are drawn,
       
   125         // not when the control is constructed.
       
   126         TBool iHasBeenDrawn;
       
   127         TFileName iBmpFilename;
       
   128         TInt iBmpId;
       
   129         TInt iBmpMask;
       
   130 
       
   131         CPeriodic* iTimer;
       
   132         TInt iEffectTimerCount;
       
   133         TInt iAnimatedEffectValue;
       
   134         
       
   135         TInt iStoredLevel;
       
   136         
       
   137         // For hi-res volume control implementation
       
   138         TInt iMinimumValue;
       
   139         TInt iMaximumValue;
       
   140         TInt iGfxMode; // Defines which icons are loaded when drawing
       
   141         TInt iOldScaleSettingVolume; // for 9 step setting volume
       
   142         
       
   143         /**
       
   144         * Flag to define whether or not this control is topmost on the navi pane's
       
   145         * control stack.
       
   146         */
       
   147         TBool iIsOnNaviStack;
       
   148         TInt iOldLevel;
       
   149         TBool iReduce;        
       
   150         
       
   151         TBool iNoDraw;        
       
   152         TBool iGrabPoint;
       
   153 
       
   154        /**
       
   155         * Extended touch area used 
       
   156         */
       
   157         TBool iUseExtendedTouchArea;
       
   158         
       
   159        /**
       
   160         * Touch area 
       
   161         */        
       
   162         TRect iTouchArea;
       
   163     };
       
   164 
       
   165 // ----------------------------------------------------------------------------
       
   166 // CAknVolumeControl::CAknVolumeControl()
       
   167 // Default constructor.
       
   168 // ----------------------------------------------------------------------------
       
   169 //
       
   170 EXPORT_C CAknVolumeControl::CAknVolumeControl()
       
   171     {
       
   172     AKNTASHOOK_ADD( this, "CAknVolumeControl" );
       
   173     }
       
   174 
       
   175 // ----------------------------------------------------------------------------
       
   176 // CAknVolumeControl::~CAknVolumeControl()
       
   177 // Destructor.
       
   178 // ----------------------------------------------------------------------------
       
   179 //
       
   180 EXPORT_C CAknVolumeControl::~CAknVolumeControl()
       
   181     {
       
   182     AKNTASHOOK_REMOVE();
       
   183     AknsUtils::DeregisterControlPosition( this );
       
   184     delete iBitmap;
       
   185     delete iMaskBitmap;
       
   186     delete iExtension;
       
   187     }
       
   188 
       
   189 // ----------------------------------------------------------------------------
       
   190 // CAknVolumeControl::SetValue(TInt aValue)
       
   191 // Sets the value.
       
   192 // ----------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C void CAknVolumeControl::SetValue( TInt aValue )
       
   195     {
       
   196     // NOTE: In settings page layouts (EDynRangeSettingsVolumeControl) 
       
   197     // using dynamic min and max values defined in the resource file. The 
       
   198     // values cannot be checked in SetValue() because SetValue() is called 
       
   199     // before ConstructFromResource() which actually reads the min and max 
       
   200     // values as well as the default value even though it is also given in 
       
   201     // the settings page constructor parameter.
       
   202     //
       
   203     if ( !iExtension )
       
   204         {
       
   205         return;
       
   206         }
       
   207     
       
   208     TBool valueChanged( aValue != iValue );
       
   209     
       
   210     switch( iStyle )
       
   211         {
       
   212         case EDynRangeSettingsVolumeControl:
       
   213         case EDynRangeNaviPaneVolumeControl:
       
   214             // Do not check EDynRangeSettingsVolumeControl because it's value 
       
   215             // might be set before the actual min and max are read from the 
       
   216             // resource (settings page feature).
       
   217             // Navi pane's EDynRangeNaviPaneVolumeControl is also ignored.
       
   218             break;
       
   219         default:
       
   220             __ASSERT_DEBUG( aValue >= iExtension->iMinimumValue && 
       
   221                             aValue <= iExtension->iMaximumValue, 
       
   222                             Panic( EAknPanicOutOfRange ) );
       
   223         }
       
   224     
       
   225     iValue = aValue;
       
   226 
       
   227     if ( iExtension )
       
   228         {
       
   229         iExtension->iFlags &= ~KVolumeNaviPaneMuted;
       
   230         }
       
   231 
       
   232     if ( iStyle == ENaviPaneVolumeControl || 
       
   233          iStyle == EDynRangeNaviPaneVolumeControl )
       
   234         {
       
   235         TInt event = MAknNavigationObserver::ENaviEventHandleNavigation;
       
   236         if ( iValue <= iExtension->iMinimumValue )
       
   237             {
       
   238             event=MAknNavigationObserver::ENaviEventLeftMostItemReached;
       
   239             if ( iValue == iExtension->iMinimumValue )
       
   240                 {
       
   241                 iExtension->iFlags |= KVolumeNaviPaneMuted;
       
   242                 }
       
   243             }
       
   244         else if ( iExtension->iMaximumValue == iValue )
       
   245             {
       
   246             event = MAknNavigationObserver::ENaviEventRightMostItemReached;
       
   247             }
       
   248         
       
   249         TRAP_IGNORE(
       
   250             ReportEventL(
       
   251                 STATIC_CAST( MCoeControlObserver::TCoeEvent, event ) ) );
       
   252 
       
   253         if ( valueChanged )
       
   254             {
       
   255             TRAP_IGNORE(
       
   256                 ReportEventL(
       
   257                     MCoeControlObserver::EEventStateChanged ) );
       
   258             }
       
   259 
       
   260         SetVolumeLayout( iStyle );
       
   261         if ( !iExtension->iNoDraw )
       
   262             {
       
   263             DrawNow();    
       
   264             }        
       
   265         
       
   266         // Volume popup is used instead of navi pane volume control,
       
   267         // pass the new value also to the popup.
       
   268         CAknVolumePopup* parent = static_cast<CAknVolumePopup*> ( Parent() );
       
   269         if ( parent && parent->ComponentControl( 5 ) == this )
       
   270             {
       
   271             if ( valueChanged )
       
   272                 {
       
   273                 parent->SetValue( aValue );
       
   274                 }
       
   275 
       
   276             if ( iExtension->iIsOnNaviStack && ( valueChanged ||
       
   277                 aValue == iExtension->iMinimumValue ||
       
   278                 aValue == iExtension->iMaximumValue ) )
       
   279                 {
       
   280                 // Show the popup only if status pane is visible
       
   281                 // to maintain same kind of functionality as in
       
   282                 // navi pane volume control.
       
   283                 CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
       
   284                 if ( sp && sp->IsVisible() )
       
   285                     {
       
   286                     TRAP_IGNORE( parent->ShowVolumePopupL() );
       
   287                     }
       
   288                 }
       
   289             }
       
   290         }
       
   291     }
       
   292 
       
   293 // ----------------------------------------------------------------------------
       
   294 // CAknVolumeControl::Value() const
       
   295 // Returns the value.
       
   296 // ----------------------------------------------------------------------------
       
   297 //
       
   298 EXPORT_C TInt CAknVolumeControl::Value() const
       
   299     {
       
   300     return iValue;
       
   301     }
       
   302 
       
   303 // ----------------------------------------------------------------------------
       
   304 // CAknVolumeControl::SetRange()
       
   305 //
       
   306 // ----------------------------------------------------------------------------
       
   307 //
       
   308 EXPORT_C void CAknVolumeControl::SetRange( TInt aMinimumValue, 
       
   309                                            TInt aMaximumValue )
       
   310     {
       
   311     TBool rangeChanged( aMinimumValue != iExtension->iMinimumValue ||
       
   312                         aMaximumValue != iExtension->iMaximumValue );
       
   313     
       
   314     __ASSERT_DEBUG( aMinimumValue < aMaximumValue, 
       
   315                      Panic( EAknPanicInvalidValue ) );
       
   316     if ( iExtension )
       
   317         {
       
   318         iExtension->iMinimumValue = aMinimumValue;
       
   319         iExtension->iMaximumValue = aMaximumValue;
       
   320         }
       
   321         
       
   322     // disable old volume control scaling
       
   323     if(iExtension->iOldScaleSettingVolume)
       
   324         {
       
   325         iExtension->iOldScaleSettingVolume = EFalse;
       
   326         }
       
   327         
       
   328     if ( iExtension->iIsOnNaviStack )
       
   329         {
       
   330         // Volume popup is used instead of navi pane volume control,
       
   331         // pass the new range also to the popup.
       
   332         CAknVolumePopup* parent = static_cast<CAknVolumePopup*> ( Parent() );
       
   333 
       
   334         if ( parent && parent->ComponentControl( 5 ) == this )
       
   335             {
       
   336             if ( rangeChanged )
       
   337                 {
       
   338                 parent->SetRange( aMinimumValue, aMaximumValue );
       
   339                 }
       
   340             }
       
   341         }
       
   342     }
       
   343 
       
   344 // ----------------------------------------------------------------------------
       
   345 // CAknVolumeControl::GetRange()
       
   346 //
       
   347 // ----------------------------------------------------------------------------
       
   348 //
       
   349 EXPORT_C void CAknVolumeControl::GetRange( TInt& aMinimumValue, 
       
   350                                            TInt& aMaximumValue )
       
   351     {
       
   352     if ( iExtension )
       
   353         {
       
   354         aMinimumValue = iExtension->iMinimumValue;
       
   355         aMaximumValue = iExtension->iMaximumValue;
       
   356         }
       
   357     }
       
   358 
       
   359 // ----------------------------------------------------------------------------
       
   360 // CAknVolumeControl::CreateBitmapL()
       
   361 //
       
   362 // ----------------------------------------------------------------------------
       
   363 //
       
   364 EXPORT_C CFbsBitmap* CAknVolumeControl::CreateBitmapL(TInt aValue)
       
   365     {
       
   366     CGulIcon* icon = 
       
   367             CreateSetStyleListBoxIconL( aValue ); // now have ownership
       
   368     icon->SetBitmapsOwnedExternally( ETrue );
       
   369     CFbsBitmap* bitmap = icon->Bitmap();
       
   370     CFbsBitmap* mask = icon->Mask();
       
   371     delete icon;
       
   372     delete mask;
       
   373     return bitmap; // Ownership transferred
       
   374     }
       
   375 
       
   376 // ----------------------------------------------------------------------------
       
   377 // CAknVolumeControl::CreateSetStyleListBoxIconL()
       
   378 // Draw volume control in setting list item
       
   379 // ----------------------------------------------------------------------------
       
   380 //
       
   381 EXPORT_C CGulIcon* CAknVolumeControl::CreateSetStyleListBoxIconL( TInt aValue )
       
   382     {
       
   383     
       
   384     // Make the icon and put it in the array
       
   385     CGulIcon* icon = CGulIcon::NewLC();
       
   386 
       
   387     TRect origin;
       
   388     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, origin );
       
   389 
       
   390     TAknLayoutRect layoutRect;
       
   391     layoutRect.LayoutRect(origin,
       
   392                     AknLayoutScalable_Avkon::listscroll_gen_pane(0));
       
   393     layoutRect.LayoutRect(layoutRect.Rect(),
       
   394                     AknLayoutScalable_Avkon::list_gen_pane(0));
       
   395     layoutRect.LayoutRect(layoutRect.Rect(),
       
   396                     AknLayoutScalable_Avkon::list_setting_number_pane(0));
       
   397     layoutRect.LayoutRect(layoutRect.Rect(),
       
   398                     AknLayoutScalable_Avkon::set_value_pane(0));
       
   399     layoutRect.LayoutRect(layoutRect.Rect(),
       
   400                     AknLayoutScalable_Avkon::volume_small_pane_cp());
       
   401     TRect rect(layoutRect.Rect());
       
   402 
       
   403     // Move to 0,0
       
   404     rect.Move(-rect.iTl.iX,-rect.iTl.iY);
       
   405 
       
   406     CVolumeExtension::CreateSvgSettingsIconL( rect, aValue, icon );
       
   407 
       
   408     CleanupStack::Pop( icon ); // icon - not owned anymore, do not destroy
       
   409 
       
   410     return icon; // Ownership transferred
       
   411     }
       
   412 
       
   413 // ----------------------------------------------------------------------------
       
   414 // CAknVolumeControl::CreateScalableListBoxIconL()
       
   415 // Draw a scalable volume control in setting list item
       
   416 // ----------------------------------------------------------------------------
       
   417 //
       
   418 EXPORT_C CGulIcon* CAknVolumeControl::CreateSetDynRangeStyleListBoxIconL( 
       
   419                                                                  TInt aValue,
       
   420                                                                  TInt aMinimum,
       
   421                                                                  TInt aMaximum )
       
   422     {
       
   423     
       
   424     
       
   425     // Make the icon and put it in the array
       
   426     CGulIcon* icon = CGulIcon::NewLC();
       
   427 
       
   428     TRect origin;
       
   429     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, origin );
       
   430 
       
   431     TAknLayoutRect layoutRect;
       
   432     layoutRect.LayoutRect(origin,
       
   433                     AknLayoutScalable_Avkon::listscroll_gen_pane(0));
       
   434     layoutRect.LayoutRect(layoutRect.Rect(),
       
   435                     AknLayoutScalable_Avkon::list_gen_pane(0));
       
   436     layoutRect.LayoutRect(layoutRect.Rect(),
       
   437                     AknLayoutScalable_Avkon::list_setting_number_pane(0));
       
   438     layoutRect.LayoutRect(layoutRect.Rect(),
       
   439                     AknLayoutScalable_Avkon::set_value_pane(0));
       
   440     layoutRect.LayoutRect(layoutRect.Rect(),
       
   441                     AknLayoutScalable_Avkon::volume_small_pane_cp());
       
   442     TRect rect(layoutRect.Rect());
       
   443 
       
   444     // Move to 0,0
       
   445     rect.Move(-rect.iTl.iX,-rect.iTl.iY);
       
   446 
       
   447     CVolumeExtension::CreateDynRangeStyleSettingsIconL( rect, aValue, icon, 
       
   448                                                         aMinimum, aMaximum );
       
   449 
       
   450     CleanupStack::Pop( icon ); // icon - not owned anymore, do not destroy
       
   451 
       
   452     return icon; // Ownership transferred
       
   453     }
       
   454   
       
   455     
       
   456 // ----------------------------------------------------------------------------
       
   457 // CAknVolumeControl::HandleNaviStackChange()
       
   458 // ----------------------------------------------------------------------------
       
   459 //    
       
   460 void CAknVolumeControl::HandleNaviStackChange( TBool aIsOnNaviStack )
       
   461     {
       
   462     if ( iExtension )
       
   463         {
       
   464         iExtension->iIsOnNaviStack = aIsOnNaviStack;
       
   465         }
       
   466     }
       
   467     
       
   468     
       
   469 // ----------------------------------------------------------------------------
       
   470 // CAknVolumeControl::MinimumSize()
       
   471 // Returns the size.
       
   472 // ----------------------------------------------------------------------------
       
   473 //
       
   474 TSize CAknVolumeControl::MinimumSize()
       
   475     {
       
   476     TAknLayoutRect layout;
       
   477     if ( iStyle == ENaviPaneVolumeControl )
       
   478         {
       
   479         if ( AknStatuspaneUtils::SmallLayoutActive() )
       
   480             {
       
   481             layout.LayoutRect( Rect(),
       
   482                         AknLayoutScalable_Avkon::volume_small2_pane() );        
       
   483             }
       
   484         else
       
   485             {
       
   486             layout.LayoutRect( Rect(),
       
   487                         AknLayoutScalable_Avkon::volume_small_pane() );        
       
   488             }
       
   489         
       
   490         return layout.Rect().Size();
       
   491         }
       
   492     else // Setting Page & Popup volume control
       
   493         {
       
   494         return Rect().Size();
       
   495         }
       
   496     }
       
   497 
       
   498 // ----------------------------------------------------------------------------
       
   499 // CAknVolumeControl::OfferKeyEventL
       
   500 // Handles the key events.
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 TKeyResponse CAknVolumeControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   504                                                 TEventCode aType )
       
   505     {
       
   506     if ( aType == EEventKey )
       
   507         {
       
   508         TInt volumeValue = Value();
       
   509         switch( aKeyEvent.iCode )
       
   510             {
       
   511             case EKeyLeftArrow:
       
   512                 {
       
   513                 if (volumeValue > iExtension->iMinimumValue)
       
   514                     {
       
   515                     volumeValue--;
       
   516                     SetValue( volumeValue );
       
   517                     if ( iStyle != EDynRangePopupVolumeControl &&
       
   518                          !iExtension->iNoDraw )
       
   519                         {                        
       
   520                         DrawNow();
       
   521                         }
       
   522                     ReportEventL( MCoeControlObserver::EEventStateChanged );
       
   523                     }
       
   524                 else
       
   525                     {
       
   526                     CAknVolumePopup* parent =
       
   527                         static_cast<CAknVolumePopup*> ( Parent() );
       
   528                     if ( iExtension &&
       
   529                          iExtension->iIsOnNaviStack &&
       
   530                          parent &&
       
   531                          parent->ComponentControl( 5 ) == this )
       
   532                         {
       
   533                         // Show the volume popup even if volume level is not changed
       
   534                         // to indicate that a volume adjustment key event has been
       
   535                         // received.
       
   536                         CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
       
   537                         if ( sp && sp->IsVisible() )
       
   538                             {
       
   539                             // Show the popup only if status pane is visible
       
   540                             // to maintain same kind of functionality as in
       
   541                             // navi pane volume control.
       
   542                             parent->ShowVolumePopupL();
       
   543                             }
       
   544                         }
       
   545                         
       
   546                     if ( iStyle != ESettingsVolumeControl )
       
   547                         {
       
   548                         TInt event = MAknNavigationObserver::ENaviEventLeftMostItemReached;
       
   549                         ReportEventL( 
       
   550                             STATIC_CAST( MCoeControlObserver::TCoeEvent, event ) );
       
   551                         }
       
   552 #ifdef RD_ANIMATION_EFFECTS
       
   553                     else if (iExtension && (iExtension->iGfxMode == KGfxModeOld))
       
   554                         {
       
   555                         // only with old volume graphics
       
   556                         StartTimerL();
       
   557                         }
       
   558 #endif
       
   559                     }
       
   560                     
       
   561                 return EKeyWasConsumed;
       
   562                 }
       
   563             case EKeyRightArrow:
       
   564                 {
       
   565                 if ( iExtension && (volumeValue < iExtension->iMaximumValue) )
       
   566                     {
       
   567                     volumeValue++;
       
   568                     SetValue( volumeValue );
       
   569                     if ( iStyle != EDynRangePopupVolumeControl && 
       
   570                          !iExtension->iNoDraw )
       
   571                         {                        
       
   572                         DrawNow();
       
   573                         }
       
   574                     ReportEventL( MCoeControlObserver::EEventStateChanged );                    
       
   575                     }
       
   576                 else
       
   577                     {
       
   578                     CAknVolumePopup* parent =
       
   579                         static_cast<CAknVolumePopup*> ( Parent() );
       
   580                     if ( iExtension &&
       
   581                          iExtension->iIsOnNaviStack &&
       
   582                          parent &&
       
   583                          parent->ComponentControl( 5 ) == this )
       
   584                         {
       
   585                         // Show the volume popup even if volume level is not changed
       
   586                         // to indicate that a volume adjustment key event has been
       
   587                         // received.
       
   588                         CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
       
   589                         if ( sp && sp->IsVisible() )
       
   590                             {
       
   591                             // Show the popup only if status pane is visible
       
   592                             // to maintain same kind of functionality as in
       
   593                             // navi pane volume control.
       
   594                             parent->ShowVolumePopupL();
       
   595                             }
       
   596                         }
       
   597                         
       
   598                     if ( iStyle != ESettingsVolumeControl )
       
   599                         {
       
   600                         TInt event = MAknNavigationObserver::ENaviEventRightMostItemReached;
       
   601                         ReportEventL(
       
   602                             STATIC_CAST( MCoeControlObserver::TCoeEvent, event ) );
       
   603                         }
       
   604 #ifdef RD_ANIMATION_EFFECTS
       
   605                     else if (iExtension && iExtension->iGfxMode == KGfxModeOld)
       
   606                         {
       
   607                         // only with old volume graphics
       
   608                         StartTimerL();
       
   609                         }
       
   610 #endif
       
   611                     }
       
   612                     
       
   613                 return EKeyWasConsumed;
       
   614                 }
       
   615             default:
       
   616                 break;
       
   617             }
       
   618         }
       
   619     return EKeyWasNotConsumed;
       
   620     }
       
   621 
       
   622 // ----------------------------------------------------------------------------
       
   623 // CAknVolumeControl::ConstructFromResourceL(TResourceReader& aReader)
       
   624 // Basic construct from the resource function.
       
   625 // ----------------------------------------------------------------------------
       
   626 //
       
   627 EXPORT_C void CAknVolumeControl::ConstructFromResourceL(
       
   628                             TResourceReader& aReader)
       
   629     {
       
   630     TBool newResourceStructUsed = EFalse;
       
   631     
       
   632     iStyle=aReader.ReadInt16();
       
   633         
       
   634     if(iStyle == -1) // 0xfffffff
       
   635         {
       
   636         newResourceStructUsed = ETrue;
       
   637         iStyle=aReader.ReadInt16();
       
   638         }
       
   639              
       
   640     if (iStyle == ESmallPopupVolumeControl || 
       
   641         iStyle == ESmallPopupVolumeControlWithPercent )
       
   642         {
       
   643         iStyle = EDynRangePopupVolumeControl;
       
   644         }
       
   645     __ASSERT_ALWAYS( iStyle == ESettingsVolumeControl
       
   646                      || iStyle == ENaviPaneVolumeControl
       
   647                      || iStyle == EPopupVolumeControl
       
   648                      || iStyle == EDynRangeSettingsVolumeControl
       
   649                      || iStyle == EDynRangeNaviPaneVolumeControl
       
   650                      || iStyle == EDynRangePopupVolumeControl,
       
   651                      Panic( EAknPanicOutOfRange ) );
       
   652 
       
   653     iExtension = new(ELeave) CVolumeExtension;
       
   654     iExtension->iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   655 
       
   656     TInt value = aReader.ReadInt16();
       
   657 
       
   658 
       
   659     TPtrC bmpFile=aReader.ReadTPtrC();
       
   660     TFileName filename( bmpFile );
       
   661     CompleteWithAppPath( filename );
       
   662     TInt bmpId=aReader.ReadInt16();
       
   663     TInt bmpMask=aReader.ReadInt16();
       
   664     
       
   665     if ( iStyle != ESettingsVolumeControl )
       
   666         {
       
   667         iExtension->iBmpFilename = filename;
       
   668         iExtension->iBmpId = bmpId;
       
   669         iExtension->iBmpMask = bmpMask;
       
   670         
       
   671         CreateNaviIconL();
       
   672         // Rest of the volume icons will be loaded later.
       
   673         }
       
   674     
       
   675     // Read default min and max volume values from new VOLUME struct used by 
       
   676     // new hi-res volume layout resources. These are not defined in older 
       
   677     // layout resources so do not read these in this case.
       
   678     if( newResourceStructUsed )
       
   679         {
       
   680         iExtension->iMinimumValue = aReader.ReadInt16();
       
   681         iExtension->iMaximumValue = aReader.ReadInt16();
       
   682         __ASSERT_DEBUG( iExtension->iMinimumValue < iExtension->iMaximumValue, 
       
   683                         Panic( EAknPanicInvalidValue ) );
       
   684         
       
   685         }
       
   686     // setting volume, also dyn range uses 1-10 scale if using old struct
       
   687     else if(iStyle == ESettingsVolumeControl || iStyle == EDynRangeSettingsVolumeControl)
       
   688         {
       
   689         // set scaled value calculation to note the old 1-10 scale with 10 graphics
       
   690         iExtension->iOldScaleSettingVolume = ETrue;
       
   691         iExtension->iMinimumValue = KVolumeMinValue;
       
   692         iExtension->iMaximumValue = KVolumeMaxValue;
       
   693         }
       
   694     else
       
   695         {
       
   696         iExtension->iMinimumValue = KVolumeNaviPaneMutedValue;
       
   697         iExtension->iMaximumValue = KVolumeMaxValue;
       
   698         }
       
   699     
       
   700     if ( iStyle == EPopupVolumeControl)
       
   701         {
       
   702         iStyle = EDynRangePopupVolumeControl;
       
   703         }
       
   704     // SetValue checks iMinimumValue and iMaximumValue which must be read before this
       
   705     SetValue( value );
       
   706     }
       
   707 
       
   708 // ----------------------------------------------------------------------------
       
   709 // CAknVolumeControl::SizeChanged()
       
   710 // Sets the layout.
       
   711 // ----------------------------------------------------------------------------
       
   712 //
       
   713 void CAknVolumeControl::SizeChanged()
       
   714     {
       
   715     AknsUtils::RegisterControlPosition( this );
       
   716     SetVolumeLayout( iStyle );
       
   717     if ( AknLayoutUtils::PenEnabled()&& 
       
   718          iExtension &&
       
   719          !iExtension->iGrabPoint )
       
   720         {
       
   721         // Enable drag events, it will then be possible to drag from thumb
       
   722         EnableDragEvents();
       
   723         
       
   724         //Enable dragging to start from thumb and then move outside the slider
       
   725         DrawableWindow()->SetPointerGrab( ETrue );
       
   726         
       
   727         iExtension->iGrabPoint = ETrue;
       
   728         }
       
   729     }
       
   730 
       
   731 // ----------------------------------------------------------------------------
       
   732 // CAknVolumeControl::SetVolumeLayout(TInt aStyle)
       
   733 // Pure layout function.
       
   734 // ----------------------------------------------------------------------------
       
   735 //
       
   736 void CAknVolumeControl::SetVolumeLayout( TInt aStyle )
       
   737     {
       
   738     TAknLayoutRect layout;
       
   739     TRect rect(Rect());
       
   740     TRect parentRect( Rect() );
       
   741 
       
   742     switch ( aStyle )
       
   743         {
       
   744         case ESettingsVolumeControl:
       
   745             {
       
   746             layout.LayoutRect( rect,
       
   747                                 AknLayoutScalable_Avkon::volume_set_pane_g1() );
       
   748             iStartPos = layout.Rect().iTl;
       
   749 
       
   750             if ( iExtension )
       
   751                 {
       
   752                 iExtension->CalculateParentRect( aStyle, rect );
       
   753                 UseExtendedTouchArea();
       
   754                 return;
       
   755                 }
       
   756             }
       
   757             break;
       
   758 
       
   759         case ENaviPaneVolumeControl:
       
   760         case EDynRangeNaviPaneVolumeControl:        
       
   761             {
       
   762             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   763             TRgb color;
       
   764             AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnIconColors,
       
   765                                         EAknsCIQsnIconColorsCG7 );
       
   766             TRAP_IGNORE ( CreateNaviIconL() );
       
   767             if (AknStatuspaneUtils::StaconPaneActive())
       
   768                 {
       
   769                 rect = CAknNavigationDecorator::DecoratedControlRect(
       
   770                             CAknNavigationDecorator::ENaviVolume );
       
   771                 layout.LayoutRect( rect,
       
   772                         AknLayoutScalable_Avkon::volume_small_pane() );
       
   773                 iStartPos = TPoint( layout.Rect().iTl.iX ,
       
   774                                     layout.Rect().iTl.iY );
       
   775                 layout.LayoutRect( rect,
       
   776                         AknLayoutScalable_Avkon::navi_navi_volume_pane_g1() );
       
   777                 iBmpPos = TPoint( layout.Rect().iTl.iX ,
       
   778                                   layout.Rect().iTl.iY );
       
   779                 
       
   780                 }
       
   781             else if (AknStatuspaneUtils::IdleLayoutActive())
       
   782                 {
       
   783                 layout.LayoutRect( rect,
       
   784                     AknLayoutScalable_Avkon::volume_small_pane() );
       
   785                 iStartPos = TPoint( layout.Rect().iTl.iX - rect.iTl.iX,
       
   786                                     layout.Rect().iTl.iY );
       
   787 
       
   788                 layout.LayoutRect( rect,
       
   789                     AknLayoutScalable_Avkon::navi_navi_volume_pane_g1() );
       
   790                 iBmpPos = TPoint( layout.Rect().iTl.iX - rect.iTl.iX,
       
   791                                   layout.Rect().iTl.iY );
       
   792 
       
   793                 }
       
   794             else if ( AknStatuspaneUtils::SmallLayoutActive() )
       
   795                 {
       
   796                 //Get the volume strength indicator layout
       
   797                 layout.LayoutRect( rect,
       
   798                     AknLayoutScalable_Avkon::volume_small2_pane() );
       
   799                 //volume strength indicator start position
       
   800                 iStartPos = TPoint( layout.Rect().iTl.iX, 
       
   801                                     layout.Rect().iTl.iY );
       
   802                 
       
   803                 //Bitmap layout
       
   804                 layout.LayoutRect( parentRect, 
       
   805                     AknLayoutScalable_Avkon::status_small_volume_pane_g1()
       
   806                     );
       
   807                 iBmpPos = TPoint( layout.Rect().iTl.iX,
       
   808                                   layout.Rect().iTl.iY );
       
   809                 }
       
   810             else
       
   811                 {
       
   812                 layout.LayoutRect( rect,
       
   813                     AknLayoutScalable_Avkon::volume_small_pane() );
       
   814                 iStartPos = TPoint( layout.Rect().iTl.iX - rect.iTl.iX,
       
   815                                     layout.Rect().iTl.iY );
       
   816                 layout.LayoutRect( rect,
       
   817                     AknLayoutScalable_Avkon::navi_navi_volume_pane_g1() );
       
   818                 iBmpPos = TPoint( layout.Rect().iTl.iX - rect.iTl.iX,
       
   819                                   layout.Rect().iTl.iY );
       
   820                 }
       
   821             if ( iBitmap != NULL )
       
   822                 {
       
   823                 AknIconUtils::SetIconColor( iBitmap, color );
       
   824                 AknIconUtils::SetSize(iBitmap, layout.Rect().Size());
       
   825                 if ( iExtension )
       
   826                     {
       
   827                     iExtension->iMuteRect = layout.Rect();
       
   828                     }
       
   829                 }
       
   830             }
       
   831             break;
       
   832 
       
   833         case EPopupVolumeControl:
       
   834             // just use given rect!
       
   835             iStartPos = TPoint( rect.iTl.iX, rect.iTl.iY ); 
       
   836             break;
       
   837 
       
   838         default:
       
   839             // does not happen
       
   840             break;
       
   841         }
       
   842 
       
   843     if ( iExtension )
       
   844         {
       
   845         iExtension->CalculateParentRect( aStyle, parentRect );
       
   846         }
       
   847     }
       
   848 
       
   849 // ----------------------------------------------------------------------------
       
   850 // CAknVolumeControl::Draw(const TRect& aRect) const
       
   851 // Implementation of automatically called control drawing function from 
       
   852 // CCoeControl.
       
   853 // ----------------------------------------------------------------------------
       
   854 //
       
   855 void CAknVolumeControl::Draw( const TRect& /*aRect*/ ) const
       
   856     {
       
   857     if ( iExtension->iNoDraw )
       
   858         {
       
   859         return;
       
   860         }
       
   861     /*
       
   862     * If there are volume graphics in active skin, use those to be compatible 
       
   863     * with 2.6 skins, then check for svg graphics. If that fails, draw using 
       
   864     * legacy code
       
   865     */
       
   866     if ( iExtension && !iExtension->iHasBeenDrawn )
       
   867         {
       
   868         TRAP_IGNORE( iExtension->LoadBitmapsL( iStyle, Rect()
       
   869                                                /*iAvkonAppUi->ApplicationRect() */));
       
   870         iExtension->iHasBeenDrawn = ETrue;
       
   871         }
       
   872     
       
   873     if( iExtension && iExtension->iGfxMode == KGfxModeNew)
       
   874         {
       
   875         DrawDynRangeSettingsStyleVolumeControl( iExtension->iParentRect );
       
   876         }
       
   877     else if( iExtension )
       
   878         {
       
   879             switch( iStyle )
       
   880             {
       
   881             case ESettingsVolumeControl:
       
   882                 DrawSettingsStyleVolumeControl( Rect() );
       
   883                 break;
       
   884             default:
       
   885                 if( AknsUtils::AvkonSkinEnabled() )
       
   886                     {
       
   887                     DrawSkinnedDefaultStyleVolumeControl( Rect() );
       
   888                     }
       
   889                 else
       
   890                     {
       
   891                     DrawDefaultStyleVolumeControl( Rect() );
       
   892                     }
       
   893                 break;
       
   894             }    
       
   895         }
       
   896     
       
   897     }
       
   898 
       
   899 // ----------------------------------------------------------------------------
       
   900 // CAknVolumeControl::DrawSettingsStyleVolumeControl
       
   901 //
       
   902 // ----------------------------------------------------------------------------
       
   903 //
       
   904 void CAknVolumeControl::DrawSettingsStyleVolumeControl( const TRect& aRect ) const
       
   905     {
       
   906     CWindowGc& gc=SystemGc();
       
   907     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   908     MAknsControlContext* edCc = AknsDrawUtils::ControlContext( this );
       
   909     AknsDrawUtils::Background( skin, edCc, this, gc, aRect );
       
   910 
       
   911     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   912     gc.SetPenStyle(CGraphicsContext::ENullPen);
       
   913 
       
   914     if (AknsUtils::AvkonSkinEnabled() && iExtension)
       
   915         {
       
   916         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   917         iExtension->DrawSvgSettingsVolume( iExtension->iParentRect, 
       
   918                                            gc, 
       
   919                                            ScaledValue() );
       
   920         return;
       
   921         }
       
   922     else
       
   923         {
       
   924         //I'm not sure whether this branch is useless or not ,so I didn't delete this branch.
       
   925         TInt colorIndex = 0;
       
   926         for (TInt i=0; i < KVolumeLevels; i++) // there is ten bars
       
   927             {
       
   928             if ( i < ScaledValue() )
       
   929                 {
       
   930                 colorIndex = 1;
       
   931                 }
       
   932             else
       
   933                 {
       
   934                 colorIndex = 0;
       
   935                 }
       
   936             TRect rect = Rect();
       
   937             TAknWindowLineLayout layout = AKN_LAYOUT_TABLE_Setting_volume_pane_elements_SUB_TABLE_0(i + 1, colorIndex);
       
   938             TAknLayoutRect volumeBarLayout;
       
   939             volumeBarLayout.LayoutRect(rect, layout);
       
   940             if ( iExtension && AknLayoutUtils::PenEnabled() )
       
   941                 {
       
   942                 // Store rect for every level. We can then decide what level was clicked
       
   943                 iExtension->iVolumeLevels[i] = volumeBarLayout.Rect();
       
   944                 }
       
   945             gc.SetBrushColor( volumeBarLayout.Color() );
       
   946             gc.DrawRect( volumeBarLayout.Rect() );
       
   947             }
       
   948         }
       
   949     }
       
   950 
       
   951 
       
   952 // ----------------------------------------------------------------------------
       
   953 // CAknVolumeControl::DrawDynRangeSettingsStyleVolumeControl
       
   954 //
       
   955 // ----------------------------------------------------------------------------
       
   956 //
       
   957 void CAknVolumeControl::DrawDynRangeSettingsStyleVolumeControl( 
       
   958     const TRect& aVolumeArea ) const
       
   959     {
       
   960     // !!! Assumptions used: Sizes of iExtension->iInActiveIcons[0],
       
   961     // iExtension->iActiveIcons[0], corresponding masks and 
       
   962     // aVolumeArea are identical.
       
   963     CWindowGc& gc=SystemGc();
       
   964     if ( !Background() )
       
   965         {
       
   966         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   967         MAknsControlContext* edCc = AknsDrawUtils::ControlContext( this );
       
   968         
       
   969         if ( iStyle != EDynRangePopupVolumeControl )
       
   970             {        
       
   971             AknsDrawUtils::Background( skin, edCc, this, gc, aVolumeArea );
       
   972             }
       
   973         }
       
   974     else
       
   975         {
       
   976         Background()->Draw( gc, *this, aVolumeArea );
       
   977         }
       
   978 
       
   979     // Only skin enabled version should exist
       
   980     TRect iconRect(0,0, iExtension->iActiveIcons[0]->SizeInPixels().iWidth,
       
   981                         iExtension->iActiveIcons[0]->SizeInPixels().iHeight );
       
   982 
       
   983     TRect activeRect;// rect area used for active volume slider icon
       
   984     TRect inactiveRect;// rect area used for inactive volume slider icon
       
   985     
       
   986     CalcVolumeIconAreas( Value(), 
       
   987                          aVolumeArea, 
       
   988                          activeRect, 
       
   989                          inactiveRect );
       
   990     
       
   991     // Area of the actual icon to be drawn in rect area
       
   992     TRect activeIcon( 0, 0, 
       
   993                       activeRect.iBr.iX - activeRect.iTl.iX, 
       
   994                       activeRect.iBr.iY - activeRect.iTl.iY ); 
       
   995     
       
   996     // Area of the actual icon to be drawn in rect area
       
   997     TRect inactiveIcon( inactiveRect.iTl.iX - aVolumeArea.iTl.iX, 
       
   998                         0,
       
   999                         inactiveRect.iBr.iX - aVolumeArea.iTl.iX,
       
  1000                         inactiveRect.iBr.iY - aVolumeArea.iTl.iY );
       
  1001 
       
  1002     gc.BitBltMasked( activeRect.iTl, 
       
  1003                      iExtension->iActiveIcons[0], 
       
  1004                      activeIcon, 
       
  1005                      iExtension->iActiveMasks[0], ETrue );
       
  1006 
       
  1007     gc.BitBltMasked( inactiveRect.iTl, 
       
  1008                      iExtension->iInActiveIcons[0], 
       
  1009                      inactiveIcon, 
       
  1010                      iExtension->iInActiveMasks[0], ETrue );
       
  1011     // Draw speaker or mute icon
       
  1012     if ( ( iBitmap != NULL ) && ( iMaskBitmap != NULL ) )
       
  1013         {
       
  1014         TRect bmpRect(TPoint(0,0),TSize(iBitmap->SizeInPixels()));
       
  1015         if (iStyle == EDynRangeNaviPaneVolumeControl)  // popup handles icons itself
       
  1016             {
       
  1017             gc.BitBltMasked(iBmpPos, iBitmap, bmpRect, iMaskBitmap, ETrue);
       
  1018             }
       
  1019         }    
       
  1020     }
       
  1021 
       
  1022 
       
  1023 // ----------------------------------------------------------------------------
       
  1024 // CAknVolumeControl::CalcVolumeIconAreas()
       
  1025 //
       
  1026 // ----------------------------------------------------------------------------
       
  1027 //
       
  1028 void CAknVolumeControl::CalcVolumeIconAreas( const TInt aVolume, 
       
  1029                                              const TRect& aDrawArea,
       
  1030                                              TRect& aActiveRect, 
       
  1031                                              TRect& aInactiveRect ) const
       
  1032     {
       
  1033     // Calculate drawing area split between active and inactive icon areas in percentage
       
  1034     // it is caculating the activeRatio by iOldScaleSettingVolume
       
  1035     // it is very important for drawing the volumecontrol
       
  1036     // because the tester requires there must be at least one piece of shadow in it,
       
  1037     // if we set the iMinimumValue not as (iMinimunValue+1) in HandlePointerEventL and 
       
  1038     // draw the aActiveRect like this, all things go well. 
       
  1039     TInt activeRatio;
       
  1040     if( !iExtension->iOldScaleSettingVolume )
       
  1041         {
       
  1042         activeRatio = ( aVolume - iExtension->iMinimumValue ) * 100
       
  1043                         / ( iExtension->iMaximumValue - iExtension->iMinimumValue );
       
  1044         }
       
  1045     
       
  1046     else
       
  1047         {
       
  1048         activeRatio = aVolume * 10;
       
  1049         }
       
  1050     aActiveRect.iTl.iX = aDrawArea.iTl.iX;
       
  1051     aActiveRect.iTl.iY = aDrawArea.iTl.iY;
       
  1052     aActiveRect.iBr.iX = aDrawArea.iTl.iX + ( aDrawArea.iBr.iX - aDrawArea.iTl.iX ) * activeRatio / 100;
       
  1053     aActiveRect.iBr.iY = aDrawArea.iBr.iY;
       
  1054     
       
  1055     aInactiveRect.iTl.iX = aActiveRect.iBr.iX /*+ 1*/;
       
  1056     aInactiveRect.iTl.iY = aDrawArea.iTl.iY;
       
  1057     aInactiveRect.iBr.iX = aDrawArea.iBr.iX;
       
  1058     aInactiveRect.iBr.iY = aDrawArea.iBr.iY;
       
  1059     }
       
  1060     
       
  1061     
       
  1062 // ----------------------------------------------------------------------------
       
  1063 // CAknVolumeControl::DrawDefaultStyleVolumeControl()
       
  1064 // NON SKINNED DRAW!
       
  1065 // ----------------------------------------------------------------------------
       
  1066 //
       
  1067 void CAknVolumeControl::DrawDefaultStyleVolumeControl( const TRect& /*aRect*/ ) const
       
  1068     {
       
  1069     CWindowGc& gc=SystemGc();
       
  1070     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1071     
       
  1072     //I'm not sure whether this branch is useless or not ,so I didn't delete this branch.
       
  1073     TInt volumeLIndex;
       
  1074     TAknLayoutRect layoutRect;
       
  1075 
       
  1076     if ( AknStatuspaneUtils::IdleLayoutActive() )
       
  1077         {
       
  1078         volumeLIndex = 0;
       
  1079         }
       
  1080     else
       
  1081         {
       
  1082         volumeLIndex = 1;
       
  1083         }
       
  1084 
       
  1085     TRect parent( TSize( 0, 0 ) );
       
  1086     TRect volumeNaviPaneRect;   // volume_navi_pane
       
  1087 
       
  1088     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1089     gc.SetPenStyle(CGraphicsContext::ENullPen); // column drawing should have no outline
       
  1090     TRgb c1, c2;
       
  1091 
       
  1092     if (iStyle == ENaviPaneVolumeControl)
       
  1093         {
       
  1094         layoutRect.LayoutRect( parent, AKN_LAYOUT_WINDOW_volume_navi_pane( volumeLIndex ) );
       
  1095         volumeNaviPaneRect = layoutRect.Rect();
       
  1096 
       
  1097         layoutRect.LayoutRect( volumeNaviPaneRect, AKN_LAYOUT_TABLE_Volume_pane_elements__one_( 0, 0 ) );
       
  1098         c1 = layoutRect.Color();
       
  1099         layoutRect.LayoutRect( volumeNaviPaneRect, AKN_LAYOUT_TABLE_Volume_pane_elements__one_( 0, 1 ) );
       
  1100         c2 = layoutRect.Color();
       
  1101         }
       
  1102     else  // Popup volume needs different colors
       
  1103         {
       
  1104         layoutRect.LayoutRect( Rect(), AKN_LAYOUT_TABLE_Volume_pane_elements__one_( 0, 0 ) );
       
  1105         c1 = layoutRect.Color();
       
  1106         layoutRect.LayoutRect( Rect(), AKN_LAYOUT_TABLE_Setting_volume_pane_elements_SUB_TABLE_0( 2, 0 ) );
       
  1107         c2 = layoutRect.Color();
       
  1108         }
       
  1109 
       
  1110     for (TInt i=0; i < KVolumeLevels; i++) // there is ten bars
       
  1111         {
       
  1112         if ( i < ScaledValue())
       
  1113             {
       
  1114             gc.SetBrushColor(c1);
       
  1115             }
       
  1116         else
       
  1117             {
       
  1118             gc.SetBrushColor(c2);
       
  1119             }
       
  1120 
       
  1121         if ( iStyle != ENaviPaneVolumeControl )
       
  1122             {
       
  1123             TRect tempRect( 0, 0, 0, 0 );
       
  1124             layoutRect.LayoutRect( tempRect, AKN_LAYOUT_TABLE_Volume_pane_elements__one_( i, 0 ) );
       
  1125             TPoint start( iStartPos.iX + layoutRect.Rect().iTl.iX, iStartPos.iY + layoutRect.Rect().iTl.iY );
       
  1126             TSize size( layoutRect.Rect().Size() );
       
  1127             gc.DrawRect( TRect( start, size ) );
       
  1128 
       
  1129             if ( AknLayoutUtils::PenEnabled() )
       
  1130                 {
       
  1131                 // Store rect for every level. We can then decide what level was clicked
       
  1132                 iExtension->iVolumeLevels[i] = layoutRect.Rect();
       
  1133                 }
       
  1134             }
       
  1135         else
       
  1136             {
       
  1137             layoutRect.LayoutRect( volumeNaviPaneRect, AKN_LAYOUT_TABLE_Volume_pane_elements__one_( i, 0 ) );
       
  1138             gc.DrawRect( layoutRect.Rect() );
       
  1139 
       
  1140             if ( AknLayoutUtils::PenEnabled() )
       
  1141                 {
       
  1142                 // Store rect for every level. We can then decide what level was clicked
       
  1143                 iExtension->iVolumeLevels[i] = layoutRect.Rect();
       
  1144                 }
       
  1145             }
       
  1146         }
       
  1147     
       
  1148     }
       
  1149     
       
  1150     
       
  1151 // ----------------------------------------------------------------------------
       
  1152 // CAknVolumeControl::DrawSkinnedDefaultStyleVolumeControl()
       
  1153 //
       
  1154 // ----------------------------------------------------------------------------
       
  1155 //
       
  1156 void CAknVolumeControl::DrawSkinnedDefaultStyleVolumeControl( 
       
  1157     const TRect& /*aRect*/ ) const
       
  1158     {
       
  1159     CWindowGc& gc=SystemGc();
       
  1160     // No test on AknsUtils::AvkonSkinEnabled() because this control is used in
       
  1161     // the navipane Skinned bitmap.
       
  1162     if ( !Background() )
       
  1163         {
       
  1164         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1165         AknsDrawUtils::Background( skin, 
       
  1166                                AknsDrawUtils::ControlContext( this ), 
       
  1167                                this, 
       
  1168                                gc, 
       
  1169                                Rect() );
       
  1170         }
       
  1171     else
       
  1172         {
       
  1173         Background()->Draw( gc, *this, Rect() );
       
  1174         }
       
  1175 
       
  1176 
       
  1177     // Draw speaker or mute icon
       
  1178     if ( ( iBitmap != NULL ) && ( iMaskBitmap != NULL ) )
       
  1179         {
       
  1180         TRect bmpRect(TPoint(0,0),TSize(iBitmap->SizeInPixels()));
       
  1181         if (iStyle == ENaviPaneVolumeControl)  // popup handles icons itself
       
  1182             {
       
  1183             gc.BitBltMasked(iBmpPos, iBitmap, bmpRect, iMaskBitmap, ETrue);
       
  1184             }
       
  1185         }
       
  1186     if ( iExtension )
       
  1187         {
       
  1188         if ( ( iStyle != ENaviPaneVolumeControl ) || 
       
  1189                !( iExtension->iFlags & KVolumeNaviPaneMuted ) )
       
  1190             {
       
  1191             iExtension->DrawSvgSmallVolume( iStyle,
       
  1192                                             iExtension->iParentRect,
       
  1193                                             gc,
       
  1194                                             ScaledValue() );
       
  1195             return;
       
  1196             }
       
  1197         }
       
  1198 
       
  1199     }
       
  1200 
       
  1201 
       
  1202 // ----------------------------------------------------------------------------
       
  1203 // CAknVolumeControl::ExtensionInterface()
       
  1204 //
       
  1205 // ----------------------------------------------------------------------------
       
  1206 //
       
  1207 EXPORT_C void* CAknVolumeControl::ExtensionInterface( TUid /*aInterface*/ )
       
  1208     {
       
  1209     return NULL;
       
  1210     }
       
  1211 
       
  1212 // ----------------------------------------------------------------------------
       
  1213 // CAknVolumeControl::HandlePointerEventL()
       
  1214 // Processes Volumecontrol's pointer event's.
       
  1215 // This function requests what volume level contains the clicked point
       
  1216 // And then set's new volumelevel according to that.
       
  1217 // ----------------------------------------------------------------------------
       
  1218 //
       
  1219 EXPORT_C void CAknVolumeControl::HandlePointerEventL(
       
  1220                         const TPointerEvent& aPointerEvent)
       
  1221     {
       
  1222     if ( AknLayoutUtils::PenEnabled() && iExtension )
       
  1223         {
       
  1224         if ( IsDimmed() )
       
  1225             {
       
  1226             iExtension->iFlags &= ~KVolumeButtonDown;
       
  1227             return;
       
  1228             }
       
  1229 
       
  1230         TRect rect;
       
  1231         if ( iExtension->iUseExtendedTouchArea )
       
  1232             {
       
  1233             rect = iExtension->iTouchArea;
       
  1234             }
       
  1235         else
       
  1236             {
       
  1237             AknLayoutUtils::LayoutMetricsRect( 
       
  1238                     AknLayoutUtils::EApplicationWindow, rect );            
       
  1239             }
       
  1240 
       
  1241         TInt level = KVolumeLevelNotFound;
       
  1242         if( !rect.Contains( aPointerEvent.iPosition ) )
       
  1243             {
       
  1244             level = Value();
       
  1245             }
       
  1246         else
       
  1247             {
       
  1248             level = iExtension->GetVolumeLevelByPosition( iStyle, 
       
  1249                 aPointerEvent.iPosition, rect );
       
  1250             }
       
  1251 
       
  1252         TBool valueChanged( EFalse ); // if pointerevent changes volume level                
       
  1253         
       
  1254         switch( aPointerEvent.iType )
       
  1255             {
       
  1256             case TPointerEvent::EButton1Down:
       
  1257                 {
       
  1258                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1259                 if ( feedback )
       
  1260                     {
       
  1261                     feedback->InstantFeedback( ETouchFeedbackSlider );
       
  1262                     }
       
  1263                 }
       
  1264             case TPointerEvent::EDrag:
       
  1265             case TPointerEvent::EButtonRepeat: // fall trough
       
  1266                 {
       
  1267                 // click was inside VolumeControl
       
  1268                 if ( rect.Contains( aPointerEvent.iPosition ) )
       
  1269                     {
       
  1270                     // Pointer down in volumeControl
       
  1271                     iExtension->iFlags |= KVolumeButtonDown;
       
  1272                     valueChanged = ETrue;                    
       
  1273                     }
       
  1274                 Window().RequestPointerRepeatEvent( KScrollRepeatTimeout, rect );
       
  1275                 }
       
  1276                 break;
       
  1277 
       
  1278             case TPointerEvent::EButton1Up:
       
  1279                 {
       
  1280                 // if pointer was putted down inside VolumeControl
       
  1281                 iExtension->iFlags &= ~KVolumeButtonDown;
       
  1282                 }
       
  1283                 break;
       
  1284             
       
  1285             default:
       
  1286                 break;                
       
  1287             }        
       
  1288         // get clicked volume level depending type of volumebar
       
  1289         if ( valueChanged )
       
  1290             {            
       
  1291             if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1292                 {
       
  1293                 iExtension->iReduce = ( level <= Value() );
       
  1294                 iExtension->iOldLevel = level;
       
  1295                 }
       
  1296             if ( level < Value() )
       
  1297                 {
       
  1298                 iExtension->iReduce = ETrue;
       
  1299                 }
       
  1300             else if ( level > Value() + 1 )
       
  1301                 {
       
  1302                 iExtension->iReduce = ( level < iExtension->iOldLevel );                
       
  1303                 }
       
  1304             else if ( iExtension->iReduce && 
       
  1305                 ( level == Value() || level == Value() + 1 ) )
       
  1306                 {
       
  1307                 level--;
       
  1308                 }
       
  1309             }
       
  1310         //value step change
       
  1311         // correction should not be done when outside of control
       
  1312         if( iExtension->iFlags & KVolumeStepChange )
       
  1313             {
       
  1314             if( level > Value() )
       
  1315                 {
       
  1316                 level = Value() + 1;
       
  1317                 }
       
  1318             else if( level < Value() )
       
  1319                 {
       
  1320                 level = Value() - 1;
       
  1321                 }            
       
  1322             }//value step change over
       
  1323         if ( level < iExtension->iMinimumValue )
       
  1324            {
       
  1325            level = iExtension->iMinimumValue;
       
  1326            }
       
  1327        else if ( level > iExtension->iMaximumValue )
       
  1328            {
       
  1329            level = iExtension->iMaximumValue;
       
  1330            }
       
  1331         
       
  1332         iExtension->iOldLevel = level;
       
  1333         
       
  1334         if ( level == KVolumeLevelMuteTapped )
       
  1335             {
       
  1336             if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
  1337                 {
       
  1338                 // mute indicator was tapped
       
  1339                 if ( Value() == iExtension->iMinimumValue )
       
  1340                     {
       
  1341                     // restore saved value
       
  1342                     level = iExtension->iStoredLevel; 
       
  1343                     iExtension->iStoredLevel = iExtension->iMinimumValue;
       
  1344                     }
       
  1345                 else
       
  1346                     {
       
  1347                     // mute
       
  1348                     iExtension->iStoredLevel = Value();
       
  1349                     level = iExtension->iMinimumValue;
       
  1350                     }
       
  1351                 valueChanged = ETrue;
       
  1352                 }
       
  1353             else
       
  1354                 {
       
  1355                 // ignore 
       
  1356                 return;
       
  1357                 }
       
  1358             }
       
  1359 
       
  1360         if ( valueChanged && (level != iValue) )
       
  1361             {
       
  1362             if ( aPointerEvent.iType == TPointerEvent::EDrag || 
       
  1363                  aPointerEvent.iType == TPointerEvent::EButtonRepeat )
       
  1364                 {
       
  1365                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1366                 if ( feedback )
       
  1367                     {
       
  1368                     feedback->InstantFeedback( this, ETouchFeedbackSlider );    
       
  1369                     }                
       
  1370                 }
       
  1371             
       
  1372             iValue = level;
       
  1373             SetValue(iValue);
       
  1374             ReportEventL(MCoeControlObserver::EEventStateChanged);
       
  1375             DrawDeferred();
       
  1376             }
       
  1377         }
       
  1378     }
       
  1379 
       
  1380 
       
  1381 // ----------------------------------------------------------------------------
       
  1382 // CAknVolumeControl::HandleNaviDecoratorEventL()
       
  1383 // Observes navigation decorator's events
       
  1384 // currently possibly events are right and left arrow presses by pointer
       
  1385 // increments/decrements volumelevel depending on event.
       
  1386 // ----------------------------------------------------------------------------
       
  1387 //
       
  1388 EXPORT_C void CAknVolumeControl::HandleNaviDecoratorEventL( TInt aEventID )
       
  1389     {
       
  1390     if ( AknLayoutUtils::PenEnabled() )
       
  1391         {
       
  1392         switch(aEventID)
       
  1393             {
       
  1394             case MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow:
       
  1395                 {
       
  1396                 if ( iExtension && iValue > iExtension->iMinimumValue )
       
  1397                     {
       
  1398                     iValue -= 1;
       
  1399                     SetValue( iValue );
       
  1400                     ReportEventL(MCoeControlObserver::EEventStateChanged);
       
  1401                     DrawDeferred();
       
  1402                     }
       
  1403                 }
       
  1404                 break;
       
  1405 
       
  1406             case MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow:
       
  1407                 if ( iExtension && iValue < iExtension->iMaximumValue )
       
  1408                     {
       
  1409                     iValue+=1;
       
  1410                     SetValue(iValue);
       
  1411                     ReportEventL(MCoeControlObserver::EEventStateChanged);
       
  1412                     DrawDeferred();
       
  1413                     }
       
  1414                 break;
       
  1415 
       
  1416             default:
       
  1417                 break;
       
  1418             }
       
  1419         }
       
  1420     }
       
  1421 
       
  1422 
       
  1423 // ----------------------------------------------------------------------------
       
  1424 // CAknVolumeControl::IndicationDrawCallbackL()
       
  1425 //
       
  1426 // ----------------------------------------------------------------------------
       
  1427 //
       
  1428 TInt CAknVolumeControl::IndicationDrawCallbackL( TAny* aThis )
       
  1429     {
       
  1430     CAknVolumeControl* volumeControl =
       
  1431         static_cast<CAknVolumeControl*>(aThis);
       
  1432 
       
  1433     volumeControl->SmallDirectionIndicationL();
       
  1434 
       
  1435     return KErrNone;
       
  1436     }
       
  1437 
       
  1438 // ----------------------------------------------------------------------------
       
  1439 // CAknVolumeControl::SmallDirectionIndicationL()
       
  1440 //
       
  1441 // ----------------------------------------------------------------------------
       
  1442 //
       
  1443 void CAknVolumeControl::SmallDirectionIndicationL()
       
  1444     {
       
  1445     // We must calculate redraw area either the biggest or the smallest
       
  1446     // volume bar
       
  1447 
       
  1448     TRect rect;
       
  1449     TPoint p;
       
  1450     TRect srcRect;
       
  1451     TRect bmpRect;
       
  1452 
       
  1453     // check the icon or bitmap is not null
       
  1454     TBool checkNull(EFalse);
       
  1455 
       
  1456     // Cancel blinking if moved from min or max position, unless the area is
       
  1457     // blank. Then redraw and cancel after redraw
       
  1458     if( iExtension && iValue != iExtension->iAnimatedEffectValue &&
       
  1459         iExtension->iEffectTimerCount%2 == 0)
       
  1460         {
       
  1461         iExtension->iTimer->Cancel();
       
  1462         return;
       
  1463         }
       
  1464 
       
  1465     // CDMA case
       
  1466     if( iExtension && iExtension->iAnimatedEffectValue == 0 )
       
  1467         {
       
  1468         iExtension->iAnimatedEffectValue += 1;
       
  1469         }
       
  1470     
       
  1471     TInt scaledValue = ScaledValue(); // scale the value to make possible the dynamic range
       
  1472     if ( iExtension && iStyle == ESettingsVolumeControl )
       
  1473         {
       
  1474         rect = iExtension->RectFromLayout( iExtension->iParentRect,
       
  1475             AknLayoutScalable_Avkon::volume_set_pane_g(
       
  1476                             scaledValue - 1 ));
       
  1477         if (AknsUtils::AvkonSkinEnabled() && iExtension)
       
  1478             {
       
  1479             p = TPoint( rect.iTl.iX, rect.iTl.iY );
       
  1480             srcRect = TRect(0, 0, rect.Width(), rect.Height());
       
  1481             }
       
  1482         }
       
  1483     else  // navipane volume control, popup volume control
       
  1484         {
       
  1485         if ( iBitmap != NULL )
       
  1486             {
       
  1487             bmpRect = TRect(TPoint(0,0),TSize(iBitmap->SizeInPixels()));
       
  1488             }
       
  1489         
       
  1490         if ( iExtension && AknStatuspaneUtils::SmallLayoutActive() )
       
  1491             {
       
  1492             rect = iExtension->RectFromLayout( iExtension->iParentRect,
       
  1493                 AknLayoutScalable_Avkon::volume_small2_pane_g(
       
  1494                             scaledValue - 1 ) );
       
  1495             }
       
  1496         else if( iExtension )
       
  1497             {
       
  1498             rect = iExtension->RectFromLayout( iExtension->iParentRect,
       
  1499                         AknLayoutScalable_Avkon::volume_small_pane_g(
       
  1500                                 scaledValue - 1 ) );
       
  1501             }
       
  1502             
       
  1503         p = TPoint( rect.iTl.iX, rect.iTl.iY );
       
  1504         srcRect = TRect(0, 0, rect.Width(), rect.Height());
       
  1505         }
       
  1506 
       
  1507     Window().Invalidate(rect);
       
  1508     ActivateGc();
       
  1509 
       
  1510     Window().BeginRedraw(rect);
       
  1511     CWindowGc& gc=SystemGc();
       
  1512     if( !Background() )
       
  1513         {
       
  1514         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1515 
       
  1516         MAknsControlContext* edCc = AknsDrawUtils::ControlContext( this );
       
  1517         AknsDrawUtils::Background( skin, edCc, this, gc, rect);        
       
  1518         }
       
  1519     else
       
  1520         {
       
  1521         Background()->Draw( gc, *this, rect );
       
  1522         }
       
  1523     if( iExtension && iExtension->iEffectTimerCount%2 == 1)
       
  1524         {
       
  1525         checkNull = ( iExtension->iActiveIcons[
       
  1526                         scaledValue-1] != NULL )
       
  1527                     && ( iExtension->iActiveMasks[
       
  1528                         scaledValue-1] != NULL );
       
  1529         if (iStyle==ESettingsVolumeControl)
       
  1530             {
       
  1531             gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1532             gc.SetPenStyle(CGraphicsContext::ENullPen);
       
  1533             if ( AknsUtils::AvkonSkinEnabled() && iExtension
       
  1534                  && checkNull )
       
  1535                 {
       
  1536                 gc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
  1537                 gc.BitBltMasked( p, 
       
  1538                                  iExtension->iActiveIcons[
       
  1539                                     scaledValue-1],
       
  1540                                  srcRect,
       
  1541                                  iExtension->iActiveMasks[
       
  1542                                     scaledValue-1],
       
  1543                                  ETrue);
       
  1544                 }
       
  1545             }
       
  1546         else
       
  1547             {
       
  1548             if ( iExtension && checkNull )
       
  1549                 {
       
  1550                 gc.BitBltMasked( p, 
       
  1551                                  iExtension->iActiveIcons[
       
  1552                                     scaledValue-1],
       
  1553                                  srcRect,
       
  1554                                  iExtension->iActiveMasks[
       
  1555                                     scaledValue-1],
       
  1556                                  ETrue);
       
  1557                 }
       
  1558             }
       
  1559         }
       
  1560     Window().EndRedraw();
       
  1561     DeactivateGc();
       
  1562     if( iExtension )
       
  1563         {
       
  1564         iExtension->iEffectTimerCount++;
       
  1565         }
       
  1566 
       
  1567     // Stop timer if done normal-inverted-normal-inverted-normal sequence
       
  1568     //  or the user has changed the value from the min or max
       
  1569     if( iExtension && 
       
  1570         ( iExtension->iEffectTimerCount > 3 || iExtension->iAnimatedEffectValue != iValue ) )
       
  1571         {
       
  1572         iExtension->iTimer->Cancel();
       
  1573         }
       
  1574 
       
  1575     }
       
  1576 
       
  1577 // ----------------------------------------------------------------------------
       
  1578 // CAknVolumeControl::StartTimerL()
       
  1579 //
       
  1580 // ----------------------------------------------------------------------------
       
  1581 //
       
  1582 void CAknVolumeControl::StartTimerL()
       
  1583     {
       
  1584     if(iExtension->iTimer->IsActive())
       
  1585         return; // do not re-start as we have the feedback ongoing
       
  1586 
       
  1587     iExtension->iEffectTimerCount = 0;
       
  1588     iExtension->iAnimatedEffectValue = ScaledValue();
       
  1589 
       
  1590     const TTimeIntervalMicroSeconds32 KVolumeFeedbackActionTime = 160*1000;
       
  1591 
       
  1592     TCallBack callback(IndicationDrawCallbackL,this);
       
  1593     iExtension->iTimer->Start(KVolumeFeedbackActionTime,
       
  1594         KVolumeFeedbackActionTime, callback);
       
  1595     }
       
  1596 
       
  1597 
       
  1598 // ----------------------------------------------------------------------------
       
  1599 // CAknVolumeControl::CreateNaviIconL()
       
  1600 // (Re)creates the navi pane icon.
       
  1601 // ----------------------------------------------------------------------------
       
  1602 //
       
  1603 void CAknVolumeControl::CreateNaviIconL()
       
  1604     {
       
  1605     if ( !iExtension )
       
  1606         {
       
  1607         return;
       
  1608         }
       
  1609 
       
  1610     TInt bmpId = iExtension->iBmpId;
       
  1611     TInt bmpMask = iExtension->iBmpMask;
       
  1612 
       
  1613     // We compare to avkon.rh STRUCT VOLUME default values
       
  1614     if ( iExtension->iBmpFilename.CompareF(_L("")) != 0 )
       
  1615         {
       
  1616         MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
  1617         if ( iExtension->iFlags & KVolumeNaviPaneMuted )
       
  1618             {
       
  1619             delete iBitmap;
       
  1620             iBitmap = NULL;
       
  1621             delete iMaskBitmap;
       
  1622             iMaskBitmap = NULL;
       
  1623             AknsUtils::CreateColorIconL(skin,
       
  1624                                     KAknsIIDQgnIndiSpeakerMuted,
       
  1625                                     KAknsIIDQsnTextColors,
       
  1626                                     EAknsCIQsnTextColorsCG19,
       
  1627                                     iBitmap,
       
  1628                                     iMaskBitmap,
       
  1629                                     KAvkonBitmapFile,                                 
       
  1630                                     EMbmAvkonQgn_indi_speaker_muted,
       
  1631                                     EMbmAvkonQgn_indi_speaker_muted_mask,
       
  1632                                     KRgbWhite );
       
  1633             }
       
  1634         else
       
  1635             {
       
  1636             if ( bmpId != -1 )
       
  1637                 {
       
  1638                 delete iBitmap;
       
  1639                 iBitmap = NULL;
       
  1640                 delete iMaskBitmap;
       
  1641                 iMaskBitmap = NULL;
       
  1642 
       
  1643                 if ( bmpMask != -1 )
       
  1644                     {
       
  1645                     AknsUtils::CreateColorIconL( skin,
       
  1646                             KAknsIIDQgnIndiSpeakerActive,
       
  1647                             KAknsIIDQsnTextColors,
       
  1648                             EAknsCIQsnTextColorsCG19,
       
  1649                             iBitmap,
       
  1650                             iMaskBitmap,
       
  1651                             iExtension->iBmpFilename,                                 
       
  1652                             bmpId,
       
  1653                             bmpMask,
       
  1654                             KRgbWhite );
       
  1655                     // sizes are set in setlayoutl
       
  1656                     }
       
  1657                 else
       
  1658                     {
       
  1659                     iBitmap = AknIconUtils::CreateIconL(
       
  1660                                 iExtension->iBmpFilename, bmpId );
       
  1661                     }
       
  1662                 }
       
  1663             }
       
  1664         }
       
  1665     }
       
  1666 
       
  1667 
       
  1668 
       
  1669 // ----------------------------------------------------------------------------
       
  1670 // CAknVolumeControl::ScaledValue()
       
  1671 //
       
  1672 // ----------------------------------------------------------------------------
       
  1673 //
       
  1674 TInt CAknVolumeControl::ScaledValue() const
       
  1675     {
       
  1676     TInt scaledValue = iValue;
       
  1677     if(iExtension && !iExtension->iOldScaleSettingVolume)
       
  1678         {
       
  1679         scaledValue = 10 * ( iValue - iExtension->iMinimumValue ) 
       
  1680            / ( iExtension->iMaximumValue - iExtension->iMinimumValue );
       
  1681         }
       
  1682     return scaledValue;
       
  1683     }
       
  1684 
       
  1685 
       
  1686 // ----------------------------------------------------------------------------
       
  1687 // CAknVolumeControl::UseExtendedTouchArea
       
  1688 //
       
  1689 // ----------------------------------------------------------------------------
       
  1690 //
       
  1691 void CAknVolumeControl::UseExtendedTouchArea()
       
  1692     {
       
  1693     TRect touchActiveArea;
       
  1694     TPoint winPosition( Window().AbsPosition() );
       
  1695     TRect appRect;
       
  1696     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  1697             appRect );
       
  1698     TAknLayoutRect mainpaneRect;
       
  1699     mainpaneRect.LayoutRect( appRect, AknLayoutScalable_Apps::main_pane(3) );
       
  1700     touchActiveArea = mainpaneRect.Rect();
       
  1701 
       
  1702     touchActiveArea.Move( touchActiveArea.iTl.iX - winPosition.iX,
       
  1703             touchActiveArea.iTl.iY - winPosition.iY );
       
  1704     iExtension->iTouchArea = touchActiveArea;
       
  1705     iExtension->iUseExtendedTouchArea = ETrue;
       
  1706     }
       
  1707 
       
  1708 
       
  1709 // ----------------------------------------------------------------------------
       
  1710 // CVolumeExtension::
       
  1711 //
       
  1712 // ----------------------------------------------------------------------------
       
  1713 //
       
  1714 CVolumeExtension::CVolumeExtension():
       
  1715     iMinimumValue( KVolumeNaviPaneMutedValue ), 
       
  1716     iMaximumValue( KVolumeMaxValue ), 
       
  1717     iGfxMode( KGfxModeNotLoaded ),
       
  1718     iOldScaleSettingVolume(EFalse),
       
  1719     iGrabPoint( EFalse )
       
  1720     {
       
  1721     iFlags |= KVolumeStepChange;
       
  1722     }
       
  1723 
       
  1724 // ----------------------------------------------------------------------------
       
  1725 // CAknVolumeControl::HandleResourceChange()
       
  1726 // Handles a change to CAknVolumeControl's resources.
       
  1727 // Currently it handles the change of Skins
       
  1728 // ----------------------------------------------------------------------------
       
  1729 //
       
  1730 EXPORT_C void CAknVolumeControl::HandleResourceChange(TInt aType)
       
  1731     {
       
  1732     if ((aType==KAknsMessageSkinChange) || (aType == KEikColorResourceChange)
       
  1733             || (aType == KEikDynamicLayoutVariantSwitch))
       
  1734         {
       
  1735         SizeChanged();
       
  1736         if ( iExtension )
       
  1737             {
       
  1738             iExtension->iHasBeenDrawn = EFalse;
       
  1739             }
       
  1740         }
       
  1741     CCoeControl::HandleResourceChange( aType );
       
  1742     }
       
  1743     
       
  1744 void CAknVolumeControl::SuppressDrawing( TBool aSuppress )
       
  1745     {
       
  1746     if ( iExtension )
       
  1747         {
       
  1748         iExtension->iNoDraw = aSuppress;    
       
  1749         }    
       
  1750     }
       
  1751 
       
  1752 // ----------------------------------------------------------------------------
       
  1753 // CVolumeExtension::~CVolumeExtension
       
  1754 //
       
  1755 // ----------------------------------------------------------------------------
       
  1756 //
       
  1757 CVolumeExtension::~CVolumeExtension()
       
  1758     {
       
  1759     DeleteBitmaps();
       
  1760     if(iTimer && iTimer->IsActive())
       
  1761         iTimer->Cancel();
       
  1762     delete iTimer;
       
  1763     }
       
  1764 
       
  1765 // ----------------------------------------------------------------------------
       
  1766 // CVolumeExtension::UseSvgDrawing
       
  1767 //
       
  1768 // ----------------------------------------------------------------------------
       
  1769 //
       
  1770 TBool CVolumeExtension::UseSvgDrawing()
       
  1771     {
       
  1772     return ETrue;
       
  1773     }
       
  1774 
       
  1775 // ----------------------------------------------------------------------------
       
  1776 // CVolumeExtension::DeleteBitmaps
       
  1777 //
       
  1778 // ----------------------------------------------------------------------------
       
  1779 //
       
  1780 void CVolumeExtension::DeleteBitmaps()
       
  1781     {
       
  1782     TInt i;
       
  1783 
       
  1784     for( i = 0; i < KVolumeLevels; i++)
       
  1785         {
       
  1786         delete iActiveIcons[i];
       
  1787         iActiveIcons[i] = NULL;
       
  1788         delete iActiveMasks[i];
       
  1789         iActiveMasks[i] = NULL;
       
  1790         delete iInActiveIcons[i];
       
  1791         iInActiveIcons[i] = NULL;
       
  1792         delete iInActiveMasks[i];
       
  1793         iInActiveMasks[i] = NULL;
       
  1794         }
       
  1795     }
       
  1796 
       
  1797 // ----------------------------------------------------------------------------
       
  1798 // CVolumeExtension::SetIconSizes
       
  1799 //
       
  1800 // ----------------------------------------------------------------------------
       
  1801 //
       
  1802 void CVolumeExtension::SetIconSizes( TInt aStyle, const TRect& aParent ) const
       
  1803     {
       
  1804     TSize s;
       
  1805 
       
  1806     if( iGfxMode == KGfxModeOld )
       
  1807         {
       
  1808         for( TInt i = 0; i < KVolumeLevels; i++)
       
  1809             {
       
  1810             switch ( aStyle )
       
  1811                 {
       
  1812                 case ESettingsVolumeControl:
       
  1813                     s = RectFromLayout( aParent,
       
  1814                         AknLayoutScalable_Avkon::volume_set_pane_g(i) ).Size();
       
  1815                     break;
       
  1816                 case ENaviPaneVolumeControl:
       
  1817                     {
       
  1818                     TRect parentRect(aParent);
       
  1819                     if ( AknStatuspaneUtils::SmallLayoutActive() )
       
  1820                         {
       
  1821                         parentRect = RectFromLayout(
       
  1822                                     parentRect,
       
  1823                                     AknLayoutScalable_Avkon::volume_small2_pane()
       
  1824                                     );
       
  1825                         s = RectFromLayout(
       
  1826                                 parentRect,
       
  1827                                 AknLayoutScalable_Avkon::volume_small2_pane_g( i ) 
       
  1828                                 ).Size();
       
  1829                         }
       
  1830                     else
       
  1831                         {
       
  1832                         parentRect = RectFromLayout(
       
  1833                                     parentRect,
       
  1834                                     AknLayoutScalable_Avkon::volume_small_pane()
       
  1835                                     );
       
  1836                         s = RectFromLayout(
       
  1837                                 parentRect,
       
  1838                                 AknLayoutScalable_Avkon::volume_small_pane_g(i) 
       
  1839                                 ).Size();
       
  1840                         }
       
  1841                     }
       
  1842                     break;
       
  1843                 case EPopupVolumeControl:
       
  1844                     s = RectFromLayout(
       
  1845                             aParent,
       
  1846                             AknLayoutScalable_Avkon::volume_small_pane_g( i ) 
       
  1847                             ).Size();
       
  1848                     break;
       
  1849                 case EDynRangeSettingsVolumeControl:
       
  1850                 case EDynRangeNaviPaneVolumeControl:
       
  1851                 case EDynRangePopupVolumeControl:
       
  1852                     s.iHeight = iParentRect.Height();
       
  1853                     s.iWidth = iParentRect.Width();
       
  1854                     break;
       
  1855                 default:
       
  1856                     // can not happen
       
  1857                     break;
       
  1858                 }
       
  1859             if ( iActiveIcons[i] != NULL )
       
  1860                 {
       
  1861                 AknIconUtils::SetSize( iActiveIcons[i],
       
  1862                                     s, EAspectRatioNotPreserved );
       
  1863                 }
       
  1864             if ( iInActiveIcons[i] != NULL )
       
  1865                 {
       
  1866                 AknIconUtils::SetSize( iInActiveIcons[i],s,
       
  1867                                         EAspectRatioNotPreserved );
       
  1868                 }
       
  1869             }
       
  1870         }
       
  1871     else
       
  1872         {
       
  1873         s.iHeight = iParentRect.Height();
       
  1874         s.iWidth = iParentRect.Width();
       
  1875 
       
  1876         if ( iActiveIcons[0] != NULL )
       
  1877             {
       
  1878             AknIconUtils::SetSize( iActiveIcons[0], s, 
       
  1879                                    EAspectRatioNotPreserved );
       
  1880             }
       
  1881         if ( iInActiveIcons[0] != NULL )
       
  1882             {
       
  1883             AknIconUtils::SetSize( iInActiveIcons[0], s,
       
  1884                                    EAspectRatioNotPreserved );
       
  1885             }
       
  1886 
       
  1887         }
       
  1888    
       
  1889     }
       
  1890 
       
  1891 // ----------------------------------------------------------------------------
       
  1892 // CVolumeExtension::LoadBitmapsL
       
  1893 //
       
  1894 // Multiple fallback levels for loading bitmaps:
       
  1895 // 1. Try loading new bitmaps using skin (icons will be scaled)
       
  1896 // 2. Try loading old bitmaps using skin (either small or large icons)
       
  1897 // 3. Load new bitmaps without skins (icons will be scaled)
       
  1898 // ----------------------------------------------------------------------------
       
  1899 //
       
  1900 void CVolumeExtension::LoadBitmapsL( TInt aStyle, const TRect& aParent )
       
  1901     {
       
  1902     DeleteBitmaps();
       
  1903 
       
  1904     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1905     TInt err = -1;// Init to any value but 0
       
  1906 
       
  1907 //TODO: Verify that new skins are available and loaded
       
  1908 
       
  1909     // 1. Load new with skin           
       
  1910     TRAP( err, TryLoadBitmapsSkinnedL( skin ) );
       
  1911     iGfxMode = KGfxModeNew;
       
  1912 
       
  1913     // 2. Load old with skin
       
  1914     if( err ) 
       
  1915         {
       
  1916         switch( aStyle ) 
       
  1917             {
       
  1918             case ESettingsVolumeControl:
       
  1919                 TRAP( err, TryLoadBitmapsDefaultLargeL( skin ) );
       
  1920                 iGfxMode = KGfxModeOld;
       
  1921                 break;
       
  1922             case ENaviPaneVolumeControl:
       
  1923             case EPopupVolumeControl:
       
  1924                 TRAP( err, TryLoadBitmapsDefaultSmallL( skin ) );
       
  1925                 iGfxMode = KGfxModeOld;
       
  1926                 break;
       
  1927             }
       
  1928         }
       
  1929     
       
  1930     // 3. Load new without skin
       
  1931     if( err )
       
  1932         {
       
  1933         iGfxMode = KGfxModeNotLoaded;
       
  1934         TRAP( err, TryLoadBitmapsNoSkinL() ); // Last chance - must succeed.
       
  1935         iGfxMode = KGfxModeNew;
       
  1936         }
       
  1937     // There absolutely are no whatsoever icons available  -> abort!
       
  1938     User::LeaveIfError( err );
       
  1939 
       
  1940     SetIconSizes( aStyle, aParent );
       
  1941     }
       
  1942 
       
  1943 
       
  1944 // ----------------------------------------------------------------------------
       
  1945 // CVolumeExtension::TryLoadBitmapsSkinnedL
       
  1946 //
       
  1947 // ----------------------------------------------------------------------------
       
  1948 //
       
  1949 void CVolumeExtension::TryLoadBitmapsSkinnedL( MAknsSkinInstance* aSkin )
       
  1950     {
       
  1951     AknsUtils::CreateIconL(
       
  1952         aSkin,
       
  1953         KAknsIIDQgnGrafVolumeSetOff,
       
  1954         iInActiveIcons[0],
       
  1955         iInActiveMasks[0],
       
  1956         KNullDesC, // Disables fallback
       
  1957         EMbmAvkonQgn_graf_volume_small_off,
       
  1958         EMbmAvkonQgn_graf_volume_small_off_mask ) ;
       
  1959 
       
  1960     AknsUtils::CreateIconL(
       
  1961         aSkin,
       
  1962         KAknsIIDQgnGrafVolumeSetOn,
       
  1963         iActiveIcons[0],
       
  1964         iActiveMasks[0],
       
  1965         KNullDesC, // Disables fallback
       
  1966         EMbmAvkonQgn_graf_volume_small_on,
       
  1967         EMbmAvkonQgn_graf_volume_small_on_mask );
       
  1968     }
       
  1969 
       
  1970 
       
  1971 // ----------------------------------------------------------------------------
       
  1972 // CVolumeExtension::
       
  1973 //
       
  1974 // ----------------------------------------------------------------------------
       
  1975 //
       
  1976 void CVolumeExtension::TryLoadBitmapsDefaultSmallL( MAknsSkinInstance* aSkin )
       
  1977     {
       
  1978     const TAknsItemID iconOffSkinIDArray[] = 
       
  1979         {
       
  1980         KAknsIIDQgnGrafVolumeSmall1Off,
       
  1981         KAknsIIDQgnGrafVolumeSmall2Off,
       
  1982         KAknsIIDQgnGrafVolumeSmall3Off,
       
  1983         KAknsIIDQgnGrafVolumeSmall4Off,
       
  1984         KAknsIIDQgnGrafVolumeSmall5Off,
       
  1985         KAknsIIDQgnGrafVolumeSmall6Off,
       
  1986         KAknsIIDQgnGrafVolumeSmall7Off,
       
  1987         KAknsIIDQgnGrafVolumeSmall8Off,
       
  1988         KAknsIIDQgnGrafVolumeSmall9Off,
       
  1989         KAknsIIDQgnGrafVolumeSmall10Off
       
  1990         };
       
  1991     const TAknsItemID iconOnSkinIDArray[] = 
       
  1992         {
       
  1993         KAknsIIDQgnGrafVolumeSmall1On,
       
  1994         KAknsIIDQgnGrafVolumeSmall2On,
       
  1995         KAknsIIDQgnGrafVolumeSmall3On,
       
  1996         KAknsIIDQgnGrafVolumeSmall4On,
       
  1997         KAknsIIDQgnGrafVolumeSmall5On,
       
  1998         KAknsIIDQgnGrafVolumeSmall6On,
       
  1999         KAknsIIDQgnGrafVolumeSmall7On,
       
  2000         KAknsIIDQgnGrafVolumeSmall8On,
       
  2001         KAknsIIDQgnGrafVolumeSmall9On,
       
  2002         KAknsIIDQgnGrafVolumeSmall10On
       
  2003         };
       
  2004     const TInt iconOffIDArray[] = 
       
  2005         {
       
  2006         EMbmAvkonQgn_graf_volume_small_1_off,
       
  2007         EMbmAvkonQgn_graf_volume_small_2_off,
       
  2008         EMbmAvkonQgn_graf_volume_small_3_off,
       
  2009         EMbmAvkonQgn_graf_volume_small_4_off,
       
  2010         EMbmAvkonQgn_graf_volume_small_5_off,
       
  2011         EMbmAvkonQgn_graf_volume_small_6_off,
       
  2012         EMbmAvkonQgn_graf_volume_small_7_off,
       
  2013         EMbmAvkonQgn_graf_volume_small_8_off,
       
  2014         EMbmAvkonQgn_graf_volume_small_9_off,
       
  2015         EMbmAvkonQgn_graf_volume_small_10_off
       
  2016         };
       
  2017     const TInt iconOffMaskIDArray[] = 
       
  2018         {
       
  2019         EMbmAvkonQgn_graf_volume_small_1_off_mask,
       
  2020         EMbmAvkonQgn_graf_volume_small_2_off_mask,
       
  2021         EMbmAvkonQgn_graf_volume_small_3_off_mask,
       
  2022         EMbmAvkonQgn_graf_volume_small_4_off_mask,
       
  2023         EMbmAvkonQgn_graf_volume_small_5_off_mask,
       
  2024         EMbmAvkonQgn_graf_volume_small_6_off_mask,
       
  2025         EMbmAvkonQgn_graf_volume_small_7_off_mask,
       
  2026         EMbmAvkonQgn_graf_volume_small_8_off_mask,
       
  2027         EMbmAvkonQgn_graf_volume_small_9_off_mask,
       
  2028         EMbmAvkonQgn_graf_volume_small_10_off_mask
       
  2029         };
       
  2030     const TInt iconOnIDArray[] = 
       
  2031         {
       
  2032         EMbmAvkonQgn_graf_volume_small_1_on,
       
  2033         EMbmAvkonQgn_graf_volume_small_2_on,
       
  2034         EMbmAvkonQgn_graf_volume_small_3_on,
       
  2035         EMbmAvkonQgn_graf_volume_small_4_on,
       
  2036         EMbmAvkonQgn_graf_volume_small_5_on,
       
  2037         EMbmAvkonQgn_graf_volume_small_6_on,
       
  2038         EMbmAvkonQgn_graf_volume_small_7_on,
       
  2039         EMbmAvkonQgn_graf_volume_small_8_on,
       
  2040         EMbmAvkonQgn_graf_volume_small_9_on,
       
  2041         EMbmAvkonQgn_graf_volume_small_10_on
       
  2042         };
       
  2043     const TInt iconOnMaskIDArray[] = 
       
  2044         {
       
  2045         EMbmAvkonQgn_graf_volume_small_1_on_mask,
       
  2046         EMbmAvkonQgn_graf_volume_small_2_on_mask,
       
  2047         EMbmAvkonQgn_graf_volume_small_3_on_mask,
       
  2048         EMbmAvkonQgn_graf_volume_small_4_on_mask,
       
  2049         EMbmAvkonQgn_graf_volume_small_5_on_mask,
       
  2050         EMbmAvkonQgn_graf_volume_small_6_on_mask,
       
  2051         EMbmAvkonQgn_graf_volume_small_7_on_mask,
       
  2052         EMbmAvkonQgn_graf_volume_small_8_on_mask,
       
  2053         EMbmAvkonQgn_graf_volume_small_9_on_mask,
       
  2054         EMbmAvkonQgn_graf_volume_small_10_on_mask
       
  2055         };
       
  2056     
       
  2057     for ( TInt i=0; i<10; i++ )
       
  2058         {
       
  2059         AknsUtils::CreateIconL( 
       
  2060                 aSkin, 
       
  2061                 iconOffSkinIDArray[i],
       
  2062                 iInActiveIcons[i],
       
  2063                 iInActiveMasks[i],
       
  2064                 KNullDesC,
       
  2065                 iconOffIDArray[i],
       
  2066                 iconOffMaskIDArray[i]
       
  2067                 );
       
  2068         AknsUtils::CreateIconL( 
       
  2069                 aSkin, 
       
  2070                 iconOnSkinIDArray[i],
       
  2071                 iActiveIcons[i],
       
  2072                 iActiveMasks[i],
       
  2073                 KNullDesC,
       
  2074                 iconOnIDArray[i],
       
  2075                 iconOnMaskIDArray[i]
       
  2076                 );
       
  2077         }
       
  2078     }
       
  2079     
       
  2080     
       
  2081 // ----------------------------------------------------------------------------
       
  2082 // CVolumeExtension::
       
  2083 //
       
  2084 // ----------------------------------------------------------------------------
       
  2085 //
       
  2086 void CVolumeExtension::TryLoadBitmapsDefaultLargeL( MAknsSkinInstance* aSkin )
       
  2087     {
       
  2088     const TAknsItemID iconOffSkinIDArray[] = 
       
  2089         {
       
  2090         KAknsIIDQgnGrafVolumeSet1Off,
       
  2091         KAknsIIDQgnGrafVolumeSet2Off,
       
  2092         KAknsIIDQgnGrafVolumeSet3Off,
       
  2093         KAknsIIDQgnGrafVolumeSet4Off,
       
  2094         KAknsIIDQgnGrafVolumeSet5Off,
       
  2095         KAknsIIDQgnGrafVolumeSet6Off,
       
  2096         KAknsIIDQgnGrafVolumeSet7Off,
       
  2097         KAknsIIDQgnGrafVolumeSet8Off,
       
  2098         KAknsIIDQgnGrafVolumeSet9Off,
       
  2099         KAknsIIDQgnGrafVolumeSet10Off
       
  2100         };
       
  2101     const TAknsItemID iconOnSkinIDArray[] = 
       
  2102         {
       
  2103         KAknsIIDQgnGrafVolumeSet1On,
       
  2104         KAknsIIDQgnGrafVolumeSet2On,
       
  2105         KAknsIIDQgnGrafVolumeSet3On,
       
  2106         KAknsIIDQgnGrafVolumeSet4On,
       
  2107         KAknsIIDQgnGrafVolumeSet5On,
       
  2108         KAknsIIDQgnGrafVolumeSet6On,
       
  2109         KAknsIIDQgnGrafVolumeSet7On,
       
  2110         KAknsIIDQgnGrafVolumeSet8On,
       
  2111         KAknsIIDQgnGrafVolumeSet9On,
       
  2112         KAknsIIDQgnGrafVolumeSet10On
       
  2113         };
       
  2114     const TInt iconOffIDArray[] = 
       
  2115         {
       
  2116         EMbmAvkonQgn_graf_volume_set_1_off,
       
  2117         EMbmAvkonQgn_graf_volume_set_2_off,
       
  2118         EMbmAvkonQgn_graf_volume_set_3_off,
       
  2119         EMbmAvkonQgn_graf_volume_set_4_off,
       
  2120         EMbmAvkonQgn_graf_volume_set_5_off,
       
  2121         EMbmAvkonQgn_graf_volume_set_6_off,
       
  2122         EMbmAvkonQgn_graf_volume_set_7_off,
       
  2123         EMbmAvkonQgn_graf_volume_set_8_off,
       
  2124         EMbmAvkonQgn_graf_volume_set_9_off,
       
  2125         EMbmAvkonQgn_graf_volume_set_10_off
       
  2126         };
       
  2127     const TInt iconOffMaskIDArray[] = 
       
  2128         {
       
  2129         EMbmAvkonQgn_graf_volume_set_1_off_mask,
       
  2130         EMbmAvkonQgn_graf_volume_set_2_off_mask,
       
  2131         EMbmAvkonQgn_graf_volume_set_3_off_mask,
       
  2132         EMbmAvkonQgn_graf_volume_set_4_off_mask,
       
  2133         EMbmAvkonQgn_graf_volume_set_5_off_mask,
       
  2134         EMbmAvkonQgn_graf_volume_set_6_off_mask,
       
  2135         EMbmAvkonQgn_graf_volume_set_7_off_mask,
       
  2136         EMbmAvkonQgn_graf_volume_set_8_off_mask,
       
  2137         EMbmAvkonQgn_graf_volume_set_9_off_mask,
       
  2138         EMbmAvkonQgn_graf_volume_set_10_off_mask
       
  2139         };
       
  2140     const TInt iconOnIDArray[] = 
       
  2141         {
       
  2142         EMbmAvkonQgn_graf_volume_set_1_on,
       
  2143         EMbmAvkonQgn_graf_volume_set_2_on,
       
  2144         EMbmAvkonQgn_graf_volume_set_3_on,
       
  2145         EMbmAvkonQgn_graf_volume_set_4_on,
       
  2146         EMbmAvkonQgn_graf_volume_set_5_on,
       
  2147         EMbmAvkonQgn_graf_volume_set_6_on,
       
  2148         EMbmAvkonQgn_graf_volume_set_7_on,
       
  2149         EMbmAvkonQgn_graf_volume_set_8_on,
       
  2150         EMbmAvkonQgn_graf_volume_set_9_on,
       
  2151         EMbmAvkonQgn_graf_volume_set_10_on
       
  2152         };
       
  2153     const TInt iconOnMaskIDArray[] = 
       
  2154         {
       
  2155         EMbmAvkonQgn_graf_volume_set_1_on_mask,
       
  2156         EMbmAvkonQgn_graf_volume_set_2_on_mask,
       
  2157         EMbmAvkonQgn_graf_volume_set_3_on_mask,
       
  2158         EMbmAvkonQgn_graf_volume_set_4_on_mask,
       
  2159         EMbmAvkonQgn_graf_volume_set_5_on_mask,
       
  2160         EMbmAvkonQgn_graf_volume_set_6_on_mask,
       
  2161         EMbmAvkonQgn_graf_volume_set_7_on_mask,
       
  2162         EMbmAvkonQgn_graf_volume_set_8_on_mask,
       
  2163         EMbmAvkonQgn_graf_volume_set_9_on_mask,
       
  2164         EMbmAvkonQgn_graf_volume_set_10_on_mask
       
  2165         };
       
  2166 
       
  2167     for ( TInt i=0; i<10; i++ )
       
  2168         {
       
  2169         AknsUtils::CreateIconL( 
       
  2170                 aSkin, 
       
  2171                 iconOffSkinIDArray[i],
       
  2172                 iInActiveIcons[i],
       
  2173                 iInActiveMasks[i],
       
  2174                 KNullDesC,
       
  2175                 iconOffIDArray[i],
       
  2176                 iconOffMaskIDArray[i]
       
  2177                 );
       
  2178         AknsUtils::CreateIconL( 
       
  2179                 aSkin, 
       
  2180                 iconOnSkinIDArray[i],
       
  2181                 iActiveIcons[i],
       
  2182                 iActiveMasks[i],
       
  2183                 KNullDesC,
       
  2184                 iconOnIDArray[i],
       
  2185                 iconOnMaskIDArray[i]
       
  2186                 );
       
  2187         }
       
  2188     
       
  2189     }
       
  2190 
       
  2191 
       
  2192 // ----------------------------------------------------------------------------
       
  2193 // CVolumeExtension::TryLoadBitmapsNoSkinL
       
  2194 //
       
  2195 // ----------------------------------------------------------------------------
       
  2196 //
       
  2197 void CVolumeExtension::TryLoadBitmapsNoSkinL()
       
  2198     {
       
  2199     AknIconUtils::CreateIconL(
       
  2200             iInActiveIcons[0],
       
  2201             iInActiveMasks[0],
       
  2202             KAvkonBitmapFile,
       
  2203             EMbmAvkonQgn_graf_volume_small_off,
       
  2204             EMbmAvkonQgn_graf_volume_small_off_mask );
       
  2205     AknIconUtils::CreateIconL(
       
  2206             iActiveIcons[0],
       
  2207             iActiveMasks[0],
       
  2208             KAvkonBitmapFile,
       
  2209             EMbmAvkonQgn_graf_volume_small_on,
       
  2210             EMbmAvkonQgn_graf_volume_small_on_mask );
       
  2211     }
       
  2212     
       
  2213 // ----------------------------------------------------------------------------
       
  2214 // CVolumeExtension::CalculateParentRect
       
  2215 //
       
  2216 // ----------------------------------------------------------------------------
       
  2217 //
       
  2218 void CVolumeExtension::CalculateParentRect( TInt aStyle, const TRect& aParent )
       
  2219     {
       
  2220     switch (aStyle)
       
  2221         {
       
  2222         case ENaviPaneVolumeControl:
       
  2223         case EDynRangeNaviPaneVolumeControl:
       
  2224                 {
       
  2225                 // Rect() gives navi_navi_volume_pane in the control hierarchy.
       
  2226                 if ( AknStatuspaneUtils::SmallLayoutActive() )
       
  2227                     {
       
  2228                     iParentRect = RectFromLayout(
       
  2229                                 aParent,
       
  2230                                 AknLayoutScalable_Avkon::volume_small2_pane()
       
  2231                                 );
       
  2232                     }
       
  2233                 else
       
  2234                     {
       
  2235                     iParentRect = RectFromLayout(
       
  2236                                 aParent,
       
  2237                                 AknLayoutScalable_Avkon::volume_small_pane()
       
  2238                                 );
       
  2239                     }
       
  2240                 }
       
  2241             break;
       
  2242         case ESettingsVolumeControl:
       
  2243         case EPopupVolumeControl:
       
  2244         default:
       
  2245             iParentRect = aParent; // Rect()
       
  2246             break;
       
  2247         }
       
  2248     }
       
  2249 
       
  2250 // ----------------------------------------------------------------------------
       
  2251 // CVolumeExtension::DrawSvgSmallVolume
       
  2252 //
       
  2253 // ----------------------------------------------------------------------------
       
  2254 //
       
  2255 void CVolumeExtension::DrawSvgSmallVolume(
       
  2256                         TInt aStyle,
       
  2257                         const TRect& aRect,
       
  2258                         CBitmapContext& aGc,
       
  2259                         TInt aValue
       
  2260                         )
       
  2261     {
       
  2262     TRect r;
       
  2263     for (TInt i = 0; i < KVolumeLevels; i++)
       
  2264         {
       
  2265         if ( aStyle == EPopupVolumeControl )
       
  2266             {
       
  2267             r = RectFromLayout( aRect,
       
  2268                         AknLayoutScalable_Avkon::volume_small_pane_g( i ) );
       
  2269             }
       
  2270         else // navi pane volume control
       
  2271             {
       
  2272             if ( AknStatuspaneUtils::SmallLayoutActive() )
       
  2273                 {
       
  2274                 r = RectFromLayout( aRect,
       
  2275                         AknLayoutScalable_Avkon::volume_small2_pane_g( i ) );
       
  2276                 }
       
  2277             else
       
  2278                 {
       
  2279                 r = RectFromLayout( aRect,
       
  2280                         AknLayoutScalable_Avkon::volume_small_pane_g( i ) );
       
  2281                 }
       
  2282             }
       
  2283             
       
  2284         TPoint p( r.iTl.iX, r.iTl.iY );
       
  2285         TRect srcRect(0, 0, r.Width(), r.Height());
       
  2286 
       
  2287         if ( AknLayoutUtils::PenEnabled() )
       
  2288             {
       
  2289             // Store rect for every level.
       
  2290             // We can then decide what level was clicked
       
  2291             iVolumeLevels[i] = r;
       
  2292             }
       
  2293 
       
  2294         if ( i < aValue )
       
  2295             {
       
  2296             if ( ( iActiveIcons[i] != NULL ) && ( iActiveMasks[i] != NULL ) )
       
  2297                 {
       
  2298                 aGc.BitBltMasked( p, iActiveIcons[i],
       
  2299                                     srcRect, iActiveMasks[i], ETrue);
       
  2300                 }
       
  2301             }
       
  2302         else
       
  2303             {
       
  2304             if ( ( iInActiveIcons[i] != NULL ) 
       
  2305                 && ( iInActiveMasks[i] != NULL ) )
       
  2306                 {
       
  2307                 aGc.BitBltMasked( p, iInActiveIcons[i], 
       
  2308                                     srcRect, iInActiveMasks[i], ETrue);
       
  2309                 }
       
  2310             }
       
  2311         }
       
  2312     }
       
  2313 
       
  2314 // ----------------------------------------------------------------------------
       
  2315 // CVolumeExtension::DrawSvgSettingsVolume
       
  2316 //
       
  2317 // ----------------------------------------------------------------------------
       
  2318 //
       
  2319 void CVolumeExtension::DrawSvgSettingsVolume( const TRect& aRect,
       
  2320                         CWindowGc& aGc, TInt aValue )
       
  2321     {
       
  2322     TRect r;
       
  2323     for (TInt i = 0; i < KVolumeLevels; i++)
       
  2324         {
       
  2325         r = RectFromLayout( aRect,
       
  2326                     AknLayoutScalable_Avkon::volume_set_pane_g( i ) );
       
  2327         TPoint p( r.iTl.iX, r.iTl.iY );
       
  2328         TRect srcRect(0, 0, r.Width(), r.Height());
       
  2329 
       
  2330         if ( AknLayoutUtils::PenEnabled() )
       
  2331             {
       
  2332             // Store rect for every level.
       
  2333             // We can then decide what level was clicked
       
  2334             iVolumeLevels[i] = r;
       
  2335             }
       
  2336 
       
  2337         if ( i < aValue )
       
  2338             {
       
  2339             if ( ( iActiveIcons[i] != NULL ) && ( iActiveMasks[i] != NULL ) )
       
  2340                 {
       
  2341                 aGc.BitBltMasked( p, iActiveIcons[i],
       
  2342                                     srcRect, iActiveMasks[i], ETrue);
       
  2343                 }
       
  2344             }
       
  2345         else
       
  2346             {
       
  2347             if ( ( iInActiveIcons[i] != NULL )
       
  2348                     && ( iInActiveMasks[i] != NULL ) )
       
  2349                 {
       
  2350                 aGc.BitBltMasked( p, iInActiveIcons[i], srcRect, 
       
  2351                                     iInActiveMasks[i], ETrue);
       
  2352                 }
       
  2353             }
       
  2354         }
       
  2355     }
       
  2356 
       
  2357 // ----------------------------------------------------------------------------
       
  2358 // CVolumeExtension::
       
  2359 //
       
  2360 // ----------------------------------------------------------------------------
       
  2361 //
       
  2362 void CVolumeExtension::CreateSvgSettingsIconL(
       
  2363                 const TRect& aRect, TInt aValue, CGulIcon* aIcon )
       
  2364     {
       
  2365     CVolumeExtension* extension = new (ELeave) CVolumeExtension;
       
  2366     CleanupStack::PushL( extension );
       
  2367 
       
  2368     extension->LoadBitmapsL( ENaviPaneVolumeControl, aRect );
       
  2369     extension->DrawSvgSettingsIconL( aRect, aValue, aIcon );
       
  2370 
       
  2371     CleanupStack::PopAndDestroy(); // extension
       
  2372     }
       
  2373 // ----------------------------------------------------------------------------
       
  2374 // CVolumeExtension::
       
  2375 //
       
  2376 // ----------------------------------------------------------------------------
       
  2377 //
       
  2378 void CVolumeExtension::CreateDynRangeStyleSettingsIconL( const TRect& aRect, 
       
  2379                                                     TInt aValue, 
       
  2380                                                     CGulIcon* aIcon, 
       
  2381                                                     TInt aMinimum,
       
  2382                                                     TInt aMaximum )
       
  2383     {
       
  2384     CVolumeExtension* extension = new (ELeave) CVolumeExtension;
       
  2385     CleanupStack::PushL( extension );
       
  2386 
       
  2387     extension->LoadBitmapsL( EDynRangeSettingsVolumeControl, aRect );
       
  2388     extension->DrawDynRangeStyleSettingsIconL( aRect, aValue, aIcon, aMinimum, aMaximum );
       
  2389 
       
  2390     CleanupStack::PopAndDestroy(); // extension
       
  2391     }
       
  2392 // ----------------------------------------------------------------------------
       
  2393 // CVolumeExtension::
       
  2394 //
       
  2395 // ----------------------------------------------------------------------------
       
  2396 //
       
  2397 void CVolumeExtension::DrawSvgSettingsIconL(
       
  2398                 const TRect& aRect, TInt aValue, CGulIcon* aIcon )
       
  2399     {
       
  2400     __ASSERT_DEBUG( ( aValue >= iMinimumValue )
       
  2401                             && (aValue <= iMaximumValue), 
       
  2402                     Panic(EAknPanicOutOfRange) );
       
  2403     if( iGfxMode == KGfxModeNew )
       
  2404         {
       
  2405         DrawDynRangeStyleSettingsIconL( aRect, aValue, aIcon, iMinimumValue, iMaximumValue );            
       
  2406         }
       
  2407     else
       
  2408         {
       
  2409             
       
  2410         // The actual bitmap
       
  2411         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2412         CleanupStack::PushL( bitmap );
       
  2413 
       
  2414         bitmap->Create( aRect.Size(),
       
  2415                     CCoeEnv::Static()->ScreenDevice()->DisplayMode() );
       
  2416         CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  2417         CleanupStack::PushL( fbsBitGc );
       
  2418         CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap );
       
  2419         CleanupStack::PushL( bmpDevice );
       
  2420         fbsBitGc->Activate( bmpDevice );
       
  2421 
       
  2422         TRect r;
       
  2423 
       
  2424         for (TInt i = 0; i < KVolumeLevels; i++)
       
  2425             {
       
  2426             r = RectFromLayout( aRect,
       
  2427                     AknLayoutScalable_Avkon::volume_small_pane_cp_g(i));
       
  2428             TPoint p( r.iTl.iX, r.iTl.iY );
       
  2429             TRect srcRect(0, 0, r.Width(), r.Height());
       
  2430 
       
  2431             if ( AknLayoutUtils::PenEnabled() )
       
  2432                 {
       
  2433                 // Store rect for every level.
       
  2434                 // We can then decide what level was clicked
       
  2435                 iVolumeLevels[i] = r;
       
  2436                 }
       
  2437 
       
  2438             if ( i < aValue )
       
  2439                 {
       
  2440                 if ( iActiveIcons[i] != NULL )
       
  2441                     {
       
  2442                     AknIconUtils::SetSize( iActiveIcons[i], r.Size() );
       
  2443                     fbsBitGc->BitBlt( p, iActiveIcons[i], srcRect );
       
  2444                     }
       
  2445                 }
       
  2446             else
       
  2447                 {
       
  2448                 if ( iInActiveIcons[i] != NULL )
       
  2449                     {
       
  2450                     AknIconUtils::SetSize( iInActiveIcons[i], r.Size() );
       
  2451                     fbsBitGc->BitBlt( p, iInActiveIcons[i], srcRect );
       
  2452                     }
       
  2453                 }
       
  2454             }
       
  2455                 
       
  2456         CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  2457         aIcon->SetBitmap( bitmap ); // Transfers ownership
       
  2458         CleanupStack::Pop(); // bitmap
       
  2459 
       
  2460         // The mask
       
  2461         CFbsBitmap* mask = new (ELeave) CFbsBitmap;
       
  2462         CleanupStack::PushL( mask );
       
  2463 
       
  2464         mask->Create( aRect.Size(), iActiveMasks[0]->DisplayMode() );
       
  2465         fbsBitGc = CFbsBitGc::NewL();
       
  2466         CleanupStack::PushL( fbsBitGc );
       
  2467         bmpDevice = CFbsBitmapDevice::NewL( mask );
       
  2468         CleanupStack::PushL( bmpDevice );
       
  2469         fbsBitGc->Activate( bmpDevice );
       
  2470         fbsBitGc->SetPenStyle( CGraphicsContext::ENullPen );
       
  2471         fbsBitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2472         fbsBitGc->SetBrushColor( KRgbBlack );
       
  2473         fbsBitGc->DrawRect( TRect( aRect.Size() ) );
       
  2474 
       
  2475         fbsBitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2476 
       
  2477         for ( TInt i = 0; i < KVolumeLevels; i++ )
       
  2478             {
       
  2479             r = RectFromLayout( aRect,
       
  2480                     AknLayoutScalable_Avkon::volume_small_pane_cp_g( i ) );
       
  2481             TPoint p( r.iTl.iX, r.iTl.iY );
       
  2482             TRect srcRect( 0, 0, r.Width(), r.Height() );
       
  2483 
       
  2484             if ( i < aValue )
       
  2485                 {
       
  2486                 if ( ( iActiveMasks[i] != NULL ) )
       
  2487                     {
       
  2488                     AknIconUtils::SetSize( iActiveMasks[i], r.Size() );
       
  2489                     fbsBitGc->BitBlt( p, iActiveMasks[i], srcRect );
       
  2490                     }
       
  2491                 }
       
  2492             else
       
  2493                 {
       
  2494                 if ( iInActiveMasks[i] != NULL )
       
  2495                     {
       
  2496                     AknIconUtils::SetSize( iInActiveMasks[i], r.Size() );
       
  2497                     fbsBitGc->BitBlt( p, iInActiveMasks[i], srcRect );
       
  2498                     }
       
  2499                 }
       
  2500             }
       
  2501 
       
  2502         CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  2503         aIcon->SetMask( mask ); // Transfers ownership
       
  2504         CleanupStack::Pop(); // mask
       
  2505         }
       
  2506     }
       
  2507 // ----------------------------------------------------------------------------
       
  2508 // CVolumeExtension::
       
  2509 //
       
  2510 // ----------------------------------------------------------------------------
       
  2511 //
       
  2512 void CVolumeExtension::DrawDynRangeStyleSettingsIconL( const TRect& aRect, 
       
  2513                                                   TInt aValue, 
       
  2514                                                   CGulIcon* aIcon, 
       
  2515                                                   TInt aMinimum, 
       
  2516                                                   TInt aMaximum )
       
  2517     {
       
  2518     __ASSERT_DEBUG( ( aValue >= aMinimum )
       
  2519                             && (aValue <= aMaximum), 
       
  2520                     Panic(EAknPanicOutOfRange) );
       
  2521     
       
  2522     // The actual bitmap
       
  2523     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  2524     CleanupStack::PushL( bitmap );
       
  2525 
       
  2526     bitmap->Create( aRect.Size(),
       
  2527                 CCoeEnv::Static()->ScreenDevice()->DisplayMode() );
       
  2528     CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  2529     CleanupStack::PushL( fbsBitGc );
       
  2530     CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap );
       
  2531     CleanupStack::PushL( bmpDevice );
       
  2532     fbsBitGc->Activate( bmpDevice );
       
  2533 
       
  2534     TRect r( aRect );
       
  2535     // the following is original code
       
  2536     // TRect activeRect(r.iTl.iX, r.iTl.iY, r.Width() * aValue/( aMaximum - aMinimum + 1 ), r.Height()); 
       
  2537     // but the following is changed 
       
  2538     // just remove +1 from denominator, because it should be aMaximum - aMinimum 
       
  2539     // and caculate the activeRect seperately according to the iOld ScaleSettingVolume.
       
  2540     TInt range;
       
  2541     if( iOldScaleSettingVolume )
       
  2542         {
       
  2543         range = KVolumeLevels ;      
       
  2544         } 
       
  2545     else
       
  2546         {
       
  2547         range = aMaximum - aMinimum ;
       
  2548         }
       
  2549     TRect activeRect(r.iTl.iX, r.iTl.iY, r.Width() * aValue/range, r.Height()); 
       
  2550     TRect inActiveRect( activeRect.iBr.iX, activeRect.iTl.iY, r.iBr.iX, r.iBr.iY );
       
  2551 
       
  2552    if ( iActiveIcons[0] != NULL && iInActiveIcons[0] != NULL )
       
  2553        {
       
  2554        // add the last parameter for every SetSize() function
       
  2555        // In order to make the solid graphic has the same size as the volume control                 
       
  2556        AknIconUtils::SetSize( iActiveIcons[0], r.Size(),EAspectRatioNotPreserved );
       
  2557        fbsBitGc->BitBlt( activeRect.iTl, iActiveIcons[0], activeRect );
       
  2558        AknIconUtils::SetSize( iInActiveIcons[0], r.Size(),EAspectRatioNotPreserved );
       
  2559        fbsBitGc->BitBlt( inActiveRect.iTl, iInActiveIcons[0], inActiveRect );       
       
  2560 
       
  2561        }
       
  2562 
       
  2563     CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  2564     aIcon->SetBitmap( bitmap ); // Transfers ownership
       
  2565     CleanupStack::Pop(); // bitmap
       
  2566 
       
  2567     // The mask
       
  2568     CFbsBitmap* mask = new (ELeave) CFbsBitmap;
       
  2569     CleanupStack::PushL( mask );
       
  2570 
       
  2571     mask->Create( aRect.Size(), iActiveMasks[0]->DisplayMode() );
       
  2572     fbsBitGc = CFbsBitGc::NewL();
       
  2573     CleanupStack::PushL( fbsBitGc );
       
  2574     bmpDevice = CFbsBitmapDevice::NewL( mask );
       
  2575     CleanupStack::PushL( bmpDevice );
       
  2576     fbsBitGc->Activate( bmpDevice );
       
  2577     fbsBitGc->SetPenStyle( CGraphicsContext::ENullPen );
       
  2578     fbsBitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2579     fbsBitGc->SetBrushColor( KRgbBlack );
       
  2580     fbsBitGc->DrawRect( TRect( aRect.Size() ) );
       
  2581 
       
  2582     fbsBitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2583     
       
  2584    if ( iActiveMasks[0] != NULL && iInActiveMasks[0] != NULL )
       
  2585        {
       
  2586        // add the last parameter for every SetSize() function
       
  2587        // In order to make the solid graphic has the same size as the volume control   
       
  2588        AknIconUtils::SetSize( iActiveMasks[0], r.Size(),EAspectRatioNotPreserved );
       
  2589        fbsBitGc->BitBlt( activeRect.iTl, iActiveMasks[0], activeRect );
       
  2590        AknIconUtils::SetSize( iInActiveMasks[0], r.Size(),EAspectRatioNotPreserved );
       
  2591        fbsBitGc->BitBlt( inActiveRect.iTl, iInActiveMasks[0], inActiveRect );
       
  2592        } 
       
  2593           
       
  2594     CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  2595     aIcon->SetMask( mask ); // Transfers ownership
       
  2596     CleanupStack::Pop(); // mask
       
  2597     }
       
  2598 
       
  2599 // ----------------------------------------------------------------------------
       
  2600 // CVolumeExtension::RectFromLayout
       
  2601 //
       
  2602 // ----------------------------------------------------------------------------
       
  2603 //
       
  2604 TRect CVolumeExtension::RectFromLayout(const TRect& aParent,
       
  2605                 const TAknWindowComponentLayout& aComponentLayout) const
       
  2606     {
       
  2607     TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine();
       
  2608     TAknLayoutRect layoutRect;
       
  2609     layoutRect.LayoutRect(aParent,lineLayout);
       
  2610     return layoutRect.Rect();
       
  2611     }
       
  2612 
       
  2613 // ----------------------------------------------------------------------------
       
  2614 // CVolumeExtension::GetVolumeLevelByPosition()
       
  2615 // This function Searches which iVolumeLevels array's element (TRect) contains
       
  2616 // aPoint. The array is ordered so that the index can then be used to return 
       
  2617 // correct volume level. aAreaRect is used to add volumelevel's height to cover
       
  2618 // whole area so user does not need to click "inside" level. This function also
       
  2619 // calculates gap between volumelevel rects and returns correct volumelevel
       
  2620 // also from clicks to these gaps
       
  2621 // ----------------------------------------------------------------------------
       
  2622 //
       
  2623 TInt CVolumeExtension::GetVolumeLevelByPosition( const TInt& ,
       
  2624                                                  const TPoint& aPoint, 
       
  2625                                                  const TRect& aAreaRect ) const
       
  2626     {
       
  2627     if ( AknLayoutUtils::PenEnabled() )
       
  2628         {
       
  2629         TInt volumeLevel = KVolumeLevelNotFound; 
       
  2630         TInt range = iMaximumValue - iMinimumValue ;
       
  2631         // Use hi-res volume control with dynamic volume range
       
  2632         if( iGfxMode == KGfxModeNew )
       
  2633             {
       
  2634             // Check the point's position in iParentRect x-axis. Use this to 
       
  2635             // define a value between iMinimumValue  and iMaximumValue. Step 
       
  2636             // size is always 1 (value is rounded up).
       
  2637              TInt pointInVolumeAxis = aPoint.iX - iParentRect.iTl.iX;
       
  2638             // This rouds up to integer.
       
  2639             TInt total( pointInVolumeAxis * range );
       
  2640             TInt volumePosition = total / iParentRect.Width() + iMinimumValue;
       
  2641             if ( total % iParentRect.Width() > 0 )
       
  2642                 {
       
  2643                 volumePosition++;
       
  2644                 }             
       
  2645             
       
  2646             if( volumePosition >= iMinimumValue && volumePosition <= iMaximumValue )
       
  2647                 {
       
  2648                 volumeLevel = volumePosition;
       
  2649                 }
       
  2650             else if(volumePosition > iMaximumValue)
       
  2651                 {
       
  2652                 volumeLevel = iMaximumValue;
       
  2653                 }
       
  2654             else
       
  2655                 {
       
  2656                 volumeLevel = iMinimumValue;
       
  2657                 }
       
  2658             }
       
  2659         // Use old volume implementation with range [0,10]
       
  2660         else 
       
  2661             {
       
  2662             TRect nextRect;
       
  2663             TRect thisRect = iVolumeLevels[0];
       
  2664             
       
  2665             if ( iMuteRect.Contains( aPoint ))
       
  2666                 {
       
  2667                 return KVolumeLevelMuteTapped;
       
  2668                 }
       
  2669 
       
  2670             for (TInt i = 1; i <= KVolumeLevels; i++)
       
  2671                 {
       
  2672                 // do not read next rect, if this is last round
       
  2673                 if ( i < KVolumeLevels )
       
  2674                     {
       
  2675                     // read rect for volume level i
       
  2676                     nextRect = iVolumeLevels[i];
       
  2677 
       
  2678                     // set thisRect to contain half of gap between this and next
       
  2679                     //  rect
       
  2680                     // + 1 because right and bottom borders are not "inside" rect
       
  2681                     thisRect.iBr.iX = (nextRect.iTl.iX - thisRect.iBr.iX)/2
       
  2682                                         + thisRect.iBr.iX;
       
  2683 
       
  2684                     // set nextRect to contain other half of gap
       
  2685                     //  between these two rects
       
  2686                     nextRect.iTl.iX = thisRect.iBr.iX;
       
  2687                     }
       
  2688 
       
  2689                 // set volumebars where pointer is accepted
       
  2690                 //  for it to be as high as area.
       
  2691                 thisRect.iTl.iY = aAreaRect.iTl.iY;
       
  2692                 thisRect.iBr.iY = aAreaRect.iBr.iY;
       
  2693 
       
  2694                 if ( thisRect.Contains( aPoint ))
       
  2695                     {
       
  2696                     // Because array is zero indexed, but volumes starts at 1
       
  2697                     //--> Conversion by adding one before return.
       
  2698                     // (and here so that it needs to be done only once)
       
  2699                     volumeLevel = i;
       
  2700                     volumeLevel = volumeLevel * range/KVolumeLevels;
       
  2701                     break;
       
  2702                     }
       
  2703                 thisRect = nextRect;
       
  2704                 }
       
  2705             if( aPoint.iX > iVolumeLevels[KVolumeLevels-1].iBr.iX )
       
  2706                 {
       
  2707                 volumeLevel = iMaximumValue;
       
  2708                 }
       
  2709             else if( aPoint.iX < iVolumeLevels[0].iBr.iX )
       
  2710                 {
       
  2711                 volumeLevel = iMinimumValue;    
       
  2712                 }
       
  2713             }
       
  2714         return volumeLevel;
       
  2715         }
       
  2716     else
       
  2717         {
       
  2718         // Should not occur, just prevent complier's warning
       
  2719         return 0;
       
  2720         }
       
  2721     }
       
  2722 
       
  2723 //  End of File