2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Base class for view architecture-based applications.
18 #ifndef __AKNVIEWAPPUI_H__
19 #define __AKNVIEWAPPUI_H__
24 // FORWARD DECLARATIONS
26 class CAknViewShutter;
27 class CAknLocalScreenClearer;
28 class CAknViewAppUiExtension;
29 class CAknViewNavigator;
32 #define iAvkonViewAppUi ((CAknViewAppUi*)CEikonEnv::Static()->EikAppUi())
37 * Base class for view architecture-based applications.
39 * @since Series 60 0.9
41 class CAknViewAppUi : public CAknAppUi
44 NONSHARABLE_CLASS(CViewActivationItem) : public CBase
49 * Two-phased constructor.
50 * @param aNewView Application view.
51 * @param aCustomMessageId Message ID.
52 * @param aCustomMessage Message contents.
53 * @param aPrevViewId The UID of the previously active view.
54 * @return Pointer to new @c CViewActivationItem object.
56 static CViewActivationItem* NewLC(CAknView* aNewView,
57 TUid aCustomMessageId,
58 const TDesC8& aCustomMessage,
59 const TVwsViewId& aPrevViewId);
64 ~CViewActivationItem();
66 CViewActivationItem(CAknView* aNewView,
67 TUid aCustomMessageId,
68 const TVwsViewId& aPrevViewId);
70 void ConstructL(const TDesC8& aCustomMessage);
77 TUid iCustomMessageId;
80 HBufC8* iCustomMessage;
82 // The UID of the previously active view.
83 TVwsViewId iPrevViewId;
87 * Container class used to hold information about one split view.
89 NONSHARABLE_CLASS(TAknSplitViewContainer)
93 * Checks is a view is part of the split view.
94 * @param aViewId UID of the view to be checked.
95 * @return ETrue if the given view belongs to the split view.
97 TBool IsPartOf( const TUid aViewId );
102 // ETrue if a view's activation failed
106 // the size of the leftmost view
110 typedef CArrayPtrFlat<CViewActivationItem> CAknViewActivationQueue;
111 typedef CArrayPtrFlat<CAknView> CAknViews;
116 * Initialises this app UI with standard values.
117 * @param aAppUiFlags Application user interface flags.
119 IMPORT_C void BaseConstructL(TInt aAppUiFlags=EStandardApp);
124 IMPORT_C virtual ~CAknViewAppUi();
127 * Activates a specified application view, without passing any message.
128 * The function leaves if activation of the view fails.
129 * @param aViewId Identifier of the view to activate.
131 IMPORT_C void ActivateLocalViewL(TUid aViewId);
134 * Activates a specified application view, then passes the message text
135 * descriptor aCustomMessage for a message of type aCustomMessageId.
136 * The function leaves if activation of the view fails.
137 * @param aViewId Identifier of the view to activate.
138 * @param aCustomMessageId Specifies the message type.
139 * @param aCustomMessage The message passed to the activated view.
141 IMPORT_C void ActivateLocalViewL(TUid aViewId,
142 TUid aCustomMessageId,
143 const TDesC8& aCustomMessage);
146 * Gets a pointer to specified application view.
147 * @param aView ID of the application view.
148 * @return Pointer to application view object,
149 * NULL if aView doesn't exists.
151 IMPORT_C CAknView* View(TUid aView) const;
154 * Registers and adds the view to the app UI.
155 * This function calls @c CCoeAppUi::RegisterViewL.
156 * @param aView The view to be registered and added.
158 IMPORT_C void AddViewL(CAknView* aView); // takes ownership of aView
161 * Removes and deregisteres the view from the app UI.
162 * This function calls @c CCoeAppUi::DeregisterView.
163 * @param aViewId The view to be deregistered and removed.
165 IMPORT_C void RemoveView(TUid aViewId);
168 * Processes user commands.
169 * @param aCommand A command ID.
171 IMPORT_C void ProcessCommandL(TInt aCommand);
174 * Stops displaying the application’s menu bar.
176 IMPORT_C void StopDisplayingMenuBar();
178 // Avkon view architecture system. Internal use only.
179 void ViewActivatedL(CAknView* aView,
180 const TVwsViewId& aPrevViewId,
181 TUid aCustomMessageId,
182 const TDesC8& aCustomMessage);
184 void ViewDeactivated(CAknView* aView);
187 * Combines two views. If either of the views belongs to another view combination
188 * then that combination is removed.
189 * @since Series 60 5.0
190 * @param aView1Id UID of the first (leftmost) view.
191 * @param aView2Id UID of the second view.
192 * @param aLeftViewSize Size of the first view (in percentages).
194 IMPORT_C void SetSplitViewL( const TUid aView1Id, const TUid aView2Id, const TInt aLeftViewSize );
197 * Removes a view combination containing the given view UID. If the view
198 * with the given UID is currently visible then the screen is switched to
199 * single view and the the given view stays active.
200 * @since Series 60 5.0
201 * @param aViewId UID of a view combination.
203 IMPORT_C void RemoveSplitViewL( const TUid aViewId );
206 * Checks if split view is in use.
207 * @since Series 60 5.0
208 * @return ETrue if a split view is active.
210 IMPORT_C TBool SplitViewActive() const;
213 * Returns the currently focused view.
214 * @since Series 60 5.0
215 * @return UID of the currently focused view.
217 IMPORT_C TUid FocusedView() const;
220 * Checks if the given view is visible on the screen.
221 * @since Series 60 5.0
222 * @param aViewId View to be checked.
223 * @return ETrue if the given view is visible.
225 IMPORT_C TBool ViewShown( const TUid aViewId ) const;
228 * Enables/disables local screen clearer.
229 * Local screen clearer is used in the view based applications
230 * to clear the application window if/when the view itself fails
231 * to do this. By default, the clearer is used.
232 * This function must be called before the BaseConstructL() to
233 * prevent the screen clearer on application start up.
236 * @param aEnable ETrue enables local screen clearer.
237 * EFalse disables local screen clearer.
239 IMPORT_C void EnableLocalScreenClearer( TBool aEnable = ETrue );
242 * Returns view's rectangle.
243 * @since Series 60 5.0
244 * @param aViewId UID of the view whose rectangle should be returned.
245 * @param Given view's drawing area.
247 TRect ViewRect( const TUid aViewId ) const;
250 * Handles keyboard initiated navigation between visible split views.
251 * @since Series 60 5.0
252 * @param aKeyEvent Keyboard event.
253 * @param EKeyWasConsumed if view focus was changed.
255 TKeyResponse HandleViewNavigationL( const TKeyEvent& aKeyEvent );
260 * From @c MEikStatusPaneObserver. Handles a change in the position or
261 * size of the screen area occupied by the status pane.
263 IMPORT_C void HandleStatusPaneSizeChange();
266 * From @c CCoeAppUi. Handles changes in keyboard focus when
267 * an application switches to foreground.
268 * @param aForeground @c ETrue if the application is in the foreground,
269 * otherwise @c EFalse.
271 IMPORT_C void HandleForegroundEventL(TBool aForeground);
274 * From AknAppUi. Handles pointer-initiated view switch. Currently this
275 * function does nothing but calls base class function.
276 * @since Series 60 3.0
277 * @param aEvent Window server event.
278 * @param aDestination Pointer to the control which the event is targeted to.
280 IMPORT_C void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
283 static TInt ActivationCallBack(TAny* aThis);
284 void ActivationTick();
285 void QueueActivationTick();
288 * Asserts that extension object has been created.
289 * @return Extension object.
291 CAknViewAppUiExtension* Extension() const;
294 * Activates views in split view.
295 * @since Series 60 5.0
296 * @param View under activation.
298 void ActivateSplitViewL( CViewActivationItem* aItem );
301 * If the given view is part of a split view then returns that split view,
302 * @since Series 60 5.0
303 * @param aViewId UID of a view that belongs to a split view.
304 * @return Pointer to a correct split view or NULL if no corresponding split view was found.
306 TAknSplitViewContainer* SplitView( const TUid aViewId ) const;
313 // Application views.
317 CAknViewShutter* iShutter;
318 CAknLocalScreenClearer* iClearer;
319 CAknViewActivationQueue* iActivationQueue;
320 CIdle* iActivationTick;
322 CAknViewAppUiExtension* iExtension;
325 #endif // __AKNVIEWAPPUI_H__