|
1 /* |
|
2 * Copyright (c) 2008-2009 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: View Base |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_GLXVIEWBASE_H |
|
22 #define C_GLXVIEWBASE_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 |
|
27 #include <aknview.h> |
|
28 #include <akntitle.h> |
|
29 #include <alf/alftimedvalue.h> |
|
30 #include <alf/ialfviewwidget.h> |
|
31 #include <glxanimationfactory.h> |
|
32 #include "glxkeyeventreceiver.h" |
|
33 #include <mglxanimationobserver.h> |
|
34 #include <glxlog.h> |
|
35 #include <akntoolbar.h> |
|
36 #include <akntoolbarobserver.h> |
|
37 #include "mglxsoftkeyhandler.h" |
|
38 #include <mul/mulevent.h> |
|
39 #include <alf/ialfwidgetfactory.h> |
|
40 class CGlxCommandHandler; |
|
41 class CGlxUiUtility; |
|
42 class CAlfControlGroup; |
|
43 class CGlxKeyMonitor; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 |
|
47 /** |
|
48 * View base |
|
49 * |
|
50 * @lib glxviewbase.lib |
|
51 */ |
|
52 class CGlxViewBase : public CAknView, |
|
53 public MGlxAnimationObserver, |
|
54 public MAknToolbarObserver |
|
55 { |
|
56 public: |
|
57 /** |
|
58 * Constructor |
|
59 */ |
|
60 IMPORT_C CGlxViewBase(TBool aSyncActivation = ETrue); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 IMPORT_C virtual ~CGlxViewBase(); |
|
66 |
|
67 /** |
|
68 * Add a command handler to the view (ownership transferred and the |
|
69 * command handler is deleted in the event of a leave). |
|
70 * @param aCommandHandler The command handler to add. |
|
71 */ |
|
72 IMPORT_C void AddCommandHandlerL(CGlxCommandHandler* aCommandHandler); |
|
73 |
|
74 /** |
|
75 * Enable and set a Title in screen furniture |
|
76 * @param aTitleText The text to be displayed |
|
77 * @param aAnimate Indicates if the change is to be animated |
|
78 */ |
|
79 IMPORT_C void SetTitleL(const TDesC& aTitleText); |
|
80 |
|
81 /** |
|
82 * Disable a Title in screen furniture |
|
83 * @param aAnimate Indicates if the change is to be animated |
|
84 */ |
|
85 IMPORT_C void DisableTitle(); |
|
86 |
|
87 /** |
|
88 * Handles commands |
|
89 * @param aCommand The command to respond to |
|
90 * @return ETrue iff the command has been handled. |
|
91 */ |
|
92 IMPORT_C virtual TInt DoHandleCommandL(TInt aCommand); |
|
93 |
|
94 /** |
|
95 * Sets the grid tool. |
|
96 * @param grid toolbar handle. |
|
97 */ |
|
98 IMPORT_C void SetGridToolBar(CAknToolbar* aToolbar); |
|
99 |
|
100 /** |
|
101 * Returns the current active toolbar |
|
102 * Needed as grid toolbar is created dynamically |
|
103 */ |
|
104 IMPORT_C CAknToolbar* GetToolBar(); |
|
105 |
|
106 protected: // From MCoeView. |
|
107 |
|
108 /** |
|
109 * See @ref MCoeView. |
|
110 */ |
|
111 IMPORT_C void ViewActivatedL(const TVwsViewId& aPrevViewId, |
|
112 TUid aCustomMessageId, |
|
113 const TDesC8& aCustomMessage); |
|
114 |
|
115 /** |
|
116 * See @ref MCoeView |
|
117 */ |
|
118 IMPORT_C void ViewDeactivated(); |
|
119 |
|
120 |
|
121 protected: // From MGlxAnimationObserver |
|
122 IMPORT_C virtual void AnimationComplete(MGlxAnimation* aAnimation); |
|
123 |
|
124 protected: |
|
125 //From MAknToolbarObserver |
|
126 IMPORT_C void OfferToolbarEventL( TInt aCommand ); |
|
127 |
|
128 IMPORT_C void SetToolbarObserver(MAknToolbarObserver* aObserver); |
|
129 |
|
130 protected: |
|
131 /** |
|
132 * IMPORTANT: Call this from the ConstructL of any derived class |
|
133 */ |
|
134 IMPORT_C void ViewBaseConstructL(); |
|
135 |
|
136 /** |
|
137 * Derived classes should use this to deal with any view-specific commands |
|
138 * @param aCommand The command to respond to |
|
139 * @return ETrue iff the command has been handled. |
|
140 */ |
|
141 IMPORT_C virtual TBool HandleViewCommandL(TInt aCommand); |
|
142 |
|
143 /** |
|
144 * Derived classes should use this to initialize the menus if required |
|
145 * @param aResourceId The menu resource |
|
146 * @param aMenuPane The menu pane to edit |
|
147 */ |
|
148 IMPORT_C virtual void ViewDynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
149 |
|
150 /** |
|
151 * This will be called on derived classes when the view is activated |
|
152 * @param aPrevViewId Specifies the view previously active. |
|
153 * @param aCustomMessageId Specifies the message type. |
|
154 * @param aCustomMessage The activation message. |
|
155 */ |
|
156 virtual void DoViewActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage) = 0; |
|
157 |
|
158 /** |
|
159 * This will be called on derived classes when the view is deactivated |
|
160 */ |
|
161 virtual void DoViewDeactivate() = 0; |
|
162 |
|
163 /** |
|
164 * This is called on derived classes before the options menu |
|
165 * is opened. The derived classes should use it to ensure that |
|
166 * all required attributes have been retrieved in order to determine |
|
167 * if the command should be displayed on the options menu and. |
|
168 */ |
|
169 IMPORT_C virtual void FetchAttributesL(); |
|
170 |
|
171 /** |
|
172 * This is called on derived classes before commands are executed. |
|
173 * The derived classes should use it to ensure that all the required |
|
174 * attributes have been tetrieved in order to execute the command. |
|
175 */ |
|
176 IMPORT_C virtual void FetchAttributesForCommandL(TInt aCommand); |
|
177 |
|
178 /** |
|
179 * Report whether the given type of animation is supported by the class |
|
180 * @return ETrue iff the animaiton is implemented |
|
181 */ |
|
182 IMPORT_C virtual TBool ViewAnimationSupported(TGlxViewswitchAnimation aType); |
|
183 |
|
184 /** |
|
185 * Start the given type of view-switch animation |
|
186 * @param aType The type of animation (e.g. Entry / Exit) |
|
187 * @param aDirection The direction of the animation (e.g. Forwards / Backwards) |
|
188 */ |
|
189 IMPORT_C virtual void DoViewAnimationL(TGlxViewswitchAnimation aType, TGlxNavigationDirection aDirection); |
|
190 |
|
191 /** |
|
192 * Sets the toolbar state after command execution. |
|
193 * @ return ETrue If item is a system item. Else EFalse |
|
194 */ |
|
195 IMPORT_C virtual void SetToolbarStateL(); |
|
196 |
|
197 |
|
198 private: |
|
199 // From MEikMenuObserver |
|
200 IMPORT_C virtual void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
201 |
|
202 // From MGlxUiCommandHandler |
|
203 IMPORT_C void HandleCommandL(TInt aCommand); |
|
204 |
|
205 // From CAknView |
|
206 IMPORT_C void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); |
|
207 IMPORT_C void DoDeactivate(); |
|
208 |
|
209 private: |
|
210 |
|
211 /** |
|
212 * Initialize a viewswitch animation |
|
213 * @param aType The type of animation to start |
|
214 */ |
|
215 void InitAnimationL(TGlxViewswitchAnimation aType); |
|
216 |
|
217 /** |
|
218 * Cancel the current viewswitch animation, if any |
|
219 */ |
|
220 void CancelViewAnimation(); |
|
221 |
|
222 /** |
|
223 * Called when the view-switch animation is complete or interrupted |
|
224 * @param aType The type of animation (e.g. Entry / Exit) |
|
225 */ |
|
226 void ViewAnimationComplete(TGlxViewswitchAnimation aType); |
|
227 |
|
228 /** |
|
229 * Gets the title pane instance. |
|
230 */ |
|
231 CAknTitlePane* GetTitlePaneL(); |
|
232 |
|
233 /* |
|
234 * Set toolbar items dimmed. |
|
235 * @param aDimmed Flag for the toolbar items to be dimmed. |
|
236 */ |
|
237 void SetToolbarItemsDimmed(TBool aDimmed); |
|
238 |
|
239 protected: |
|
240 /** |
|
241 * Optionally implemented by sub-classes to prepare command handlers. |
|
242 * Called once for every command handler added to the view. |
|
243 * @param aCommandHandler command handler added to the view. |
|
244 */ |
|
245 virtual void DoPrepareCommandHandlerL(CGlxCommandHandler* /*aCommandHandler*/) {}; |
|
246 |
|
247 protected: |
|
248 /// The list of command handlers owned by the view |
|
249 RPointerArray<CGlxCommandHandler> iCommandHandlerList; |
|
250 |
|
251 protected: |
|
252 CGlxUiUtility* iUiUtility; ///< The UiUtility in use |
|
253 |
|
254 /// The view animation time |
|
255 TInt iViewAnimationTime; |
|
256 |
|
257 /// Status of FullScreen Transition is started |
|
258 TBool iIsTransEffectStarted; |
|
259 private: |
|
260 /** |
|
261 * Functions to handle view activate asynchronously |
|
262 */ |
|
263 static TBool ViewActivateCallbackL(TAny* aPtr); |
|
264 inline void ViewActivateL(); |
|
265 |
|
266 private: |
|
267 /// Resource file offset |
|
268 TInt iViewBaseResourceOffset; |
|
269 |
|
270 /// Ui Utility resource file offset |
|
271 TInt iUiUtilitiesResourceOffset; |
|
272 /// The type of viewswitch animation in progress, if any |
|
273 TGlxViewswitchAnimation iViewAnimationInProgress; |
|
274 |
|
275 /// Flag to determine if this view is activated synchronously |
|
276 const TBool iSyncActivation; |
|
277 |
|
278 //This is a Kind of Hack to prevent Photos to act on any command's till |
|
279 //Corresponding view is activated |
|
280 //This Should be fixed with Proper Way |
|
281 TBool iViewActivated; |
|
282 |
|
283 /// View activate attributes for callback |
|
284 TVwsViewId iPrevViewId; |
|
285 TUid iCustomMessageId; |
|
286 HBufC8* iCustomMessage; |
|
287 |
|
288 /// Callback for view activate |
|
289 CAsyncCallBack* iViewActivateCallback; |
|
290 |
|
291 /// Status pane for title |
|
292 CAknTitlePane* iTitlePane; |
|
293 //used store the grid toolbar |
|
294 CAknToolbar* iToolbar; |
|
295 }; |
|
296 |
|
297 |
|
298 #endif // C_GLXVIEWBASE_H |