2 * Copyright (c) 1997-1999 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.
19 #if !defined(__EIKSPMOD_H__)
20 #define __EIKSPMOD_H__
22 #if !defined(__E32BASE_H__)
26 #if !defined(__EIKON_HRH__)
30 #if !defined(__EIKSRVC_H__)
35 class TResourceReader;
36 class CEikStatusPaneLayoutTree;
39 class CEikStatusPaneLayout;
40 namespace AknLayout { class CInstance; }
41 namespace AknLayoutScalable_Avkon { class CInstance; }
43 // Extra bit flags not defined in hrh file.
44 const TInt KEikStatusPaneDirectionBit = 0x04;
45 const TInt KEikStatusPaneHiddenBit = 0x08;
46 const TInt KEikStatusPaneInitInitializedBit = 0x80000000;
53 * This class stores the details about status pane sub pane
54 * ownership and initial contents.
57 class TEikStatusPaneInit
61 * Default constructor.
68 TEikStatusPaneInit(const TEikStatusPaneInit& aCopy);
73 TEikStatusPaneInit& operator=(const TEikStatusPaneInit& aCopy);
77 * @return id of the pane.
79 inline TPaneId Id() const;
82 * Loads deafault values of the pane from given resource.
83 * Resource reader should point to an entry from the arrays of
84 * SPANE_PANE structures found in the STATUS_PANE_SYSTEM_MODEL
85 * and STATUS_PANE_APP_MODEL resource structures.
87 * @param @aResource Resource reader.
89 void LoadDefaults(TResourceReader& aResource);
92 * Gets flag that indicates if the sub pane is owned by the
94 * @return ETrue if pane is application owned, otherwise EFalse.
96 inline TBool AppOwned() const;
99 * Returns control type id of the pane.
100 * @return Id of the control inside the pane.
102 inline TInt ControlTypeId() const;
105 * Returns resource id of the control in the pane.
106 * @return Control resource id.
108 inline TInt ControlResourceId() const;
113 inline void SetHidden();
116 * Clears hidden flag.
118 inline void ClearHidden();
122 * @return ETrue if the pane is hidden.
124 inline TBool IsHidden() const;
128 * Gets initialized flag.
129 * @return ETrue if the pane is initialized.
131 inline TBool Initialized();
134 * Sets initialized flag.
136 inline void SetInitialized();
141 TInt iControlResource;
148 * This class stores array of TEikStatusPaneInit instances.
151 NONSHARABLE_CLASS(CEikStatusPaneSetInit) : public CArrayFixFlat<TEikStatusPaneInit>
156 * Two phase constructor.
158 static CEikStatusPaneSetInit* NewL();
163 ~CEikStatusPaneSetInit();
166 * Loads deafault values of the panes from given resource.
167 * Values are read from SPANE_PANE structure found in the
168 * STATUS_PANE_SYSTEM_MODEL and STATUS_PANE_APP_MODEL resource
170 * @param @aResource Resource reader.
172 void LoadDefaultsL(TResourceReader& aResource);
175 * Finds the pane init with a given id. If a pane init
176 * is not found, method leaves with code KErrNotFound.
177 * @return The pane init instance with given id.
179 TEikStatusPaneInit& FindL(const TPaneId& aPaneId);
184 * Private constructor.
186 CEikStatusPaneSetInit();
192 * This abstract class is used for checking pane layout validity.
195 class MEikStatusPaneLayoutTreeVisitor
199 * Virtual function of which implementation should be provided
200 * by the classes that implement the layout check visitor design
202 * @param aNode A layout node to be visited.
204 virtual void VisitL(CEikStatusPaneLayoutTree* aNode) = 0;
211 * This class calculates and stores the screen area available
212 * for each layout tree.
215 NONSHARABLE_CLASS(CEikStatusPaneLayoutTree) : public CBase
220 /** Horizontal direction */
222 /** Vertical direction */
230 ~CEikStatusPaneLayoutTree();
233 * Two phase constructor.
234 * @param aLayout Layout data
235 * @param aResource Resource of layout tree.
236 * @param aDefaultDirection Default direction of the layout tree.
238 static CEikStatusPaneLayoutTree* NewL(CEikStatusPaneLayout* aLayout, TResourceReader& aResource, TDirection aDefaultDirection = EHorizontal);
241 * Finds the layout tree with a given pane id.
242 * @param aPaneId A id of the pane.
243 * @return If layout tree was found, a pointer to layout tree
244 * with given id. Otherwise NULL is returned.
246 CEikStatusPaneLayoutTree* Find(const TPaneId& aPaneId);
249 * Calls given visitor objects VisitL, method. Additionally
250 * calls AcceptL -method of each sub pane layouts inside this layout tree.
251 * @param aVisitor A visitor object to be visited.
253 void AcceptL(MEikStatusPaneLayoutTreeVisitor* aVisitor);
257 * @return id of the pane.
259 inline TPaneId Id() const;
262 * Gets rectagle of the layout tree.
263 * @return Rectangle of the layout tree.
265 inline TRect Rect() const;
268 * This method maps given layout resource id and subpane UID to correct
269 * layout lines in the AknLayout system.
272 * @param aLayoutResourceId Id of a statuspane layout.
273 * @param aPaneId Uid of a statuspane subpane.
274 * @return A rectangle which specifies the given subpane size
275 * and position in the given layout.
278 TRect AknLayoutRect(TInt aLayoutResourceId, TPaneId aPaneId);
283 * Private constructor.
284 * @param aLayout Layout data
285 * @param aDefaultDirection Default direction of the layout tree.
287 CEikStatusPaneLayoutTree(CEikStatusPaneLayout* aLayout, TDirection aDefaultDirection);
290 * Private 2nd phase constructor.
291 * @param aResource Resource of layout tree.
293 void ConstructL(TResourceReader& aResource);
296 * Sets rectagle of the layout tree.
297 * @param aRect Rectangle of the layout tree.
299 void SetRect(const TRect& aRect);
302 * Gets direction of the layout tree.
303 * @return Direction of the layout tree.
305 inline TDirection Direction();
308 * Sets direction of the layout tree.
309 * @param aDirection Direction of the layout tree.
311 void SetDirection(TDirection aDirection);
314 * Gets size of the layout tree.
315 * @return size of the layout tree.
320 * Gets stretchable flag of the layout tree.
321 * @return Stretchable flag of the layout tree.
323 inline TBool Stretchable();
326 * Sets stretchable flag of the layout tree.
327 * @param Stretchable flag of the layout tree.
329 void SetStretchable(TBool aStretchable);
332 * Sets the layout of the sub panes inside layout tree according to
333 * layout tree attributes read from the resource structures.
338 * This methods purpose is eqvivalent of the Layout() method, but the difference
339 * is that this method uses AknLayout system instead of the statuspane
340 * resource definitions for determining the positions and sizes of the subpanes.
342 * If AknLayoutUsed flag has not been set then this method defaults to the behaviour
343 * of the Layout() -method.
346 * @param aLayoutResourceId Id of the statuspane layout which is to be laid out.
349 void Layout(TInt aLayoutResourceId);
352 * This method sets flag which tells wheter AknLayout system is
353 * used or not for layout.
356 * @param aAknLayoutUsed ETrue if AknLayout is to be used. EFalse otherwise.
359 void SetAknLayoutUsed(TBool aAknLayoutUsed);
362 * This method gets flag which tells wheter AknLayout system is
363 * used or not for layout.
366 * @return ETrue if AknLayout is to be used. EFalse otherwise.
369 TBool AknLayoutUsed();
377 typedef CArrayPtrFlat<CEikStatusPaneLayoutTree> CSubPaneArray;
378 CSubPaneArray* iSubPanes;
380 CEikStatusPaneLayout* iLayout;
383 friend class CEikStatusPaneLayout;
389 * This class calculates and stores the screen area available
390 * for each sub pane layout.
393 NONSHARABLE_CLASS(CEikStatusPaneLayout) : public CBase
397 * Two phase constructor.
398 * @param aResource Resource of sub pane layout.
399 * @param aScreenRect Screen rectangle.
401 static CEikStatusPaneLayout* NewL(TResourceReader& aResource, const TRect& aScreenRect);
404 * Two phase constructor.
405 * @param aResource Resource of sub pane layout.
406 * @param aScreenRect Screen rectangle.
407 * @param aLayoutId Id of the status pane layout.
409 static CEikStatusPaneLayout* NewL(TResourceReader& aResource, const TRect& aScreenRect, TInt aLayoutId);
414 ~CEikStatusPaneLayout();
417 * Finds the pane init with a given id. If a pane init
418 * is not found NULL pointer is returned.
419 * @return The layout tree instance with given id.
421 inline CEikStatusPaneLayoutTree* Find(const TPaneId& aPaneId) const;
424 * Calls given visitor objects VisitL, method.
425 * @param aVisitor A visitor object to be visited.
427 inline void AcceptL(MEikStatusPaneLayoutTreeVisitor* aVisitor);
430 * Gets rectagle of the sub pane layout.
431 * @return Rectangle of the sub pane layout.
433 inline TRect Rect() const;
436 * Re-reads layout data from AknLayout system. The data may have to be refreshed when e.g.
437 * screen resolution, orientation or language variant layout is changed on the fly.
440 * @param aLayoutResourceId Id of the statuspane layout which data is to be refreshed.
443 void AknLayoutRefresh(TInt aLayoutResourceId);
446 * This method tells if this layout is using AknLayout system for placing and sizing
447 * the statuspane subpanes.
450 * @return ETrue if this layout has been initailized to use AknLayout. EFalse if the default
451 * statuspane layout system is in use.
454 TBool AknLayoutUsed();
457 * This method maps given layout resource id and subpane UID to correct
458 * layout lines in the AknLayout system.
461 * @param aLayoutResourceId Id of a statuspane layout.
462 * @param aPaneId Uid of a statuspane subpane.
463 * @return A rectangle which specifies the given subpane size
464 * and position in the given layout.
467 TRect AknLayoutRect(TInt aLayoutResourceId, TPaneId aPaneId);
474 CEikStatusPaneLayout();
477 * 2nd phase constructor.
479 void ConstructL(TResourceReader& aResource, const TRect& aScreenRect, TInt aLayoutId);
482 CEikStatusPaneLayoutTree* iRoot;
487 * Updates layout data.
488 * @param aLayoutResId Status pane layout resource id.
490 void UpdateLayoutData(TInt aLayoutResId);
492 private: // layout data for all nodes in CEikStatusPaneLayoutTree
493 friend class CEikStatusPaneLayoutTree;
494 const AknLayout::CInstance& iAknLayout;
495 const AknLayoutScalable_Avkon::CInstance& iAknLayoutScalable_Avkon;
498 TRect iUsualStatusPaneRect;
499 TRect iApplicationWindowRect;
500 TRect iStaconLayout1Rect;
501 TRect iStaconLayout2Rect;
502 TRect iSmallStatusPaneRect;
508 * Base class for status pane model.
511 class CEikStatusPaneModelBase : public CBase
518 IMPORT_C ~CEikStatusPaneModelBase();
521 * Gets the pane inits of the status pane.
522 * @return Pane inits.
524 inline CEikStatusPaneSetInit* PaneInits() const;
527 * Sets the status pane layout
528 * @param aLayoutResId Resource id of the status pane layout.
529 * @param aChangeStatusPaneNow A flag to indicate immediate status pane layout change.
531 IMPORT_C virtual void SetLayoutL(TInt aLayoutResId, TBool aChangeStatusPaneNow = ETrue);
534 * Gets the current layout.
535 * @return The current layout.
537 inline CEikStatusPaneLayout* CurrentLayout() const;
540 * Gets the current layout resource id.
541 * @return The current layout resource id.
543 IMPORT_C TInt CurrentLayoutResId() const;
546 * Re-reads layout data for all existing layouts from AknLayout system. The data
547 * may have to be refreshed when e.g. screen resolution, orientation or language
548 * variant layout is changed on the fly.
553 void AknLayoutRefresh();
556 * This method tells if given layout is using AknLayout system for placing and sizing
557 * the statuspane subpanes.
560 * @param aLayoutId Layout which layout type is wanted to be known.
561 * @return ETrue if given layout has been initailized to use AknLayout. EFalse if the default
562 * statuspane layout system is in use.
565 TBool AknLayoutUsed(TInt aLayoutId);
570 * Internal class to CEikStatusPaneModel,
571 * which ties layout resource IDs to layout structures.
573 NONSHARABLE_CLASS(CIdLayoutPair) : public CBase
578 * @param aResId Resource id
579 * @param aLayout Sub pane layout
581 CIdLayoutPair(TInt aResId, CEikStatusPaneLayout* aLayout);
588 CEikStatusPaneLayout* iLayout;
590 typedef CArrayPtrFlat<CIdLayoutPair> CLayoutIdSet;
591 typedef CArrayFixFlat<TInt> CIdSet;
597 * @param aEikEnv An environment for creating controls.
599 IMPORT_C CEikStatusPaneModelBase(CEikonEnv& aEikEnv);
602 * Base constructor for 2nd phase construction.
603 * @param aCoreResId Status pane core resource id.
605 IMPORT_C void BaseConstructL(TInt aCoreResId);
608 * Loads given layout from resource.
609 * @param aLayoutResId Layout resource id.
611 IMPORT_C CEikStatusPaneLayout* LoadLayoutL(TInt aLayoutResId);
614 * Returns set of legal layout ids.
615 * @return Set of allowed status pane layout ids.
617 inline CIdSet* LegalIds() const;
620 * Checks if given layout id is allowed.
621 * @param aLayoutResId Layout id to be checked.
622 * @return ETrue if given layout id is allowed.
624 TBool IsLegalId(TInt aLayoutResId) const;
629 * @param aLayoutResId Layout resource id.
631 CEikStatusPaneLayout* Layout(TInt aLayoutResId);
634 * Checks given layout.
635 * @param aLayout Layout to be checked.
637 void CheckLayoutL(CEikStatusPaneLayout* aLayout);
640 IMPORT_C virtual void Reserved_1();
643 NONSHARABLE_CLASS(TLayoutChecker) : public MEikStatusPaneLayoutTreeVisitor
646 TLayoutChecker(CEikStatusPaneSetInit* aPanes);
647 void VisitL(CEikStatusPaneLayoutTree* aNode);
649 CEikStatusPaneSetInit* iPanes;
653 CLayoutIdSet* iLayouts;
658 CEikStatusPaneSetInit* iPanes;
659 CEikStatusPaneLayout* iCurrentLayout;
666 * Status pane model for application status pane.
669 NONSHARABLE_CLASS(CEikAppStatusPaneModel) : public CEikStatusPaneModelBase
673 * Two phase constructor.
675 * @param aEikEnv An environment for creating controls.
676 * @param aCoreResId Status pane core resource id
677 * @param aAppResId Application status pane resource id
678 * @param aChangeStatusPaneNow A flag to indicate immediate status pane layout change.
679 * @return Constructed instance.
681 static CEikAppStatusPaneModel* NewL(CEikonEnv& aEikEnv, /*REikSrvSession,*/ TInt aCoreResId, TInt aAppResId = EEikStatusPaneUseDefaults, TBool aChangeStatusPaneNow = ETrue);
686 ~CEikAppStatusPaneModel();
689 * Takes current layout into use.
691 void ApplyCurrentLayoutL();
695 * from CEikStatusPaneModelBase
697 void SetLayoutL(TInt aLayoutResId, TBool aChangeStatusPaneNow = ETrue);
700 * from CEikStatusPaneModelBase
702 void SetLayoutL(TInt aLayoutResId, TBool aChangeStatusPaneNow, TBool aNotfiyServerSide);
705 CEikAppStatusPaneModel(CEikonEnv& aEikEnv);
706 void ConstructL(TInt aCoreResId, TInt aAppResId, TBool aChangeStatusPaneNow = ETrue);
710 inline TPaneId TEikStatusPaneInit::Id() const { return iId; }
711 inline TBool TEikStatusPaneInit::AppOwned() const { return iFlags & EEikStatusPaneAppOwned; }
712 inline TInt TEikStatusPaneInit::ControlTypeId() const { return iControlId; }
713 inline TInt TEikStatusPaneInit::ControlResourceId() const { return iControlResource; }
714 inline void TEikStatusPaneInit::SetHidden() {iFlags|=KEikStatusPaneHiddenBit;}
715 inline void TEikStatusPaneInit::ClearHidden() {iFlags&=~KEikStatusPaneHiddenBit;}
716 inline TBool TEikStatusPaneInit::IsHidden() const {return iFlags&KEikStatusPaneHiddenBit;}
718 inline CEikStatusPaneLayoutTree* CEikStatusPaneLayout::Find(const TPaneId& aPaneId) const { return iRoot->Find(aPaneId); }
719 inline void CEikStatusPaneLayout::AcceptL(MEikStatusPaneLayoutTreeVisitor* aVisitor) { iRoot->AcceptL(aVisitor); }
720 inline TRect CEikStatusPaneLayout::Rect() const { return iRoot->Rect(); }
722 inline TPaneId CEikStatusPaneLayoutTree::Id() const { return iId; }
723 inline TRect CEikStatusPaneLayoutTree::Rect() const { return iRect; }
726 inline CEikStatusPaneSetInit* CEikStatusPaneModelBase::PaneInits() const { return iPanes; }
727 inline CEikStatusPaneLayout* CEikStatusPaneModelBase::CurrentLayout() const { return iCurrentLayout; }
728 inline CEikStatusPaneModelBase::CIdSet* CEikStatusPaneModelBase::LegalIds() const { return iLegalIds; }