|
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 file for presentation elements. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALF_SCROLLBAR_DEFAULT_BASEELEMENT_H |
|
20 #define ALF_SCROLLBAR_DEFAULT_BASEELEMENT_H |
|
21 |
|
22 //INCLUDES |
|
23 #include "alf/alfelement.h" |
|
24 #include <alf/alflayout.h> |
|
25 #include <alf/alfimagevisual.h> |
|
26 |
|
27 #include <alf/ialfwidgeteventhandler.h> |
|
28 #include <alf/ialfscrollbardefaultbaseelement.h> |
|
29 #include "ialfscrollbarbaseelementinternal.h" |
|
30 |
|
31 #include "alfscrollbarmodel.h" |
|
32 #include <AknLayout2Def.h> |
|
33 |
|
34 using namespace osncore; |
|
35 |
|
36 namespace Alf |
|
37 { |
|
38 |
|
39 enum TOperation |
|
40 { |
|
41 ENop, // Nothing is going on. |
|
42 EMoveItem // Item is begin moved. |
|
43 }; |
|
44 // Forward declarations |
|
45 class IAlfWidgetEventHandler; |
|
46 class CAlfWidgetControl; |
|
47 class AlfScrollBarLongTapTimer; |
|
48 |
|
49 /** |
|
50 * Default Base Element of the Scrollbar. |
|
51 */ |
|
52 class AlfScrollBarDefaultBaseElement : |
|
53 public IAlfScrollBarDefaultBaseElement, |
|
54 public AlfElement, |
|
55 public IAlfWidgetEventHandler, |
|
56 public IAlfScrollBarBaseElementInternal |
|
57 { |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Constructor |
|
62 * @param aControl Widget control. |
|
63 * @param aName Name of the item element. |
|
64 * @param aCustomData . |
|
65 * @param mNode . |
|
66 * @since S60 ?S60_version |
|
67 */ |
|
68 AlfScrollBarDefaultBaseElement ( |
|
69 CAlfWidgetControl& aControl, |
|
70 const char* aName, |
|
71 DuiNode* mNode = NULL, |
|
72 AlfCustomInitDataBase* aCustomData=NULL); |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 virtual ~AlfScrollBarDefaultBaseElement(); |
|
78 |
|
79 //-------------------------------------------------------------------------- |
|
80 // APIs from the IAlfScrollBarDefaultBaseElement for controlling the |
|
81 // visualization of the scrollbar |
|
82 //-------------------------------------------------------------------------- |
|
83 |
|
84 /** |
|
85 * Sets the animation time for the thumb movement. |
|
86 * Controls the movement of the thumb in the context of scroll |
|
87 * @since S60 ?S60_version |
|
88 * @param Animation time in milliseconds |
|
89 */ |
|
90 void setThumbAnimationTime(int aTime); |
|
91 |
|
92 /** |
|
93 * Gets the Thumb animation time. |
|
94 * @since S60 ?S60_version |
|
95 * @return Animation time. |
|
96 */ |
|
97 int getThumbAnimationTime() const; |
|
98 |
|
99 /** |
|
100 * Sets the Opacity of thumb. This is relative to widget opacity. |
|
101 * Default value is 1.0. The value of aOpacity should be between 0.0 to 1.0 |
|
102 * @since S60 ?S60_version |
|
103 * @param Opacity of the thumb |
|
104 */ |
|
105 void setThumbOpacity(float aOpacity); |
|
106 |
|
107 /** |
|
108 * Gets the Opacity of thumb. |
|
109 * @since S60 ?S60_version |
|
110 * @return: Thumb opacity |
|
111 */ |
|
112 float getThumbOpacity() const; |
|
113 |
|
114 /** |
|
115 * Sets the Opacity of widget. |
|
116 * Default value of scrollbar opacity is 1.0. |
|
117 * |
|
118 * @param aOpacity Opacity of the scrollbar. The value should be between 0.0 |
|
119 * to 1.0. |
|
120 * |
|
121 * @exception AlfException |
|
122 */ |
|
123 void setOpacity(float aOpacity); |
|
124 |
|
125 /** |
|
126 * Gets the Opacity of widget. |
|
127 * |
|
128 * @return: Thumb opacity |
|
129 */ |
|
130 float getOpacity() const; |
|
131 |
|
132 //-------------------------------------------------------------------------- |
|
133 // APIs from the IAlfScrollBarBaseElement |
|
134 //-------------------------------------------------------------------------- |
|
135 |
|
136 |
|
137 |
|
138 //-------------------------------------------------------------------------- |
|
139 // Overriden Apis from IAlfWidgetEventHandlers |
|
140 //-------------------------------------------------------------------------- |
|
141 // |
|
142 |
|
143 /** |
|
144 * Used to identify event handlers that are capable of handling |
|
145 * a specified key or custom event. |
|
146 * Pointer event handlers cannot be identified directly, |
|
147 * since they are dependent on the presentation. |
|
148 * Therefore, pointer event handlers should be associated with |
|
149 * a custom event ID that can be used to simulate the actual pointer event. |
|
150 * @since S60 ?S60_version |
|
151 * @param aEvent The event. |
|
152 * @param aControl |
|
153 * @return <code>ETrue</code> if the event can be processed. |
|
154 * Otherwise <code>EFalse</code>. |
|
155 */ |
|
156 bool accept(CAlfWidgetControl& aControl, const TAlfEvent& aEvent) const; |
|
157 |
|
158 /** |
|
159 * @see IAlfWidgetEventHandler |
|
160 */ |
|
161 virtual AlfEventHandlerType eventHandlerType(); |
|
162 |
|
163 /** |
|
164 * @see IAlfWidgetEventHandler |
|
165 */ |
|
166 virtual AlfEventHandlerExecutionPhase eventExecutionPhase(); |
|
167 |
|
168 /** |
|
169 * Called when an input event is being offered to this event handler. |
|
170 * The return value is used to indicate if the event was processed. |
|
171 * Processed events may not be offered to other event handlers. |
|
172 * @since S60 ?S60_version |
|
173 * @param aControl The parent control of this event handler. |
|
174 * @param aEvent The event. |
|
175 * @return <code>ETrue</code> if the event was processed. |
|
176 * Otherwise <code>EFalse</code>. |
|
177 */ |
|
178 virtual AlfEventStatus offerEvent( |
|
179 CAlfWidgetControl& aControl, |
|
180 const TAlfEvent& aEvent ); |
|
181 |
|
182 /** |
|
183 * Defines the widget states, where the event handler is active. |
|
184 * By default, if this method is not called, the event handler is expected |
|
185 * to be active in all states. |
|
186 * @param aStates A bitmask defining the widget states, where the event |
|
187 * handler is active. The low 16 bits are reserved for the states |
|
188 * defined by the framework in <TODO: add reference>. The high 16 bits are |
|
189 * available for states defined by the client code. |
|
190 */ |
|
191 void setActiveStates(unsigned int aStates); |
|
192 |
|
193 /** |
|
194 * Sets AlfWidgetEventHandlerInitData to event handler. |
|
195 * @param aData A data structure which contains for example id of the event |
|
196 * handler. |
|
197 */ |
|
198 virtual void setEventHandlerData( |
|
199 const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
200 { |
|
201 |
|
202 } |
|
203 |
|
204 /** |
|
205 * Returns AlfWidgetEventHandlerInitData. |
|
206 * @return A pointer to AlfWidgetEventHandlerInitData structure |
|
207 * which contains for example id of the event handler. |
|
208 */ |
|
209 virtual AlfWidgetEventHandlerInitData* eventHandlerData() |
|
210 { |
|
211 return NULL; |
|
212 } |
|
213 |
|
214 /** |
|
215 * Friend class for timer functions. |
|
216 * |
|
217 */ |
|
218 friend class AlfScrollBarLongTapTimer; |
|
219 |
|
220 //-------------------------------------------------------------------------- |
|
221 //Overriden Apis from IAlfScrollBarBaseElementInternal |
|
222 //-------------------------------------------------------------------------- |
|
223 // |
|
224 |
|
225 /** |
|
226 * Notified when the base layout of scrollbar changes . |
|
227 * Relayouts all the visuals with respect to the new size. |
|
228 */ |
|
229 void baseLayoutSizeChanged(); |
|
230 |
|
231 /** |
|
232 * Send the corresponding Custom events to the scrollbar eventhandlers |
|
233 * according to the visual clicked. |
|
234 */ |
|
235 bool processPointerEvent(TAlfEvent * aPntrEvent); |
|
236 |
|
237 /** |
|
238 * Creates the Visualization of scrollbar |
|
239 * |
|
240 */ |
|
241 void createVisualization(); |
|
242 |
|
243 /** |
|
244 * Updates the Visualization of scrollbar |
|
245 * |
|
246 */ |
|
247 void updateVisualization(); |
|
248 |
|
249 /** |
|
250 * Destroy the Visualization of scrollbar |
|
251 * |
|
252 */ |
|
253 void destroyVisualization(); |
|
254 |
|
255 /** |
|
256 * Returns pointer to AlfScrollBarModel |
|
257 * |
|
258 */ |
|
259 void initializeScrollModel(); |
|
260 |
|
261 /** |
|
262 * handles longTap event |
|
263 */ |
|
264 AlfEventStatus handleLongTapEvent(); |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // From class IAlfInterfaceBase. |
|
268 // |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 /** |
|
272 * Getter for interfaces provided by the widget. |
|
273 * @since S60 ?S60_version |
|
274 * @param aType A descriptor to identify the type of the queried interface. |
|
275 * @return The queried interface, or NULL if the interface is not |
|
276 * supported or available. |
|
277 */ |
|
278 virtual IAlfInterfaceBase* makeInterface(const IfId& aType); |
|
279 |
|
280 |
|
281 //-------------------------------------------------------------------------- |
|
282 // Internal member functions AlfScrollBarDefaultBaseElement |
|
283 //-------------------------------------------------------------------------- |
|
284 // |
|
285 |
|
286 /** |
|
287 * handles the pointerDown event |
|
288 */ |
|
289 bool handlePointerDownEvent(TAlfEvent * aPntrEvent); |
|
290 |
|
291 /** |
|
292 * Sends pageup or pagedown event according to hit point on track |
|
293 */ |
|
294 AlfEventStatus trackVisualHit(CAlfVisual * aHitVisual); |
|
295 |
|
296 /** |
|
297 * handles the pointerUp event |
|
298 */ |
|
299 void handlePointerUpEvent(); |
|
300 |
|
301 /** |
|
302 * Initializes the scrollbar layouts with LCT layout data |
|
303 */ |
|
304 void initializeLayout(); |
|
305 |
|
306 /** |
|
307 * Initializes the scrollbar Tracklayout with LCT layout data |
|
308 */ |
|
309 void initializeTrackLayout(); |
|
310 |
|
311 /** |
|
312 * Initializes the scrollbar Thumblayout with LCT layout data |
|
313 */ |
|
314 void initializeThumbLayout(); |
|
315 |
|
316 /** |
|
317 * Sets position and Size on the Visual/layout |
|
318 * @param aVisual Visual/Layout on which position and size is being set |
|
319 * @param aXVal Position X value |
|
320 * @param aYVal Position Y value |
|
321 * @param aWidth Width |
|
322 * @param aHeight Height |
|
323 */ |
|
324 void setPositionAndSize(CAlfVisual * aVisual, |
|
325 int aXVal, int aYVal, |
|
326 int aWidth, int aHeight); |
|
327 |
|
328 /** |
|
329 * Set skin images on scrollbar track |
|
330 */ |
|
331 void setTrackImage(); |
|
332 |
|
333 /** |
|
334 * Set skin images on scrollbar thumb |
|
335 */ |
|
336 void setThumbImage(); |
|
337 |
|
338 /** |
|
339 * Changes the scrollbar track image, based on the flag state |
|
340 * @param aPressed false for normal graphics, |
|
341 * true for pressed graphics |
|
342 */ |
|
343 void changeTrackImage(bool aPressed = false); |
|
344 |
|
345 /** |
|
346 * Changes the scrollbar thumb image, based on the flag state |
|
347 * @param aPressed false for normal graphics, |
|
348 * true for pressed graphics |
|
349 */ |
|
350 void changeThumbImage(bool aPressed = false); |
|
351 |
|
352 /** |
|
353 * Calculates the StepSize and thumbLength |
|
354 */ |
|
355 void calculateStepSizeAndThumbLength(); |
|
356 |
|
357 /** |
|
358 * Calculates minimum and maximum thumbLength |
|
359 */ |
|
360 void setThumbMinMaxLength(); |
|
361 |
|
362 |
|
363 private: |
|
364 |
|
365 /** |
|
366 * handles the scroll bar click event |
|
367 * |
|
368 */ |
|
369 AlfEventStatus handleScrollBarClickedEvent( |
|
370 const TAlfEvent& aEvent ); |
|
371 /** |
|
372 * Creates the visual template hirarchy of scrollbar. |
|
373 */ |
|
374 void createDefaultBaseElement(); |
|
375 |
|
376 /** |
|
377 * Sets LctLayoutData on the Visual/layout |
|
378 * @param aRect Parent rect of the visual |
|
379 * @param aWindowLineLayout TAknWindowLineLayout handle which has the LCT values |
|
380 * to be set |
|
381 * @param aVisual Visual/Layout on which LctLayoutData is being set |
|
382 */ |
|
383 void setLCTData(const TRect& aRect , |
|
384 TAknWindowLineLayout& aWindowLineLayout,CAlfVisual * aVisual); |
|
385 |
|
386 /** |
|
387 * Initialize drag flags and store drag start point |
|
388 */ |
|
389 bool initializeThumbDragData( const TPoint& aPointerPos ); |
|
390 |
|
391 /** |
|
392 * Stop drag |
|
393 */ |
|
394 bool stopDrag(CAlfVisual* aHitVisual, TInt aAnimTime); |
|
395 |
|
396 /** |
|
397 * changes the graphics of scrollbar to pressed/normal |
|
398 */ |
|
399 void changeGraphics(); |
|
400 |
|
401 /** |
|
402 * checks whether it is scrollbar trackVisual or not |
|
403 */ |
|
404 bool isScrollbarTrackVisual(CAlfVisual *aVisual); |
|
405 |
|
406 /** |
|
407 * changes the graphics of scrollbar to pressed/normal |
|
408 */ |
|
409 bool isScrollbarThumbVisual(CAlfVisual *aVisual); |
|
410 |
|
411 /* |
|
412 * Instance of ScrollBarLongTapTimer. |
|
413 */ |
|
414 auto_ptr<AlfScrollBarLongTapTimer> mLongTapTimer; |
|
415 |
|
416 /* |
|
417 * holds the value if minimum thumb size. |
|
418 */ |
|
419 TAlfMetric mThumbMinSize; |
|
420 |
|
421 /* |
|
422 * holds that value of minimum thumb size specified by the user. |
|
423 */ |
|
424 TAlfMetric mUserThumbMinSize; |
|
425 |
|
426 /* |
|
427 * Flag set to true if minimum thumbsize is set. |
|
428 */ |
|
429 bool mIsMinSizeFlagSet; |
|
430 |
|
431 /* |
|
432 * Flag set to true if longTapObserver is set. |
|
433 */ |
|
434 bool mIsLongTapObserverSet; |
|
435 |
|
436 /* |
|
437 * pointer to scrollbarThumbLCTData. |
|
438 */ |
|
439 struct ScrollbarThumbLCTData *mLCTData; |
|
440 |
|
441 /* |
|
442 * pointer to ScrollBarDefaultLCTBaseElementData. |
|
443 */ |
|
444 struct ScrollBarBaseElementData *mData; |
|
445 |
|
446 }; // end of class AlfScrollBarDefaultBaseElement |
|
447 |
|
448 } // end of namespace Alf |
|
449 |
|
450 #endif //ALF_SCROLLBAR_DEFAULT_BASEELEMENT_H |
|
451 //End Of File |