2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Volume editor class
19 #ifndef AKNVOLUMECONTROL_H
20 #define AKNVOLUMECONTROL_H
22 #include <AknNaviDecoratorObserver.h>
24 #include <AknControl.h>
27 class MAknsSkinInstance;
28 class CVolumeExtension;
31 * Used for controlling the volume setting on the phone.
33 class CAknVolumeControl : public CAknControl, public MAknNaviDecoratorObserver
39 * C++ default constructor.
41 IMPORT_C CAknVolumeControl();
46 IMPORT_C ~CAknVolumeControl();
51 * @param aValue The new volume.
53 IMPORT_C void SetValue(TInt aValue);
58 * @return The volume setting.
60 IMPORT_C TInt Value() const;
63 * Sets the range of the volume control. Maximum value must be greater
64 * than the minimum value, or the method will Panic.
67 * @param aMinimumValue The minimum value of the volume control
68 * @param aMaximumValue The maximum value of the volume control
70 * Will panic with EAknPanicInvalidValue if the minimum value is
71 * greater or equal than maximum value.
74 IMPORT_C void SetRange( TInt aMinimumValue, TInt aMaximumValue );
77 * Gets the range of the volume control.
79 * @param aMinimumValue The minimum value of the volume control
80 * @param aMaximumValue The maximum value of the volume control
82 IMPORT_C void GetRange( TInt& aMinimumValue, TInt& aMaximumValue );
84 void SuppressDrawing( TBool aSuppress );
85 public: // from CCoeControl
88 * From @c CCoeControl.
90 * Gets minimun size of layout rectangle.
92 * @return Minimum layout rectangle size.
101 * @param aKeyEvent Key event to be handled.
102 * @param aType Type of the event.
103 * @return Returns @c EKeyConsumed if key event was handled.
105 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
108 * From @c CCoeControl.
110 * Construct item from given resource.
112 * @param aReader Resource reader reading the wanted resource set.
114 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
117 * From @c CCoeControl.
119 * Handles the change of @c CAknVolumeControl's resources.
121 * @param aType Type of resource to change
123 IMPORT_C void HandleResourceChange(TInt aType);
126 * Creates volume bitmap to "list pane for setting item"
127 * (setting option item volume graphic). Ownership of the returned bitmap
128 * is transfered to the caller.
130 * @param aValue Current value (1-10)
131 * @return Volume bitmap. Ownership of the bitmap is transfered to
134 IMPORT_C static CFbsBitmap* CreateBitmapL(TInt aValue);
137 * Creates general volume icon to "list pane for setting item"
138 * (setting option item volume graphic). Ownership of the returned icon
139 * is transfered to the caller.
141 * @param aValue Current value (1-10)
142 * @return Volume icon. Ownership of the icon is transfered to
145 IMPORT_C static CGulIcon* CreateSetStyleListBoxIconL( TInt aValue );
148 * Creates Hi-res volume icon to "list pane for setting item"
149 * (setting option item volume graphic). Ownership of the returned icon
150 * is transfered to the caller.
153 * @param aValue Current value (1-10)
154 * @param aMinimum Minimum for Hi-res volume control
155 * @param aMaximum Maximum for Hi-res volume control
156 * @return Volume icon. Ownership of the icon is transfered to
159 IMPORT_C static CGulIcon* CreateSetDynRangeStyleListBoxIconL( TInt aValue,
164 * Informs the volume control about whether or not it's placed on the
165 * navi pane's control stack
167 * @param aIsOnNaviStack @c ETrue if the control is on the navi stack,
168 * @c EFalse otherwise.
170 void HandleNaviStackChange( TBool aIsOnNaviStack );
172 protected: // from CCoeControl
175 * From @c CCoeControl.
177 * Handles layout change.
182 * From @c CCoeControl.
184 * Draws every visible item into the specified rectangle.
186 * @param aRect the specified rectangle.
188 void Draw(const TRect& aRect) const;
193 * From @c CCoeControl.
195 * Handles pointer events.
197 * @param aPointerEvent Pointer event to be handled
199 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
202 * From @c MAknNaviDecoratorObserver
204 * Handles Navidecorator events (Arrow left and arrow right)
206 * @param aEventID ID of event to be handled
208 IMPORT_C void HandleNaviDecoratorEventL( TInt aEventID );
215 IMPORT_C void* ExtensionInterface( TUid aInterface );
222 void SetVolumeLayout(TInt aStyle);
225 * Starts a timer for feedback effect visualization
230 * A callback function for feedback effect.
232 * @param aThis Pointer to this volume control.
234 static TInt IndicationDrawCallbackL( TAny* aThis );
237 * Implementation of the feedback effect (Blinking when the volume value
238 * is set to the max/min value).
240 void SmallDirectionIndicationL();
243 * (Re)create the navi icon
245 void CreateNaviIconL();
247 // Refactored: Used for drawing different styles.
248 void DrawSettingsStyleVolumeControl( const TRect& aRect ) const;
249 void DrawDefaultStyleVolumeControl( const TRect& aRect ) const;
250 void DrawSkinnedDefaultStyleVolumeControl( const TRect& aRect ) const;
251 void DrawDynRangeSettingsStyleVolumeControl( const TRect& aVolumeArea ) const;
254 * Calculates the volume icon areas using given volume value.
256 * @param aVolume Volume used as the ratio between active and inactive areas.
257 * @param aDrawArea The whole drawing area.
258 * @param aActiveRect Drawing area for the active icon.
259 * @param aInactiveRect Drawing area for the inactive icon.
261 void CalcVolumeIconAreas( const TInt aVolume,
262 const TRect& aDrawArea,
264 TRect& aInactiveRect ) const;
267 * Utility function for scaling the value between iMiminumValue and
268 * iMaximumValue to a range of [0-10]. This is needed for old drawing
269 * functions that assume only 10 step volume control.
271 * @return Colume value scaled to range of [0-10].
273 TInt CAknVolumeControl::ScaledValue() const;
276 * Set extended touch area to be used
278 void UseExtendedTouchArea();
283 CFbsBitmap* iMaskBitmap;
285 CVolumeExtension* iExtension;
292 #endif // AKNVOLUMECONTROL_H