uifw/AvKon/src/Aknslider.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknUtils.h>
       
    21 #include <barsread.h>
       
    22 #include <eikenv.h>
       
    23 #include <AknDef.h>
       
    24 #include <AknPanic.h>
       
    25 #include <avkon.hrh>
       
    26 #include <avkon.mbg>
       
    27 #include <e32math.h>
       
    28 #include <bitstd.h>
       
    29 #include <bitdev.h>
       
    30 #include <aknconsts.h>
       
    31 #include <StringLoader.h>
       
    32 #include <AknsDrawUtils.h>
       
    33 #include <centralrepository.h>
       
    34 #include <AvkonInternalCRKeys.h>
       
    35 #include <AknsFrameBackgroundControlContext.h>
       
    36 #include <gulicon.h>
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <aknlayoutscalable_apps.cdl.h>
       
    39 #include <layoutmetadata.cdl.h>
       
    40 #include <AknIconUtils.h>
       
    41 #include <AknBidiTextUtils.h>
       
    42 
       
    43 #include <AknTasHook.h>
       
    44 #include "aknslider.h"
       
    45 
       
    46 #include <touchfeedback.h>
       
    47 
       
    48 // Large enough for a 20 digit number or fraction with two 9 digit numbers.
       
    49 // This number is not in the header as it does not need to be known by the
       
    50 // client.
       
    51 const TInt KAknSliderValueLabelValueMaxLength = 20;
       
    52 
       
    53 // This value is used to account for the safety demands of StringLoader. It
       
    54 // requires extra length in the target descriptor of its formatting than you
       
    55 // would expect.
       
    56 const TInt KAknSliderFormatKeyLength = 2;
       
    57 
       
    58 // This value is the optimum number of repeat key events to get through the
       
    59 // range of the slider.
       
    60 
       
    61 const TInt KAknSliderFeedbackActionTime = 160 * 1000; // Interval, microseconds
       
    62 
       
    63 // Default draw color 
       
    64 const TInt KAknSliderDefaultDrawColor = 120;
       
    65 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
       
    66 const TInt KStableFeedbackIntesity = 50;
       
    67 const TInt KFeedbackTimeout = 100000;
       
    68 const TInt KNoFeedbackTimeout = 0;
       
    69 const TInt KStepThreshold = 15;
       
    70 // ============================================================================
       
    71 // Internal class to hold slider control data, primarily coming from resource.
       
    72 NONSHARABLE_CLASS( CAknSliderData ): public CBase
       
    73     {
       
    74 public:
       
    75     static CAknSliderData* NewLC( TInt aResourceId );
       
    76     static CAknSliderData* NewL( TResourceReader& aReader );
       
    77     ~CAknSliderData();
       
    78 
       
    79     void SetRange( TInt aMinimumValue, TInt aMaximumValue );
       
    80     inline TInt Range() const
       
    81         {
       
    82         return iMaximumValue - iMinimumValue;
       
    83         }
       
    84 
       
    85     void SetDecimalPlaces( TInt aDecimalPlaces );
       
    86     inline TInt DecimalPlaces() const
       
    87         {
       
    88         return iDecimalPlaces;
       
    89         }
       
    90 
       
    91 
       
    92 private:
       
    93     CAknSliderData();
       
    94     void ConstructFromResourceL( TInt aResourceId );
       
    95     void ConstructFromResourceL( TResourceReader& aReader );
       
    96 
       
    97     // Copy constructor, declared not defined -> disabled
       
    98     CAknSliderData( const CAknSliderData& aData );
       
    99     // Assignment operator, declared not defined -> disabled
       
   100     const CAknSliderData& operator=( const CAknSliderData& aData );
       
   101 
       
   102 public:
       
   103     TInt iMinimumValue;
       
   104     TInt iMaximumValue;
       
   105     TInt iStepSize;
       
   106     TInt iValueType;
       
   107     TInt iLayout;
       
   108     HBufC* iText; // Owned
       
   109 
       
   110     // Text to be used for the singular label if needed. Owned
       
   111     HBufC* iSingularText;
       
   112 
       
   113     HBufC* iMinimumLabelText; // Owned
       
   114     HBufC* iMaximumLabelText; // Owned
       
   115     TInt iDecoratorImageId;
       
   116     TAknFeedbackStyle iFeedbackStyle;
       
   117         
       
   118 private:
       
   119     TInt iDecimalPlaces;
       
   120 
       
   121     // NOTE! This class is only for storing the data read from slider resource.
       
   122     // Do not add any unnecessary members to this class, such data and
       
   123     // functionality should go to the extension instead.
       
   124     };
       
   125 
       
   126 
       
   127 // ----------------------------------------------------------------------------
       
   128 // CAknSliderData::NewLC
       
   129 // ----------------------------------------------------------------------------
       
   130 //
       
   131 CAknSliderData* CAknSliderData::NewLC( TInt aResourceId )
       
   132     {
       
   133     CAknSliderData* self = new ( ELeave ) CAknSliderData();
       
   134     CleanupStack::PushL( self );
       
   135     self->ConstructFromResourceL( aResourceId );
       
   136     return self;
       
   137     }
       
   138 
       
   139 
       
   140 // ----------------------------------------------------------------------------
       
   141 // CAknSliderData::NewL
       
   142 // ----------------------------------------------------------------------------
       
   143 //
       
   144 CAknSliderData* CAknSliderData::NewL( TResourceReader& aReader )
       
   145     {
       
   146     CAknSliderData* self = new ( ELeave ) CAknSliderData();
       
   147     CleanupStack::PushL( self );
       
   148     self->ConstructFromResourceL( aReader );
       
   149     CleanupStack::Pop( self );
       
   150     return self;
       
   151     }
       
   152 
       
   153 
       
   154 // ----------------------------------------------------------------------------
       
   155 // Constructor
       
   156 // ----------------------------------------------------------------------------
       
   157 //
       
   158 CAknSliderData::CAknSliderData()
       
   159     {
       
   160     // Derived from CBase -> members zeroed
       
   161     }
       
   162 
       
   163 
       
   164 // ----------------------------------------------------------------------------
       
   165 // Destructor
       
   166 // ----------------------------------------------------------------------------
       
   167 //
       
   168 CAknSliderData::~CAknSliderData()
       
   169     {
       
   170     delete iText;
       
   171     delete iSingularText;
       
   172     delete iMinimumLabelText;
       
   173     delete iMaximumLabelText;
       
   174     }
       
   175 
       
   176 // ----------------------------------------------------------------------------
       
   177 // CAknSliderData::ConstructFromResourceL
       
   178 // ----------------------------------------------------------------------------
       
   179 //
       
   180 void CAknSliderData::ConstructFromResourceL( TInt aResourceId )
       
   181     {
       
   182     TResourceReader reader;
       
   183     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
       
   184     ConstructFromResourceL( reader );
       
   185     CleanupStack::PopAndDestroy(); // reader
       
   186     }
       
   187 
       
   188 
       
   189 // ----------------------------------------------------------------------------
       
   190 // CAknSliderData::ConstructFromResource
       
   191 // ----------------------------------------------------------------------------
       
   192 //
       
   193 void CAknSliderData::ConstructFromResourceL( TResourceReader& aReader )
       
   194     {
       
   195     TInt sliderType = aReader.ReadInt16();
       
   196     if ( sliderType == EAknSliderWithFeedbackStyle )
       
   197         {
       
   198         iFeedbackStyle = (TAknFeedbackStyle)aReader.ReadInt16();
       
   199         iLayout = aReader.ReadInt16();
       
   200         }
       
   201     else
       
   202         {
       
   203         // old resource struct used -> actually sliderType contains
       
   204         // layout information
       
   205         iLayout = sliderType;
       
   206         if ( iLayout > EAknSliderLayoutHorizontal )
       
   207             {
       
   208             iLayout = EAknSliderLayoutHorizontal;
       
   209             }
       
   210         }
       
   211         
       
   212     TInt min = aReader.ReadInt16();
       
   213     TInt max = aReader.ReadInt16();
       
   214     SetRange( min, max );
       
   215     iStepSize = aReader.ReadInt16();
       
   216     iValueType = aReader.ReadInt16();
       
   217     SetDecimalPlaces( aReader.ReadInt16() );
       
   218     iSingularText = aReader.ReadHBufCL();
       
   219     iMinimumLabelText = aReader.ReadHBufCL();
       
   220     iMaximumLabelText = aReader.ReadHBufCL();
       
   221     iText = aReader.ReadHBufCL();
       
   222 
       
   223     // Extension link for graphics
       
   224     iDecoratorImageId = aReader.ReadInt32();
       
   225     if ( !iDecoratorImageId )
       
   226         {
       
   227         iDecoratorImageId = R_AVKON_SLIDER_CONTRAST_GRAPHICS;
       
   228         }
       
   229     }
       
   230 
       
   231 
       
   232 // ----------------------------------------------------------------------------
       
   233 // CAknSliderData::SetRange
       
   234 // ----------------------------------------------------------------------------
       
   235 //
       
   236 void CAknSliderData::SetRange( TInt aMinimumValue, TInt aMaximumValue )
       
   237     {
       
   238     __ASSERT_ALWAYS( aMaximumValue > aMinimumValue,
       
   239                      Panic( EAknPanicOutOfRange ) );
       
   240 
       
   241     iMaximumValue = aMaximumValue;
       
   242     iMinimumValue = aMinimumValue;
       
   243     }
       
   244 
       
   245 
       
   246 // ----------------------------------------------------------------------------
       
   247 // CAknSliderData::SetDecimalPlaces
       
   248 // ----------------------------------------------------------------------------
       
   249 //
       
   250 void CAknSliderData::SetDecimalPlaces( TInt aDecimalPlaces )
       
   251     {
       
   252     __ASSERT_DEBUG( aDecimalPlaces >= 0, Panic( EAknPanicInvalidValue ) );
       
   253     __ASSERT_DEBUG( aDecimalPlaces < 10, Panic( EAknPanicInvalidValue ) );
       
   254     iDecimalPlaces = Abs( aDecimalPlaces );
       
   255     }
       
   256     
       
   257     
       
   258 // ============================================================================
       
   259 NONSHARABLE_STRUCT( TAknSliderGfx )
       
   260     {
       
   261     TAknSliderGfx(): iRgb( NULL ), iMask( NULL )
       
   262         {}
       
   263 
       
   264     CFbsBitmap* iRgb; // Referenced.
       
   265     CFbsBitmap* iMask; // Referenced.
       
   266     // customized graphics flag
       
   267     TInt iCustomizedFlag; // if use default, then value = 0, else value = 1
       
   268     };
       
   269 
       
   270 // ============================================================================
       
   271 NONSHARABLE_CLASS( CAknSliderExtension ): public CBase
       
   272     {
       
   273 public:
       
   274 
       
   275     // Symbols for bitflags.
       
   276     enum TFlags
       
   277         {
       
   278         EFlagHorizontal,
       
   279         EFlagFillEnabled,
       
   280         EFlagMarkerEnabled,
       
   281         EFlagTickMarksEnabled,
       
   282         EFlagTickBelowOrRight,
       
   283         EFlagPointerDown,
       
   284         EFlagDraggingThumb,
       
   285         EFlagValueStepChange,
       
   286         EFlagPlayingContinuousFb,
       
   287         EFlagCount // must be the last flag
       
   288         };
       
   289 
       
   290 private:
       
   291     CAknSliderExtension();
       
   292     // Copy constructor, declared not defined -> disabled
       
   293     CAknSliderExtension( const CAknSliderExtension& );
       
   294     // Assignment operator, declared not defined -> disabled
       
   295     const CAknSliderExtension& operator=( const CAknSliderExtension& );
       
   296 
       
   297     void ConstructL();
       
   298 
       
   299 public:
       
   300     ~CAknSliderExtension();
       
   301     static CAknSliderExtension* NewL();
       
   302 
       
   303     void SetGraphics( TInt aElement, 
       
   304                       CFbsBitmap* aBitmap, 
       
   305                       CFbsBitmap* aMask,
       
   306                       TBool aCustomize = ETrue);
       
   307     void UseDefaultGraphics( TInt aElement );
       
   308     TBool UsesDefaultGraphics( TInt aElement ) const;
       
   309     TBool UsesDefaultGraphics() const;
       
   310     void GetGfx( TAknSliderGfx& aGfx, TInt aElement ) const;
       
   311     
       
   312     void DeleteBitmaps();
       
   313     void TryLoadNSliderBitmap(TBool aFromSkin, MAknsSkinInstance* aSkin );
       
   314     void TryLoadNSliderVerticalBitmap( MAknsSkinInstance* aSkin );                         
       
   315     inline void SetFlag( TInt aFlagIndex )
       
   316         {
       
   317         ASSERT( 0 <= aFlagIndex && aFlagIndex < EFlagCount );
       
   318         iFlags.Set( aFlagIndex );
       
   319         }
       
   320 
       
   321     inline void ClearFlag( TInt aFlagIndex )
       
   322         {
       
   323         ASSERT( 0 <= aFlagIndex && aFlagIndex < EFlagCount );
       
   324         iFlags.Clear( aFlagIndex );
       
   325         }
       
   326 
       
   327     inline TBool IsFlagSet( TInt aFlagIndex ) const
       
   328         {
       
   329         ASSERT( 0 <= aFlagIndex && aFlagIndex < EFlagCount );
       
   330         return iFlags.IsSet( aFlagIndex );
       
   331         }
       
   332 
       
   333 public:
       
   334     CFbsBitmap* iLineIcon; // Owned.
       
   335     CFbsBitmap* iLineIconMask; // Owned.
       
   336  
       
   337     TRect iLeftCapRect; // The default value is zero -> no left line cap
       
   338     TRect iRightCapRect; // The default value is zero -> no right line cap
       
   339     
       
   340     TRect iTickRect;
       
   341 
       
   342     CPeriodic* iTimer; // Owned.
       
   343     TInt iEffectTimerCount;
       
   344     TRect iThumbRect; // Equals GetMarkerRect
       
   345     TUint iTickInterval;
       
   346     TPoint iPenInputPos;//remember pointer input position
       
   347 
       
   348     TBool iReportMarkerDragEvent;
       
   349     TRect iTouchDownArea;
       
   350     TRect iTouchActiveArea;
       
   351     TBool iNoDraw;
       
   352         
       
   353 private:
       
   354     // If EFlagHorizontal is not set, the orientation is vertical.
       
   355     TBitFlags32 iFlags;
       
   356 
       
   357     // Stores the element graphics (rgb icon and mask icon) as bitmaps. Bitmaps
       
   358     // are owned.
       
   359     TAknSliderGfx iGfx[CAknSlider::EElemMarkerSelected + 1];
       
   360     };
       
   361 
       
   362 
       
   363 // ----------------------------------------------------------------------------
       
   364 // CAknSliderExtension::CAknSliderExtension
       
   365 // ----------------------------------------------------------------------------
       
   366 //
       
   367 CAknSliderExtension::CAknSliderExtension()
       
   368     {
       
   369     // slider is derived from CBase -> members zeroed
       
   370     SetFlag( EFlagMarkerEnabled );//default is marker enable
       
   371     SetFlag( EFlagHorizontal ); //default is horizontal enable
       
   372     SetFlag( EFlagValueStepChange); //default is step change enable
       
   373     
       
   374     // Don't report drag event as default setting
       
   375     iReportMarkerDragEvent = EFalse;
       
   376     }
       
   377 
       
   378 
       
   379 // ----------------------------------------------------------------------------
       
   380 // Destructor
       
   381 // ----------------------------------------------------------------------------
       
   382 //
       
   383 CAknSliderExtension::~CAknSliderExtension()
       
   384     {
       
   385     if( iTimer )
       
   386         {
       
   387         iTimer->Cancel();
       
   388         }
       
   389     
       
   390     delete iTimer;
       
   391     delete iLineIcon;
       
   392     delete iLineIconMask;
       
   393     
       
   394     DeleteBitmaps();
       
   395     }
       
   396 
       
   397 
       
   398 // ----------------------------------------------------------------------------
       
   399 // CAknSliderExtension::ConstructL
       
   400 // ----------------------------------------------------------------------------
       
   401 //
       
   402 void CAknSliderExtension::ConstructL()
       
   403     {
       
   404     // Create icon for line
       
   405     AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
   406         KAknsIIDQgnGrafLinePrimaryHorizontal, iLineIcon, iLineIconMask,
       
   407         KAvkonBitmapFile, EMbmAvkonQgn_graf_line_primary_horizontal,
       
   408         EMbmAvkonQgn_graf_line_primary_horizontal_mask );
       
   409     
       
   410     // Set default value
       
   411     for ( int i = 0; i <= CAknSlider::EElemMarkerSelected; ++i )
       
   412         {
       
   413         iGfx[i].iRgb = NULL;
       
   414         iGfx[i].iMask = NULL;
       
   415         iGfx[i].iCustomizedFlag = 0;
       
   416         }
       
   417         
       
   418     iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   419     }
       
   420 
       
   421 
       
   422 // ----------------------------------------------------------------------------
       
   423 // CAknSliderExtension::NewL
       
   424 // ----------------------------------------------------------------------------
       
   425 //
       
   426 CAknSliderExtension* CAknSliderExtension::NewL()
       
   427     {
       
   428     
       
   429     CAknSliderExtension* self = new( ELeave ) CAknSliderExtension();
       
   430     CleanupStack::PushL( self );
       
   431     self->ConstructL();
       
   432     CleanupStack::Pop( self );
       
   433     return self;
       
   434     }
       
   435 
       
   436 // ----------------------------------------------------------------------------
       
   437 // CAknSliderExtension::TryLoadNewSliderBitmap
       
   438 //
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 void CAknSliderExtension::TryLoadNSliderBitmap( TBool aFromSkin, MAknsSkinInstance* aSkin )
       
   442     {
       
   443     
       
   444     const TInt iconIDArray[] = 
       
   445         {
       
   446         EMbmAvkonQgn_graf_nslider_end_left,
       
   447         EMbmAvkonQgn_graf_nslider_end_right,
       
   448         EMbmAvkonQgn_graf_nslider_middle,
       
   449         EMbmAvkonQgn_graf_nslider_marker,
       
   450         EMbmAvkonQgn_graf_nslider_marker_selected
       
   451         };
       
   452     const TInt iconMaskIDArray[] = 
       
   453         {
       
   454         EMbmAvkonQgn_graf_nslider_end_left_mask,
       
   455         EMbmAvkonQgn_graf_nslider_end_right_mask,
       
   456         EMbmAvkonQgn_graf_nslider_middle_mask,
       
   457         EMbmAvkonQgn_graf_nslider_marker_mask,
       
   458         EMbmAvkonQgn_graf_nslider_marker_selected_mask
       
   459         }; 
       
   460     const TAknsItemID iconSkinIDArray[] = 
       
   461         {
       
   462         KAknsIIDQgnGrafNsliderEndLeft,
       
   463         KAknsIIDQgnGrafNsliderEndRight,
       
   464         KAknsIIDQgnGrafNsliderMiddle,
       
   465         KAknsIIDQgnGrafNsliderMarker,
       
   466         KAknsIIDQgnGrafNsliderMarkerSelected
       
   467         };
       
   468         
       
   469     const TInt element[] = 
       
   470         {
       
   471         CAknSlider::EElemEmptyLeftCap,
       
   472         CAknSlider::EElemEmptyRightCap,
       
   473         CAknSlider::EElemEmptyLine,
       
   474         CAknSlider::EElemMarker,
       
   475         CAknSlider::EElemMarkerSelected
       
   476         };
       
   477     TInt arrayTotal = sizeof( iconIDArray )/sizeof(TInt);
       
   478 
       
   479     TInt err = KErrNone;
       
   480     for ( TInt i = 0; i < arrayTotal; i++ )
       
   481         {
       
   482         CFbsBitmap* bitmapPtr = NULL;
       
   483         CFbsBitmap* maskPtr = NULL;
       
   484         
       
   485         if( aFromSkin )
       
   486             {
       
   487             //find new graphic from Skinned bitmap
       
   488             TRAP(err, AknsUtils::CreateIconL( aSkin,
       
   489                 iconSkinIDArray[i],
       
   490                 bitmapPtr,
       
   491                 maskPtr,
       
   492                 KNullDesC,
       
   493                 iconIDArray[i],
       
   494                 iconMaskIDArray[i] ));
       
   495             }
       
   496         //find new graphic from mif file
       
   497         else
       
   498             {
       
   499              TRAP(err, AknIconUtils::CreateIconL(
       
   500                 bitmapPtr,
       
   501                 maskPtr,
       
   502                 KAvkonBitmapFile,
       
   503                 iconIDArray[i],
       
   504                 iconMaskIDArray[i] ));            
       
   505             }
       
   506         if( !err )
       
   507             {
       
   508             SetGraphics( element[i], bitmapPtr, maskPtr );
       
   509             }           
       
   510         }
       
   511     }
       
   512     
       
   513   
       
   514 // ----------------------------------------------------------------------------
       
   515 // CAknSliderExtension::TryLoadNewSliderBitmap
       
   516 //
       
   517 // ----------------------------------------------------------------------------
       
   518 //
       
   519 void CAknSliderExtension::TryLoadNSliderVerticalBitmap( MAknsSkinInstance* aSkin )
       
   520     {
       
   521     
       
   522     const TInt iconIDArray[] = 
       
   523         {
       
   524         EMbmAvkonQgn_graf_nslider_vertical_top,        
       
   525         EMbmAvkonQgn_graf_nslider_vertical_bottom,
       
   526         EMbmAvkonQgn_graf_nslider_vertical_middle,
       
   527         EMbmAvkonQgn_graf_nslider_vertical_marker,
       
   528         EMbmAvkonQgn_graf_nslider_vertical_tick_major,
       
   529         EMbmAvkonQgn_graf_nslider_vertical_marker
       
   530         };
       
   531     const TInt iconMaskIDArray[] = 
       
   532         {
       
   533         EMbmAvkonQgn_graf_nslider_vertical_top_mask,
       
   534         EMbmAvkonQgn_graf_nslider_vertical_bottom_mask,
       
   535         EMbmAvkonQgn_graf_nslider_vertical_middle_mask,
       
   536         EMbmAvkonQgn_graf_nslider_vertical_marker_mask,
       
   537         EMbmAvkonQgn_graf_nslider_vertical_tick_major_mask,
       
   538         EMbmAvkonQgn_graf_nslider_marker_mask
       
   539         }; 
       
   540     const TAknsItemID iconSkinIDArray[] = 
       
   541         {
       
   542         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalTop,        
       
   543         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalBottom,
       
   544         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalMiddle,
       
   545         KAknsIIDNone,// KAknsIIDQgnGrafNsliderVerticalMarker,
       
   546         KAknsIIDNone,// KAknsIIDQgnGrafNsliderVerticalTIckMajor,
       
   547         KAknsIIDNone//KAknsIIDQgnGrafNsliderVerticalMarker
       
   548         };
       
   549         
       
   550     const TInt element[] = 
       
   551         {
       
   552         CAknSlider::EElemEmptyLeftCap,
       
   553         CAknSlider::EElemEmptyRightCap,
       
   554         CAknSlider::EElemEmptyLine,
       
   555         CAknSlider::EElemMarker,
       
   556         CAknSlider::EElemTickMark,
       
   557         CAknSlider::EElemMarkerSelected
       
   558         };
       
   559 
       
   560     TInt arrayTotal = sizeof( iconIDArray )/sizeof(TInt);
       
   561 
       
   562     TInt err = KErrNone;
       
   563     CFbsBitmap* bitmapPtr = NULL;
       
   564     CFbsBitmap* maskPtr = NULL;    
       
   565     for ( TInt i = 0; i < arrayTotal; i++ )
       
   566         {
       
   567         //find new graphic from Skinned bitmap
       
   568         TRAP(err, AknsUtils::CreateIconL( aSkin,
       
   569             iconSkinIDArray[i],
       
   570             bitmapPtr,
       
   571             maskPtr,
       
   572             KNullDesC,
       
   573             iconIDArray[i],
       
   574             iconMaskIDArray[i] ));
       
   575 
       
   576         // find new graphic from mif file
       
   577        if ( err )
       
   578             {
       
   579              TRAP(err,AknIconUtils::CreateIconL(
       
   580                 bitmapPtr,
       
   581                 maskPtr,
       
   582                 KAvkonBitmapFile,
       
   583                 iconIDArray[i],
       
   584                 iconMaskIDArray[i] ));      
       
   585             } 
       
   586         if( !err )
       
   587             {
       
   588             SetGraphics( element[i], bitmapPtr, maskPtr, EFalse );
       
   589             }          
       
   590         }
       
   591     } 
       
   592 // ----------------------------------------------------------------------------
       
   593 // CAknSliderExtension::DeleteBitmaps
       
   594 //
       
   595 // ----------------------------------------------------------------------------
       
   596 //
       
   597 void CAknSliderExtension::DeleteBitmaps()
       
   598     {
       
   599     TInt i;
       
   600 
       
   601     for( i = 0; i <= CAknSlider::EElemMarkerSelected; i++)
       
   602         {
       
   603         delete iGfx[i].iRgb;
       
   604         iGfx[i].iRgb = NULL;
       
   605         delete iGfx[i].iMask;
       
   606         iGfx[i].iMask = NULL;
       
   607       
       
   608         }
       
   609     }
       
   610    
       
   611 // ----------------------------------------------------------------------------
       
   612 // CAknSliderExtension::SetGraphics
       
   613 // ----------------------------------------------------------------------------
       
   614 //
       
   615 void CAknSliderExtension::SetGraphics( TInt aElement, 
       
   616                                        CFbsBitmap* aBitmap, 
       
   617                                        CFbsBitmap* aMask, 
       
   618                                        TBool aCustomize )
       
   619     {
       
   620     // element index is assumed to be valid (no checking)
       
   621     
       
   622     // no need to set rgb or mask to NULL as we are assigning and won't leave
       
   623     delete iGfx[aElement].iRgb;
       
   624     iGfx[aElement].iRgb = aBitmap;
       
   625 
       
   626     delete iGfx[aElement].iMask;
       
   627     iGfx[aElement].iMask = aMask;
       
   628     
       
   629     // Set the flag to 1
       
   630     iGfx[aElement].iCustomizedFlag = aCustomize;
       
   631     
       
   632     switch( aElement )
       
   633         {
       
   634         case CAknSlider::EElemFilledLine:
       
   635             {
       
   636             SetFlag( EFlagFillEnabled );          
       
   637             }
       
   638             break;
       
   639          case CAknSlider::EElemMarker:
       
   640             {
       
   641             SetFlag( EFlagMarkerEnabled );          
       
   642             }
       
   643             break;           
       
   644         case CAknSlider::EElemTickMark:
       
   645             {
       
   646             if( aBitmap==NULL && aMask==NULL )
       
   647                 {
       
   648                 ClearFlag( EFlagTickMarksEnabled );
       
   649                 }
       
   650             else
       
   651                 {
       
   652                 SetFlag( EFlagTickMarksEnabled );   
       
   653                 }
       
   654             }
       
   655             break;
       
   656         default:
       
   657             break;
       
   658     
       
   659         }
       
   660     }
       
   661 
       
   662     
       
   663 // ----------------------------------------------------------------------------
       
   664 // CAknSliderExtension::UseDefaultGraphics
       
   665 // ----------------------------------------------------------------------------
       
   666 //
       
   667 void CAknSliderExtension::UseDefaultGraphics( TInt aElement )
       
   668     {
       
   669     // element index is assumed to be valid (no checking)
       
   670     
       
   671     delete iGfx[aElement].iRgb;
       
   672     iGfx[aElement].iRgb = NULL;
       
   673 
       
   674     delete iGfx[aElement].iMask;
       
   675     iGfx[aElement].iMask = NULL;
       
   676     
       
   677     iGfx[aElement].iCustomizedFlag = 0;
       
   678     }
       
   679 
       
   680 
       
   681 
       
   682 // ----------------------------------------------------------------------------
       
   683 // CAknSliderExtension::UsesDefaultGraphics
       
   684 // ----------------------------------------------------------------------------
       
   685 //
       
   686 TBool CAknSliderExtension::UsesDefaultGraphics( TInt aElement ) const
       
   687     {
       
   688     // element index is assumed to be valid (no checking)
       
   689     
       
   690     if ( iGfx[aElement].iCustomizedFlag == 0 )
       
   691         {
       
   692         return ETrue;
       
   693         }
       
   694     return EFalse;
       
   695     }
       
   696     
       
   697 // ----------------------------------------------------------------------------
       
   698 // CAknSliderExtension::UsesDefaultGraphics
       
   699 // ----------------------------------------------------------------------------
       
   700 //
       
   701 TBool CAknSliderExtension::UsesDefaultGraphics() const
       
   702     {
       
   703     // element index is assumed to be valid (no checking)
       
   704 
       
   705     TBool ret(ETrue);
       
   706 
       
   707     ret = ret && UsesDefaultGraphics( CAknSlider::EElemEmptyLeftCap ) && 
       
   708                  UsesDefaultGraphics( CAknSlider::EElemEmptyRightCap ) &&
       
   709                  UsesDefaultGraphics( CAknSlider::EElemEmptyLine );
       
   710 
       
   711     return ret;
       
   712     }
       
   713     
       
   714 // ----------------------------------------------------------------------------
       
   715 // CAknSliderExtension::GetGfx
       
   716 // ----------------------------------------------------------------------------
       
   717 //
       
   718 void CAknSliderExtension::GetGfx( TAknSliderGfx& aGfx, TInt aElement ) const
       
   719     {
       
   720     // element index is assumed to be valid (no checking)
       
   721     
       
   722     aGfx = iGfx[aElement];
       
   723     }
       
   724 
       
   725 
       
   726 // ============================================================================
       
   727 // An internal helper class for creating slider graphics for option setting
       
   728 // item.
       
   729 NONSHARABLE_CLASS( CAknSliderIconizer ): public CBase
       
   730     {
       
   731 public:
       
   732     static void CreateSettingsIconL( const TRect& aRect, TInt aValue,
       
   733                                      CGulIcon* aIcon, const TInt aMinValue,
       
   734                                      const TInt aMaxValue );
       
   735                                      
       
   736     static void ReSizeDefaultSettingsIcons( const TRect& aParent,
       
   737                                         CAknSliderIconizer* aIcon );
       
   738     static void ReSizeNewSettingsIcons( const TRect& aParent,
       
   739                                         CAknSliderExtension* aExtension,
       
   740                                         CAknSliderIconizer* aIcon,
       
   741                                         TInt aValue, 
       
   742                                         const TInt aMinValue, 
       
   743                                         const TInt aMaxValue );
       
   744 private:
       
   745     CAknSliderIconizer();
       
   746     ~CAknSliderIconizer();
       
   747     void DrawSettingsIconL( const TRect& aRect, TInt aValue, CGulIcon* aIcon,
       
   748                             const TInt aMinValue, const TInt aMaxValue , 
       
   749                             TBool aFlagFilled ) const;
       
   750     
       
   751     void DrawDefaultSettingsIconL( const TRect& aParent, 
       
   752                                    TInt aValue, 
       
   753                                    CFbsBitGc* aFbsBitGc,
       
   754                                    const TInt aMinValue,
       
   755                                     const TInt aMaxValue ) const;
       
   756     void DrawNewSettingsIconL( const TRect& aParent, 
       
   757                                TInt aValue, 
       
   758                                CFbsBitGc* aFbsBitGc,
       
   759                                const TInt aMinValue, 
       
   760                                const TInt aMaxValue, 
       
   761                                TBool aFilledFlag ) const;           
       
   762                                 
       
   763 private:
       
   764     // Stores the element graphics (rgb icon and mask icon) as bitmaps. Bitmaps
       
   765     // are owned.
       
   766     TAknSliderGfx iSettingGfx[CAknSlider::EElemMarkerSelected + 1];
       
   767    
       
   768     };
       
   769 
       
   770 
       
   771 // ----------------------------------------------------------------------------
       
   772 // Constructor
       
   773 // ----------------------------------------------------------------------------
       
   774 //
       
   775 CAknSliderIconizer::CAknSliderIconizer()
       
   776     {
       
   777     // Derived from CBase -> members zeroed
       
   778     }
       
   779 
       
   780 
       
   781 // ----------------------------------------------------------------------------
       
   782 // Destructor
       
   783 // ----------------------------------------------------------------------------
       
   784 //
       
   785 CAknSliderIconizer::~CAknSliderIconizer()
       
   786     {
       
   787     }
       
   788 
       
   789 
       
   790 // ----------------------------------------------------------------------------
       
   791 // CAknSliderIconizer::CreateSettingsIconL
       
   792 // ----------------------------------------------------------------------------
       
   793 //
       
   794 void CAknSliderIconizer::CreateSettingsIconL(
       
   795         const TRect& aRect, TInt aValue, CGulIcon* aIcon,
       
   796         const TInt aMinValue, const TInt aMaxValue )
       
   797     {
       
   798     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   799     
       
   800     CAknSliderIconizer* iconizer = new ( ELeave ) CAknSliderIconizer;
       
   801     CleanupStack::PushL( iconizer );
       
   802     
       
   803     // Set default value
       
   804     for ( int i = 0; i <= CAknSlider::EElemMarkerSelected; ++i )
       
   805         {
       
   806         iconizer->iSettingGfx[i].iRgb = NULL;
       
   807         iconizer->iSettingGfx[i].iMask = NULL;
       
   808         iconizer->iSettingGfx[i].iCustomizedFlag = 0;
       
   809         }
       
   810 
       
   811     // aRect = set_value_pane
       
   812     TAknLayoutRect layoutRect;
       
   813     layoutRect.LayoutRect( aRect,
       
   814                         AknLayoutScalable_Avkon::slider_set_pane_cp3() );
       
   815     TRect sliderPane = layoutRect.Rect();
       
   816      CAknSliderExtension* extension = CAknSliderExtension::NewL();
       
   817     CleanupStack::PushL( extension );
       
   818            
       
   819     // Load bitmaps
       
   820     //1.load new graphics from skin
       
   821     extension->TryLoadNSliderBitmap( ETrue, skin );
       
   822     
       
   823     if( extension->UsesDefaultGraphics() )
       
   824         {
       
   825         //2. load old graphic from skin
       
   826         TRAPD( err, { 
       
   827                     AknsUtils::CreateIconL( skin,
       
   828                         KAknsIIDQgnIndiSliderSet,
       
   829                         iconizer->iSettingGfx[CAknSlider::EElemMarker].iRgb, 
       
   830                         iconizer->iSettingGfx[CAknSlider::EElemMarker].iMask,
       
   831                         KNullDesC,
       
   832                         EMbmAvkonQgn_indi_slider_edit,
       
   833                         EMbmAvkonQgn_indi_slider_edit_mask );
       
   834 
       
   835                     AknsUtils::CreateIconL( skin, 
       
   836                         KAknsIIDQgnGrafLinePrimaryHorizontal,
       
   837                         iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iRgb, 
       
   838                         iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iMask,
       
   839                         KNullDesC,
       
   840                         EMbmAvkonQgn_graf_line_primary_horizontal,
       
   841                         EMbmAvkonQgn_graf_line_primary_horizontal_mask );
       
   842                     } );
       
   843         if( !err )
       
   844             {
       
   845             ReSizeDefaultSettingsIcons( sliderPane, iconizer );
       
   846             }
       
   847                         
       
   848         //3.load new from mif, must success
       
   849 
       
   850         else
       
   851             {
       
   852             extension->TryLoadNSliderBitmap( EFalse, skin );
       
   853             }
       
   854         }
       
   855 
       
   856     
       
   857     //new slider layout
       
   858     ReSizeNewSettingsIcons( sliderPane, extension, iconizer, 
       
   859                                 aValue, aMinValue,aMaxValue );
       
   860           
       
   861     iconizer->DrawSettingsIconL( aRect, 
       
   862                                  aValue, 
       
   863                                  aIcon, 
       
   864                                  aMinValue, 
       
   865                                  aMaxValue,
       
   866                   extension->IsFlagSet(CAknSliderExtension::EFlagFillEnabled));
       
   867     
       
   868     CleanupStack::PopAndDestroy(); // extension, the bitmaps loaded deleted here
       
   869     if( iconizer->iSettingGfx[CAknSlider::EElemMarker].iCustomizedFlag == 0 )
       
   870         {
       
   871         delete iconizer->iSettingGfx[CAknSlider::EElemMarker].iRgb;
       
   872         iconizer->iSettingGfx[CAknSlider::EElemMarker].iRgb = NULL; 
       
   873         delete iconizer->iSettingGfx[CAknSlider::EElemMarker].iMask;
       
   874         iconizer->iSettingGfx[CAknSlider::EElemMarker].iMask = NULL;
       
   875         }
       
   876     if( iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iCustomizedFlag == 0 )
       
   877         {
       
   878         delete iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iRgb;
       
   879         iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iRgb = NULL; 
       
   880         delete iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iMask;
       
   881         iconizer->iSettingGfx[CAknSlider::EElemEmptyLine].iMask = NULL;
       
   882         }
       
   883     CleanupStack::PopAndDestroy( iconizer );
       
   884     }
       
   885 // ----------------------------------------------------------------------------
       
   886 // CAknSliderIconizer::ReSizeDefaultSettingsIcons
       
   887 // ----------------------------------------------------------------------------
       
   888 //
       
   889 void CAknSliderIconizer::ReSizeDefaultSettingsIcons( const TRect& aParent,
       
   890                                                  CAknSliderIconizer* aIcon )
       
   891     {
       
   892     TAknLayoutRect temp;
       
   893     TRect lineRect,markerRect;    
       
   894     //old slider layout
       
   895     temp.LayoutRect( aParent,
       
   896                         AknLayoutScalable_Avkon::slider_set_pane_g1() );
       
   897     lineRect = temp.Rect();
       
   898     temp.LayoutRect( aParent,
       
   899                         AknLayoutScalable_Avkon::slider_set_pane_g2() );
       
   900     markerRect = temp.Rect();
       
   901     if( aIcon->iSettingGfx[CAknSlider::EElemEmptyLine].iRgb != NULL &&
       
   902         aIcon->iSettingGfx[CAknSlider::EElemMarker].iRgb != NULL )
       
   903         {
       
   904     AknIconUtils::SetSize( aIcon->iSettingGfx[CAknSlider::EElemEmptyLine].iRgb,
       
   905                            lineRect.Size(),
       
   906                            EAspectRatioNotPreserved );
       
   907     AknIconUtils::SetSize( aIcon->iSettingGfx[CAknSlider::EElemMarker].iRgb, 
       
   908                            markerRect.Size() );  
       
   909         }
       
   910     }
       
   911     
       
   912 // ----------------------------------------------------------------------------
       
   913 // CAknSliderIconizer::ReSizeNewSettingsIcons
       
   914 // ----------------------------------------------------------------------------
       
   915 //
       
   916 void CAknSliderIconizer::ReSizeNewSettingsIcons( const TRect& aParent,
       
   917                                                  CAknSliderExtension* aExtentsion,
       
   918                                                  CAknSliderIconizer* aIcon,TInt aValue, 
       
   919                                                  const TInt aMinValue, 
       
   920                                                  const TInt aMaxValue )
       
   921     {
       
   922     TAknLayoutRect temp;
       
   923     TRect lineRect,markerRect,leftCapRect,rightCapRect,tickRect;
       
   924     temp.LayoutRect( aParent,
       
   925                 AknLayoutScalable_Avkon::slider_set_pane_g4() );
       
   926     lineRect = temp.Rect();
       
   927     
       
   928     temp.LayoutRect( aParent,
       
   929             AknLayoutScalable_Avkon::slider_set_pane_g3() );
       
   930     leftCapRect = temp.Rect();
       
   931     
       
   932     temp.LayoutRect( aParent,
       
   933             AknLayoutScalable_Avkon::slider_set_pane_g5() );
       
   934     rightCapRect = temp.Rect();
       
   935     
       
   936     temp.LayoutRect( aParent,
       
   937             AknLayoutScalable_Avkon::slider_set_pane_g6() );
       
   938     markerRect = temp.Rect();
       
   939     
       
   940     temp.LayoutRect( aParent,
       
   941             AknLayoutScalable_Avkon::slider_set_pane_g7() );
       
   942     
       
   943     tickRect = temp.Rect();
       
   944 
       
   945     TSize size;
       
   946     for ( int i = 0; i <= CAknSlider::EElemMarkerSelected; ++i )
       
   947         {
       
   948         if( !aExtentsion->UsesDefaultGraphics(i) )
       
   949             {
       
   950             aExtentsion->GetGfx( aIcon->iSettingGfx[i], i );
       
   951             
       
   952             switch( i )
       
   953                 {
       
   954                 case CAknSlider::EElemEmptyLine:
       
   955                     {
       
   956                     size = lineRect.Size();
       
   957                     break;
       
   958                     }
       
   959                 case CAknSlider::EElemMarker:
       
   960                 case CAknSlider::EElemMarkerSelected:
       
   961                     {
       
   962                     size = markerRect.Size();
       
   963                     break;
       
   964                     }
       
   965                 case CAknSlider::EElemTickMark:
       
   966                     {
       
   967                     size = tickRect.Size();
       
   968                     break;
       
   969                     }
       
   970                 case CAknSlider::EElemEmptyLeftCap:
       
   971                     {
       
   972                     size = leftCapRect.Size();
       
   973                     break;
       
   974                     }
       
   975                 case CAknSlider::EElemEmptyRightCap:
       
   976                     {
       
   977                     size = rightCapRect.Size();
       
   978                     break;
       
   979                     }
       
   980                 case CAknSlider::EElemFilledLeftCap:
       
   981                     {
       
   982                     size = leftCapRect.Size();
       
   983                     break;
       
   984                     }
       
   985                 case CAknSlider::EElemFilledRightCap:
       
   986                     {
       
   987                     size = rightCapRect.Size(); 
       
   988                     break;
       
   989                     }
       
   990                 case CAknSlider::EElemFilledLine:
       
   991                     {
       
   992                     TInt bmpRun = lineRect.Width() + 
       
   993                                   leftCapRect.Width() + 
       
   994                                   rightCapRect.Width() - 
       
   995                                   markerRect.Width();
       
   996                     TInt pos = ( ( bmpRun * ( aValue - aMinValue ) ) /
       
   997                                  (aMaxValue - aMinValue ) );
       
   998 
       
   999                     TPoint markerPos = TPoint( pos + markerRect.iTl.iX, markerRect.iTl.iY );
       
  1000         
       
  1001                     size.iWidth = markerPos.iX + (markerRect.Width()/2) - 
       
  1002                                   lineRect.iTl.iX;
       
  1003                     size.iHeight = lineRect.Height();
       
  1004                     break;
       
  1005                     }
       
  1006                 default:
       
  1007                 Panic( EAknPanicInvalidValue );
       
  1008                 }
       
  1009             if( aIcon->iSettingGfx[i].iRgb != NULL &&
       
  1010                 aIcon->iSettingGfx[i].iMask != NULL )
       
  1011                 {
       
  1012                 AknIconUtils::SetSize( aIcon->iSettingGfx[i].iRgb, 
       
  1013                                        size, 
       
  1014                                        EAspectRatioNotPreserved );
       
  1015                 AknIconUtils::SetSize( aIcon->iSettingGfx[i].iMask, 
       
  1016                                        size, 
       
  1017                                        EAspectRatioNotPreserved );
       
  1018                 aIcon->iSettingGfx[i].iCustomizedFlag = 1;                
       
  1019                 }
       
  1020             }
       
  1021         }
       
  1022     }
       
  1023 // ----------------------------------------------------------------------------
       
  1024 // CAknSliderIconizer::DrawSettingsIconL
       
  1025 // ----------------------------------------------------------------------------
       
  1026 //
       
  1027 void CAknSliderIconizer::DrawSettingsIconL(
       
  1028         const TRect& aRect, TInt aValue, CGulIcon* aIcon,
       
  1029         const TInt aMinValue, const TInt aMaxValue, TBool aFilledFlag ) const
       
  1030     {
       
  1031     // The actual bitmap
       
  1032     CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap;
       
  1033     CleanupStack::PushL( bitmap );
       
  1034 
       
  1035     User::LeaveIfError( bitmap->Create(
       
  1036             aRect.Size(), CCoeEnv::Static()->ScreenDevice()->DisplayMode() ) );
       
  1037     CFbsBitGc* fbsBitGc = CFbsBitGc::NewL();
       
  1038     CleanupStack::PushL( fbsBitGc );
       
  1039     CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL( bitmap );
       
  1040     CleanupStack::PushL( bmpDevice );
       
  1041     fbsBitGc->Activate( bmpDevice );
       
  1042 
       
  1043     TRect outerRect;
       
  1044     TRect innerRect;
       
  1045     TRect origin;
       
  1046     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, origin );
       
  1047 
       
  1048     TAknLayoutRect layoutRect;
       
  1049     layoutRect.LayoutRect( origin,
       
  1050                         AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ) );
       
  1051     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1052                         AknLayoutScalable_Avkon::list_gen_pane( 0 ) );
       
  1053     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1054                         AknLayoutScalable_Avkon::list_setting_number_pane( 0 ) );
       
  1055     TRect listSettingPaneRect( layoutRect.Rect() );
       
  1056 
       
  1057     // 1. Background skinning
       
  1058     TAknLayoutRect innerLayRect;
       
  1059 
       
  1060     // New style LAF data used
       
  1061 #ifdef RD_LIST_STRETCH
       
  1062     
       
  1063     // check list stretching from cenrep
       
  1064     TBool stretchingEnabled;
       
  1065     CRepository* cenRep = CRepository::NewL( KCRUidAvkon );
       
  1066     cenRep->Get( KAknAutomaticListStretching, stretchingEnabled );
       
  1067     delete cenRep;
       
  1068 
       
  1069     if ( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1070          Layout_Meta_Data::IsListStretchingEnabled() &&
       
  1071          stretchingEnabled )
       
  1072         {
       
  1073         layoutRect.LayoutRect( listSettingPaneRect,
       
  1074                         AknLayoutScalable_Avkon::set_value_pane_vc( 0 ) );        
       
  1075         }
       
  1076     else
       
  1077         {
       
  1078         layoutRect.LayoutRect( listSettingPaneRect,
       
  1079                         AknLayoutScalable_Avkon::set_value_pane( 0 ) );
       
  1080         }
       
  1081 #else
       
  1082     layoutRect.LayoutRect( listSettingPaneRect,
       
  1083                         AknLayoutScalable_Avkon::set_value_pane( 0 ) );
       
  1084 #endif
       
  1085     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1086                         AknLayoutScalable_Avkon::bg_set_opt_pane( 0 ) );
       
  1087     innerLayRect.LayoutRect( layoutRect.Rect(),
       
  1088                         AknLayoutScalable_Avkon::bg_set_opt_pane_g1() );
       
  1089 
       
  1090     // Move to 0,0
       
  1091     outerRect = layoutRect.Rect();
       
  1092     TPoint skinOffset( -outerRect.iTl.iX, -outerRect.iTl.iY );
       
  1093 
       
  1094     innerRect = innerLayRect.Rect();
       
  1095 
       
  1096     outerRect.Move( skinOffset );
       
  1097     innerRect.Move( skinOffset );
       
  1098 
       
  1099 
       
  1100     // Frame IID for qsn_fr_set_opt_foc_xxxxx
       
  1101     const TAknsItemID *frameId = &KAknsIIDQsnFrSetOptFoc;
       
  1102 
       
  1103     // Make a control context:
       
  1104     CAknsFrameBackgroundControlContext* cc =
       
  1105         CAknsFrameBackgroundControlContext::NewL(
       
  1106                 *frameId, outerRect, innerRect, EFalse );
       
  1107     CleanupStack::PushL( cc );
       
  1108 
       
  1109     TPoint dstPos( 0, 0 );
       
  1110 
       
  1111     AknsDrawUtils::DrawBackground( AknsUtils::SkinInstance(), cc, NULL,
       
  1112         *fbsBitGc, dstPos, outerRect, KAknsDrawParamDefault );
       
  1113     CleanupStack::PopAndDestroy(); // cc
       
  1114 
       
  1115     // 2. Draw the line and marker on top of the background
       
  1116     // aRect = set_value_pane
       
  1117     layoutRect.LayoutRect( aRect,
       
  1118                         AknLayoutScalable_Avkon::slider_set_pane_cp3() );
       
  1119     TRect parent = layoutRect.Rect();
       
  1120     
       
  1121 
       
  1122     //new graphic or old
       
  1123     if( iSettingGfx[CAknSlider::EElemEmptyLeftCap].iCustomizedFlag != 1 &&
       
  1124         iSettingGfx[CAknSlider::EElemEmptyRightCap].iCustomizedFlag != 1 )
       
  1125         {
       
  1126         DrawDefaultSettingsIconL( parent, aValue, fbsBitGc, 
       
  1127                                   aMinValue, aMaxValue );
       
  1128         }                               
       
  1129      else
       
  1130         {
       
  1131         DrawNewSettingsIconL(  parent, aValue, fbsBitGc, aMinValue, 
       
  1132                                aMaxValue, aFilledFlag );
       
  1133         }                            
       
  1134 
       
  1135 
       
  1136     CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  1137 
       
  1138     // Transfers ownership, so all we need to do is to..
       
  1139     aIcon->SetBitmap( bitmap );
       
  1140     CleanupStack::Pop(); // bitmap
       
  1141 
       
  1142     // 3. The mask
       
  1143     CFbsBitmap* mask = new ( ELeave ) CFbsBitmap;
       
  1144     CleanupStack::PushL( mask );
       
  1145 
       
  1146     TDisplayMode mode = iSettingGfx[CAknSlider::EElemEmptyLine].iMask->DisplayMode();
       
  1147     if ( mode == ENone )
       
  1148         {
       
  1149         mode = EGray256;
       
  1150         }
       
  1151                
       
  1152     User::LeaveIfError( mask->Create( aRect.Size(), mode ) );
       
  1153     fbsBitGc = CFbsBitGc::NewL();
       
  1154     CleanupStack::PushL( fbsBitGc );
       
  1155     bmpDevice = CFbsBitmapDevice::NewL( mask );
       
  1156     CleanupStack::PushL( bmpDevice );
       
  1157     fbsBitGc->Activate( bmpDevice );
       
  1158     fbsBitGc->SetPenStyle( CGraphicsContext::ENullPen );
       
  1159     fbsBitGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  1160     fbsBitGc->SetBrushColor( KRgbWhite );
       
  1161     fbsBitGc->DrawRect( TRect( aRect.Size() ) );
       
  1162     fbsBitGc->SetBrushStyle( CGraphicsContext::ENullBrush );
       
  1163     
       
  1164      AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *fbsBitGc,
       
  1165                               outerRect, innerRect,
       
  1166                               KAknsIIDQsnFrSetOptFoc,
       
  1167                               KAknsIIDQsnFrSetOptFocCenter,
       
  1168                               KAknsSDMAlphaOnly );   
       
  1169  
       
  1170     CleanupStack::PopAndDestroy( 2 ); // bmpDevice, fbsBitGc
       
  1171 
       
  1172     // Transfers ownership, so all we need to do is to..
       
  1173     aIcon->SetMask( mask );
       
  1174     CleanupStack::Pop(); // mask
       
  1175     
       
  1176     }
       
  1177  // ----------------------------------------------------------------------------
       
  1178 // CAknSliderIconizer::DrawDefaultSettingsIconL
       
  1179 // ----------------------------------------------------------------------------
       
  1180 //     
       
  1181 void CAknSliderIconizer::DrawDefaultSettingsIconL(
       
  1182         const TRect& aParent, TInt aValue, CFbsBitGc* aFbsBitGc,
       
  1183         const TInt aMinValue, const TInt aMaxValue ) const
       
  1184     {
       
  1185     TRect lineRect, markerRect;
       
  1186     TInt bitmapRun;
       
  1187     TAknLayoutRect layoutRect;
       
  1188       
       
  1189     layoutRect.LayoutRect( aParent,
       
  1190                     AknLayoutScalable_Avkon::slider_set_pane_g1() );
       
  1191 
       
  1192     lineRect = layoutRect.Rect(); 
       
  1193     TAknLayoutRect markerLayout;
       
  1194     markerLayout.LayoutRect( aParent,
       
  1195                         AknLayoutScalable_Avkon::slider_set_pane_g2() );
       
  1196     markerRect = markerLayout.Rect(); 
       
  1197     bitmapRun = lineRect.Width() - markerRect.Width();
       
  1198     
       
  1199     //new graphic and old graphic is in the same place
       
  1200     aFbsBitGc->BitBltMasked( TPoint( lineRect.iTl.iX, lineRect.iTl.iY ),
       
  1201                         iSettingGfx[CAknSlider::EElemEmptyLine].iRgb,
       
  1202                         TRect( 0, 0, lineRect.Width(), lineRect.Height()),
       
  1203                         iSettingGfx[CAknSlider::EElemEmptyLine].iMask,
       
  1204                         EFalse);
       
  1205      // Calculate the correct position where to draw the marker
       
  1206     
       
  1207     TInt range = aMaxValue - aMinValue;
       
  1208     // It is this expression which determines the functional direction of
       
  1209     // the slider in its drawing (but not its event handling).
       
  1210     TInt pos = ( ( bitmapRun * ( aValue - aMinValue ) ) / range );
       
  1211 
       
  1212     TPoint markerPos = TPoint( pos + markerRect.iTl.iX, markerRect.iTl.iY );
       
  1213     TRect srcRect( 0, 0, markerRect.Width(), markerRect.Height() );
       
  1214                                  
       
  1215     aFbsBitGc->BitBltMasked( markerPos, 
       
  1216                   iSettingGfx[CAknSlider::EElemMarker].iRgb, 
       
  1217                   srcRect,
       
  1218                   iSettingGfx[CAknSlider::EElemMarker].iMask,
       
  1219                   EFalse); 
       
  1220     }
       
  1221 // ----------------------------------------------------------------------------
       
  1222 // CAknSliderIconizer::DrawNewSettingsIconL
       
  1223 // ----------------------------------------------------------------------------
       
  1224 //    
       
  1225 void CAknSliderIconizer::DrawNewSettingsIconL(
       
  1226         const TRect& aParent, TInt aValue, CFbsBitGc* aFbsBitGc,
       
  1227         const TInt aMinValue, const TInt aMaxValue, TBool aFilledFlag ) const
       
  1228     {
       
  1229     TRect lineRect, markerRect, leftCapRect, rightCapRect, tickRect;
       
  1230     TInt bitmapRun;
       
  1231     TAknLayoutRect layoutRect;
       
  1232           
       
  1233     layoutRect.LayoutRect( aParent,
       
  1234             AknLayoutScalable_Avkon::slider_set_pane_g4() );
       
  1235     lineRect = layoutRect.Rect();
       
  1236     
       
  1237     layoutRect.LayoutRect( aParent,
       
  1238             AknLayoutScalable_Avkon::slider_set_pane_g3() );
       
  1239     leftCapRect = layoutRect.Rect();
       
  1240     
       
  1241     layoutRect.LayoutRect( aParent,
       
  1242             AknLayoutScalable_Avkon::slider_set_pane_g5() );
       
  1243     rightCapRect = layoutRect.Rect();
       
  1244     
       
  1245     layoutRect.LayoutRect( aParent,
       
  1246             AknLayoutScalable_Avkon::slider_set_pane_g6() );
       
  1247     markerRect = layoutRect.Rect();
       
  1248     
       
  1249     layoutRect.LayoutRect( aParent,
       
  1250             AknLayoutScalable_Avkon::slider_set_pane_g7() );
       
  1251     
       
  1252     tickRect = layoutRect.Rect();
       
  1253     bitmapRun = lineRect.Width() +
       
  1254                 leftCapRect.Width() +
       
  1255                 rightCapRect.Width() - 
       
  1256                 markerRect.Width();
       
  1257                 
       
  1258          //new graphic and old graphic is in the same place
       
  1259     aFbsBitGc->BitBltMasked( TPoint( lineRect.iTl.iX, lineRect.iTl.iY ),
       
  1260                             iSettingGfx[CAknSlider::EElemEmptyLine].iRgb,
       
  1261                             TRect( 0, 0, lineRect.Width(), lineRect.Height()),
       
  1262                             iSettingGfx[CAknSlider::EElemEmptyLine].iMask,
       
  1263                             EFalse);
       
  1264      //leftcap, rightcap,filled line,tick                                      
       
  1265     aFbsBitGc->BitBltMasked( TPoint( leftCapRect.iTl.iX, leftCapRect.iTl.iY ),
       
  1266                             iSettingGfx[CAknSlider::EElemEmptyLeftCap].iRgb,
       
  1267                             TRect(0, 0, leftCapRect.Width(), leftCapRect.Height()),
       
  1268                             iSettingGfx[CAknSlider::EElemEmptyLeftCap].iMask,
       
  1269                             EFalse);
       
  1270     aFbsBitGc->BitBltMasked( TPoint( rightCapRect.iTl.iX, rightCapRect.iTl.iY ),
       
  1271                             iSettingGfx[CAknSlider::EElemEmptyRightCap].iRgb,
       
  1272                             TRect( 0, 0, rightCapRect.Width(), rightCapRect.Height()),
       
  1273                             iSettingGfx[CAknSlider::EElemEmptyRightCap].iMask,
       
  1274                             EFalse );
       
  1275     // Calculate the correct position where to draw the marker
       
  1276     
       
  1277     TInt range = aMaxValue - aMinValue;
       
  1278     // It is this expression which determines the functional direction of
       
  1279     // the slider in its drawing (but not its event handling).
       
  1280     TInt pos = ( ( bitmapRun * ( aValue - aMinValue ) ) / range );
       
  1281 
       
  1282     TPoint markerPos = TPoint( pos + markerRect.iTl.iX, markerRect.iTl.iY );
       
  1283                               
       
  1284     //filled enable, draw filled line
       
  1285     if( aFilledFlag )
       
  1286         {
       
  1287         // filled line and cap
       
  1288         TInt fillWidth = markerPos.iX + markerRect.Width()/2 - lineRect.iTl.iX;
       
  1289         aFbsBitGc->BitBltMasked( TPoint( lineRect.iTl.iX, lineRect.iTl.iY ),
       
  1290                         iSettingGfx[CAknSlider::EElemFilledLine].iRgb,
       
  1291                         TRect(0, 0, fillWidth, lineRect.Height()),
       
  1292                         iSettingGfx[CAknSlider::EElemFilledLine].iMask,
       
  1293                         EFalse);
       
  1294         //left cap always filled
       
  1295         if( aValue != aMinValue )
       
  1296             {
       
  1297             aFbsBitGc->BitBltMasked( TPoint( lineRect.iTl.iX, lineRect.iTl.iY ),
       
  1298                         iSettingGfx[CAknSlider::EElemFilledLeftCap].iRgb,
       
  1299                         TRect(0, 0, leftCapRect.Width(), leftCapRect.Height()),
       
  1300                         iSettingGfx[CAknSlider::EElemFilledLine].iMask,
       
  1301                         EFalse);               
       
  1302             }
       
  1303 
       
  1304         //only when the line filled, the right cap filled                
       
  1305         if( aValue >= aMaxValue )
       
  1306             {
       
  1307             aFbsBitGc->BitBltMasked( TPoint( lineRect.iTl.iX, lineRect.iTl.iY ),
       
  1308                         iSettingGfx[CAknSlider::EElemFilledRightCap].iRgb,
       
  1309                         TRect( 0, 0, rightCapRect.Width(), rightCapRect.Height()),
       
  1310                         iSettingGfx[CAknSlider::EElemFilledLine].iMask,
       
  1311                         EFalse);                
       
  1312             }
       
  1313 
       
  1314         }
       
  1315     else
       
  1316         {
       
  1317          TRect srcRect( 0, 0, markerRect.Width(), markerRect.Height() );
       
  1318         
       
  1319         aFbsBitGc->BitBltMasked( markerPos, 
       
  1320                           iSettingGfx[CAknSlider::EElemMarker].iRgb, 
       
  1321                           srcRect,
       
  1322                           iSettingGfx[CAknSlider::EElemMarker].iMask,
       
  1323                           EFalse);        
       
  1324         }
       
  1325                       
       
  1326                     
       
  1327     }
       
  1328 // ============================================================================
       
  1329 
       
  1330 // ----------------------------------------------------------------------------
       
  1331 // Default constructor
       
  1332 // ----------------------------------------------------------------------------
       
  1333 //
       
  1334 EXPORT_C CAknSlider::CAknSlider()
       
  1335     {
       
  1336     // Derived from CBase -> members zeroed
       
  1337     AKNTASHOOK_ADD( this, "CAknSlider" );
       
  1338     }
       
  1339 
       
  1340 
       
  1341 // ----------------------------------------------------------------------------
       
  1342 // Destructor
       
  1343 // ----------------------------------------------------------------------------
       
  1344 //
       
  1345 EXPORT_C CAknSlider::~CAknSlider()
       
  1346     {
       
  1347     AKNTASHOOK_REMOVE();
       
  1348     AknsUtils::DeregisterControlPosition( this );
       
  1349     delete iValueLabel;
       
  1350     delete iMinLabel;
       
  1351     delete iMaxLabel;
       
  1352     delete iMarkerBmp;
       
  1353     delete iMarkerMaskBmp;
       
  1354     delete iImage;
       
  1355     delete iData;
       
  1356     delete iExt;
       
  1357     }
       
  1358 
       
  1359 
       
  1360 // ----------------------------------------------------------------------------
       
  1361 // CAknSlider::ConstructL
       
  1362 // Creates the labels.
       
  1363 // ----------------------------------------------------------------------------
       
  1364 //
       
  1365 void CAknSlider::ConstructL()
       
  1366     {
       
  1367     iExt = CAknSliderExtension::NewL();
       
  1368 
       
  1369     InitializeBitmapsL();
       
  1370     
       
  1371 
       
  1372     iValueLabel = new( ELeave ) CEikLabel;
       
  1373     iValueLabel->UseLogicalToVisualConversion( EFalse );
       
  1374     iValueLabel->SetContainerWindowL( *this );
       
  1375 
       
  1376     iMinLabel = new( ELeave ) CEikLabel;
       
  1377     iMinLabel->SetContainerWindowL( *this );
       
  1378 
       
  1379     iMaxLabel = new( ELeave ) CEikLabel;
       
  1380     iMaxLabel->SetContainerWindowL( *this );
       
  1381 
       
  1382     if ( AknLayoutUtils::PenEnabled() && ( &Window() != NULL ) )
       
  1383         {
       
  1384         // Enable drag events, it will then be possible to drag from thumb
       
  1385         EnableDragEvents();
       
  1386         //Enable dragging to start from thumb and then move outside the slider
       
  1387         DrawableWindow()->SetPointerGrab( ETrue );
       
  1388         }        
       
  1389     }
       
  1390     
       
  1391 
       
  1392 // ----------------------------------------------------------------------------
       
  1393 // CAknSlider::InitializeBitmapsL
       
  1394 // ----------------------------------------------------------------------------
       
  1395 //
       
  1396 void CAknSlider::InitializeBitmapsL()
       
  1397     {
       
  1398     
       
  1399     if ( iExt->iLineIcon )
       
  1400         {
       
  1401         delete iExt->iLineIcon;
       
  1402         iExt->iLineIcon = NULL;
       
  1403         delete iExt->iLineIconMask;
       
  1404         iExt->iLineIconMask = NULL;
       
  1405         }
       
  1406     iExt->DeleteBitmaps(); 
       
  1407            
       
  1408     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1409     
       
  1410    if( Layout() == EAknSliderLayoutVertical ) //vertical
       
  1411         {
       
  1412         //1.load default graphic for new vertical slider
       
  1413         iExt->ClearFlag( CAknSliderExtension::EFlagHorizontal );
       
  1414         iExt->TryLoadNSliderVerticalBitmap( skin );
       
  1415 
       
  1416         }
       
  1417         
       
  1418    else if ( Layout() == EAknSliderLayoutHorizontal )
       
  1419             {
       
  1420             iExt->TryLoadNSliderBitmap( ETrue, skin  ); 
       
  1421             }
       
  1422   
       
  1423    else // horizonal
       
  1424         {
       
  1425         //1.load new from skin
       
  1426         iExt->TryLoadNSliderBitmap( ETrue, skin  );  
       
  1427         if( iExt->UsesDefaultGraphics() )
       
  1428             {
       
  1429             //2.load old from skin
       
  1430             TRAPD( err,
       
  1431                 {
       
  1432                 AknsUtils::CreateIconL( skin, 
       
  1433                                         KAknsIIDQgnGrafLinePrimaryHorizontal,
       
  1434                                         iExt->iLineIcon, 
       
  1435                                         iExt->iLineIconMask,
       
  1436                                         KNullDesC,
       
  1437                                         EMbmAvkonQgn_graf_line_primary_horizontal,
       
  1438                                         EMbmAvkonQgn_graf_line_primary_horizontal_mask);
       
  1439                 AknsUtils::CreateIconL( skin, 
       
  1440                                         KAknsIIDQgnIndiSliderEdit,
       
  1441                                         iMarkerBmp, 
       
  1442                                         iMarkerMaskBmp,
       
  1443                                         KNullDesC,
       
  1444                                         EMbmAvkonQgn_indi_slider_edit,
       
  1445                                         EMbmAvkonQgn_indi_slider_edit_mask);
       
  1446                                         
       
  1447                 } );                                  
       
  1448             //3.load new from mif, must success.
       
  1449             if( err )
       
  1450                 {
       
  1451                 
       
  1452                 iExt->TryLoadNSliderBitmap( EFalse, skin );
       
  1453                 }
       
  1454             }
       
  1455 
       
  1456          }
       
  1457     
       
  1458     }
       
  1459 
       
  1460 
       
  1461 // ----------------------------------------------------------------------------
       
  1462 // CAknSlider::SetValueL
       
  1463 // ----------------------------------------------------------------------------
       
  1464 //
       
  1465 EXPORT_C void CAknSlider::SetValueL( TInt aValue )
       
  1466     {
       
  1467     // Note that this assert will panic any value that is not aligned on the
       
  1468     // step size relative to the minimum value;
       
  1469     __ASSERT_DEBUG( aValue >= MinimumValue() &&
       
  1470                     aValue<= MaximumValue() &&
       
  1471                     ( aValue-MinimumValue() ) % StepSize() == 0,
       
  1472                     Panic( EAknPanicOutOfRange ) );
       
  1473     iValue = aValue;
       
  1474     if ( iValueLabel != NULL )
       
  1475         {
       
  1476         SetValueTextL();
       
  1477         }
       
  1478     }
       
  1479 
       
  1480 
       
  1481 // ----------------------------------------------------------------------------
       
  1482 // CAknSlider::Value
       
  1483 // ----------------------------------------------------------------------------
       
  1484 //
       
  1485 EXPORT_C TInt CAknSlider::Value() const
       
  1486     {
       
  1487     return iValue;
       
  1488     }
       
  1489 
       
  1490 
       
  1491 // ----------------------------------------------------------------------------
       
  1492 // CAknSlider::CreateBitmapL
       
  1493 // Returns slider bitmap to "list pane for setting item" (setting option item
       
  1494 // slider graphic). Ownership of the bitmap is transferred to the caller.
       
  1495 // ----------------------------------------------------------------------------
       
  1496 //
       
  1497 EXPORT_C CFbsBitmap* CAknSlider::CreateBitmapL( TInt aValue, TInt aResourceId )
       
  1498     {
       
  1499     TResourceReader reader;
       
  1500     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
       
  1501 
       
  1502     reader.ReadInt16(); // ignore layout
       
  1503     TInt minValue = reader.ReadInt16();
       
  1504     TInt maxValue = reader.ReadInt16();
       
  1505     CleanupStack::PopAndDestroy(); // reader
       
  1506 
       
  1507     return CreateBitmapL( aValue, minValue, maxValue );
       
  1508     }
       
  1509 
       
  1510 
       
  1511 // ----------------------------------------------------------------------------
       
  1512 // CAknSlider::CreateBitmapL
       
  1513 // Returns slider bitmap to "list pane for setting item" (setting option item
       
  1514 // slider graphic). Ownership of the bitmap is transferred to the caller.
       
  1515 // ----------------------------------------------------------------------------
       
  1516 //
       
  1517 EXPORT_C CFbsBitmap* CAknSlider::CreateBitmapL(
       
  1518         TInt aValue, TInt aMinimumValue, TInt aMaximumValue )
       
  1519     {
       
  1520     CGulIcon* icon = CreateSetStyleListBoxIconL(
       
  1521             aValue, aMinimumValue, aMaximumValue ); // now have ownership
       
  1522     icon->SetBitmapsOwnedExternally( ETrue );
       
  1523     CFbsBitmap* bitmap = icon->Bitmap();
       
  1524     CFbsBitmap* mask = icon->Mask();
       
  1525     delete icon;
       
  1526     delete mask;
       
  1527     return bitmap; // ownership transferred
       
  1528     }
       
  1529 
       
  1530 
       
  1531 // ----------------------------------------------------------------------------
       
  1532 // CAknSlider::CreateSetStyleListBoxIconL
       
  1533 // Returns slider icon to "list pane for setting item" (setting option item
       
  1534 // slider graphic). Ownership of the icon is transferred to the caller.
       
  1535 // ----------------------------------------------------------------------------
       
  1536 //
       
  1537 EXPORT_C CGulIcon* CAknSlider::CreateSetStyleListBoxIconL(
       
  1538         TInt aValue, TInt aResourceId )
       
  1539     {
       
  1540     TResourceReader reader;
       
  1541     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
       
  1542 
       
  1543     reader.ReadInt16(); // ignore layout
       
  1544     TInt minValue = reader.ReadInt16();
       
  1545     TInt maxValue = reader.ReadInt16();
       
  1546     CleanupStack::PopAndDestroy(); // reader
       
  1547     
       
  1548     return CreateSetStyleListBoxIconL( aValue, minValue, maxValue );
       
  1549     }
       
  1550 
       
  1551 
       
  1552 // ----------------------------------------------------------------------------
       
  1553 // CAknSlider::CreateSetStyleListBoxIconL
       
  1554 // Returns slider icon to "list pane for setting item" (setting option item
       
  1555 // slider graphic). Ownership of the icon is transferred to the caller.
       
  1556 // ----------------------------------------------------------------------------
       
  1557 //
       
  1558 EXPORT_C CGulIcon* CAknSlider::CreateSetStyleListBoxIconL(
       
  1559         TInt aValue, TInt aMinimumValue, TInt aMaximumValue )
       
  1560     {
       
  1561     __ASSERT_ALWAYS( aMaximumValue > aMinimumValue,
       
  1562                      Panic( EAknPanicOutOfRange ) );
       
  1563     __ASSERT_ALWAYS( ( aValue <= aMaximumValue ) &&
       
  1564                      ( aValue >= aMinimumValue ),
       
  1565                      Panic( EAknPanicOutOfRange ) );
       
  1566 
       
  1567     // Make the icon and put it in the array
       
  1568     CGulIcon* icon = CGulIcon::NewLC();
       
  1569 
       
  1570     TRect origin;
       
  1571     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, origin );
       
  1572 
       
  1573     TAknLayoutRect layoutRect;
       
  1574     layoutRect.LayoutRect( origin,
       
  1575                         AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ) );
       
  1576     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1577                         AknLayoutScalable_Avkon::list_gen_pane( 0 ) );
       
  1578     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1579                         AknLayoutScalable_Avkon::list_setting_number_pane( 0 ) );
       
  1580     TRect listSettingPaneRect( layoutRect.Rect());
       
  1581 #ifdef RD_LIST_STRETCH
       
  1582     // check list stretching from cenrep
       
  1583     TBool stretchingEnabled;
       
  1584     CRepository* cenRep = CRepository::NewL( KCRUidAvkon );
       
  1585     cenRep->Get( KAknAutomaticListStretching, stretchingEnabled );
       
  1586     delete cenRep;
       
  1587 
       
  1588     if ( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1589          Layout_Meta_Data::IsListStretchingEnabled() &&
       
  1590          stretchingEnabled )
       
  1591         {
       
  1592         layoutRect.LayoutRect( layoutRect.Rect(),
       
  1593                         AknLayoutScalable_Avkon::set_value_pane_vc( 0 ) );
       
  1594         }
       
  1595     else
       
  1596         {
       
  1597         layoutRect.LayoutRect( layoutRect.Rect(),
       
  1598                         AknLayoutScalable_Avkon::set_value_pane( 0 ) );
       
  1599         }
       
  1600 #else
       
  1601     layoutRect.LayoutRect( layoutRect.Rect(),
       
  1602                         AknLayoutScalable_Avkon::set_value_pane( 0 ) );
       
  1603 #endif    
       
  1604     TRect setValuePaneRect( layoutRect.Rect() );
       
  1605     TRect rect( setValuePaneRect );
       
  1606 
       
  1607     // Move to 0,0
       
  1608     rect.Move( -rect.iTl.iX, -rect.iTl.iY );
       
  1609     CAknSliderIconizer::CreateSettingsIconL( rect, aValue, icon,
       
  1610                                               aMinimumValue, aMaximumValue );
       
  1611     CleanupStack::Pop( icon ); // icon - not owned anymore, do not destroy
       
  1612     return icon; // ownership transferred
       
  1613     }
       
  1614 
       
  1615 
       
  1616 // ----------------------------------------------------------------------------
       
  1617 // CAknSlider::SetRange
       
  1618 // ----------------------------------------------------------------------------
       
  1619 //
       
  1620 EXPORT_C void CAknSlider::SetRange( TInt aMinimumValue, TInt aMaximumValue )
       
  1621     {
       
  1622     SliderData()->SetRange( aMinimumValue, aMaximumValue );
       
  1623     }
       
  1624 
       
  1625 // ----------------------------------------------------------------------------
       
  1626 // CAknSlider::GetRange
       
  1627 // ----------------------------------------------------------------------------
       
  1628 //
       
  1629 EXPORT_C void CAknSlider::GetRange( TInt& aMinimumValue, TInt& aMaximumValue )
       
  1630     {
       
  1631     aMaximumValue = MaximumValue();
       
  1632     aMinimumValue = MinimumValue();
       
  1633     }
       
  1634 
       
  1635 // ----------------------------------------------------------------------------
       
  1636 // CAknSlider::SetStepSize
       
  1637 // ----------------------------------------------------------------------------
       
  1638 //
       
  1639 EXPORT_C void CAknSlider::SetStepSize( TInt aStepSize )
       
  1640     {
       
  1641     // This assert is only done for CAknSlider, as the step size is not
       
  1642     // particularly relevant for the data; That is, if you are just interested
       
  1643     // in CAknSliderData in order to format a value label, then you might want
       
  1644     // to ignore the restrictions on stepsize
       
  1645     __ASSERT_ALWAYS( aStepSize != 0 && SliderData()->Range() % aStepSize == 0,
       
  1646                      Panic( EAknPanicOutOfRange ) );
       
  1647     SliderData()->iStepSize = aStepSize;
       
  1648     }
       
  1649 
       
  1650 
       
  1651 // ----------------------------------------------------------------------------
       
  1652 // CAknSlider::SetValueTextL 
       
  1653 // Sets the text for the value label.
       
  1654 // ----------------------------------------------------------------------------
       
  1655 //
       
  1656 EXPORT_C void CAknSlider::SetValueTextL()
       
  1657     {
       
  1658     TBuf<KValueLabelTextMaxLength + KAknBidiExtraSpacePerLine> textBuf;
       
  1659     DoSetValueTextL( textBuf, iValue, *SliderData() );
       
  1660     AknBidiTextUtils::ConvertToVisualAndClipL( textBuf,
       
  1661                                                *( iValueLabel->Font() ),
       
  1662                                                iValueLabel->Size().iWidth,
       
  1663                                                iValueLabel->Size().iWidth );
       
  1664     iValueLabel->SetTextL( textBuf );
       
  1665     }
       
  1666     
       
  1667 
       
  1668 // ----------------------------------------------------------------------------
       
  1669 // CAknSlider::DoSetValueTextL
       
  1670 // ----------------------------------------------------------------------------
       
  1671 //
       
  1672 void CAknSlider::DoSetValueTextL( TDes& aTextBuf, TInt aValue,
       
  1673                                   const CAknSliderData& aSliderData )
       
  1674     {
       
  1675     TBuf<KAknSliderValueLabelValueMaxLength> valueBuf;
       
  1676     _LIT( KBareFigure, "%d" );
       
  1677     _LIT( KFraction, "%d/%d" );
       
  1678 
       
  1679     switch ( aSliderData.iValueType )
       
  1680         {
       
  1681         case EAknSliderValueBareFigure:
       
  1682             valueBuf.Format( KBareFigure, aValue ); // bare figure
       
  1683             break;
       
  1684 
       
  1685         case EAknSliderValuePercentage:
       
  1686             {
       
  1687             TInt num = ( 100 * ( aValue - aSliderData.iMinimumValue ) ) / 
       
  1688                          aSliderData.Range();                                
       
  1689             HBufC* percentage = StringLoader::LoadLC( R_QTN_SELECT_SLIDER_VALUE,num ); 
       
  1690             valueBuf.Copy( *percentage );
       
  1691             CleanupStack::PopAndDestroy( percentage );              
       
  1692             }            
       
  1693             break;
       
  1694 
       
  1695         case EAknSliderValueFraction:
       
  1696             valueBuf.Format( KFraction, aValue, aSliderData.iMaximumValue ); // x/y
       
  1697             break;
       
  1698 
       
  1699         case EAknSliderValueDecimal:
       
  1700             {
       
  1701             TReal r;
       
  1702             Math::Pow10( r, aSliderData.DecimalPlaces() );
       
  1703             // First have to format the format.
       
  1704             TBuf<8> format;
       
  1705             // This allows for 2 digit field size and/or decimal places
       
  1706             _LIT( KFormatTemplate, "%%-%d.%df" );
       
  1707             format.Format( KFormatTemplate,
       
  1708                            KAknSliderValueLabelValueMaxLength,
       
  1709                            aSliderData.DecimalPlaces() );
       
  1710             valueBuf.Format( format, aValue / r );
       
  1711             valueBuf.TrimAll();
       
  1712             }
       
  1713             break;
       
  1714         default:
       
  1715             break; // valueBuf left empty
       
  1716         } // end switch
       
  1717 
       
  1718     // Convert this formatted number if necessary to display language-sensitive
       
  1719     // numerals
       
  1720     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( valueBuf );
       
  1721 
       
  1722     // A text pointer for the format string
       
  1723     TPtr formatPtr( 0, 0 );
       
  1724 
       
  1725     if ( aSliderData.iText != NULL )
       
  1726         {
       
  1727         formatPtr.Set( aSliderData.iText->Des() );
       
  1728         }
       
  1729 
       
  1730     if ( aSliderData.iSingularText != NULL )
       
  1731         {
       
  1732         // format with %U in the supplied text. But only if value = 1 and we
       
  1733         // are using bare figure layout
       
  1734         if ( ( aValue == 1 ) &&
       
  1735              ( aSliderData.iValueType == EAknSliderValueBareFigure ) )
       
  1736             {
       
  1737             formatPtr.Set( aSliderData.iSingularText->Des() );
       
  1738             }
       
  1739         }
       
  1740 
       
  1741     if ( formatPtr.Length() > 0 )
       
  1742         {
       
  1743         FormatWithOrWithoutTokenL( aTextBuf, formatPtr, valueBuf );
       
  1744         }
       
  1745     else
       
  1746         {
       
  1747         aTextBuf.Copy( valueBuf.Left( KAknSliderValueLabelValueMaxLength ) );
       
  1748         }
       
  1749     }
       
  1750 
       
  1751 
       
  1752 // ----------------------------------------------------------------------------
       
  1753 // CAknSlider::FormatWithOrWithoutTokenL
       
  1754 //
       
  1755 // This method is used to protect the call to StringLoader::Format against
       
  1756 // passing it texts with no token. If you do, it panics.
       
  1757 //
       
  1758 // The protection here is still far from perfect, as only % is looked for. So
       
  1759 // there is still a problem.
       
  1760 //
       
  1761 // StringLoader itself should take on this responsibility and not panic. In
       
  1762 // this case, the call to this routine would just be the code in the 2nd half.
       
  1763 // ----------------------------------------------------------------------------
       
  1764 //
       
  1765 void CAknSlider::FormatWithOrWithoutTokenL(
       
  1766         TDes& aOutput, const TDesC& aFormat, const TDesC& aValue )
       
  1767     {
       
  1768     if ( aFormat.Locate('%') == -1 )
       
  1769         {
       
  1770         aOutput.Copy( aFormat.Left( KValueLabelTextMaxLength ) );
       
  1771         }
       
  1772     else
       
  1773         {
       
  1774         // We can know that the length of the resulting formatted string will
       
  1775         // be less than or equal to the sum of the two lengths Wierd effects in
       
  1776         // string loader mean we have to add 2 more (It adds key length instead
       
  1777         // of subtracting it sometimes)....
       
  1778         TInt safeLength = aValue.Length() + aFormat.Length() +
       
  1779                           KAknSliderFormatKeyLength;
       
  1780 
       
  1781         // No leaving methods are going to be called
       
  1782         HBufC* wholeTextBuf = HBufC::NewL( safeLength );
       
  1783         TPtr wholeTextPtr = wholeTextBuf->Des();
       
  1784 
       
  1785         // Value for when no %U or when there is no number (%NU)
       
  1786         TInt keyIndex = -1;
       
  1787         StringLoader::Format( wholeTextPtr, aFormat, keyIndex, aValue );
       
  1788         aOutput.Copy( wholeTextPtr.Left( KValueLabelTextMaxLength ) );
       
  1789 
       
  1790         delete wholeTextBuf;
       
  1791         }
       
  1792     }
       
  1793 
       
  1794 
       
  1795 // ----------------------------------------------------------------------------
       
  1796 // DoSetLabelTextL
       
  1797 // Local function to gather together arabization of minimum/maximum strings.
       
  1798 // Static to make the function local to this compilation unit only (i.e. not
       
  1799 // polluting the global namespace).
       
  1800 // ----------------------------------------------------------------------------
       
  1801 static void DoSetLabelTextL( const TDesC& aText, CEikLabel* aLabel )
       
  1802     {
       
  1803     if ( aLabel )
       
  1804         {
       
  1805         HBufC* localBuf = aText.AllocLC();
       
  1806         TPtr ptr = localBuf->Des();
       
  1807         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
  1808         aLabel->SetTextL( ptr ); // Makes copy of buffer
       
  1809         CleanupStack::PopAndDestroy( localBuf );
       
  1810         }
       
  1811     }
       
  1812 
       
  1813 
       
  1814 // ----------------------------------------------------------------------------
       
  1815 // CAknSlider::SetMinimumTextL
       
  1816 // Sets the text for the minimum label.
       
  1817 // ----------------------------------------------------------------------------
       
  1818 //
       
  1819 EXPORT_C void CAknSlider::SetMinimumTextL( const TDesC& aText )
       
  1820     {
       
  1821     DoSetLabelTextL( aText, iMinLabel );
       
  1822     }
       
  1823 
       
  1824 
       
  1825 // ----------------------------------------------------------------------------
       
  1826 // CAknSlider::SetMaximumTextL
       
  1827 // Sets the text for the maximum label.
       
  1828 // ----------------------------------------------------------------------------
       
  1829 //
       
  1830 EXPORT_C void CAknSlider::SetMaximumTextL( const TDesC& aText )
       
  1831     {
       
  1832     DoSetLabelTextL( aText, iMaxLabel );
       
  1833     }
       
  1834 
       
  1835 
       
  1836 // ----------------------------------------------------------------------------
       
  1837 // CAknSlider::MinimumSize
       
  1838 // ----------------------------------------------------------------------------
       
  1839 //
       
  1840 TSize CAknSlider::MinimumSize()
       
  1841     {
       
  1842     TInt index = 0;
       
  1843 
       
  1844     if ( iEditable )
       
  1845         {
       
  1846         if ( Layout() == EAknFormSliderLayout3 )
       
  1847             {
       
  1848             index = 0;
       
  1849             }
       
  1850         else if ( Layout() == EAknFormSliderLayout2 )
       
  1851             {
       
  1852             index = 1;
       
  1853             }
       
  1854         else if ( Layout() == EAknFormSliderLayout1 )
       
  1855             {
       
  1856             index = 2;
       
  1857             } 
       
  1858         }
       
  1859 
       
  1860     TAknLayoutRect temp, layout;
       
  1861     temp.LayoutRect( TRect( 0, 0, 0, 0 ),
       
  1862                              AknLayoutScalable_Avkon::Screen() );
       
  1863                              
       
  1864     layout.LayoutRect( temp.Rect(),
       
  1865                        AknLayoutScalable_Avkon::listscroll_form_pane() );
       
  1866     temp.LayoutRect( layout.Rect(),
       
  1867                      AknLayoutScalable_Avkon::list_form_gen_pane() );
       
  1868     layout.LayoutRect( temp.Rect(),
       
  1869                        AknLayoutScalable_Avkon::form_field_slider_pane( index ) );
       
  1870 
       
  1871     return layout.Rect().Size();
       
  1872     }
       
  1873 
       
  1874 
       
  1875 // ----------------------------------------------------------------------------
       
  1876 // CAknSlider::OfferKeyEventL
       
  1877 // Handles the key events.
       
  1878 // ----------------------------------------------------------------------------
       
  1879 //
       
  1880 TKeyResponse CAknSlider::OfferKeyEventL(
       
  1881         const TKeyEvent& aKeyEvent, TEventCode aType )
       
  1882     {
       
  1883     // If not a key event or in view mode
       
  1884     if ( aType != EEventKey || !iEditable )
       
  1885         {
       
  1886         return EKeyWasNotConsumed;
       
  1887         }
       
  1888 
       
  1889     TInt step = StepSize();
       
  1890     TBool hor = iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal );
       
  1891     iExt->iPenInputPos = TPoint( -1, -1 );
       
  1892 
       
  1893     if ( EKeyLeftArrow == aKeyEvent.iCode && hor )
       
  1894         {
       
  1895         TranslateValueL( -step );
       
  1896         }
       
  1897     else if ( EKeyRightArrow == aKeyEvent.iCode && hor )
       
  1898         {
       
  1899         TranslateValueL( step );
       
  1900         }
       
  1901     else if ( EKeyDownArrow == aKeyEvent.iCode && !hor )
       
  1902         {
       
  1903         TranslateValueL( -step );
       
  1904         }
       
  1905     else if ( EKeyUpArrow == aKeyEvent.iCode && !hor )
       
  1906         {
       
  1907         TranslateValueL( step );
       
  1908         }
       
  1909     else
       
  1910         {
       
  1911         return EKeyWasNotConsumed;
       
  1912         }
       
  1913 
       
  1914     return EKeyWasConsumed;
       
  1915     }
       
  1916 
       
  1917 
       
  1918 // ----------------------------------------------------------------------------
       
  1919 // CAknSlider::ConstructFromResourceL
       
  1920 // ----------------------------------------------------------------------------
       
  1921 //
       
  1922 EXPORT_C void CAknSlider::ConstructFromResourceL( TResourceReader& aReader )
       
  1923     {
       
  1924     iData = CAknSliderData::NewL( aReader );
       
  1925     ConstructL();
       
  1926 
       
  1927     // Apply constraints on the read stepsize here
       
  1928     SetStepSize( StepSize() );
       
  1929 
       
  1930     // Set the labels up
       
  1931     if ( SliderData()->iMinimumLabelText )
       
  1932         {
       
  1933         SetMinimumTextL( *( SliderData()->iMinimumLabelText ) );
       
  1934         }
       
  1935 
       
  1936     if ( SliderData()->iMaximumLabelText )
       
  1937         {
       
  1938         SetMaximumTextL( *( SliderData()->iMaximumLabelText ) );
       
  1939         }
       
  1940 
       
  1941     // Create graphics if needed
       
  1942     if ( Layout() == EAknSettingsItemSliderLayoutWithGraphics )
       
  1943         {
       
  1944         CreateDecoratorImageFromResourceL( SliderData()->iDecoratorImageId );
       
  1945         }
       
  1946 
       
  1947     TAknLayoutRect layoutRect;
       
  1948     TRect containerRect;
       
  1949     if( Layout() == EAknSliderLayoutVertical )
       
  1950         {
       
  1951         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  1952                                        containerRect );
       
  1953 
       
  1954         layoutRect.LayoutRect(containerRect,AknLayoutScalable_Avkon::main_pane(13) );
       
  1955         containerRect = layoutRect.Rect();
       
  1956         
       
  1957         layoutRect.LayoutRect( containerRect,
       
  1958             AknLayoutScalable_Avkon::popup_slider_window(0) );
       
  1959         containerRect = layoutRect.Rect();   
       
  1960          
       
  1961         SetRect( containerRect );
       
  1962         }
       
  1963     else if( Layout() == EAknSliderLayoutHorizontal )
       
  1964         {
       
  1965         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  1966                                        containerRect );
       
  1967 
       
  1968         layoutRect.LayoutRect(containerRect,AknLayoutScalable_Apps::main_pane(0) );
       
  1969         containerRect = layoutRect.Rect();
       
  1970         
       
  1971         layoutRect.LayoutRect( containerRect,
       
  1972             AknLayoutScalable_Apps::main_video_tele_pane(0) );
       
  1973         containerRect = layoutRect.Rect();
       
  1974         
       
  1975         layoutRect.LayoutRect( containerRect,
       
  1976             AknLayoutScalable_Apps::popup_vtel_slider_window(0) );
       
  1977         containerRect = layoutRect.Rect();
       
  1978 
       
  1979         SetRect( containerRect );
       
  1980         }
       
  1981     else
       
  1982         {
       
  1983         SetRect( MinimumSize() );
       
  1984         }
       
  1985    
       
  1986     
       
  1987     SetValueTextL();
       
  1988     }
       
  1989 
       
  1990 
       
  1991 // ----------------------------------------------------------------------------
       
  1992 // CAknSlider::ConstructFromResourceL
       
  1993 // ----------------------------------------------------------------------------
       
  1994 //
       
  1995 EXPORT_C void CAknSlider::ConstructFromResourceL(
       
  1996         CCoeControl* aParent, TInt aValue, TResourceReader& aReader )
       
  1997     {
       
  1998     SetContainerWindowL( *aParent );
       
  1999     ConstructFromResourceL( aReader ); // Call basic ConstructFromResourceL()
       
  2000     SetValueL( aValue );
       
  2001     ActivateL();
       
  2002     //DrawNow();
       
  2003     }
       
  2004 
       
  2005 
       
  2006 // ----------------------------------------------------------------------------
       
  2007 // CAknSlider::HandleResourceChange
       
  2008 // ----------------------------------------------------------------------------
       
  2009 //
       
  2010 EXPORT_C void CAknSlider::HandleResourceChange( TInt aType )
       
  2011     {
       
  2012     CCoeControl::HandleResourceChange( aType );
       
  2013     
       
  2014     switch ( aType )
       
  2015         {
       
  2016         case KEikMessageCaptionedControlEditableStateChange:
       
  2017             {
       
  2018             iEditable = ETrue;
       
  2019             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  2020             if ( feedback )
       
  2021                 {
       
  2022                 feedback->EnableFeedbackForControl( this, ETrue );
       
  2023                 }
       
  2024             }            
       
  2025             break;
       
  2026         case KEikMessageCaptionedControlNotEditableStateChange:
       
  2027             {
       
  2028             iEditable = EFalse;
       
  2029             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  2030             if ( feedback )
       
  2031                 {
       
  2032                 feedback->EnableFeedbackForControl( this, EFalse );
       
  2033                 }       
       
  2034             }            
       
  2035             break;
       
  2036 
       
  2037         case KAknsMessageSkinChange:
       
  2038             {
       
  2039             SetLabelColor();
       
  2040             }
       
  2041             break;
       
  2042         default:
       
  2043             break;
       
  2044         }
       
  2045     }
       
  2046 
       
  2047 
       
  2048 // ----------------------------------------------------------------------------
       
  2049 // CAknSlider::CountComponentControls
       
  2050 // Standard CCoeControl routine to return the number of component controls.
       
  2051 // ----------------------------------------------------------------------------
       
  2052 //
       
  2053 EXPORT_C TInt CAknSlider::CountComponentControls() const
       
  2054     {
       
  2055     TInt count = 0;
       
  2056     CCoeControl* controls[] = { iValueLabel, iMaxLabel, iMinLabel, iImage };
       
  2057     for ( TUint ii = 0; ii < sizeof( controls ) / sizeof( CCoeControl* ); ++ii )
       
  2058         {
       
  2059         if ( controls[ii] )
       
  2060             {
       
  2061             count++;
       
  2062             }
       
  2063         }
       
  2064     return count;
       
  2065     }
       
  2066 
       
  2067 
       
  2068 // ----------------------------------------------------------------------------
       
  2069 // CAknSlider::ComponentControl
       
  2070 // Standard CCoeControl routine to return the control at a given index
       
  2071 // ----------------------------------------------------------------------------
       
  2072 //
       
  2073 EXPORT_C CCoeControl* CAknSlider::ComponentControl( TInt aIndex ) const
       
  2074     {
       
  2075     CCoeControl* controls[] = { iValueLabel, iMaxLabel, iMinLabel, iImage };
       
  2076     for ( TUint ii = 0; ii < sizeof( controls ) / sizeof( CCoeControl* ); ++ii )
       
  2077         {
       
  2078         if ( controls[ii] && aIndex-- == 0 )
       
  2079             {
       
  2080             return controls[ii];
       
  2081             }
       
  2082         }
       
  2083     return NULL;
       
  2084     }
       
  2085 
       
  2086 
       
  2087 // ----------------------------------------------------------------------------
       
  2088 // CAknSlider::SizeChanged
       
  2089 // Sets the layout.
       
  2090 // ----------------------------------------------------------------------------
       
  2091 //
       
  2092 void CAknSlider::SizeChanged()
       
  2093     {
       
  2094     switch ( Layout() )
       
  2095         {
       
  2096         case EAknFormSliderLayout1:
       
  2097             {
       
  2098             FormSliderLayout1();
       
  2099             break;
       
  2100             }
       
  2101         case EAknFormSliderLayout2:
       
  2102             {
       
  2103             FormSliderLayout2();
       
  2104             break;
       
  2105             }
       
  2106         case EAknFormSliderLayout3:
       
  2107             {
       
  2108             FormSliderLayout3();
       
  2109             break;
       
  2110             }
       
  2111         case EAknSettingsItemSliderLayout:
       
  2112         case EAknSettingsItemSliderLayoutWithGraphics:
       
  2113       
       
  2114             {
       
  2115             SettingsItemSliderLayout();
       
  2116             break;
       
  2117             }
       
  2118         case EAknMIDPFormSliderLayout:
       
  2119             {
       
  2120             MIDPFormSliderLayout();
       
  2121             break;
       
  2122             }
       
  2123          case EAknSliderLayoutVertical:        
       
  2124             {
       
  2125             VerticalSliderLayout();
       
  2126             break;
       
  2127             } 
       
  2128         case EAknSliderLayoutHorizontal:
       
  2129             {
       
  2130             HorizontalSliderLayout();
       
  2131             break;
       
  2132             }
       
  2133                       
       
  2134         default:
       
  2135             break;
       
  2136         }
       
  2137 
       
  2138     TAknLayoutRect horLine;
       
  2139 
       
  2140     if ( Layout() == EAknSettingsItemSliderLayout ||
       
  2141          Layout() == EAknSettingsItemSliderLayoutWithGraphics  ||
       
  2142          Layout() == EAknSliderLayoutVertical ||
       
  2143          Layout() == EAknSliderLayoutHorizontal )
       
  2144         {
       
  2145         horLine.LayoutRect( iMarkerArea,
       
  2146                 AKN_LAYOUT_WINDOW_Slider_pane_elements_Line_1 );
       
  2147         }
       
  2148     else
       
  2149         {
       
  2150         horLine.LayoutRect( iMarkerArea,
       
  2151                 AKN_LAYOUT_WINDOW_Slider_pane_elements__form__Line_1 );
       
  2152         }
       
  2153 
       
  2154     TRect horRect = horLine.Rect();
       
  2155     iColor = horLine.Color();
       
  2156 
       
  2157     SetLabelColor();
       
  2158     AknsUtils::RegisterControlPosition( this );
       
  2159     }
       
  2160 
       
  2161 
       
  2162 // ----------------------------------------------------------------------------
       
  2163 // CAknSlider::FormSliderLayout1
       
  2164 // Pure layout function. Value label is shown in the same place in View and
       
  2165 // Edit modes.
       
  2166 // ----------------------------------------------------------------------------
       
  2167 //
       
  2168 void CAknSlider::FormSliderLayout1()
       
  2169     {
       
  2170     TRect rect = Rect();
       
  2171     AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2172             AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_2 );
       
  2173 
       
  2174     TAknLayoutRect layoutRect;
       
  2175      
       
  2176     // slider_form_pane
       
  2177     TAknLayoutRect temp, layout;
       
  2178     temp.LayoutRect( rect,
       
  2179                 AknLayoutScalable_Avkon::slider_cont_pane( 2 ) );
       
  2180 
       
  2181     layout.LayoutRect( temp.Rect(),
       
  2182                 AknLayoutScalable_Avkon::slider_form_pane( 1 ) );
       
  2183     iMarkerArea = layout.Rect();
       
  2184                 
       
  2185     // Load new slider layout if exist
       
  2186     if(  !(iExt->UsesDefaultGraphics()) )
       
  2187         {
       
  2188         temp.LayoutRect( layout.Rect(),
       
  2189                 AknLayoutScalable_Avkon::slider_form_pane_g4() );
       
  2190         iLineRect = temp.Rect();
       
  2191         
       
  2192         temp.LayoutRect( layout.Rect(),
       
  2193                 AknLayoutScalable_Avkon::slider_form_pane_g3() );
       
  2194         iExt->iLeftCapRect = temp.Rect();
       
  2195         
       
  2196         temp.LayoutRect( layout.Rect(),
       
  2197                 AknLayoutScalable_Avkon::slider_form_pane_g5() );
       
  2198         iExt->iRightCapRect = temp.Rect();
       
  2199         
       
  2200         temp.LayoutRect( layout.Rect(),
       
  2201                 AknLayoutScalable_Avkon::slider_form_pane_g7() ); 
       
  2202         iExt->iTickRect = temp.Rect();
       
  2203    
       
  2204         temp.LayoutRect( layout.Rect(),        
       
  2205                 AknLayoutScalable_Avkon::slider_form_pane_g6() );
       
  2206         iExt->iThumbRect = temp.Rect();
       
  2207         
       
  2208         }
       
  2209     else
       
  2210         {
       
  2211         temp.LayoutRect( layout.Rect(),
       
  2212                          AknLayoutScalable_Avkon::slider_form_pane_g1() );
       
  2213         AknIconUtils::SetSize( iExt->iLineIcon, temp.Rect().Size() );
       
  2214         iLineRect = temp.Rect();
       
  2215         
       
  2216         temp.LayoutRect( layout.Rect(),
       
  2217                          AknLayoutScalable_Avkon::slider_form_pane_g2() );
       
  2218         iExt->iThumbRect = temp.Rect(); 
       
  2219         }
       
  2220     }
       
  2221 
       
  2222 
       
  2223 // ----------------------------------------------------------------------------
       
  2224 // CAknSlider::FormSliderLayout2
       
  2225 // Pure layout function. Value label is not shown in the same place in Edit
       
  2226 // mode.
       
  2227 // ----------------------------------------------------------------------------
       
  2228 //
       
  2229 void CAknSlider::FormSliderLayout2()
       
  2230     {
       
  2231     TRect rect = Rect();
       
  2232     if ( iEditable )
       
  2233         {
       
  2234         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2235                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_3( 0, 0 ) );
       
  2236         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2237                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_3( 2, 2 ) );
       
  2238 
       
  2239         TAknLayoutRect temp, layout;
       
  2240         temp.LayoutRect( rect,
       
  2241                 AknLayoutScalable_Avkon::slider_cont_pane( 1 ) );
       
  2242 
       
  2243         layout.LayoutRect( temp.Rect(),
       
  2244                 AknLayoutScalable_Avkon::slider_form_pane( 0 ) );
       
  2245         iMarkerArea = layout.Rect();
       
  2246         //Load new slider layout if exist
       
  2247         if( !(iExt->UsesDefaultGraphics() ) )
       
  2248             {
       
  2249             temp.LayoutRect( layout.Rect(),
       
  2250                     AknLayoutScalable_Avkon::slider_form_pane_g4() );
       
  2251             iLineRect = temp.Rect();
       
  2252             
       
  2253             temp.LayoutRect( layout.Rect(),
       
  2254                     AknLayoutScalable_Avkon::slider_form_pane_g3() );
       
  2255             iExt->iLeftCapRect = temp.Rect();
       
  2256             
       
  2257             temp.LayoutRect( layout.Rect(),
       
  2258                     AknLayoutScalable_Avkon::slider_form_pane_g5() );
       
  2259             iExt->iRightCapRect = temp.Rect();
       
  2260             
       
  2261             temp.LayoutRect( layout.Rect(),
       
  2262                     AknLayoutScalable_Avkon::slider_form_pane_g7() );
       
  2263             iExt->iTickRect = temp.Rect(); 
       
  2264                    
       
  2265             temp.LayoutRect( layout.Rect(),        
       
  2266                     AknLayoutScalable_Avkon::slider_form_pane_g6() );
       
  2267             iExt->iThumbRect = temp.Rect();
       
  2268             }
       
  2269         else
       
  2270             {
       
  2271             temp.LayoutRect( layout.Rect(),
       
  2272                              AknLayoutScalable_Avkon::slider_form_pane_g1() );
       
  2273             AknIconUtils::SetSize( iExt->iLineIcon, temp.Rect().Size() );
       
  2274             iLineRect = temp.Rect();
       
  2275             
       
  2276             temp.LayoutRect( layout.Rect(),
       
  2277                              AknLayoutScalable_Avkon::slider_form_pane_g2() );
       
  2278             iExt->iThumbRect = temp.Rect();  
       
  2279             }
       
  2280 
       
  2281         if ( iValueLabel )
       
  2282             {
       
  2283             // Label must not overlap control but width is used to set view
       
  2284             // mode text
       
  2285             TSize tempSize = iValueLabel->Size();
       
  2286             iValueLabel->SetSize( TSize( tempSize.iWidth, 0 ) );
       
  2287             }
       
  2288         }
       
  2289     else
       
  2290         {
       
  2291         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2292                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_2 );
       
  2293         }
       
  2294     }
       
  2295 
       
  2296 
       
  2297 // ----------------------------------------------------------------------------
       
  2298 // CAknSlider::FormSliderLayout3
       
  2299 // Pure layout function. Value label is not shown in the same place in Edit
       
  2300 // mode.
       
  2301 // ----------------------------------------------------------------------------
       
  2302 //
       
  2303 void CAknSlider::FormSliderLayout3()
       
  2304     {
       
  2305     TRect rect = Rect();
       
  2306     
       
  2307     if ( iEditable )
       
  2308         {
       
  2309         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2310                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_2 );
       
  2311         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2312                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_3( 0, 1 ) );
       
  2313         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2314                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_3( 2, 3 ) );
       
  2315 
       
  2316         TAknLayoutRect temp, layout;
       
  2317         temp.LayoutRect( rect,
       
  2318                 AknLayoutScalable_Avkon::slider_cont_pane( 0 ) );
       
  2319 
       
  2320         // slider layout with value, min and max labels
       
  2321         layout.LayoutRect( temp.Rect(),
       
  2322                 AknLayoutScalable_Avkon::slider_form_pane( 0 ) );
       
  2323         iMarkerArea = layout.Rect();
       
  2324         //Load new slider layout if exist
       
  2325         if( !(iExt->UsesDefaultGraphics()) )
       
  2326             {
       
  2327             temp.LayoutRect( layout.Rect(),
       
  2328                     AknLayoutScalable_Avkon::slider_form_pane_g4() );
       
  2329             iLineRect = temp.Rect();
       
  2330             
       
  2331             temp.LayoutRect( layout.Rect(),
       
  2332                     AknLayoutScalable_Avkon::slider_form_pane_g3() );
       
  2333             iExt->iLeftCapRect = temp.Rect();
       
  2334             
       
  2335             temp.LayoutRect( layout.Rect(),
       
  2336                     AknLayoutScalable_Avkon::slider_form_pane_g5() );
       
  2337             iExt->iRightCapRect = temp.Rect();
       
  2338             
       
  2339             temp.LayoutRect( layout.Rect(),
       
  2340                     AknLayoutScalable_Avkon::slider_form_pane_g7() );
       
  2341             iExt->iTickRect = temp.Rect();
       
  2342                     
       
  2343             temp.LayoutRect( layout.Rect(),        
       
  2344                     AknLayoutScalable_Avkon::slider_form_pane_g6() );
       
  2345             iExt->iThumbRect = temp.Rect();
       
  2346             }
       
  2347         else
       
  2348             {
       
  2349             temp.LayoutRect( layout.Rect(),
       
  2350                              AknLayoutScalable_Avkon::slider_form_pane_g1() );
       
  2351             AknIconUtils::SetSize( iExt->iLineIcon, temp.Rect().Size() );
       
  2352             iLineRect = temp.Rect(); 
       
  2353             
       
  2354             temp.LayoutRect( layout.Rect(),
       
  2355                              AknLayoutScalable_Avkon::slider_form_pane_g2() );
       
  2356             iExt->iThumbRect = temp.Rect(); 
       
  2357             }
       
  2358         }
       
  2359     else
       
  2360         {
       
  2361         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2362                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_2 );
       
  2363         }
       
  2364     }
       
  2365 
       
  2366 
       
  2367 // ----------------------------------------------------------------------------
       
  2368 // CAknSlider::SettingsItemSliderLayout
       
  2369 // Pure layout function.
       
  2370 // ----------------------------------------------------------------------------
       
  2371 //
       
  2372 void CAknSlider::SettingsItemSliderLayout()
       
  2373     {
       
  2374     TRect rect = Rect();
       
  2375     iEditable = ETrue;
       
  2376   
       
  2377     TAknLayoutRect temp, layoutRect;    
       
  2378     if ( Layout() == EAknSettingsItemSliderLayout) 
       
  2379     
       
  2380         {
       
  2381         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2382                 AknLayoutScalable_Avkon::setting_slider_pane_t1_copy1( 0 ) );
       
  2383         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2384                 AknLayoutScalable_Avkon::setting_slider_pane_t2_copy1( 0 ) );
       
  2385         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2386                 AknLayoutScalable_Avkon::setting_slider_pane_t3_copy1( 0 ) );
       
  2387         layoutRect.LayoutRect( rect, 
       
  2388                 AknLayoutScalable_Avkon::slider_set_pane_copy1( 0 ) );
       
  2389         // Indication rect for setting slider pane
       
  2390         iExt->iTouchDownArea = Rect();
       
  2391         
       
  2392         iExt->iTouchActiveArea = TouchActiveArea();
       
  2393         }
       
  2394 
       
  2395     if ( Layout() == EAknSettingsItemSliderLayoutWithGraphics  )
       
  2396         {
       
  2397         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2398                 AknLayoutScalable_Avkon::setting_slider_graphic_pane_t1_copy1( 0 ) );
       
  2399         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2400                 AknLayoutScalable_Avkon::setting_slider_graphic_pane_t2_copy1( 0 ) );
       
  2401         AknLayoutUtils::LayoutImage( iImage, rect,
       
  2402                 AknLayoutScalable_Avkon::setting_slider_graphic_pane_g1_copy1( 0 ) );
       
  2403         AknIconUtils::SetSize( const_cast<CFbsBitmap*>( iImage->Bitmap() ),
       
  2404                                iImage->Size(), EAspectRatioNotPreserved );
       
  2405         layoutRect.LayoutRect( rect, 
       
  2406                 AknLayoutScalable_Avkon::slider_set_pane_cp_copy1( 0 ) );
       
  2407         // Indication rect for setting slider pane
       
  2408         iExt->iTouchDownArea = Rect();
       
  2409 
       
  2410         iExt->iTouchActiveArea = TouchActiveArea();
       
  2411         }
       
  2412 
       
  2413     iMarkerArea = layoutRect.Rect();
       
  2414 
       
  2415     //new horizonal slider
       
  2416     if( !(iExt->UsesDefaultGraphics()))
       
  2417         {
       
  2418         temp.LayoutRect( iMarkerArea,
       
  2419                 AknLayoutScalable_Avkon::slider_set_pane_g4_copy1(0) );
       
  2420         iLineRect = temp.Rect();
       
  2421         temp.LayoutRect( iMarkerArea,
       
  2422                 AknLayoutScalable_Avkon::slider_set_pane_g3_copy1(0) );
       
  2423         iExt->iLeftCapRect = temp.Rect();
       
  2424         temp.LayoutRect( iMarkerArea,
       
  2425                 AknLayoutScalable_Avkon::slider_set_pane_g5_copy1(0) );
       
  2426         iExt->iRightCapRect = temp.Rect();
       
  2427         temp.LayoutRect( iMarkerArea,
       
  2428                 AknLayoutScalable_Avkon::slider_set_pane_g7_copy1(0) );
       
  2429         iExt->iTickRect = temp.Rect();
       
  2430         temp.LayoutRect( iMarkerArea,        
       
  2431                 AknLayoutScalable_Avkon::slider_set_pane_g6_copy1(0) );
       
  2432         iExt->iThumbRect = temp.Rect();
       
  2433         }
       
  2434      else //default slider 
       
  2435         {
       
  2436         temp.LayoutRect( iMarkerArea,
       
  2437                 AknLayoutScalable_Avkon::slider_set_pane_g1_copy1() );
       
  2438         AknIconUtils::SetSize( iExt->iLineIcon, temp.Rect().Size() );
       
  2439         iLineRect = temp.Rect(); 
       
  2440         temp.LayoutRect( iMarkerArea,
       
  2441                 AknLayoutScalable_Avkon::slider_set_pane_g2_copy1() );
       
  2442         iExt->iThumbRect = temp.Rect();
       
  2443         }
       
  2444     }
       
  2445 
       
  2446 
       
  2447 // ----------------------------------------------------------------------------
       
  2448 // CAknSlider::VerticalSliderLayout
       
  2449 // Pure layout function.
       
  2450 // ----------------------------------------------------------------------------
       
  2451 //
       
  2452 void CAknSlider::VerticalSliderLayout()
       
  2453     {
       
  2454     TRect rect = Rect();
       
  2455     iEditable = ETrue;
       
  2456     
       
  2457     TAknLayoutRect temp, layoutRect;    
       
  2458     if( !(iExt->UsesDefaultGraphics()))
       
  2459         {
       
  2460         iMarkerArea = rect;
       
  2461         temp.LayoutRect( iMarkerArea,
       
  2462         AknLayoutScalable_Avkon::small_volume_slider_vertical_pane_g2() );
       
  2463         iLineRect = temp.Rect();
       
  2464         
       
  2465         temp.LayoutRect( iMarkerArea,
       
  2466                AknLayoutScalable_Avkon::small_volume_slider_vertical_pane_g3() );
       
  2467         iExt->iThumbRect = temp.Rect();
       
  2468         }
       
  2469     else
       
  2470         {
       
  2471         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2472                 AknLayoutScalable_Avkon::setting_slider_pane_t1(1) );
       
  2473         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2474                 AknLayoutScalable_Avkon::setting_slider_pane_t2(1) );
       
  2475         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2476                 AknLayoutScalable_Avkon::setting_slider_pane_t3(1) );
       
  2477 
       
  2478         iMarkerArea = rect;
       
  2479         //new vertical slider    
       
  2480 
       
  2481         temp.LayoutRect( iMarkerArea,
       
  2482                 AknLayoutScalable_Avkon::slider_pane_g3(0) );
       
  2483         iLineRect = temp.Rect();
       
  2484         
       
  2485         temp.LayoutRect( iMarkerArea,
       
  2486                 AknLayoutScalable_Avkon::slider_pane_g1(0) );
       
  2487         iExt->iLeftCapRect = temp.Rect();
       
  2488         
       
  2489         temp.LayoutRect( iMarkerArea,
       
  2490                 AknLayoutScalable_Avkon::slider_pane_g2(0) );
       
  2491         iExt->iRightCapRect = temp.Rect();
       
  2492         
       
  2493         temp.LayoutRect( iMarkerArea,
       
  2494                 AknLayoutScalable_Avkon::slider_pane_g3(0) );
       
  2495         iExt->iTickRect = temp.Rect(); 
       
  2496                
       
  2497         temp.LayoutRect( iMarkerArea,        
       
  2498                 AknLayoutScalable_Avkon::slider_pane_g4(0) );
       
  2499         iExt->iThumbRect = temp.Rect();        
       
  2500         }
       
  2501     }    
       
  2502 // ----------------------------------------------------------------------------
       
  2503 // CAknSlider::HorizontalSliderLayout
       
  2504 // Pure layout function.
       
  2505 // ----------------------------------------------------------------------------
       
  2506 //    
       
  2507 void CAknSlider::HorizontalSliderLayout()  
       
  2508     {
       
  2509     TRect rect = Rect();
       
  2510     iEditable = ETrue;
       
  2511     
       
  2512     TAknLayoutRect temp, layoutRect;
       
  2513     if( !( iExt->UsesDefaultGraphics() ) )
       
  2514         {
       
  2515         iMarkerArea = rect;
       
  2516         temp.LayoutRect( iMarkerArea,
       
  2517         AknLayoutScalable_Apps::vtel_slider_pane_g2(0) );
       
  2518         AknIconUtils::SetSize( iExt->iLineIcon, rect.Size() );
       
  2519         iLineRect = Rect();
       
  2520         
       
  2521         /*temp.LayoutRect( iMarkerArea,
       
  2522                 AknLayoutScalable_Apps::vtel_slider_pane_g4(0) );
       
  2523         iExt->iLeftCapRect = temp.Rect();
       
  2524         
       
  2525         temp.LayoutRect( iMarkerArea,
       
  2526                 AknLayoutScalable_Apps::vtel_slider_pane_g3(0) );
       
  2527         iExt->iRightCapRect = temp.Rect();*/
       
  2528         
       
  2529         temp.LayoutRect( rect,
       
  2530                AknLayoutScalable_Apps::vtel_slider_pane_g5(0) );
       
  2531         iExt->iThumbRect = temp.Rect();
       
  2532         }
       
  2533     else
       
  2534         {
       
  2535         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2536                 AknLayoutScalable_Avkon::setting_slider_pane_t1(0) );
       
  2537         AknLayoutUtils::LayoutLabel( iMinLabel, rect,
       
  2538                 AknLayoutScalable_Avkon::setting_slider_pane_t2(0) );
       
  2539         AknLayoutUtils::LayoutLabel( iMaxLabel, rect,
       
  2540                 AknLayoutScalable_Avkon::setting_slider_pane_t3(0) );
       
  2541         layoutRect.LayoutRect( rect, 
       
  2542                 AknLayoutScalable_Avkon::slider_set_pane(0) );
       
  2543 
       
  2544         iMarkerArea = layoutRect.Rect();
       
  2545         //new vertical slider    
       
  2546 
       
  2547         temp.LayoutRect( iMarkerArea,
       
  2548                 AknLayoutScalable_Avkon::slider_set_pane_g4(0) );
       
  2549         iLineRect = temp.Rect();
       
  2550         
       
  2551         temp.LayoutRect( iMarkerArea,
       
  2552                 AknLayoutScalable_Avkon::slider_set_pane_g3(0) );
       
  2553         iExt->iLeftCapRect = temp.Rect();
       
  2554         
       
  2555         temp.LayoutRect( iMarkerArea,
       
  2556                 AknLayoutScalable_Avkon::slider_set_pane_g5(0) );
       
  2557         iExt->iRightCapRect = temp.Rect();
       
  2558         
       
  2559         temp.LayoutRect( iMarkerArea,
       
  2560                 AknLayoutScalable_Avkon::slider_set_pane_g7(0) );
       
  2561         iExt->iTickRect = temp.Rect(); 
       
  2562                
       
  2563         temp.LayoutRect( iMarkerArea,        
       
  2564                 AknLayoutScalable_Avkon::slider_set_pane_g6(0) );
       
  2565         iExt->iThumbRect = temp.Rect();        
       
  2566         }   
       
  2567     }
       
  2568 // ----------------------------------------------------------------------------
       
  2569 // CAknSlider::MIDPFormSliderLayout
       
  2570 // Pure layout function. Value, min and max labels are shown.
       
  2571 // ----------------------------------------------------------------------------
       
  2572 //
       
  2573 void CAknSlider::MIDPFormSliderLayout()
       
  2574     {
       
  2575     TRect rect = Rect();
       
  2576     if ( iEditable )
       
  2577         {
       
  2578         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2579                 AknLayoutScalable_Avkon::form2_midp_gauge_slider_pane_t1() );
       
  2580 
       
  2581         TAknLayoutRect layout, temp;
       
  2582         layout.LayoutRect( rect,
       
  2583                 AknLayoutScalable_Avkon::form2_midp_gauge_slider_cont_pane(0) );
       
  2584         AknLayoutUtils::LayoutLabel( iMinLabel, layout.Rect(),
       
  2585                 AknLayoutScalable_Avkon::form2_midp_gauge_slider_pane_t2_cp01(0) );
       
  2586         AknLayoutUtils::LayoutLabel( iMaxLabel, layout.Rect(),
       
  2587                 AknLayoutScalable_Avkon::form2_midp_gauge_slider_pane_t3_cp01(1) );  
       
  2588         temp.LayoutRect( layout.Rect(),
       
  2589                 AknLayoutScalable_Avkon::form2_midp_slider_pane_cp01(0));  
       
  2590         iMarkerArea = temp.Rect();   
       
  2591         temp.LayoutRect( iMarkerArea,
       
  2592                 AknLayoutScalable_Avkon::form2_midp_slider_pane_g2(0) );   
       
  2593         AknIconUtils::SetSize( iExt->iLineIcon, temp.Rect().Size() );
       
  2594         iLineRect = temp.Rect();
       
  2595         
       
  2596         temp.LayoutRect( iMarkerArea,
       
  2597                 AknLayoutScalable_Avkon::form2_midp_slider_pane_g1(0) );
       
  2598         iExt->iLeftCapRect = temp.Rect();
       
  2599         
       
  2600         temp.LayoutRect( iMarkerArea,
       
  2601                 AknLayoutScalable_Avkon::form2_midp_slider_pane_g3(0) );
       
  2602         iExt->iRightCapRect = temp.Rect();
       
  2603         
       
  2604         temp.LayoutRect( iMarkerArea,
       
  2605                 AknLayoutScalable_Avkon::slider_form_pane_g7(0) );
       
  2606         iExt->iTickRect = temp.Rect(); 
       
  2607         
       
  2608         temp.LayoutRect( iMarkerArea,
       
  2609                          AknLayoutScalable_Avkon::slider_form_pane_g2() );
       
  2610         iExt->iThumbRect = temp.Rect(); 
       
  2611         }
       
  2612     else
       
  2613         {
       
  2614         AknLayoutUtils::LayoutLabel( iValueLabel, rect,
       
  2615                 AKN_LAYOUT_TEXT_Form_slider_field_texts_Line_2 );
       
  2616         }
       
  2617     }
       
  2618 
       
  2619 // ----------------------------------------------------------------------------
       
  2620 // CAknSlider::Draw
       
  2621 // Implementation of automatically called control drawing function from
       
  2622 // CCoeControl.
       
  2623 // ----------------------------------------------------------------------------
       
  2624 //
       
  2625 void CAknSlider::Draw( const TRect& /*aRect*/ ) const
       
  2626     {
       
  2627     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal ) )
       
  2628         {
       
  2629         DrawHorizontal( ETrue );
       
  2630         }
       
  2631     else // must be vertical
       
  2632         {
       
  2633         DrawVertical( ETrue );
       
  2634         }
       
  2635     }
       
  2636 
       
  2637 
       
  2638 // ----------------------------------------------------------------------------
       
  2639 // CAknSlider::DrawHorizontalTickMarks
       
  2640 //
       
  2641 // Draws horizontal tick marks. The slider grows rightwards and tick marks are
       
  2642 // placed above or below the line. If tick mark interval is zero the repeat
       
  2643 // step size is used as the interval.
       
  2644 //
       
  2645 // Slider range is not a pixel space, conversion must be done from
       
  2646 // slider range to actual pixel range. Using one pixel width for the
       
  2647 // tick interval in pixel space is not possible, as rounding errors
       
  2648 // would cumulate. Each tick pixel coordinate must be separately
       
  2649 // determined.
       
  2650 //
       
  2651 // Slider range [r1, r2] e Z, pixel range [p1, p2] e Z. Mapping from
       
  2652 // slider range position r to pixel range position p:
       
  2653 //
       
  2654 //            | (r - r1)(p2 - p1) |
       
  2655 //   p = p1 + | ----------------- |
       
  2656 //            |_     r2 - r1     _|
       
  2657 //
       
  2658 // Flooring indicates truncation caused by integer division.
       
  2659 // ----------------------------------------------------------------------------
       
  2660 //
       
  2661 void CAknSlider::DrawHorizontalTickMarks( CWindowGc& aGc ) const
       
  2662     {
       
  2663     TAknSliderGfx gfx;
       
  2664     FetchGfx( gfx, EElemTickMark, iExt->iTickRect.Size() );
       
  2665 
       
  2666     if ( !gfx.iRgb )
       
  2667         {
       
  2668         aGc.SetBrushStyle( CWindowGc::ESolidBrush );
       
  2669         aGc.SetBrushColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  2670         }
       
  2671 
       
  2672     const TInt mw = MarkerSize().iWidth; // Marker width
       
  2673     const TInt r1 = SliderData()->iMinimumValue; // Slider range start
       
  2674     const TInt r2 = SliderData()->iMaximumValue; // Slider range end
       
  2675     // Note that r2 - r1 > 0 as slider quarantees that
       
  2676     // SliderData()->iMinimumValue < SliderData()->iMaximumValue.
       
  2677 
       
  2678     const TInt p1 = iMarkerArea.iTl.iX + mw / 2; // Pixel range start
       
  2679     const TInt p2 = p1 + iMarkerArea.Width() - mw; // Pixel range end
       
  2680 
       
  2681     // Interval between tick marks, if zero then use step spacing.
       
  2682     // StepSize is always >= 1, therefore s cannot be zero which would
       
  2683     // lead to infinite loop below.
       
  2684     const TInt s = ( 0 == iExt->iTickInterval ) ? StepSize():
       
  2685                                                   iExt->iTickInterval;
       
  2686                                                   
       
  2687     const TInt tickWidth = iExt->iTickRect.Size().iWidth;
       
  2688     
       
  2689     // If tick width is even, handle as if it was uneven. The extra column of
       
  2690     // pixels is aligned to right side of the tick mark middle position.
       
  2691     const TInt off = ( tickWidth / 2 ) -
       
  2692                      ( ( tickWidth % 2 == 0 ) ? 1: 0 );
       
  2693                      
       
  2694 
       
  2695     TRect rect = iExt->iTickRect;
       
  2696 
       
  2697     for ( int r = r1; r <= r2; r += s )
       
  2698         {
       
  2699         // Current pos in the range -> current pos on screen, r2 - r1 > 0
       
  2700         // always (see comment above).
       
  2701         rect.iTl.iX = p1 + ( ( r - r1 ) * ( p2 - p1 ) ) / ( r2 - r1 ) - off;
       
  2702         rect.iBr.iX = rect.iTl.iX + tickWidth;
       
  2703 
       
  2704         if ( gfx.iRgb && gfx.iMask )
       
  2705             {
       
  2706             aGc.BitBltMasked( rect.iTl, gfx.iRgb, rect.Size(), gfx.iMask, EFalse );
       
  2707             }
       
  2708         else if ( gfx.iRgb )
       
  2709             {
       
  2710             aGc.BitBlt( rect.iTl, gfx.iRgb, rect.Size() );
       
  2711             }
       
  2712         else
       
  2713             {
       
  2714             aGc.DrawRect( rect );
       
  2715             }
       
  2716         }
       
  2717     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  2718     }
       
  2719 
       
  2720 
       
  2721 // ----------------------------------------------------------------------------
       
  2722 // CAknSlider::DrawVerticalTickMarks
       
  2723 //
       
  2724 // Draws vertical tick marks. The slider grows upwards and tick marks are
       
  2725 // placed to the left or right of the line. If tick mark interval is zero the
       
  2726 // repeat step size is used as the interval. Implementation is similar to
       
  2727 // DrawHorizontalTickMarks, the major difference is that in vertical mode
       
  2728 // slider range and pixel range grow to different directions.
       
  2729 // ----------------------------------------------------------------------------
       
  2730 //
       
  2731 void CAknSlider::DrawVerticalTickMarks( CWindowGc& aGc ) const
       
  2732     {
       
  2733     TAknSliderGfx gfx;
       
  2734     FetchGfx( gfx, EElemTickMark, iExt->iTickRect.Size() );
       
  2735 
       
  2736     if ( !gfx.iRgb )
       
  2737         {
       
  2738         aGc.SetBrushStyle( CWindowGc::ESolidBrush );
       
  2739         aGc.SetBrushColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  2740         }
       
  2741 
       
  2742     const TInt mh = MarkerSize().iHeight; // Marker height
       
  2743     const TInt r1 = SliderData()->iMinimumValue; // Slider range start
       
  2744     const TInt r2 = SliderData()->iMaximumValue; // Slider range end
       
  2745     // Note that r2 - r1 > 0 as slider quarantees that
       
  2746     // SliderData()->iMinimumValue < SliderData()->iMaximumValue.
       
  2747 
       
  2748     const TInt p2 = iMarkerArea.iBr.iY - mh / 2; // Pixel range end
       
  2749     const TInt p1 = p2 - iMarkerArea.Height() + mh; // Pixel range start
       
  2750 
       
  2751     // Interval between tick marks, if zero then use step spacing.
       
  2752     // StepSize is always >= 1, therefore s cannot be zero which would
       
  2753     // lead to infinite loop below.
       
  2754     const TInt s = ( 0 == iExt->iTickInterval ) ? StepSize():
       
  2755                                                   iExt->iTickInterval;
       
  2756 
       
  2757     const TInt tickHeight = iExt->iTickRect.Size().iHeight;
       
  2758     
       
  2759     // If tick width is even, handle as if it was uneven. The extra column of
       
  2760     // pixels is aligned above the tick mark middle position.
       
  2761     const TInt off = ( tickHeight / 2 ) -
       
  2762                      ( ( tickHeight % 2 == 0 ) ? 1: 0 );
       
  2763 
       
  2764     TRect rect = iExt->iTickRect;
       
  2765     for ( int r = r1; r <= r2; r += s )
       
  2766         {
       
  2767         // Current pos in the range -> current pos on screen, r2 - r1 > 0,
       
  2768         // checked above
       
  2769         rect.iBr.iY = p2 - ( ( r - r1 ) * ( p2 - p1 ) ) / ( r2 - r1 ) + off;
       
  2770         rect.iTl.iY = rect.iBr.iY - tickHeight;
       
  2771 
       
  2772         if ( gfx.iRgb && gfx.iMask )
       
  2773             {
       
  2774             aGc.BitBltMasked( rect.iTl, gfx.iRgb, rect.Size(), gfx.iMask, EFalse );
       
  2775             }
       
  2776         else if ( gfx.iRgb )
       
  2777             {
       
  2778             aGc.BitBlt( rect.iTl, gfx.iRgb, rect.Size() );
       
  2779             }
       
  2780         else
       
  2781             {
       
  2782             aGc.DrawRect( rect );
       
  2783             }
       
  2784         }
       
  2785     }
       
  2786 
       
  2787 
       
  2788 // ----------------------------------------------------------------------------
       
  2789 // CAknSlider::CreateDecoratorImageFromResourceL
       
  2790 // ----------------------------------------------------------------------------
       
  2791 //
       
  2792 void CAknSlider::CreateDecoratorImageFromResourceL( TInt aImageResourceId )
       
  2793     {
       
  2794     iImage = new ( ELeave ) CEikImage();
       
  2795     TResourceReader reader;
       
  2796     CEikonEnv::Static()->CreateResourceReaderLC( reader, aImageResourceId );
       
  2797     iImage->ConstructFromResourceL( reader );
       
  2798     CleanupStack::PopAndDestroy(); // reader
       
  2799     }
       
  2800 
       
  2801 
       
  2802 // ----------------------------------------------------------------------------
       
  2803 // CAknSlider::SetDecimalPlaces
       
  2804 // ----------------------------------------------------------------------------
       
  2805 //
       
  2806 EXPORT_C void CAknSlider::SetDecimalPlaces( TInt aDecimalPlaces )
       
  2807     {
       
  2808     SliderData()->SetDecimalPlaces( aDecimalPlaces );
       
  2809     }
       
  2810 
       
  2811 
       
  2812 // ----------------------------------------------------------------------------
       
  2813 // CAknSlider::DecimalPlaces
       
  2814 // ----------------------------------------------------------------------------
       
  2815 //
       
  2816 EXPORT_C TInt CAknSlider::DecimalPlaces() const
       
  2817     {
       
  2818     return SliderData()->DecimalPlaces();
       
  2819     }
       
  2820 
       
  2821 
       
  2822 // ----------------------------------------------------------------------------
       
  2823 // CAknSlider::SetGraphics
       
  2824 // ----------------------------------------------------------------------------
       
  2825 //
       
  2826 EXPORT_C void CAknSlider::SetGraphics( TInt aElement, CFbsBitmap* aBitmap,
       
  2827                                        CFbsBitmap* aMask )
       
  2828     {
       
  2829     if ( aElement < 0 || aElement > EElemMarkerSelected )//|| !aBitmap )
       
  2830         {
       
  2831         Panic( EAknPanicInvalidValue );
       
  2832         }
       
  2833 
       
  2834     iExt->SetGraphics( aElement, aBitmap, aMask );
       
  2835     }
       
  2836 
       
  2837     
       
  2838 // ----------------------------------------------------------------------------
       
  2839 // CAknSlider::UseDefaultGraphics
       
  2840 // ----------------------------------------------------------------------------
       
  2841 //
       
  2842 EXPORT_C void CAknSlider::UseDefaultGraphics( TInt aElement )
       
  2843     {
       
  2844     if ( aElement < 0 || aElement > EElemMarkerSelected )
       
  2845         {
       
  2846         Panic( EAknPanicInvalidValue );
       
  2847         }
       
  2848 
       
  2849     iExt->UseDefaultGraphics( aElement );
       
  2850     }
       
  2851 
       
  2852 
       
  2853 // ----------------------------------------------------------------------------
       
  2854 // CAknSlider::UsesDefaultGraphics
       
  2855 // ----------------------------------------------------------------------------
       
  2856 //
       
  2857 EXPORT_C TBool CAknSlider::UsesDefaultGraphics( TInt aElement ) const
       
  2858     {
       
  2859     if ( aElement < 0 || aElement > EElemMarkerSelected )
       
  2860         {
       
  2861         Panic( EAknPanicInvalidValue );
       
  2862         }
       
  2863 
       
  2864     return iExt->UsesDefaultGraphics( aElement );
       
  2865     }
       
  2866 
       
  2867 
       
  2868 // ----------------------------------------------------------------------------
       
  2869 // CAknSlider::SetPositionIndicators
       
  2870 // ----------------------------------------------------------------------------
       
  2871 //
       
  2872 EXPORT_C void CAknSlider::SetPositionIndicators( TUint32 aFlags )
       
  2873     {
       
  2874     iExt->ClearFlag( CAknSliderExtension::EFlagFillEnabled );
       
  2875     iExt->ClearFlag( CAknSliderExtension::EFlagMarkerEnabled );
       
  2876 
       
  2877     if ( EPosFilling & aFlags )
       
  2878         {
       
  2879         iExt->SetFlag( CAknSliderExtension::EFlagFillEnabled );
       
  2880         }
       
  2881     else
       
  2882         {
       
  2883         // If no position indicator is set, always default to visible
       
  2884         // marker
       
  2885         iExt->SetFlag( CAknSliderExtension::EFlagMarkerEnabled );
       
  2886         }
       
  2887 
       
  2888     if ( EPosMarker & aFlags )
       
  2889         {
       
  2890         iExt->SetFlag( CAknSliderExtension::EFlagMarkerEnabled );
       
  2891         }
       
  2892     }
       
  2893 
       
  2894 
       
  2895 // ----------------------------------------------------------------------------
       
  2896 // CAknSlider::PositionIndicators
       
  2897 // ----------------------------------------------------------------------------
       
  2898 //
       
  2899 EXPORT_C TUint32 CAknSlider::PositionIndicators() const
       
  2900     {
       
  2901     TUint32 flags = 0;
       
  2902 
       
  2903     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagMarkerEnabled ) )
       
  2904         {
       
  2905         flags |= EPosMarker;
       
  2906         }
       
  2907 
       
  2908     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) )
       
  2909         {
       
  2910         flags |= EPosFilling;
       
  2911         }
       
  2912 
       
  2913     return flags;
       
  2914     }
       
  2915 
       
  2916 
       
  2917 // ----------------------------------------------------------------------------
       
  2918 // CAknSlider::Orientation
       
  2919 // ----------------------------------------------------------------------------
       
  2920 //
       
  2921 EXPORT_C TAknOrientation CAknSlider::Orientation() const
       
  2922     {
       
  2923     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal ) )
       
  2924         {
       
  2925         return EAknOrientationHorizontal;
       
  2926         }
       
  2927     return EAknOrientationVertical;
       
  2928     }
       
  2929 
       
  2930 
       
  2931 // ----------------------------------------------------------------------------
       
  2932 // CAknSlider::SetTicksEnabled
       
  2933 // ----------------------------------------------------------------------------
       
  2934 //
       
  2935 EXPORT_C void CAknSlider::SetTicksEnabled( TBool aStatus )
       
  2936     {
       
  2937     if ( aStatus )
       
  2938         {
       
  2939         iExt->SetFlag( CAknSliderExtension::EFlagTickMarksEnabled );
       
  2940         }
       
  2941     else
       
  2942         {
       
  2943         iExt->ClearFlag( CAknSliderExtension::EFlagTickMarksEnabled );
       
  2944         }
       
  2945     }
       
  2946 
       
  2947 
       
  2948 // ----------------------------------------------------------------------------
       
  2949 // CAknSlider::TicksEnabled
       
  2950 // ----------------------------------------------------------------------------
       
  2951 //
       
  2952 EXPORT_C TBool CAknSlider::TicksEnabled() const
       
  2953     {
       
  2954     return iExt->IsFlagSet( CAknSliderExtension::EFlagTickMarksEnabled );
       
  2955     }
       
  2956 
       
  2957 
       
  2958 // ----------------------------------------------------------------------------
       
  2959 // CAknSlider::SetTickInterval
       
  2960 // ----------------------------------------------------------------------------
       
  2961 //
       
  2962 EXPORT_C void CAknSlider::SetTickInterval( TUint aInterval )
       
  2963     {
       
  2964     iExt->iTickInterval = aInterval;
       
  2965     }
       
  2966 
       
  2967 
       
  2968 // ----------------------------------------------------------------------------
       
  2969 // CAknSlider::TickInterval
       
  2970 // ----------------------------------------------------------------------------
       
  2971 //
       
  2972 EXPORT_C TUint CAknSlider::TickInterval() const
       
  2973     {
       
  2974     return iExt->iTickInterval;
       
  2975     }
       
  2976 
       
  2977 
       
  2978 // ----------------------------------------------------------------------------
       
  2979 // CAknSlider::NumberOfLines
       
  2980 // ----------------------------------------------------------------------------
       
  2981 //
       
  2982 EXPORT_C TInt CAknSlider::NumberOfLines() const
       
  2983     {
       
  2984     TInt noOfLines = 1;
       
  2985 
       
  2986     if ( iEditable )
       
  2987         {
       
  2988         switch ( Layout() )
       
  2989             {
       
  2990             case EAknFormSliderLayout1: // drop through
       
  2991             case EAknFormSliderLayout2:
       
  2992                 noOfLines = 2;
       
  2993                 break;
       
  2994             case EAknFormSliderLayout3:
       
  2995                 noOfLines = 3;
       
  2996                 break;
       
  2997             default:
       
  2998                 break;
       
  2999             }
       
  3000         }
       
  3001 
       
  3002     return noOfLines;
       
  3003     }
       
  3004 
       
  3005 
       
  3006 // ----------------------------------------------------------------------------
       
  3007 // CAknSlider::CreateValueTextInHBufCL
       
  3008 //
       
  3009 // Returns the text that would appear at the top of the slider setting page if
       
  3010 // it were opened Ownership of the text buffer is transferred to the caller.
       
  3011 // ----------------------------------------------------------------------------
       
  3012 //
       
  3013 EXPORT_C HBufC* CAknSlider::CreateValueTextInHBufCL(
       
  3014         TInt aValue, TInt aResourceId )
       
  3015     {
       
  3016     CAknSliderData* sliderResourceData = CAknSliderData::NewLC( aResourceId );
       
  3017 
       
  3018     __ASSERT_DEBUG( aValue >= sliderResourceData->iMinimumValue &&
       
  3019                     aValue <= sliderResourceData->iMaximumValue,
       
  3020                     Panic( EAknPanicOutOfRange ) );
       
  3021 
       
  3022     TBuf<KValueLabelTextMaxLength> textBuffer;
       
  3023     CAknSlider::DoSetValueTextL( textBuffer, aValue, *sliderResourceData );
       
  3024 
       
  3025     CleanupStack::PopAndDestroy(); // sliderResourceData
       
  3026     HBufC* valueTextBufC = textBuffer.AllocL();
       
  3027     return valueTextBufC;
       
  3028     }
       
  3029 
       
  3030 // ----------------------------------------------------------------------------
       
  3031 // CAknSlider::StepSize
       
  3032 // ----------------------------------------------------------------------------
       
  3033 //
       
  3034 TInt CAknSlider::StepSize() const
       
  3035     {
       
  3036     return iData->iStepSize;
       
  3037     }
       
  3038 
       
  3039 
       
  3040 // ----------------------------------------------------------------------------
       
  3041 // CAknSlider::Layout
       
  3042 // ----------------------------------------------------------------------------
       
  3043 //
       
  3044 TInt CAknSlider::Layout() const
       
  3045     {
       
  3046     return iData->iLayout;
       
  3047     }
       
  3048 
       
  3049 
       
  3050 // ----------------------------------------------------------------------------
       
  3051 // CAknSlider::MaximumValue
       
  3052 // ----------------------------------------------------------------------------
       
  3053 //
       
  3054 TInt CAknSlider::MaximumValue() const
       
  3055     {
       
  3056     return iData->iMaximumValue;
       
  3057     }
       
  3058 
       
  3059 
       
  3060 // ----------------------------------------------------------------------------
       
  3061 // CAknSlider::MinimumValue
       
  3062 // ----------------------------------------------------------------------------
       
  3063 //
       
  3064 TInt CAknSlider::MinimumValue() const
       
  3065     {
       
  3066     return iData->iMinimumValue;
       
  3067     }
       
  3068 
       
  3069 
       
  3070 // ----------------------------------------------------------------------------
       
  3071 // CAknSlider::Range
       
  3072 // ----------------------------------------------------------------------------
       
  3073 //
       
  3074 TInt CAknSlider::Range() const
       
  3075     {
       
  3076     return iData->Range();
       
  3077     }
       
  3078 
       
  3079 
       
  3080 // ----------------------------------------------------------------------------
       
  3081 // CAknSlider::SliderData
       
  3082 // ----------------------------------------------------------------------------
       
  3083 //
       
  3084 CAknSliderData* CAknSlider::SliderData() const
       
  3085     {
       
  3086     // This method is used to trap all the accesses to the internal data when
       
  3087     // the 2nd stage construction has not taken place
       
  3088     __ASSERT_DEBUG( iData, Panic( EAknPanicObjectNotFullyConstructed ) );
       
  3089     return iData;
       
  3090     }
       
  3091 
       
  3092 
       
  3093 // ----------------------------------------------------------------------------
       
  3094 // CAknSlider::HandlePointerEventL
       
  3095 //
       
  3096 // Handles slider's pointer events. This function calculates thumb position
       
  3097 // when button down happens. Then it compares position to thumb position and if
       
  3098 // pointerevent was for the thumb it will set dragging on. Otherwise, the thumb
       
  3099 // will be moved to down position.
       
  3100 //
       
  3101 // If value have to be changed with this pointerevent, the new value have to be
       
  3102 // calculated. The calculation is based for drawing, so we have to find "what
       
  3103 // value" would be drawn to clicked position and thus deside what value was
       
  3104 // selected from slider.
       
  3105 // ----------------------------------------------------------------------------
       
  3106 //
       
  3107 EXPORT_C void CAknSlider::HandlePointerEventL( const TPointerEvent& aEvent )
       
  3108     {
       
  3109     if ( !AknLayoutUtils::PenEnabled() )
       
  3110         {
       
  3111         return;
       
  3112         }
       
  3113 
       
  3114     if ( IsDimmed() )
       
  3115         {
       
  3116         iExt->ClearFlag( CAknSliderExtension::EFlagPointerDown );
       
  3117         iExt->ClearFlag( CAknSliderExtension::EFlagDraggingThumb );
       
  3118         return;
       
  3119         }
       
  3120     
       
  3121     TBool thumbMoved = EFalse;
       
  3122     TBool valueChanged = EFalse;
       
  3123     TBool upFromDrag = EFalse;
       
  3124     TRect mrect;
       
  3125     GetMarkerRect( mrect );    
       
  3126     TInt reportDragEvent(0);// if this value is 0, it means no need to report
       
  3127     TBool hor = iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal );
       
  3128     
       
  3129     //Setting pane slider use extended touch area to hand pointer event
       
  3130     TRect touchDownArea;
       
  3131     TRect touchActiveArea;
       
  3132     if( Layout() == EAknSettingsItemSliderLayout ||
       
  3133         Layout() == EAknSettingsItemSliderLayoutWithGraphics
       
  3134         )
       
  3135         {
       
  3136         touchDownArea = iExt->iTouchDownArea;
       
  3137         touchActiveArea = iExt->iTouchActiveArea;
       
  3138         }
       
  3139     else
       
  3140         {
       
  3141         touchDownArea = iMarkerArea;
       
  3142         touchActiveArea = iMarkerArea;
       
  3143         }
       
  3144         
       
  3145     if( iEditable )
       
  3146         {
       
  3147          switch ( aEvent.iType )
       
  3148             {
       
  3149             case TPointerEvent::EButton1Down:
       
  3150                 {
       
  3151                 if ( touchDownArea.Contains( aEvent.iPosition ) )
       
  3152                     {
       
  3153                        // repeat until thumb reaches the stylus down position    
       
  3154                     iExt->iPenInputPos = aEvent.iPosition;
       
  3155 
       
  3156                     // Click was inside and down slider marker area
       
  3157                     iExt->SetFlag( CAknSliderExtension::EFlagPointerDown );
       
  3158                     // Start draggint even if the click was not inside thumb rect
       
  3159                     if ( mrect.Contains( aEvent.iPosition ) )
       
  3160                         {
       
  3161                         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3162                         if ( feedback )
       
  3163                             {
       
  3164                             feedback->InstantFeedback( this, ETouchFeedbackSlider, aEvent );
       
  3165                             }
       
  3166                         iExt->SetFlag( CAknSliderExtension::EFlagDraggingThumb );
       
  3167                         reportDragEvent = EDragMarkerStart;
       
  3168                         }                    
       
  3169                     // Marker icon changes - draw
       
  3170                     if ( !iExt->iNoDraw )
       
  3171                         {
       
  3172                         DrawDeferred();  
       
  3173                         }
       
  3174                     valueChanged = ETrue;
       
  3175                     }
       
  3176                 }
       
  3177                 break;
       
  3178             case TPointerEvent::EButtonRepeat:
       
  3179                 {
       
  3180                 if ( touchActiveArea.Contains( aEvent.iPosition ) )
       
  3181                     {
       
  3182                     // repeat until thumb reaches the stylus down position    
       
  3183                     iExt->iPenInputPos = aEvent.iPosition;
       
  3184 
       
  3185                     // Click was inside and down slider marker area
       
  3186                     iExt->SetFlag( CAknSliderExtension::EFlagPointerDown );
       
  3187                     // Start draggint even if the click was not inside thumb rect
       
  3188                     if ( mrect.Contains( aEvent.iPosition ) )
       
  3189                         {
       
  3190                         iExt->SetFlag( CAknSliderExtension::EFlagDraggingThumb );
       
  3191                         reportDragEvent = EDragMarkerStart;
       
  3192                         }                    
       
  3193                     // Marker icon changes - draw
       
  3194                     if ( !iExt->iNoDraw )
       
  3195                         {
       
  3196                         DrawDeferred();    
       
  3197                         }
       
  3198                     valueChanged = ETrue;
       
  3199                     }
       
  3200                     if ( mrect.Contains( aEvent.iPosition ) )
       
  3201                         {
       
  3202                         StopFeedback();
       
  3203                         }
       
  3204                 }
       
  3205                 break;
       
  3206             // Drag can out of touchDownArea to support finger touch out of range,
       
  3207             // when the pointer fall down the thumb,then use touchDragArea  
       
  3208             case TPointerEvent::EDrag:
       
  3209                 {
       
  3210                 if ( ( iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) ||
       
  3211                        touchActiveArea.Contains( aEvent.iPosition ) ) &&
       
  3212                      iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) )
       
  3213                     {
       
  3214                     if ( hor && aEvent.iPosition.iX != iExt->iPenInputPos.iX )
       
  3215                         {
       
  3216                         thumbMoved = ETrue;
       
  3217                         }
       
  3218                     if ( !hor && aEvent.iPosition.iY != iExt->iPenInputPos.iY )
       
  3219                         {
       
  3220                         thumbMoved = ETrue;
       
  3221                         }
       
  3222                     iExt->iPenInputPos = aEvent.iPosition;
       
  3223                     valueChanged = ETrue;
       
  3224                     }
       
  3225                 if ( !iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) &&
       
  3226                      !touchActiveArea.Contains( aEvent.iPosition ))
       
  3227                     {
       
  3228                         StopFeedback();
       
  3229                     }
       
  3230                 }
       
  3231                 break; 
       
  3232                 
       
  3233             case TPointerEvent::EButton1Up:
       
  3234                 {
       
  3235                 if ( iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) &&
       
  3236                      iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) )
       
  3237                     {
       
  3238                     iExt->iPenInputPos = aEvent.iPosition;
       
  3239                     valueChanged = ETrue;
       
  3240                     upFromDrag = ETrue;
       
  3241                     reportDragEvent = EDragMarkerEnd;
       
  3242                     }
       
  3243                 iExt->ClearFlag( CAknSliderExtension::EFlagPointerDown );
       
  3244                 iExt->ClearFlag( CAknSliderExtension::EFlagDraggingThumb );
       
  3245                 if ( mrect.Contains( aEvent.iPosition ) )
       
  3246                     {
       
  3247                     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3248                     if ( feedback )
       
  3249                         {
       
  3250                         feedback->InstantFeedback( this,
       
  3251                                                    ETouchFeedbackSlider,
       
  3252                                                    ETouchFeedbackVibra,
       
  3253                                                    aEvent );
       
  3254                         }
       
  3255                     }
       
  3256                 StopFeedback();
       
  3257 
       
  3258                 // Marker icon changes - draw
       
  3259                 if ( !iExt->iNoDraw )
       
  3260                     {
       
  3261                     DrawDeferred();    
       
  3262                     }
       
  3263                 }
       
  3264                 break;
       
  3265                 
       
  3266             default:
       
  3267                 break;
       
  3268             }       
       
  3269         }
       
  3270 
       
  3271                         
       
  3272     TBool valueStepChange = iExt->IsFlagSet( CAknSliderExtension::EFlagValueStepChange );
       
  3273     
       
  3274     // if pointerevent causes value changing, we have to calculate the
       
  3275     // clicked value.
       
  3276     if ( valueChanged )
       
  3277         {
       
  3278         TInt betweenSteps;
       
  3279         TInt value = Value();
       
  3280         TBool isDragThumb = EFalse;
       
  3281 
       
  3282         if( (iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) &&
       
  3283             iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown )) || 
       
  3284             !valueStepChange || upFromDrag )
       
  3285             {
       
  3286             //not value step or drag happened
       
  3287             isDragThumb = ETrue;
       
  3288             value = CalcAlignedValue( iExt->iPenInputPos );
       
  3289             }
       
  3290         else if( !mrect.Contains( aEvent.iPosition ) )
       
  3291             {// value step change begin
       
  3292             TInt step = StepSize();
       
  3293             TInt halfStepRange(0);
       
  3294             TBool repeat = ( ( aEvent.iType == TPointerEvent::EButton1Down ) ||
       
  3295             ( aEvent.iType == TPointerEvent::EButtonRepeat ) ) ? ETrue : EFalse;
       
  3296 
       
  3297             if(!hor)
       
  3298                 {
       
  3299                 halfStepRange = (iMarkerArea.Height() - mrect.Height())/( 2 * Range() );
       
  3300                 if( aEvent.iPosition.iY < mrect.iTl.iY + mrect.Height()/2 - halfStepRange )
       
  3301                     {
       
  3302                     TranslateValueL( step, repeat );
       
  3303                     value = iValue;
       
  3304                     }
       
  3305                 else if( aEvent.iPosition.iY > mrect.iTl.iY + mrect.Height()/2 + halfStepRange )
       
  3306                     {
       
  3307                     TranslateValueL( -step, repeat );
       
  3308                     value = iValue;
       
  3309                     }
       
  3310                 else
       
  3311                     {
       
  3312                     value = iValue;
       
  3313                     }
       
  3314                 }
       
  3315              else
       
  3316                 {
       
  3317                 halfStepRange = (iMarkerArea.Width() - mrect.Width())/( 2 * Range() );
       
  3318                 if( aEvent.iPosition.iX < mrect.iTl.iX + mrect.Width()/2 - halfStepRange )
       
  3319                     {
       
  3320                     TranslateValueL( -step, repeat );
       
  3321                     value = iValue;
       
  3322                     }
       
  3323                 else if( aEvent.iPosition.iX > mrect.iTl.iX + mrect.Width()/2 + halfStepRange )
       
  3324                     {
       
  3325                     TranslateValueL( step, repeat );
       
  3326                     value = iValue;
       
  3327                     }
       
  3328                 else
       
  3329                     {
       
  3330                     value = iValue;
       
  3331                     }     
       
  3332                 }
       
  3333 
       
  3334                 Window().RequestPointerRepeatEvent( KScrollRepeatTimeout, touchActiveArea );
       
  3335              }// value step change over
       
  3336         
       
  3337         // calculate how many pixels was clicked between steps
       
  3338         betweenSteps = value % StepSize();
       
  3339 
       
  3340         if ( betweenSteps != 0 )
       
  3341             {
       
  3342             value = value - betweenSteps;
       
  3343 
       
  3344             // if click was nearer or middle of values, then move it to
       
  3345             // next possible value
       
  3346             if ( betweenSteps > ( StepSize() / 2 ) )
       
  3347                 {
       
  3348                 value = value + StepSize();
       
  3349                 }
       
  3350             }
       
  3351 
       
  3352         // Move to Max/Min values if value is not withing range
       
  3353         if ( value > MaximumValue() )
       
  3354             {
       
  3355             value = MaximumValue();
       
  3356             }
       
  3357         else if ( value < MinimumValue() )
       
  3358             {
       
  3359             value = MinimumValue();
       
  3360             }
       
  3361         if( value == MinimumValue() )
       
  3362             {
       
  3363             //The value is minimum value, but the pointer fell on the position which is
       
  3364             //less than minimum + 1 position.
       
  3365             if( hor && 
       
  3366                 aEvent.iPosition.iX < iMarkerArea.iTl.iX + iExt->iThumbRect.Width() / 2 + 
       
  3367                              ( iMarkerArea.iTl.iX - iExt->iThumbRect.Width() ) / Range() )
       
  3368                 {
       
  3369                 iExt->iPenInputPos = 
       
  3370                       TPoint( iMarkerArea.iTl.iX + iExt->iThumbRect.Width() / 2, 
       
  3371                               iMarkerArea.iTl.iY );                
       
  3372                 thumbMoved = EFalse;
       
  3373                 }
       
  3374             
       
  3375             if( !hor && 
       
  3376                 aEvent.iPosition.iY > iMarkerArea.iBr.iY - iExt->iThumbRect.Height() / 2 - 
       
  3377                              ( iMarkerArea.iTl.iY - iExt->iThumbRect.Height() ) / Range() )
       
  3378                 {
       
  3379                 iExt->iPenInputPos = 
       
  3380                           TPoint( iMarkerArea.iBr.iX,
       
  3381                                   iMarkerArea.iTl.iY - iExt->iThumbRect.Height() / 2 );                
       
  3382                 thumbMoved = EFalse;
       
  3383                 }
       
  3384             }
       
  3385         if( value == MaximumValue() )
       
  3386             {
       
  3387             if( hor )
       
  3388                 {
       
  3389                 iExt->iPenInputPos.iX = iMarkerArea.iTl.iX - iExt->iThumbRect.Width() / 2;
       
  3390                 thumbMoved = EFalse;
       
  3391                 }
       
  3392             else
       
  3393                 {
       
  3394                 iExt->iPenInputPos.iY = iMarkerArea.iTl.iY + iExt->iThumbRect.Height() / 2;
       
  3395                 thumbMoved = EFalse;
       
  3396                 }
       
  3397             }
       
  3398         if ( thumbMoved )
       
  3399             {
       
  3400             StartFeedback( &aEvent, KFeedbackTimeout );
       
  3401             }
       
  3402         if ( iValue != value )
       
  3403             {
       
  3404             SetValueL( value );
       
  3405             if ( &Window() != NULL )
       
  3406                 {                
       
  3407                 ReportEventL( MCoeControlObserver::EEventStateChanged );
       
  3408                 if ( !iExt->iNoDraw )
       
  3409                     {
       
  3410                     DrawDeferred();    
       
  3411                     }
       
  3412                 }
       
  3413             }
       
  3414         else if( isDragThumb ) // fix TSW EAKH-7FAF63
       
  3415             {
       
  3416             // smoothly
       
  3417             DrawDeferred();
       
  3418             }
       
  3419         }
       
  3420         
       
  3421     // Report drag event if it is needed
       
  3422     if( iExt->iReportMarkerDragEvent && reportDragEvent )
       
  3423         {
       
  3424         ReportEventL( static_cast<MCoeControlObserver::TCoeEvent>(reportDragEvent) );
       
  3425         }
       
  3426     }
       
  3427 
       
  3428 
       
  3429 // ----------------------------------------------------------------------------
       
  3430 // CAknSlider::CalcAlignedValue
       
  3431 // ----------------------------------------------------------------------------
       
  3432 //
       
  3433 TInt CAknSlider::CalcAlignedValue( const TPoint& aPoint ) 
       
  3434     {
       
  3435     TBool hor = iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal );
       
  3436     TInt bitmapRun = 0;
       
  3437     TInt returnValue = MinimumValue();
       
  3438     
       
  3439     if ( hor )
       
  3440         {
       
  3441         bitmapRun = iMarkerArea.Width() - iExt->iThumbRect.Width();
       
  3442         returnValue = ( ( Range() * ( aPoint.iX - iMarkerArea.iTl.iX -
       
  3443             iExt->iThumbRect.Width() / 2 ) + bitmapRun / 2 ) / bitmapRun ) + MinimumValue();
       
  3444         }
       
  3445     else
       
  3446         {
       
  3447         bitmapRun = iMarkerArea.Height() - iExt->iThumbRect.Height();
       
  3448         returnValue = ( ( Range() * ( iMarkerArea.iBr.iY - aPoint.iY -
       
  3449             iExt->iThumbRect.Height() / 2 ) + bitmapRun / 2 ) / bitmapRun ) + MinimumValue();
       
  3450         }
       
  3451     return returnValue;
       
  3452     }
       
  3453 
       
  3454 
       
  3455 // ----------------------------------------------------------------------------
       
  3456 // CAknSlider::ExtensionInterface
       
  3457 // ----------------------------------------------------------------------------
       
  3458 //
       
  3459 EXPORT_C void* CAknSlider::ExtensionInterface( TUid /*aInterface*/ )
       
  3460     {
       
  3461     return NULL;
       
  3462     }
       
  3463 
       
  3464 
       
  3465 // ----------------------------------------------------------------------------
       
  3466 // CAknSlider::StartTimerL
       
  3467 // ----------------------------------------------------------------------------
       
  3468 //
       
  3469 void CAknSlider::StartTimerL()
       
  3470     {
       
  3471     if ( iExt->iTimer->IsActive() )
       
  3472         {
       
  3473         return; // do not re-start as we have the feedback ongoing
       
  3474         }
       
  3475 
       
  3476     iExt->iEffectTimerCount = 0;
       
  3477 
       
  3478     TCallBack callback( IndicationDrawCallbackL, this );
       
  3479      iExt->iTimer->Start(
       
  3480             TTimeIntervalMicroSeconds32( KAknSliderFeedbackActionTime ),
       
  3481             KAknSliderFeedbackActionTime, callback );
       
  3482     }
       
  3483 
       
  3484 
       
  3485 // ----------------------------------------------------------------------------
       
  3486 // CAknSlider::IndicationDrawCallbackL
       
  3487 // ----------------------------------------------------------------------------
       
  3488 //
       
  3489 TInt CAknSlider::IndicationDrawCallbackL( TAny* aThis )
       
  3490     {
       
  3491     CAknSlider* slider = static_cast<CAknSlider*>( aThis );
       
  3492     slider->SmallDirectionIndicationL();
       
  3493     return KErrNone;
       
  3494     }
       
  3495 
       
  3496 
       
  3497 // ----------------------------------------------------------------------------
       
  3498 // CAknSlider::SmallDirectionIndicationL
       
  3499 // ----------------------------------------------------------------------------
       
  3500 //
       
  3501 void CAknSlider::SmallDirectionIndicationL()
       
  3502     {
       
  3503     Window().Invalidate( iMarkerArea );
       
  3504     ActivateGc();
       
  3505     Window().BeginRedraw( iMarkerArea );
       
  3506     CWindowGc& gc = SystemGc();
       
  3507     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  3508     gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
  3509     gc.SetPenColor( AKN_LAF_COLOR( 0 ) );
       
  3510 
       
  3511     if( !Background() )
       
  3512         {
       
  3513         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  3514         MAknsControlContext* cc = NULL;        
       
  3515         if ( AknsUtils::AvkonSkinEnabled() )
       
  3516             {
       
  3517             cc = AknsDrawUtils::ControlContext( this );
       
  3518             }         
       
  3519         AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
  3520         }
       
  3521      else
       
  3522         {
       
  3523         TRect rect = Window().GetDrawRect();
       
  3524         Background()->Draw( gc, *this, rect );
       
  3525         }
       
  3526     
       
  3527     TBool drawMarker = EFalse;
       
  3528     if ( iExt->iEffectTimerCount % 2 == 1 )
       
  3529         {
       
  3530         drawMarker = ETrue;
       
  3531         }
       
  3532 
       
  3533     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal ) )
       
  3534         {
       
  3535         DrawHorizontal( drawMarker );
       
  3536         }
       
  3537     else // Must be vertical
       
  3538         {
       
  3539         DrawVertical( drawMarker );
       
  3540         }
       
  3541 
       
  3542     Window().EndRedraw();
       
  3543     DeactivateGc();
       
  3544 
       
  3545     iExt->iEffectTimerCount++;
       
  3546 
       
  3547     // Stop timer if done normal-inverted-normal-inverted-normal sequence
       
  3548     if ( iExt->iEffectTimerCount > 3 )
       
  3549         {
       
  3550         iExt->iTimer->Cancel();
       
  3551         }
       
  3552     }
       
  3553 
       
  3554 
       
  3555 // ----------------------------------------------------------------------------
       
  3556 // CAknSlider::TranslateValueL
       
  3557 //
       
  3558 // Moves the current slider value by aDelta. If the value of aDelta is
       
  3559 // negative, the current value is decremented by |aDelta|. If the value of
       
  3560 // aDelta is positive, the current value is incremented by |aDelta|.
       
  3561 // ----------------------------------------------------------------------------
       
  3562 //
       
  3563 void CAknSlider::TranslateValueL( TInt aDelta, TBool aFeedback )
       
  3564     {
       
  3565     TInt sliderValue = Value();
       
  3566 
       
  3567     sliderValue += aDelta;
       
  3568     
       
  3569     // calculate how many pixels was clicked between steps
       
  3570     TInt betweenSteps = sliderValue % StepSize();
       
  3571         
       
  3572     if ( betweenSteps != 0 )
       
  3573         {
       
  3574         sliderValue = sliderValue - betweenSteps;
       
  3575 
       
  3576         // if click was nearer or middle of values, then move it to
       
  3577         // next possible value
       
  3578         if ( betweenSteps > ( StepSize() / 2 ) )
       
  3579             {
       
  3580             sliderValue = sliderValue + StepSize();
       
  3581             }
       
  3582         }
       
  3583     
       
  3584     if ( sliderValue > MaximumValue() )
       
  3585         {
       
  3586         sliderValue = MaximumValue();
       
  3587         }
       
  3588     else if ( sliderValue < MinimumValue() )
       
  3589         {
       
  3590         sliderValue = MinimumValue();
       
  3591         }
       
  3592     
       
  3593 
       
  3594     TInt oldSliderValue = Value();
       
  3595     SetValueL( sliderValue );
       
  3596 
       
  3597     ReportEventL( MCoeControlObserver::EEventStateChanged );
       
  3598 
       
  3599     // start the timer if we tried to move the slider but the slider did
       
  3600     // not move (in either maximum or minimum already).
       
  3601 #ifdef RD_ANIMATION_EFFECTS
       
  3602     if ( sliderValue == oldSliderValue )
       
  3603         {
       
  3604         StartTimerL();
       
  3605         }
       
  3606 #endif
       
  3607 
       
  3608     if ( sliderValue != oldSliderValue )
       
  3609         {
       
  3610         if( aFeedback )
       
  3611             {
       
  3612             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3613             if ( feedback )
       
  3614                {
       
  3615                feedback->InstantFeedback( this, ETouchFeedbackSlider );
       
  3616                }          
       
  3617             }
       
  3618 
       
  3619         Window().Invalidate( Rect() );
       
  3620         }
       
  3621     }    
       
  3622 
       
  3623 
       
  3624 // ----------------------------------------------------------------------------
       
  3625 // CAknSlider::GetMarkerRect
       
  3626 //
       
  3627 // Returns the marker rectangle (the knob). Note that this is not equal to
       
  3628 // iMarkerArea.
       
  3629 // ----------------------------------------------------------------------------
       
  3630 //
       
  3631 void CAknSlider::GetMarkerRect( TRect& aRect ) const
       
  3632     {
       
  3633     aRect = TRect( MarkerPos(), MarkerSize());
       
  3634     }
       
  3635 
       
  3636 
       
  3637 // ----------------------------------------------------------------------------
       
  3638 // CAknSlider::MarkerSize
       
  3639 //
       
  3640 // Returns the marker size (the knob). Note that this is not equal to
       
  3641 // iMarkerArea.Size(). 
       
  3642 // ----------------------------------------------------------------------------
       
  3643 //
       
  3644 TSize CAknSlider::MarkerSize() const
       
  3645     {
       
  3646     return iExt->iThumbRect.Size();
       
  3647     }
       
  3648 
       
  3649 
       
  3650 // ----------------------------------------------------------------------------
       
  3651 // CAknSlider::MarkerPos
       
  3652 //
       
  3653 // Returns the marker position (knob). Note that this is not equal to
       
  3654 // iMarkerArea.iTl. 
       
  3655 // ----------------------------------------------------------------------------
       
  3656 //
       
  3657 TPoint CAknSlider::MarkerPos() const
       
  3658     {
       
  3659     TPoint p;
       
  3660 
       
  3661     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal ) )
       
  3662         {
       
  3663         TSize markerSize( MarkerSize() );
       
  3664         TInt pixelRange = iMarkerArea.Width() - markerSize.iWidth;
       
  3665         TInt pos = ( pixelRange * ( iValue - MinimumValue() ) / Range() );
       
  3666         
       
  3667         if ( AknLayoutUtils::PenEnabled() && 
       
  3668              iMarkerArea.Contains( iExt->iPenInputPos ) &&
       
  3669              &Window() != NULL )
       
  3670             {
       
  3671             if( !iExt->IsFlagSet( CAknSliderExtension::EFlagValueStepChange ) ||
       
  3672               ( iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) &&
       
  3673                 iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) ) )
       
  3674                 {
       
  3675                 p.iX = iExt->iPenInputPos.iX - ( markerSize.iWidth ) / 2;
       
  3676                 }
       
  3677             else
       
  3678                 {
       
  3679                 p.iX = iMarkerArea.iTl.iX + pos;
       
  3680                 }
       
  3681             } 
       
  3682         else
       
  3683             {
       
  3684             p.iX = iMarkerArea.iTl.iX + pos;
       
  3685             }       
       
  3686         p.iY = iMarkerArea.iTl.iY;
       
  3687         }
       
  3688     else
       
  3689         {
       
  3690         TSize markerSize( MarkerSize() );
       
  3691         TInt pixelRange = iMarkerArea.Height() - markerSize.iHeight;
       
  3692         TInt pos = ( pixelRange * ( iValue - MinimumValue() ) / Range() );
       
  3693         
       
  3694         p.iX = iMarkerArea.iTl.iX;
       
  3695         if ( AknLayoutUtils::PenEnabled() && 
       
  3696              iMarkerArea.Contains( iExt->iPenInputPos ) &&
       
  3697              &Window() != NULL )
       
  3698             {
       
  3699             if( !iExt->IsFlagSet( CAknSliderExtension::EFlagValueStepChange ) ||
       
  3700               ( iExt->IsFlagSet( CAknSliderExtension::EFlagDraggingThumb ) &&
       
  3701                 iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) ) )
       
  3702                 {
       
  3703                 p.iY = iExt->iPenInputPos.iY - ( markerSize.iHeight ) / 2;
       
  3704                 }
       
  3705             else
       
  3706                 {
       
  3707                 p.iY = iMarkerArea.iBr.iY - pos - markerSize.iHeight;
       
  3708                 }
       
  3709             }
       
  3710         else
       
  3711             {
       
  3712             p.iY = iMarkerArea.iBr.iY - pos - markerSize.iHeight;
       
  3713             } 
       
  3714         }
       
  3715     return p;
       
  3716     }
       
  3717 
       
  3718 
       
  3719 // ----------------------------------------------------------------------------
       
  3720 // CondBlit
       
  3721 //
       
  3722 // Helper C-function for conditional blitting, static to make the function
       
  3723 // visible to this compilation unit only.
       
  3724 // ----------------------------------------------------------------------------
       
  3725 //
       
  3726 inline static void CondBlit( CWindowGc& aGc, const TPoint& aPoint,
       
  3727         const CFbsBitmap* aBitmap, const TSize& aSourceSize,
       
  3728         const CFbsBitmap* aMask, TBool aInvertMask = ETrue )
       
  3729     {
       
  3730     const TPoint origin( 0, 0 );
       
  3731     
       
  3732     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  3733     aGc.SetPenStyle( CGraphicsContext::ENullPen );
       
  3734     aGc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
  3735     aGc.SetPenColor( AKN_LAF_COLOR( 0 ) );
       
  3736     
       
  3737     if ( aBitmap && aMask )
       
  3738         {
       
  3739         aGc.BitBltMasked( aPoint, aBitmap, 
       
  3740                           TRect( origin, aSourceSize ), 
       
  3741                           aMask, aInvertMask );
       
  3742         }
       
  3743     else if ( aBitmap )
       
  3744         {
       
  3745         aGc.BitBlt( aPoint, aBitmap, TRect( origin, aSourceSize) );
       
  3746         }
       
  3747     else
       
  3748         {
       
  3749         // If no bitmap resource, it doesn't need to render default color any more
       
  3750         /*aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  3751         aGc.SetBrushColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  3752         aGc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  3753         aGc.SetPenColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  3754         aGc.DrawRect( TRect( aPoint, aSourceSize ) );*/
       
  3755         }
       
  3756     }
       
  3757 
       
  3758 
       
  3759 // ----------------------------------------------------------------------------
       
  3760 // CAknSlider::DrawHorizontal
       
  3761 // ----------------------------------------------------------------------------
       
  3762 //
       
  3763 void CAknSlider::DrawHorizontal( TBool aDrawMarker ) const
       
  3764     {
       
  3765     CWindowGc& gc = SystemGc();
       
  3766     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  3767     gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
  3768     gc.SetPenColor( AKN_LAF_COLOR( 0 ) );
       
  3769 
       
  3770     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  3771     MAknsControlContext* cc = NULL;
       
  3772 
       
  3773     if ( AknsUtils::AvkonSkinEnabled() )
       
  3774         {
       
  3775         cc = AknsDrawUtils::ControlContext( this );
       
  3776         }
       
  3777 
       
  3778     if ( !FindBackground() )
       
  3779         {
       
  3780         AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
  3781         }
       
  3782     
       
  3783     // Don't draw slider in form view mode
       
  3784     if ( !( Layout() == EAknSettingsItemSliderLayout ||
       
  3785             Layout() == EAknSettingsItemSliderLayoutWithGraphics || 
       
  3786             Layout() == EAknSliderLayoutVertical ||
       
  3787             Layout() == EAknSliderLayoutHorizontal ||
       
  3788             iEditable ) )
       
  3789         {
       
  3790         return;
       
  3791         }
       
  3792 
       
  3793     DrawHorizontalLine( gc ); // Draw line and end caps
       
  3794 
       
  3795     // Draw the tick marks, if any
       
  3796     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagTickMarksEnabled ) )
       
  3797         {
       
  3798         DrawHorizontalTickMarks( gc );
       
  3799         }
       
  3800 
       
  3801     // Draw the marker
       
  3802     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagMarkerEnabled ) &&
       
  3803         aDrawMarker )
       
  3804         {
       
  3805         TRect rect;
       
  3806         TAknSliderGfx gfx;
       
  3807 
       
  3808         GetMarkerRect( rect );
       
  3809         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) )
       
  3810             {
       
  3811             FetchGfx( gfx, EElemMarkerSelected, rect.Size() );
       
  3812             }
       
  3813         else
       
  3814             {
       
  3815             FetchGfx( gfx, EElemMarker, rect.Size() );
       
  3816             }
       
  3817 
       
  3818         CondBlit( gc, rect.iTl, gfx.iRgb, rect.Size(), gfx.iMask, ETrue );
       
  3819         }
       
  3820    }
       
  3821 
       
  3822 
       
  3823 // ----------------------------------------------------------------------------
       
  3824 // CAknSlider::DrawVertical
       
  3825 // ----------------------------------------------------------------------------
       
  3826 //
       
  3827 void CAknSlider::DrawVertical( TBool aDrawMarker ) const
       
  3828     {
       
  3829     CWindowGc& gc = SystemGc();
       
  3830     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  3831     gc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
  3832     gc.SetPenColor( AKN_LAF_COLOR( 0 ) );
       
  3833     
       
  3834     // Don't draw slider in form view mode
       
  3835     if ( !( Layout() == EAknSettingsItemSliderLayout ||
       
  3836             Layout() == EAknSettingsItemSliderLayoutWithGraphics || 
       
  3837             Layout() == EAknSliderLayoutVertical||
       
  3838             Layout() == EAknSliderLayoutHorizontal ||
       
  3839             iEditable ) )
       
  3840         {
       
  3841         return;
       
  3842         }
       
  3843     
       
  3844     DrawVerticalLine( gc ); // Draw line and end caps
       
  3845 
       
  3846     // Draw the tick marks, if any
       
  3847     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagTickMarksEnabled ) )
       
  3848         {
       
  3849         DrawVerticalTickMarks( gc );
       
  3850         }
       
  3851 
       
  3852     // Draw the marker
       
  3853     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagMarkerEnabled ) &&
       
  3854         aDrawMarker )
       
  3855         {
       
  3856         TRect rect;
       
  3857         TAknSliderGfx gfx;
       
  3858 
       
  3859         GetMarkerRect( rect );
       
  3860         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagPointerDown ) )
       
  3861             {
       
  3862             FetchGfx( gfx, EElemMarkerSelected, rect.Size() );
       
  3863             }
       
  3864         else
       
  3865             {
       
  3866             FetchGfx( gfx, EElemMarker, rect.Size() );
       
  3867             }
       
  3868 
       
  3869         CondBlit( gc, rect.iTl, gfx.iRgb, rect.Size(), gfx.iMask, ETrue );
       
  3870         }
       
  3871     }
       
  3872 
       
  3873 
       
  3874 // ----------------------------------------------------------------------------
       
  3875 // CAknSlider::DrawHorizontalLine
       
  3876 // ----------------------------------------------------------------------------
       
  3877 //
       
  3878 void CAknSlider::DrawHorizontalLine( CWindowGc& aGc ) const
       
  3879     {
       
  3880     TPoint pos;
       
  3881     TSize size;
       
  3882     TAknSliderGfx gfx;
       
  3883 
       
  3884     TRect mrect;
       
  3885     GetMarkerRect( mrect );
       
  3886     TInt markerW2 = mrect.Width() / 2;
       
  3887     
       
  3888     // End caps and line use the same height
       
  3889     size = iExt->iLeftCapRect.Size();
       
  3890         
       
  3891     // Draw the left cap, if any
       
  3892     if ( iExt->iLeftCapRect.Size().iWidth > 0 )
       
  3893         {
       
  3894         pos = iExt->iLeftCapRect.iTl;        
       
  3895         FetchGfx( gfx, EElemEmptyLeftCap, size );
       
  3896         CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  3897 
       
  3898         // Fill the left cap if needed
       
  3899         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) && 
       
  3900              iValue != MinimumValue())
       
  3901             {
       
  3902             FetchGfx( gfx, EElemFilledLeftCap, size );
       
  3903             CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  3904             }
       
  3905         }
       
  3906 
       
  3907     // Draw the right cap, if any
       
  3908     if ( iExt->iRightCapRect.Size().iWidth > 0 )
       
  3909         {
       
  3910         pos = iExt->iRightCapRect.iTl; 
       
  3911         FetchGfx( gfx, EElemEmptyRightCap, size );
       
  3912         CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  3913 
       
  3914         // Fill the right cap if needed
       
  3915         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) &&
       
  3916              iValue >= MaximumValue() )
       
  3917             {
       
  3918             FetchGfx( gfx, EElemFilledRightCap, size );
       
  3919             CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  3920             }
       
  3921         }
       
  3922 
       
  3923     // Draw the line
       
  3924     FetchGfx( gfx, EElemEmptyLine, iLineRect.Size() );
       
  3925     CondBlit( aGc, iLineRect.iTl, gfx.iRgb, iLineRect.Size(), gfx.iMask );
       
  3926 
       
  3927     // Draw the line filling, if any
       
  3928     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) )
       
  3929         {
       
  3930         if( Layout() == EAknSliderLayoutHorizontal )
       
  3931             {
       
  3932             //pos.SetXY( iLineRect.iTl.iX + mrect.Width(), mrect.iTl.iY );
       
  3933             pos.SetXY( iLineRect.iTl.iX, mrect.iTl.iY );
       
  3934             size  = iLineRect.Size();
       
  3935             FetchGfx( gfx, EElemFilledLine, size );
       
  3936             //size.iWidth = iLineRect.iBr.iX - ( mrect.iTl.iX + mrect.Width() );
       
  3937             size.iWidth = mrect.iTl.iX - iLineRect.iTl.iX;
       
  3938         
       
  3939         
       
  3940             if ( MaximumValue() == iValue )
       
  3941                 {
       
  3942                 pos = iLineRect.iTl;
       
  3943                 size.iWidth = iLineRect.Width();
       
  3944                 }
       
  3945             if ( MinimumValue() == iValue )
       
  3946                 {
       
  3947                 //pos.SetXY( iLineRect.iTl.iX, mrect.iTl.iY + markerH2/*iLineRect.iBr.iY*/ );
       
  3948                 //size.iHeight = size.iHeight - markerH2;
       
  3949                 }
       
  3950            
       
  3951             CondBlit( aGc, iLineRect.iTl, gfx.iRgb, size, gfx.iMask );
       
  3952             }
       
  3953         else
       
  3954             {
       
  3955             size.iWidth = mrect.iTl.iX + markerW2 - iLineRect.iTl.iX ;
       
  3956             FetchGfx( gfx, EElemFilledLine, size );
       
  3957             if ( MaximumValue() == iValue )
       
  3958                 {
       
  3959                 size.iWidth = iLineRect.Width();
       
  3960                 }
       
  3961 
       
  3962         CondBlit( aGc, iLineRect.iTl, gfx.iRgb, size, gfx.iMask );
       
  3963             }
       
  3964         }
       
  3965     }
       
  3966 
       
  3967 // ----------------------------------------------------------------------------
       
  3968 // RectBlit
       
  3969 //
       
  3970 // Helper C-function for conditional blitting, static to make the function
       
  3971 // visible to this compilation unit only.
       
  3972 // ----------------------------------------------------------------------------
       
  3973 //
       
  3974 inline static void RectBlit( CWindowGc& aGc, const TPoint& aTl,
       
  3975         const TSize& aSize, const TInt aPosY,
       
  3976         const CFbsBitmap* aBitmap, const CFbsBitmap* aMask )
       
  3977     {
       
  3978     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
  3979     aGc.SetPenStyle( CGraphicsContext::ENullPen );
       
  3980     aGc.SetBrushColor( AKN_LAF_COLOR( 0 ) );
       
  3981     aGc.SetPenColor( AKN_LAF_COLOR( 0 ) );
       
  3982     
       
  3983     if ( aBitmap && aMask )
       
  3984         {
       
  3985         aGc.BitBltMasked( aTl,
       
  3986                           aBitmap,
       
  3987                           TRect( TPoint( 0, aPosY ),
       
  3988                                  TSize( aSize.iWidth, aSize.iHeight - aPosY ) ),
       
  3989                           aMask,
       
  3990                           ETrue );
       
  3991         }
       
  3992     else if ( aBitmap )
       
  3993         {
       
  3994         aGc.BitBlt( aTl,
       
  3995                     aBitmap,
       
  3996                     TRect( TPoint(0, aPosY),
       
  3997                            TSize( aSize.iWidth, aSize.iHeight - aPosY ) ) );
       
  3998         }
       
  3999     else
       
  4000         {
       
  4001         // If no bitmap resource, it doesn't need to render default color any more
       
  4002         /*aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  4003         aGc.SetBrushColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  4004         aGc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  4005         aGc.SetPenColor( AKN_LAF_COLOR( KAknSliderDefaultDrawColor ) );
       
  4006         aGc.DrawRect( TRect( aTl, TSize( aSize.iWidth, aSize.iHeight - aPosY ) ) );*/
       
  4007         }
       
  4008     }
       
  4009 
       
  4010 
       
  4011 // ----------------------------------------------------------------------------
       
  4012 // CAknSlider::DrawVerticalLine
       
  4013 // ----------------------------------------------------------------------------
       
  4014 //
       
  4015 void CAknSlider::DrawVerticalLine( CWindowGc& aGc ) const
       
  4016     {
       
  4017     TPoint pos;
       
  4018     TSize size;
       
  4019     TAknSliderGfx gfx;
       
  4020 
       
  4021     TRect mrect;
       
  4022     GetMarkerRect( mrect );
       
  4023 
       
  4024     TInt markerH2 = mrect.Height() / 2;
       
  4025     TInt fromTop(0);
       
  4026 
       
  4027     // End caps and line use the same width
       
  4028     size = iExt->iLeftCapRect.Size();
       
  4029 
       
  4030     // Draw the bottom cap, if any
       
  4031     if ( iExt->iLeftCapRect.Size().iWidth > 0 )
       
  4032         {
       
  4033         pos = iExt->iLeftCapRect.iTl;
       
  4034         FetchGfx( gfx, EElemEmptyLeftCap, size );
       
  4035         CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  4036 
       
  4037         // Fill the bottom cap if needed
       
  4038         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) )
       
  4039             {
       
  4040             //bottom cap filled when all the line filled
       
  4041             FetchGfx( gfx, EElemFilledLeftCap, size );
       
  4042             RectBlit( aGc, pos, size, fromTop,
       
  4043                       gfx.iRgb, gfx.iMask );
       
  4044             }
       
  4045         }
       
  4046 
       
  4047     // Draw the top cap, if any
       
  4048     if ( iExt->iRightCapRect.Size().iWidth > 0 )
       
  4049         {
       
  4050         pos = pos = iExt->iRightCapRect.iTl;
       
  4051 
       
  4052         FetchGfx( gfx, EElemEmptyRightCap, size );
       
  4053         CondBlit( aGc, pos, gfx.iRgb, size, gfx.iMask );
       
  4054 
       
  4055         if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) && 
       
  4056              iValue >= MaximumValue() )
       
  4057             {
       
  4058             FetchGfx( gfx, EElemFilledRightCap, size );
       
  4059             RectBlit( aGc, pos, size, fromTop, gfx.iRgb, gfx.iMask );
       
  4060             }
       
  4061         }
       
  4062         
       
  4063     // Draw the line
       
  4064     FetchGfx( gfx, EElemEmptyLine, iLineRect.Size() );
       
  4065     CondBlit( aGc, iLineRect.iTl, gfx.iRgb, iLineRect.Size(), gfx.iMask );
       
  4066 
       
  4067     // Draw the line filling, if any
       
  4068     if ( iExt->IsFlagSet( CAknSliderExtension::EFlagFillEnabled ) )
       
  4069         {
       
  4070         pos.SetXY( iLineRect.iTl.iX, mrect.iTl.iY + mrect.Height() );
       
  4071         size  = iLineRect.Size();
       
  4072         FetchGfx( gfx, EElemFilledLine, size );
       
  4073         size.iHeight = iLineRect.iBr.iY - ( mrect.iTl.iY + mrect.Height() );
       
  4074         
       
  4075         
       
  4076         if ( MaximumValue() == iValue )
       
  4077             {
       
  4078             pos = iLineRect.iTl;
       
  4079             size.iHeight = iLineRect.Height();
       
  4080             }
       
  4081         if ( MinimumValue() == iValue )
       
  4082             {
       
  4083             //pos.SetXY( iLineRect.iTl.iX, mrect.iTl.iY + markerH2/*iLineRect.iBr.iY*/ );
       
  4084             //size.iHeight = size.iHeight - markerH2;
       
  4085             }
       
  4086         RectBlit( aGc, pos, iLineRect.Size(),
       
  4087                   iLineRect.Height() - size.iHeight,
       
  4088                   gfx.iRgb, gfx.iMask );
       
  4089         }
       
  4090     }
       
  4091 
       
  4092 
       
  4093 // ----------------------------------------------------------------------------
       
  4094 // CAknSlider::FetchGfx
       
  4095 // ----------------------------------------------------------------------------
       
  4096 //
       
  4097 void CAknSlider::FetchGfx(
       
  4098         TAknSliderGfx& aGfx, TInt aElement, const TSize& aSize ) const
       
  4099     {
       
  4100     if ( aElement < 0 || aElement > EElemMarkerSelected )
       
  4101         {
       
  4102         Panic( EAknPanicInvalidValue );
       
  4103         }
       
  4104 
       
  4105     TScaleMode mode = EAspectRatioNotPreserved; // default ratio
       
  4106     
       
  4107     // Step 1: Check if custom graphics have been defined for this element.
       
  4108     if ( !iExt->UsesDefaultGraphics( aElement ) || 
       
  4109           Layout() == EAknSliderLayoutVertical ||
       
  4110           Layout() == EAknSliderLayoutHorizontal )
       
  4111         {
       
  4112         iExt->GetGfx( aGfx, aElement );
       
  4113         if ( ( aElement == EElemEmptyLine ) || ( aElement == EElemFilledLine ) )
       
  4114             {
       
  4115             mode = EAspectRatioNotPreserved;
       
  4116             }
       
  4117         
       
  4118         if ( aGfx.iRgb )
       
  4119             {
       
  4120             AknIconUtils::SetSize( aGfx.iRgb, aSize, mode );
       
  4121             }
       
  4122         if ( aGfx.iMask )
       
  4123             {
       
  4124             AknIconUtils::SetSize( aGfx.iMask, aSize, mode );
       
  4125             }
       
  4126             
       
  4127         return;
       
  4128         }
       
  4129     else
       
  4130         {
       
  4131         aGfx.iRgb = NULL;
       
  4132         aGfx.iMask = NULL;
       
  4133         }
       
  4134         
       
  4135     // Step 2: No custom graphics, try Avkon icons.    
       
  4136     if( Layout() != EAknSliderLayoutVertical && Layout() != EAknSliderLayoutHorizontal )//vertical is always customized
       
  4137        {
       
  4138         if ( EElemEmptyLine == aElement )
       
  4139             {
       
  4140             aGfx.iRgb = iExt->iLineIcon;
       
  4141             aGfx.iMask = iExt->iLineIconMask;
       
  4142             }
       
  4143         else if ( EElemMarker == aElement ||
       
  4144                   EElemMarkerSelected == aElement )
       
  4145             {
       
  4146             aGfx.iRgb = iMarkerBmp;
       
  4147             aGfx.iMask = iMarkerMaskBmp;
       
  4148             }
       
  4149         }
       
  4150 
       
  4151     //resize the graphic    
       
  4152     if ( aGfx.iRgb )
       
  4153         {
       
  4154         AknIconUtils::SetSize( aGfx.iRgb, aSize, mode );
       
  4155         }
       
  4156     if ( aGfx.iMask )
       
  4157         {
       
  4158         AknIconUtils::SetSize( aGfx.iMask, aSize, mode );
       
  4159         }
       
  4160 
       
  4161     }
       
  4162 
       
  4163 // ----------------------------------------------------------------------------
       
  4164 // CAknSlider::EnableDrag
       
  4165 // ----------------------------------------------------------------------------
       
  4166 //
       
  4167 EXPORT_C void CAknSlider::EnableDrag()
       
  4168     {
       
  4169     EnableDragEvents();
       
  4170     }
       
  4171 
       
  4172 // ----------------------------------------------------------------------------
       
  4173 // CAknSlider::SetLabelColor
       
  4174 // ----------------------------------------------------------------------------
       
  4175 //
       
  4176 
       
  4177 void CAknSlider::SetLabelColor()
       
  4178     {
       
  4179     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  4180     TRgb color;
       
  4181     TInt error;
       
  4182     if ( Layout() != EAknSettingsItemSliderLayout &&
       
  4183          Layout() != EAknSettingsItemSliderLayoutWithGraphics  &&
       
  4184          Layout() != EAknSliderLayoutVertical &&
       
  4185          Layout() != EAknSliderLayoutHorizontal ) 
       
  4186         {
       
  4187         error = AknsUtils::GetCachedColor( skin, color,
       
  4188                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG8 );
       
  4189         }
       
  4190     else
       
  4191         {
       
  4192         error = AknsUtils::GetCachedColor( skin, color,
       
  4193                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG7 );
       
  4194         }
       
  4195 
       
  4196     if ( !error )
       
  4197         {
       
  4198         // ignore error
       
  4199         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  4200                         *iMinLabel, EColorLabelText, color ) );
       
  4201         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  4202                         *iMaxLabel, EColorLabelText, color ) );
       
  4203         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  4204                         *iValueLabel, EColorLabelText, color ) );
       
  4205         }
       
  4206 
       
  4207     AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnLineColors,
       
  4208                                EAknsCIQsnLineColorsCG8 );
       
  4209     iColor = color;
       
  4210     }
       
  4211 
       
  4212 // ----------------------------------------------------------------------------
       
  4213 // CAknSlider::ReportMarkerDragEvent
       
  4214 // ----------------------------------------------------------------------------
       
  4215 //
       
  4216 void CAknSlider::ReportMarkerDragEvent( TBool aEnable )
       
  4217     {
       
  4218     iExt->iReportMarkerDragEvent = aEnable;
       
  4219     }
       
  4220 
       
  4221 void CAknSlider::SuppressDrawing( TBool aSuppress )
       
  4222     {
       
  4223     iExt->iNoDraw = aSuppress;
       
  4224     }
       
  4225 
       
  4226 // ----------------------------------------------------------------------------
       
  4227 // CAknSlider::FocusChanged
       
  4228 // ----------------------------------------------------------------------------
       
  4229 //
       
  4230 EXPORT_C void CAknSlider::FocusChanged(TDrawNow /*aDrawNow*/)
       
  4231     {
       
  4232     if ( !IsFocused() )
       
  4233         {
       
  4234         iExt->ClearFlag( CAknSliderExtension::EFlagPointerDown );
       
  4235         iExt->ClearFlag( CAknSliderExtension::EFlagDraggingThumb );
       
  4236         // Marker icon changes - draw
       
  4237         if ( !iExt->iNoDraw )
       
  4238             {
       
  4239             DrawDeferred();    
       
  4240             }
       
  4241         }
       
  4242     }
       
  4243 
       
  4244 // ----------------------------------------------------------------------------
       
  4245 // CAknSlider::StartFeedback
       
  4246 // ----------------------------------------------------------------------------
       
  4247 //
       
  4248 void CAknSlider::StartFeedback( const TPointerEvent* aPointerEvent, TTimeIntervalMicroSeconds32 aTimeout )
       
  4249     {
       
  4250     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  4251     if ( feedback )
       
  4252         {
       
  4253         TInt intensity = KStableFeedbackIntesity;
       
  4254         if ( SliderData()->iFeedbackStyle == EAknSliderFbDynamic )
       
  4255             {
       
  4256             intensity = FeedbackIntensity();
       
  4257             }
       
  4258         feedback->StartFeedback( this, ETouchContinuousSlider, aPointerEvent, intensity, aTimeout );
       
  4259         iExt->SetFlag( CAknSliderExtension::EFlagPlayingContinuousFb );
       
  4260         }
       
  4261     }
       
  4262 
       
  4263 // ----------------------------------------------------------------------------
       
  4264 // CAknSlider::StopFeedback
       
  4265 // ----------------------------------------------------------------------------
       
  4266 //
       
  4267 void CAknSlider::StopFeedback() 
       
  4268     {
       
  4269     iExt->ClearFlag( CAknSliderExtension::EFlagPlayingContinuousFb );
       
  4270     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  4271     if ( feedback )
       
  4272         {
       
  4273         feedback->StopFeedback( this );
       
  4274         }
       
  4275     }
       
  4276 
       
  4277 // ----------------------------------------------------------------------------
       
  4278 // CAknSlider::ModifyFeedback
       
  4279 // ----------------------------------------------------------------------------
       
  4280 //
       
  4281 void CAknSlider::ModifyFeedback() 
       
  4282     {
       
  4283     TInt intensity = FeedbackIntensity();
       
  4284     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  4285     if ( feedback )
       
  4286         {
       
  4287         feedback->ModifyFeedback( this, intensity );
       
  4288         }
       
  4289     }
       
  4290 
       
  4291 
       
  4292 // ----------------------------------------------------------------------------
       
  4293 // CAknSlider::FeedbackIntensity
       
  4294 // ----------------------------------------------------------------------------
       
  4295 //
       
  4296 TInt CAknSlider::FeedbackIntensity() 
       
  4297     {
       
  4298     TRect mrect;
       
  4299     GetMarkerRect( mrect );
       
  4300     TBool hor = iExt->IsFlagSet( CAknSliderExtension::EFlagHorizontal );
       
  4301 
       
  4302     if ( hor )
       
  4303         {
       
  4304         TInt position = mrect.iTl.iX  - iMarkerArea.iTl.iX;
       
  4305         return TReal( position )/TReal( iMarkerArea.Width()-mrect.Width() )*100;    
       
  4306         }
       
  4307     else
       
  4308         {
       
  4309         TInt position = iMarkerArea.iBr.iY - mrect.iBr.iY;
       
  4310         return TReal( position )/TReal( iMarkerArea.Height()-mrect.Height() )*100;    
       
  4311         }
       
  4312     }
       
  4313 
       
  4314 
       
  4315 // ---------------------------------------------------------------------------
       
  4316 // Provides the touch active area for setting page slider.
       
  4317 // ---------------------------------------------------------------------------
       
  4318 //
       
  4319 TRect CAknSlider::TouchActiveArea() const
       
  4320     {
       
  4321     TRect touchActiveArea;
       
  4322     TPoint winPosition( Window().AbsPosition() );
       
  4323 
       
  4324     TRect appRect;
       
  4325     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  4326                                        appRect );
       
  4327     TAknLayoutRect mainpaneRect;
       
  4328     mainpaneRect.LayoutRect( appRect, AknLayoutScalable_Apps::main_pane(3) );
       
  4329     touchActiveArea = mainpaneRect.Rect();
       
  4330 
       
  4331     // Convert main pane rect location to slider window coordinates
       
  4332     touchActiveArea.Move(
       
  4333             touchActiveArea.iTl.iX - winPosition.iX,
       
  4334             touchActiveArea.iTl.iY - winPosition.iY );
       
  4335     return touchActiveArea;
       
  4336     }
       
  4337 
       
  4338 //  End of File
       
  4339