|
1 /* |
|
2 * Copyright (c) 2008 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: Scrollable control adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __XNSCROLLABLECONTROLADAPTER_H__ |
|
19 #define __XNSCROLLABLECONTROLADAPTER_H__ |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 #include <coeccntx.h> |
|
24 #include <aknphysicsobserveriface.h> |
|
25 |
|
26 // User includes |
|
27 #include "xncontroladapter.h" |
|
28 |
|
29 // Forward declarations |
|
30 class CXnNodePluginIf; |
|
31 class CXnUiEngine; |
|
32 class CXnNode; |
|
33 class CAknPhysics; |
|
34 |
|
35 // Class declaration |
|
36 |
|
37 /** |
|
38 * @ingroup group_xnlayoutengine |
|
39 * Scrollable Control adapter interface class |
|
40 * @lib xnlayoutengine.lib |
|
41 * @since Series 60 5.0 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CXnScrollableControlAdapter ) : public CXnControlAdapter, |
|
44 public MAknPhysicsObserver, public MCoeControlContext, public MCoeControlHitTest |
|
45 { |
|
46 public: // Constructors and destructor |
|
47 /** |
|
48 * Two-phased constructor. |
|
49 */ |
|
50 static CXnScrollableControlAdapter* NewL( CXnNodePluginIf& aNode ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 ~CXnScrollableControlAdapter(); |
|
56 |
|
57 private: // Functions from base classes |
|
58 |
|
59 /** |
|
60 * see CCoeControl |
|
61 */ |
|
62 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
63 |
|
64 /** |
|
65 * see CCoeControl |
|
66 */ |
|
67 void Draw(const TRect& aRect) const; |
|
68 |
|
69 /** |
|
70 * see CCoeControl |
|
71 */ |
|
72 void SizeChanged(); |
|
73 |
|
74 /** |
|
75 * @see CCoeControl documentation |
|
76 */ |
|
77 void MakeVisible( TBool aVisible ); |
|
78 |
|
79 /** |
|
80 * @see MCoeControlHitTest documentation |
|
81 */ |
|
82 TBool HitRegionContains( const TPoint& aPoint, const CCoeControl& aControl) const; |
|
83 |
|
84 /** |
|
85 * @see CXnControlAdapter documentation |
|
86 */ |
|
87 void HandleScreenDeviceChangedL(); |
|
88 |
|
89 public: // New functions |
|
90 /** |
|
91 * Returns Called when view position changes. |
|
92 * |
|
93 * @param aNewPosition New view position. |
|
94 */ |
|
95 const TPoint DeltaPosition() const; |
|
96 |
|
97 /** |
|
98 * Reset state. |
|
99 * |
|
100 */ |
|
101 void ResetState(); |
|
102 |
|
103 /** |
|
104 * Scroll box so that the given node is shown. |
|
105 * |
|
106 */ |
|
107 void ShowItem( CXnNode& aNode ); |
|
108 |
|
109 /** |
|
110 * Layout has changed somewhere. Act if needed. |
|
111 * |
|
112 */ |
|
113 void LayoutChangedL(); |
|
114 |
|
115 public: // Functions from base classes |
|
116 /** |
|
117 * From MAknPhysicsObserver. |
|
118 * |
|
119 * Physics emulation has moved the view. |
|
120 * |
|
121 * When this method is called client should update its visual and logical |
|
122 * states to reflect the changes caused by view move. Note that if the |
|
123 * parameter @c aDrawNow is @c EFalse client is not allowed to redraw the |
|
124 * display but should only update its logical state. |
|
125 * Physics engine will ensure that the last frame is always drawn. |
|
126 * |
|
127 * @since S60 v5.0 |
|
128 * |
|
129 * @param aNewPosition The new position of the view. |
|
130 * @param aDrawNow @c ETrue if client should redraw the screen, |
|
131 * otherwise @c EFalse. |
|
132 * @param aFlags Additional flags, not used currently. |
|
133 */ |
|
134 void ViewPositionChanged( const TPoint& aNewPosition, |
|
135 TBool aDrawNow, TUint aFlags ); |
|
136 |
|
137 /** |
|
138 * From MAknPhysicsObserver. |
|
139 * Called when emulation ended. |
|
140 */ |
|
141 void PhysicEmulationEnded(); |
|
142 |
|
143 /** |
|
144 * From MAknPhysicsObserver. |
|
145 * Returns the observer view position. |
|
146 * |
|
147 * @return Physics observer view position. |
|
148 */ |
|
149 TPoint ViewPosition() const; |
|
150 |
|
151 /** |
|
152 * see MCoeControlContext |
|
153 */ |
|
154 void ResetContext( CWindowGc& aGc ) const; |
|
155 |
|
156 private: // Constructors |
|
157 /** |
|
158 * C++ default constructor. |
|
159 */ |
|
160 CXnScrollableControlAdapter( CXnNodePluginIf& aNode ); |
|
161 |
|
162 /** |
|
163 * Two-phased constructor. |
|
164 */ |
|
165 void ConstructL(); |
|
166 |
|
167 private: // New functions |
|
168 void ReadPropertiesL(); |
|
169 void InitPhysicEngineL(); |
|
170 |
|
171 private: // Data |
|
172 /** |
|
173 * UiEngine. |
|
174 * Not owned. |
|
175 */ |
|
176 CXnUiEngine* iUiEngine; |
|
177 |
|
178 /** |
|
179 * Layout node. |
|
180 */ |
|
181 CXnNodePluginIf& iNode; |
|
182 |
|
183 /** |
|
184 * Physics. |
|
185 * Own. |
|
186 */ |
|
187 CAknPhysics* iPhysics; |
|
188 |
|
189 /** |
|
190 * Pointer down start time. |
|
191 */ |
|
192 TTime iStartTime; |
|
193 |
|
194 /** |
|
195 * Start (pointer down) position. |
|
196 */ |
|
197 TPoint iStartPosition; |
|
198 |
|
199 /** |
|
200 * Position at previous pointer event. |
|
201 */ |
|
202 TPoint iPreviousPosition; |
|
203 |
|
204 /** |
|
205 * Current view position. |
|
206 */ |
|
207 TPoint iCurrentPosition; |
|
208 |
|
209 /** |
|
210 * View position at the beginning. |
|
211 */ |
|
212 TPoint iStartViewPosition; |
|
213 |
|
214 /** |
|
215 * Current pointer position. |
|
216 */ |
|
217 TPoint iStylusPosition; |
|
218 |
|
219 /** |
|
220 * Visible area, i.e. area of the scollable control that is to be drawn. |
|
221 */ |
|
222 TRect iViewPort; |
|
223 |
|
224 /** |
|
225 * True, if layout has been changed and engine needs to be reset. |
|
226 */ |
|
227 TBool iLayoutChanged; |
|
228 |
|
229 /** |
|
230 * Direction |
|
231 */ |
|
232 TInt iDirection; |
|
233 }; |
|
234 |
|
235 #endif // __XNSCROLLABLECONTROLADAPTER_H__ |
|
236 |
|
237 // End of File |