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 elements - horizontal slider. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MUL_SLIDERHORIZONTAL_H |
|
22 #define MUL_SLIDERHORIZONTAL_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/alfvisual.h> |
|
30 #include <alf/ialfwidgeteventhandler.h> |
|
31 |
|
32 |
|
33 #include <AknLayout2Def.h> |
|
34 |
|
35 #include <mul/imulsliderwidget.h> |
|
36 #include "mulslidermodel.h" |
|
37 |
|
38 #include "imulsliderbaseelementinternal.h" |
|
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 Slider. |
|
59 */ |
|
60 class MulSliderHorizontal : |
|
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 MulSliderHorizontal ( |
|
77 CAlfWidgetControl& aControl, |
|
78 const char* aName, |
|
79 AlfCustomInitDataBase* aCustomData=NULL); |
|
80 |
|
81 /** |
|
82 * Destructor |
|
83 */ |
|
84 virtual ~MulSliderHorizontal(); |
|
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 * From IAlfInterfaceBase. |
|
99 * Getter for interfaces provided by the Button widget class. |
|
100 * @since S60 ?S60_version |
|
101 * @param aType A descriptor to identify the type of the queried interface. |
|
102 * @return The queried interface, or NULL if the interface is not |
|
103 * supported or available. |
|
104 */ |
|
105 virtual IAlfInterfaceBase* makeInterface(const IfId& aType); |
|
106 |
|
107 |
|
108 |
|
109 //void createVisualization(); |
|
110 //-------------------------------------------------------------------------- |
|
111 //Overriden Apis from IAlfWidgetEventHandlers |
|
112 //-------------------------------------------------------------------------- |
|
113 // |
|
114 |
|
115 /** |
|
116 * Used to identify event handlers that are capable of handling |
|
117 * a specified key or custom event. |
|
118 * Pointer event handlers cannot be identified directly, |
|
119 * since they are dependent on the presentation. |
|
120 * Therefore, pointer event handlers should be associated with |
|
121 * a custom event ID that can be used to simulate the actual pointer event. |
|
122 * @since S60 ?S60_version |
|
123 * @param aEvent The event. |
|
124 * @param aControl |
|
125 * @return <code>ETrue</code> if the event can be processed. |
|
126 * Otherwise <code>EFalse</code>. |
|
127 */ |
|
128 bool accept(CAlfWidgetControl& aControl, const TAlfEvent& aEvent) const; |
|
129 |
|
130 |
|
131 |
|
132 /** |
|
133 * @see IAlfWidgetEventHandler |
|
134 */ |
|
135 virtual AlfEventHandlerType eventHandlerType(); |
|
136 |
|
137 /** |
|
138 * @see IAlfWidgetEventHandler |
|
139 */ |
|
140 virtual AlfEventHandlerExecutionPhase eventExecutionPhase(); |
|
141 /** |
|
142 * Called when an input event is being offered to this event handler. |
|
143 * The return value is used to indicate if the event was processed. |
|
144 * Processed events may not be offered to other event handlers. |
|
145 * @since S60 ?S60_version |
|
146 * @param aControl The parent control of this event handler. |
|
147 * @param aEvent The event. |
|
148 * @return <code>ETrue</code> if the event was processed. |
|
149 * Otherwise <code>EFalse</code>. |
|
150 */ |
|
151 |
|
152 |
|
153 virtual AlfEventStatus offerEvent( |
|
154 CAlfWidgetControl& aControl, |
|
155 const TAlfEvent& aEvent ); |
|
156 |
|
157 /** |
|
158 * Defines the widget states, where the event handler is active. |
|
159 * By default, if this method is not called, the event handler is expected |
|
160 * to be active in all states. |
|
161 * @param aStates A bitmask defining the widget states, where the event |
|
162 * handler is active. The low 16 bits are reserved for the states |
|
163 * defined by the framework in <TODO: add reference>. The high 16 bits are |
|
164 * available for states defined by the client code. |
|
165 */ |
|
166 void setActiveStates(unsigned int aStates); |
|
167 |
|
168 /** |
|
169 * Sets AlfWidgetEventHandlerInitData to event handler. |
|
170 * @param aData A data structure which contains for example id of the event |
|
171 * handler. |
|
172 */ |
|
173 virtual void setEventHandlerData( |
|
174 const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
175 { |
|
176 |
|
177 } |
|
178 |
|
179 /** |
|
180 * Returns AlfWidgetEventHandlerInitData. |
|
181 * @return A pointer to AlfWidgetEventHandlerInitData structure |
|
182 * which contains for example id of the event handler. |
|
183 */ |
|
184 virtual AlfWidgetEventHandlerInitData* eventHandlerData() |
|
185 { |
|
186 return NULL; |
|
187 } |
|
188 |
|
189 /** |
|
190 * Friend class for timer functions. |
|
191 * |
|
192 */ |
|
193 friend class MulSliderLongTapTimer; |
|
194 |
|
195 |
|
196 // From IAlfScrollBarBaseElementInternal |
|
197 |
|
198 /** |
|
199 * Notified when the base layout of scrollbar changes . |
|
200 * Relayouts all the visuals with respect to the new size. |
|
201 */ |
|
202 void baseLayoutSizeChanged(); |
|
203 |
|
204 /** |
|
205 * Initialises slider data |
|
206 */ |
|
207 void initializeSliderData(); |
|
208 /** |
|
209 * Updates visualization |
|
210 */ |
|
211 void updateVisualization(); |
|
212 /** |
|
213 * Updates text visualization |
|
214 */ |
|
215 void updateTextVisualization(); |
|
216 /** |
|
217 * handles Long tap event |
|
218 */ |
|
219 AlfEventStatus handleLongTap(); |
|
220 |
|
221 /** |
|
222 * Changes Thumb image |
|
223 */ |
|
224 void changeThumbImage(bool aPressed = false); |
|
225 /** |
|
226 * Gets thumb minimum length. |
|
227 */ |
|
228 void getThumbMinMaxLength(); |
|
229 /** |
|
230 * Creates visualization |
|
231 */ |
|
232 void createVisualization(sliderTemplate aTemplateId); |
|
233 // Creates Slider Template 3 ( Zoom Slider) |
|
234 //void createZoomSlider(); |
|
235 /** |
|
236 * create a Dual progressive slider |
|
237 */ |
|
238 void createDualProgressiveSlider(); |
|
239 |
|
240 private: // New Methods |
|
241 |
|
242 /** |
|
243 * SetBackgroundBrush |
|
244 * |
|
245 */ |
|
246 void SetBackgroundBrush(); |
|
247 |
|
248 /** |
|
249 * Retrieves the data for the slider from the model into structure |
|
250 */ |
|
251 void RetrieveData(); |
|
252 |
|
253 /** |
|
254 * Sets the position of the handle |
|
255 * |
|
256 * @param aCurrTick The new position of the handle |
|
257 */ |
|
258 void SetThumbPosition();//int aCurrTick); |
|
259 |
|
260 /** |
|
261 * Sets the text for the counter visual |
|
262 * |
|
263 * @param aNewString The counter visual text value |
|
264 * @throw Invalid Argument incase there is no layout at zeroth position |
|
265 */ |
|
266 void SetTextLabels(const UString& aNewString); |
|
267 |
|
268 /** |
|
269 * Sets the image for the image visual |
|
270 * |
|
271 * @param aImagePath The path of the new image |
|
272 * @throw Invalid Argument incase there is no layout at zeroth position |
|
273 */ |
|
274 void SetNewImagePath(const UString& aImagePath); |
|
275 |
|
276 /** |
|
277 * Sets the image for the image visual from thr provided texture id |
|
278 * |
|
279 * @param aTextureId The texture id of the new image |
|
280 * @throw Invalid Argument incase there is no layout at zeroth position |
|
281 */ |
|
282 void SetNewImageTexture(const int aTextureId); |
|
283 |
|
284 /** |
|
285 * Notifies about the initiation of pointer down event on the visual. |
|
286 * |
|
287 * @returns true after the drag has started |
|
288 */ |
|
289 //bool StartDrag(CAlfVisual *aDragVisual); |
|
290 |
|
291 /** |
|
292 * Sets the starting position of the pointer doen event and will |
|
293 * start ignoring the visual for further possible pointer events |
|
294 * |
|
295 * @param aOperation true to signify start of drag. |
|
296 */ |
|
297 //void Begin(TBool aOperation); |
|
298 |
|
299 /** |
|
300 * Checks if the drag event is On |
|
301 * |
|
302 * @returns true if the drag event is on. |
|
303 */ |
|
304 //bool BeingDragged() const; |
|
305 |
|
306 /** |
|
307 * Clears the flag for ignoring the visual for pointer events. |
|
308 */ |
|
309 //void StopDrag(); |
|
310 |
|
311 /** |
|
312 * Handles the key events only. |
|
313 * |
|
314 * @param aEvent event to be handled |
|
315 * @returns if the event was handled or not |
|
316 */ |
|
317 AlfEventStatus HandleKeyEvents(const TAlfEvent& aEvent); |
|
318 |
|
319 /** |
|
320 * Handles the pointer events only. |
|
321 * |
|
322 * @aControl The alfwidget control |
|
323 * @param aEvent Event to be handled |
|
324 * @returns if the event was handled or not |
|
325 */ |
|
326 AlfEventStatus HandlePointerEvents( TAlfEvent* aEvent); |
|
327 /** |
|
328 * Handles pointer down event |
|
329 */ |
|
330 AlfEventStatus handlePointerDownEvent(TAlfEvent * aPntrEvent); |
|
331 /** |
|
332 * Checks if the slider visual is hit |
|
333 * |
|
334 * @param aVisual Visual that has been touched. |
|
335 * @param aPointerPt position of the pointer |
|
336 * @param aEvent Event to be handled |
|
337 * @returns true/false if the visual is touched |
|
338 */ |
|
339 bool IsSldVisualHit(const CAlfVisual& aVisual,TPoint aPointerPt,const TAlfEvent& aEvent); |
|
340 |
|
341 /** |
|
342 * Checks if the hit point is within the tappable area |
|
343 * |
|
344 * @param aPointerPt position of the pointer |
|
345 * @param aEvent Event to be handled |
|
346 * @returns true/false if the point is in tappable area |
|
347 */ |
|
348 bool InTappableArea(const TPoint& aPointerPt,const TAlfEvent& aEvent) ; |
|
349 |
|
350 /** |
|
351 * Converts pixel to value according to range of slider |
|
352 * @param aPixel The pixel value passed |
|
353 * @param aMaxPixel The maximum value to be considered for calculation |
|
354 * returns rounded int value after conversion |
|
355 */ |
|
356 int PixelToValue(int aPixel,int aMaxPixel); |
|
357 |
|
358 /** |
|
359 * Converts value to pixel according to range of slider |
|
360 * @param aVal The value passed |
|
361 * @param aMaxPixel The maximum value to be considered for calculation |
|
362 * returns rounded int pixel after conversion |
|
363 */ |
|
364 int ValueToPixel(int aVal, int aMaxPixel); |
|
365 |
|
366 /** |
|
367 * Creates the new image for the given path |
|
368 * @param aImageVisual The visual to which the image is to be set |
|
369 * @param aPath The new path of the image |
|
370 * @returns Returns the new image to be set |
|
371 */ |
|
372 TAlfImage CreateImageFromImagePath( const CAlfImageVisual& aImageVisual, const TPtrC8& aPath ); |
|
373 |
|
374 /** |
|
375 * Sets the new value for max and min range considering min range as zero.Its helpful |
|
376 * for the negative min range values or greater than zero min range values. |
|
377 * |
|
378 * @param aMap Contains data.Used to get the data from current model. |
|
379 */ |
|
380 void NormalizeRange(/*IAlfMap& aMap*/); |
|
381 |
|
382 /** |
|
383 * Stores the value for x and y coordinate of baselayout position in structure. |
|
384 * Later the values from the structure is used to get/set the relative values |
|
385 * according to the new position of baselayout. |
|
386 */ |
|
387 void RelativePos(); |
|
388 void mirrorPointerPosition(const TPoint& aPointerPos ); |
|
389 |
|
390 /* |
|
391 * Change volume icon |
|
392 */ |
|
393 void VolumeIconChange(bool aFlag,int aValue); |
|
394 private: |
|
395 /** |
|
396 * IsSliderVisual |
|
397 */ |
|
398 bool IsSliderVisual(CAlfVisual *aVisual); |
|
399 |
|
400 |
|
401 /** returns pixel values |
|
402 */ |
|
403 void ConvertDataToPixels(); |
|
404 |
|
405 /** |
|
406 * updateModelPrimaryValue |
|
407 * |
|
408 */ |
|
409 void updateModelPrimaryValue(int aNewPosValue); |
|
410 /** |
|
411 * Start drag |
|
412 */ |
|
413 bool initializeThumbDragData( const TPoint& aPointerPos ); |
|
414 |
|
415 /** |
|
416 * Stop drag |
|
417 */ |
|
418 bool stopDrag(); |
|
419 |
|
420 |
|
421 /** |
|
422 * Handles pointer Events |
|
423 */ |
|
424 void handlePointerUpEvent(); |
|
425 /** |
|
426 * Snaps primary value to ticks |
|
427 */ |
|
428 void snapPrimaryValueToTicks(); |
|
429 /** |
|
430 * Set images for three part track |
|
431 * |
|
432 */ |
|
433 void setTrackImage(); |
|
434 /** |
|
435 * Checks if the track visual is Hit |
|
436 */ |
|
437 AlfEventStatus trackVisualHit(CAlfVisual * aHitVisual); |
|
438 /** |
|
439 * layout the visuals |
|
440 * |
|
441 */ |
|
442 void layoutVisuals(sliderTemplate aTemplateId); |
|
443 private: // Class Data |
|
444 |
|
445 // auto_ptr< MulSliderHorizontalImpl>mData; // Owned |
|
446 struct MulHorizontalSliderDataImpl* mData; |
|
447 // auto_ptr<SliderDefaultLCTBaseElementData> mData; |
|
448 auto_ptr<MulSliderPos> mPosData; // Structure for storing current and previous values |
|
449 // const UString& mStyle; |
|
450 auto_ptr<MulSliderLongTapTimer> mLongTapTimer; |
|
451 CAlfVisual *mDragVisual; |
|
452 MulSliderModel * mSliderModel; |
|
453 MulSliderWidget * mSliderWidget; |
|
454 }; // end of class AlfScrollBarDefaultLCTBaseElement |
|
455 |
|
456 } // end of namespace Alf |
|
457 |
|
458 #endif //MUL_SLIDERHORIZONTAL_H |
|
459 //End Of File |
|