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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 // Copyright (c) 1997-2001 Symbian Ltd. All rights reserved.
27 #include <babitflags.h>
35 // FORWARD DECLARATIONS
38 class CEikButtonGroupContainer;
39 class CAknControlStack;
40 class CAknViewExtension;
46 * This is an abstract base class for a Series 60 application view.
48 * @since Series 60 0.9
50 class CAknView : public CBase, public MCoeView, public MEikMenuObserver,
51 public MObjectProvider
56 * Standard constructor.
61 * Standard destructor.
66 * This is a second stage constructor initializing this view with standard
67 * values. Should be called from derived classes second stage construction
69 * @param aResId The numeric ID of the resource (@c iViewInfo) to be read.
70 * If aResId=0, resource file is not accessed.
72 IMPORT_C void BaseConstructL(TInt aResId=0);
75 * Constructs invisible button group container and menu if they don't exist
76 * yet. They are placed on the view stack. To be used by views which need
77 * to access the menu or cba before the view is activated for the first
80 IMPORT_C void ConstructMenuAndCbaEarlyL();
83 * Activate any view in the product. Calls @c CCoeAppUi::ActivateViewL(
85 * @param aViewId Identifies the view to activate.
87 IMPORT_C void ActivateViewL(const TVwsViewId& aViewId);
90 * Activate any view, then passes the message text @c aCustomMessage of
91 * type @c aCustomMessageId. Calls @c CCoeAppUi::ActivateViewL(
92 * aViewId,aCustomMessageId,aCustomMessage)
93 * @param aViewId Identifies the view to activate.
94 * @param aCustomMessageId Specifies the message type.
95 * @param aCustomMessage The message passed to the activated view.
97 IMPORT_C void ActivateViewL(const TVwsViewId& aViewId,
98 TUid aCustomMessageId,
99 const TDesC8& aCustomMessage);
102 * Returns views id, intended for overriding by sub classes.
103 * @return id for this view.
105 IMPORT_C virtual TUid Id() const =0;
108 * Event handler for status pane size changes.
109 * @c CAknView provides an empty implementation for sub classes that do
110 * not want to handle this event.
112 IMPORT_C virtual void HandleStatusPaneSizeChange();
115 * From @c MCoeView. The full view Id for this view. Calls @c Id()
116 * @return View identification number.
118 IMPORT_C TVwsViewId ViewId() const;
121 * From @c MEikMenuObserver. This function processes user commands by
122 * handling @c aCommand values @c EAknSoftkeyOptions, @c EAknCmdExit,
123 * @c EEikCmdCanceled and passing the others to @c HandleCommandL()
124 * for sub class to decide the actions.
125 * @param aCommand ID of the command to respond to.
127 IMPORT_C virtual void ProcessCommandL(TInt aCommand);
130 * Command handling function intended for overriding by sub classes.
131 * Default implementation is empty.
132 * @param aCommand ID of the command to respond to.
134 IMPORT_C virtual void HandleCommandL(TInt aCommand);
137 * Menu bar accessor method. This returns the views menu if available,
138 * otherwise it returns the applications menu bar.
139 * @return @c CEikMenuBar pointer to views menu bar.
141 IMPORT_C virtual CEikMenuBar* MenuBar() const;
144 * Calculates the client rectangle of the view, taking the applications
145 * client rectangle and the views CBA into account.
146 * Calls @c CEikAppUi::ClientRect()
147 * @return @c TRect the area of the screen available to the application
150 IMPORT_C TRect ClientRect() const;
153 * This function causes the menu bar to disappear from the screen until it
154 * is invoked again by the user.
155 * Calls @c CEikAppUi::StopDisplayingMenuBar().
157 IMPORT_C void StopDisplayingMenuBar();
160 * Determines whether the application is foreground.
161 * @return @c ETrue if view is foreground.
163 IMPORT_C TBool IsForeground() const;
166 * Called by the framework when view's rectangle changes. The default
167 * implementation is empty. This function is not used yet.
168 * @since Series 60 3.0
170 IMPORT_C virtual void HandleViewRectChange();
173 * Asks the view to redraw its area. Needs to be implemented only by
174 * views used in split view architecture. The default implementation is
175 * empty. This function is not used yet.
176 * @since Series 60 3.0
178 IMPORT_C virtual void Redraw() const;
182 * Avkon view architecture system. Internal use only.
183 * Calls @c DoActivateL.
185 IMPORT_C virtual void AknViewActivatedL(const TVwsViewId& aPrevViewId,
186 TUid aCustomMessageId,
187 const TDesC8& aCustomMessage);
190 * Avkon view architecture system. Internal use only. Function is called
191 * by @c CAknViewAppUi::~CAknViewAppUi() for immediate view deactivation.
192 * Calls @c DoDeactivate.
194 void AknViewDeactivated();
197 * Avkon view architecture system. Internal use only.
199 void ProcessForegroundEventL(TBool aForeground);
201 private: // formerly from @c MTopSetMember<CEikMenuBar>
202 IMPORT_C virtual void Reserved_MtsmPosition();
203 IMPORT_C virtual void Reserved_MtsmObject();
208 * Accessor for the applications user interface as a @c CAknViewAppUi.
209 * @return Pointer to user interface instance.
211 IMPORT_C CAknViewAppUi* AppUi() const;
214 * Status pane accessor method.
215 * @return Pointer to status pane.
217 IMPORT_C CEikStatusPane* StatusPane() const;
220 * Button group container (=CBA) accessor method.
221 * This returns the views CBA if there is one, and the applications user
222 * interfaces CBA otherwise.
223 * @return Pointer to @c CEikButtonGroupContainer.
225 IMPORT_C CEikButtonGroupContainer* Cba() const;
228 * Handles a view activation and passes the message of type
229 * @c aCustomMessageId. This function is intended for overriding by
230 * sub classes. This function is called by @c AknViewActivatedL().
231 * Views should not launch waiting or modal notes or dialogs in
233 * @param aPrevViewId Specifies the view previously active.
234 * @param aCustomMessageId Specifies the message type.
235 * @param aCustomMessage The activation message.
237 IMPORT_C virtual void DoActivateL(const TVwsViewId& aPrevViewId,
238 TUid aCustomMessageId,
239 const TDesC8& aCustomMessage) = 0;
242 * View deactivation function intended for overriding by sub classes.
243 * This function is called by @c AknViewDeactivated().
245 virtual void DoDeactivate() = 0;
247 protected: // From MCoeView.
250 * From @c MCoeView. Takes any action required when this view is activated.
251 * Handles this view activation event from view server. Calls
252 * @c CAknViewAppUi::ViewActivatedL()
253 * @param aPrevViewId Specifies the view previously active.
254 * @param aCustomMessageId Specifies the message type.
255 * @param aCustomMessage Activation message.
257 IMPORT_C void ViewActivatedL(const TVwsViewId& aPrevViewId,
258 TUid aCustomMessageId,
259 const TDesC8& aCustomMessage);
262 * From @c MCoeView. Takes any action that is required following
263 * deactivation of this view. Handles this view deactivation event from
264 * viewserver. Calls @c CAknViewAppUi::ViewDeactivated()
266 IMPORT_C void ViewDeactivated();
269 * From @c MCoeView. Screen device changed function from viewserver.
270 * @return TVwsViewIdAndMessage created with default values.
272 IMPORT_C TVwsViewIdAndMessage ViewScreenDeviceChangedL();
274 protected: // from MObjectProvider
277 * From @c MObjectProvider. Gets an (@c MAknsControlContext) object whose
278 * type is encapsulated by the specified TTypeUid object. Calls
279 * @c SupplyMopObject( @c TTypeUid aId,
280 * @c CEikButtonGroupContainer* iCba, @c CEikMenuBar* iMenu ).
281 * @param aId Encapsulates the @c Uid that identifies the type of object
283 * @return Pointer to the @c MAknsControlContext object provided. Note that
284 * the pointer may be @c NULL.
286 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
289 * From @c MObjectProvider. Gets the parent object provider.
290 * @return Pointer to the parent object provider (@c MObjectProvider) that
291 * is @c CAknViewAppUi* iAppUi, or @c NULL.
293 IMPORT_C MObjectProvider* MopNext();
295 protected: // From MEikMenuObserver.
298 * From @c MEikMenuObserver. Menu emphasising or de-emphasising function.
299 * @c CEikMenuBar objects call this on their observer. Updates the value of
300 * the flags for the (@c aMenuControl) on the control stack.
301 * @param aMenuControl The control to be emphasised or de-emphasisied.
302 * @param aEmphasis @c ETrue to emphasize the menu, @c EFalse to refuse the
305 IMPORT_C virtual void SetEmphasis(CCoeControl* aMenuControl,
309 * From @c MEikMenuObserver. Foreground event handling function intended
310 * for overriding by sub classes.
311 * @param aForeground Indicates the required focus state of the control.
313 IMPORT_C virtual void HandleForegroundEventL(TBool aForeground);
315 private: // internal functions
316 void ConstructMenuAndCbaL(TBool aVisible);
319 * Asserts that extension class object exists.
320 * @return Extension object.
322 CAknViewExtension* Extension() const;
324 public: // new functions
327 * @since Series 60 3.1
328 * @return toolbar object.
330 IMPORT_C CAknToolbar* Toolbar() const;
333 * This function causes toolbar to be hidden
334 * @since Series 60 3.1
336 IMPORT_C void StopDisplayingToolbar();
339 * Determines if the toolbar of this view is shown when the view is
342 * @return ETrue if toolbar is shown.
344 IMPORT_C TBool ToolbarShownOnViewActivation() const;
347 * Sets toolbar visibility status of this view according to value given.
348 * The value is used when view is activated.
350 * @param aVisible to determine if toolbar should be shown.
352 IMPORT_C void ShowToolbarOnViewActivation( TBool aVisible );
355 * Saves toolbar status of this view according to values given.
356 * The values are used when view is activated.
358 * @param aVisible to determine if toolbar should be shown.
359 * @param aFocused ETrue if toolbar is focused, EFalse if not
361 void SaveToolbarStatus( TBool aVisible, TBool aFocused );
364 * Sets new toolbar for the view. Deletes old toolbar. If the old toolbar
365 * was shown before deleting, then the new toolbar will also be shown.
367 * @param aToolbar pointer to new toolbar
369 IMPORT_C void SetToolbar( CAknToolbar* aToolbar );
372 * Creates a new toolbar object with the resource id given and sets it for
373 * the view. Deletes old toolbar. If the old toolbar was shown before
374 * deleting, then the new toolbar will also be shown.
376 * @param aResourceId Resource id of the new toolbar
378 IMPORT_C void CreateAndSetToolbarL( TInt aResourceId );
382 // The follow object is not owned by this class. iCoeEnv is protected in
383 // keeping with @c CCoeAppUi & @c CCoeControl
387 CAknViewAppUi* iAppUi;
389 // @c SAknViewInfo is the C++ image of resource structure AVKON_VIEW
393 TUint8 iVersion; // resource struct version
394 TInt iHotKeys; // resource id
395 TInt iMenu; // resource id
396 TInt iCba; // resource id
397 TInt iToolbar; // resource id
398 TInt iExtension; // resource id
401 // The following member data are owned by this class
402 SAknViewInfo iViewInfo;
404 CEikButtonGroupContainer* iCba;
406 CAknViewExtension* iExtension;