epoc32/include/mw/aknvolumecontrol.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  Volume editor class
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef AKNVOLUMECONTROL_H
williamr@2
    20
#define AKNVOLUMECONTROL_H
williamr@2
    21
williamr@2
    22
#include <aknnavidecoratorobserver.h>
williamr@2
    23
williamr@2
    24
#include <AknControl.h>
williamr@2
    25
williamr@2
    26
class CGulIcon;
williamr@2
    27
class MAknsSkinInstance;
williamr@2
    28
class CVolumeExtension;
williamr@2
    29
williamr@2
    30
/**
williamr@2
    31
 * Used for controlling the volume setting on the phone.
williamr@2
    32
 */
williamr@2
    33
class CAknVolumeControl : public CAknControl, public MAknNaviDecoratorObserver
williamr@2
    34
    {
williamr@2
    35
williamr@2
    36
    public:
williamr@2
    37
williamr@2
    38
        /** 
williamr@2
    39
         * C++ default constructor. 
williamr@2
    40
         */
williamr@2
    41
        IMPORT_C CAknVolumeControl();
williamr@2
    42
williamr@2
    43
        /** 
williamr@2
    44
         * Destructor. 
williamr@2
    45
         */
williamr@2
    46
        IMPORT_C ~CAknVolumeControl();
williamr@2
    47
williamr@2
    48
        /** 
williamr@2
    49
         * Sets volume.
williamr@2
    50
         *
williamr@2
    51
         * @param aValue The new volume.
williamr@2
    52
         */
williamr@2
    53
        IMPORT_C void SetValue(TInt aValue);
williamr@2
    54
williamr@2
    55
        /** 
williamr@2
    56
         * Gets volume.
williamr@2
    57
         *
williamr@2
    58
         * @return The volume setting.
williamr@2
    59
         */ 
williamr@2
    60
        IMPORT_C TInt Value() const;
williamr@2
    61
williamr@2
    62
        /**
williamr@2
    63
        * Sets the range of the volume control. Maximum value must be greater 
williamr@2
    64
        * than the minimum value, or the method will Panic.
williamr@2
    65
        *
williamr@2
    66
        * @since 3.2
williamr@2
    67
        * @param aMinimumValue The minimum value of the volume  control
williamr@2
    68
        * @param aMaximumValue The maximum value of the volume control
williamr@2
    69
        * @par Exceptions:
williamr@2
    70
        *   Will panic with EAknPanicInvalidValue if the minimum value is 
williamr@2
    71
        *   greater or equal than maximum value.
williamr@2
    72
        *
williamr@2
    73
        */
williamr@2
    74
        IMPORT_C void SetRange( TInt aMinimumValue, TInt aMaximumValue );
williamr@2
    75
        
williamr@2
    76
        /**
williamr@2
    77
        * Gets the range of the volume control.
williamr@2
    78
        * @since 3.2
williamr@2
    79
        * @param aMinimumValue The minimum value of the volume  control
williamr@2
    80
        * @param aMaximumValue The maximum value of the volume control
williamr@2
    81
        */
williamr@2
    82
        IMPORT_C void GetRange( TInt& aMinimumValue, TInt& aMaximumValue );
williamr@2
    83
        
williamr@2
    84
        void SuppressDrawing( TBool aSuppress );
williamr@2
    85
    public: // from CCoeControl
williamr@2
    86
williamr@2
    87
        /** 
williamr@2
    88
         * From @c CCoeControl.
williamr@2
    89
         * 
williamr@2
    90
         * Gets minimun size of layout rectangle.
williamr@2
    91
         *
williamr@2
    92
         * @return Minimum layout rectangle size. 
williamr@2
    93
         */ 
williamr@2
    94
        TSize MinimumSize();
williamr@2
    95
   
williamr@2
    96
        /** 
williamr@2
    97
         * From @c CCoeControl 
williamr@2
    98
         *
williamr@2
    99
         * Handles key events.
williamr@2
   100
         * 
williamr@2
   101
         * @param aKeyEvent Key event to be handled.
williamr@2
   102
         * @param aType Type of the event.
williamr@2
   103
         * @return Returns @c EKeyConsumed if key event was handled. 
williamr@2
   104
         */ 
williamr@2
   105
        TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
williamr@2
   106
        
williamr@2
   107
        /**
williamr@2
   108
         * From @c CCoeControl.
williamr@2
   109
         *
williamr@2
   110
         * Construct item from given resource.
williamr@2
   111
         *
williamr@2
   112
         * @param aReader Resource reader reading the wanted resource set. 
williamr@2
   113
         */
williamr@2
   114
        IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
williamr@2
   115
        
williamr@2
   116
        /** 
williamr@2
   117
         * From @c CCoeControl.
williamr@2
   118
         *
williamr@2
   119
         * Handles the change of @c CAknVolumeControl's resources. 
williamr@2
   120
         * 
williamr@2
   121
         * @param aType Type of resource to change
williamr@2
   122
         */ 
williamr@2
   123
        IMPORT_C void HandleResourceChange(TInt aType);
williamr@2
   124
        
williamr@2
   125
        /**
williamr@2
   126
         * Creates volume bitmap to "list pane for setting item" 
williamr@2
   127
         * (setting option item volume graphic). Ownership of the returned bitmap
williamr@2
   128
         * is transfered to the caller.
williamr@2
   129
         *
williamr@2
   130
         * @param  aValue Current value (1-10)
williamr@2
   131
         * @return Volume bitmap. Ownership of the bitmap is transfered to 
williamr@2
   132
         *         the caller.
williamr@2
   133
         */
williamr@2
   134
        IMPORT_C static CFbsBitmap* CreateBitmapL(TInt aValue);
williamr@2
   135
    
williamr@2
   136
        /**
williamr@2
   137
        * Creates general volume icon to "list pane for setting item" 
williamr@2
   138
        * (setting option item volume graphic). Ownership of the returned icon
williamr@2
   139
        * is transfered to the caller.
williamr@2
   140
        *
williamr@2
   141
        * @param  aValue Current value (1-10)
williamr@2
   142
        * @return Volume icon. Ownership of the icon is transfered to 
williamr@2
   143
        *         the caller.
williamr@2
   144
        */
williamr@2
   145
        IMPORT_C static CGulIcon* CreateSetStyleListBoxIconL( TInt aValue );
williamr@2
   146
        
williamr@2
   147
        /**
williamr@2
   148
        * Creates Hi-res volume icon to "list pane for setting item" 
williamr@2
   149
        * (setting option item volume graphic). Ownership of the returned icon
williamr@2
   150
        * is transfered to the caller.
williamr@2
   151
        *
williamr@2
   152
        * @since 3.2
williamr@2
   153
        * @param  aValue Current value (1-10)
williamr@2
   154
        * @param  aMinimum Minimum for Hi-res volume control
williamr@2
   155
        * @param  aMaximum Maximum for Hi-res volume control        
williamr@2
   156
        * @return Volume icon. Ownership of the icon is transfered to 
williamr@2
   157
        *         the caller.
williamr@2
   158
        */
williamr@2
   159
        IMPORT_C static CGulIcon* CreateSetDynRangeStyleListBoxIconL( TInt aValue,
williamr@2
   160
                                                                  TInt aMinimum,
williamr@2
   161
                                                                  TInt aMaximum );
williamr@2
   162
williamr@2
   163
        /**
williamr@2
   164
        * Informs the volume control about whether or not it's placed on the
williamr@2
   165
        * navi pane's control stack
williamr@2
   166
        *
williamr@2
   167
        * @param  aIsOnNaviStack  @c ETrue if the control is on the navi stack,
williamr@2
   168
        *                         @c EFalse otherwise.
williamr@2
   169
        */                                                                  
williamr@2
   170
        void HandleNaviStackChange( TBool aIsOnNaviStack );
williamr@2
   171
        
williamr@2
   172
    protected: // from CCoeControl
williamr@2
   173
williamr@2
   174
        /** 
williamr@2
   175
         * From @c CCoeControl. 
williamr@2
   176
         *
williamr@2
   177
         * Handles layout change. 
williamr@2
   178
         */
williamr@2
   179
        void SizeChanged();
williamr@2
   180
        
williamr@2
   181
        /**
williamr@2
   182
         * From @c CCoeControl.
williamr@2
   183
         *
williamr@2
   184
         * Draws every visible item into the specified rectangle.
williamr@2
   185
         *
williamr@2
   186
         * @param aRect the specified rectangle.
williamr@2
   187
         */ 
williamr@2
   188
        void Draw(const TRect& aRect) const;
williamr@2
   189
        
williamr@2
   190
    public:
williamr@2
   191
williamr@2
   192
        /**
williamr@2
   193
         * From @c CCoeControl. 
williamr@2
   194
         *
williamr@2
   195
         * Handles pointer events.
williamr@2
   196
         * 
williamr@2
   197
         * @param aPointerEvent Pointer event to be handled
williamr@2
   198
         */
williamr@2
   199
        IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@2
   200
williamr@2
   201
        /**
williamr@2
   202
         * From @c MAknNaviDecoratorObserver
williamr@2
   203
         *
williamr@2
   204
         * Handles Navidecorator events (Arrow left and arrow right)
williamr@2
   205
         * 
williamr@2
   206
         * @param aEventID ID of event to be handled
williamr@2
   207
         */
williamr@2
   208
        IMPORT_C void HandleNaviDecoratorEventL( TInt aEventID ); 
williamr@2
   209
williamr@2
   210
    private:
williamr@2
   211
    
williamr@2
   212
        /**
williamr@2
   213
        * From CAknControl
williamr@2
   214
        */
williamr@2
   215
        IMPORT_C void* ExtensionInterface( TUid aInterface );        
williamr@2
   216
        
williamr@2
   217
    private:
williamr@2
   218
        
williamr@2
   219
        /**
williamr@2
   220
        *
williamr@2
   221
        */
williamr@2
   222
        void SetVolumeLayout(TInt aStyle);
williamr@2
   223
        
williamr@2
   224
        /**
williamr@2
   225
        * Starts a timer for feedback effect visualization 
williamr@2
   226
        */
williamr@2
   227
        void StartTimerL();
williamr@2
   228
        
williamr@2
   229
    	/**
williamr@2
   230
    	 * A callback function for feedback effect.
williamr@2
   231
    	 *
williamr@2
   232
    	 * @param aThis Pointer to this volume control.
williamr@2
   233
    	 */
williamr@2
   234
        static TInt IndicationDrawCallbackL( TAny* aThis );
williamr@2
   235
		
williamr@2
   236
		/**
williamr@2
   237
         * Implementation of the feedback effect (Blinking when the volume value
williamr@2
   238
         * is set to the max/min value).
williamr@2
   239
         */
williamr@2
   240
		void SmallDirectionIndicationL();
williamr@2
   241
williamr@2
   242
        /**
williamr@2
   243
        * (Re)create the navi icon
williamr@2
   244
        */
williamr@2
   245
        void CreateNaviIconL();
williamr@2
   246
        
williamr@2
   247
        // Refactored: Used for drawing different styles.
williamr@2
   248
        void DrawSettingsStyleVolumeControl( const TRect& aRect ) const;
williamr@2
   249
        void DrawDefaultStyleVolumeControl( const TRect& aRect ) const;
williamr@2
   250
        void DrawSkinnedDefaultStyleVolumeControl( const TRect& aRect ) const;
williamr@2
   251
        void DrawDynRangeSettingsStyleVolumeControl( const TRect& aVolumeArea ) const;
williamr@2
   252
    
williamr@2
   253
        /**
williamr@2
   254
        * Calculates the volume icon areas using given volume value.
williamr@2
   255
        *
williamr@2
   256
        * @param aVolume Volume used as the ratio between active and inactive areas.
williamr@2
   257
        * @param aDrawArea The whole drawing area.
williamr@2
   258
        * @param aActiveRect Drawing area for the active icon.
williamr@2
   259
        * @param aInactiveRect Drawing area for the inactive icon.
williamr@2
   260
        */    
williamr@2
   261
        void CalcVolumeIconAreas( const TInt aVolume, 
williamr@2
   262
                                  const TRect& aDrawArea,
williamr@2
   263
                                  TRect& aActiveRect, 
williamr@2
   264
                                  TRect& aInactiveRect ) const;
williamr@2
   265
williamr@2
   266
        /**
williamr@2
   267
        * Utility function for scaling the value between iMiminumValue and 
williamr@2
   268
        * iMaximumValue to a range of [0-10]. This is needed for old drawing 
williamr@2
   269
        * functions that assume only 10 step volume control.
williamr@2
   270
        *
williamr@2
   271
        * @return Colume value scaled to range of [0-10].
williamr@2
   272
        */
williamr@2
   273
        TInt CAknVolumeControl::ScaledValue() const;
williamr@2
   274
        
williamr@2
   275
williamr@2
   276
    private:        
williamr@2
   277
    
williamr@2
   278
        CFbsBitmap*         iBitmap;
williamr@2
   279
        CFbsBitmap*         iMaskBitmap;
williamr@2
   280
        TPoint              iStartPos;
williamr@2
   281
        CVolumeExtension*   iExtension;
williamr@2
   282
        TInt                iSpare1;
williamr@2
   283
        TPoint              iBmpPos;
williamr@2
   284
        TInt                iValue;
williamr@2
   285
        TInt                iStyle;
williamr@2
   286
    };
williamr@2
   287
williamr@2
   288
#endif        // AKNVOLUMECONTROL_H