1 /* |
|
2 * Copyright (c) 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: Header for presentation element - vertical slider. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MUL_SLIDERVERTICAL_H |
|
22 #define MUL_SLIDERVERTICAL_H |
|
23 |
|
24 //INCLUDES |
|
25 #include <alf/alfanchorlayout.h> |
|
26 #include "alf/alfelement.h" |
|
27 #include <alf/alfimagevisual.h> |
|
28 #include <alf/alflayout.h> |
|
29 #include <alf/alftexture.h> |
|
30 #include <mul/imulsliderwidget.h> |
|
31 |
|
32 #include <alf/ialfwidgeteventhandler.h> |
|
33 #include <alf/alfbitmapprovider.h> |
|
34 |
|
35 #include "mulslidermodel.h" |
|
36 #include <AknLayout2Def.h> |
|
37 #include "imulsliderbaseelementinternal.h" |
|
38 |
|
39 |
|
40 namespace duiuimodel |
|
41 { |
|
42 class DuiNode; |
|
43 } |
|
44 |
|
45 using namespace osncore; |
|
46 |
|
47 namespace Alf |
|
48 { |
|
49 struct MulSliderPos; |
|
50 |
|
51 |
|
52 // Forward declarations |
|
53 class IAlfWidgetEventHandler; |
|
54 class CAlfWidgetControl; |
|
55 class MulSliderLongTapTimer; |
|
56 |
|
57 /** |
|
58 * Default Base Element of the Scrollbar. |
|
59 */ |
|
60 class MulSliderVertical : |
|
61 public AlfElement, |
|
62 public IAlfWidgetEventHandler, |
|
63 public IMulSliderBaseElementInternal, |
|
64 public MAlfBitmapProvider |
|
65 { |
|
66 public: |
|
67 |
|
68 /** |
|
69 * Constructor |
|
70 * @param aControl Widget control. |
|
71 * @param aName Name of the item element. |
|
72 * @param aCustomData . |
|
73 * @param mNode . |
|
74 * @since S60 ?S60_version |
|
75 */ |
|
76 MulSliderVertical ( |
|
77 CAlfWidgetControl& aControl, |
|
78 const char* aName, |
|
79 AlfCustomInitDataBase* aCustomData=NULL); |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 */ |
|
84 virtual ~MulSliderVertical(); |
|
85 |
|
86 /** |
|
87 * bitmap provider. |
|
88 * @since S60 ?S60_version |
|
89 * @param aId bitmap ID. |
|
90 * @param aBitmap bitmap. |
|
91 * @param aMaskBitmap mask for the bitmap. |
|
92 * @return |
|
93 */ |
|
94 void ProvideBitmapL (TInt aId, |
|
95 CFbsBitmap *& aBitmap, |
|
96 CFbsBitmap *& aMaskBitmap); |
|
97 |
|
98 /** |
|
99 * From IAlfInterfaceBase. |
|
100 * Getter for interfaces provided by the Button widget class. |
|
101 * @since S60 ?S60_version |
|
102 * @param aType A descriptor to identify the type of the queried interface. |
|
103 * @return The queried interface, or NULL if the interface is not |
|
104 * supported or available. |
|
105 */ |
|
106 virtual IAlfInterfaceBase* makeInterface(const IfId& aType); |
|
107 |
|
108 |
|
109 /** |
|
110 * Sets the text for the counter visual |
|
111 * |
|
112 * @param aNewString The counter visual text value |
|
113 * @throw Invalid Argument incase there is no layout at zeroth position |
|
114 */ |
|
115 void SetTextLabels(const char* aStr); |
|
116 |
|
117 |
|
118 //-------------------------------------------------------------------------- |
|
119 //Overriden Apis from IAlfWidgetEventHandlers |
|
120 //-------------------------------------------------------------------------- |
|
121 // |
|
122 |
|
123 /** |
|
124 * Used to identify event handlers that are capable of handling |
|
125 * a specified key or custom event. |
|
126 * Pointer event handlers cannot be identified directly, |
|
127 * since they are dependent on the presentation. |
|
128 * Therefore, pointer event handlers should be associated with |
|
129 * a custom event ID that can be used to simulate the actual pointer event. |
|
130 * @since S60 ?S60_version |
|
131 * @param aEvent The event. |
|
132 * @param aControl |
|
133 * @return <code>ETrue</code> if the event can be processed. |
|
134 * Otherwise <code>EFalse</code>. |
|
135 */ |
|
136 bool accept(CAlfWidgetControl& aControl, const TAlfEvent& aEvent) const; |
|
137 |
|
138 |
|
139 |
|
140 /** |
|
141 * @see IAlfWidgetEventHandler |
|
142 */ |
|
143 virtual AlfEventHandlerType eventHandlerType(); |
|
144 |
|
145 /** |
|
146 * @see IAlfWidgetEventHandler |
|
147 */ |
|
148 virtual AlfEventHandlerExecutionPhase eventExecutionPhase(); |
|
149 /** |
|
150 * Called when an input event is being offered to this event handler. |
|
151 * The return value is used to indicate if the event was processed. |
|
152 * Processed events may not be offered to other event handlers. |
|
153 * @since S60 ?S60_version |
|
154 * @param aControl The parent control of this event handler. |
|
155 * @param aEvent The event. |
|
156 * @return <code>ETrue</code> if the event was processed. |
|
157 * Otherwise <code>EFalse</code>. |
|
158 */ |
|
159 |
|
160 |
|
161 virtual AlfEventStatus offerEvent( |
|
162 CAlfWidgetControl& aControl, |
|
163 const TAlfEvent& aEvent ); |
|
164 |
|
165 /** |
|
166 * Defines the widget states, where the event handler is active. |
|
167 * By default, if this method is not called, the event handler is expected |
|
168 * to be active in all states. |
|
169 * @param aStates A bitmask defining the widget states, where the event |
|
170 * handler is active. The low 16 bits are reserved for the states |
|
171 * defined by the framework in <TODO: add reference>. The high 16 bits are |
|
172 * available for states defined by the client code. |
|
173 */ |
|
174 void setActiveStates(unsigned int aStates); |
|
175 |
|
176 /** |
|
177 * Sets AlfWidgetEventHandlerInitData to event handler. |
|
178 * @param aData A data structure which contains for example id of the event |
|
179 * handler. |
|
180 */ |
|
181 virtual void setEventHandlerData( |
|
182 const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
183 { |
|
184 |
|
185 } |
|
186 |
|
187 /** |
|
188 * Returns AlfWidgetEventHandlerInitData. |
|
189 * @return A pointer to AlfWidgetEventHandlerInitData structure |
|
190 * which contains for example id of the event handler. |
|
191 */ |
|
192 virtual AlfWidgetEventHandlerInitData* eventHandlerData() |
|
193 { |
|
194 return NULL; |
|
195 } |
|
196 |
|
197 /** |
|
198 * Friend class for timer functions. |
|
199 * |
|
200 */ |
|
201 friend class MulSliderLongTapTimer; |
|
202 |
|
203 |
|
204 //-------------------------------------------------------------------------- |
|
205 //Overriden Apis from IMulSliderBaseElementInternal |
|
206 //-------------------------------------------------------------------------- |
|
207 // |
|
208 |
|
209 /** |
|
210 * Notified when the base layout of scrollbar changes . |
|
211 * Relayouts all the visuals with respect to the new size. |
|
212 */ |
|
213 void baseLayoutSizeChanged(); |
|
214 |
|
215 /** |
|
216 * createVisualization |
|
217 * @param aTemplateId .aTemplateId takes 3 or 9 as parameter. |
|
218 */ |
|
219 void createVisualization(sliderTemplate aTemplateId); |
|
220 |
|
221 /** |
|
222 * updateVisualization |
|
223 * Notified when the base layout of scrollbar changes . |
|
224 * Relayouts all the visuals with respect to the new size. |
|
225 */ |
|
226 void updateVisualization(); |
|
227 |
|
228 /** |
|
229 * Updates Text visualization. |
|
230 * |
|
231 */ |
|
232 |
|
233 void updateTextVisualization(); |
|
234 /** |
|
235 * Sets transparency for the Widget |
|
236 * @param aTransparent - opacity level |
|
237 */ |
|
238 void MakeTransparent(bool aVal); |
|
239 /** |
|
240 *Stops all event handling |
|
241 * |
|
242 * |
|
243 */ |
|
244 void stopEvents() ; |
|
245 private: |
|
246 /** |
|
247 * Set skin images on scrollbar track |
|
248 */ |
|
249 void setTrackImage(); |
|
250 |
|
251 /** |
|
252 * Set skin images on scrollbar thumb |
|
253 */ |
|
254 void setThumbImage(); |
|
255 /** |
|
256 * Sets the position of the handle |
|
257 * |
|
258 * |
|
259 */ |
|
260 void SetThumbPosition(); |
|
261 |
|
262 /** |
|
263 * Handles the key events only. |
|
264 * |
|
265 * @param aEvent event to be handled |
|
266 * @returns The return value is used to indicate if the event was processed. |
|
267 */ |
|
268 AlfEventStatus HandleKeyEvents(const TAlfEvent& aEvent); |
|
269 |
|
270 /** |
|
271 * Handles the pointer events only. |
|
272 * |
|
273 * |
|
274 * @param aEvent Event to be handled |
|
275 * @returns The return value is used to indicate if the event was processed. |
|
276 */ |
|
277 AlfEventStatus HandlePointerEvents( TAlfEvent* aEvent); |
|
278 |
|
279 /** |
|
280 * handles the pointerDown event |
|
281 * |
|
282 * @param aEvent Event to be handled |
|
283 * @returns The return value is used to indicate if the event was processed. |
|
284 */ |
|
285 AlfEventStatus handlePointerDownEvent(TAlfEvent * aPntrEvent); |
|
286 |
|
287 |
|
288 private: |
|
289 |
|
290 |
|
291 /** |
|
292 * IsSliderVisual |
|
293 * |
|
294 */ |
|
295 bool IsSliderVisual(CAlfVisual *aVisual); |
|
296 |
|
297 |
|
298 /** |
|
299 * layout the visuals |
|
300 * |
|
301 */ |
|
302 void layoutVisuals( sliderTemplate aTemplateId) ; |
|
303 |
|
304 |
|
305 |
|
306 /** |
|
307 * |
|
308 * initializes Model and Widget Pointer |
|
309 */ |
|
310 void initializeSliderData(); |
|
311 |
|
312 /** |
|
313 * SetBackgroundBrush |
|
314 * |
|
315 */ |
|
316 void SetBackgroundBrush(); |
|
317 |
|
318 /** |
|
319 * ConvertDataToPixels |
|
320 * |
|
321 */ |
|
322 void ConvertDataToPixels(); |
|
323 |
|
324 /** |
|
325 * updateModelPrimaryValue |
|
326 * |
|
327 */ |
|
328 void updateModelPrimaryValue(int aNewPosValue); |
|
329 |
|
330 /** |
|
331 * Start drag |
|
332 */ |
|
333 bool initializeThumbDragData(const TPoint& aPointerPos); |
|
334 |
|
335 |
|
336 /** |
|
337 * Stop drag |
|
338 */ |
|
339 bool stopDrag(); |
|
340 |
|
341 /** |
|
342 * handlePointerUpEvent |
|
343 */ |
|
344 void handlePointerUpEvent(); |
|
345 |
|
346 /** |
|
347 * snapPrimaryValueToTicks |
|
348 */ |
|
349 void snapPrimaryValueToTicks(); |
|
350 |
|
351 /** |
|
352 * trackVisualHit |
|
353 */ |
|
354 AlfEventStatus trackVisualHit(CAlfVisual * aHitVisual); |
|
355 |
|
356 /** |
|
357 * Texture for Visuals of slider. |
|
358 * |
|
359 */ |
|
360 TAlfImage skinTexture(TSize aPrtImageSize, TSize aLscImageSize, TInt aPrtSkinId, TInt aLscSkinId ); |
|
361 |
|
362 /* |
|
363 * Get the Feedback Intensity |
|
364 */ |
|
365 TInt feedbackIntensity(); |
|
366 |
|
367 |
|
368 private: // Class Data |
|
369 |
|
370 |
|
371 struct MulVerticalSliderDataImpl* mData; |
|
372 |
|
373 // Structure for storing current and previous values |
|
374 auto_ptr<MulSliderPos> mPosData; |
|
375 |
|
376 |
|
377 auto_ptr<MulSliderLongTapTimer> mLongTapTimer; |
|
378 MulSliderModel * mSliderModel; |
|
379 MulSliderWidget * mSliderWidget; |
|
380 |
|
381 }; // end of class |
|
382 |
|
383 } // end of namespace Alf |
|
384 |
|
385 #endif //MUL_SLIDERVERTICAL_H |
|
386 //End Of File |
|