uifw/AvKon/src/AknVolumePopup.cpp
changeset 0 2f259fa3e83a
child 29 a8834a2e9a96
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  Popup Volume indicator
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "AknVolumePopup.h"
       
    22 #include <apgwgnam.h>
       
    23 #include <eiklabel.h>
       
    24 #include <StringLoader.h>
       
    25 #include <barsread.h>
       
    26 #include <Aknvolumecontrol.h>
       
    27 #include <AknUtils.h>
       
    28 #include <AknsDrawUtils.h>
       
    29 #include <aknconsts.h>
       
    30 #include <aknappui.h>
       
    31 #include <aknslider.h>
       
    32 #include <aknlayoutscalable_avkon.cdl.h>
       
    33 #include <aknlayoutscalable_apps.cdl.h>
       
    34 #include <layoutmetadata.cdl.h>
       
    35 #include <skinlayout.cdl.h>
       
    36 #include <avkon.mbg>
       
    37 #include <aknbutton.h>
       
    38 #include <e32math.h>
       
    39 #include <AknPanic.h>
       
    40 #include <gulicon.h>
       
    41 #include <AknsFrameBackgroundControlContext.h>
       
    42 #include <AknWsEventObserver.h>
       
    43 #include <AknStatuspaneUtils.h>
       
    44 
       
    45 #include <touchfeedback.h>
       
    46 #include <AknTasHook.h>
       
    47 const TInt KSliderUsed = 0xffff;
       
    48 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
       
    49 const TReal KWidthSpace = 1.3;
       
    50 // ============================ MEMBER FUNCTIONS =============================
       
    51 
       
    52 // ============================================================================
       
    53 NONSHARABLE_CLASS( CAknVolumePopupExtension ): public CBase,
       
    54                                                public MAknWsEventObserver
       
    55     {
       
    56 public:
       
    57 
       
    58 private:
       
    59     CAknVolumePopupExtension();
       
    60     void ConstructL();
       
    61 
       
    62 public:
       
    63     ~CAknVolumePopupExtension();
       
    64     static CAknVolumePopupExtension* NewL();
       
    65     CAknControl* VolumeControl();
       
    66 
       
    67     void SetGraphics( TInt aElement, 
       
    68                       CFbsBitmap* aBitmap, 
       
    69                       CFbsBitmap* aMask );
       
    70                   
       
    71     void TryLoadDefaultSliderVolumeBitmap();               
       
    72     void TryLoadDefaultHorizontalVolumeBitmap(); 
       
    73     
       
    74     // from MAknWsEventObserver
       
    75     void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination);
       
    76 public:
       
    77     CAknVolumeControl*  iOldVolumeControl;
       
    78     CAknSlider*         iSliderControl;
       
    79     TSize iMarkerSize;
       
    80     CAknsFrameBackgroundControlContext* iBgContext;
       
    81     TBool iUseMutedIcon;
       
    82     TBool iSpeakerHidden;
       
    83     TInt iSliderUsed;
       
    84     
       
    85     CAknVolumePopup* iParent;
       
    86     TBool iClosePopupWhenTapped;
       
    87     TBool iHaveDefaultValue;
       
    88     TInt iDefaultValue;
       
    89     TBool iResetDefaultValue;
       
    90     TBool iInitialized;
       
    91     TBool iHandlingPointerEvent;
       
    92     TBool iWindowGroupCreated;
       
    93 private:
       
    94 
       
    95     TBitFlags32 iFlags;
       
    96     };
       
    97     
       
    98 // ----------------------------------------------------------------------------
       
    99 // CAknVolumePopupExtension::CAknVolumePopupExtension
       
   100 // ----------------------------------------------------------------------------
       
   101 //
       
   102 CAknVolumePopupExtension::CAknVolumePopupExtension()
       
   103     : iUseMutedIcon(ETrue),
       
   104       iClosePopupWhenTapped(ETrue),
       
   105       iHaveDefaultValue(EFalse), 
       
   106       iDefaultValue(-1),
       
   107       iResetDefaultValue(ETrue)
       
   108     {
       
   109     }
       
   110     
       
   111 // ----------------------------------------------------------------------------
       
   112 // Destructor
       
   113 // ----------------------------------------------------------------------------
       
   114 //
       
   115 CAknVolumePopupExtension::~CAknVolumePopupExtension()
       
   116     {
       
   117     delete iSliderControl;
       
   118     delete iOldVolumeControl;
       
   119     delete iBgContext;
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------------------------
       
   123 // CAknVolumePopupExtension::NewL
       
   124 // ----------------------------------------------------------------------------
       
   125 //
       
   126 CAknVolumePopupExtension* CAknVolumePopupExtension::NewL()
       
   127     {
       
   128     
       
   129     CAknVolumePopupExtension* self = new( ELeave ) CAknVolumePopupExtension();
       
   130     CleanupStack::PushL( self );
       
   131     self->ConstructL();
       
   132     CleanupStack::Pop( self );
       
   133     return self;
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
       
   137 // CAknVolumePopupExtension::ConstructL
       
   138 // ----------------------------------------------------------------------------
       
   139 //
       
   140 void CAknVolumePopupExtension::ConstructL()
       
   141     {
       
   142     }
       
   143 // ----------------------------------------------------------------------------
       
   144 // CAknVolumePopupExtension::VolumeControl
       
   145 // ----------------------------------------------------------------------------
       
   146 // 
       
   147 CAknControl* CAknVolumePopupExtension::VolumeControl()
       
   148         {
       
   149         if( iSliderUsed == KSliderUsed )
       
   150             {
       
   151             return iSliderControl;
       
   152             }
       
   153         return iOldVolumeControl;
       
   154         } 
       
   155 // ----------------------------------------------------------------------------
       
   156 // CAknVolumePopupExtension::SetGraphics
       
   157 // ----------------------------------------------------------------------------
       
   158 //
       
   159 void CAknVolumePopupExtension::SetGraphics( TInt aElement, 
       
   160                                        CFbsBitmap* aBitmap, 
       
   161                                        CFbsBitmap* aMask )
       
   162     {
       
   163     // element index is assumed to be valid (no checking)
       
   164 
       
   165     if( aElement >= CAknSlider::EElemEmptyLeftCap && 
       
   166         aElement <= CAknSlider::EElemMarkerSelected )
       
   167         {
       
   168         iSliderControl->SetGraphics( aElement , aBitmap, aMask );
       
   169         }
       
   170     }
       
   171   
       
   172 // ----------------------------------------------------------------------------
       
   173 // CAknVolumePopupExtension::TryLoadDefaultSliderVolumeBitmap
       
   174 //
       
   175 // ----------------------------------------------------------------------------
       
   176 //     
       
   177 void CAknVolumePopupExtension::TryLoadDefaultSliderVolumeBitmap()
       
   178     {
       
   179     iSliderControl->SetGraphics( CAknSlider::EElemTickMark, NULL, NULL );
       
   180     }                         
       
   181 // ----------------------------------------------------------------------------
       
   182 // CAknVolumePopupExtension::TryLoadDefaultHorizontalVolumeBitmap
       
   183 //
       
   184 // ----------------------------------------------------------------------------
       
   185 //     
       
   186 void CAknVolumePopupExtension::TryLoadDefaultHorizontalVolumeBitmap()
       
   187     {
       
   188     const TInt iconIDArray[] = 
       
   189         {
       
   190         EMbmAvkonQgn_graf_volume_small_off,        
       
   191         EMbmAvkonQgn_graf_volume_small_on,
       
   192         EMbmAvkonQgn_graf_nslider_marker,
       
   193         EMbmAvkonQgn_graf_nslider_marker_selected
       
   194         };
       
   195     const TInt iconMaskIDArray[] = 
       
   196         {
       
   197         EMbmAvkonQgn_graf_volume_small_off_mask,        
       
   198         EMbmAvkonQgn_graf_volume_small_on_mask,
       
   199         EMbmAvkonQgn_graf_nslider_marker_mask,
       
   200         EMbmAvkonQgn_graf_nslider_marker_selected_mask
       
   201         }; 
       
   202     const TAknsItemID iconSkinIDArray[] = 
       
   203         {
       
   204         KAknsIIDQgnGrafVolumeSmallOff,        
       
   205         KAknsIIDQgnGrafVolumeSmallOn,
       
   206         KAknsIIDQgnGrafNsliderMarker,
       
   207         KAknsIIDQgnGrafNsliderMarkerSelected
       
   208         };
       
   209         
       
   210     const TInt element[] = 
       
   211         {
       
   212         CAknSlider::EElemEmptyLine,
       
   213         CAknSlider::EElemFilledLine,
       
   214         CAknSlider::EElemMarker,
       
   215         CAknSlider::EElemMarkerSelected
       
   216         };
       
   217     TInt count = sizeof( iconIDArray )/sizeof(TInt);
       
   218     
       
   219     TInt err = KErrNone;
       
   220     CFbsBitmap* bitmapPtr = NULL;
       
   221     CFbsBitmap* maskPtr = NULL;    
       
   222     for ( TInt i = 0; i < count; i++ )
       
   223         {
       
   224         //find new graphic from Skinned bitmap
       
   225         TRAP(err, AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
   226             iconSkinIDArray[i],
       
   227             bitmapPtr,
       
   228             maskPtr,
       
   229             KNullDesC,
       
   230             iconIDArray[i],
       
   231             iconMaskIDArray[i] ));
       
   232 
       
   233         // find new graphic from mif file
       
   234        if ( err )
       
   235             {
       
   236              TRAP(err,AknIconUtils::CreateIconL(
       
   237                 bitmapPtr,
       
   238                 maskPtr,
       
   239                 KAvkonBitmapFile,
       
   240                 iconIDArray[i],
       
   241                 iconMaskIDArray[i] ));      
       
   242             } 
       
   243         if( !err )
       
   244             {
       
   245             iSliderControl->SetGraphics( element[i], bitmapPtr, maskPtr );
       
   246             }          
       
   247         }
       
   248     }   
       
   249     
       
   250 // ----------------------------------------------------------------------------
       
   251 // CAknVolumePopupExtension::HandleWsEventL
       
   252 // ----------------------------------------------------------------------------
       
   253 //    
       
   254 void CAknVolumePopupExtension::HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination)
       
   255     {
       
   256     if( aEvent.Type() == EEventPointer )
       
   257         {
       
   258         // Touch outside of volume popup, close volume popup
       
   259         if( iClosePopupWhenTapped && 
       
   260             aEvent.Pointer()->iType == TPointerEvent::EButton1Down &&
       
   261             aDestination != iParent )
       
   262             {
       
   263             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   264             if ( feedback )
       
   265                 {
       
   266                 feedback->InstantFeedback( ETouchFeedbackPopUp );
       
   267                 }
       
   268             iParent->CloseVolumePopup();
       
   269             }
       
   270         }
       
   271     }
       
   272     
       
   273 // ---------------------------------------------------------------------------
       
   274 // CAknVolumePopup::CAknVolumePopup
       
   275 //
       
   276 //
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 CAknVolumePopup::CAknVolumePopup(TInt aFlags):
       
   280     iFlags(aFlags),
       
   281     iAdjustmentIndicatorOn(ETrue),
       
   282     iVertical(EFalse),
       
   283     iTimeout(0)
       
   284     {
       
   285     }
       
   286 
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CAknVolumePopup::ConstructFromResourceL
       
   290 // 
       
   291 // ---------------------------------------------------------------------------
       
   292 //
       
   293 EXPORT_C CAknVolumePopup* CAknVolumePopup::ConstructFromResourceL(
       
   294                                                            TInt aResourceId )
       
   295     {
       
   296     // create volume control
       
   297     TResourceReader reader;
       
   298     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
       
   299 
       
   300     TInt flags = -1;
       
   301     TInt sliderType = reader.ReadInt16();
       
   302     if ( sliderType == EAknSliderWithFeedbackStyle )
       
   303         {
       
   304         TInt feedbackStyle = (TAknFeedbackStyle)reader.ReadInt16();
       
   305         flags = reader.ReadInt16();
       
   306         }
       
   307     else
       
   308         {
       
   309         flags = sliderType;
       
   310         }
       
   311     if( flags == -1) // 0xffff
       
   312         {
       
   313         flags = reader.ReadInt16();
       
   314         }        
       
   315 
       
   316     if( flags == ENaviPaneVolumeControl ||
       
   317         flags == EDynRangeNaviPaneVolumeControl ) 
       
   318         {
       
   319         CAknVolumePopup* self = new( ELeave ) CAknVolumePopup( KSliderUsed );
       
   320         CleanupStack::PopAndDestroy(); // reader
       
   321         CleanupStack::PushL( self );
       
   322         self->ConstructL( NULL, EFalse, aResourceId );
       
   323         CleanupStack::Pop();
       
   324         return self;   
       
   325         }
       
   326     else
       
   327         {
       
   328     	CAknVolumePopup* self = new( ELeave ) CAknVolumePopup(0);
       
   329     	CleanupStack::PopAndDestroy(); // reader
       
   330         CleanupStack::PushL( self );
       
   331         self->ConstructL( NULL, EFalse, aResourceId );
       
   332         CleanupStack::Pop();
       
   333         return self;    
       
   334         }
       
   335     }
       
   336     
       
   337 // ---------------------------------------------------------------------------
       
   338 // CAknVolumePopup::NewL
       
   339 //
       
   340 // ---------------------------------------------------------------------------
       
   341 //
       
   342 EXPORT_C CAknVolumePopup* CAknVolumePopup::NewL( CCoeControl* aParent,
       
   343                                                      TBool aIsVertical )
       
   344     {
       
   345     CAknVolumePopup* self = new( ELeave ) CAknVolumePopup(KSliderUsed);
       
   346     CleanupStack::PushL( self );
       
   347     
       
   348     if( aIsVertical )
       
   349         {
       
   350         self->ConstructL( aParent, ETrue, R_AVKON_VERTICAL_POPUP_SLIDER );
       
   351         }
       
   352     else
       
   353         {
       
   354         self->ConstructL( aParent, aIsVertical, R_AVKON_HORIZONTAL_POPUP_SLIDER );
       
   355         }
       
   356     CleanupStack::Pop();
       
   357     AKNTASHOOK_ADDL( self, "CAknVolumePopup" );
       
   358     return self;    
       
   359     }
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // CAknVolumePopup::ConstructL
       
   363 // Symbian 2nd phase constructor can leave.
       
   364 // ---------------------------------------------------------------------------
       
   365 //
       
   366 void CAknVolumePopup::ConstructL( CCoeControl* aParent, 
       
   367                                   TBool aIsVertical, 
       
   368                                   TInt aResourceId )
       
   369     {
       
   370     iExt = CAknVolumePopupExtension::NewL();
       
   371     iVertical = aIsVertical;
       
   372     iExt->iSliderUsed = iFlags;
       
   373     iExt->iParent = this;
       
   374    // create inactivity timer
       
   375     iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   376     
       
   377     // create volume control
       
   378     TResourceReader reader;
       
   379     iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
       
   380     TInt sliderType = reader.ReadInt16();
       
   381     if ( sliderType == EAknSliderWithFeedbackStyle )
       
   382         {
       
   383         TInt feedbackStyle = (TAknFeedbackStyle)reader.ReadInt16();
       
   384         iFlags = reader.ReadInt16();
       
   385         }
       
   386     else
       
   387         {
       
   388         iFlags = sliderType;
       
   389         }
       
   390     
       
   391     if( iFlags == -1) // 0xffff
       
   392         {
       
   393         iFlags = reader.ReadInt16();
       
   394         reader.Rewind( 2 );
       
   395         }
       
   396         
       
   397     reader.Rewind( 2 );
       
   398 
       
   399     if ( iFlags == EPopupVolumeControl )
       
   400         {
       
   401          //use the new style popup volume control
       
   402         iFlags = ESmallPopupVolumeControl;
       
   403         }
       
   404 
       
   405     if( !aParent && (iFlags == ENaviPaneVolumeControl ||
       
   406          iFlags == EDynRangeNaviPaneVolumeControl ))
       
   407         {
       
   408         CreateWindowL();
       
   409         DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
       
   410         }
       
   411     else if( !aParent )
       
   412         {
       
   413         // create a window group for volume popup
       
   414         // needed to prevent apps noticing this window
       
   415         RWsSession& wsSession = iCoeEnv->WsSession();
       
   416         iWindowGroup = RWindowGroup( wsSession );
       
   417         User::LeaveIfError( iWindowGroup.Construct( (TUint32) &iWindowGroup, EFalse ) );
       
   418         iWindowGroup.AutoForeground(EFalse);
       
   419 
       
   420         CApaWindowGroupName* name = CApaWindowGroupName::NewLC( wsSession,
       
   421                                                                 (TUint32) &iWindowGroup );
       
   422         name->SetHidden( ETrue );
       
   423         name->SetCaptionL( KVolumePopupWgName ); // FIXME - KSomeUniqueName, available to OOM watcher so this won't be closed
       
   424         User::LeaveIfError( name->SetWindowGroupName( iWindowGroup ));
       
   425         CleanupStack::PopAndDestroy();  //name
       
   426         iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront );
       
   427 
       
   428          // create control's window to own window group
       
   429         CreateWindowL( &iWindowGroup );
       
   430         
       
   431         //catch other windows poninter 
       
   432         Window().SetNonFading(ETrue); 
       
   433         iExt->iWindowGroupCreated = ETrue;
       
   434         }
       
   435     else
       
   436         {
       
   437         CreateWindowL( aParent );
       
   438         }
       
   439         
       
   440     if ( CAknEnv::Static()->TransparencyEnabled() )
       
   441         {
       
   442         Window().SetRequiredDisplayMode( EColor16MA );
       
   443         Window().SetTransparencyAlphaChannel();
       
   444         Window().SetBackgroundColor(TRgb(~0));
       
   445         }
       
   446     Window().SetShadowDisabled(ETrue);
       
   447     
       
   448     
       
   449     // Values received from the navi pane volume control resource.
       
   450     TInt value    = KErrNotFound;
       
   451     TInt minvalue = KErrNotFound;
       
   452     TInt maxvalue = KErrNotFound;
       
   453     if( iExt->iSliderUsed != KSliderUsed )
       
   454         {
       
   455         iExt->iOldVolumeControl = new( ELeave )CAknVolumeControl;
       
   456 
       
   457         if ( AknLayoutUtils::PenEnabled() )
       
   458             iExt->VolumeControl()->SetContainerWindowL(*this);
       
   459         
       
   460         iExt->iOldVolumeControl->ConstructFromResourceL(reader);	
       
   461         }
       
   462     else if( iVertical ||
       
   463          iFlags == ENaviPaneVolumeControl ||
       
   464          iFlags == EDynRangeNaviPaneVolumeControl )
       
   465         {
       
   466          //use the vertical slider
       
   467         iExt->iSliderControl = new( ELeave )CAknSlider;
       
   468         iExt->iSliderControl->SetBackground( this );
       
   469         
       
   470         if ( iFlags == ENaviPaneVolumeControl ||
       
   471              iFlags == EDynRangeNaviPaneVolumeControl )
       
   472             {
       
   473             // Navi pane shows vertical volume popup instead of the old navi
       
   474             // pane volume control, but the old style volume control must
       
   475             // be also created in order to preserve BC.
       
   476             
       
   477             // Read and set the initial value and range from the resource
       
   478             // before passing it to the CAknVolumeControl.
       
   479             TInt int16Length( sizeof( TInt16 ) );
       
   480             reader.Advance( int16Length ); // identifier or flags
       
   481             if ( iFlags == EDynRangeNaviPaneVolumeControl )
       
   482                 {
       
   483                 reader.Advance( int16Length ); // flags
       
   484                 }
       
   485 
       
   486             value = reader.ReadInt16();
       
   487             
       
   488             if ( iFlags == EDynRangeNaviPaneVolumeControl )
       
   489                 {
       
   490                 TPtrC filename = reader.ReadTPtrC();
       
   491                 
       
   492                 reader.Advance( 2 * int16Length ); // bitmap and mask ID
       
   493                 
       
   494                 minvalue = reader.ReadInt16();
       
   495                 maxvalue = reader.ReadInt16();
       
   496                 
       
   497                 reader.Rewind( 4 * int16Length );
       
   498                 reader.Rewind( filename.Size() + int16Length ); // filename + length heading
       
   499                 reader.Rewind( 3 * int16Length );
       
   500                 }
       
   501             else
       
   502                 {
       
   503                 reader.Rewind( 2 * int16Length );
       
   504                 }
       
   505             
       
   506             iVertical = ETrue;
       
   507             iExt->iOldVolumeControl = new ( ELeave ) CAknVolumeControl;
       
   508             iExt->iOldVolumeControl->SetContainerWindowL(*this);
       
   509             iExt->iOldVolumeControl->ConstructFromResourceL( reader );
       
   510             iExt->iOldVolumeControl->SuppressDrawing( ETrue );
       
   511             
       
   512             // Old volume control was created with the navi pane volume control
       
   513             // resource, slider resource is used to create the slider control.
       
   514             CleanupStack::PopAndDestroy(); // reader
       
   515             iCoeEnv->CreateResourceReaderLC( reader, R_AVKON_VERTICAL_POPUP_SLIDER );
       
   516             }
       
   517 
       
   518         if(AknLayoutUtils::PenEnabled())
       
   519             iExt->VolumeControl()->SetContainerWindowL(*this);
       
   520         iExt->iSliderControl->ConstructFromResourceL(this, 0, reader);
       
   521         iExt->TryLoadDefaultSliderVolumeBitmap();
       
   522         iExt->iSliderControl->ReportMarkerDragEvent( ETrue );
       
   523         iExt->iSliderControl->SuppressDrawing( ETrue );
       
   524        }           
       
   525     else
       
   526         {
       
   527         iExt->iSliderControl = new( ELeave )CAknSlider;
       
   528         iExt->iSliderControl->SetBackground( this );
       
   529 
       
   530         if ( AknLayoutUtils::PenEnabled() )
       
   531             {
       
   532             iExt->VolumeControl()->SetContainerWindowL( *this );
       
   533             }
       
   534         
       
   535         iExt->iSliderControl->ConstructFromResourceL( this, 0, reader );
       
   536         iExt->TryLoadDefaultHorizontalVolumeBitmap();
       
   537         iExt->iSliderControl->ReportMarkerDragEvent( ETrue );
       
   538         iExt->iSliderControl->SuppressDrawing( ETrue );
       
   539         }   
       
   540     
       
   541     
       
   542     iExt->VolumeControl()->SetObserver( this );
       
   543     if ( iExt->iOldVolumeControl &&
       
   544          iExt->iOldVolumeControl != iExt->VolumeControl() )
       
   545         {
       
   546         // iOldVolumeControl is a navi pane volume control,
       
   547         // observer must be set.
       
   548         iExt->iOldVolumeControl->SetObserver( this );
       
   549         }
       
   550 
       
   551     CleanupStack::PopAndDestroy(); // reader
       
   552     if ( !( AknLayoutUtils::PenEnabled() ) )
       
   553         {
       
   554         iExt->VolumeControl()->SetContainerWindowL(*this);
       
   555         }
       
   556 
       
   557     // In case of volume popup launched from navi pane set the range
       
   558     // and value from resource before creating controls.
       
   559     if ( iFlags == ENaviPaneVolumeControl ||
       
   560          iFlags == EDynRangeNaviPaneVolumeControl )
       
   561         {
       
   562         if ( minvalue != KErrNotFound && maxvalue != KErrNotFound )
       
   563             {
       
   564             iExt->iSliderControl->SetRange( minvalue, maxvalue );
       
   565             }
       
   566             
       
   567         if ( value != KErrNotFound )
       
   568             {
       
   569             iVolume = value;
       
   570             iExt->iSliderControl->SetValueL( value );
       
   571             }
       
   572         }
       
   573 
       
   574     if( iExt->iSliderUsed == KSliderUsed )
       
   575         {
       
   576         iValueType = EAknSliderValueNone;
       
   577         }
       
   578     else
       
   579         {
       
   580         iValueType = EAknSliderValuePercentage;
       
   581         }
       
   582     CreateControlsL();
       
   583     SetVolumeLayout();
       
   584     // set default behavior
       
   585     ShowMuteAsLabel( ETrue );
       
   586 
       
   587     // Ensure the popup always gets resource change events via the control 
       
   588     // stack. Even if popup is not visible, it need to handle resource change
       
   589     // event to adjust position. So add popup to stack in its constructor.
       
   590     // Popup does not accept key event and keyboard focus.
       
   591     iAvkonAppUi->AddToStackL( this, ECoeStackPriorityDialog+1,
       
   592                               ECoeStackFlagRefusesFocus );
       
   593 
       
   594     SetVisibilityL(EFalse);    // to make CCoeControl::IsVisible() work
       
   595 
       
   596     iExt->iHaveDefaultValue = EFalse;
       
   597     iExt->iInitialized = ETrue;
       
   598     }
       
   599     
       
   600 // ---------------------------------------------------------------------------
       
   601 // CAknVolumePopup::CreateControlsL
       
   602 //
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 void CAknVolumePopup::CreateControlsL()
       
   606     {
       
   607     // create label controls
       
   608     delete iLabel;
       
   609     iLabel = NULL;
       
   610     iLabel = new(ELeave) CEikLabel;
       
   611     iLabel->SetContainerWindowL( *this );
       
   612     iLabel->SetObserver( this );
       
   613     SetLabelColor();  
       
   614     DoSetValue( Value() );
       
   615     
       
   616     if(iFlags == EPopupVolumeControl || iFlags == ESmallPopupVolumeControl)
       
   617         SetValueType(EAknSliderValuePercentage);
       
   618     
       
   619     SetValueTextL();
       
   620 
       
   621     
       
   622     CreateSpeakerL();      
       
   623 
       
   624     if( iFlags == ESmallPopupVolumeControl || 
       
   625         iFlags == ESmallPopupVolumeControlWithPercent ) 
       
   626         {
       
   627         TAknTextComponentLayout percentText = 
       
   628         AknLayoutScalable_Avkon::popup_side_volume_key_window_t2();
       
   629         CFont* font = NULL;
       
   630         AknLayoutUtils::FontFromId( percentText.Font(), font );
       
   631         iLabel->SetFont( font );                
       
   632         // create arrows here.
       
   633         CreateLeftRightButtonL();
       
   634         }
       
   635     else if ( iExt->iSliderUsed != KSliderUsed &&
       
   636               iFlags != ENaviPaneVolumeControl &&
       
   637               iFlags != EDynRangeNaviPaneVolumeControl )
       
   638         {
       
   639         delete iMutedLabel;
       
   640         iMutedLabel = NULL;
       
   641         iMutedLabel = new (ELeave) CEikLabel;
       
   642         iMutedLabel->SetContainerWindowL( *this );
       
   643         TRgb color;
       
   644         if ( iMutedLabel ) // Is not in use in every mode.
       
   645             {            
       
   646             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iMutedLabel,
       
   647                                                             EColorLabelText,
       
   648                                                             color) );
       
   649             }
       
   650         HBufC* txt = StringLoader::LoadL( R_AVKON_POPUP_VOLUME_MUTED, iCoeEnv );
       
   651         CleanupStack::PushL( txt );
       
   652         iMutedLabel->SetTextL( *txt );
       
   653         CleanupStack::PopAndDestroy(); // txt        
       
   654         }
       
   655 
       
   656     //create "+""-" for vertical slider
       
   657     if( iExt->iSliderUsed == KSliderUsed )
       
   658         {
       
   659         if ( iVertical )
       
   660             {               
       
   661             // create arrows here.
       
   662             CreateUpDownButtonL();
       
   663             }
       
   664         else 
       
   665             {               
       
   666             // create arrows here.
       
   667             CreateLeftRightButtonL();
       
   668             }
       
   669         }
       
   670     }
       
   671 // ---------------------------------------------------------------------------
       
   672 // CAknVolumePopup::SetSpeakerIconL
       
   673 //
       
   674 // ---------------------------------------------------------------------------
       
   675 //
       
   676 void CAknVolumePopup::CreateSpeakerL()
       
   677     {
       
   678     if (iSpeaker)
       
   679         {
       
   680         delete iSpeaker;
       
   681         iSpeaker = NULL;
       
   682         }
       
   683         
       
   684     CGulIcon* iconSpeaker  = CGulIcon::NewLC();
       
   685     CFbsBitmap* speakerBitmap;
       
   686     CFbsBitmap* speakerMask;
       
   687     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   688     if( iVertical && iExt->iSliderUsed )
       
   689         {
       
   690         AknsUtils::CreateColorIconL( skin,
       
   691                                      KAknsIIDQgnIndiNsliderUnmuted,
       
   692                                      KAknsIIDQsnTextColors,
       
   693                                      EAknsCIQsnTextColorsCG19,
       
   694                                      speakerBitmap,
       
   695                                      speakerMask,
       
   696                                      KAvkonBitmapFile,                                 
       
   697                                      EMbmAvkonQgn_indi_nslider_unmuted,
       
   698                                      EMbmAvkonQgn_indi_nslider_unmuted_mask,
       
   699                                      KRgbWhite );
       
   700         }
       
   701     else
       
   702         {
       
   703         AknsUtils::CreateColorIconL( skin,
       
   704                                      KAknsIIDQgnIndiSpeakerActive,
       
   705                                      KAknsIIDQsnTextColors,
       
   706                                      EAknsCIQsnTextColorsCG19,
       
   707                                      speakerBitmap,
       
   708                                      speakerMask,
       
   709                                      KAvkonBitmapFile,                                 
       
   710                                      EMbmAvkonQgn_indi_speaker,
       
   711                                      EMbmAvkonQgn_indi_speaker_mask,
       
   712                                      KRgbWhite );
       
   713         }
       
   714             
       
   715     iconSpeaker->SetBitmap( speakerBitmap );
       
   716     iconSpeaker->SetMask( speakerMask ); 
       
   717     TInt flag = KAknButtonStateHasLatchedFrame|KAknButtonNoFrame;
       
   718     if( !iExt->iUseMutedIcon )
       
   719         {
       
   720         flag = KAknButtonNoFrame;
       
   721         }
       
   722     //speaker button 
       
   723     iSpeaker = CAknButton::NewL( iconSpeaker, 
       
   724                               NULL,
       
   725                               NULL,
       
   726                               NULL, 
       
   727                               KNullDesC, 
       
   728                               KNullDesC, 
       
   729                               flag, 
       
   730                               0);
       
   731     CleanupStack::Pop();                          
       
   732     if( iExt->iUseMutedIcon )
       
   733         {
       
   734         CGulIcon* iconMute  = CGulIcon::NewLC();
       
   735         CFbsBitmap* muteBitmap;
       
   736         CFbsBitmap* muteMask;
       
   737         if( iVertical && iExt->iSliderUsed )
       
   738             {
       
   739             AknsUtils::CreateColorIconL(skin,
       
   740                                         KAknsIIDQgnIndiNsliderMuted,
       
   741                                         KAknsIIDQsnTextColors,
       
   742                                         EAknsCIQsnTextColorsCG19,
       
   743                                         muteBitmap,
       
   744                                         muteMask,
       
   745                                         KAvkonBitmapFile,                                 
       
   746                                         EMbmAvkonQgn_indi_nslider_muted,
       
   747                                         EMbmAvkonQgn_indi_nslider_muted_mask,
       
   748                                         KRgbWhite );
       
   749             }
       
   750         else
       
   751             {
       
   752             AknsUtils::CreateColorIconL(skin,
       
   753                                         KAknsIIDQgnIndiSpeakerMuted,
       
   754                                         KAknsIIDQsnTextColors,
       
   755                                         EAknsCIQsnTextColorsCG19,
       
   756                                         muteBitmap,
       
   757                                         muteMask,
       
   758                                         KAvkonBitmapFile,                                 
       
   759                                         EMbmAvkonQgn_indi_speaker_muted,
       
   760                                         EMbmAvkonQgn_indi_speaker_muted_mask,
       
   761                                         KRgbWhite );
       
   762             }
       
   763             
       
   764         iconMute->SetBitmap( muteBitmap );
       
   765         iconMute->SetMask( muteMask ); 
       
   766         iSpeaker->AddStateL( iconMute, 
       
   767                                   NULL,
       
   768                                   NULL,
       
   769                                   NULL, 
       
   770                                   KNullDesC, 
       
   771                                   KNullDesC, 
       
   772                                   1 );
       
   773                                                      
       
   774         CleanupStack::Pop();         
       
   775         }
       
   776 
       
   777     if( iSpeaker )
       
   778         {
       
   779         iSpeaker->SetContainerWindowL( *this );
       
   780         iSpeaker->SetObserver( this );        
       
   781         }
       
   782     } 
       
   783             
       
   784 // ---------------------------------------------------------------------------
       
   785 // CAknVolumePopup::SetSpeakerIconL
       
   786 //
       
   787 // ---------------------------------------------------------------------------
       
   788 //
       
   789 void CAknVolumePopup::SetControlIconL( TInt aElement,
       
   790                                        CFbsBitmap* aBitmap,
       
   791                                        CFbsBitmap* aMask )
       
   792     {
       
   793     CGulIcon* icon  = CGulIcon::NewLC();
       
   794     icon->SetBitmap( aBitmap );
       
   795     icon->SetMask( aMask ); 
       
   796 
       
   797     switch( aElement )
       
   798         {
       
   799         case EElemSpeaker:
       
   800             {
       
   801             CAknButtonState* state = iSpeaker->State(0);
       
   802             state->SetIcon( icon );
       
   803             }
       
   804             break;
       
   805         case EElemMute:
       
   806             {
       
   807             if( iExt->iUseMutedIcon)
       
   808                 {
       
   809                 CAknButtonState* state = iSpeaker->State(1);
       
   810                 state->SetIcon( icon );                
       
   811                 }
       
   812             }
       
   813             break;
       
   814         case EElemPlusButtonActive:
       
   815             {
       
   816             CAknButtonState* state = iIncArrow->State(0);
       
   817             state->SetIcon( icon );
       
   818             }
       
   819             break;
       
   820         case EElemMinusButtonActive:
       
   821             {
       
   822             CAknButtonState* state = iDecArrow->State(0);
       
   823             state->SetIcon( icon );
       
   824             }
       
   825             break;
       
   826         case EElemPlusButtonInActive:
       
   827             {
       
   828             CAknButtonState* state = iIncArrow->State(0);
       
   829             state->SetDimmedIcon( icon );
       
   830             }
       
   831             break;
       
   832         case EElemMinusButtonInActive:
       
   833             {
       
   834             CAknButtonState* state = iDecArrow->State(0);
       
   835             state->SetDimmedIcon( icon );
       
   836             }
       
   837             break;
       
   838         case EElemPlusButtonSelected:
       
   839             {
       
   840             CAknButtonState* state = iIncArrow->State(0);
       
   841             state->SetPressedIcon( icon );
       
   842             }
       
   843             break;
       
   844         case EElemMinusButtonSelected:
       
   845             {
       
   846             CAknButtonState* state = iDecArrow->State(0);
       
   847             state->SetPressedIcon( icon );
       
   848             }
       
   849             break;
       
   850         default:
       
   851            break;
       
   852         }
       
   853     CleanupStack::Pop();// the ownership of the icon is transfered to button.   	        
       
   854     }  
       
   855  
       
   856 // ---------------------------------------------------------------------------
       
   857 // CAknVolumePopup::CreateLeftRightButtonL
       
   858 //
       
   859 // ---------------------------------------------------------------------------
       
   860 //
       
   861 void CAknVolumePopup::CreateLeftRightButtonL()
       
   862     {
       
   863     if ( iDecArrow )
       
   864         {
       
   865         delete iDecArrow;
       
   866         iDecArrow = NULL;
       
   867         }
       
   868         
       
   869     if ( iIncArrow )
       
   870         {
       
   871         delete iIncArrow;
       
   872         iIncArrow = NULL;
       
   873         }
       
   874         
       
   875     iDecArrow = CAknButton::NewL( KAvkonBitmapFile, 
       
   876                                   EMbmAvkonQgn_indi_navi_arrow_left, 
       
   877                                   EMbmAvkonQgn_indi_navi_arrow_left_mask,
       
   878                                   -1, 
       
   879                                   -1,
       
   880                                   EMbmAvkonQgn_indi_navi_arrow_left, 
       
   881                                   EMbmAvkonQgn_indi_navi_arrow_left_mask,
       
   882                                   -1,
       
   883                                   -1,
       
   884                                   KNullDesC, 
       
   885                                   KNullDesC, 
       
   886                                   KAknButtonNoFrame | KAknButtonKeyRepeat | 
       
   887                                                         KAknButtonNoClear, 
       
   888                                   0,
       
   889                                   KAknsIIDQgnIndiNaviArrowLeft,
       
   890                                   KAknsIIDNone,
       
   891                                   KAknsIIDQgnIndiNaviArrowLeft
       
   892                                   );
       
   893     iDecArrow->SetContainerWindowL( *this );
       
   894     iDecArrow->SetObserver( this );
       
   895     
       
   896     iIncArrow = CAknButton::NewL( KAvkonBitmapFile, 
       
   897                                   EMbmAvkonQgn_indi_navi_arrow_right, 
       
   898                                   EMbmAvkonQgn_indi_navi_arrow_right_mask,
       
   899                                   -1, 
       
   900                                   -1,
       
   901                                   EMbmAvkonQgn_indi_navi_arrow_right, 
       
   902                                   EMbmAvkonQgn_indi_navi_arrow_right_mask,
       
   903                                   -1,
       
   904                                   -1,
       
   905                                   KNullDesC, 
       
   906                                   KNullDesC, 
       
   907                                   KAknButtonNoFrame | KAknButtonKeyRepeat | 
       
   908                                                         KAknButtonNoClear, 
       
   909                                   0,
       
   910                                   KAknsIIDQgnIndiNaviArrowRight,
       
   911                                   KAknsIIDNone,
       
   912                                   KAknsIIDQgnIndiNaviArrowRight
       
   913                                   );
       
   914     iIncArrow->SetContainerWindowL( *this );
       
   915     iIncArrow->SetObserver( this );                                          
       
   916     }
       
   917 // ---------------------------------------------------------------------------
       
   918 // CAknVolumePopup::CreateUpDownButtonL
       
   919 //
       
   920 // ---------------------------------------------------------------------------
       
   921 //
       
   922 void CAknVolumePopup::CreateUpDownButtonL()
       
   923     {
       
   924     if ( iDecArrow )
       
   925         {
       
   926         delete iDecArrow;
       
   927         iDecArrow = NULL;
       
   928         }
       
   929         
       
   930     if ( iIncArrow )
       
   931         {
       
   932         delete iIncArrow;
       
   933         iIncArrow = NULL;
       
   934         }
       
   935     if( iVertical && iExt->iSliderUsed )
       
   936         {
       
   937         CFbsBitmap* bitmap = NULL;
       
   938         CFbsBitmap* mask = NULL;
       
   939         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   940         AknsUtils::CreateColorIconL( skin,
       
   941                                      KAknsIIDQgnIndiNsliderLevelIncrease,
       
   942                                      KAknsIIDQsnTextColors,
       
   943                                      EAknsCIQsnTextColorsCG19,
       
   944                                      bitmap,
       
   945                                      mask, 
       
   946                                      KAvkonBitmapFile,
       
   947                                      EMbmAvkonQgn_indi_nslider_level_increase,
       
   948                                      EMbmAvkonQgn_indi_nslider_level_increase_mask,
       
   949                                      KRgbWhite ); 
       
   950 
       
   951         iIncArrow = CAknButton::NewL( CGulIcon::NewL( bitmap, mask ),  //aIcon
       
   952                                       NULL,                            //aDimmedIcon
       
   953                                       NULL,                            //aPressedIcon
       
   954                                       NULL,                            //aHoverIcon
       
   955                                       KNullDesC,                       //aText
       
   956                                       KNullDesC,                       //aHelpText
       
   957                                       KAknButtonNoFrame | KAknButtonNoClear | KAknButtonKeyRepeat,//aButtonFlags
       
   958                                       0                                //aStateFlags
       
   959                                      );
       
   960                                           
       
   961         iIncArrow->SetContainerWindowL( *this );
       
   962         iIncArrow->SetObserver( this );
       
   963         
       
   964         bitmap = NULL;
       
   965         mask = NULL;
       
   966         AknsUtils::CreateColorIconL( skin,
       
   967                                      KAknsIIDQgnIndiNsliderLevelDecrease,
       
   968                                      KAknsIIDQsnTextColors,
       
   969                                      EAknsCIQsnTextColorsCG19,
       
   970                                      bitmap,
       
   971                                      mask, 
       
   972                                      KAvkonBitmapFile,
       
   973                                      EMbmAvkonQgn_indi_nslider_level_decrease,
       
   974                                      EMbmAvkonQgn_indi_nslider_level_decrease_mask,
       
   975                                      KRgbWhite ); 
       
   976         
       
   977         iDecArrow = CAknButton::NewL( CGulIcon::NewL( bitmap, mask ),  //aIcon
       
   978                                       NULL,                            //aDimmedIcon
       
   979                                       NULL,                            //aPressedIcon
       
   980                                       NULL,                            //aHoverIcon
       
   981                                       KNullDesC,                       //aText
       
   982                                       KNullDesC,                       //aHelpText
       
   983                                       KAknButtonNoFrame | KAknButtonNoClear | KAknButtonKeyRepeat,//aButtonFlags
       
   984                                       0                                //aStateFlags
       
   985                                     );
       
   986                                                    
       
   987         iDecArrow->SetContainerWindowL( *this );
       
   988         iDecArrow->SetObserver( this ); 
       
   989         }
       
   990     else
       
   991         {
       
   992         iIncArrow =  CAknButton::NewL( KAvkonBitmapFile, 
       
   993                                       EMbmAvkonQgn_indi_volume_arrow_up, 
       
   994                                       EMbmAvkonQgn_indi_volume_arrow_up_mask,
       
   995                                       EMbmAvkonQgn_indi_volume_arrow_up_inactive, 
       
   996                                       EMbmAvkonQgn_indi_volume_arrow_up_inactive_mask,
       
   997                                       EMbmAvkonQgn_indi_volume_arrow_up_selected, 
       
   998                                       EMbmAvkonQgn_indi_volume_arrow_up_selected_mask,
       
   999                                       -1,
       
  1000                                       -1,
       
  1001                                       KNullDesC, 
       
  1002                                       KNullDesC, 
       
  1003                                       KAknButtonNoFrame | KAknButtonNoClear|KAknButtonKeyRepeat, 
       
  1004                                       0,
       
  1005                                       KAknsIIDQgnIndiVolumeArrowUp,
       
  1006                                       KAknsIIDQgnIndiVolumeArrowUpInactive,
       
  1007                                       KAknsIIDQgnIndiVolumeArrowUpSelected
       
  1008 
       
  1009                                       );
       
  1010 
       
  1011                                 
       
  1012         iIncArrow->SetContainerWindowL( *this );
       
  1013         iIncArrow->SetObserver( this );
       
  1014         
       
  1015         iDecArrow = CAknButton::NewL( KAvkonBitmapFile, 
       
  1016                                       EMbmAvkonQgn_indi_volume_arrow_down, 
       
  1017                                       EMbmAvkonQgn_indi_volume_arrow_down_mask,
       
  1018                                       EMbmAvkonQgn_indi_volume_arrow_down_inactive, 
       
  1019                                       EMbmAvkonQgn_indi_volume_arrow_down_inactive_mask,
       
  1020                                       EMbmAvkonQgn_indi_volume_arrow_down_selected, 
       
  1021                                       EMbmAvkonQgn_indi_volume_arrow_down_selected_mask,
       
  1022                                       -1,
       
  1023                                       -1,
       
  1024                                       KNullDesC, 
       
  1025                                       KNullDesC, 
       
  1026                                       KAknButtonNoFrame | KAknButtonKeyRepeat | 
       
  1027                                                             KAknButtonNoClear, 
       
  1028                                       0,
       
  1029                                       KAknsIIDQgnIndiVolumeArrowDown,
       
  1030                                       KAknsIIDQgnIndiVolumeArrowDownInactive,
       
  1031                                       KAknsIIDQgnIndiVolumeArrowDownSelected
       
  1032                                       );                          
       
  1033         iDecArrow->SetContainerWindowL( *this );
       
  1034         iDecArrow->SetObserver( this ); 
       
  1035         }
       
  1036 
       
  1037     }
       
  1038 // ---------------------------------------------------------------------------
       
  1039 // CAknVolumePopup::NewL
       
  1040 // DEPRECATED
       
  1041 // ---------------------------------------------------------------------------
       
  1042 //
       
  1043 EXPORT_C CAknVolumePopup* CAknVolumePopup::NewL ( TUid /*aSharedDataVolumeUid*/,
       
  1044                                                  const TDesC& /*aKey*/, 
       
  1045                                                  TInt /*aMinimumValue*/ )
       
  1046     {
       
  1047     return CAknVolumePopup::NewL();
       
  1048     }
       
  1049 
       
  1050 
       
  1051 // ---------------------------------------------------------------------------
       
  1052 // CAknVolumePopup::NewL
       
  1053 // DEPRECATED
       
  1054 // ---------------------------------------------------------------------------
       
  1055 //
       
  1056 EXPORT_C CAknVolumePopup* CAknVolumePopup::NewL( 
       
  1057                             TInt /*aMinimumValue = 0 parameter deprecated */ )
       
  1058     {
       
  1059     CAknVolumePopup* self = new( ELeave ) CAknVolumePopup(0);
       
  1060     CleanupStack::PushL( self );
       
  1061     self->ConstructL( NULL, EFalse );
       
  1062     CleanupStack::Pop();
       
  1063     AKNTASHOOK_ADDL( self, "CAknVolumePopup" );
       
  1064     return self;
       
  1065     }
       
  1066 
       
  1067 // ---------------------------------------------------------------------------
       
  1068 // CAknVolumePopup::~CAknVolumePopup
       
  1069 //
       
  1070 // ---------------------------------------------------------------------------
       
  1071 //
       
  1072 CAknVolumePopup::~CAknVolumePopup()
       
  1073     {
       
  1074     AKNTASHOOK_REMOVE();
       
  1075     // Set the pointer to the observer NULL here, because otherwise
       
  1076     // this might crash upon the CloseVolumePopup() call when
       
  1077     // trying to report an event to an invalid observer.
       
  1078     SetObserver( NULL );
       
  1079     CloseVolumePopup();
       
  1080     if( iAvkonAppUi )
       
  1081 		{
       
  1082 		iAvkonAppUi->RemoveFromStack( this );
       
  1083 		}
       
  1084     if ( iExt->iWindowGroupCreated )
       
  1085         {
       
  1086         iWindowGroup.Close();
       
  1087         }
       
  1088     delete iTimer;
       
  1089     delete iSpeaker;
       
  1090 
       
  1091     delete iLabel;
       
  1092     delete iMutedLabel;
       
  1093    
       
  1094     delete iMutedText;
       
  1095     delete iIncArrow;
       
  1096     delete iDecArrow;
       
  1097     
       
  1098     delete iExt;
       
  1099     }
       
  1100 
       
  1101 
       
  1102 // ---------------------------------------------------------------------------
       
  1103 // CAknVolumePopup::HandleVolumeKeyEventL
       
  1104 // ---------------------------------------------------------------------------
       
  1105 //
       
  1106 EXPORT_C TKeyResponse CAknVolumePopup::HandleVolumeKeyEventL(
       
  1107             const TKeyEvent& /*aEvent*/, TEventCode /*aType*/)
       
  1108     { return EKeyWasNotConsumed; }  // deprecated
       
  1109 
       
  1110 
       
  1111 // ---------------------------------------------------------------------------
       
  1112 // CAknVolumePopup::CountComponentControls
       
  1113 // ---------------------------------------------------------------------------
       
  1114 //
       
  1115 TInt CAknVolumePopup::CountComponentControls() const
       
  1116     {
       
  1117     if( iExt->iSliderUsed == KSliderUsed )
       
  1118         {
       
  1119         if ( iExt->iOldVolumeControl )
       
  1120             {
       
  1121             // Volume popup launched from navi pane, so old volume
       
  1122             // control exists also.
       
  1123             return 6;
       
  1124             }
       
  1125         else
       
  1126             {
       
  1127             return 5;// iLabel,iSliderControl,iSpeaker,iDecArrow,iIncArrow
       
  1128             }
       
  1129         }
       
  1130         
       
  1131     else if( iFlags == ESmallPopupVolumeControl || 
       
  1132              iFlags == ESmallPopupVolumeControlWithPercent )
       
  1133         {
       
  1134         return 5;// iLabel, VolumeControl, iSpeaker,iDecArrow,iIncArrow
       
  1135         }
       
  1136 
       
  1137     return 3; // iLabel, VolumeControl(iMutedLabel), iSpeaker
       
  1138     }
       
  1139 
       
  1140 // ---------------------------------------------------------------------------
       
  1141 // CAknVolumePopup::ComponentControl
       
  1142 // ---------------------------------------------------------------------------
       
  1143 //
       
  1144 CCoeControl* CAknVolumePopup::ComponentControl(TInt aIndex) const
       
  1145     {
       
  1146     switch (aIndex)
       
  1147         {
       
  1148         case 1:
       
  1149             return iLabel;     
       
  1150         case 0:
       
  1151             {
       
  1152             if(iExt->iSliderUsed != KSliderUsed &&
       
  1153                iFlags != ESmallPopupVolumeControl && 
       
  1154                iFlags != ESmallPopupVolumeControlWithPercent &&
       
  1155                iFlags != ENaviPaneVolumeControl &&
       
  1156                iFlags != EDynRangeNaviPaneVolumeControl &&
       
  1157                iMuted )
       
  1158                 {
       
  1159                 return iMutedLabel;
       
  1160                 }
       
  1161             else
       
  1162                 {
       
  1163                 return iExt->VolumeControl();
       
  1164                 }
       
  1165             }
       
  1166         case 2:
       
  1167             return iSpeaker;
       
  1168         case 3:
       
  1169             if( iDecArrow )
       
  1170                 {
       
  1171                 return iDecArrow;
       
  1172                 }
       
  1173         case 4:
       
  1174             if( iIncArrow )
       
  1175                 {
       
  1176                 return iIncArrow;
       
  1177                 }
       
  1178         case 5:
       
  1179             return iExt->iOldVolumeControl;
       
  1180          
       
  1181         default:
       
  1182             break;
       
  1183         }
       
  1184     return NULL;
       
  1185     }
       
  1186 // ----------------------------------------------------------------------------
       
  1187 // CAknVolumePopup::GetMarkerRect
       
  1188 //
       
  1189 // ----------------------------------------------------------------------------
       
  1190 //
       
  1191 void CAknVolumePopup::GetMarkerRect( TRect& aRect )
       
  1192     {
       
  1193     TPoint p;
       
  1194     TInt min,max;
       
  1195     GetRange( min, max );
       
  1196     TSize markerSize( iExt->iMarkerSize );
       
  1197     TRect volumeControlRect = iExt->VolumeControl()->Rect();    
       
  1198     if ( iExt->iSliderUsed == KSliderUsed )
       
  1199         {
       
  1200         
       
  1201         TInt pixelRange = volumeControlRect.Height() - markerSize.iHeight;
       
  1202         TInt pos = ( pixelRange * ( iVolume - min ) / (max-min) );
       
  1203             
       
  1204         p.iX = volumeControlRect.iTl.iX;
       
  1205         p.iY = volumeControlRect.iBr.iY - pos - markerSize.iHeight;
       
  1206 
       
  1207         }
       
  1208         
       
  1209     aRect = TRect( p, iExt->iMarkerSize );
       
  1210     }
       
  1211 
       
  1212  
       
  1213 // ---------------------------------------------------------------------------
       
  1214 // CAknVolumePopup::HandlePointerEventL
       
  1215 // ---------------------------------------------------------------------------
       
  1216 //    
       
  1217 void CAknVolumePopup::HandlePointerEventL(const TPointerEvent &aPointerEvent)
       
  1218     {
       
  1219     iExt->iHandlingPointerEvent = ETrue;
       
  1220     TInt oldValue = Value();
       
  1221 
       
  1222     if ( !AknLayoutUtils::PenEnabled() )
       
  1223         {
       
  1224         return;
       
  1225         }
       
  1226     //if touch point outside the window, popup volume will be closed. 
       
  1227     TRect window = TRect(0,0, iParentRect.Width(), iParentRect.Height());
       
  1228   
       
  1229     TPointerEvent pointerEvent = aPointerEvent;
       
  1230     TRect dragRect;
       
  1231     TRect volumeControlRect = iExt->VolumeControl()->Rect();
       
  1232     if( iExt->iSliderUsed == KSliderUsed )
       
  1233         {
       
  1234         dragRect = TRect( window.iTl.iX, 
       
  1235                         volumeControlRect.iTl.iY, 
       
  1236                         window.iBr.iX, 
       
  1237                         volumeControlRect.iBr.iY );
       
  1238                         
       
  1239         }
       
  1240     switch( aPointerEvent.iType )
       
  1241         {
       
  1242         case TPointerEvent::EButton1Down:
       
  1243         	{
       
  1244         	if ( iMuted && ( !iSpeakerRect.Contains( aPointerEvent.iPosition ) ) &&
       
  1245         	     ( !iDecArrow->Rect().Contains( aPointerEvent.iPosition ) ) &&
       
  1246         	     ( !iIncArrow->Rect().Contains( aPointerEvent.iPosition ) ) )
       
  1247                 	{
       
  1248                 	HandleControlEventL( iSpeaker, EEventStateChanged ); 
       
  1249                 	break;
       
  1250                 	}
       
  1251         	}
       
  1252         case TPointerEvent::EButtonRepeat:
       
  1253         case TPointerEvent::EDrag:
       
  1254             {
       
  1255             /*finger touch slider, the pointer fell on the position 
       
  1256             which is in finger touch area but not in markerarea,
       
  1257             becuase markerarea pointer can handle by slider.*/
       
  1258             if( iExt->iSliderUsed == KSliderUsed )  
       
  1259                 {
       
  1260                 if( iVertical && dragRect.Contains( aPointerEvent.iPosition ) &&
       
  1261                     !volumeControlRect.Contains( aPointerEvent.iPosition ) ) 
       
  1262                     {
       
  1263                     pointerEvent.iPosition.iX = volumeControlRect.iTl.iX;
       
  1264                     }
       
  1265                 else if( dragRect.Contains( aPointerEvent.iPosition ) &&
       
  1266                     !volumeControlRect.Contains( aPointerEvent.iPosition ) ) 
       
  1267                     {
       
  1268                     pointerEvent.iPosition.iY = volumeControlRect.iTl.iY;
       
  1269                     }
       
  1270                 }
       
  1271             }
       
  1272             break;
       
  1273         default:
       
  1274             break;
       
  1275         }
       
  1276     
       
  1277     ResetTimer();
       
  1278     
       
  1279     //for finger touch and drag
       
  1280     TRect markerRect;
       
  1281     GetMarkerRect( markerRect );    
       
  1282     CCoeControl::HandlePointerEventL( pointerEvent );
       
  1283     
       
  1284     markerRect.iTl.iX = window.iTl.iX;
       
  1285     markerRect.iBr.iX = window.iBr.iX;
       
  1286     if( dragRect.Contains( aPointerEvent.iPosition ) &&
       
  1287         !volumeControlRect.Contains( aPointerEvent.iPosition ) &&
       
  1288         !markerRect.Contains( aPointerEvent.iPosition ) &&
       
  1289         aPointerEvent.iType != TPointerEvent::EDrag )
       
  1290         {
       
  1291         Window().RequestPointerRepeatEvent( KScrollRepeatTimeout, window );
       
  1292         }
       
  1293     iExt->iHandlingPointerEvent = EFalse;
       
  1294     }
       
  1295 // ---------------------------------------------------------------------------
       
  1296 // CAknVolumePopup::Draw
       
  1297 // ---------------------------------------------------------------------------
       
  1298 //
       
  1299 void CAknVolumePopup::Draw(const TRect& aRect) const
       
  1300     {
       
  1301     CWindowGc& gc = SystemGc();
       
  1302     RRegion clippingReg(aRect);
       
  1303     
       
  1304     if( iExt->iSliderUsed == KSliderUsed && iExt->iSliderControl)
       
  1305         {
       
  1306         clippingReg.SubRect(iExt->iSliderControl->Rect());
       
  1307         }
       
  1308     
       
  1309     gc.SetClippingRegion( clippingReg );
       
  1310     
       
  1311     TAknLayoutRect windowRect;
       
  1312     windowRect.LayoutRect( iParentRect,
       
  1313                            AknLayoutScalable_Avkon::bg_popup_sub_pane_cp22());
       
  1314     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  1315     gc.SetPenStyle( CGraphicsContext::ENullPen );                               
       
  1316     gc.SetBrushColor( windowRect.Color() );
       
  1317     
       
  1318     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1319     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  1320 
       
  1321     TBool frameDrawn( EFalse );
       
  1322     if ( CAknEnv::Static()->TransparencyEnabled() )
       
  1323         {
       
  1324         // the added flag removes the white bg for transparency
       
  1325         frameDrawn = AknsDrawUtils::Background( skin, cc, this, gc, 
       
  1326                                                   windowRect.Rect(), 
       
  1327                                                   KAknsDrawParamNoClearUnderImage );
       
  1328         }
       
  1329     else
       
  1330         {
       
  1331         frameDrawn = AknsDrawUtils::Background( skin, cc, this, gc, 
       
  1332                                                   windowRect.Rect() );
       
  1333         }
       
  1334 
       
  1335     if( !frameDrawn )
       
  1336         {
       
  1337         gc.DrawRect( windowRect.Rect() );
       
  1338         }
       
  1339     gc.CancelClippingRegion();
       
  1340     clippingReg.Close();
       
  1341     }
       
  1342     
       
  1343 // ---------------------------------------------------------------------------
       
  1344 // CAknVolumePopup::SetValue
       
  1345 // ---------------------------------------------------------------------------
       
  1346 //
       
  1347 EXPORT_C void CAknVolumePopup::SetValue(TInt aValue)
       
  1348 	{
       
  1349 	if ( iExt->iInitialized )
       
  1350 	    {
       
  1351 	    if(!iExt->iHaveDefaultValue )
       
  1352             {
       
  1353             iExt->iDefaultValue = aValue;
       
  1354             iExt->iHaveDefaultValue = ETrue;
       
  1355             }
       
  1356             
       
  1357     	TInt min, max;
       
  1358         GetRange(min, max); 
       
  1359     	if( ( aValue==min ) && ( !iMuted ) )
       
  1360     		{
       
  1361     		MutePressed();
       
  1362     		return;
       
  1363     		}
       
  1364         DoSetValue( aValue );
       
  1365 	    }
       
  1366 	}
       
  1367 	    
       
  1368 // ---------------------------------------------------------------------------
       
  1369 // CAknVolumePopup::DoSetValue
       
  1370 // ---------------------------------------------------------------------------
       
  1371 //
       
  1372 void CAknVolumePopup::DoSetValue(TInt aValue)
       
  1373     {
       
  1374     if ( iVisible )
       
  1375         {
       
  1376         ResetTimer();
       
  1377         }
       
  1378     TInt min, max;
       
  1379     GetRange( min, max );
       
  1380     // if value is out of bounds then do nothing. 
       
  1381     if ( aValue < min || aValue > max )
       
  1382         {
       
  1383         //__ASSERT_DEBUG(0,User::Panic(_L("CAknVolumePopup"), KErrArgument));
       
  1384         }
       
  1385     
       
  1386     TBool valueChanged( aValue != iVolume );
       
  1387        
       
  1388     if ( valueChanged )
       
  1389         {
       
  1390         iVolume = aValue;
       
  1391         }
       
  1392     //value not changed, but value text can be changed    
       
  1393     TInt err = KErrNone;   
       
  1394     if( iFlags == ESmallPopupVolumeControl || 
       
  1395         iFlags == ESmallPopupVolumeControlWithPercent ||
       
  1396         iFlags == KSliderUsed ||
       
  1397         iFlags == ENaviPaneVolumeControl ||
       
  1398         iFlags == EDynRangeNaviPaneVolumeControl )
       
  1399         { 
       
  1400         TRAP(err,SetValueTextL());
       
  1401         }
       
  1402    
       
  1403      if (iVolume == min)
       
  1404         {
       
  1405         SetSpeakerMuted( ETrue );        
       
  1406         }   
       
  1407     else if ( iVolume > min && iMuted )
       
  1408         {
       
  1409         SetSpeakerMuted( EFalse );
       
  1410         }        
       
  1411     if ( iExt->iSliderUsed == KSliderUsed ||
       
  1412          iFlags == ENaviPaneVolumeControl ||
       
  1413          iFlags == EDynRangeNaviPaneVolumeControl ) 
       
  1414         {
       
  1415         if ( valueChanged )
       
  1416             {
       
  1417             TRAP(err,iExt->iSliderControl->SetValueL( iVolume ));
       
  1418             
       
  1419             if ( iFlags == ENaviPaneVolumeControl ||
       
  1420                  iFlags == EDynRangeNaviPaneVolumeControl )
       
  1421                 {
       
  1422                 // Navi pane volume control.
       
  1423                 iExt->iOldVolumeControl->SetValue( iVolume );
       
  1424                 }
       
  1425             }
       
  1426         }
       
  1427     else if( iFlags == ESmallPopupVolumeControl || 
       
  1428         iFlags == ESmallPopupVolumeControlWithPercent )
       
  1429         {
       
  1430         if ( valueChanged )
       
  1431             {
       
  1432             iExt->iOldVolumeControl->SetValue( iVolume );
       
  1433             }
       
  1434         }        
       
  1435     if( iIncArrow && iDecArrow )
       
  1436         {
       
  1437         iIncArrow->SetDimmed(EFalse);
       
  1438         iDecArrow->SetDimmed(EFalse);
       
  1439         if( aValue == min )
       
  1440             {
       
  1441             iDecArrow->SetDimmed(ETrue);
       
  1442             }
       
  1443         else if( aValue == max )
       
  1444             {
       
  1445             iIncArrow->SetDimmed(ETrue);
       
  1446             }
       
  1447         } 
       
  1448    
       
  1449     if ( iVisible )
       
  1450         {
       
  1451         SetVisibilityL( ETrue );
       
  1452         DrawDeferred();
       
  1453         }
       
  1454     }
       
  1455 
       
  1456 // ----------------------------------------------------------------------------
       
  1457 // CAknVolumePopup::SetValueTextL 
       
  1458 // Sets the text for the value label.
       
  1459 // ----------------------------------------------------------------------------
       
  1460 //
       
  1461  void CAknVolumePopup::SetValueTextL()
       
  1462     {
       
  1463     TBuf<KTextLen> textBuf;
       
  1464     DoSetValueTextL( textBuf, iVolume );
       
  1465     iLabel->SetTextL( textBuf );
       
  1466     }
       
  1467     
       
  1468 
       
  1469 // ----------------------------------------------------------------------------
       
  1470 // CAknVolumePopup::DoSetValueTextL
       
  1471 // ----------------------------------------------------------------------------
       
  1472 //
       
  1473 void CAknVolumePopup::DoSetValueTextL( TDes& aTextBuf, TInt aValue )
       
  1474     {
       
  1475     TBuf<KTextLen> valueBuf;
       
  1476     _LIT( KBareFigure, "%d" );
       
  1477     _LIT( KPercentageMirror, "%%%d" );
       
  1478     _LIT( KFraction, "%d/%d" );
       
  1479     TInt min,max;
       
  1480     GetRange( min, max );
       
  1481     iExt->iSpeakerHidden = ETrue;
       
  1482     switch ( iValueType )
       
  1483         {
       
  1484         case EAknSliderValueBareFigure:
       
  1485             valueBuf.Format( KBareFigure, aValue ); // bare figure
       
  1486             break;
       
  1487 
       
  1488         case EAknSliderValuePercentage:
       
  1489             if( AknLayoutUtils::LayoutMirrored() )
       
  1490                 {
       
  1491             	valueBuf.Format( KPercentageMirror, aValue );
       
  1492                 }
       
  1493             else
       
  1494                 {
       
  1495                 HBufC* percentage = StringLoader::LoadLC( R_QTN_SELECT_SLIDER_VALUE, aValue );                
       
  1496                	valueBuf.Copy( *percentage );
       
  1497             	CleanupStack::PopAndDestroy( percentage );
       
  1498                 }
       
  1499             break;
       
  1500 
       
  1501         case EAknSliderValueFraction:
       
  1502             valueBuf.Format( KFraction, aValue, max ); // x/y
       
  1503             break;
       
  1504 
       
  1505         case EAknSliderValueDecimal:
       
  1506             {
       
  1507             TReal r;
       
  1508             Math::Pow10( r, iDecimalPlaces );
       
  1509             // First have to format the format.
       
  1510             TBuf<8> format;
       
  1511             // This allows for 2 digit field size and/or decimal places
       
  1512             _LIT( KFormatTemplate, "%%-%d.%df" );
       
  1513             format.Format( KFormatTemplate,
       
  1514                            KTextLen,
       
  1515                            iDecimalPlaces );
       
  1516             valueBuf.Format( format, aValue / r );
       
  1517             valueBuf.TrimAll();
       
  1518             }
       
  1519             break;
       
  1520         default:
       
  1521             iExt->iSpeakerHidden = EFalse;
       
  1522             break; // valueBuf left empty
       
  1523         } // end switch
       
  1524 
       
  1525     // Convert this formatted number if necessary to display language-sensitive
       
  1526     // numerals
       
  1527     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( valueBuf );
       
  1528 
       
  1529     // A text pointer for the format string
       
  1530 
       
  1531     aTextBuf.Copy( valueBuf.Left( KTextLen ) );
       
  1532     }
       
  1533 
       
  1534 
       
  1535 // ---------------------------------------------------------------------------
       
  1536 // CAknVolumePopup::SetRange
       
  1537 // ---------------------------------------------------------------------------
       
  1538 //
       
  1539 EXPORT_C void CAknVolumePopup::SetRange( TInt aMinimumValue, TInt aMaximumValue )
       
  1540     {
       
  1541     if( iExt->iDefaultValue<=aMinimumValue )
       
  1542         {
       
  1543         iExt->iDefaultValue = aMinimumValue;
       
  1544         }
       
  1545     else if( iExt->iDefaultValue>= aMaximumValue )
       
  1546         {
       
  1547         iExt->iDefaultValue =  aMaximumValue;
       
  1548         }
       
  1549         
       
  1550     if( iExt->iSliderUsed == KSliderUsed )
       
  1551         {
       
  1552         iExt->iSliderControl->SetRange( aMinimumValue, aMaximumValue );
       
  1553         }
       
  1554     else
       
  1555         {
       
  1556         iExt->iOldVolumeControl->SetRange( aMinimumValue, aMaximumValue );
       
  1557         }
       
  1558         
       
  1559     // the mute's stored value should always be at least the min value
       
  1560     iStoredLevel = aMinimumValue;
       
  1561     }
       
  1562 
       
  1563 
       
  1564 // ---------------------------------------------------------------------------
       
  1565 // CAknVolumePopup::GetRange()
       
  1566 //
       
  1567 // ---------------------------------------------------------------------------
       
  1568 //
       
  1569 EXPORT_C void CAknVolumePopup::GetRange( TInt& aMinimumValue, 
       
  1570                                          TInt& aMaximumValue )
       
  1571     {
       
  1572     if( iExt->iSliderUsed == KSliderUsed )
       
  1573         {
       
  1574         iExt->iSliderControl->GetRange( aMinimumValue, aMaximumValue );
       
  1575         }
       
  1576     else
       
  1577         {
       
  1578         iExt->iOldVolumeControl->GetRange( aMinimumValue, aMaximumValue );
       
  1579         }
       
  1580 
       
  1581     }
       
  1582 
       
  1583 
       
  1584 // ---------------------------------------------------------------------------
       
  1585 // CAknVolumePopup::Value
       
  1586 // ---------------------------------------------------------------------------
       
  1587 //
       
  1588 EXPORT_C TInt CAknVolumePopup::Value() const
       
  1589     {
       
  1590     if( iExt->iSliderUsed == KSliderUsed )
       
  1591         {
       
  1592         return iExt->iSliderControl->Value();
       
  1593         }
       
  1594     else
       
  1595         {
       
  1596         return iExt->iOldVolumeControl->Value();
       
  1597         }
       
  1598     
       
  1599     }
       
  1600 
       
  1601 // ---------------------------------------------------------------------------
       
  1602 // CAknVolumePopup::SetValueType
       
  1603 // ---------------------------------------------------------------------------
       
  1604 //
       
  1605 EXPORT_C void CAknVolumePopup::SetValueType( TInt aValueType )
       
  1606     {
       
  1607     if( iExt->iSliderUsed == KSliderUsed )
       
  1608         {
       
  1609         iValueType = aValueType;
       
  1610         DoSetValue( Value() );
       
  1611         }
       
  1612     }
       
  1613    
       
  1614 // ---------------------------------------------------------------------------
       
  1615 // CAknVolumePopup::SetStepSize()
       
  1616 //
       
  1617 // ---------------------------------------------------------------------------
       
  1618 //
       
  1619 EXPORT_C void CAknVolumePopup::SetStepSize( TInt aStepSize )
       
  1620     {
       
  1621     if( iExt->iSliderUsed == KSliderUsed )
       
  1622         {
       
  1623         return iExt->iSliderControl->SetStepSize( aStepSize );
       
  1624         }
       
  1625     }
       
  1626     
       
  1627 // ---------------------------------------------------------------------------
       
  1628 // CAknVolumePopup::SetAdjustmentIndicatorOn()
       
  1629 //
       
  1630 // ---------------------------------------------------------------------------
       
  1631 //    
       
  1632 EXPORT_C void CAknVolumePopup::SetAdjustmentIndicatorDisplay( TBool aFlag )
       
  1633     {
       
  1634     iAdjustmentIndicatorOn = aFlag;
       
  1635     }
       
  1636 // ---------------------------------------------------------------------------
       
  1637 // CAknVolumePopup::SetTimeOutAsSecond()
       
  1638 //
       
  1639 // ---------------------------------------------------------------------------
       
  1640 //    
       
  1641 EXPORT_C void CAknVolumePopup::SetTimeOutAsSecond( TInt aSecond )
       
  1642     {
       
  1643     iTimeout = aSecond;
       
  1644     }
       
  1645 // ---------------------------------------------------------------------------
       
  1646 // CAknVolumePopup::SetDecimalPlaces()
       
  1647 //
       
  1648 // ---------------------------------------------------------------------------
       
  1649 //     
       
  1650 EXPORT_C void CAknVolumePopup::SetDecimalPlaces( TInt aDecimalPlaces )
       
  1651     {
       
  1652     __ASSERT_DEBUG( aDecimalPlaces >= 0, Panic( EAknPanicInvalidValue ) );
       
  1653     __ASSERT_DEBUG( aDecimalPlaces < 10, Panic( EAknPanicInvalidValue ) );
       
  1654     iDecimalPlaces = aDecimalPlaces;
       
  1655     }
       
  1656 // ---------------------------------------------------------------------------
       
  1657 // CAknVolumePopup::SetTitleTextL
       
  1658 // ---------------------------------------------------------------------------
       
  1659 //
       
  1660 EXPORT_C void CAknVolumePopup::SetTitleTextL( const TDesC& aText )
       
  1661     {
       
  1662     if ( iFlags != ESmallPopupVolumeControl && 
       
  1663         iFlags != ESmallPopupVolumeControlWithPercent &&
       
  1664         iFlags != KSliderUsed )
       
  1665         {        
       
  1666         iLabel->SetTextL( aText );
       
  1667         iLabel->CropText();  // add ellipsis if text does not fit
       
  1668         }
       
  1669     if ( iVisible )
       
  1670         {
       
  1671         Window().Invalidate( iLabel->Rect() );
       
  1672         }    
       
  1673     }
       
  1674 
       
  1675 // ---------------------------------------------------------------------------
       
  1676 // CAknVolumePopup::ShowProfileName
       
  1677 // ---------------------------------------------------------------------------
       
  1678 //
       
  1679 EXPORT_C void CAknVolumePopup::ShowProfileName( TBool /*aShowProfile*/ )
       
  1680     { } // deprecated
       
  1681 
       
  1682 // ---------------------------------------------------------------------------
       
  1683 // CAknVolumePopup::ShowMuteAsLabel
       
  1684 // ---------------------------------------------------------------------------
       
  1685 //
       
  1686 /*EXPORT_C*/ void CAknVolumePopup::ShowMuteAsLabel( TBool aShowMuteAsLabel )
       
  1687     {
       
  1688     iShowMuteAsLabel = aShowMuteAsLabel;
       
  1689     }
       
  1690 
       
  1691 TKeyResponse CAknVolumePopup::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
  1692                                                 TEventCode aType )
       
  1693     { 
       
  1694     TKeyResponse response( EKeyWasNotConsumed );    
       
  1695     
       
  1696     if ( aType == EEventKey )
       
  1697         {
       
  1698         switch( aKeyEvent.iCode )
       
  1699             {
       
  1700             case EKeyEscape:
       
  1701                 if ( iVisible  )
       
  1702                     {
       
  1703                     CloseVolumePopup();
       
  1704                     response = EKeyWasConsumed;
       
  1705                     }
       
  1706                 break;
       
  1707             default:
       
  1708                 break;
       
  1709             }
       
  1710         }
       
  1711         
       
  1712     return response;
       
  1713     }
       
  1714 // ---------------------------------------------------------------------------
       
  1715 // CAknVolumePopup::UseMutedIcon
       
  1716 // ---------------------------------------------------------------------------
       
  1717 //    
       
  1718 EXPORT_C void CAknVolumePopup::UseMutedIcon( TBool aFlag )
       
  1719     {
       
  1720     iExt->iUseMutedIcon = aFlag;
       
  1721     CreateSpeakerL();
       
  1722     }
       
  1723 
       
  1724 // ---------------------------------------------------------------------------
       
  1725 // CAknVolumePopup::SetSpeakerMuted
       
  1726 // ---------------------------------------------------------------------------
       
  1727 //
       
  1728 void CAknVolumePopup::SetSpeakerMuted( TBool aMuted )
       
  1729     {
       
  1730     if( iSpeaker && iExt->iUseMutedIcon )
       
  1731         {
       
  1732         iSpeaker->SetCurrentState( aMuted ? 1 : 0, ETrue );
       
  1733         }
       
  1734 	    if ( iMuted != aMuted )
       
  1735         {
       
  1736         if ( iVisible )
       
  1737             {
       
  1738             // skin stuff - find out size of the corner piece
       
  1739             TAknLayoutRect cornerRect;
       
  1740             // skinned draw uses submenu popup window skin
       
  1741             cornerRect.LayoutRect(
       
  1742                 Rect(),                            
       
  1743                 AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );
       
  1744                                    
       
  1745 	            Window().Invalidate();
       
  1746             }
       
  1747         }
       
  1748     iMuted = aMuted;
       
  1749     }
       
  1750 // ---------------------------------------------------------------------------
       
  1751 // CAknVolumePopup::MutePressed
       
  1752 // ---------------------------------------------------------------------------
       
  1753 //
       
  1754 void CAknVolumePopup::MutePressed()
       
  1755     {
       
  1756     // not slider
       
  1757     TInt min, max;
       
  1758     GetRange(min, max);
       
  1759     
       
  1760     // mute indicator was tapped
       
  1761     if ( iMuted )
       
  1762         {
       
  1763         // The popup was muted, so let's restore the value
       
  1764         if(iStoredLevel == min)
       
  1765         {
       
  1766         if( iExt->iSliderUsed == KSliderUsed )
       
  1767         	iStoredLevel += iExt->iSliderControl->StepSize();
       
  1768         else
       
  1769         	iStoredLevel++;
       
  1770         }
       
  1771         
       
  1772         // restore saved value
       
  1773         DoSetValue(iStoredLevel);
       
  1774         // Put minimum as default, so if we drag or use SetValue to set the value
       
  1775         // to mute, we then come out of the mute
       
  1776         iStoredLevel = min;
       
  1777         }
       
  1778     else if(!iMuted)
       
  1779         {
       
  1780         // mute the volume popup
       
  1781         iStoredLevel = Value();
       
  1782         DoSetValue(min);
       
  1783         }
       
  1784     }
       
  1785 // ---------------------------------------------------------------------------
       
  1786 // CAknVolumePopup::StartTimer
       
  1787 // ---------------------------------------------------------------------------
       
  1788 //
       
  1789 void CAknVolumePopup::StartTimer()
       
  1790     {
       
  1791     if ( !iTimer->IsActive() )  // should not be
       
  1792         {
       
  1793         if( iTimeout != 0 )
       
  1794             {
       
  1795              iTimer->Start( iTimeout * 1000000,
       
  1796                        iTimeout * 1000000,
       
  1797                        TCallBack( CAknVolumePopup::TimerExpired, this ) );
       
  1798             }
       
  1799         else
       
  1800             {
       
  1801             iTimer->Start( KInactivityTime,
       
  1802                            KInactivityTime,
       
  1803                        TCallBack( CAknVolumePopup::TimerExpired, this ) );
       
  1804             }
       
  1805         }
       
  1806     }
       
  1807 // ---------------------------------------------------------------------------
       
  1808 // CAknVolumePopup::ResetTimer
       
  1809 // ---------------------------------------------------------------------------
       
  1810 //
       
  1811 void CAknVolumePopup::ResetTimer()
       
  1812     {
       
  1813     if (iTimer->IsActive())
       
  1814         {
       
  1815         iTimer->Cancel();
       
  1816         }
       
  1817     if( !Parent() )
       
  1818         {
       
  1819         StartTimer();
       
  1820         }
       
  1821     }
       
  1822 
       
  1823 // ---------------------------------------------------------------------------
       
  1824 // CAknVolumePopup::TimerExpired
       
  1825 // ---------------------------------------------------------------------------
       
  1826 //
       
  1827 TInt CAknVolumePopup::TimerExpired(TAny * aPtr)
       
  1828     {
       
  1829     ((CAknVolumePopup*)aPtr)->CloseVolumePopup();
       
  1830     return EFalse;   // do not restart timer
       
  1831     }
       
  1832 
       
  1833 // ---------------------------------------------------------------------------
       
  1834 // CAknVolumePopup::ShowVolumePopupL
       
  1835 // ---------------------------------------------------------------------------
       
  1836 //
       
  1837 EXPORT_C void CAknVolumePopup::ShowVolumePopupL()
       
  1838     {
       
  1839     ResetTimer();
       
  1840     
       
  1841     if (iVisible)
       
  1842         {      
       
  1843         return;
       
  1844         }
       
  1845 
       
  1846     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1847     if ( feedback )
       
  1848         {
       
  1849         feedback->InstantFeedback( ETouchFeedbackPopUp );
       
  1850         }
       
  1851     CleanupStack::PushL(TCleanupItem(CleanupShowVolumePopup, this));
       
  1852        
       
  1853     SetVisibilityL(ETrue);
       
  1854     ActivateL();
       
  1855     DrawNow();
       
  1856     // finally, make window visible
       
  1857     if( !Parent() && (iFlags == ENaviPaneVolumeControl ||
       
  1858          iFlags == EDynRangeNaviPaneVolumeControl ))
       
  1859         {
       
  1860         DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
       
  1861         }
       
  1862     else if( !Parent() )
       
  1863         {
       
  1864         iWindowGroup.SetOrdinalPosition( 0, KWindowPosition );
       
  1865         }
       
  1866    
       
  1867     if ( Window().IsFaded() )
       
  1868         {
       
  1869         Window().SetFaded( EFalse, RWindowTreeNode::EFadeIncludeChildren );
       
  1870         }
       
  1871     CleanupStack::Pop();    // clean volume popup cleanup item
       
  1872     }
       
  1873 // ---------------------------------------------------------------------------
       
  1874 // CAknVolumePopup::SizeChanged
       
  1875 // ---------------------------------------------------------------------------
       
  1876 //
       
  1877 void CAknVolumePopup::SizeChanged()
       
  1878     {
       
  1879     // ensure that rect has right size.
       
  1880         
       
  1881     iParentRect = TRect(0,0,Rect().Width(), Rect().Height());
       
  1882 
       
  1883     TAknWindowComponentLayout volumeComponent; // volumecontrol
       
  1884     TAknWindowComponentLayout iconComponent; // mute/unmute icon
       
  1885     TAknTextComponentLayout textComponent;
       
  1886     TRect iconRect;
       
  1887      
       
  1888     if ( iFlags == ESmallPopupVolumeControl || 
       
  1889         iFlags == ESmallPopupVolumeControlWithPercent )
       
  1890         {   
       
  1891         // percent field
       
  1892         textComponent = 
       
  1893             AknLayoutScalable_Avkon::popup_side_volume_key_window_t2();             
       
  1894         // arrows
       
  1895         TAknWindowComponentLayout leftArrow = 
       
  1896             AknLayoutScalable_Avkon::popup_side_volume_key_window_g2();
       
  1897         TAknWindowComponentLayout rightArrow = 
       
  1898             AknLayoutScalable_Avkon::popup_side_volume_key_window_g3();
       
  1899         
       
  1900         TAknLayoutRect arrow;
       
  1901         
       
  1902         arrow.LayoutRect( Rect(), leftArrow );
       
  1903         iDecArrow->SetRect( arrow.Rect() );
       
  1904         
       
  1905         arrow.LayoutRect( Rect(), rightArrow );
       
  1906         iIncArrow->SetRect( arrow.Rect() );
       
  1907         
       
  1908         // icon component is wrong!
       
  1909         iconComponent = AknLayoutScalable_Avkon::ai2_mp_volume_pane_g1();        
       
  1910         iconRect = TRect( TSize( textComponent.H(), textComponent.H() ) );
       
  1911         
       
  1912         volumeComponent = AknLayoutScalable_Avkon::navi_navi_volume_pane_cp2();           
       
  1913                        
       
  1914         }
       
  1915     else if ( iExt->iSliderUsed != KSliderUsed &&
       
  1916               iFlags != ENaviPaneVolumeControl &&
       
  1917               iFlags != EDynRangeNaviPaneVolumeControl )
       
  1918         {
       
  1919        
       
  1920         volumeComponent = AknLayoutScalable_Avkon::volume_small_pane_cp1();    
       
  1921         iconComponent = AknLayoutScalable_Avkon::popup_side_volume_key_window_g1();
       
  1922         TAknLayoutRect r;
       
  1923         r.LayoutRect( Rect(),
       
  1924             iconComponent );    
       
  1925         iconRect = r.Rect();   
       
  1926         iSpeakerRect = iconRect; 
       
  1927 
       
  1928         TAknLayoutRect mutedLabelRect;
       
  1929         mutedLabelRect.LayoutRect( Rect(),
       
  1930                     AknLayoutScalable_Avkon::volume_small_pane_cp1() );
       
  1931         iMutedLabel->SetRect(mutedLabelRect.Rect()); 
       
  1932         AknLayoutUtils::LayoutControl(iExt->VolumeControl(),Rect(),volumeComponent);
       
  1933          
       
  1934         }
       
  1935         
       
  1936     if( iExt->iSliderUsed != KSliderUsed )
       
  1937         {
       
  1938     	if( iFlags != ESmallPopupVolumeControl && 
       
  1939             iFlags != ESmallPopupVolumeControlWithPercent &&
       
  1940             iFlags != ENaviPaneVolumeControl &&
       
  1941             iFlags != EDynRangeNaviPaneVolumeControl )
       
  1942             {
       
  1943             textComponent = 
       
  1944                 AknLayoutScalable_Avkon::popup_side_volume_key_window_t1();        
       
  1945             }
       
  1946         }
       
  1947     else if( iVertical )
       
  1948         {
       
  1949         textComponent = 
       
  1950             AknLayoutScalable_Avkon::popup_slider_window_t2(0);
       
  1951         }
       
  1952      else 
       
  1953          {
       
  1954      	 textComponent = 
       
  1955              AknLayoutScalable_Apps::popup_vtel_slider_window_t1(0);
       
  1956          }
       
  1957             
       
  1958         AknLayoutUtils::LayoutLabel( iLabel, iParentRect, textComponent );
       
  1959         SetLabelColor();
       
  1960         AknLayoutUtils::LayoutControl( iExt->VolumeControl(), iParentRect, volumeComponent );
       
  1961         
       
  1962     if (  iExt->iSliderUsed != KSliderUsed  )
       
  1963     {
       
  1964         if( ( iFlags == ESmallPopupVolumeControl || 
       
  1965              iFlags == ESmallPopupVolumeControlWithPercent ) )
       
  1966             {
       
  1967             TPoint volTL = iExt->VolumeControl()->Rect().iTl;
       
  1968             volTL += TPoint( iconRect.Width()*KWidthSpace, 0 );
       
  1969             TSize volSize = iExt->VolumeControl()->Size();
       
  1970             //small gap between icon and control
       
  1971             volSize -= TSize(iconRect.Width()*KWidthSpace,0); 
       
  1972             iExt->VolumeControl()->SetRect( TRect( volTL, volSize ) );
       
  1973             iSpeakerRect = TRect( iExt->VolumeControl()->Rect().iTl - 
       
  1974                                   TPoint( iconRect.Size().iWidth*KWidthSpace, 0), 
       
  1975                                   iconRect.Size() ); 
       
  1976             }
       
  1977         }
       
  1978     else if( iVertical )
       
  1979         {
       
  1980         // with icon
       
  1981         if( !iExt->iSpeakerHidden )
       
  1982             {
       
  1983             volumeComponent = AknLayoutScalable_Avkon::slider_pane(0);
       
  1984             AknLayoutUtils::LayoutControl( iExt->VolumeControl(),
       
  1985                                            iParentRect,
       
  1986                                            volumeComponent );
       
  1987             
       
  1988             //ic
       
  1989             TAknLayoutRect r;
       
  1990             r.LayoutRect( iParentRect, 
       
  1991                           AknLayoutScalable_Avkon::popup_slider_window_g6(0) );
       
  1992             iSpeakerRect = r.Rect();
       
  1993             
       
  1994             //"+""-" icon
       
  1995             TRect t;
       
  1996             TInt touch;
       
  1997             r.LayoutRect( iParentRect, 
       
  1998                           AknLayoutScalable_Avkon::popup_slider_window_g4(0) );
       
  1999             touch = r.Rect().iTl.iX - iParentRect.iTl.iX;
       
  2000             t.iTl.iX = r.Rect().iTl.iX - touch/2;
       
  2001             t.iTl.iY = r.Rect().iTl.iY;
       
  2002             t.iBr.iX = r.Rect().iBr.iX + touch/2;
       
  2003             t.iBr.iY = r.Rect().iBr.iY;
       
  2004             iIncArrow->SetRect( t );
       
  2005             TInt icon = iIncArrow->SetIconSize( r.Rect().Size() );
       
  2006             r.LayoutRect( iParentRect, 
       
  2007                           AknLayoutScalable_Avkon::popup_slider_window_g5(0) );
       
  2008             t.iTl.iX = r.Rect().iTl.iX - touch/2;
       
  2009             t.iTl.iY = r.Rect().iTl.iY;
       
  2010             t.iBr.iX = r.Rect().iBr.iX + touch/2;
       
  2011             t.iBr.iY = r.Rect().iBr.iY;
       
  2012             iDecArrow->SetRect( t );
       
  2013             icon = iDecArrow->SetIconSize( r.Rect().Size() );
       
  2014             
       
  2015             //marker size
       
  2016             r.LayoutRect( iParentRect, 
       
  2017             AknLayoutScalable_Avkon::popup_slider_window_g6(0) );
       
  2018             iExt->iMarkerSize = r.Rect().Size();
       
  2019             }
       
  2020         // with text
       
  2021         else if( iValueType != EAknSliderValueNone )
       
  2022             {
       
  2023             volumeComponent =  AknLayoutScalable_Avkon::slider_pane(1);
       
  2024             AknLayoutUtils::LayoutControl( iExt->VolumeControl(),
       
  2025                                            iParentRect,
       
  2026                                            volumeComponent );
       
  2027             //"+""-" icon
       
  2028             TAknLayoutRect r;
       
  2029             r.LayoutRect( iParentRect, 
       
  2030                           AknLayoutScalable_Avkon::popup_slider_window_g4(1) );
       
  2031             iIncArrow->SetRect( r.Rect() );
       
  2032             r.LayoutRect( iParentRect, 
       
  2033                           AknLayoutScalable_Avkon::popup_slider_window_g5(1) );
       
  2034             iDecArrow->SetRect( r.Rect() );
       
  2035             
       
  2036             //marker size
       
  2037             r.LayoutRect( iParentRect, 
       
  2038             AknLayoutScalable_Avkon::popup_slider_window_g6(0) );
       
  2039             iExt->iMarkerSize = r.Rect().Size();
       
  2040             }
       
  2041         // without icon and text
       
  2042         else
       
  2043             {
       
  2044             volumeComponent = AknLayoutScalable_Avkon::slider_pane(2);
       
  2045             AknLayoutUtils::LayoutControl( iExt->VolumeControl(),
       
  2046                                            iParentRect,
       
  2047                                            volumeComponent );
       
  2048             
       
  2049             //"+""-" icon
       
  2050             TAknLayoutRect r;
       
  2051             r.LayoutRect( iParentRect, 
       
  2052                           AknLayoutScalable_Avkon::popup_slider_window_g4(2) );
       
  2053             iIncArrow->SetRect( r.Rect() );
       
  2054             r.LayoutRect( iParentRect, 
       
  2055                           AknLayoutScalable_Avkon::popup_slider_window_g5(2) );
       
  2056             iDecArrow->SetRect( r.Rect() );
       
  2057             
       
  2058             //marker size
       
  2059             r.LayoutRect( iParentRect, 
       
  2060             AknLayoutScalable_Avkon::popup_slider_window_g6(0) );
       
  2061             iExt->iMarkerSize = r.Rect().Size();
       
  2062             }
       
  2063         }
       
  2064     else 
       
  2065         {
       
  2066         // Horizontal
       
  2067         textComponent = 
       
  2068              AknLayoutScalable_Apps::popup_vtel_slider_window_t1(0);
       
  2069         volumeComponent = 
       
  2070              AknLayoutScalable_Apps::vtel_slider_pane(0);  
       
  2071 
       
  2072         AknLayoutUtils::LayoutLabel( iLabel, iParentRect, textComponent );
       
  2073         SetLabelColor();
       
  2074         AknLayoutUtils::LayoutControl( iExt->VolumeControl(), iParentRect, volumeComponent );
       
  2075     
       
  2076         TAknLayoutRect r;
       
  2077         r.LayoutRect( iParentRect, 
       
  2078         AknLayoutScalable_Apps::vtel_slider_pane(0) );
       
  2079     
       
  2080         iExt->VolumeControl()->SetRect( r.Rect() );
       
  2081         r.LayoutRect( iParentRect, 
       
  2082                       AknLayoutScalable_Apps::popup_vtel_slider_window_g2(0) );
       
  2083         
       
  2084         iSpeakerRect = r.Rect();
       
  2085         
       
  2086         //"+""-" icon
       
  2087         r.LayoutRect( iParentRect, 
       
  2088                        AknLayoutScalable_Apps::popup_vtel_slider_window_g4(0) );
       
  2089         iIncArrow->SetRect( r.Rect() );
       
  2090         r.LayoutRect( iParentRect, 
       
  2091                        AknLayoutScalable_Apps::popup_vtel_slider_window_g3(0) );
       
  2092         iDecArrow->SetRect( r.Rect() );
       
  2093         
       
  2094         //slider pane and marker size
       
  2095       
       
  2096         r.LayoutRect( iParentRect, 
       
  2097         AknLayoutScalable_Apps::vtel_slider_pane_g5(0) );
       
  2098         iExt->iMarkerSize = r.Rect().Size();
       
  2099         }
       
  2100     iSpeaker->SetRect( iSpeakerRect );
       
  2101     
       
  2102     // read outer rect and inner rect from layout data
       
  2103     TAknLayoutRect outerRect;
       
  2104     outerRect.LayoutRect( iParentRect,
       
  2105                           AknLayoutScalable_Avkon::bg_popup_sub_pane_cp22());
       
  2106 
       
  2107     TAknLayoutRect innerRect;
       
  2108     innerRect.LayoutRect( outerRect.Rect(),                            
       
  2109                           AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );            
       
  2110     
       
  2111     iExt->iBgContext->SetFrameRects( outerRect.Rect(), innerRect.Rect() ); 
       
  2112     }
       
  2113 // ----------------------------------------------------------------------------
       
  2114 // CAknVolumeControl::SetVolumeLayout(TInt aStyle)
       
  2115 // Pure layout function.
       
  2116 // ----------------------------------------------------------------------------
       
  2117 //
       
  2118 void CAknVolumePopup::SetVolumeLayout()
       
  2119     {
       
  2120     // get default parent rectangle (top pane)
       
  2121     TRect appRect;
       
  2122     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  2123                                        appRect );
       
  2124     TInt variety( 0 );
       
  2125     if ( iFlags == ESmallPopupVolumeControl )
       
  2126         {       
       
  2127         variety = 2; 
       
  2128         }
       
  2129     else if ( iFlags == ESmallPopupVolumeControlWithPercent )
       
  2130         {
       
  2131         variety = 1;
       
  2132         } 
       
  2133 	TAknLayoutRect r;
       
  2134     
       
  2135     if( iExt->iSliderUsed != KSliderUsed )
       
  2136         {
       
  2137         r.LayoutRect( appRect,AknLayoutScalable_Avkon::area_top_pane(3) );
       
  2138         r.LayoutRect( r.Rect(),
       
  2139             AknLayoutScalable_Avkon::popup_side_volume_key_window( variety ) );    	
       
  2140         }
       
  2141     else if ( iVertical ||
       
  2142               iFlags == ENaviPaneVolumeControl ||
       
  2143               iFlags == EDynRangeNaviPaneVolumeControl )
       
  2144         {
       
  2145         // Same condition for the main pane variety in 
       
  2146         // CAknNavigationControlContainer::VolumePopupRect()
       
  2147         TInt mainPaneVariety = 3; // portrait main pane
       
  2148         if ( AknStatuspaneUtils::HDLayoutActive()  || 
       
  2149              Layout_Meta_Data::IsLandscapeOrientation() )
       
  2150             {
       
  2151             // Full screen main pane variety
       
  2152             mainPaneVariety = 13;
       
  2153             }
       
  2154                     
       
  2155         r.LayoutRect(appRect,AknLayoutScalable_Avkon::main_pane(mainPaneVariety) );
       
  2156             
       
  2157         if( Parent() )
       
  2158             {
       
  2159             r.LayoutRect( Parent()->Rect(),
       
  2160             AknLayoutScalable_Avkon::popup_slider_window(
       
  2161                 Layout_Meta_Data::IsLandscapeOrientation() ) );
       
  2162             }
       
  2163         else
       
  2164             {
       
  2165             r.LayoutRect( r.Rect(),
       
  2166             AknLayoutScalable_Avkon::popup_slider_window(
       
  2167                 Layout_Meta_Data::IsLandscapeOrientation() ) );           
       
  2168             }
       
  2169         }
       
  2170     else
       
  2171         {
       
  2172         r.LayoutRect( appRect,
       
  2173             AknLayoutScalable_Apps::main_pane(0) ); 
       
  2174         r.LayoutRect( r.Rect(),
       
  2175             AknLayoutScalable_Apps::main_video_tele_pane(0) );
       
  2176         r.LayoutRect( r.Rect(),
       
  2177             AknLayoutScalable_Apps::popup_vtel_slider_window(0) );
       
  2178         }
       
  2179     
       
  2180     iParentRect = r.Rect();
       
  2181     delete iExt->iBgContext;
       
  2182 	iExt->iBgContext = NULL;
       
  2183 	TRAP_IGNORE( iExt->iBgContext = CAknsFrameBackgroundControlContext::NewL(
       
  2184             KAknsIIDQsnFrPopup, iParentRect, iParentRect, EFalse ) );
       
  2185     SetRect( iParentRect );  
       
  2186     }
       
  2187 // ---------------------------------------------------------------------------
       
  2188 // CAknVolumePopup::HandleResourceChange
       
  2189 // ---------------------------------------------------------------------------
       
  2190 //    
       
  2191 void CAknVolumePopup::HandleResourceChange( TInt aType )
       
  2192     {    
       
  2193     CCoeControl::HandleResourceChange( aType );
       
  2194     if ( aType == KAknsMessageSkinChange )
       
  2195         {
       
  2196         TRAP_IGNORE( CreateControlsL() );
       
  2197         SizeChanged();
       
  2198         }
       
  2199     else if ( aType == KEikDynamicLayoutVariantSwitch )
       
  2200         {
       
  2201         SetVolumeLayout();        
       
  2202         PositionChanged();       
       
  2203         }
       
  2204     }
       
  2205 // ---------------------------------------------------------------------------
       
  2206 // CAknVolumePopup::HandleControlEventL
       
  2207 // ---------------------------------------------------------------------------
       
  2208 //    
       
  2209 void CAknVolumePopup::HandleControlEventL( CCoeControl* aControl,
       
  2210                                            TCoeEvent aEventType )
       
  2211     {
       
  2212     // In case of navi pane volume control we must send the event
       
  2213     // also to the navigation decorator control to keep the volume levels
       
  2214     // between the popup and the application in sync.
       
  2215     if ( iVertical &&
       
  2216          aControl == iExt->iOldVolumeControl )
       
  2217         {
       
  2218         ReportEventL( aEventType );
       
  2219         }
       
  2220     
       
  2221     switch( aEventType )
       
  2222         {
       
  2223         case EEventStateChanged:
       
  2224             {        
       
  2225             TInt value = -1;
       
  2226             value = Value();
       
  2227 
       
  2228             if ( aControl == iIncArrow && iExt->VolumeControl() )
       
  2229                 {
       
  2230                 if( iExt->iSliderUsed == KSliderUsed )         
       
  2231                 	value = value + iExt->iSliderControl->StepSize();
       
  2232                 else
       
  2233                 	value++;
       
  2234                 }
       
  2235             else if ( aControl == iDecArrow && iExt->VolumeControl() )
       
  2236                 {
       
  2237                 if( iExt->iSliderUsed == KSliderUsed )
       
  2238                 	value = value - iExt->iSliderControl->StepSize();
       
  2239                 else
       
  2240                 	value--;
       
  2241                 }
       
  2242             else if ( aControl == iSpeaker )
       
  2243                 {         
       
  2244                 if( iExt->iUseMutedIcon )
       
  2245                     MutePressed();
       
  2246                 /**
       
  2247                 * Press speaker icon,Value() should return KVolumePopupMutedValue 
       
  2248                 * or saved value
       
  2249                 */
       
  2250                 }
       
  2251             if ( aControl != iSpeaker )
       
  2252                 {
       
  2253 	            TInt min, max;
       
  2254 	            GetRange(min, max);
       
  2255                 TBool valueChanged( value != iVolume );                
       
  2256                 DoSetValue(value);
       
  2257                 // because +/- button is already dimmed it does not play sensitive 
       
  2258                 // feedback on last step (in case of button repeat)
       
  2259                 if (( aControl == iDecArrow || aControl == iIncArrow ) &&
       
  2260                       valueChanged && ( value == min || value == max ) &&
       
  2261                       !iExt->iHandlingPointerEvent )
       
  2262                     {
       
  2263                     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  2264                     if ( feedback )
       
  2265                         {
       
  2266                         feedback->InstantFeedback( this, ETouchFeedbackSensitiveButton );
       
  2267                         }
       
  2268                     }
       
  2269                 }
       
  2270             ReportEventL( aEventType );
       
  2271             break;
       
  2272             }
       
  2273         case EEventRequestFocus:
       
  2274             {
       
  2275             if( aControl == iLabel && iExt->iHaveDefaultValue && iExt->iResetDefaultValue )
       
  2276                 {
       
  2277                 // Restore default value
       
  2278                 DoSetValue( iExt->iDefaultValue );
       
  2279                 ReportEventL( EEventStateChanged );
       
  2280                 }
       
  2281             break;
       
  2282             }
       
  2283         default:
       
  2284             {
       
  2285             break;
       
  2286             }
       
  2287         }
       
  2288     }
       
  2289 
       
  2290 // ---------------------------------------------------------------------------
       
  2291 // CAknVolumePopup::CleanupShowVolumePopup
       
  2292 // ---------------------------------------------------------------------------
       
  2293 //
       
  2294 void CAknVolumePopup::CleanupShowVolumePopup(TAny* aThis)
       
  2295     {
       
  2296     ((CAknVolumePopup*)aThis)->CloseVolumePopup();
       
  2297     }
       
  2298 
       
  2299 
       
  2300 // ---------------------------------------------------------------------------
       
  2301 // CAknVolumePopup::CloseVolumePopup
       
  2302 // ---------------------------------------------------------------------------
       
  2303 //
       
  2304 EXPORT_C void CAknVolumePopup::CloseVolumePopup()
       
  2305     {
       
  2306     if (iTimer)
       
  2307         {
       
  2308         iTimer->Cancel();
       
  2309         }
       
  2310 
       
  2311     if (iVisible)
       
  2312         {
       
  2313         if( !Parent() && (iFlags == ENaviPaneVolumeControl ||
       
  2314             iFlags == EDynRangeNaviPaneVolumeControl ))
       
  2315             {
       
  2316             DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront);
       
  2317             }
       
  2318     else if( !Parent() )
       
  2319             {
       
  2320             iWindowGroup.SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront );
       
  2321             }
       
  2322         
       
  2323         TRAP_IGNORE( SetVisibilityL(EFalse) );
       
  2324         }
       
  2325     }
       
  2326 
       
  2327 // ---------------------------------------------------------------------------
       
  2328 // CAknVolumePopup::SetVisibilityL
       
  2329 // ---------------------------------------------------------------------------
       
  2330 //
       
  2331 void CAknVolumePopup::SetVisibilityL(TBool aVisibility)
       
  2332     {
       
  2333     if (aVisibility)
       
  2334         {
       
  2335         iAvkonAppUi->UpdateStackedControlFlags(this, 0, ECoeStackFlagRefusesFocus);
       
  2336         SetFocus(aVisibility);
       
  2337         if (iVolume == 0 || iMuted )
       
  2338             {
       
  2339             if ( iMutedLabel )
       
  2340                 {                
       
  2341                 iMutedLabel->MakeVisible(ETrue);
       
  2342                 }
       
  2343 
       
  2344             if ( iExt->VolumeControl() )
       
  2345                 {
       
  2346                 iExt->VolumeControl()->MakeVisible(ETrue);
       
  2347                 }
       
  2348 
       
  2349             if ( iDecArrow && iIncArrow )
       
  2350                 {                
       
  2351                 iDecArrow->MakeVisible( EFalse );
       
  2352                 iIncArrow->MakeVisible( ETrue );                 
       
  2353                 }
       
  2354             }
       
  2355         else            
       
  2356             {
       
  2357             TInt min, max;
       
  2358             GetRange( min, max );
       
  2359                        
       
  2360             if ( iMutedLabel )
       
  2361                 { 
       
  2362                 iMutedLabel->MakeVisible(EFalse);
       
  2363                 }
       
  2364             if( iExt->VolumeControl() )
       
  2365                 {
       
  2366                 iExt->VolumeControl()->MakeVisible(ETrue);
       
  2367                 }
       
  2368             }
       
  2369         // "+" "-" switch on/off   
       
  2370         if( iIncArrow && iDecArrow )
       
  2371             {
       
  2372             iIncArrow->MakeVisible( iAdjustmentIndicatorOn );
       
  2373             iDecArrow->MakeVisible( iAdjustmentIndicatorOn );            
       
  2374             }
       
  2375         }
       
  2376     else
       
  2377         {
       
  2378         iAvkonAppUi->UpdateStackedControlFlags(this, ECoeStackFlagRefusesFocus, ECoeStackFlagRefusesFocus);
       
  2379         SetFocus(aVisibility);
       
  2380         if( iExt->VolumeControl() )
       
  2381             {
       
  2382             iExt->VolumeControl()->MakeVisible(EFalse);
       
  2383             }
       
  2384         if ( iMutedLabel )
       
  2385             { 
       
  2386             iMutedLabel->MakeVisible(EFalse);
       
  2387             }
       
  2388         if ( iDecArrow && iIncArrow )
       
  2389             {                
       
  2390             iDecArrow->MakeVisible( EFalse );
       
  2391             iIncArrow->MakeVisible( EFalse );                 
       
  2392             }
       
  2393         }
       
  2394     if( iSpeaker )
       
  2395         {
       
  2396         iSpeaker->MakeVisible( aVisibility && !iExt->iSpeakerHidden );
       
  2397         }
       
  2398         
       
  2399     if( iLabel )
       
  2400         {
       
  2401         iLabel->MakeVisible( aVisibility && iValueType != EAknSliderValueNone);
       
  2402         }
       
  2403 
       
  2404     MakeVisible( aVisibility );
       
  2405 
       
  2406     if( iVisible != aVisibility )
       
  2407         {
       
  2408         //Capture pointer event via CAknWsEventMonitor
       
  2409         CAknWsEventMonitor* eventMonitor = iAvkonAppUi->EventMonitor();
       
  2410         if( eventMonitor )
       
  2411             {
       
  2412             if( aVisibility )
       
  2413                 {
       
  2414                 eventMonitor->AddObserverL( iExt );
       
  2415                 }
       
  2416             else
       
  2417                 {
       
  2418                 eventMonitor->RemoveObserver( iExt );
       
  2419                 }
       
  2420             eventMonitor->Enable( aVisibility );
       
  2421             }
       
  2422         }
       
  2423         
       
  2424     iVisible = aVisibility;
       
  2425     if( !iVisible )
       
  2426         {
       
  2427         ReportEventL( MCoeControlObserver::EEventStateChanged );
       
  2428         }
       
  2429     }
       
  2430     
       
  2431 // ---------------------------------------------------------------------------
       
  2432 // CAknVolumePopup::PositionChanged
       
  2433 // ---------------------------------------------------------------------------
       
  2434 //
       
  2435 void CAknVolumePopup::PositionChanged()
       
  2436     {
       
  2437     if ( iExt->iSliderUsed == KSliderUsed || iFlags == ESmallPopupVolumeControl || 
       
  2438         iFlags == ESmallPopupVolumeControlWithPercent
       
  2439          )
       
  2440         {        
       
  2441         // adjust popup so that if will fit into screen
       
  2442         TRect appRect;
       
  2443         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  2444                                            appRect); 
       
  2445         
       
  2446         // subtract cba's rect if it is visible
       
  2447         CCoeControl* cba = iAvkonAppUi->Cba();
       
  2448         if( cba && cba->IsVisible() )
       
  2449             {
       
  2450             TAknWindowComponentLayout cbaLayout;
       
  2451             TAknLayoutRect cbaRect;
       
  2452             
       
  2453             if( Layout_Meta_Data::IsLandscapeOrientation() )
       
  2454                 {
       
  2455                 cbaLayout = AknLayoutScalable_Avkon::area_side_right_pane( 0 );
       
  2456                 cbaRect.LayoutRect( appRect, cbaLayout );
       
  2457                 appRect.iBr.iX -= cbaRect.Rect().Width();
       
  2458                 }
       
  2459             else
       
  2460                 {
       
  2461                 cbaLayout = AknLayoutScalable_Avkon::area_bottom_pane( 0 );
       
  2462                 cbaRect.LayoutRect( appRect, cbaLayout );
       
  2463                 appRect.iBr.iY -= cbaRect.Rect().Height();
       
  2464                 }
       
  2465             }
       
  2466         
       
  2467         TPoint position = Position();
       
  2468         if( !Parent() )
       
  2469             {
       
  2470             if ( Position().iX < appRect.iTl.iX )
       
  2471                 {
       
  2472                 position.iX = appRect.iTl.iX;
       
  2473                 }
       
  2474             if ( Position().iY < appRect.iTl.iY )
       
  2475                 {
       
  2476                 position.iY = appRect.iTl.iY;
       
  2477                 }
       
  2478             if ( Position().iX + Rect().Width() > appRect.iBr.iX )
       
  2479                 {
       
  2480                 position.iX = appRect.iBr.iX - Rect().Width();
       
  2481                 }
       
  2482             if ( Position().iY + Rect().Height()> appRect.iBr.iY )
       
  2483                 {
       
  2484                 position.iY = appRect.iBr.iY - Rect().Height();
       
  2485                 }        
       
  2486             }
       
  2487         else
       
  2488             {
       
  2489             if ( PositionRelativeToScreen().iX < appRect.iTl.iX )
       
  2490                 {
       
  2491                 iPosition.iX = appRect.iTl.iX - Parent()->PositionRelativeToScreen().iX;
       
  2492                 }
       
  2493             if ( PositionRelativeToScreen().iY < appRect.iTl.iY )
       
  2494                 {
       
  2495                 iPosition.iY = appRect.iTl.iY - Parent()->PositionRelativeToScreen().iY;
       
  2496                 }
       
  2497             if ( PositionRelativeToScreen().iX + Rect().Width() > appRect.iBr.iX )
       
  2498                 {
       
  2499                 iPosition.iX = appRect.iBr.iX - Rect().Width() - Parent()->PositionRelativeToScreen().iX;
       
  2500                 }
       
  2501             if ( PositionRelativeToScreen().iY + Rect().Height()> appRect.iBr.iY )
       
  2502                 {
       
  2503                 iPosition.iY = appRect.iBr.iY - Rect().Height() - Parent()->PositionRelativeToScreen().iY;
       
  2504                 } 
       
  2505             }
       
  2506         SetRect( TRect( position, Rect().Size() ) );
       
  2507         }
       
  2508     }
       
  2509 
       
  2510     
       
  2511 // ---------------------------------------------------------------------------
       
  2512 // CAknVolumePopup::Draw
       
  2513 // ---------------------------------------------------------------------------
       
  2514 //    
       
  2515 void CAknVolumePopup::Draw( CWindowGc &aGc, 
       
  2516                             const CCoeControl& aControl, 
       
  2517                             const TRect& ) const
       
  2518     {
       
  2519     /*when the slider's value is minium or maximum, of the user
       
  2520       press up/down key, the marker will flick. when this happened,
       
  2521       the background should be draw here, because the drawing is not
       
  2522       trigered from drawing server.*/
       
  2523       
       
  2524     aGc.SetClippingRect( aControl.Rect() );
       
  2525     
       
  2526     TAknLayoutRect windowRect;
       
  2527     
       
  2528     windowRect.LayoutRect( iParentRect,
       
  2529                        AknLayoutScalable_Avkon::bg_popup_sub_pane_cp22());  
       
  2530     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  2531     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
  2532 
       
  2533     TBool frameDrawn( EFalse );
       
  2534     if ( CAknEnv::Static()->TransparencyEnabled() )
       
  2535         {
       
  2536         // the added flag removes the white bg for transparency
       
  2537         frameDrawn = AknsDrawUtils::Background( skin, cc, this, aGc, 
       
  2538                                                     aControl.Rect(), 
       
  2539                                                     KAknsDrawParamNoClearUnderImage );
       
  2540         }
       
  2541     else
       
  2542         {
       
  2543         frameDrawn = AknsDrawUtils::Background( skin, cc, this, aGc, 
       
  2544                                                     aControl.Rect() );
       
  2545         
       
  2546         }
       
  2547 
       
  2548     if( !frameDrawn )
       
  2549         {
       
  2550         aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2551         aGc.SetPenStyle( CGraphicsContext::ENullPen );
       
  2552         aGc.SetBrushColor( windowRect.Color() );
       
  2553         aGc.DrawRect( windowRect.Rect() );
       
  2554         }
       
  2555     }
       
  2556       
       
  2557 // ----------------------------------------------------------------------------
       
  2558 // CAknVolumePopup::SetGraphics
       
  2559 // ----------------------------------------------------------------------------
       
  2560 //
       
  2561 EXPORT_C void CAknVolumePopup::SetGraphics( TInt aElement, CFbsBitmap* aBitmap,
       
  2562                                             CFbsBitmap* aMask )
       
  2563     {
       
  2564     if ( aElement < 0 || 
       
  2565          aElement > EElemMinusButtonSelected || 
       
  2566          !aBitmap ||
       
  2567          ( aElement > CAknSlider::EElemMarkerSelected && 
       
  2568            aElement < EElemSpeaker ) )
       
  2569         {
       
  2570         Panic( EAknPanicInvalidValue );
       
  2571         }
       
  2572     if( aElement >= EElemSpeaker )
       
  2573         {
       
  2574         TRAP_IGNORE( SetControlIconL( aElement,  aBitmap, aMask  ) );
       
  2575         }
       
  2576     else
       
  2577         {
       
  2578         iExt->SetGraphics( aElement, aBitmap, aMask );
       
  2579         }              
       
  2580     }
       
  2581     
       
  2582 // ----------------------------------------------------------------------------
       
  2583 // CAknVolumePopup::MopSupplyObject
       
  2584 // ----------------------------------------------------------------------------
       
  2585 //    
       
  2586 TTypeUid::Ptr CAknVolumePopup::MopSupplyObject( TTypeUid aId )
       
  2587     {
       
  2588     if( aId.iUid == MAknsControlContext::ETypeId && iExt && iExt->iBgContext )
       
  2589         {
       
  2590         // Supply background skin context for scroll bars.
       
  2591         return MAknsControlContext::SupplyMopObject( aId, iExt->iBgContext);
       
  2592         }
       
  2593 
       
  2594     return CCoeControl::MopSupplyObject( aId );
       
  2595     }        
       
  2596 // ----------------------------------------------------------------------------
       
  2597 // CAknVolumePopup::SetLabelColor
       
  2598 // ----------------------------------------------------------------------------
       
  2599 //    
       
  2600 void CAknVolumePopup::SetLabelColor()
       
  2601     {
       
  2602 	TRgb color;
       
  2603     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
  2604     TInt error = AknsUtils::GetCachedColor( skin,
       
  2605                                             color,
       
  2606                                             KAknsIIDQsnTextColors,
       
  2607                                             EAknsCIQsnTextColorsCG19 );
       
  2608     if ( !error )
       
  2609         {
       
  2610         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iLabel,
       
  2611                                                             EColorLabelText,
       
  2612                                                             color) );
       
  2613         }
       
  2614     
       
  2615     }
       
  2616 
       
  2617 // ----------------------------------------------------------------------------
       
  2618 // CAknVolumePopup::ClosePopupWhenTapped
       
  2619 // ----------------------------------------------------------------------------
       
  2620 //    
       
  2621 EXPORT_C void CAknVolumePopup::ClosePopupWhenTappedOutside( TBool aEnable )
       
  2622     {
       
  2623     iExt->iClosePopupWhenTapped = aEnable;
       
  2624     }
       
  2625     
       
  2626 // ----------------------------------------------------------------------------
       
  2627 // CAknVolumePopup::SetDefaultValue
       
  2628 // ----------------------------------------------------------------------------
       
  2629 // 
       
  2630 EXPORT_C void CAknVolumePopup::SetDefaultValue( TInt aValue )
       
  2631     {
       
  2632     TInt min,max;
       
  2633     GetRange( min, max );
       
  2634     
       
  2635      __ASSERT_DEBUG( aValue >= min &&
       
  2636                      aValue<= max,
       
  2637                      Panic( EAknPanicOutOfRange ) );
       
  2638                      
       
  2639     iExt->iDefaultValue = aValue;
       
  2640     iExt->iHaveDefaultValue = ETrue;
       
  2641     }
       
  2642 
       
  2643 // ----------------------------------------------------------------------------
       
  2644 // CAknVolumePopup::EnableValueFieldTouch
       
  2645 // ----------------------------------------------------------------------------
       
  2646 // 
       
  2647 EXPORT_C void CAknVolumePopup::EnableResetViaValueField( TBool aEnabled )
       
  2648     {
       
  2649     iExt->iResetDefaultValue = aEnabled;
       
  2650     }
       
  2651 
       
  2652 
       
  2653 //  End of File