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