|
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: |
|
15 * A compound control class. It is responsible for drawing and updating |
|
16 * a set of buttons. Button selections are also handled and forwarded |
|
17 * as commands to the AppUi. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #ifndef __CVRBUTTONPANEL_H__ |
|
23 #define __CVRBUTTONPANEL_H__ |
|
24 |
|
25 // INCLUDES |
|
26 #include <coecntrl.h> |
|
27 #include <AknUtils.h> |
|
28 #include <coecobs.h> // MCoeControlObserver |
|
29 |
|
30 #include "MVRObserver.h" |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class MVRButtonPanelModel; |
|
34 class MAknsSkinInstance; |
|
35 class CApaMaskedBitmap; |
|
36 class TAknsItemID; |
|
37 class CAknButton; |
|
38 |
|
39 // CLASS DEFINITION |
|
40 /** |
|
41 * A compound control class. It is responsible for drawing and updating |
|
42 * a set of buttons. Button selections are also handled and forwarded |
|
43 * as commands to the AppUi. |
|
44 */ |
|
45 NONSHARABLE_CLASS( CVRButtonPanel ) |
|
46 : public CCoeControl, |
|
47 public MVRObserver, |
|
48 public MCoeControlObserver, |
|
49 public MCoeControlBackground |
|
50 { |
|
51 public: // data types |
|
52 enum TFocusChange |
|
53 { |
|
54 EFocusUp = -1, |
|
55 EFocusDown = 1, |
|
56 EFocusInvalid = 2 |
|
57 }; |
|
58 |
|
59 // pointer event types used in VR |
|
60 enum TLastPointerEventType |
|
61 { |
|
62 EVRButtonDownEvent, |
|
63 EVRButtonDragOutsideEvent, |
|
64 EVRButtonUpEvent |
|
65 }; |
|
66 |
|
67 public: // constructors and destructor |
|
68 |
|
69 /** |
|
70 * Constructor. |
|
71 * @param aModel Pointer to the button panel model. |
|
72 * Ownership is not transferred. |
|
73 */ |
|
74 CVRButtonPanel( MVRButtonPanelModel* aModel ); |
|
75 |
|
76 /** |
|
77 * Constructor. |
|
78 * @param aModel Pointer to the button panel model. |
|
79 * @param aParentViewUid Uid of CVRRecView for fast swap |
|
80 * Ownership is not transferred. |
|
81 */ |
|
82 CVRButtonPanel( MVRButtonPanelModel* aModel, TUid aParentViewUid ); |
|
83 |
|
84 /** |
|
85 * Destructor |
|
86 */ |
|
87 virtual ~CVRButtonPanel(); |
|
88 |
|
89 /** |
|
90 * 2nd phase constructor. |
|
91 */ |
|
92 void ConstructL(); |
|
93 |
|
94 private: // constructors |
|
95 |
|
96 /** |
|
97 * Default constructor. Not implemented. |
|
98 */ |
|
99 CVRButtonPanel(); |
|
100 |
|
101 /** |
|
102 * Creates control buttons from given resources |
|
103 * @param aButtonsResourceId The resource used in buttons' construction. |
|
104 */ |
|
105 void CreateButtonsFromResourcesL( TInt aButtonsResourceId ); |
|
106 |
|
107 public: |
|
108 |
|
109 /** |
|
110 * Updates the layout of all child controls to current active |
|
111 * layout (Euro, Apac, Arabic/Hebrew) |
|
112 */ |
|
113 void UpdateLayoutL( ); |
|
114 |
|
115 /** |
|
116 * Handles a change to the application's resources |
|
117 * @param aType The type of changed resource |
|
118 */ |
|
119 void HandleResourceChangeL( TInt aType ); |
|
120 |
|
121 public: // from CCoeControl |
|
122 |
|
123 /* |
|
124 * From CCoeControl |
|
125 * @see CCoeControl |
|
126 */ |
|
127 void SizeChanged(); |
|
128 |
|
129 /** |
|
130 * When a key event occurs, the control framework calls this function |
|
131 * for each control on the control stack, until one of them can process |
|
132 * the key event (and returns EKeyWasConsumed). |
|
133 * @param aKeyEvent The key event. |
|
134 * @param aType The type of key event: EEventKey, EEventKeyUp |
|
135 * or EEventKeyDown |
|
136 * @return Indicates whether or not the key event was used by this |
|
137 * control |
|
138 */ |
|
139 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
140 TEventCode aType ); |
|
141 |
|
142 /** |
|
143 * Gets called whenever a pointer event occurs. |
|
144 * @param aPointerEvent The pointer event to handle. |
|
145 */ |
|
146 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
147 |
|
148 public: // from MVRObserver |
|
149 |
|
150 /** |
|
151 * Called to notify a change in the observed subject's state. |
|
152 */ |
|
153 void Update( TVRUpdateCommand aCommand ); |
|
154 |
|
155 public: // from MCoeControlObserver |
|
156 |
|
157 /** |
|
158 * This function is called when a control for which this control is the observer |
|
159 * calls CCoeControl::ReportEventL(). In VoiceRecorder button pointer events are |
|
160 * handled here. |
|
161 * @param aControl The control that sent the event. |
|
162 * @param aEventType The event type. |
|
163 */ |
|
164 void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType); |
|
165 |
|
166 private: // from MCoeControlBackground |
|
167 |
|
168 /* |
|
169 * From MCoeControlBackground |
|
170 * @see MCoeControlBackground |
|
171 */ |
|
172 void Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const; |
|
173 |
|
174 public: // new methods |
|
175 |
|
176 /* |
|
177 * Checks which button is currently focused and returns the index |
|
178 * value of that |
|
179 * @return The index for the currently focused button |
|
180 */ |
|
181 TInt FocusedButton() const; |
|
182 |
|
183 private: // from CCoeControl |
|
184 |
|
185 /** |
|
186 * Draws this control. |
|
187 * @param aRect The area that needs updating. Ignored. |
|
188 */ |
|
189 void Draw( const TRect& aRect ) const; |
|
190 |
|
191 /** |
|
192 * Called by the framework to get the number of sub-components |
|
193 * contained in this component. |
|
194 * @return The number of component controls contained by this control |
|
195 */ |
|
196 TInt CountComponentControls() const; |
|
197 |
|
198 /** |
|
199 * Called by the framework to get a specified sub-component |
|
200 * of this component. |
|
201 * @param aIndex The index of the component to get. |
|
202 * @return The component control with an index of aIndex. |
|
203 */ |
|
204 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
205 |
|
206 private: // new methods |
|
207 |
|
208 /** |
|
209 * Moves focus to the next non-dimmed button. |
|
210 * @param aDirection EFocusDown to move downwards, EFocusUp upwards |
|
211 */ |
|
212 void MoveFocus( const TFocusChange aDirection, TBool aDrawNow ); |
|
213 |
|
214 /** |
|
215 * Updates buttons by changing their state |
|
216 */ |
|
217 void UpdateButtons(); |
|
218 |
|
219 /** |
|
220 * Draws highlight rectangle for the focused button. |
|
221 * @param aGc Current Graphic Context in use. |
|
222 */ |
|
223 void DrawFocus( CWindowGc& aGc ) const; |
|
224 |
|
225 /** |
|
226 * Creates and starts a CPeriodic timer object |
|
227 * with a resolution of KVRFastForwUpdateDelay |
|
228 */ |
|
229 void StartTimerL(); |
|
230 |
|
231 /** |
|
232 * Stops and deletes the timer object. |
|
233 */ |
|
234 void StopTimer(); |
|
235 |
|
236 /** |
|
237 * Called by the CPeriodic timer to handle a tick. |
|
238 * Uses HandleTimerCallBack() to do the actual work. |
|
239 * @param aButtonPanel Always a valid pointer to CVRButtonPanel object |
|
240 * @return ETrue to indicate that the timer should continue. |
|
241 */ |
|
242 static TInt TimerCallBack( TAny* aButtonPanel ); |
|
243 |
|
244 /** |
|
245 * Non-static variant of TimerCallBack (more convinient to implement). |
|
246 */ |
|
247 void HandleTimerCallBack(); |
|
248 |
|
249 /** |
|
250 * Search corresponding command of the focused/pressed button and |
|
251 * sends it to active view |
|
252 */ |
|
253 void FetchAndSendCommandL(); |
|
254 |
|
255 /** |
|
256 * Handles special cases concerning button focus |
|
257 */ |
|
258 void TuneButtonFocus(); |
|
259 |
|
260 |
|
261 private: // data |
|
262 |
|
263 /** |
|
264 * Pointer to the button panel model. Not owned. |
|
265 */ |
|
266 MVRButtonPanelModel* iModel; |
|
267 |
|
268 /** |
|
269 * The index of the currently focused button. |
|
270 */ |
|
271 TInt iFocusedButton; |
|
272 |
|
273 // Skin instance. Not owned. |
|
274 MAknsSkinInstance* iSkin; |
|
275 |
|
276 // Uid of the parent view |
|
277 TUid iParentViewUid; |
|
278 |
|
279 /** |
|
280 * Pointer to the timer object. Owned. |
|
281 */ |
|
282 CPeriodic* iTimer; |
|
283 |
|
284 // Button panel's button controls. Owned. |
|
285 CArrayPtrFlat< CAknButton > iVRButtons; |
|
286 |
|
287 /** |
|
288 * Tells what pointer event is the last that has happened |
|
289 */ |
|
290 TLastPointerEventType iLastPointerEvent; |
|
291 |
|
292 }; |
|
293 |
|
294 #endif // __CVRBUTTONPANEL_H__ |