2 * Copyright (c) 2002-2010 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: EIKON Status Pane control.
19 #ifndef __EIKSPANE_H__
20 #define __EIKSPANE_H__
26 class CCoeBrushAndPenContext;
27 class CEikStatusPaneContainer;
28 class CEikStatusPaneBaseExtension;
29 class CAknStatuspaneClearer;
30 class CAknDelayedForegroundObserver;
31 class CAknStatusPaneDataSubscriber;
35 * Status pane flag indicating that a sub-pane exists
38 const TInt KStatusPaneCapsPresentBit = 1;
41 * Status pane flag indicating that a sub-pane is owned
42 * by the application side status pane.
44 const TInt KStatusPaneCapsAppOwnedBit = 2;
47 * Status pane flag indicating that a sub-pane is part of
48 * a specific status pane layout.
50 const TInt KStatusPaneCapsInCurrentLayoutBit = 4;
53 * The @c MEikStatusPaneObserver interface allows a status pane observer to
54 * pick up changes in the size or position of the status pane. Such events
55 * will be as a result of layout changes which cause an actual change in the
56 * status pane rectangle.
58 class MEikStatusPaneObserver
61 virtual void HandleStatusPaneSizeChange() = 0;
65 * The base class for status panes.
67 class CEikStatusPaneBase : public CBase
73 * Describes the capabilities of a subpane.
75 class TPaneCapabilities
86 * Tests whether the subpane exists in the status pane.
88 * @return @c ETrue if the subpane exists and can be used by the
89 * application, even if the subpane is not visible.
91 inline TBool IsPresent() const;
94 * Tests whether the pane is owned by the application or the server.
95 * Applications can only interact directly with application owned
98 * @return @c ETrue if the subpane is owned by the application.
100 inline TBool IsAppOwned() const;
103 * Tests if this pane is part of the current status pane layout.
105 * @return @c ETrue if pane is part of the current status pane layout.
107 inline TBool IsInCurrentLayout() const;
111 inline void SetPresent();
112 inline void SetAppOwned();
113 inline void SetInCurrentLayout();
121 friend class CEikStatusPaneBase;
129 IMPORT_C ~CEikStatusPaneBase();
132 * Gets a pointer to the thread's currently active status pane
133 * without transferring ownership.
135 * @return Pointer to currently active status pane.
136 * Returns @c NULL if no such pane exists.
138 IMPORT_C static CEikStatusPaneBase* Current();
141 * Sets the status pane observer.
143 * @param aObserver Pointer to status pane observer.
145 inline void SetObserver( MEikStatusPaneObserver* aObserver );
148 * Modifies the bounding rectangle so that it lies next to the
149 * status pane rectangle.
151 * The status pane always places itself along the edge of the screen, so
152 * that it is consistent across applications and the server. It is
153 * assumed that the given bounding rectangle does not extend beyond
156 * @param[in,out] aBoundingRect The bounding rectangle.
158 IMPORT_C void ReduceRect( TRect& aBoundingRect ) const;
161 * Adds and removes pane rectangles from @c aRegion.
163 * @param aRegion The two-dimensional area from where
164 * rectangles are removed from or where
165 * rectangles are added to.
166 * @param aIncludeAppPanes If @c ETrue, app panes are added, otherwise
168 * @param aIncludeServerPanes If @c ETrue, server panes are added,
171 IMPORT_C void GetShapeL( TRegion& aRegion,
172 TBool aIncludeAppPanes,
173 TBool aIncludeServerPanes ) const;
176 * Switches to the specified status pane layout.
178 * The actual layout to which this method switches may not be the
179 * same as specified in @c aLayoutResourceId parameter.
180 * Eg. if landscape mode status pane layout is set with this method,
181 * while in portrait mode, it's mapped to the corresponding layout
182 * in the portrait mode. This should be noted when using
183 * @c CEikStatusPaneBase::CurrentLayoutResId().
185 * From release 3.2 on the old status pane layouts are also mapped
186 * to the new layouts, ie.
187 * @c R_AVKON_STATUS_PANE_LAYOUT_USUAL ->
188 * @c R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT
190 * @c R_AVKON_STATUS_PANE_LAYOUT_IDLE ->
191 * @c R_AVKON_STATUS_PANE_LAYOUT_IDLE_EXT
193 * @param aLayoutResourceId Layout resource ID. This must be one of the
194 * layouts identified in the status pane
195 * resource structures, otherwise the function
196 * leaves @c KErrNotFound.
199 * @leave KErrNotFound The specified layout does not exist in the
200 * status pane resource structures.
202 IMPORT_C virtual void SwitchLayoutL( TInt aLayoutResourceId );
205 * Sets the visibility of the status pane and it's contents.
207 * @param aVisible If @c ETrue the status pane and it's contents are set
210 IMPORT_C virtual void MakeVisible( TBool aVisible );
213 * Sets the status pane and it's contents to dimmed state.
215 * @param aDimmed If @c ETrue the status pane and it's contents are
216 * set to dimmed state.
218 IMPORT_C virtual void SetDimmed( TBool aDimmed );
223 * @param aFaded Not used.
225 IMPORT_C virtual void SetFaded( TBool aFaded );
228 * Handles changes in resources which are shared across the environment.
229 * This function responds to the changes in resources by propagating them
230 * to sub-parts of the status pane.
232 * @param aType A message type.
234 IMPORT_C virtual void HandleResourceChange( TInt aType );
237 * Returns always @c ETrue.
241 IMPORT_C virtual TBool OkToChangeStatusPaneNow();
244 * Sets all the visual flags at once
245 * (@c KEikStatusPaneBaseVisibleBit and
246 * @c KEikStatusPaneBaseDimmedBit).
248 * @param aFlags Flags to be set.
250 IMPORT_C void SetFlags( TInt aFlags );
253 * Gets status pane settings.
255 * @return Flags used by status pane base class.
257 IMPORT_C TInt Flags() const;
260 * Gets the visibility of the status pane.
262 * @return @c ETrue if the status pane is visible.
264 IMPORT_C TBool IsVisible() const;
267 * Gets the dimmed state of the status pane.
269 * @return @c ETrue if the status pane is dimmed.
271 IMPORT_C TBool IsDimmed() const;
274 * Gets the fade status of the status pane.
276 * @return @c ETrue if status pane is faded.
278 IMPORT_C TBool IsFaded() const;
281 * Gets the capabilities of a sub-pane in the status pane.
283 * @param aPaneId Sub-pane ID.
285 * @return Capabilities of the pane.
287 IMPORT_C TPaneCapabilities PaneCapabilities( TPaneId aPaneId ) const;
290 * Provides the screen rectangle of a sub-pane.
291 * This can be used to set the size of a new control which you want
292 * to place in the status pane.
294 * @param aPaneId Sub-pane ID.
296 * @return The sub-pane rectangle.
298 * @leave KErrNotFound The sub-pane ID is not valid.
300 IMPORT_C TRect PaneRectL( TPaneId aPaneId ) const;
303 * Provides the control currently inside a sub-pane.
304 * This gives the application direct access to the contents of a pane.
306 * @param aPaneId Sub-pane ID.
308 * @return Pointer to the control instance inside the sub-pane.
310 * @leave KErrNotFound The sub-pane ID is not valid.
312 IMPORT_C CCoeControl* ControlL( TPaneId aPaneId ) const;
315 * Swaps the control currently inside a sub-pane.
316 * The new control must be a fully constructed control.
317 * It will be placed inside the status pane, and the current
318 * content will be returned to the caller.
320 * @param aPaneId ID of the sub-pane.
321 * @param aNewControl A fully constructed control to
322 * place at @c aPaneId.
324 * @return The control which was at @c aPaneId.
326 * @leave KErrNotFound This can occur before ownership of the new
327 * control is taken, if the subpane ID is not valid.
329 IMPORT_C CCoeControl* SwapControlL( TPaneId aPaneId,
330 CCoeControl* aNewControl );
333 * Provides access to the container control of a sub-pane.
334 * You will need access to the container of a sub pane if you want
335 * to swap in a new control. The container control should be set as the
336 * parent window of the new control.
337 * It also provides a fast way to get the rectangle of the sub-pane
340 * @param aPaneId ID of the sub-pane.
342 * @return Pointer to the new container control for the sub-pane.
344 * @leave KErrNotFound The sub-pane ID is not valid.
346 IMPORT_C CCoeControl* ContainerControlL( TPaneId aPaneId ) const;
349 * Provides access to a server-side window group.
351 * @return Pointer to the window group.
353 inline RWindowGroup* WindowGroup() const;
358 IMPORT_C void DrawNow();
361 * Gets the resource ID of the current layout.
363 * @return The resource ID of the current layout.
366 IMPORT_C TInt CurrentLayoutResId() const;
369 * Status pane drawing commands.
376 /** Draw immediately. */
379 /** Draw with low priority. */
384 * Sets the skin background ID of sub-panes which
385 * are in the CBA area.
386 * @internal This method is not exported.
388 * @param aBgID The skin background ID to be set.
389 * @param aDrawCmd Whether the status pane is drawn
390 * when updating the background context,
391 * (@see @c TDrawCmd).
393 void SetCbaAreaBackgroundID( const TAknsItemID& aBgID,
394 CEikStatusPaneBase::TDrawCmd aDrawCmd );
397 * Returns the current skin background ID of the sub-panes
398 * which are in the CBA area.
399 * @internal This method is not exported.
401 * @return The skin background ID.
403 TAknsItemID CbaAreaBackgroundID();
408 * C++ default constructor.
410 * @param aEikEnv An environment for creating controls and utility
411 * functions for manipulating them.
412 * @param aParent Pointer to the parent window group.
414 IMPORT_C CEikStatusPaneBase( CEikonEnv& aEikEnv, RWindowGroup* aParent );
417 * Initializes the status pane with standard values.
419 * @param aCoreResId ID of the status pane resource.
421 IMPORT_C void BaseConstructL( TInt aCoreResId );
424 * Creates a new model for the status pane.
426 * @param aCoreResId ID of the status pane resource.
428 * @return Pointer to the new status pane model instance.
430 virtual CEikStatusPaneModelBase* CreateModelL( TInt aCoreResId ) const = 0;
433 * Creates the sub-panes to the status pane.
438 * Creates a sub-pane.
440 * @param[in] aPaneInit Initial values for the sub-pane.
442 void CreatePaneL( const TEikStatusPaneInit& aPaneInit );
445 * Gets a container of a specified sub-pane.
447 * @param aPaneId The sub-pane ID.
449 * @return Pointer to the container of the sub-pane with a given ID.
451 CEikStatusPaneContainer* Find( TPaneId aPaneId ) const;
454 * Can be used to determine whether or not the status pane is on
455 * application side or server side.
457 * @return @c ETrue if the status pane resides in the application side,
458 * @c EFalse if it's on the server side.
460 virtual TBool IsApp() const = 0;
463 * Gets the rectangle of the status pane.
465 * @return The rectangle used by the status pane.
467 inline TRect Rect() const;
470 * Calls @c CCoeControl's @c DrawNow() or @c DrawDeferred() to draw the
471 * status pane. If @c aDraw is @c ENoDraw status pane is not drawed.
473 * @param aDraw Status pane drawing command.
475 void DoDrawNow( TDrawCmd aDraw );
478 * Gets the status pane clearer.
480 * @return Pointer to the status pane clearer instance.
482 CAknStatuspaneClearer* Clearer();
485 * Disables the status pane clearer.
487 * @param aDisabled Disabled if @c ETrue.
489 IMPORT_C void DisableClearer( TBool aDisabled );
492 * Prepares the status pane for the application exit.
493 * Clears the status pane.
495 IMPORT_C void CommonPrepareForAppExit();
499 void DoSwitchLayoutL( TInt aLayoutResourceId, TDrawCmd aDraw );
500 void ApplyLayoutL( CEikStatusPaneLayout* aLayout, TDrawCmd aDraw );
501 void SetAllInvisible();
502 void SetNotNeededInvisible();
507 * Notifies the command button area and status pane observer about the
508 * status pane size change. If the status pane is an embedded application,
509 * also this application is notified.
511 void ReportSizeChange();
515 class TSetRectAndVisibility : public MEikStatusPaneLayoutTreeVisitor
519 TSetRectAndVisibility( TBool aIsApp, CEikStatusPaneBase* aStatusPane );
520 void VisitL( CEikStatusPaneLayoutTree* aNode );
525 CEikStatusPaneBase* iStatusPane;
528 friend class TSetRectAndVisibility;
532 void SetLastUsedResourceId( TInt aResourceId );
533 TInt LastUsedResourceId();
534 TInt ReadInitialUsedResourceIdL( TInt aCoreResId );
535 TInt InitialUsedResourceId();
536 TRect LargestBoundingRect( TRegion& aWholeRegion,
537 TRegion& aRemovedRegion ) const;
538 void SetCombinedPaneVisibilityL( TBool aVisible );
543 * Gets the status pane data subscriber.
545 * @return Pointer to the status pane data subscriber.
547 CAknStatusPaneDataSubscriber* DataSubscriber() const;
550 * Sets the initial status pane resource ID to an extension class
551 * @c CEikStatusPaneBaseExtension.
553 * @param aResourceId The initial status pane resource ID.
555 void SetInitialUsedResourceId( TInt aResourceId );
558 * Optimizes the status pane region which cleared during
559 * status pane layout change.
561 * @param aOldResourceId Old status pane resource ID.
562 * @param aNewResourceId New status pane resource ID.
563 * @param[in,out] aRegion Status pane region.
564 * On return contains only
565 * the region that needs to be cleared.
567 void OptimizeClearerWindowShape( TInt aOldResourceId,
572 * Sets redraw storing state of the window.
574 * @param aWindow The window whose redraw storing state is to be set.
575 * @param aOn @c ETrue to turn redraw storing on.
577 void SetStoreHandler( RWindow* aWindow, TBool aOn );
582 * An environment for creating controls and utility functions for
588 * Status pane model class. <br>
591 CEikStatusPaneModelBase* iModel;
594 * Flags for the status pane.
600 typedef CArrayPtrFlat<CEikStatusPaneContainer> CContainerControls;
601 CContainerControls* iControls;
605 MEikStatusPaneObserver* iObserver;
606 RWindowGroup* iParentWindowGroup;
607 CEikStatusPaneBaseExtension* iExtension;
611 * Application side status pane class.
613 * @c CEikStatusPane is the interface through which applications use the
614 * status pane. This class synchronises the status pane layout with the
615 * server side status pane object. To do this, the @c ApplyCurrentSettingsL()
616 * method must be called whenever the owner application switches to the
619 NONSHARABLE_CLASS( CEikStatusPane ) : public CEikStatusPaneBase,
620 public MCoeForegroundObserver
625 * Two-phased constructor.
627 * @param aEikEnv An environment for creating controls
628 * and utility functions for
630 * @param aParent Pointer to the parent window group.
631 * @param aCoreStatusPaneModelResId Status pane core resource ID.
632 * @param aAppStatusPaneModelResId Resource ID of the application's
635 * @return Pointer to the created @c CEikStatusPane object.
637 IMPORT_C static CEikStatusPane* NewL(
639 RWindowGroup* aParent,
640 TInt aCoreStatusPaneModelResId,
641 TInt aAppStatusPaneModelResId = EEikStatusPaneUseDefaults );
646 IMPORT_C ~CEikStatusPane();
649 * Synchronises the server status pane layout with the
650 * application status pane.
652 IMPORT_C void ApplyCurrentSettingsL();
655 * Prepares the status pane for the application exit.
656 * Clears the status pane.
658 IMPORT_C void PrepareForAppExit();
661 * Sets the visiblility of the status pane and its contents.
662 * From @c CEikStatusPaneBase.
664 * @param aVisible If @c ETrue the status pane and its
665 * contents are set visible.
667 IMPORT_C virtual void MakeVisible( TBool aVisible );
670 * Sets the status pane and its contents to dimmed state.
671 * From @c CEikStatusPaneBase.
673 * @param aDimmed If @c ETrue the status pane and its
674 * contents are set to dimmed state.
676 IMPORT_C virtual void SetDimmed( TBool aDimmed );
680 * From @c CEikStatusPaneBase.
682 * @param aFaded Not used.
684 IMPORT_C virtual void SetFaded( TBool aFaded );
687 * Handles changes in resources which are shared across the environment.
688 * This function responds to the changes in resources by propagating them
689 * to sub-parts of the status pane.
690 * From @c CEikStatusPaneBase.
692 * @param aType A message type.
694 IMPORT_C virtual void HandleResourceChange( TInt aType );
697 * Returns always @c ETrue.
698 * From @c CEikStatusPaneBase.
702 IMPORT_C virtual TBool OkToChangeStatusPaneNow();
707 * Default C++ constructor.
709 * @param aEikEnv An environment for creating controls
710 * and utility functions for
712 * @param aParent Pointer to the parent window group.
713 * @param aAppStatusPaneModelResId Resource ID of the application's
716 CEikStatusPane( CEikonEnv& aEikEnv,
717 RWindowGroup* aParent,
718 TInt aAppStatusPaneModelId );
721 * Second-phase constructor.
723 * @param aCoreStatusPaneModelResId Status pane core resource ID.
725 void ConstructL( TInt aCoreStatusPaneModelResId );
728 * Creates the application side status pane model.
730 * @param aCoreResId Status pane core resource ID.
732 virtual CEikStatusPaneModelBase* CreateModelL( TInt aCoreResId ) const;
735 * Can be used to determine whether or not the status pane is on
736 * application side or server side.
743 * Applies the current status pane flags.
745 void ApplyCurrentFlags();
748 * Hides all the sub-panes owned by the application
751 void HideAppPanes( TBool aHide );
753 private: // From base class @c MCoeForegroundObserver.
756 * Handles foreground gain events.
758 void HandleGainingForeground();
761 * Handles foreground lose events.
763 void HandleLosingForeground();
768 * Reads the initial status pane layout from the status pane resources.
770 * @param aCoreResId Status pane core resource ID.
771 * @param aAppStatusPaneModelResId Resource ID specified by the
774 TInt ReadInitialUsedResourceIdL( TInt aCoreResId,
775 TInt aAppStatusPaneModelResId );
778 * Handles foreground lose events.
780 void DoHandleLosingForegroundL();
786 /** Formerly TEikStatusPaneSyncDrawer* iSyncDrawer */
789 /** Formerly iServerSpWgId */
790 CAknDelayedForegroundObserver* iDelayedForegroundObserver;
794 * Checks if the pane exists in this status pane.
795 * Note: this will return @c ETrue if the pane can be used,
796 * even if it is not visible.
798 inline TBool CEikStatusPaneBase::TPaneCapabilities::IsPresent() const
800 return iFlags & KStatusPaneCapsPresentBit;
804 * Checks if this pane is owned by application rather than the server.
805 * Applications can only interact directly with application owned panes.
807 inline TBool CEikStatusPaneBase::TPaneCapabilities::IsAppOwned() const
809 return iFlags & KStatusPaneCapsAppOwnedBit;
813 * Checks if this pane is part of the current status pane layout.
815 inline TBool CEikStatusPaneBase::TPaneCapabilities::IsInCurrentLayout() const
817 return iFlags & KStatusPaneCapsInCurrentLayoutBit;
821 * Set the status pane observer.
823 inline void CEikStatusPaneBase::SetObserver( MEikStatusPaneObserver* aObserver )
825 iObserver = aObserver;
829 * Gets the status pane rectangle.
831 inline TRect CEikStatusPaneBase::Rect() const
833 return iModel->CurrentLayout()->Rect();
837 * Gets the window group that this status pane belongs to.
839 inline RWindowGroup* CEikStatusPaneBase::WindowGroup() const
841 return iParentWindowGroup;
844 #endif // __EIKSPANE_H__