uifw/EikStd/coctlsrc/eikspane.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  EIKON Status Pane control.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDE FILES
       
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    21 #include <uikon/eikdefmacros.h>
       
    22 #endif
       
    23 #include <barsread.h>
       
    24 #include <eikspane.h>
       
    25 #include <coeccntx.h>
       
    26 #include <aknappui.h>
       
    27 #include <eikenv.h>
       
    28 #include <uiklaf/private/lafspane.h>
       
    29 #include <AknSgcc.h>
       
    30 #include <AknUtils.h>
       
    31 #include <AknStatuspaneUtils.h>
       
    32 #include <AknsCombinedBackgroundControlContext.h>
       
    33 #include <AknsMaskedLayerBackgroundControlContext.h>
       
    34 #include <eikapp.h>
       
    35 
       
    36 #include <coecntrl.h>
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <layoutmetadata.cdl.h>
       
    39 #include <AknsDrawUtils.h>
       
    40 #include "aknstatuspanedatasubscriber.h"
       
    41 
       
    42 #ifdef RD_SCALABLE_UI_V2
       
    43 #include <akntouchpane.h>
       
    44 #endif // RD_SCALABLE_UI_V2
       
    45 
       
    46 #include <pslninternalcrkeys.h>
       
    47 #include <centralrepository.h>
       
    48 #include <akntranseffect.h>
       
    49 
       
    50 #include <AknTasHook.h>
       
    51 /** Granularity of the sub-pane control array. */
       
    52 const TInt KEikStatusPaneControlGranularity = 4;
       
    53 
       
    54 /** Fading is no longer handled here. */
       
    55 // const TInt KEikStatusPaneBaseFadedBit    = 1;
       
    56 
       
    57 /** Flag indicating status pane visibility. */
       
    58 const TInt KEikStatusPaneBaseVisibleBit     = 2;
       
    59 
       
    60 /** Flag indicating status pane dimming state. */
       
    61 const TInt KEikStatusPaneBaseDimmedBit      = 4;
       
    62 
       
    63 /** Unique UID for status pane TLS singleton. */
       
    64 const TUid KUidStatusPaneTls = { 0x10005FB5 };
       
    65 
       
    66 /** Default timeout for status pane blanker. */
       
    67 const TInt KDefaultUnblankTimeout = 100000; // 0.1 s
       
    68 
       
    69 /** This flag is used to turn redraw storing on/off in status pane. */
       
    70 const TInt KEnableRedrawStoring = ETrue;
       
    71 
       
    72 const TUid KActiveIdle2Uid = {0x102750F0};
       
    73 
       
    74 inline void CEikStatusPaneBase::TPaneCapabilities::SetPresent()
       
    75     {
       
    76     iFlags |= KStatusPaneCapsPresentBit;
       
    77     }
       
    78 
       
    79 inline void CEikStatusPaneBase::TPaneCapabilities::SetAppOwned()
       
    80     {
       
    81     iFlags |= KStatusPaneCapsAppOwnedBit;
       
    82     }
       
    83 
       
    84 inline void CEikStatusPaneBase::TPaneCapabilities::SetInCurrentLayout()
       
    85     {
       
    86     iFlags |= KStatusPaneCapsInCurrentLayoutBit;
       
    87     }
       
    88 
       
    89 #ifdef RD_FULLSCREEN_WALLPAPER
       
    90 
       
    91 /**
       
    92 * Skin background context layers used in usual status pane layouts.
       
    93 */
       
    94 enum
       
    95     {
       
    96     ELayerWallpaper  = 0,
       
    97     ELayerBackground = 1,
       
    98     ELayerExtension  = 2,
       
    99     ELayerStripe     = 3,
       
   100     ELayerN          = 4
       
   101     };
       
   102 
       
   103 /**
       
   104 * Skin background layers for first context used in stacon pane layouts.
       
   105 */
       
   106 enum
       
   107     {
       
   108     ELayerStaconWallpaper = 0,
       
   109     ELayerStaconTop       = 1,
       
   110     ELayerStaconBottom    = 2,
       
   111     ELayerStaconN         = 3
       
   112     };
       
   113 
       
   114 /**
       
   115 * Skin background layers for second context used in stacon pane layouts.
       
   116 */
       
   117 enum
       
   118     {
       
   119     ELayerStaconWp   = 0,
       
   120     ELayerStaconSkin = 1
       
   121     };
       
   122 
       
   123 /**
       
   124 * Skin background layers for second context used in flat status pane layouts.
       
   125 */
       
   126 enum
       
   127     {
       
   128     ELayerFlatCbaWp   = 0,
       
   129     ELaterFlatCbaSkin = 1
       
   130     };
       
   131 
       
   132 /**
       
   133 * Skin background layers for first context used in flat status pane layouts.
       
   134 */
       
   135 enum
       
   136     {
       
   137     ELayerFlatWallpaper  = 0,
       
   138     ELayerFlatBackground = 1,
       
   139     ELayerFlatTl         = 2,
       
   140     ELayerFlatTr         = 3,
       
   141     ELayerFlatBl         = 4,
       
   142     ELayerFlatBr         = 5,
       
   143     ELayerFlatT          = 6,
       
   144     ELayerFlatB          = 7,
       
   145     ELayerFlatR          = 8,
       
   146     ELayerFlatL          = 9,
       
   147     ELayerFlatCenter     = 10,
       
   148     ELayerFlatMain       = 11,
       
   149     ELayerFlatCba        = 12,
       
   150     ELayerFlatN          = 13
       
   151     };
       
   152 
       
   153 #else
       
   154 
       
   155 /**
       
   156 * Skin background context layers used in usual status pane layouts.
       
   157 */
       
   158 enum
       
   159     {
       
   160     ELayerBackground = 0,
       
   161     ELayerExtension  = 1,
       
   162     ELayerStripe     = 2,
       
   163     ELayerWallpaper  = 3,
       
   164     ELayerN          = 4
       
   165     };
       
   166 
       
   167 /**
       
   168 * Skin background context layers used in stacon pane layouts.
       
   169 */
       
   170 enum
       
   171     {
       
   172     ELayerStaconTop       = 0,
       
   173     ELayerStaconBottom    = 1,
       
   174     ELayerStaconMain      = 2,
       
   175     ELayerStaconWallpaper = 3,
       
   176     ELayerStaconN         = 4
       
   177     };
       
   178 
       
   179 /**
       
   180 * Skin background context layers used in flat status pane layouts.
       
   181 */
       
   182 enum
       
   183     {
       
   184     ELayerFlatBackground = 0,
       
   185     ELayerFlatTl         = 1,
       
   186     ELayerFlatTr         = 2,
       
   187     ELayerFlatBl         = 3,
       
   188     ELayerFlatBr         = 4,
       
   189     ELayerFlatT          = 5,
       
   190     ELayerFlatB          = 6,
       
   191     ELayerFlatR          = 7,
       
   192     ELayerFlatL          = 8,
       
   193     ELayerFlatCenter     = 9,
       
   194     ELayerFlatMain       = 10,
       
   195     ELayerFlatWallpaper  = 11,
       
   196     ELayerFlatCba        = 12,
       
   197     ELayerFlatN          = 13
       
   198     };
       
   199 
       
   200 #endif // RD_FULLSCREEN_WALLPAPER
       
   201 
       
   202 /**
       
   203 * Status pane blanker disable levels.
       
   204 * As of release 3.2 status pane blanker is not used anymore.
       
   205 */
       
   206 enum
       
   207     {
       
   208     EBlankDisableLevelNone   = 0, ///< Blanker is enabled.
       
   209     EBlankDisableLevelNormal = 1, ///< Blanker is disabled, but may be used in some situations.
       
   210     EBlankDisableLevelHigh   = 2  ///< Blanker is always disabled.
       
   211     };
       
   212 
       
   213 /** Resource IDs for portrait mode status pane layouts. */
       
   214 const TInt KStatusPanePortraitResIds[] =
       
   215     {
       
   216     R_AVKON_STATUS_PANE_LAYOUT_IDLE,
       
   217     R_AVKON_STATUS_PANE_LAYOUT_USUAL,
       
   218     R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE,
       
   219     R_AVKON_STATUS_PANE_LAYOUT_EMPTY,
       
   220     R_AVKON_STATUS_PANE_LAYOUT_SMALL,
       
   221     R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE,
       
   222     R_AVKON_STATUS_PANE_LAYOUT_VT,
       
   223     R_AVKON_STATUS_PANE_LAYOUT_USUAL_MIRRORED,
       
   224     R_AVKON_STATUS_PANE_LAYOUT_IDLE_MIRRORED,
       
   225     R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE_MIRRORED,
       
   226     R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE_MIRRORED,
       
   227     R_AVKON_STATUS_PANE_LAYOUT_VT_MIRRORED,
       
   228     R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT,
       
   229     R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT,
       
   230     R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT,
       
   231     R_AVKON_STATUS_PANE_LAYOUT_IDLE_EXT,
       
   232     R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS
       
   233     };
       
   234 
       
   235 /** Resource IDs for landscape mode status pane layouts. */
       
   236 const TInt KStatusPaneLandscapeResIds[] =
       
   237     {
       
   238     R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE,
       
   239     R_AVKON_STATUS_PANE_LAYOUT_EMPTY,
       
   240     R_AVKON_STATUS_PANE_LAYOUT_SMALL,
       
   241     R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE,
       
   242     R_AVKON_STATUS_PANE_LAYOUT_VT,
       
   243     R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE_MIRRORED,
       
   244     R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE_MIRRORED,
       
   245     R_AVKON_STATUS_PANE_LAYOUT_VT_MIRRORED,
       
   246     R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT,
       
   247     R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT,
       
   248     R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT,
       
   249     R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT,
       
   250     R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT,
       
   251     R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT,
       
   252     R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT,
       
   253     R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT,
       
   254     R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL,
       
   255     R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE,
       
   256     R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT,
       
   257     R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT,
       
   258     R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT_NO_SOFTKEYS,
       
   259     R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS
       
   260     };
       
   261 
       
   262 
       
   263 // ======== LOCAL FUNCTIONS ========
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // Checks if a specified status pane layout is supported in portrait.
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 static TBool SupportedPortraitResId( TInt aResId )
       
   270     {
       
   271     for ( TUint ii = 0;
       
   272           ii < sizeof( KStatusPanePortraitResIds ) /
       
   273                sizeof( *KStatusPanePortraitResIds );
       
   274           ii++ )
       
   275         {
       
   276         if ( KStatusPanePortraitResIds[ii] == aResId )
       
   277             {
       
   278             return ETrue;
       
   279             }
       
   280         }
       
   281 	return EFalse;
       
   282 	}
       
   283 
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // Checks if a specified status pane layout is supported in landscape.
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 static TBool SupportedLandscapeResId( TInt aResId )
       
   290 	{
       
   291     for ( TUint ii = 0;
       
   292           ii < sizeof( KStatusPaneLandscapeResIds ) /
       
   293                sizeof( *KStatusPaneLandscapeResIds );
       
   294           ii++ )
       
   295         {
       
   296         if ( KStatusPaneLandscapeResIds[ii] == aResId )
       
   297             {
       
   298             return ETrue;
       
   299             }
       
   300         }
       
   301 	return EFalse;
       
   302 	}
       
   303 
       
   304 
       
   305 // ---------------------------------------------------------------------------
       
   306 // Helper method to compose two layout lines together.
       
   307 // ---------------------------------------------------------------------------
       
   308 //
       
   309 inline TAknWindowComponentLayout DoCompose( TAknWindowComponentLayout aLine1,
       
   310                                             TAknWindowComponentLayout aLine2 )
       
   311     {
       
   312     return TAknWindowComponentLayout::Compose( aLine1, aLine2 );
       
   313     }
       
   314 
       
   315 
       
   316 /**
       
   317  * Interface for key - value pair getter.
       
   318  */
       
   319 NONSHARABLE_CLASS( MKeyValue )
       
   320 	{
       
   321 public:
       
   322 
       
   323     /**
       
   324     * Return CR key ID.
       
   325     */
       
   326 	virtual TUint32 Key() const = 0;
       
   327 
       
   328 	/**
       
   329     * Return CR key value.
       
   330     */
       
   331 	virtual TInt Value() const = 0;
       
   332 	};
       
   333 
       
   334 /**
       
   335  * Interface for a key change listener.
       
   336  */
       
   337 NONSHARABLE_CLASS( MKeyListener )
       
   338 	{
       
   339 public:
       
   340 
       
   341     /**
       
   342     * Called when a value of a key changes.
       
   343     */
       
   344 	virtual void KeyChanged( const MKeyValue& aKeyValue ) = 0;
       
   345 	};
       
   346 
       
   347 /**
       
   348  * Class for observing changes in Central Repository properties.
       
   349  */
       
   350 NONSHARABLE_CLASS( CCenRepListen ) : public CActive, public MKeyValue
       
   351 	{
       
   352 public:
       
   353 
       
   354     /**
       
   355     * Two-phased constructor.
       
   356     *
       
   357     * @param  aRep       UID of the repository.
       
   358     * @param  aKey       ID  of the key inside the repository.
       
   359     * @param  aListener  Listener to be informed of changes.
       
   360     */
       
   361 	static CCenRepListen* NewL( const TUid& aRep,
       
   362 	                            const TUint32 aKey,
       
   363 	                            MKeyListener& aListener );
       
   364 
       
   365     /**
       
   366     * Returns the current value of a CR key.
       
   367     *
       
   368     * @return Value of the key.
       
   369     */
       
   370 	TInt Value() const;
       
   371 
       
   372 	/**
       
   373     * Returns the ID of a CR key that is being listened to.
       
   374     *
       
   375     * @return ID of a CR key.
       
   376     */
       
   377 	TUint32 Key() const;
       
   378 
       
   379 	/**
       
   380 	* Starts listening to the CR key.
       
   381 	*/
       
   382 	void Listen();
       
   383 
       
   384 	/**
       
   385 	* Destructor.
       
   386 	*/
       
   387 	~CCenRepListen();
       
   388 
       
   389 private:
       
   390 
       
   391     /**
       
   392     * C++ constructor.
       
   393     *
       
   394     * @param  aKey       ID  of the key inside the repository.
       
   395     * @param  aListener  Listener to be informed of changes.
       
   396     */
       
   397 	CCenRepListen( const TUint32 aKey, MKeyListener& aListener );
       
   398 
       
   399 	/**
       
   400 	* Second-phase constructor.
       
   401 	*
       
   402 	* @param  aRep  UID of the repository.
       
   403 	*/
       
   404 	void ConstructL( const TUid& aRep );
       
   405 
       
   406 	/**
       
   407 	* Cancels listening.
       
   408 	*/
       
   409 	void DoCancel();
       
   410 
       
   411 	/**
       
   412 	* Called when the key value is changed.
       
   413 	*/
       
   414 	void RunL();
       
   415 
       
   416 private:
       
   417 
       
   418     /** ID of the key being listened to. */
       
   419 	const TUint32   iKey;
       
   420 
       
   421 	/** Listener to be informed of changes. */
       
   422 	MKeyListener&   iListener;
       
   423 
       
   424 	/** Current value of the key. */
       
   425 	TInt            iValue;
       
   426 
       
   427 	/** Pointer to a repository. */
       
   428 	CRepository*    iRepository;
       
   429 	};
       
   430 
       
   431 
       
   432 // ---------------------------------------------------------------------------
       
   433 // CCenRepListen::NewL
       
   434 // Two-phased constructor.
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 CCenRepListen* CCenRepListen::NewL( const TUid& aRep,
       
   438                                     const TUint32 aKey,
       
   439                                     MKeyListener& aListener )
       
   440 	{
       
   441 	CCenRepListen* l = new (ELeave) CCenRepListen( aKey, aListener );
       
   442 	CleanupStack::PushL( l );
       
   443 	l->ConstructL( aRep );
       
   444     CleanupStack::Pop( l );
       
   445 	return l;
       
   446 	}
       
   447 
       
   448 
       
   449 // ---------------------------------------------------------------------------
       
   450 // CCenRepListen::Value
       
   451 // Returns the current value of the key.
       
   452 // ---------------------------------------------------------------------------
       
   453 //
       
   454 TInt CCenRepListen::Value() const
       
   455 	{
       
   456 	return iValue;
       
   457 	}
       
   458 
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CCenRepListen::Value
       
   462 // Returns the key being listened to.
       
   463 // ---------------------------------------------------------------------------
       
   464 //
       
   465 TUint32 CCenRepListen::Key() const
       
   466 	{
       
   467 	return iKey;
       
   468 	}
       
   469 
       
   470 
       
   471 // ---------------------------------------------------------------------------
       
   472 // CCenRepListen::Listen
       
   473 // Starts listening to a value changes.
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 void CCenRepListen::Listen()
       
   477 	{
       
   478 	Cancel();
       
   479 	SetActive();
       
   480 	iRepository->NotifyRequest( iKey, iStatus );
       
   481 	}
       
   482 
       
   483 // ---------------------------------------------------------------------------
       
   484 // CCenRepListen::CCenRepListen
       
   485 // C++ constructor
       
   486 // ---------------------------------------------------------------------------
       
   487 //
       
   488 CCenRepListen::CCenRepListen( const TUint32 aKey,
       
   489                               MKeyListener& aListener )
       
   490     : CActive( CActive::EPriorityStandard ),
       
   491       iKey( aKey ),
       
   492       iListener( aListener )
       
   493 	{
       
   494 	CActiveScheduler::Add( this );
       
   495 	}
       
   496 
       
   497 
       
   498 // ---------------------------------------------------------------------------
       
   499 // CCenRepListen::ConstructL
       
   500 // Second-phase constructor.
       
   501 // ---------------------------------------------------------------------------
       
   502 //
       
   503 void CCenRepListen::ConstructL( const TUid& aRep )
       
   504 	{
       
   505 	iRepository = CRepository::NewL( aRep );
       
   506 	User::LeaveIfError( iRepository->Get( iKey, iValue ) );
       
   507 	}
       
   508 
       
   509 
       
   510 // ---------------------------------------------------------------------------
       
   511 // CCenRepListen::DoCancel
       
   512 // Cancels listening.
       
   513 // ---------------------------------------------------------------------------
       
   514 //
       
   515 void CCenRepListen::DoCancel()
       
   516 	{
       
   517 	iRepository->NotifyCancelAll();
       
   518 	}
       
   519 
       
   520 
       
   521 // ---------------------------------------------------------------------------
       
   522 // CCenRepListen::RunL
       
   523 // Called when the key value changes.
       
   524 // ---------------------------------------------------------------------------
       
   525 //
       
   526 void CCenRepListen::RunL()
       
   527 	{
       
   528 	User::LeaveIfError( iRepository->Get( iKey, iValue ) );
       
   529 	iListener.KeyChanged( *this );
       
   530 	}
       
   531 
       
   532 
       
   533 // ---------------------------------------------------------------------------
       
   534 // CCenRepListen::~CCenRepListen
       
   535 // Destructor.
       
   536 // ---------------------------------------------------------------------------
       
   537 //
       
   538 CCenRepListen::~CCenRepListen()
       
   539 	{
       
   540 	Cancel();
       
   541 	delete iRepository;
       
   542 	}
       
   543 
       
   544 
       
   545 /**
       
   546  * Helper class for setting the state of redraw storing.
       
   547  */
       
   548 NONSHARABLE_CLASS( CRedrawStoreHandler ) : public CBase, public MKeyListener
       
   549 	{
       
   550 public:
       
   551 
       
   552     /**
       
   553     * Destructor.
       
   554     */
       
   555 	~CRedrawStoreHandler();
       
   556 
       
   557 	/**
       
   558 	* Second-phase constructor.
       
   559 	*/
       
   560 	void ConstructL();
       
   561 
       
   562 	/**
       
   563 	* Sets the redraw storing on/off for a specified window.
       
   564 	*/
       
   565 	void SetStore( RWindow* aWindow, TBool aOn );
       
   566 
       
   567 private: // From base class @c MKeyListener.
       
   568 
       
   569     /**
       
   570     * Handles changes in the observer CR key value.
       
   571     */
       
   572 	void KeyChanged( const MKeyValue& aKeyValue );
       
   573 
       
   574 private:
       
   575 
       
   576     /** Pointer to the window whose redraw storing state is controlled. */
       
   577 	RWindow* iWindow;
       
   578 
       
   579 	/** CR key change listener. */
       
   580 	CCenRepListen* iListen;
       
   581 
       
   582 	/** Set state of the redraw storing. */
       
   583 	TBool iStoreValue;
       
   584 	};
       
   585 
       
   586 
       
   587 // ---------------------------------------------------------------------------
       
   588 // CRedrawStoreHandler::~CRedrawStoreHandler
       
   589 // Destructor.
       
   590 // ---------------------------------------------------------------------------
       
   591 //
       
   592 CRedrawStoreHandler::~CRedrawStoreHandler()
       
   593 	{
       
   594 	delete iListen;
       
   595 	}
       
   596 
       
   597 
       
   598 // ---------------------------------------------------------------------------
       
   599 // CRedrawStoreHandler::ConstructL
       
   600 // Second-phase constructor.
       
   601 // ---------------------------------------------------------------------------
       
   602 //
       
   603 void CRedrawStoreHandler::ConstructL()
       
   604 	{
       
   605     if ( !CAknEnv::Static()->TransparencyEnabled() )
       
   606         {
       
   607 	iListen = CCenRepListen::NewL( KCRUidThemes,
       
   608 	                               KThemesTransitionEffects,
       
   609 	                               *this );
       
   610 	iListen->Listen();
       
   611         }
       
   612 
       
   613 	}
       
   614 
       
   615 
       
   616 // ---------------------------------------------------------------------------
       
   617 // CRedrawStoreHandler::SetStore
       
   618 // Sets the redraw storing on/off for a specified window.
       
   619 // ---------------------------------------------------------------------------
       
   620 //
       
   621 void CRedrawStoreHandler::SetStore( RWindow* aWindow, TBool aOn )
       
   622 	{
       
   623     if ( !CAknEnv::Static()->TransparencyEnabled() )
       
   624         {
       
   625 	    iWindow     = aWindow;
       
   626 	    iStoreValue = aOn;
       
   627 
       
   628 	    if ( aOn )
       
   629 		    {
       
   630 		    KeyChanged( *iListen );
       
   631 		    }
       
   632 	    else
       
   633 		    {
       
   634 		    iWindow->EnableRedrawStore( EFalse );
       
   635 		    }
       
   636         }
       
   637 	}
       
   638 
       
   639 
       
   640 // ---------------------------------------------------------------------------
       
   641 // CRedrawStoreHandler::KeyChanged
       
   642 // Disables redraw storing if fullscreen transition effects are set on.
       
   643 // ---------------------------------------------------------------------------
       
   644 //
       
   645 void CRedrawStoreHandler::KeyChanged( const MKeyValue& aKeyValue )
       
   646 	{
       
   647 	if ( iWindow && aKeyValue.Key() == KThemesTransitionEffects )
       
   648 		{
       
   649 		const TBool fullScreen =
       
   650 		    !aKeyValue.Value() & AknTransEffect::EFullScreenTransitionsOff;
       
   651 		if ( iStoreValue )
       
   652 			{
       
   653 			iWindow->EnableRedrawStore( !fullScreen );
       
   654 			}
       
   655 		iListen->Listen();
       
   656 		}
       
   657 
       
   658 	}
       
   659 
       
   660 
       
   661 /**
       
   662  * This class is used for drawing a empty (blank) statuspane background.
       
   663  */
       
   664 NONSHARABLE_CLASS( CAknStatuspaneClearer ) : public CAknControl
       
   665 	{
       
   666 public:
       
   667 
       
   668     /**
       
   669     * Two-phased constructor.
       
   670     */
       
   671     static CAknStatuspaneClearer* NewLC( RWindowGroup& aParent,
       
   672                                          TInt aStatuspaneLayoutId,
       
   673                                          TBool aOwnWindowGroup );
       
   674 
       
   675     /**
       
   676     * Two-phased constructor.
       
   677     */
       
   678 	static CAknStatuspaneClearer* NewL( RWindowGroup& aParent,
       
   679 	                                    TInt aStatuspaneLayoutId,
       
   680 	                                    TBool aOwnWindowGroup );
       
   681 
       
   682     /**
       
   683     * Sets blank window shape to same as statuspanes shape.
       
   684     */
       
   685     void SetDefaultShape();
       
   686 
       
   687     /**
       
   688     * Sets blank window shape to given shape.
       
   689     */
       
   690     void SetShape( TRegion& aRegion );
       
   691 
       
   692     /**
       
   693     * Sets blank window skin backgound to match given statuspane layout.
       
   694     */
       
   695     void SetSkinBackgroundContext( TInt aStatuspaneLayoutId,
       
   696                                    TBool aDrawNavi = ETrue );
       
   697 
       
   698     /**
       
   699     * Enables blank functionality. If this has been called, then calls
       
   700     * to method Blank() works normally.
       
   701     */
       
   702     void EnableBlank();
       
   703 
       
   704     /**
       
   705     * Disables blank functionality. If this has been called, then calls
       
   706     * to method Blank() does nothing.
       
   707     */
       
   708     void DisableBlank( TInt aDisableLevel );
       
   709 
       
   710     /**
       
   711     * Tells if blank functionality has been disabled
       
   712     */
       
   713     TInt BlankDisabled();
       
   714 
       
   715     /**
       
   716     * Draws blank statuspane background using previously set shape and
       
   717     * skin background and makes blank window visible.
       
   718     */
       
   719     void Blank();
       
   720 
       
   721     /**
       
   722     * Draws blank statuspane background using previously set shape and
       
   723     * skin background. Unblanks window automatically after aUnblankTimeout
       
   724     * time (in milliseconds).
       
   725     */
       
   726     void Blank( TInt aUnblankTimeout );
       
   727 
       
   728     /**
       
   729     * Tells wheter Blank() has been called but Unblank() has not yet been
       
   730     * called.
       
   731     */
       
   732     TBool IsBlank();
       
   733 
       
   734     /**
       
   735     * Makes blank window not visible.
       
   736     */
       
   737     void UnBlank();
       
   738 
       
   739     /**
       
   740     * Sets blank window ordinal position.
       
   741     */
       
   742 	void SetOrdinalPosition( TInt aPosition );
       
   743 
       
   744     /**
       
   745     * Destructor.
       
   746     */
       
   747 	virtual ~CAknStatuspaneClearer();
       
   748 
       
   749 private:
       
   750 
       
   751     /**
       
   752     * Private construction function.
       
   753     */
       
   754 	void ConstructL( RWindowGroup& aParent,
       
   755 	                 TInt aStatuspaneLayoutId,
       
   756 	                 TBool aOwnWindowGroup );
       
   757 
       
   758     /**
       
   759     * Starts timer.
       
   760     */
       
   761     void InitTimer( TInt aDelay, TInt aInterval );
       
   762 
       
   763     /**
       
   764     * Cancels timer.
       
   765     */
       
   766     void CancelTimer();
       
   767 
       
   768     /**
       
   769     * Static timer callback.
       
   770     */
       
   771     static TInt TimerEvent( TAny* aPtr );
       
   772 
       
   773     /**
       
   774     * Timer callback.
       
   775     */
       
   776     void DoTimerEvent();
       
   777 
       
   778 private:	// From base class @c CCoeControl.
       
   779 
       
   780 	void Draw( const TRect& aRect ) const;
       
   781 
       
   782 private:
       
   783 
       
   784     /** Timer for automatic unblanking. */
       
   785     CPeriodic* iUnblankTimer;
       
   786 
       
   787     /**
       
   788     * Statuspane layout ID which is used to decide what
       
   789     * kind of skin background is drawn.
       
   790     */
       
   791     TInt iStatuspaneLayoutId;
       
   792 
       
   793     /** A flag to temporarily disable blanking functionality. */
       
   794     TInt iBlankDisableLevel;
       
   795 
       
   796     /** Skin background context. */
       
   797     CAknsMaskedLayerBackgroundControlContext* iBgContext;
       
   798 
       
   799     /**
       
   800     * Parent window group.
       
   801     * Own if iOwnWindowGroup is ETrue.
       
   802     */
       
   803 	RWindowGroup* iParent;
       
   804 
       
   805 	/**
       
   806 	* A flag indicating whether or not blanker owns it's window group.
       
   807 	*/
       
   808 	TBool iOwnWindowGroup;
       
   809 	};
       
   810 
       
   811 
       
   812 /**
       
   813  * Delayed foreground state observer class.
       
   814  * Used by the status pane in situations where the state of redraw storing
       
   815  * needs to be changed when foreground state changes, but it cannot be
       
   816  * done at the moment when the foreground event is received.
       
   817  */
       
   818 NONSHARABLE_CLASS( CAknDelayedForegroundObserver ) : public CBase
       
   819 	{
       
   820 public:
       
   821 
       
   822     /**
       
   823     * Two-phased constructor.
       
   824     */
       
   825 	static CAknDelayedForegroundObserver* NewLC(
       
   826 	    MCoeForegroundObserver* aObserver );
       
   827 
       
   828     /**
       
   829     * Two-phased constructor.
       
   830     */
       
   831 	static CAknDelayedForegroundObserver* NewL(
       
   832 	    MCoeForegroundObserver* aObserver );
       
   833 
       
   834     /**
       
   835     * Destructor.
       
   836     */
       
   837 	virtual ~CAknDelayedForegroundObserver();
       
   838 
       
   839     /**
       
   840     * Starts delay, after delay MCoeForegroundObserver::HandleGainingForeground
       
   841     * is called. This is repeated aNumberOfRepeats of times.
       
   842     */
       
   843     void StartDelayedForegroundGainObservation( TInt aDelay,
       
   844                                                 TInt aNumberOfRepeats );
       
   845 
       
   846     /**
       
   847     * Starts delay, after delay MCoeForegroundObserver::HandleLosingForeground
       
   848     * is called. This is repeated aNumberOfRepeats of times.
       
   849     */
       
   850     void StartDelayedForegroundLossObservation( TInt aDelay,
       
   851                                                 TInt aNumberOfRepeats );
       
   852 
       
   853     /**
       
   854     * Stops delayed observation timer.
       
   855     */
       
   856     void StopDelayedObservation();
       
   857 
       
   858     /**
       
   859     * Tells if a call to MCoeForegroundObserver interface has been
       
   860     * called but the call has not yet returned.
       
   861     */
       
   862 	TBool IsDelayedCallbackActive();
       
   863 
       
   864 private:
       
   865 
       
   866     /**
       
   867     * Private construction function.
       
   868     */
       
   869 	void ConstructL( MCoeForegroundObserver* aObserver );
       
   870 
       
   871     /**
       
   872     * Starts timer.
       
   873     */
       
   874     void InitTimer( TInt aDelay, TInt aInterval );
       
   875 
       
   876     /**
       
   877     * Cancels timer.
       
   878     */
       
   879     void CancelTimer();
       
   880 
       
   881     /**
       
   882     * Static timer callback.
       
   883     */
       
   884     static TInt TimerEvent( TAny* aPtr );
       
   885 
       
   886     /**
       
   887     * Timer callback.
       
   888     */
       
   889     void DoTimerEvent();
       
   890 
       
   891 private:
       
   892 
       
   893     CPeriodic* iTimer;
       
   894 	MCoeForegroundObserver* iObserver;
       
   895 	TBool iForegroundLossObserverved;
       
   896 	TBool iDelayedCallbackActive;
       
   897 	TInt  iNumberOfRepeats;
       
   898 	};
       
   899 
       
   900 
       
   901 
       
   902 // ---------------------------------------------------------------------------
       
   903 // CAknDelayedForegroundObserver::NewLC
       
   904 // Two-phased constructor.
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 CAknDelayedForegroundObserver* CAknDelayedForegroundObserver::NewLC(
       
   908     MCoeForegroundObserver* aObserver )
       
   909 	{
       
   910 	CAknDelayedForegroundObserver* self =
       
   911 	    new (ELeave) CAknDelayedForegroundObserver;
       
   912 	CleanupStack::PushL( self );
       
   913 	self->ConstructL( aObserver );
       
   914 	return self;
       
   915 	}
       
   916 
       
   917 
       
   918 // ---------------------------------------------------------------------------
       
   919 // CAknDelayedForegroundObserver::NewL
       
   920 // Two-phased constructor.
       
   921 // ---------------------------------------------------------------------------
       
   922 //
       
   923 CAknDelayedForegroundObserver* CAknDelayedForegroundObserver::NewL(
       
   924     MCoeForegroundObserver* aObserver )
       
   925 	{
       
   926 	CAknDelayedForegroundObserver* self =
       
   927 	    CAknDelayedForegroundObserver::NewLC( aObserver );
       
   928 	CleanupStack::Pop( self );
       
   929 	return self;
       
   930 	}
       
   931 
       
   932 
       
   933 // ---------------------------------------------------------------------------
       
   934 // CAknDelayedForegroundObserver::ConstructL
       
   935 // Second-phase constructor.
       
   936 // ---------------------------------------------------------------------------
       
   937 //
       
   938 void CAknDelayedForegroundObserver::ConstructL(
       
   939     MCoeForegroundObserver* aObserver )
       
   940 	{
       
   941 	iObserver = aObserver;
       
   942    	iTimer    = CPeriodic::NewL( CActive::EPriorityStandard );
       
   943 	}
       
   944 
       
   945 
       
   946 // ---------------------------------------------------------------------------
       
   947 // CAknDelayedForegroundObserver::~CAknDelayedForegroundObserver
       
   948 // Destructor.
       
   949 // ---------------------------------------------------------------------------
       
   950 //
       
   951 CAknDelayedForegroundObserver::~CAknDelayedForegroundObserver()
       
   952 	{
       
   953     if ( iTimer )
       
   954     	{
       
   955    	    iTimer->Cancel();
       
   956         delete iTimer;
       
   957     	}
       
   958 	}
       
   959 
       
   960 
       
   961 // ---------------------------------------------------------------------------
       
   962 // CAknDelayedForegroundObserver::StartDelayedForegroundGainObservation
       
   963 // Starts delayed observation of foreground gain.
       
   964 // ---------------------------------------------------------------------------
       
   965 //
       
   966 void CAknDelayedForegroundObserver::StartDelayedForegroundGainObservation(
       
   967     TInt aDelay, TInt aNumberOfRepeats )
       
   968 	{
       
   969 	CancelTimer();
       
   970 	iNumberOfRepeats           = aNumberOfRepeats;
       
   971 	iForegroundLossObserverved = EFalse;
       
   972 	InitTimer( aDelay, aDelay );
       
   973 	}
       
   974 
       
   975 
       
   976 // ---------------------------------------------------------------------------
       
   977 // CAknDelayedForegroundObserver::StartDelayedForegroundLossObservation
       
   978 // Starts delayed observation of foreground loss.
       
   979 // ---------------------------------------------------------------------------
       
   980 //
       
   981 void CAknDelayedForegroundObserver::StartDelayedForegroundLossObservation(
       
   982     TInt aDelay, TInt aNumberOfRepeats )
       
   983 	{
       
   984 	CancelTimer();
       
   985 	iNumberOfRepeats           = aNumberOfRepeats;
       
   986 	iForegroundLossObserverved = ETrue;
       
   987 	InitTimer( aDelay, aDelay );
       
   988 	}
       
   989 
       
   990 
       
   991 // ---------------------------------------------------------------------------
       
   992 // CAknDelayedForegroundObserver::StopDelayedObservation
       
   993 // Stops delayed observation.
       
   994 // ---------------------------------------------------------------------------
       
   995 //
       
   996 void CAknDelayedForegroundObserver::StopDelayedObservation()
       
   997 	{
       
   998 	CancelTimer();
       
   999 	}
       
  1000 
       
  1001 
       
  1002 // ---------------------------------------------------------------------------
       
  1003 // CAknDelayedForegroundObserver::IsDelayedCallbackActive
       
  1004 // Checks whether the callback is already active.
       
  1005 // ---------------------------------------------------------------------------
       
  1006 //
       
  1007 TBool CAknDelayedForegroundObserver::IsDelayedCallbackActive()
       
  1008 	{
       
  1009 	return iDelayedCallbackActive;
       
  1010 	}
       
  1011 
       
  1012 
       
  1013 // ---------------------------------------------------------------------------
       
  1014 // CAknDelayedForegroundObserver::InitTimer
       
  1015 // Starts the timer.
       
  1016 // ---------------------------------------------------------------------------
       
  1017 //
       
  1018 void CAknDelayedForegroundObserver::InitTimer( TInt aDelay, TInt aInterval )
       
  1019     {
       
  1020     CancelTimer();
       
  1021     if ( iTimer && !iTimer->IsActive() ) // start timer if not already started
       
  1022         {
       
  1023         iTimer->Start(
       
  1024             TTimeIntervalMicroSeconds32( aDelay ),
       
  1025 		    TTimeIntervalMicroSeconds32( aInterval ),
       
  1026             TCallBack( TimerEvent, this ) );
       
  1027         }
       
  1028     }
       
  1029 
       
  1030 
       
  1031 // ---------------------------------------------------------------------------
       
  1032 // CAknDelayedForegroundObserver::CancelTimer
       
  1033 // Cancels the timer.
       
  1034 // ---------------------------------------------------------------------------
       
  1035 //
       
  1036 void CAknDelayedForegroundObserver::CancelTimer()
       
  1037     {
       
  1038    	if ( iTimer && iTimer->IsActive() )
       
  1039     	{
       
  1040    		iTimer->Cancel();
       
  1041     	}
       
  1042     }
       
  1043 
       
  1044 
       
  1045 // ---------------------------------------------------------------------------
       
  1046 // CAknDelayedForegroundObserver::TimerEvent
       
  1047 // Static timer callback function.
       
  1048 // ---------------------------------------------------------------------------
       
  1049 //
       
  1050 TInt CAknDelayedForegroundObserver::TimerEvent( TAny* aPtr )
       
  1051     {
       
  1052     static_cast<CAknDelayedForegroundObserver*>( aPtr )->DoTimerEvent();
       
  1053     return TRUE;
       
  1054     }
       
  1055 
       
  1056 
       
  1057 // ---------------------------------------------------------------------------
       
  1058 // CAknDelayedForegroundObserver::DoTimerEvent
       
  1059 // Timer callback function.
       
  1060 // ---------------------------------------------------------------------------
       
  1061 //
       
  1062 void CAknDelayedForegroundObserver::DoTimerEvent()
       
  1063     {
       
  1064     if ( !iNumberOfRepeats-- )
       
  1065         {
       
  1066     	CancelTimer();
       
  1067         }
       
  1068 
       
  1069 	iDelayedCallbackActive = ETrue;
       
  1070 
       
  1071     if ( iForegroundLossObserverved )
       
  1072         {
       
  1073     	iObserver->HandleLosingForeground();
       
  1074         }
       
  1075     else
       
  1076         {
       
  1077     	iObserver->HandleGainingForeground();
       
  1078         }
       
  1079 
       
  1080 	iDelayedCallbackActive = EFalse;
       
  1081     }
       
  1082 
       
  1083 
       
  1084 /**
       
  1085  * class CEikStatusPaneContainer.
       
  1086  * Container class for status pane's sub-pane controls.
       
  1087  */
       
  1088 NONSHARABLE_CLASS( CEikStatusPaneContainer ) : public CCoeControl,
       
  1089                                                public MCoeControlObserver,
       
  1090                                                public MCoeControlContext
       
  1091 	{
       
  1092 public:
       
  1093 
       
  1094     /**
       
  1095     * Two-phased constructor.
       
  1096     */
       
  1097     static CEikStatusPaneContainer* NewL(
       
  1098         TPaneId aPaneId,
       
  1099         TInt aControlTypeId,
       
  1100         TInt aControlResId,
       
  1101         RWindowGroup* aParent,
       
  1102         CAknsMaskedLayerBackgroundControlContext* aBgContext1,
       
  1103         CAknsMaskedLayerBackgroundControlContext* aBgContext2,
       
  1104         CAknStatusPaneDataSubscriber* aDataSubscriber,
       
  1105         CRedrawStoreHandler& aRedrawStoreHandler );
       
  1106 
       
  1107     /**
       
  1108     * Destructor.
       
  1109     */
       
  1110     ~CEikStatusPaneContainer();
       
  1111 
       
  1112     /**
       
  1113     * Returns the sub-pane ID of this container.
       
  1114     */
       
  1115     inline TPaneId Id() const;
       
  1116 
       
  1117     /**
       
  1118     * Returns the control inside this container.
       
  1119     */
       
  1120     inline CCoeControl* Control() const;
       
  1121 
       
  1122     /**
       
  1123     * Sets the control inside this container.
       
  1124     */
       
  1125     inline void SetControl( CCoeControl* aNewControl );
       
  1126 
       
  1127     /**
       
  1128     * Prepares the skin background context for drawing.
       
  1129     */
       
  1130     static void PrepareBackgroundContext(
       
  1131         CAknsMaskedLayerBackgroundControlContext* aBgContext,
       
  1132         TInt aLayoutId,
       
  1133         TBool aDrawNavi = ETrue,
       
  1134         TInt aContextNumber = 0,
       
  1135         TAknsItemID aCbaBgID = KAknsIIDQsnBgAreaControl );
       
  1136 
       
  1137     /**
       
  1138     * Prepares the base skin background context for drawing.
       
  1139     */
       
  1140     static void PrepareBackgroundBaseContext( MAknsControlContext* aBgContext,
       
  1141                                               TInt aLayoutId,
       
  1142                                               TBool aDrawNavi = ETrue );
       
  1143 
       
  1144     /**
       
  1145     * Handles resource change events.
       
  1146     */
       
  1147     void HandleResourceChange( TInt aType );
       
  1148 
       
  1149 public: // From base class @c CCoeControl.
       
  1150 
       
  1151     /**
       
  1152     * Sets the dimming status.
       
  1153     */
       
  1154     virtual void SetDimmed( TBool aDimmed );
       
  1155 
       
  1156 protected: // From base class @c CCoeControl.
       
  1157 
       
  1158     /**
       
  1159     * Supplies an object of type aId to the mop-chain.
       
  1160     */
       
  1161     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
  1162 
       
  1163 private:
       
  1164 
       
  1165     /**
       
  1166     * C++ constructor.
       
  1167     */
       
  1168     CEikStatusPaneContainer( TPaneId aPaneId );
       
  1169 
       
  1170     /**
       
  1171     * Second-phase constructor.
       
  1172     */
       
  1173     void ConstructL( TInt aControlTypeId,
       
  1174                      TInt aControlResId,
       
  1175                      RWindowGroup* aParent,
       
  1176                      CAknsMaskedLayerBackgroundControlContext* aBgContext1,
       
  1177                      CAknsMaskedLayerBackgroundControlContext* aBgContext2,
       
  1178                      CAknStatusPaneDataSubscriber* aDataSubscriber,
       
  1179                      CRedrawStoreHandler& aRedrawStoreHandler );
       
  1180 
       
  1181     /**
       
  1182     * Handles size change events.
       
  1183     */
       
  1184 	virtual void SizeChanged();
       
  1185 
       
  1186 	/**
       
  1187     * Returns the number of component control inside this container.
       
  1188     */
       
  1189 	virtual TInt CountComponentControls() const;
       
  1190 
       
  1191 	/**
       
  1192     * Gets a component control by control index.
       
  1193     */
       
  1194 	virtual CCoeControl* ComponentControl( TInt aIndex ) const;
       
  1195 
       
  1196 	/**
       
  1197     * Handles events from an observed control.
       
  1198     */
       
  1199 	void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
  1200 
       
  1201 	/**
       
  1202 	* Writes the internal state of the control and its components to aStream.
       
  1203 	*/
       
  1204 	void WriteInternalStateL( RWriteStream& aWriteStream ) const;
       
  1205 
       
  1206     /**
       
  1207 	* Draws the control.
       
  1208 	*/
       
  1209 	void Draw( const TRect& aRect ) const;
       
  1210 
       
  1211 private:
       
  1212 
       
  1213     /** Sub-pane ID of this container. */
       
  1214 	TPaneId iPaneId;
       
  1215 
       
  1216 	/** Contained control. */
       
  1217 	CCoeControl* iControl;
       
  1218 
       
  1219 private:
       
  1220 
       
  1221     /**
       
  1222     * First skin background context.
       
  1223     * Not own.
       
  1224     */
       
  1225     CAknsMaskedLayerBackgroundControlContext* iBgContext1;
       
  1226 
       
  1227     /**
       
  1228     * Second skin background context.
       
  1229     * Not own.
       
  1230     */
       
  1231     CAknsMaskedLayerBackgroundControlContext* iBgContext2;
       
  1232 
       
  1233     /**
       
  1234     * Pointer to the status pane data subscriber.
       
  1235     * Not own.
       
  1236     */
       
  1237     CAknStatusPaneDataSubscriber* iDataSubscriber;
       
  1238 	};
       
  1239 
       
  1240 
       
  1241 // ---------------------------------------------------------------------------
       
  1242 // CEikStatusPaneContainer::Id
       
  1243 // Returns the sub-pane ID.
       
  1244 // ---------------------------------------------------------------------------
       
  1245 //
       
  1246 inline TPaneId CEikStatusPaneContainer::Id() const
       
  1247     {
       
  1248     return iPaneId;
       
  1249     }
       
  1250 
       
  1251 // ---------------------------------------------------------------------------
       
  1252 // CEikStatusPaneContainer::Control
       
  1253 // Gets the control inside this container.
       
  1254 // ---------------------------------------------------------------------------
       
  1255 //
       
  1256 inline CCoeControl* CEikStatusPaneContainer::Control() const
       
  1257     {
       
  1258     return iControl;
       
  1259     }
       
  1260 
       
  1261 // ---------------------------------------------------------------------------
       
  1262 // CEikStatusPaneContainer::SetControl
       
  1263 // Sets the control inside this container.
       
  1264 // ---------------------------------------------------------------------------
       
  1265 //
       
  1266 inline void CEikStatusPaneContainer::SetControl( CCoeControl* aNewControl )
       
  1267     {
       
  1268     iControl = aNewControl;
       
  1269     }
       
  1270 
       
  1271 
       
  1272 // ---------------------------------------------------------------------------
       
  1273 // CEikStatusPaneContainer::NewL
       
  1274 // Two-phased constructor.
       
  1275 // ---------------------------------------------------------------------------
       
  1276 //
       
  1277 CEikStatusPaneContainer* CEikStatusPaneContainer::NewL(
       
  1278     TPaneId aPaneId,
       
  1279     TInt aControlTypeId,
       
  1280     TInt aControlResId,
       
  1281     RWindowGroup* aParent,
       
  1282     CAknsMaskedLayerBackgroundControlContext* aBgContext1,
       
  1283     CAknsMaskedLayerBackgroundControlContext* aBgContext2,
       
  1284     CAknStatusPaneDataSubscriber* aDataSubscriber,
       
  1285     CRedrawStoreHandler& aRedrawStoreHandler )
       
  1286     {
       
  1287     CEikStatusPaneContainer* self =
       
  1288         new (ELeave) CEikStatusPaneContainer( aPaneId );
       
  1289     CleanupStack::PushL( self );
       
  1290     self->ConstructL( aControlTypeId,
       
  1291                       aControlResId,
       
  1292                       aParent,
       
  1293                       aBgContext1,
       
  1294                       aBgContext2,
       
  1295                       aDataSubscriber,
       
  1296                       aRedrawStoreHandler );
       
  1297     CleanupStack::Pop( self );
       
  1298     AKNTASHOOK_ADDL( self, "CEikStatusPaneContainer" );
       
  1299     return self;
       
  1300     }
       
  1301 
       
  1302 
       
  1303 // ---------------------------------------------------------------------------
       
  1304 // CEikStatusPaneContainer::CEikStatusPaneContainer
       
  1305 // C++ constructor.
       
  1306 // ---------------------------------------------------------------------------
       
  1307 //
       
  1308 CEikStatusPaneContainer::CEikStatusPaneContainer( TPaneId aPaneId )
       
  1309     : iPaneId( aPaneId )
       
  1310 	{
       
  1311 	}
       
  1312 
       
  1313 
       
  1314 
       
  1315 // ---------------------------------------------------------------------------
       
  1316 // CEikStatusPaneContainer::~CEikStatusPaneContainer
       
  1317 // Destructor.
       
  1318 // ---------------------------------------------------------------------------
       
  1319 //
       
  1320 CEikStatusPaneContainer::~CEikStatusPaneContainer()
       
  1321 	{
       
  1322 	AKNTASHOOK_REMOVE();
       
  1323 	delete iControl;
       
  1324 	}
       
  1325 
       
  1326 
       
  1327 // ---------------------------------------------------------------------------
       
  1328 // CEikStatusPaneContainer::ConstructL
       
  1329 // Second-phase constructor.
       
  1330 // ---------------------------------------------------------------------------
       
  1331 //
       
  1332 void CEikStatusPaneContainer::ConstructL(
       
  1333     TInt aControlTypeId,
       
  1334     TInt aControlResId,
       
  1335     RWindowGroup* aParent,
       
  1336     CAknsMaskedLayerBackgroundControlContext* aBgContext1,
       
  1337     CAknsMaskedLayerBackgroundControlContext* aBgContext2,
       
  1338     CAknStatusPaneDataSubscriber* aDataSubscriber,
       
  1339     CRedrawStoreHandler& aRedrawStoreHandler )
       
  1340     {
       
  1341     SetMopParent( iEikonEnv->EikAppUi() );
       
  1342 
       
  1343     CreateWindowL( aParent );
       
  1344     
       
  1345     //This is added for homescreen transparent
       
  1346     CEikApplication* app = iEikonEnv->EikAppUi()->Application();
       
  1347     if ( app && app->AppDllUid() == KActiveIdle2Uid  )
       
  1348         {
       
  1349         if( KErrNone == Window().SetTransparencyAlphaChannel())
       
  1350             Window().SetBackgroundColor(~0);
       
  1351         }
       
  1352     else
       
  1353         {
       
  1354         Window().SetBackgroundColor(
       
  1355         iEikonEnv->ControlColor( EColorStatusPaneBackground, *this ) );
       
  1356         }
       
  1357 
       
  1358     // This helps for unsyncronized undimming problems.
       
  1359     aRedrawStoreHandler.SetStore( &Window(), KEnableRedrawStoring );
       
  1360 
       
  1361     iBgContext1 = aBgContext1;
       
  1362     iBgContext2 = aBgContext2;
       
  1363 
       
  1364     iDataSubscriber = aDataSubscriber;
       
  1365 
       
  1366 	SetControlContext( this );
       
  1367 
       
  1368 	RWindow& window = Window();
       
  1369 	window.SetPointerGrab( ETrue );
       
  1370 	window.SetShadowDisabled( ETrue );
       
  1371 	window.SetNonFading( !LafStatusPaneContainer::AllowFading() );
       
  1372 	EnableDragEvents();
       
  1373 
       
  1374 	HandleResourceChange( KEikColorResourceChange );
       
  1375 
       
  1376 	iControl = EikControlFactory::CreateByTypeL( aControlTypeId ).iControl;
       
  1377 	iControl->SetContainerWindowL( *this );
       
  1378 	iControl->SetNonFocusing();
       
  1379 
       
  1380 	TResourceReader res;
       
  1381 	if ( aControlResId )
       
  1382 	    {
       
  1383 		iEikonEnv->CreateResourceReaderLC( res, aControlResId );
       
  1384 	    }
       
  1385 
       
  1386 	// If the following line panics, you forgot to give a resource
       
  1387 	// to a control that needs one.
       
  1388 	iControl->ConstructFromResourceL( res );
       
  1389 	if ( aControlResId )
       
  1390 	    {
       
  1391 		CleanupStack::PopAndDestroy();	// res
       
  1392 	    }
       
  1393 
       
  1394 	SetComponentsToInheritVisibility();
       
  1395 	MakeVisible( EFalse );
       
  1396 
       
  1397 	ActivateL();
       
  1398     }
       
  1399 
       
  1400 
       
  1401 // ---------------------------------------------------------------------------
       
  1402 // CEikStatusPaneContainer::SizeChanged
       
  1403 // Handles size change events.
       
  1404 // ---------------------------------------------------------------------------
       
  1405 //
       
  1406 void CEikStatusPaneContainer::SizeChanged()
       
  1407 	{
       
  1408 	iControl->SetRect( Rect() );
       
  1409 	}
       
  1410 
       
  1411 
       
  1412 // ---------------------------------------------------------------------------
       
  1413 // CEikStatusPaneContainer::CountComponentControls
       
  1414 // Returns the amount of component controls.
       
  1415 // ---------------------------------------------------------------------------
       
  1416 //
       
  1417 TInt CEikStatusPaneContainer::CountComponentControls() const
       
  1418 	{
       
  1419 	return 1;
       
  1420 	}
       
  1421 
       
  1422 
       
  1423 // ---------------------------------------------------------------------------
       
  1424 // CEikStatusPaneContainer::ComponentControl
       
  1425 // Returns a contained control.
       
  1426 // ---------------------------------------------------------------------------
       
  1427 //
       
  1428 CCoeControl* CEikStatusPaneContainer::ComponentControl(
       
  1429     TInt /*aIndex*/ ) const
       
  1430 	{
       
  1431 	return iControl;
       
  1432 	}
       
  1433 
       
  1434 
       
  1435 // ---------------------------------------------------------------------------
       
  1436 // CEikStatusPaneContainer::HandleControlEventL
       
  1437 // Handles events received from the observed control.
       
  1438 // ---------------------------------------------------------------------------
       
  1439 //
       
  1440 void CEikStatusPaneContainer::HandleControlEventL( CCoeControl* aControl,
       
  1441                                                    TCoeEvent aEventType )
       
  1442 	{
       
  1443 	if ( aControl == iControl && aEventType == EEventStateChanged )
       
  1444 	    {
       
  1445 		DrawNow();
       
  1446 	    }
       
  1447 	}
       
  1448 
       
  1449 
       
  1450 // ---------------------------------------------------------------------------
       
  1451 // CEikStatusPaneContainer::PrepareBackgroundBaseContext
       
  1452 // Prepares base skin background context for drawing.
       
  1453 // ---------------------------------------------------------------------------
       
  1454 //
       
  1455 void CEikStatusPaneContainer::PrepareBackgroundBaseContext(
       
  1456     MAknsControlContext* aBgContext, TInt aLayoutId, TBool aDrawNavi )
       
  1457     {
       
  1458 
       
  1459     if ( aBgContext->IsCompatibleWithType( EAknsControlContextTypeCombined ) )
       
  1460         {
       
  1461         TInt contextCount = 0;
       
  1462         // Get first part of combination.
       
  1463         MAknsControlContext* partOfCombinedContext =
       
  1464             static_cast<CAknsCombinedBackgroundControlContext*>(
       
  1465                 aBgContext )->GetControlContext( contextCount );
       
  1466 
       
  1467         // While there are parts, fetch them and prepare each separately.
       
  1468         while ( partOfCombinedContext )
       
  1469             {
       
  1470             CEikStatusPaneContainer::PrepareBackgroundContext(
       
  1471                 static_cast<CAknsMaskedLayerBackgroundControlContext*>(
       
  1472                     partOfCombinedContext),
       
  1473                 aLayoutId,
       
  1474                 aDrawNavi,
       
  1475                 contextCount );
       
  1476             partOfCombinedContext =
       
  1477                 static_cast<CAknsCombinedBackgroundControlContext*>(
       
  1478                     aBgContext)->GetControlContext( ++contextCount );
       
  1479             }
       
  1480         }
       
  1481     else // other contextes should be compatible with layered cc's.
       
  1482         {
       
  1483         CEikStatusPaneContainer::PrepareBackgroundContext(
       
  1484             static_cast<CAknsMaskedLayerBackgroundControlContext*>(
       
  1485                 aBgContext),
       
  1486             aLayoutId,
       
  1487             aDrawNavi );
       
  1488         }
       
  1489     }
       
  1490 
       
  1491 
       
  1492 // ---------------------------------------------------------------------------
       
  1493 // CEikStatusPaneContainer::PrepareBackgroundContext
       
  1494 // Prepares skin background context for drawing.
       
  1495 // ---------------------------------------------------------------------------
       
  1496 //
       
  1497 void CEikStatusPaneContainer::PrepareBackgroundContext(
       
  1498     CAknsMaskedLayerBackgroundControlContext* aBgContext,
       
  1499     TInt aLayoutId,
       
  1500     TBool aDrawNavi,
       
  1501     TInt aContextNumber,
       
  1502     TAknsItemID aCbaBgID )
       
  1503     {
       
  1504     if ( !SupportedPortraitResId( aLayoutId ) &&
       
  1505          !SupportedLandscapeResId( aLayoutId ) )
       
  1506         {
       
  1507         // Layout not supported, do nothing.
       
  1508         return;
       
  1509         }
       
  1510 
       
  1511     // This is not using ApplicationRect(), because it
       
  1512     // causes RWsSession::Flush().
       
  1513     TRect screen;
       
  1514     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );
       
  1515 
       
  1516     // Application window rectangle.
       
  1517     TRect application_window;
       
  1518     AknLayoutUtils::LayoutMetricsRect(
       
  1519         AknLayoutUtils::EApplicationWindow, application_window );
       
  1520 
       
  1521     // Usual status pane
       
  1522     TAknWindowLineLayout statusPane(
       
  1523         DoCompose( AknLayoutScalable_Avkon::area_top_pane( 0 ),
       
  1524                    AknLayoutScalable_Avkon::status_pane( 0 ) ).LayoutLine() );
       
  1525     TAknLayoutRect status_pane_usual;
       
  1526     status_pane_usual.LayoutRect( application_window, statusPane );
       
  1527     TRect statusPaneUsual( status_pane_usual.Rect() );
       
  1528 
       
  1529     // Stacon top pane.
       
  1530     TAknLayoutRect layoutRect;
       
  1531     layoutRect.LayoutRect(
       
  1532         application_window,
       
  1533         DoCompose( AknLayoutScalable_Avkon::area_top_pane( 2 ),
       
  1534                    AknLayoutScalable_Avkon::stacon_top_pane() ).LayoutLine() );
       
  1535     TRect staconTop( layoutRect.Rect() );
       
  1536 
       
  1537     // Stacon bottom pane.
       
  1538     layoutRect.LayoutRect(
       
  1539         application_window,
       
  1540         DoCompose( AknLayoutScalable_Avkon::area_bottom_pane( 2 ),
       
  1541                    AknLayoutScalable_Avkon::stacon_bottom_pane() ).LayoutLine() );
       
  1542     TRect staconBottom( layoutRect.Rect() );
       
  1543 
       
  1544     // CBA for landscape bottom softkeys.
       
  1545     TRect cbaRect( 0,0,0,0 );
       
  1546     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1547         {
       
  1548         layoutRect.LayoutRect(
       
  1549             application_window,
       
  1550             DoCompose( AknLayoutScalable_Avkon::area_bottom_pane( 6 ),
       
  1551                        AknLayoutScalable_Avkon::control_pane() ).LayoutLine() );
       
  1552         cbaRect = layoutRect.Rect();
       
  1553         }
       
  1554 
       
  1555     // Clear the layers first.
       
  1556     for ( TInt n = 0; n < ELayerFlatN; n++ )
       
  1557         {
       
  1558         aBgContext->SetLayerImage( n, KAknsIIDNone );
       
  1559         }
       
  1560 
       
  1561     // By default - no mask.
       
  1562     TAknsItemID maskIID( KAknsIIDNone );
       
  1563     TRAP_IGNORE( aBgContext->SetLayerMaskAndSizeL(
       
  1564         maskIID, application_window ) );
       
  1565     TRect maskRect( 0,0,0,0 );
       
  1566 
       
  1567     switch( aLayoutId )
       
  1568         {
       
  1569         case R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE:
       
  1570         case R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE_MIRRORED:
       
  1571 			  {
       
  1572            TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
  1573 
       
  1574            if ( isLandscape )
       
  1575                {
       
  1576                TAknWindowLineLayout topLayout( AknLayoutScalable_Avkon::area_top_pane(8).LayoutLine() );
       
  1577 
       
  1578                TAknLayoutRect layoutRect;
       
  1579                layoutRect.LayoutRect( application_window, topLayout );
       
  1580                TRect topLayoutRect( layoutRect.Rect() );
       
  1581 
       
  1582                TAknWindowLineLayout statuspaneLayout( AknLayoutScalable_Avkon::status_pane(2).LayoutLine() );
       
  1583                layoutRect.LayoutRect( topLayoutRect, statuspaneLayout );
       
  1584                TRect spRect( layoutRect.Rect() );
       
  1585 
       
  1586                aBgContext->SetLayerImage( ELayerBackground, KAknsIIDQsnBgAreaStatus );
       
  1587                aBgContext->SetLayerRect( ELayerBackground, spRect );
       
  1588                }
       
  1589            else
       
  1590                {
       
  1591                aBgContext->SetLayerImage( ELayerBackground, KAknsIIDQsnBgAreaStatus );
       
  1592                aBgContext->SetLayerRect( ELayerBackground, status_pane_usual.Rect() );
       
  1593                }
       
  1594 
       
  1595 			  break;
       
  1596 			  }
       
  1597         case R_AVKON_STATUS_PANE_LAYOUT_USUAL_WITH_BATTERY_PANE:
       
  1598         case R_AVKON_STATUS_PANE_LAYOUT_USUAL:
       
  1599         case R_AVKON_STATUS_PANE_LAYOUT_USUAL_MIRRORED:
       
  1600         case R_AVKON_STATUS_PANE_LAYOUT_VT:
       
  1601         case R_AVKON_STATUS_PANE_LAYOUT_VT_MIRRORED:
       
  1602             {
       
  1603             // First
       
  1604             aBgContext->SetLayerImage( ELayerBackground, KAknsIIDQsnBgAreaStatus );
       
  1605             aBgContext->SetLayerRect(  ELayerBackground, statusPaneUsual );
       
  1606 
       
  1607             // Extension
       
  1608             aBgContext->SetLayerImage( ELayerExtension, KAknsIIDNone );
       
  1609 
       
  1610             // Stripe
       
  1611             if ( aDrawNavi )
       
  1612                 {
       
  1613                 aBgContext->SetLayerImage( ELayerStripe, KAknsIIDQsnBgNavipaneSolid );
       
  1614                 }
       
  1615             else
       
  1616                 {
       
  1617                 aBgContext->SetLayerImage( ELayerStripe, KAknsIIDNone );
       
  1618                 }
       
  1619 
       
  1620             // skin does not follow avkon LAF, skin wipe is 176x15, not 174x15
       
  1621             TAknLayoutRect navi_wipe;
       
  1622             navi_wipe.LayoutRect(
       
  1623                 statusPaneUsual,
       
  1624                 AknLayoutScalable_Avkon::status_pane_g1( 0 ).LayoutLine() );
       
  1625             TRect skinnedNaviWipeRect( navi_wipe.Rect() );
       
  1626             skinnedNaviWipeRect.iTl.iX = 0;
       
  1627             skinnedNaviWipeRect.iBr.iX = statusPaneUsual.iBr.iX;
       
  1628 
       
  1629             aBgContext->SetLayerRect( ELayerStripe, skinnedNaviWipeRect );
       
  1630 
       
  1631             // Wallpaper
       
  1632             aBgContext->SetLayerImage( ELayerWallpaper, KAknsIIDNone );
       
  1633             break;
       
  1634             }
       
  1635 
       
  1636         case R_AVKON_STATUS_PANE_LAYOUT_IDLE:
       
  1637         case R_AVKON_STATUS_PANE_LAYOUT_IDLE_MIRRORED:
       
  1638             {
       
  1639             // First
       
  1640             TAknLayoutRect status_pane;
       
  1641             status_pane = status_pane_usual;
       
  1642 
       
  1643             // Extension
       
  1644             TAknLayoutRect extension;
       
  1645             extension.LayoutRect(
       
  1646                 application_window,
       
  1647                 AKN_LAYOUT_WINDOW_main_pane( application_window, 0, 1, 1 ) );
       
  1648 
       
  1649             // Wallpaper
       
  1650             aBgContext->SetLayerImage( ELayerWallpaper,  KAknsIIDWallpaper );
       
  1651             aBgContext->SetLayerRect(  ELayerWallpaper,  screen );
       
  1652             aBgContext->SetLayerImage( ELayerBackground, KAknsIIDQsnBgAreaStatusIdle );
       
  1653             aBgContext->SetLayerRect(  ELayerBackground, statusPaneUsual );
       
  1654 
       
  1655             if ( aDrawNavi )
       
  1656                 {
       
  1657                 aBgContext->SetLayerImage( ELayerStripe, KAknsIIDQsnBgNavipaneSolidIdle );
       
  1658                 }
       
  1659             else
       
  1660                 {
       
  1661                 aBgContext->SetLayerImage( ELayerStripe, KAknsIIDNone );
       
  1662                 }
       
  1663 
       
  1664             // skin does not follow avkon LAF, skin wipe is 176x15, not 174x15
       
  1665             TAknLayoutRect navi_wipe;
       
  1666             navi_wipe.LayoutRect(
       
  1667                 statusPaneUsual,
       
  1668                 AknLayoutScalable_Avkon::status_pane_g1( 0 ).LayoutLine() );
       
  1669             TRect skinnedNaviWipeRect( navi_wipe.Rect() );
       
  1670             skinnedNaviWipeRect.iTl.iX = 0;
       
  1671             skinnedNaviWipeRect.iBr.iX = statusPaneUsual.iBr.iX;
       
  1672             aBgContext->SetLayerRect( ELayerStripe, skinnedNaviWipeRect );
       
  1673 
       
  1674             maskIID  = KAknsIIDQgnGrafBgPrtTopMaskIcon;
       
  1675             maskRect = statusPaneUsual;
       
  1676 
       
  1677             break;
       
  1678             }
       
  1679 
       
  1680         case R_AVKON_STATUS_PANE_LAYOUT_SMALL:
       
  1681         case R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE:
       
  1682         case R_AVKON_STATUS_PANE_LAYOUT_SMALL_WITH_SIGNAL_PANE_MIRRORED:
       
  1683             {
       
  1684             // First
       
  1685             TAknWindowLineLayout topAreaLayout;
       
  1686             TAknsItemID bgID = KAknsIIDQsnBgNavipaneSolid;
       
  1687             if ( AknLayoutUtils::CbaLocation() ==
       
  1688                     AknLayoutUtils::EAknCbaLocationBottom &&
       
  1689                  Layout_Meta_Data::IsLandscapeOrientation() )
       
  1690                 {
       
  1691                 // Landscape with bottom softkeys is the only landscape mode
       
  1692                 // in which small status pane can be shown.
       
  1693                 topAreaLayout =
       
  1694                     AknLayoutScalable_Avkon::area_top_pane( 2 ).LayoutLine();
       
  1695                 // This is used because doesn't quite work with the same
       
  1696                 // skin item ID as in portrait mode.
       
  1697                 bgID = KAknsIIDQsnBgAreaStaconRt;
       
  1698                 }
       
  1699             else
       
  1700                 {
       
  1701                 topAreaLayout =
       
  1702                     AknLayoutScalable_Avkon::area_top_pane( 1 ).LayoutLine();
       
  1703                 }
       
  1704 
       
  1705             // The status pane fills the whole top area in this layout.
       
  1706             TAknLayoutRect topAreaLayoutRect;
       
  1707             topAreaLayoutRect.LayoutRect( application_window, topAreaLayout );
       
  1708             TRect topAreaRect( topAreaLayoutRect.Rect() );
       
  1709 
       
  1710             aBgContext->SetLayerImage( ELayerBackground, bgID );
       
  1711             aBgContext->SetLayerRect(  ELayerBackground, topAreaRect );
       
  1712 
       
  1713             // Extension
       
  1714             aBgContext->SetLayerImage( ELayerExtension, KAknsIIDNone );
       
  1715 
       
  1716             // Stripe
       
  1717             aBgContext->SetLayerImage( ELayerStripe, KAknsIIDNone );
       
  1718 
       
  1719             // Wallpaper
       
  1720             aBgContext->SetLayerImage( ELayerWallpaper, KAknsIIDNone );
       
  1721             break;
       
  1722             }
       
  1723 
       
  1724         case R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT:
       
  1725         case R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT:
       
  1726             {
       
  1727             aBgContext->SetLayerImage( ELayerStaconTop,
       
  1728                                        KAknsIIDQsnBgAreaStaconRt );
       
  1729             aBgContext->SetLayerRect(  ELayerStaconTop, staconTop );
       
  1730 
       
  1731             aBgContext->SetLayerImage( ELayerStaconBottom,
       
  1732                                        KAknsIIDQsnBgAreaStaconRb );
       
  1733             aBgContext->SetLayerRect(  ELayerStaconBottom, staconBottom );
       
  1734 
       
  1735             aBgContext->SetLayerImage( ELayerStaconWallpaper, KAknsIIDNone );
       
  1736 
       
  1737             aBgContext->SetLayerImage( ELayerStaconN, KAknsIIDNone );
       
  1738             break;
       
  1739             }
       
  1740 
       
  1741         case R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT:
       
  1742             {
       
  1743             // First
       
  1744             TAknLayoutRect status_pane;
       
  1745             status_pane.LayoutRect(
       
  1746                 application_window,
       
  1747                 AKN_LAYOUT_WINDOW_status_pane( application_window, 1 ) );
       
  1748 
       
  1749             // Wallpaper
       
  1750             aBgContext->SetLayerImage( ELayerStaconWp, KAknsIIDWallpaper );
       
  1751 
       
  1752             // Top
       
  1753             if ( aContextNumber == 0 )
       
  1754                 {
       
  1755                 aBgContext->SetLayerRect( ELayerStaconWp, staconTop );
       
  1756 
       
  1757                 aBgContext->SetLayerImage( ELayerStaconSkin,
       
  1758                                            KAknsIIDQsnBgAreaStaconRtIdle );
       
  1759                 aBgContext->SetLayerRect(  ELayerStaconSkin, staconTop );
       
  1760 
       
  1761                 maskIID  = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  1762                 maskRect = staconTop;
       
  1763                 }
       
  1764             // Bottom
       
  1765             else if ( aContextNumber == 1 )
       
  1766                 {
       
  1767                 aBgContext->SetLayerRect( ELayerStaconWp, screen );
       
  1768 
       
  1769                 aBgContext->SetLayerImage( ELayerStaconSkin,
       
  1770                                            KAknsIIDQsnBgAreaStaconRbIdle );
       
  1771                 aBgContext->SetLayerRect(  ELayerStaconSkin, staconBottom );
       
  1772 
       
  1773                 maskIID  = KAknsIIDQgnGrafBgLscBottomMaskIcon;
       
  1774                 maskRect = staconBottom;
       
  1775                 }
       
  1776 
       
  1777             break;
       
  1778             }
       
  1779 
       
  1780         case R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT:
       
  1781         case R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT:
       
  1782             {
       
  1783             aBgContext->SetLayerImage( ELayerStaconTop,
       
  1784                                        KAknsIIDQsnBgAreaStaconLt );
       
  1785             aBgContext->SetLayerRect(  ELayerStaconTop, staconTop );
       
  1786 
       
  1787             aBgContext->SetLayerImage( ELayerStaconBottom,
       
  1788                                        KAknsIIDQsnBgAreaStaconLb );
       
  1789             aBgContext->SetLayerRect(  ELayerStaconBottom, staconBottom );
       
  1790 
       
  1791             aBgContext->SetLayerImage( ELayerStaconWallpaper, KAknsIIDNone );
       
  1792             break;
       
  1793             }
       
  1794 
       
  1795         case R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT:
       
  1796             {
       
  1797             // Wallpaper
       
  1798             aBgContext->SetLayerImage( ELayerStaconWp, KAknsIIDWallpaper );
       
  1799 
       
  1800             // Top
       
  1801             if ( aContextNumber == 0 )
       
  1802                 {
       
  1803                 aBgContext->SetLayerRect( ELayerStaconWp, staconTop );
       
  1804 
       
  1805                 aBgContext->SetLayerImage( ELayerStaconSkin,
       
  1806                                            KAknsIIDQsnBgAreaStaconLtIdle );
       
  1807                 aBgContext->SetLayerRect(  ELayerStaconSkin, staconTop );
       
  1808 
       
  1809                 maskIID  = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  1810                 maskRect = staconTop;
       
  1811                 }
       
  1812             // Bottom
       
  1813             else if ( aContextNumber == 1 )
       
  1814                 {
       
  1815                 aBgContext->SetLayerRect( ELayerStaconWp, screen );
       
  1816 
       
  1817                 aBgContext->SetLayerImage( ELayerStaconSkin,
       
  1818                                            KAknsIIDQsnBgAreaStaconLbIdle );
       
  1819                 aBgContext->SetLayerRect(  ELayerStaconSkin, staconBottom );
       
  1820 
       
  1821                 maskIID  = KAknsIIDQgnGrafBgLscBottomMaskIcon;
       
  1822                 maskRect = staconBottom;
       
  1823                 }
       
  1824 
       
  1825             break;
       
  1826             }
       
  1827 
       
  1828         case R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT:
       
  1829         case R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT:
       
  1830             {
       
  1831             if ( aContextNumber == 0 )
       
  1832                 {
       
  1833                 // We use frame as layered context so that we can avoid having 2
       
  1834                 // separate bg contextes in this class. Anyway framecontext is
       
  1835                 // implemented using layered context so this should be quite ok
       
  1836                 // thing to do.
       
  1837 
       
  1838                 TInt topVariety = 0;
       
  1839                 TInt spVariety  = 0;
       
  1840                 TInt bgVariety  = 0;
       
  1841 
       
  1842                 TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
  1843 
       
  1844                 if ( isLandscape )
       
  1845                     {
       
  1846                     topVariety = 8;
       
  1847                     spVariety  = 2;
       
  1848                     bgVariety  = 1;
       
  1849                     }
       
  1850                 else
       
  1851                     {
       
  1852                     topVariety = 6;
       
  1853                     spVariety  = 3;
       
  1854                     bgVariety  = 0;
       
  1855                     }
       
  1856 
       
  1857                 TAknLayoutRect layoutRect;
       
  1858                 layoutRect.LayoutRect(
       
  1859                     application_window,
       
  1860                     AknLayoutScalable_Avkon::area_top_pane( topVariety ).LayoutLine() );
       
  1861                 TRect topLayoutRect( layoutRect.Rect() );
       
  1862 
       
  1863                 layoutRect.LayoutRect(
       
  1864                     topLayoutRect,
       
  1865                     AknLayoutScalable_Avkon::status_pane( spVariety ).LayoutLine() );
       
  1866                 TRect spRect( layoutRect.Rect() );
       
  1867 
       
  1868                 layoutRect.LayoutRect(
       
  1869                     spRect,
       
  1870                     AknLayoutScalable_Avkon::bg_status_flat_pane( bgVariety ).LayoutLine() );
       
  1871                 TRect bgRect( layoutRect.Rect() );
       
  1872 
       
  1873 
       
  1874                 if ( aLayoutId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
       
  1875                     {
       
  1876                     TAknLayoutRect extension;
       
  1877                         extension.LayoutRect(
       
  1878                         application_window,
       
  1879                         AKN_LAYOUT_WINDOW_main_pane( application_window, 0, 1, 1 ) );
       
  1880 
       
  1881                     // Wallpaper
       
  1882                     aBgContext->SetLayerImage( ELayerFlatWallpaper,
       
  1883                                                KAknsIIDWallpaper );
       
  1884                     aBgContext->SetLayerRect(  ELayerFlatWallpaper, screen );
       
  1885 
       
  1886                     // Main pane
       
  1887                     aBgContext->SetLayerImage( ELayerFlatMain,
       
  1888                                                KAknsIIDQsnBgAreaMainIdle );
       
  1889                     aBgContext->SetLayerRect( ELayerFlatMain, extension.Rect() );
       
  1890 
       
  1891                     // Skin background, transparency support
       
  1892                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  1893                                                KAknsIIDQsnBgScreenIdle );
       
  1894                     aBgContext->SetLayerRect(  ELayerFlatBackground,
       
  1895                                                topLayoutRect );
       
  1896 
       
  1897                     // CBA area
       
  1898                     aBgContext->SetLayerImage( ELayerFlatCba,
       
  1899                                                KAknsIIDQsnBgAreaControlIdle );
       
  1900                     aBgContext->SetLayerRect( ELayerFlatCba, cbaRect );
       
  1901                     }
       
  1902                  else
       
  1903                     { // Not Idle.
       
  1904                     // Main pane
       
  1905                     aBgContext->SetLayerImage( ELayerFlatMain, KAknsIIDNone );
       
  1906 
       
  1907                     // Wallpaper
       
  1908                     aBgContext->SetLayerImage( ELayerFlatWallpaper, KAknsIIDNone );
       
  1909 
       
  1910                     // Skin background, transparency support
       
  1911                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  1912                                                KAknsIIDQsnBgScreen );
       
  1913                     aBgContext->SetLayerRect( ELayerFlatBackground, screen );
       
  1914 
       
  1915                     // CBA area
       
  1916                     aBgContext->SetLayerImage( ELayerFlatCba, aCbaBgID );
       
  1917                     aBgContext->SetLayerRect( ELayerFlatCba, cbaRect );
       
  1918                     }
       
  1919 
       
  1920                 MAknsSkinInstance* si = AknsUtils::SkinInstance();
       
  1921                 CAknsItemData* idata  = NULL;
       
  1922                 if ( si )
       
  1923                     {
       
  1924                     TRAP_IGNORE(
       
  1925                         idata = si->CreateUncachedItemDataL(
       
  1926                             KAknsIIDQsnFrStatusFlat, EAknsITImageTable ) );
       
  1927                     }
       
  1928 
       
  1929                 if ( idata ) // 9 piece frame used
       
  1930                     {
       
  1931                     TAknWindowLineLayout layout( AknLayoutScalable_Avkon::bg_status_flat_pane_g2().LayoutLine() );
       
  1932                     layoutRect.LayoutRect( bgRect, layout );
       
  1933                     aBgContext->SetLayerImage( ELayerFlatTl, KAknsIIDQsnFrStatusFlatCornerTl );
       
  1934                     aBgContext->SetLayerRect( ELayerFlatTl, layoutRect.Rect() );
       
  1935 
       
  1936                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g3().LayoutLine();
       
  1937                     layoutRect.LayoutRect( bgRect, layout );
       
  1938                     aBgContext->SetLayerImage( ELayerFlatTr, KAknsIIDQsnFrStatusFlatCornerTr );
       
  1939                     aBgContext->SetLayerRect( ELayerFlatTr, layoutRect.Rect());
       
  1940 
       
  1941                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g4().LayoutLine();
       
  1942                     layoutRect.LayoutRect( bgRect, layout );
       
  1943                     aBgContext->SetLayerImage( ELayerFlatBl, KAknsIIDQsnFrStatusFlatCornerBl );
       
  1944                     aBgContext->SetLayerRect( ELayerFlatBl, layoutRect.Rect() );
       
  1945 
       
  1946                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g5().LayoutLine();
       
  1947                     layoutRect.LayoutRect( bgRect, layout );
       
  1948                     aBgContext->SetLayerImage( ELayerFlatBr, KAknsIIDQsnFrStatusFlatCornerBr );
       
  1949                     aBgContext->SetLayerRect( ELayerFlatBr, layoutRect.Rect() );
       
  1950 
       
  1951                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g6().LayoutLine();
       
  1952                     layoutRect.LayoutRect( bgRect, layout );
       
  1953                     aBgContext->SetLayerImage( ELayerFlatT,  KAknsIIDQsnFrStatusFlatSideT);
       
  1954                     aBgContext->SetLayerRect( ELayerFlatT, layoutRect.Rect() );
       
  1955 
       
  1956                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g7().LayoutLine();
       
  1957                     layoutRect.LayoutRect( bgRect, layout );
       
  1958                     aBgContext->SetLayerImage( ELayerFlatB, KAknsIIDQsnFrStatusFlatSideB );
       
  1959                     aBgContext->SetLayerRect( ELayerFlatB, layoutRect.Rect() );
       
  1960 
       
  1961                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g9().LayoutLine();
       
  1962                     layoutRect.LayoutRect( bgRect, layout );
       
  1963                     aBgContext->SetLayerImage( ELayerFlatR, KAknsIIDQsnFrStatusFlatSideR );
       
  1964                     aBgContext->SetLayerRect( ELayerFlatR, layoutRect.Rect() );
       
  1965 
       
  1966                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g8().LayoutLine();
       
  1967                     layoutRect.LayoutRect( bgRect, layout );
       
  1968                     aBgContext->SetLayerImage( ELayerFlatL, KAknsIIDQsnFrStatusFlatSideL );
       
  1969                     aBgContext->SetLayerRect( ELayerFlatL, layoutRect.Rect() );
       
  1970 
       
  1971                     layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g1().LayoutLine();
       
  1972                     layoutRect.LayoutRect( bgRect, layout );
       
  1973                     aBgContext->SetLayerImage( ELayerFlatCenter, KAknsIIDQsnFrStatusFlatCenter );
       
  1974                     aBgContext->SetLayerRect( ELayerFlatCenter, layoutRect.Rect() );
       
  1975 
       
  1976                     if ( aLayoutId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
       
  1977                         {
       
  1978                         if ( isLandscape )
       
  1979                             {
       
  1980                             maskIID = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  1981                             }
       
  1982                         else
       
  1983                             {
       
  1984                             maskIID = KAknsIIDQgnGrafBgPrtTopMaskIcon;
       
  1985                             }
       
  1986                         maskRect = spRect;
       
  1987                         }
       
  1988                     }
       
  1989                 else // handle one piece version here
       
  1990                     {
       
  1991                     if ( aLayoutId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
       
  1992                         {
       
  1993                         // Wallpaper
       
  1994                         aBgContext->SetLayerImage( ELayerFlatWallpaper,
       
  1995                                                    KAknsIIDWallpaper );
       
  1996                         aBgContext->SetLayerRect( ELayerFlatWallpaper,
       
  1997                                                   staconTop );
       
  1998 
       
  1999                         // Skin background
       
  2000                         aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2001                                                    KAknsIIDQsnFrStatusFlat );
       
  2002                         aBgContext->SetLayerRect( ELayerFlatBackground, bgRect );
       
  2003 
       
  2004                         // Set all other frame parts empty as they
       
  2005                         // might already be filled with something
       
  2006                         for ( TInt n = ELayerFlatBackground + 1; n <= ELayerFlatCenter; n++ )
       
  2007                            {
       
  2008                            aBgContext->SetLayerImage( n, KAknsIIDNone );
       
  2009                            }
       
  2010                         if ( isLandscape )
       
  2011                             {
       
  2012                             maskIID = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  2013                             }
       
  2014                         else
       
  2015                             {
       
  2016                             maskIID = KAknsIIDQgnGrafBgPrtTopMaskIcon;
       
  2017                             }
       
  2018                         maskRect = spRect;
       
  2019                         }
       
  2020                     else
       
  2021                         {
       
  2022                         aBgContext->SetLayerImage( 0, KAknsIIDQsnFrStatusFlat );
       
  2023                         aBgContext->SetLayerRect( 0, bgRect );
       
  2024                         // Set all other frame parts empty as they
       
  2025                         // might already be filled with something
       
  2026                         for ( TInt n = 1; n <= ELayerFlatCenter; n++ )
       
  2027                             {
       
  2028                             aBgContext->SetLayerImage( n, KAknsIIDNone );
       
  2029                             }
       
  2030                         }
       
  2031                     }
       
  2032 
       
  2033                 delete idata;
       
  2034                 }
       
  2035             else // context == 1 - this is the area removed from cba for clock
       
  2036                  // and indicator updates.
       
  2037                 {
       
  2038                 if ( aLayoutId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
       
  2039                     {
       
  2040                     aBgContext->SetLayerImage( ELayerFlatCbaWp,
       
  2041                                                KAknsIIDWallpaper );
       
  2042                     aBgContext->SetLayerRect( ELayerFlatCbaWp, screen );
       
  2043 
       
  2044                     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  2045                         {
       
  2046                         maskIID = KAknsIIDQgnGrafBgLscBottomMaskIcon;
       
  2047                         }
       
  2048                     else
       
  2049                         {
       
  2050                         maskIID = KAknsIIDQgnGrafBgPrtBottomMaskIcon;
       
  2051                         }
       
  2052                     maskRect = cbaRect;
       
  2053                     }
       
  2054                 else
       
  2055                     {
       
  2056                     aBgContext->SetLayerImage( ELayerFlatCbaWp, KAknsIIDNone );
       
  2057                     }
       
  2058 
       
  2059                 aBgContext->SetLayerImage( ELaterFlatCbaSkin,
       
  2060                                            KAknsIIDQsnBgAreaControlIdle );
       
  2061                 aBgContext->SetLayerRect( ELaterFlatCbaSkin, cbaRect );
       
  2062                 }
       
  2063 
       
  2064             break;
       
  2065             }
       
  2066 
       
  2067        case R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT:
       
  2068             {
       
  2069             // For now we use classic statuspane
       
  2070             TAknLayoutRect layoutRect;
       
  2071 
       
  2072             // Statuspane background
       
  2073             aBgContext->SetLayerImage( ELayerBackground,
       
  2074                                        KAknsIIDQsnBgAreaStatus );
       
  2075             layoutRect.LayoutRect(
       
  2076                 statusPaneUsual,
       
  2077                 AknLayoutScalable_Avkon::status_pane_g2( 3 ).LayoutLine() );
       
  2078             aBgContext->SetLayerRect( ELayerBackground, layoutRect.Rect() );
       
  2079 
       
  2080             // Navipane background graphics
       
  2081             aBgContext->SetLayerImage( ELayerStripe,
       
  2082                                        KAknsIIDQsnBgNavipaneSolid );
       
  2083             layoutRect.LayoutRect(
       
  2084                 statusPaneUsual,
       
  2085                 AknLayoutScalable_Avkon::status_pane_g1( 4 ).LayoutLine() );
       
  2086             aBgContext->SetLayerRect( ELayerStripe, layoutRect.Rect() );
       
  2087 
       
  2088             break;
       
  2089             }
       
  2090 
       
  2091        case R_AVKON_STATUS_PANE_LAYOUT_IDLE_EXT:
       
  2092             {
       
  2093             // For now we use classic statuspane
       
  2094             TAknLayoutRect layoutRect;
       
  2095 
       
  2096             // Statuspane background
       
  2097             aBgContext->SetLayerImage( ELayerWallpaper, KAknsIIDWallpaper );
       
  2098             layoutRect.LayoutRect(
       
  2099                 statusPaneUsual,
       
  2100                 AknLayoutScalable_Avkon::status_pane_g1( 0 ).LayoutLine() );
       
  2101             aBgContext->SetLayerRect( ELayerWallpaper, screen );
       
  2102 
       
  2103             aBgContext->SetLayerImage( ELayerBackground,
       
  2104                                        KAknsIIDQsnBgAreaStatusIdle );
       
  2105             layoutRect.LayoutRect(
       
  2106                 statusPaneUsual,
       
  2107                 AknLayoutScalable_Avkon::status_pane_g2( 0 ).LayoutLine() );
       
  2108             aBgContext->SetLayerRect( ELayerBackground, layoutRect.Rect() );
       
  2109 
       
  2110             TRect statusPaneRect( layoutRect.Rect() );
       
  2111 
       
  2112             // Navipane background graphics
       
  2113             aBgContext->SetLayerImage( ELayerStripe,
       
  2114                                        KAknsIIDQsnBgNavipaneSolidIdle );
       
  2115             layoutRect.LayoutRect(
       
  2116                 statusPaneUsual,
       
  2117                 AknLayoutScalable_Avkon::status_pane_g1( 0 ).LayoutLine() );
       
  2118             aBgContext->SetLayerRect( ELayerStripe, layoutRect.Rect() );
       
  2119 
       
  2120             aBgContext->SetLayerImage( ELayerN, KAknsIIDNone );
       
  2121 
       
  2122             maskIID  = KAknsIIDQgnGrafBgPrtTopMaskIcon;
       
  2123             maskRect = statusPaneRect;
       
  2124 
       
  2125             break;
       
  2126             }
       
  2127 
       
  2128         case R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL:
       
  2129         case R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE: // fallthrough
       
  2130             {
       
  2131             TAknLayoutRect wideStatusPane;
       
  2132             wideStatusPane.LayoutRect(
       
  2133                 application_window, DoCompose(
       
  2134                     AknLayoutScalable_Avkon::area_top_pane( 8 ),
       
  2135                     AknLayoutScalable_Avkon::status_pane( 1 ) ).LayoutLine() );
       
  2136             TRect wideSPRect( wideStatusPane.Rect() );
       
  2137 
       
  2138             if ( aLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE )
       
  2139                 {
       
  2140                 aBgContext->SetLayerImage( ELayerFlatWallpaper,
       
  2141                                            KAknsIIDWallpaper );
       
  2142                 aBgContext->SetLayerRect( ELayerFlatWallpaper, screen );
       
  2143 
       
  2144                 maskIID  = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  2145                 maskRect = wideSPRect;
       
  2146                 }
       
  2147 
       
  2148             aBgContext->SetLayerImage( ELayerFlatMain, KAknsIIDNone );
       
  2149 
       
  2150             aBgContext->SetLayerImage( ELayerFlatCba, KAknsIIDNone );
       
  2151 
       
  2152             MAknsSkinInstance* si = AknsUtils::SkinInstance();
       
  2153             CAknsItemData* idata  = NULL;
       
  2154             if ( si )
       
  2155                 {
       
  2156                 TRAP_IGNORE( idata = si->CreateUncachedItemDataL(
       
  2157                     KAknsIIDQsnFrStatusFlat, EAknsITImageTable ) );
       
  2158                 }
       
  2159 
       
  2160             if ( idata ) // 9 piece frame used
       
  2161                 {
       
  2162                 if ( aLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE )
       
  2163                     {
       
  2164                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2165                                                KAknsIIDQsnBgScreenIdle );
       
  2166                     }
       
  2167                 else if ( aCbaBgID == KAknsIIDQsnBgAreaControlMp )
       
  2168                     {
       
  2169                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2170                                                KAknsIIDQsnBgScreenMp );
       
  2171                     }
       
  2172                 else
       
  2173                     {
       
  2174                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2175                                                KAknsIIDQsnBgScreen );
       
  2176                     }
       
  2177                 aBgContext->SetLayerRect( ELayerFlatBackground, screen );
       
  2178 
       
  2179                 TAknWindowLineLayout layout( AknLayoutScalable_Avkon::bg_status_flat_pane_g2().LayoutLine() );
       
  2180                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2181                 aBgContext->SetLayerImage( ELayerFlatTl, KAknsIIDQsnFrStatusFlatCornerTl );
       
  2182                 aBgContext->SetLayerRect( ELayerFlatTl, layoutRect.Rect() );
       
  2183 
       
  2184                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g3().LayoutLine();
       
  2185                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2186                 aBgContext->SetLayerImage( ELayerFlatTr, KAknsIIDQsnFrStatusFlatCornerTr );
       
  2187                 aBgContext->SetLayerRect( ELayerFlatTr, layoutRect.Rect());
       
  2188 
       
  2189                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g4().LayoutLine();
       
  2190                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2191                 aBgContext->SetLayerImage( ELayerFlatBl, KAknsIIDQsnFrStatusFlatCornerBl );
       
  2192                 aBgContext->SetLayerRect( ELayerFlatBl, layoutRect.Rect() );
       
  2193 
       
  2194                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g5().LayoutLine();
       
  2195                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2196                 aBgContext->SetLayerImage( ELayerFlatBr, KAknsIIDQsnFrStatusFlatCornerBr );
       
  2197                 aBgContext->SetLayerRect( ELayerFlatBr, layoutRect.Rect() );
       
  2198 
       
  2199                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g6().LayoutLine();
       
  2200                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2201                 aBgContext->SetLayerImage( ELayerFlatT,  KAknsIIDQsnFrStatusFlatSideT);
       
  2202                 aBgContext->SetLayerRect( ELayerFlatT, layoutRect.Rect() );
       
  2203 
       
  2204                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g7().LayoutLine();
       
  2205                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2206                 aBgContext->SetLayerImage( ELayerFlatB, KAknsIIDQsnFrStatusFlatSideB );
       
  2207                 aBgContext->SetLayerRect( ELayerFlatB, layoutRect.Rect() );
       
  2208 
       
  2209                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g9().LayoutLine();
       
  2210                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2211                 aBgContext->SetLayerImage( ELayerFlatR, KAknsIIDQsnFrStatusFlatSideR );
       
  2212                 aBgContext->SetLayerRect( ELayerFlatR, layoutRect.Rect() );
       
  2213 
       
  2214                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g8().LayoutLine();
       
  2215                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2216                 aBgContext->SetLayerImage( ELayerFlatL, KAknsIIDQsnFrStatusFlatSideL );
       
  2217                 aBgContext->SetLayerRect( ELayerFlatL, layoutRect.Rect() );
       
  2218 
       
  2219                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g1().LayoutLine();
       
  2220                 layoutRect.LayoutRect( wideSPRect, layout );
       
  2221                 aBgContext->SetLayerImage( ELayerFlatCenter, KAknsIIDQsnFrStatusFlatCenter );
       
  2222                 aBgContext->SetLayerRect( ELayerFlatCenter, layoutRect.Rect() );
       
  2223 
       
  2224                 delete idata;
       
  2225                 }
       
  2226             else
       
  2227                 {
       
  2228                 aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2229                                            KAknsIIDQsnFrStatusFlat );
       
  2230                 aBgContext->SetLayerRect( ELayerFlatBackground,
       
  2231                                           wideSPRect );
       
  2232                 }
       
  2233 
       
  2234             break;
       
  2235             }
       
  2236 
       
  2237         case R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT:
       
  2238         case R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT: // fallthrough
       
  2239             {
       
  2240             TBool idleLayout =
       
  2241                 aLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT;
       
  2242 
       
  2243             TAknLayoutRect flatWideStatusPane;
       
  2244             flatWideStatusPane.LayoutRect(
       
  2245                 application_window,
       
  2246                 DoCompose( AknLayoutScalable_Avkon::area_top_pane( 19 ),
       
  2247                            AknLayoutScalable_Avkon::status_pane( 4 ) ).LayoutLine() );
       
  2248             TRect spRect( flatWideStatusPane.Rect() );
       
  2249 
       
  2250             if ( idleLayout )
       
  2251                 {
       
  2252                 aBgContext->SetLayerImage( ELayerFlatWallpaper, KAknsIIDWallpaper );
       
  2253                 aBgContext->SetLayerRect( ELayerFlatWallpaper, screen );
       
  2254                 maskIID  = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  2255                 maskRect = spRect;
       
  2256                 }
       
  2257 
       
  2258             aBgContext->SetLayerImage( ELayerFlatMain, KAknsIIDNone );
       
  2259 
       
  2260             aBgContext->SetLayerImage( ELayerFlatCba, KAknsIIDNone );
       
  2261 
       
  2262             MAknsSkinInstance* si = AknsUtils::SkinInstance();
       
  2263             CAknsItemData* idata = NULL;
       
  2264             if ( si )
       
  2265                 {
       
  2266                 TRAP_IGNORE(
       
  2267                     idata = si->CreateUncachedItemDataL( KAknsIIDQsnFrStatusFlat,
       
  2268                                                          EAknsITImageTable ) );
       
  2269                 }
       
  2270 
       
  2271             if ( idata ) // 9 piece frame used
       
  2272                 {
       
  2273                 if ( aCbaBgID == KAknsIIDQsnBgAreaControlMp )
       
  2274                     {
       
  2275                     aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2276                                                KAknsIIDQsnBgScreenMp );
       
  2277                     }
       
  2278                 else
       
  2279                     {
       
  2280                     aBgContext->SetLayerImage(
       
  2281                         ELayerFlatBackground,
       
  2282                         idleLayout ? KAknsIIDQsnBgScreenIdle :
       
  2283                                      KAknsIIDQsnBgScreen );
       
  2284                     }
       
  2285                 aBgContext->SetLayerRect( ELayerFlatBackground, screen );
       
  2286 
       
  2287                 TAknWindowLineLayout layout( AknLayoutScalable_Avkon::bg_status_flat_pane_g2().LayoutLine() );
       
  2288                 layoutRect.LayoutRect( spRect, layout );
       
  2289                 aBgContext->SetLayerImage( ELayerFlatTl, KAknsIIDQsnFrStatusFlatCornerTl );
       
  2290                 aBgContext->SetLayerRect( ELayerFlatTl, layoutRect.Rect() );
       
  2291 
       
  2292                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g3().LayoutLine();
       
  2293                 layoutRect.LayoutRect( spRect, AknLayoutScalable_Avkon::bg_status_flat_pane_g3() );
       
  2294                 aBgContext->SetLayerImage( ELayerFlatTr, KAknsIIDQsnFrStatusFlatCornerTr );
       
  2295                 aBgContext->SetLayerRect( ELayerFlatTr, layoutRect.Rect());
       
  2296 
       
  2297                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g4().LayoutLine();
       
  2298                 layoutRect.LayoutRect( spRect, layout );
       
  2299                 aBgContext->SetLayerImage( ELayerFlatBl, KAknsIIDQsnFrStatusFlatCornerBl );
       
  2300                 aBgContext->SetLayerRect( ELayerFlatBl, layoutRect.Rect() );
       
  2301 
       
  2302                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g5().LayoutLine();
       
  2303                 layoutRect.LayoutRect( spRect, layout );
       
  2304                 aBgContext->SetLayerImage( ELayerFlatBr, KAknsIIDQsnFrStatusFlatCornerBr );
       
  2305                 aBgContext->SetLayerRect( ELayerFlatBr, layoutRect.Rect() );
       
  2306 
       
  2307                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g6().LayoutLine();
       
  2308                 layoutRect.LayoutRect( spRect, layout );
       
  2309                 aBgContext->SetLayerImage( ELayerFlatT,  KAknsIIDQsnFrStatusFlatSideT);
       
  2310                 aBgContext->SetLayerRect( ELayerFlatT, layoutRect.Rect() );
       
  2311 
       
  2312                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g7().LayoutLine();
       
  2313                 layoutRect.LayoutRect( spRect, layout );
       
  2314                 aBgContext->SetLayerImage( ELayerFlatB, KAknsIIDQsnFrStatusFlatSideB );
       
  2315                 aBgContext->SetLayerRect( ELayerFlatB, layoutRect.Rect() );
       
  2316 
       
  2317                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g9().LayoutLine();
       
  2318                 layoutRect.LayoutRect( spRect, layout );
       
  2319                 aBgContext->SetLayerImage( ELayerFlatR, KAknsIIDQsnFrStatusFlatSideR );
       
  2320                 aBgContext->SetLayerRect( ELayerFlatR, layoutRect.Rect() );
       
  2321 
       
  2322                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g8().LayoutLine();
       
  2323                 layoutRect.LayoutRect( spRect, layout );
       
  2324                 aBgContext->SetLayerImage( ELayerFlatL, KAknsIIDQsnFrStatusFlatSideL );
       
  2325                 aBgContext->SetLayerRect( ELayerFlatL, layoutRect.Rect() );
       
  2326 
       
  2327                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g1().LayoutLine();
       
  2328                 layoutRect.LayoutRect( spRect, layout );
       
  2329                 aBgContext->SetLayerImage( ELayerFlatCenter, KAknsIIDQsnFrStatusFlatCenter );
       
  2330                 aBgContext->SetLayerRect( ELayerFlatCenter, layoutRect.Rect() );
       
  2331 
       
  2332                 delete idata;
       
  2333                 }
       
  2334             else
       
  2335                 {
       
  2336                 aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2337                                            KAknsIIDQsnFrStatusFlat );
       
  2338                 aBgContext->SetLayerRect( ELayerFlatBackground, spRect );
       
  2339                 }
       
  2340 
       
  2341             break;
       
  2342             }
       
  2343 
       
  2344         case R_AVKON_WIDESCREEN_PANE_LAYOUT_USUAL_FLAT_NO_SOFTKEYS:
       
  2345         case R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS: // fallthrough
       
  2346             {
       
  2347             TBool idleLayout =
       
  2348                 aLayoutId == R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS;
       
  2349 
       
  2350             TAknLayoutRect flatWideStatusPane;
       
  2351             flatWideStatusPane.LayoutRect(
       
  2352                 application_window,
       
  2353                 DoCompose( AknLayoutScalable_Avkon::area_top_pane( 20 ),
       
  2354                            AknLayoutScalable_Avkon::status_pane( 5 ) ).LayoutLine() );
       
  2355             TRect spRect( flatWideStatusPane.Rect() );
       
  2356 
       
  2357             if ( idleLayout )
       
  2358                 {
       
  2359                 aBgContext->SetLayerImage( ELayerFlatWallpaper, KAknsIIDWallpaper );
       
  2360                 aBgContext->SetLayerRect( ELayerFlatWallpaper, screen );
       
  2361                 maskIID  = KAknsIIDQgnGrafBgLscTopMaskIcon;
       
  2362                 maskRect = spRect;
       
  2363                 }
       
  2364 
       
  2365             aBgContext->SetLayerImage( ELayerFlatMain, KAknsIIDNone );
       
  2366 
       
  2367             aBgContext->SetLayerImage( ELayerFlatCba, KAknsIIDNone );
       
  2368 
       
  2369             MAknsSkinInstance* si = AknsUtils::SkinInstance();
       
  2370             CAknsItemData* idata  = NULL;
       
  2371             if ( si )
       
  2372                 {
       
  2373                 TRAP_IGNORE(
       
  2374                     idata = si->CreateUncachedItemDataL( KAknsIIDQsnFrStatusFlat,
       
  2375                                                          EAknsITImageTable ) );
       
  2376                 }
       
  2377 
       
  2378             if ( idata ) // 9 piece frame used
       
  2379                 {
       
  2380                 aBgContext->SetLayerImage(
       
  2381                     ELayerFlatBackground,
       
  2382                     idleLayout ? KAknsIIDQsnBgScreenIdle :
       
  2383                                  KAknsIIDQsnBgScreen );
       
  2384                 aBgContext->SetLayerRect( ELayerFlatBackground, screen );
       
  2385 
       
  2386                 TAknWindowLineLayout layout( AknLayoutScalable_Avkon::bg_status_flat_pane_g2().LayoutLine() );
       
  2387                 layoutRect.LayoutRect( spRect, layout );
       
  2388                 aBgContext->SetLayerImage( ELayerFlatTl, KAknsIIDQsnFrStatusFlatCornerTl );
       
  2389                 aBgContext->SetLayerRect( ELayerFlatTl, layoutRect.Rect() );
       
  2390 
       
  2391                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g3().LayoutLine();
       
  2392                 layoutRect.LayoutRect( spRect, layout );
       
  2393                 aBgContext->SetLayerImage( ELayerFlatTr, KAknsIIDQsnFrStatusFlatCornerTr );
       
  2394                 aBgContext->SetLayerRect( ELayerFlatTr, layoutRect.Rect());
       
  2395 
       
  2396                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g4().LayoutLine();
       
  2397                 layoutRect.LayoutRect( spRect, layout );
       
  2398                 aBgContext->SetLayerImage( ELayerFlatBl, KAknsIIDQsnFrStatusFlatCornerBl );
       
  2399                 aBgContext->SetLayerRect( ELayerFlatBl, layoutRect.Rect() );
       
  2400 
       
  2401                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g5().LayoutLine();
       
  2402                 layoutRect.LayoutRect( spRect, layout );
       
  2403                 aBgContext->SetLayerImage( ELayerFlatBr, KAknsIIDQsnFrStatusFlatCornerBr );
       
  2404                 aBgContext->SetLayerRect( ELayerFlatBr, layoutRect.Rect() );
       
  2405 
       
  2406                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g6().LayoutLine();
       
  2407                 layoutRect.LayoutRect( spRect, layout );
       
  2408                 aBgContext->SetLayerImage( ELayerFlatT,  KAknsIIDQsnFrStatusFlatSideT);
       
  2409                 aBgContext->SetLayerRect( ELayerFlatT, layoutRect.Rect() );
       
  2410 
       
  2411                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g7().LayoutLine();
       
  2412                 layoutRect.LayoutRect( spRect, layout );
       
  2413                 aBgContext->SetLayerImage( ELayerFlatB, KAknsIIDQsnFrStatusFlatSideB );
       
  2414                 aBgContext->SetLayerRect( ELayerFlatB, layoutRect.Rect() );
       
  2415 
       
  2416                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g9().LayoutLine();
       
  2417                 layoutRect.LayoutRect( spRect, layout );
       
  2418                 aBgContext->SetLayerImage( ELayerFlatR, KAknsIIDQsnFrStatusFlatSideR );
       
  2419                 aBgContext->SetLayerRect( ELayerFlatR, layoutRect.Rect() );
       
  2420 
       
  2421                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g8().LayoutLine();
       
  2422                 layoutRect.LayoutRect( spRect, layout );
       
  2423                 aBgContext->SetLayerImage( ELayerFlatL, KAknsIIDQsnFrStatusFlatSideL );
       
  2424                 aBgContext->SetLayerRect( ELayerFlatL, layoutRect.Rect() );
       
  2425 
       
  2426                 layout = AknLayoutScalable_Avkon::bg_status_flat_pane_g1().LayoutLine();
       
  2427                 layoutRect.LayoutRect( spRect, layout );
       
  2428                 aBgContext->SetLayerImage( ELayerFlatCenter, KAknsIIDQsnFrStatusFlatCenter );
       
  2429                 aBgContext->SetLayerRect( ELayerFlatCenter, layoutRect.Rect() );
       
  2430 
       
  2431                 delete idata;
       
  2432                 }
       
  2433             else
       
  2434                 {
       
  2435                 aBgContext->SetLayerImage( ELayerFlatBackground,
       
  2436                                            KAknsIIDQsnFrStatusFlat );
       
  2437                 aBgContext->SetLayerRect( ELayerFlatBackground, spRect );
       
  2438                 }
       
  2439 
       
  2440             break;
       
  2441             }
       
  2442 
       
  2443         default:
       
  2444             {
       
  2445             for ( TInt n = 0; n < ELayerFlatN; n++ )
       
  2446                 {
       
  2447                 aBgContext->SetLayerImage( n, KAknsIIDNone );
       
  2448                 }
       
  2449             }
       
  2450         }
       
  2451 
       
  2452     TRAP_IGNORE( aBgContext->SetLayerMaskAndSizeL( maskIID, maskRect ) );
       
  2453     }
       
  2454 
       
  2455 
       
  2456 // ---------------------------------------------------------------------------
       
  2457 // CEikStatusPaneContainer::HandleResourceChange
       
  2458 // Handles resource change events.
       
  2459 // ---------------------------------------------------------------------------
       
  2460 //
       
  2461 void CEikStatusPaneContainer::HandleResourceChange( TInt aType )
       
  2462 	{
       
  2463 	if ( aType == KEikColorResourceChange )
       
  2464 		{
       
  2465 		Window().SetBackgroundColor(
       
  2466 		    iEikonEnv->ControlColor( EColorStatusPaneBackground, *this ) );
       
  2467         }
       
  2468 
       
  2469     if ( iControl )
       
  2470         {
       
  2471         iControl->HandleResourceChange( aType );
       
  2472         }
       
  2473     }
       
  2474 
       
  2475 
       
  2476 // ---------------------------------------------------------------------------
       
  2477 // CEikStatusPaneContainer::Draw
       
  2478 // Draws the pane.
       
  2479 // ---------------------------------------------------------------------------
       
  2480 //
       
  2481 void CEikStatusPaneContainer::Draw( const TRect& /*aRect*/ ) const
       
  2482 	{
       
  2483 	}
       
  2484 
       
  2485 
       
  2486 // ---------------------------------------------------------------------------
       
  2487 // CEikStatusPaneContainer::MopSupplyObject
       
  2488 // Supplies a contained object to the mop-chain.
       
  2489 // ---------------------------------------------------------------------------
       
  2490 //
       
  2491 TTypeUid::Ptr CEikStatusPaneContainer::MopSupplyObject( TTypeUid aId )
       
  2492     {
       
  2493     if ( aId.iUid == MAknsControlContext::ETypeId )
       
  2494         {
       
  2495         // Always return iBgContext1 to mop-chain, iBgContext2 is its parent
       
  2496         // and gets redrawn automatically.
       
  2497         return MAknsControlContext::SupplyMopObject( aId, iBgContext1 );
       
  2498         }
       
  2499     else if ( aId.iUid == CAknStatusPaneDataSubscriber::ETypeId )
       
  2500         {
       
  2501        	return aId.MakePtr( iDataSubscriber );
       
  2502         }
       
  2503 
       
  2504     return CCoeControl::MopSupplyObject( aId );
       
  2505     }
       
  2506 
       
  2507 
       
  2508 // ---------------------------------------------------------------------------
       
  2509 // CEikStatusPaneContainer::WriteInternalStateL
       
  2510 // Writes the internal state of the control and its components to aStream.
       
  2511 // Does nothing in release mode.
       
  2512 // Designed to be overidden and base called by subclasses.
       
  2513 // ---------------------------------------------------------------------------
       
  2514 //
       
  2515 #ifndef _DEBUG
       
  2516 
       
  2517 void CEikStatusPaneContainer::WriteInternalStateL( RWriteStream& ) const
       
  2518 	{
       
  2519 	}
       
  2520 
       
  2521 #else
       
  2522 
       
  2523 void CEikStatusPaneContainer::WriteInternalStateL(
       
  2524     RWriteStream& aWriteStream ) const
       
  2525 	{
       
  2526 	_LIT( KEikLitStatPnCtlStart, "<CEikStatusPaneContainer>" );
       
  2527 	_LIT( KEikLitStatPnCtlEnd,   "<\\CEikStatusPaneContainer>" );
       
  2528 	_LIT( KEikLitStatPnPane,     "<iPaneId>" );
       
  2529 	_LIT( KEikLitStatPnPaneEnd,  "<\\iPaneId>" );
       
  2530 
       
  2531 	aWriteStream << KEikLitStatPnCtlStart;
       
  2532 	aWriteStream << KEikLitStatPnPane;
       
  2533 	aWriteStream.WriteInt32L( iPaneId.iUid );
       
  2534 	aWriteStream << KEikLitStatPnPaneEnd;
       
  2535 	CCoeControl::WriteInternalStateL( aWriteStream );
       
  2536 	aWriteStream << KEikLitStatPnCtlEnd;
       
  2537 	}
       
  2538 
       
  2539 #endif // _DEBUG
       
  2540 
       
  2541 
       
  2542 // ---------------------------------------------------------------------------
       
  2543 // CEikStatusPaneContainer::SetDimmed
       
  2544 // Sets the pane dimmed/undimmed.
       
  2545 // ---------------------------------------------------------------------------
       
  2546 //
       
  2547 void CEikStatusPaneContainer::SetDimmed( TBool aDimmed )
       
  2548 	{
       
  2549 	CCoeControl::SetDimmed( aDimmed );
       
  2550 	if ( iControl )
       
  2551 	    {
       
  2552 		iControl->SetDimmed( aDimmed );
       
  2553 	    }
       
  2554 	}
       
  2555 
       
  2556 
       
  2557 
       
  2558 // ===========================================================================
       
  2559 // class CEikStatusPaneTls
       
  2560 // ===========================================================================
       
  2561 //
       
  2562 class CEikStatusPaneTls : public CCoeStatic
       
  2563 	{
       
  2564 public:
       
  2565 
       
  2566 	static void SetL( CEikStatusPaneBase& aPane );
       
  2567 	static void Remove( const CEikStatusPaneBase& aPane );
       
  2568 	static CEikStatusPaneBase* Pane();
       
  2569 
       
  2570 private:
       
  2571 
       
  2572 	inline CEikStatusPaneTls();
       
  2573 	inline static CEikStatusPaneTls* Self();
       
  2574 
       
  2575 private: // Member data.
       
  2576 
       
  2577 	CEikStatusPaneBase*	iPane;
       
  2578 	};
       
  2579 
       
  2580 // Define inlines first to ensure the compiler really inlines them.
       
  2581 
       
  2582 // ---------------------------------------------------------------------------
       
  2583 // CEikStatusPaneTls::CEikStatusPaneTls
       
  2584 // C++ constructor.
       
  2585 // ---------------------------------------------------------------------------
       
  2586 //
       
  2587 inline CEikStatusPaneTls::CEikStatusPaneTls()
       
  2588 	: CCoeStatic( KUidStatusPaneTls, CCoeStatic::EApp )
       
  2589 	{
       
  2590 	}
       
  2591 
       
  2592 // ---------------------------------------------------------------------------
       
  2593 // CEikStatusPaneTls::Self
       
  2594 // Gets the singleton instance of CEikStatusPaneTls.
       
  2595 // ---------------------------------------------------------------------------
       
  2596 //
       
  2597 inline CEikStatusPaneTls* CEikStatusPaneTls::Self()
       
  2598 	{
       
  2599 	return static_cast<CEikStatusPaneTls*>(
       
  2600 	    CCoeEnv::Static( KUidStatusPaneTls ) );
       
  2601 	}
       
  2602 
       
  2603 
       
  2604 // ---------------------------------------------------------------------------
       
  2605 // CEikStatusPaneTls::SetL
       
  2606 // Sets the status pane.
       
  2607 // ---------------------------------------------------------------------------
       
  2608 //
       
  2609 void CEikStatusPaneTls::SetL( CEikStatusPaneBase& aPane )
       
  2610 	{ // static
       
  2611 	CEikStatusPaneTls* self = CEikStatusPaneTls::Self();
       
  2612 	if ( !self )
       
  2613 		{
       
  2614 		// CCoeEnv takes ownership immediately.
       
  2615 		self = new (ELeave) CEikStatusPaneTls();
       
  2616 		}
       
  2617 	self->iPane = &aPane;
       
  2618 	}
       
  2619 
       
  2620 
       
  2621 // ---------------------------------------------------------------------------
       
  2622 // CEikStatusPaneTls::Remove
       
  2623 // Removes the current status pane.
       
  2624 // ---------------------------------------------------------------------------
       
  2625 //
       
  2626 void CEikStatusPaneTls::Remove( const CEikStatusPaneBase& aPane )
       
  2627 	{ // static
       
  2628 	CEikStatusPaneTls* self = CEikStatusPaneTls::Self();
       
  2629 	if ( self && (TInt) ( self->iPane ) == (TInt) &aPane )
       
  2630 	    {
       
  2631 		delete self;
       
  2632 	    }
       
  2633 	}
       
  2634 
       
  2635 
       
  2636 // ---------------------------------------------------------------------------
       
  2637 // CEikStatusPaneTls::Pane
       
  2638 // Returns the current status pane.
       
  2639 // ---------------------------------------------------------------------------
       
  2640 //
       
  2641 CEikStatusPaneBase* CEikStatusPaneTls::Pane()
       
  2642 	{ // static
       
  2643 	CEikStatusPaneBase* ret = NULL;
       
  2644 	CEikStatusPaneTls* self = CEikStatusPaneTls::Self();
       
  2645 	if ( self )
       
  2646 		{
       
  2647 		ret = self->iPane;
       
  2648 		}
       
  2649 	return ret;
       
  2650 	}
       
  2651 
       
  2652 
       
  2653 /**
       
  2654  * Internal extension class
       
  2655  */
       
  2656 class CEikStatusPaneBaseExtension : public CBase
       
  2657     {
       
  2658 public:
       
  2659     static CEikStatusPaneBaseExtension* NewL()
       
  2660         {
       
  2661         CEikStatusPaneBaseExtension* self =
       
  2662             new (ELeave) CEikStatusPaneBaseExtension();
       
  2663         CleanupStack::PushL( self );
       
  2664         self->ConstructL();
       
  2665         CleanupStack::Pop( self );
       
  2666         return self;
       
  2667         }
       
  2668 
       
  2669     void ConstructL()
       
  2670         {
       
  2671         iCbaBgID = KAknsIIDQsnBgAreaControl;
       
  2672         };
       
  2673 
       
  2674     ~CEikStatusPaneBaseExtension()
       
  2675         {
       
  2676         };
       
  2677 
       
  2678 public:
       
  2679 
       
  2680     /** Resource id that last has been reuqested by app using switch layout. */
       
  2681 	TInt iLastRequestedResourceId;
       
  2682 
       
  2683 	/** Resource id that last has been used in portrait mode. */
       
  2684     TInt  iLastPortraitResourceId;
       
  2685 
       
  2686     /** Resource id that last has been used in lnadscape mode. */
       
  2687     TInt iLastLandscapeResourceId;
       
  2688 
       
  2689     /** Resource id that was initally defined as default id. */
       
  2690     TInt iInitialResourceId;
       
  2691 
       
  2692     /** Status pane clearer is not used anymore. */
       
  2693     CAknStatuspaneClearer* iBlankStatuspane;
       
  2694 
       
  2695     CAknStatusPaneDataSubscriber* iDataSubscriber;
       
  2696 
       
  2697     CAknsCombinedBackgroundControlContext* iCommonBgContext;
       
  2698 
       
  2699     /** Handles switching redraw storing on and off when required. */
       
  2700     CRedrawStoreHandler* iRedrawStoreHandler;
       
  2701 
       
  2702     /** Skin background item of current CBA. */
       
  2703     TAknsItemID         iCbaBgID;
       
  2704     };
       
  2705 
       
  2706 
       
  2707 // ===========================================================================
       
  2708 // class CEikStatusPaneBase
       
  2709 // ===========================================================================
       
  2710 
       
  2711 
       
  2712 // ---------------------------------------------------------------------------
       
  2713 // CEikStatusPaneBase::~CEikStatusPaneBase
       
  2714 // Destructor.
       
  2715 // ---------------------------------------------------------------------------
       
  2716 //
       
  2717 EXPORT_C CEikStatusPaneBase::~CEikStatusPaneBase()
       
  2718 	{
       
  2719 	if ( iControls )
       
  2720 	    {
       
  2721 		iControls->ResetAndDestroy();
       
  2722 	    }
       
  2723 	delete iControls;
       
  2724 	delete iModel;
       
  2725 	if ( iExtension )
       
  2726 		{
       
  2727 		delete iExtension->iRedrawStoreHandler;
       
  2728 		delete iExtension->iBlankStatuspane;
       
  2729 		delete iExtension->iDataSubscriber;
       
  2730 		delete iExtension->iCommonBgContext;
       
  2731 		}
       
  2732     delete iExtension;
       
  2733 	CEikStatusPaneTls::Remove( *this );
       
  2734 	}
       
  2735 
       
  2736 
       
  2737 // ---------------------------------------------------------------------------
       
  2738 // CEikStatusPaneBase::Current
       
  2739 // Returns a pointer to the thread's currently active status pane
       
  2740 // without transferring ownership.  Returns NULL is no such pane exists.
       
  2741 // ---------------------------------------------------------------------------
       
  2742 //
       
  2743 EXPORT_C CEikStatusPaneBase* CEikStatusPaneBase::Current()
       
  2744 	{ // static
       
  2745 	return CEikStatusPaneTls::Pane();
       
  2746 	}
       
  2747 
       
  2748 
       
  2749 // ---------------------------------------------------------------------------
       
  2750 // CEikStatusPaneBase::SwitchLayoutL
       
  2751 // Switch to the specified status pane layout.
       
  2752 // This must be one of the layouts identified in the status pane resource
       
  2753 // structures, otherwise the function leaves KErrNotFound.
       
  2754 // ---------------------------------------------------------------------------
       
  2755 //
       
  2756 EXPORT_C void CEikStatusPaneBase::SwitchLayoutL( TInt aLayoutResourceId )
       
  2757 	{
       
  2758 	if ( !Clearer() && IsApp() )
       
  2759 		{
       
  2760 		// DrawNow because otherwise screenupdate looks ugly
       
  2761 		DoSwitchLayoutL( aLayoutResourceId, EDrawNow );
       
  2762 		}
       
  2763     else
       
  2764     	{
       
  2765 		// DrawDeferred can be used if the clearer does exist
       
  2766     	DoSwitchLayoutL( aLayoutResourceId, EDrawDeferred );
       
  2767     	}
       
  2768 
       
  2769     SetLastUsedResourceId( aLayoutResourceId );
       
  2770 	}
       
  2771 
       
  2772 
       
  2773 // ---------------------------------------------------------------------------
       
  2774 // CEikStatusPaneBase::DoSwitchLayoutL
       
  2775 // Switches the status pane layout.
       
  2776 // ---------------------------------------------------------------------------
       
  2777 //
       
  2778 void CEikStatusPaneBase::DoSwitchLayoutL( TInt aLayoutResourceId,
       
  2779                                           TDrawCmd aDraw )
       
  2780 	{
       
  2781 	TInt oldResId     = CurrentLayoutResId();
       
  2782 	TInt blankedResId = oldResId;
       
  2783 
       
  2784    	RRegion oldRegion;
       
  2785    	CleanupClosePushL( oldRegion );
       
  2786    	RRegion newRegion;
       
  2787    	CleanupClosePushL( newRegion );
       
  2788    	GetShapeL( oldRegion, ETrue, ETrue );
       
  2789 
       
  2790     TBool forcedBlank = EFalse;
       
  2791     CAknStatuspaneClearer* clearer = Clearer();
       
  2792     if ( clearer )
       
  2793     	{
       
  2794 	    // We blank even if blanking has been disabled with
       
  2795 	    // normal disable level.
       
  2796 	    if ( clearer->BlankDisabled() == EBlankDisableLevelNormal )
       
  2797 	    	{
       
  2798 	    	clearer->EnableBlank();
       
  2799 	    	forcedBlank = ETrue;
       
  2800 	    	}
       
  2801     	}
       
  2802 
       
  2803 
       
  2804     // If AknLayout system is used for placing statuspane elements, then
       
  2805     // we need to be less strict when new layout is applied or size change
       
  2806     // is reported. This is because AknLayout data may change even when
       
  2807     // statuspane layout id doesn't e.g. in dynamic variant changes etc.
       
  2808     // So we check here first if either new or old one is using AknLayout.
       
  2809     TBool aknLayoutUsed = iModel->AknLayoutUsed( aLayoutResourceId ) ||
       
  2810                           iModel->AknLayoutUsed( CurrentLayoutResId() );
       
  2811 
       
  2812 	CEikStatusPaneLayout* oldLayout = iModel->CurrentLayout();
       
  2813 	TRect oldRect = Rect();
       
  2814     if ( IsApp() )
       
  2815         {
       
  2816         CEikAppStatusPaneModel* appModel =
       
  2817             static_cast<CEikAppStatusPaneModel*> ( iModel );
       
  2818         // This does not update serverside, we later at better time ourself call
       
  2819         // CAknSgcClient::HandleChangeL()
       
  2820         appModel->SetLayoutL( aLayoutResourceId, ETrue, EFalse );
       
  2821         }
       
  2822     else
       
  2823         {
       
  2824         // On server side we do this normally.
       
  2825         iModel->SetLayoutL( aLayoutResourceId, OkToChangeStatusPaneNow() );
       
  2826         }
       
  2827 
       
  2828 	CEikStatusPaneLayout* newLayout = iModel->CurrentLayout();
       
  2829 	if ( newLayout != oldLayout || aknLayoutUsed )
       
  2830 		{
       
  2831 		// Need to refresh the model's layout.
       
  2832 	    iModel->AknLayoutRefresh();
       
  2833 
       
  2834         TBool drawNavi = ETrue;
       
  2835 
       
  2836 		if ( clearer )
       
  2837 			{
       
  2838 			// Before we do the layout switch, we create a blank window to cover
       
  2839     		// the non-syncronized layout transformation. This should make layout
       
  2840     		// swithces look a bit smoother.
       
  2841     	    //
       
  2842 		    if ( !clearer->BlankDisabled() )
       
  2843 	            {
       
  2844 	            TBool newBoundingRectIsLarger = ETrue;
       
  2845 
       
  2846 	        	GetShapeL( newRegion, ETrue, ETrue );
       
  2847 
       
  2848                 TRect newBoundingRect( newRegion.BoundingRect() );
       
  2849                 TRect oldBoundingRect( oldRegion.BoundingRect() );
       
  2850 
       
  2851 	            newBoundingRectIsLarger =
       
  2852 	                ( newBoundingRect.Size().iHeight * newRegion.BoundingRect().Size().iWidth >=
       
  2853 	                  oldBoundingRect.Size().iHeight * oldRegion.BoundingRect().Size().iWidth );
       
  2854 
       
  2855 				// If new rect is much smaller than the old, then
       
  2856 				// we don't want to draw navi graphics in the blanker.
       
  2857 	            drawNavi =
       
  2858 	                ( newBoundingRect.Size().iHeight >
       
  2859 	                  ( oldBoundingRect.Size().iHeight / 2 ) );
       
  2860 
       
  2861 	    	    // First select better layout that is used for blanking.
       
  2862 	            if ( ( newBoundingRectIsLarger &&
       
  2863 	                   ( IsApp() ||
       
  2864 	                     forcedBlank ||
       
  2865 	                     oldBoundingRect.Size() == TSize(0,0) ) ) )
       
  2866 	                {
       
  2867 	                blankedResId = CurrentLayoutResId();
       
  2868 	    		    OptimizeClearerWindowShape( oldResId,
       
  2869 	    		                                CurrentLayoutResId(),
       
  2870 	    		                                newRegion );
       
  2871 	    		    clearer->SetShape( newRegion );
       
  2872 	                }
       
  2873 	            else
       
  2874 	                {
       
  2875 	                blankedResId = oldResId;
       
  2876 	    		    OptimizeClearerWindowShape( oldResId,
       
  2877 	    		                                CurrentLayoutResId(),
       
  2878 	    		                                oldRegion);
       
  2879 	    		    clearer->SetShape( oldRegion );
       
  2880 	                }
       
  2881 
       
  2882 	            clearer->SetSkinBackgroundContext( blankedResId, drawNavi );
       
  2883 	            clearer->SetOrdinalPosition( 0 );
       
  2884 
       
  2885 	            if ( IsApp() )
       
  2886 	                {
       
  2887 	                // timeout for serverside app
       
  2888 	    	        //clearer->Blank(KDefaultUnblankTimeout*3);
       
  2889 	    	        clearer->Blank( KDefaultUnblankTimeout );
       
  2890 	                }
       
  2891 	            else
       
  2892 	                {
       
  2893 	                // little longer timeout for serverside
       
  2894 	    	        //clearer->Blank(KDefaultUnblankTimeout*5);
       
  2895 	    	        clearer->Blank( KDefaultUnblankTimeout * 2 );
       
  2896 	                }
       
  2897 	            }
       
  2898 			}
       
  2899 
       
  2900 
       
  2901         // Update serverside model (SetLayoutL)
       
  2902         if ( IsApp() )
       
  2903         	{
       
  2904         	CAknSgcClient::HandleChangeL();
       
  2905         	}
       
  2906 
       
  2907         // Trapped, so that we can always reset the blank window...
       
  2908 		TRAP_IGNORE( ApplyLayoutL( newLayout, aDraw ) );
       
  2909 
       
  2910 
       
  2911 		if ( oldRect != Rect() || aknLayoutUsed )
       
  2912 			{
       
  2913 			ReportSizeChange();
       
  2914 			}
       
  2915 
       
  2916 	    // Reset blank window shape and skin context
       
  2917         if ( clearer && !clearer->BlankDisabled() && !IsApp() )
       
  2918         	{
       
  2919    		    OptimizeClearerWindowShape( oldResId,
       
  2920    		                                CurrentLayoutResId(),
       
  2921    		                                newRegion );
       
  2922             clearer->SetShape( newRegion );
       
  2923             clearer->SetSkinBackgroundContext( CurrentLayoutResId(),
       
  2924                                                drawNavi );
       
  2925 			clearer->DrawNow();
       
  2926         	}
       
  2927 		}
       
  2928 
       
  2929    	CleanupStack::PopAndDestroy( 2, &oldRegion ); // close shapes
       
  2930 
       
  2931    	CAknStatusPaneDataSubscriber* subscriber = DataSubscriber();
       
  2932    	if ( subscriber )
       
  2933    		{
       
  2934    		subscriber->RefreshDataL();
       
  2935    		}
       
  2936 	}
       
  2937 
       
  2938 
       
  2939 // ---------------------------------------------------------------------------
       
  2940 // CEikStatusPaneBase::PaneRectL
       
  2941 // Provides the screen rectangle of a sub-pane.
       
  2942 // This can be used to set the size of a new control which you
       
  2943 // want to place in the status pane.
       
  2944 // This will leave with KErrNotFound if the pane ID is not valid.
       
  2945 // ---------------------------------------------------------------------------
       
  2946 //
       
  2947 EXPORT_C TRect CEikStatusPaneBase::PaneRectL( TPaneId aPaneId ) const
       
  2948 	{
       
  2949 	CEikStatusPaneLayoutTree* pane = iModel->CurrentLayout()->Find( aPaneId );
       
  2950 	if ( !pane )
       
  2951 		{
       
  2952 		User::Leave( KErrNotFound );
       
  2953 		}
       
  2954 	return pane->Rect();
       
  2955 	}
       
  2956 
       
  2957 
       
  2958 // ---------------------------------------------------------------------------
       
  2959 // CEikStatusPaneBase::ControlL
       
  2960 // Provides the control currently inside a sub-pane.
       
  2961 // This gives the application direct access to the contents of a pane.
       
  2962 // This will leave with KErrNotFound if the pane ID is not valid.
       
  2963 // ---------------------------------------------------------------------------
       
  2964 //
       
  2965 EXPORT_C CCoeControl* CEikStatusPaneBase::ControlL( TPaneId aPaneId ) const
       
  2966 	{
       
  2967 	CEikStatusPaneContainer* cont = Find( aPaneId );
       
  2968 	if ( !cont )
       
  2969 		{
       
  2970 		User::Leave( KErrNotFound );
       
  2971 		}
       
  2972 	return cont->Control();
       
  2973 	}
       
  2974 
       
  2975 
       
  2976 // ---------------------------------------------------------------------------
       
  2977 // CEikStatusPaneBase::SwapControlL
       
  2978 // Swaps the control currently inside a sub-pane.
       
  2979 // The new control must be a fully constructed control.
       
  2980 // It will be placed inside the status pane, and the current content
       
  2981 // will be returned to the caller.
       
  2982 // This will leave with KErrNotFound if the pane ID is not valid.
       
  2983 // ---------------------------------------------------------------------------
       
  2984 //
       
  2985 EXPORT_C CCoeControl* CEikStatusPaneBase::SwapControlL(
       
  2986     TPaneId aPaneId, CCoeControl* aNewControl )
       
  2987 	{
       
  2988 	CEikStatusPaneContainer* cont = Find( aPaneId );
       
  2989 	if ( !cont )
       
  2990 		{
       
  2991 		User::Leave( KErrNotFound );
       
  2992 		}
       
  2993 
       
  2994 	CCoeControl* oldControl = cont->Control();
       
  2995 	cont->SetControl( aNewControl );
       
  2996 
       
  2997 	return oldControl;
       
  2998 	}
       
  2999 
       
  3000 
       
  3001 // ---------------------------------------------------------------------------
       
  3002 // CEikStatusPaneBase::ContainerControlL
       
  3003 // Provides access to the container control for a sub-pane.
       
  3004 // You will need access to the container control for a sub-pane if you want to
       
  3005 // swap in a new control. The container control should be set as the parent
       
  3006 // window of the new control.
       
  3007 // NB. It also provides a fast way to get the rectangle of the
       
  3008 // sub-pane (see PaneRect()).
       
  3009 // This will leave with KErrNotFound if the pane ID is not valid.
       
  3010 // ---------------------------------------------------------------------------
       
  3011 //
       
  3012 EXPORT_C CCoeControl* CEikStatusPaneBase::ContainerControlL(
       
  3013     TPaneId aPaneId ) const
       
  3014 	{
       
  3015 	CEikStatusPaneContainer* cont = Find( aPaneId );
       
  3016 	if ( !cont )
       
  3017 		{
       
  3018 		User::Leave( KErrNotFound );
       
  3019 		}
       
  3020 	return cont;
       
  3021 	}
       
  3022 
       
  3023 
       
  3024 // ---------------------------------------------------------------------------
       
  3025 // CEikStatusPaneBase::CEikStatusPaneBase
       
  3026 // C++ constructor.
       
  3027 // ---------------------------------------------------------------------------
       
  3028 //
       
  3029 EXPORT_C CEikStatusPaneBase::CEikStatusPaneBase( CEikonEnv& aEikEnv,
       
  3030                                                  RWindowGroup* aParent )
       
  3031     : iEikEnv( aEikEnv ),
       
  3032       iFlags( KEikStatusPaneBaseVisibleBit ),
       
  3033       iParentWindowGroup( aParent )
       
  3034 	{
       
  3035 	}
       
  3036 
       
  3037 
       
  3038 // ---------------------------------------------------------------------------
       
  3039 // CEikStatusPaneBase::BaseConstructL
       
  3040 // Second-phase base constructor.
       
  3041 // ---------------------------------------------------------------------------
       
  3042 //
       
  3043 EXPORT_C void CEikStatusPaneBase::BaseConstructL( TInt aCoreResId )
       
  3044 	{
       
  3045 	CEikStatusPaneTls::SetL( *this );
       
  3046 
       
  3047     iExtension = CEikStatusPaneBaseExtension::NewL();
       
  3048 
       
  3049 	if ( IsApp() )
       
  3050 		{
       
  3051 		iExtension->iDataSubscriber = CAknStatusPaneDataSubscriber::NewL();
       
  3052 		}
       
  3053 
       
  3054     // Create a combined background context and two sub-contextes;
       
  3055     // one for stacon top and another for stacon bottom.
       
  3056     iExtension->iCommonBgContext =
       
  3057         CAknsCombinedBackgroundControlContext::NewL( ETrue );
       
  3058 
       
  3059     CAknsMaskedLayerBackgroundControlContext* staconTop =
       
  3060         CAknsMaskedLayerBackgroundControlContext::NewL(
       
  3061             KAknsIIDWallpaper, TRect(0,0,1,1), ETrue, ELayerFlatN );
       
  3062     CleanupStack::PushL( staconTop );
       
  3063     iExtension->iCommonBgContext->AddControlContext( staconTop );
       
  3064     CleanupStack::Pop( staconTop ); // ownership transferred
       
  3065 
       
  3066     CAknsMaskedLayerBackgroundControlContext* staconBottom =
       
  3067         CAknsMaskedLayerBackgroundControlContext::NewL(
       
  3068             KAknsIIDWallpaper, TRect(0,0,1,1), ETrue, ELayerFlatN );
       
  3069     CleanupStack::PushL( staconBottom );
       
  3070     iExtension->iCommonBgContext->AddControlContext( staconBottom );
       
  3071 
       
  3072     // Set stacon bottom as parent for stacon top.
       
  3073     // this is needed as top needs to be drawn when bottom is drawn.
       
  3074     staconTop->SetParentContext( staconBottom );
       
  3075     CleanupStack::Pop( staconBottom ); // ownership transferred
       
  3076 
       
  3077     iExtension->iRedrawStoreHandler = new (ELeave) CRedrawStoreHandler;
       
  3078     iExtension->iRedrawStoreHandler->ConstructL();
       
  3079 
       
  3080 	iModel = CreateModelL( aCoreResId );
       
  3081 	iControls =
       
  3082 	    new (ELeave) CContainerControls( KEikStatusPaneControlGranularity );
       
  3083 	CreatePanesL();
       
  3084 	ApplyLayoutL( iModel->CurrentLayout(), ENoDraw );
       
  3085 
       
  3086 	// Clearer is not needed anymore if all panes are drawn in app side.
       
  3087 	//iExtension->iBlankStatuspane = CAknStatuspaneClearer::NewL(*iParentWindowGroup, 0, !IsApp());
       
  3088     //iExtension->iBlankStatuspane->SetSkinBackgroundContext(CurrentLayoutResId());
       
  3089 
       
  3090 	SetInitialUsedResourceId(ReadInitialUsedResourceIdL( aCoreResId ) );
       
  3091     }
       
  3092 
       
  3093 
       
  3094 // ---------------------------------------------------------------------------
       
  3095 // CEikStatusPaneBase::CreatePanesL
       
  3096 // Creates all the sub-panes in the current layout.
       
  3097 // ---------------------------------------------------------------------------
       
  3098 //
       
  3099 void CEikStatusPaneBase::CreatePanesL()
       
  3100 	{
       
  3101 	CEikStatusPaneSetInit* inits = iModel->PaneInits();
       
  3102 	const TInt count = inits->Count();
       
  3103 	for ( TInt ii = 0; ii < count; ++ii )
       
  3104 		{
       
  3105 		TEikStatusPaneInit& init = inits->At( ii );
       
  3106 		if ( COMPARE_BOOLS( init.AppOwned(), IsApp() ) )
       
  3107 			{
       
  3108 			CreatePaneL( init );
       
  3109 			}
       
  3110 		}
       
  3111 	}
       
  3112 
       
  3113 
       
  3114 // ---------------------------------------------------------------------------
       
  3115 // CEikStatusPaneBase::CreatePaneL
       
  3116 // Creates a sub-pane.
       
  3117 // ---------------------------------------------------------------------------
       
  3118 //
       
  3119 void CEikStatusPaneBase::CreatePaneL( const TEikStatusPaneInit& aPaneInit )
       
  3120     {
       
  3121     CEikStatusPaneContainer* cont = CEikStatusPaneContainer::NewL(
       
  3122         aPaneInit.Id(),
       
  3123         aPaneInit.ControlTypeId(),
       
  3124         aPaneInit.ControlResourceId(),
       
  3125         iParentWindowGroup,
       
  3126         static_cast<CAknsMaskedLayerBackgroundControlContext*>(
       
  3127             iExtension->iCommonBgContext->GetControlContext( 0 ) ),
       
  3128         static_cast<CAknsMaskedLayerBackgroundControlContext*>(
       
  3129             iExtension->iCommonBgContext->GetControlContext( 1 ) ),
       
  3130         iExtension->iDataSubscriber,
       
  3131         *iExtension->iRedrawStoreHandler );
       
  3132     CleanupStack::PushL( cont );
       
  3133     iControls->AppendL( cont );
       
  3134     CleanupStack::Pop( cont );
       
  3135     }
       
  3136 
       
  3137 
       
  3138 // ---------------------------------------------------------------------------
       
  3139 // CEikStatusPaneBase::ApplyLayoutL
       
  3140 // Applies a status pane layout.
       
  3141 // ---------------------------------------------------------------------------
       
  3142 //
       
  3143 void CEikStatusPaneBase::ApplyLayoutL( CEikStatusPaneLayout* aLayout,
       
  3144                                        TDrawCmd aDraw )
       
  3145     {
       
  3146     // We don't set all invisible, only not needed ones to avoid flicker.
       
  3147     SetNotNeededInvisible();
       
  3148 
       
  3149     // Background layouts must be updated before AcceptL is called,
       
  3150     // otherwise the change will not be available for controls in SizeChanged
       
  3151     TInt layoutResId = CurrentLayoutResId();
       
  3152 
       
  3153     MAknsControlContext* partOfCombinedContext =
       
  3154         iExtension->iCommonBgContext->GetControlContext( 0 );
       
  3155 
       
  3156     CEikStatusPaneContainer::PrepareBackgroundContext(
       
  3157         static_cast<CAknsMaskedLayerBackgroundControlContext*>(partOfCombinedContext),
       
  3158         layoutResId,
       
  3159         ETrue,
       
  3160         0,
       
  3161         iExtension->iCbaBgID );
       
  3162 
       
  3163      // In stacon, make a second prepare and draw. This is due to that stacon
       
  3164     // has two background contextes.
       
  3165     if ( ( layoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_LEFT ||
       
  3166            layoutResId == R_AVKON_STACON_PANE_LAYOUT_IDLE_SOFTKEYS_RIGHT ||
       
  3167            layoutResId == R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ) )
       
  3168         {
       
  3169         partOfCombinedContext =
       
  3170             iExtension->iCommonBgContext->GetControlContext( 1 );
       
  3171 
       
  3172         CEikStatusPaneContainer::PrepareBackgroundContext(
       
  3173             static_cast<CAknsMaskedLayerBackgroundControlContext*>(partOfCombinedContext),
       
  3174             layoutResId,
       
  3175             ETrue,
       
  3176             1,
       
  3177             iExtension->iCbaBgID );
       
  3178         }
       
  3179 
       
  3180 	TSetRectAndVisibility vis( IsApp(), this );
       
  3181 	aLayout->AcceptL( &vis );
       
  3182 
       
  3183 	DoDrawNow( aDraw );
       
  3184 	}
       
  3185 
       
  3186 
       
  3187 // ---------------------------------------------------------------------------
       
  3188 // CEikStatusPaneBase::SetAllInvisible
       
  3189 // Sets all sub-panes non-visible.
       
  3190 // ---------------------------------------------------------------------------
       
  3191 //
       
  3192 void CEikStatusPaneBase::SetAllInvisible()
       
  3193 	{
       
  3194 	const TInt count = iControls->Count();
       
  3195 	for ( TInt ii = 0; ii < count; ++ii )
       
  3196 		{
       
  3197 		iControls->At( ii )->MakeVisible( EFalse );
       
  3198 		}
       
  3199 	}
       
  3200 
       
  3201 
       
  3202 // ---------------------------------------------------------------------------
       
  3203 // CEikStatusPaneBase::SetNotNeededInvisible
       
  3204 // Sets the sub-panes that are not needed non-visible.
       
  3205 // ---------------------------------------------------------------------------
       
  3206 //
       
  3207 void CEikStatusPaneBase::SetNotNeededInvisible()
       
  3208     {
       
  3209 	const TInt c = iControls->Count();
       
  3210 	TEikStatusPaneInit init;
       
  3211 	for ( TInt ii = 0; ii < c; ++ii )
       
  3212 		{
       
  3213 		TPaneId theid = iControls->At( ii )->Id();
       
  3214 		if ( iModel->CurrentLayout()->Find( theid ) == NULL )
       
  3215 		    {
       
  3216     		iControls->At( ii )->MakeVisible( EFalse );
       
  3217 		    }
       
  3218 		}
       
  3219     }
       
  3220 
       
  3221 
       
  3222 // ---------------------------------------------------------------------------
       
  3223 // CEikStatusPaneBase::SetStoreHandler
       
  3224 // Sets the redraw storing on/off.
       
  3225 // ---------------------------------------------------------------------------
       
  3226 //
       
  3227 void CEikStatusPaneBase::SetStoreHandler( RWindow* aWindow, TBool aOn )
       
  3228 	{
       
  3229 	iExtension->iRedrawStoreHandler->SetStore( aWindow, aOn );
       
  3230 	}
       
  3231 
       
  3232 
       
  3233 // ---------------------------------------------------------------------------
       
  3234 // CEikStatusPaneBase::DrawNow
       
  3235 // Draws the status pane immediately.
       
  3236 // ---------------------------------------------------------------------------
       
  3237 //
       
  3238 EXPORT_C void CEikStatusPaneBase::DrawNow()
       
  3239 	{
       
  3240 	DoDrawNow( EDrawNow );
       
  3241 	}
       
  3242 
       
  3243 
       
  3244 // ---------------------------------------------------------------------------
       
  3245 // CEikStatusPaneBase::DoDrawNow
       
  3246 // Draws the status pane with specified command.
       
  3247 // ---------------------------------------------------------------------------
       
  3248 //
       
  3249 void CEikStatusPaneBase::DoDrawNow( TDrawCmd aDraw )
       
  3250 	{
       
  3251 	if ( aDraw == ENoDraw )
       
  3252 		{
       
  3253 		return;
       
  3254 		}
       
  3255 
       
  3256 	const TInt count = iControls->Count();
       
  3257 	for ( TInt ii = 0; ii < count; ++ii )
       
  3258 		{
       
  3259 		CCoeControl* control = iControls->At( ii );
       
  3260 		if ( aDraw == EDrawNow )
       
  3261 		    {
       
  3262 			control->DrawNow();
       
  3263 		    }
       
  3264 		else
       
  3265 		    {
       
  3266 			control->DrawDeferred();
       
  3267 		    }
       
  3268 		}
       
  3269 	}
       
  3270 
       
  3271 
       
  3272 // ---------------------------------------------------------------------------
       
  3273 // CEikStatusPaneBase::OptimizeClearerWindowShape
       
  3274 // Optimizes the status pane blanker shape.
       
  3275 // ---------------------------------------------------------------------------
       
  3276 //
       
  3277 void CEikStatusPaneBase::OptimizeClearerWindowShape( TInt aOldResourceId,
       
  3278                                                      TInt aNewResourceId,
       
  3279                                                      TRegion& aRegion)
       
  3280 	{
       
  3281 	CEikStatusPaneSetInit* inits = iModel->PaneInits();
       
  3282 	CEikStatusPaneLayout* layout = iModel->CurrentLayout();
       
  3283 	const TInt count = inits->Count();
       
  3284 	for ( TInt ii = 0; ii < count; ++ii )
       
  3285 		{
       
  3286 		TEikStatusPaneInit& init = inits->At( ii );
       
  3287 		TPaneId theid            = init.Id();
       
  3288         TRect oldRect( layout->AknLayoutRect( aOldResourceId, theid ) );
       
  3289         TRect newRect( layout->AknLayoutRect( aNewResourceId, theid ) );
       
  3290    		if ( oldRect == newRect &&
       
  3291    		     newRect != TRect( 0, 0, 0, 0 ) &&
       
  3292    		     oldRect != TRect( 0, 0, 0, 0 ) )
       
  3293    			{
       
  3294    			aRegion.SubRect( newRect );
       
  3295    			}
       
  3296 		}
       
  3297 	}
       
  3298 
       
  3299 
       
  3300 // ---------------------------------------------------------------------------
       
  3301 // CEikStatusPaneBase::SetCbaAreaBackgroundID
       
  3302 // Sets the current CBA area skin background ID.
       
  3303 // ---------------------------------------------------------------------------
       
  3304 //
       
  3305 void CEikStatusPaneBase::SetCbaAreaBackgroundID( const TAknsItemID& aBgID,
       
  3306                                                  TDrawCmd aDrawCmd )
       
  3307     {
       
  3308     if ( iExtension->iCbaBgID != aBgID )
       
  3309         {
       
  3310         TInt contextCount = 0;
       
  3311         // Get first part of combination.
       
  3312         MAknsControlContext* partOfCombinedContext =
       
  3313             static_cast<CAknsCombinedBackgroundControlContext*>(
       
  3314                 iExtension->iCommonBgContext)->GetControlContext( contextCount );
       
  3315 
       
  3316         // While there are parts, fetch them and prepare each separately.
       
  3317         while ( partOfCombinedContext )
       
  3318             {
       
  3319             CEikStatusPaneContainer::PrepareBackgroundContext(
       
  3320                 static_cast<CAknsMaskedLayerBackgroundControlContext*>(partOfCombinedContext),
       
  3321                 CurrentLayoutResId(),
       
  3322                 ETrue,
       
  3323                 contextCount,
       
  3324                 aBgID );
       
  3325 
       
  3326             partOfCombinedContext =
       
  3327                 static_cast<CAknsCombinedBackgroundControlContext*>(
       
  3328                     iExtension->iCommonBgContext)->GetControlContext( ++contextCount );
       
  3329             }
       
  3330 
       
  3331 
       
  3332         iExtension->iCbaBgID = aBgID;
       
  3333 
       
  3334         DoDrawNow( aDrawCmd );
       
  3335         }
       
  3336     }
       
  3337 
       
  3338 
       
  3339 // ---------------------------------------------------------------------------
       
  3340 // CEikStatusPaneBase::CbaAreaBackgroundID
       
  3341 // Gets the current CBA area skin background ID.
       
  3342 // ---------------------------------------------------------------------------
       
  3343 //
       
  3344 TAknsItemID CEikStatusPaneBase::CbaAreaBackgroundID()
       
  3345     {
       
  3346     return iExtension->iCbaBgID;
       
  3347     }
       
  3348 
       
  3349 
       
  3350 // ---------------------------------------------------------------------------
       
  3351 // CEikStatusPaneBase::Find
       
  3352 // Returns a sub-pane container by the specified sub-pane ID.
       
  3353 // ---------------------------------------------------------------------------
       
  3354 //
       
  3355 CEikStatusPaneContainer* CEikStatusPaneBase::Find( TPaneId aPaneId ) const
       
  3356 	{
       
  3357 	CEikStatusPaneContainer* ctrl = NULL;
       
  3358 
       
  3359 	const TInt count = iControls->Count();
       
  3360 	for ( TInt ii = 0; ii < count; ++ii )
       
  3361 		{
       
  3362 		ctrl = iControls->At( ii );
       
  3363 		if ( ctrl->Id() == aPaneId )
       
  3364 			{
       
  3365 			break;
       
  3366 			}
       
  3367 		}
       
  3368 
       
  3369 	return ctrl;
       
  3370 	}
       
  3371 
       
  3372 
       
  3373 // ---------------------------------------------------------------------------
       
  3374 // CEikStatusPaneBase::ReduceRect
       
  3375 // Modifies the bounding rectangle passed in so that it lies next to the
       
  3376 // status pane rectangle.
       
  3377 // The status pane always places itself along the edge of the screen, so that
       
  3378 // it is consistent across applications and the server. It is assumed that the
       
  3379 // bounding rectangle passed in does not extend beyond the screen area.
       
  3380 // ---------------------------------------------------------------------------
       
  3381 //
       
  3382 EXPORT_C void CEikStatusPaneBase::ReduceRect( TRect& aBoundingRect ) const
       
  3383 	{
       
  3384 	if ( !IsVisible() )
       
  3385 		{
       
  3386 		return;
       
  3387 		}
       
  3388 
       
  3389     // If Aknlayout is used, the shape of statuspane can be complex.
       
  3390     if (iModel->AknLayoutUsed( CurrentLayoutResId() ) )
       
  3391         {
       
  3392         // TODO: This "algorithm" should still be improved,
       
  3393         // it does not always find the right solution.
       
  3394         RRegion statusPaneRegion;
       
  3395         RRegion boundingRegion;
       
  3396         TRect boundingRect( aBoundingRect );
       
  3397 
       
  3398         boundingRegion.AddRect( boundingRect );
       
  3399 
       
  3400         // Read statuspane shape
       
  3401         TRAP_IGNORE( GetShapeL( statusPaneRegion, ETrue, ETrue ) );
       
  3402         statusPaneRegion.Tidy();
       
  3403 
       
  3404         // Get largest possible rect that does not overlap with sp shape
       
  3405         TRect largestBoundingRect(
       
  3406             LargestBoundingRect( boundingRegion, statusPaneRegion ) );
       
  3407 
       
  3408         // Now, lets try to rotate all rects, we may find larger
       
  3409         // bounding rect that way.
       
  3410         RRegion rotatedBoundingRegion;
       
  3411 
       
  3412         // Rotate bounding region.
       
  3413         rotatedBoundingRegion.AddRect(
       
  3414             TRect( boundingRect.iTl.iY,
       
  3415                    boundingRect.iTl.iX,
       
  3416                    boundingRect.iBr.iY,
       
  3417                    boundingRect.iBr.iX ) );
       
  3418 
       
  3419         // Construct a statuspane shape region which has rects rotated.
       
  3420         RRegion rotatedStatusPaneRegion;
       
  3421         TInt count = statusPaneRegion.Count();
       
  3422         for ( TInt i = 0; i < count; i++ )
       
  3423             {
       
  3424             rotatedStatusPaneRegion.AddRect(
       
  3425                 TRect( statusPaneRegion[i].iTl.iY,
       
  3426                        statusPaneRegion[i].iTl.iX,
       
  3427                        statusPaneRegion[i].iBr.iY,
       
  3428                        statusPaneRegion[i].iBr.iX ) );
       
  3429             }
       
  3430 
       
  3431         // Get largest possible rect that does not overlap with sp shape.
       
  3432         TRect largestBoundingRectRotated(
       
  3433             LargestBoundingRect( rotatedBoundingRegion,
       
  3434                                  rotatedStatusPaneRegion ) );
       
  3435 
       
  3436         rotatedStatusPaneRegion.Close();
       
  3437         rotatedBoundingRegion.Close();
       
  3438         statusPaneRegion.Close();
       
  3439         boundingRegion.Close();
       
  3440 
       
  3441         // Now check which one was larger, if it was found by rotating
       
  3442         // rects then rotate it back to real coordinates.
       
  3443         if ( largestBoundingRectRotated.Height() * largestBoundingRectRotated.Width() >=
       
  3444                  largestBoundingRect.Height() * largestBoundingRect.Width() )
       
  3445             {
       
  3446             aBoundingRect = TRect( largestBoundingRectRotated.iTl.iY,
       
  3447                                    largestBoundingRectRotated.iTl.iX,
       
  3448                                    largestBoundingRectRotated.iBr.iY,
       
  3449                                    largestBoundingRectRotated.iBr.iX );
       
  3450             }
       
  3451         else
       
  3452             {
       
  3453             aBoundingRect = largestBoundingRect;
       
  3454             }
       
  3455         }
       
  3456     else
       
  3457         {
       
  3458         TRect rect( Rect() );
       
  3459 
       
  3460 	    if ( rect.iTl.iX > aBoundingRect.iTl.iX )
       
  3461 	        {
       
  3462 		    aBoundingRect.iBr.iX = rect.iTl.iX;
       
  3463 	        }
       
  3464 	    if ( rect.iBr.iX < aBoundingRect.iBr.iX )
       
  3465 	        {
       
  3466 		    aBoundingRect.iTl.iX = rect.iBr.iX;
       
  3467 	        }
       
  3468 	    if ( rect.iTl.iY > aBoundingRect.iTl.iY )
       
  3469 	        {
       
  3470 		    aBoundingRect.iBr.iY = rect.iTl.iY;
       
  3471 	        }
       
  3472 	    if ( rect.iBr.iY < aBoundingRect.iBr.iY )
       
  3473 	        {
       
  3474 		    aBoundingRect.iTl.iY = rect.iBr.iY;
       
  3475 	        }
       
  3476         }
       
  3477 	}
       
  3478 
       
  3479 
       
  3480 // ---------------------------------------------------------------------------
       
  3481 // CEikStatusPaneBase::LargestBoundingRect
       
  3482 // Gets the largest bounding rectangle that contains the specified region.
       
  3483 // ---------------------------------------------------------------------------
       
  3484 //
       
  3485 TRect CEikStatusPaneBase::LargestBoundingRect( TRegion& aWholeRegion,
       
  3486                                                TRegion& aRemovedRegion ) const
       
  3487     {
       
  3488     TInt count = aRemovedRegion.Count();
       
  3489     for ( TInt i = 0; i < count; i++ )
       
  3490         {
       
  3491         aWholeRegion.SubRect( aRemovedRegion[i] );
       
  3492         }
       
  3493 
       
  3494     aWholeRegion.Tidy();
       
  3495     TInt count2 = aWholeRegion.Count();
       
  3496 
       
  3497     TRect largestBoundingRect( 0, 0, 0, 0 );
       
  3498     for ( TInt j = 0; j < count2; j++ )
       
  3499         {
       
  3500         TRect boundingRect( aWholeRegion[j] );
       
  3501         if ( boundingRect.Height() * boundingRect.Width() >=
       
  3502                  largestBoundingRect.Height() * largestBoundingRect.Width() )
       
  3503             {
       
  3504             largestBoundingRect = boundingRect;
       
  3505             }
       
  3506         }
       
  3507 
       
  3508     // Return largest bounding rect.
       
  3509     return largestBoundingRect;
       
  3510     }
       
  3511 
       
  3512 
       
  3513 /**
       
  3514  * Visitor class for collecting the sub-pane areas to a single region.
       
  3515  */
       
  3516 NONSHARABLE_CLASS( TStatusPaneRegionCollector )
       
  3517     : public MEikStatusPaneLayoutTreeVisitor
       
  3518 	{
       
  3519 public:
       
  3520 
       
  3521 	TStatusPaneRegionCollector( CEikStatusPaneSetInit* aPanes,
       
  3522 	                            TRegion& aRegion,
       
  3523 	                            TBool aIncludeAppPanes,
       
  3524 	                            TBool aIncludeServerPanes );
       
  3525 
       
  3526 	void VisitL( CEikStatusPaneLayoutTree* aNode );
       
  3527 
       
  3528 private:
       
  3529 
       
  3530 	CEikStatusPaneSetInit* iPanes;
       
  3531 	TRegion&               iRegion;
       
  3532 	TBool                  iIncludeAppPanes;
       
  3533 	TBool                  iIncludeServerPanes;
       
  3534 	};
       
  3535 
       
  3536 
       
  3537 // ---------------------------------------------------------------------------
       
  3538 // TStatusPaneRegionCollector::TStatusPaneRegionCollector
       
  3539 // C++ constructor.
       
  3540 // ---------------------------------------------------------------------------
       
  3541 //
       
  3542 TStatusPaneRegionCollector::TStatusPaneRegionCollector(
       
  3543     CEikStatusPaneSetInit* aPanes,
       
  3544     TRegion& aRegion,
       
  3545     TBool aIncludeAppPanes,
       
  3546     TBool aIncludeServerPanes )
       
  3547     : iPanes( aPanes ),
       
  3548       iRegion( aRegion ),
       
  3549       iIncludeAppPanes( aIncludeAppPanes ),
       
  3550       iIncludeServerPanes( aIncludeServerPanes )
       
  3551 	{
       
  3552 	}
       
  3553 
       
  3554 
       
  3555 // ---------------------------------------------------------------------------
       
  3556 // TStatusPaneRegionCollector::VisitL
       
  3557 // Visit method status pane region collector.
       
  3558 // ---------------------------------------------------------------------------
       
  3559 //
       
  3560 void TStatusPaneRegionCollector::VisitL( CEikStatusPaneLayoutTree* aNode )
       
  3561 	{
       
  3562 	TBool appOwned = iPanes->FindL( aNode->Id() ).AppOwned();
       
  3563     TRect rect( aNode->Rect() );
       
  3564 	if ( ( appOwned && iIncludeAppPanes ) ||
       
  3565 	     ( !appOwned && iIncludeServerPanes ) )
       
  3566 		{
       
  3567 		iRegion.AddRect( rect );
       
  3568 		}
       
  3569 	else
       
  3570 		{
       
  3571 		iRegion.SubRect( rect );
       
  3572 		}
       
  3573 	}
       
  3574 
       
  3575 
       
  3576 // ---------------------------------------------------------------------------
       
  3577 // CEikStatusPaneBase::GetShapeL
       
  3578 // Adds and removes pane rectangles from aRegion.
       
  3579 // App panes are added is aIncludeAppPanes is ETrue, otherwise they are
       
  3580 // removed. The same holds for server panes and aIncludeServerPanes.
       
  3581 // ---------------------------------------------------------------------------
       
  3582 //
       
  3583 EXPORT_C void CEikStatusPaneBase::GetShapeL( TRegion& aRegion,
       
  3584                                              TBool aIncludeAppPanes,
       
  3585                                              TBool aIncludeServerPanes ) const
       
  3586 	{
       
  3587 	TStatusPaneRegionCollector collector( iModel->PaneInits(),
       
  3588 	                                      aRegion,
       
  3589 	                                      aIncludeAppPanes,
       
  3590 	                                      aIncludeServerPanes );
       
  3591 	iModel->CurrentLayout()->AcceptL( &collector );
       
  3592 	}
       
  3593 
       
  3594 
       
  3595 // ---------------------------------------------------------------------------
       
  3596 // CEikStatusPaneBase::SetFlags
       
  3597 // Sets all the visual flags at once (dimmed and visible).
       
  3598 // ---------------------------------------------------------------------------
       
  3599 //
       
  3600 EXPORT_C void CEikStatusPaneBase::SetFlags( TInt aFlags )
       
  3601 	{
       
  3602 	MakeVisible( aFlags & KEikStatusPaneBaseVisibleBit );
       
  3603 	SetDimmed( aFlags & KEikStatusPaneBaseDimmedBit );
       
  3604 	}
       
  3605 
       
  3606 
       
  3607 // ---------------------------------------------------------------------------
       
  3608 // CEikStatusPaneBase::Flags
       
  3609 // Returns the status pane flags.
       
  3610 // ---------------------------------------------------------------------------
       
  3611 //
       
  3612 EXPORT_C TInt CEikStatusPaneBase::Flags() const
       
  3613 	{
       
  3614 	return iFlags;
       
  3615 	}
       
  3616 
       
  3617 // ---------------------------------------------------------------------------
       
  3618 // CEikStatusPaneBase::MakeVisible
       
  3619 // Sets the visiblility of the status pane and its contents.
       
  3620 // Same as CCoeControl::MakeVisible().
       
  3621 // ---------------------------------------------------------------------------
       
  3622 //
       
  3623 EXPORT_C void CEikStatusPaneBase::MakeVisible( TBool aVisible )
       
  3624 	{
       
  3625 	if ( COMPARE_BOOLS( aVisible, IsVisible() ) )
       
  3626 		{
       
  3627 		return;
       
  3628 		}
       
  3629 
       
  3630 	if ( aVisible )
       
  3631 		{
       
  3632 		iFlags |= KEikStatusPaneBaseVisibleBit;
       
  3633 		TSetRectAndVisibility vis( IsApp(), this );
       
  3634 		// Won't leave because TSetRectAndVisibility only looks for
       
  3635 		// panes that it knows exist.
       
  3636 		TRAP_IGNORE( iModel->CurrentLayout()->AcceptL( &vis ) );
       
  3637 		DoDrawNow( EDrawDeferred );
       
  3638 		}
       
  3639 	else
       
  3640 		{
       
  3641 		iFlags &= ~KEikStatusPaneBaseVisibleBit;
       
  3642 		SetAllInvisible();
       
  3643 		}
       
  3644 
       
  3645 	ReportSizeChange();
       
  3646 	}
       
  3647 
       
  3648 
       
  3649 // ---------------------------------------------------------------------------
       
  3650 // CEikStatusPaneBase::SetDimmed
       
  3651 // Sets the dimmed state of the status pane and its contents.
       
  3652 // ---------------------------------------------------------------------------
       
  3653 //
       
  3654 EXPORT_C void CEikStatusPaneBase::SetDimmed( TBool aDimmed )
       
  3655 	{
       
  3656 	if ( COMPARE_BOOLS( aDimmed, IsDimmed() ) )
       
  3657 		{
       
  3658 		return;
       
  3659 		}
       
  3660 
       
  3661 	if ( aDimmed )
       
  3662 		{
       
  3663 		iFlags |= KEikStatusPaneBaseDimmedBit;
       
  3664 		}
       
  3665 	else
       
  3666 		{
       
  3667 		iFlags &= ~KEikStatusPaneBaseDimmedBit;
       
  3668 		}
       
  3669 
       
  3670 	const TInt count = iControls->Count();
       
  3671 	for ( TInt ii = 0; ii < count; ++ii )
       
  3672 		{
       
  3673 		iControls->At( ii )->SetDimmed( aDimmed );
       
  3674 		}
       
  3675 	}
       
  3676 
       
  3677 
       
  3678 // ---------------------------------------------------------------------------
       
  3679 // CEikStatusPaneBase::SetFaded
       
  3680 // Does nothing - fading is now handled by Window Server and
       
  3681 // the Application Framework.
       
  3682 // ---------------------------------------------------------------------------
       
  3683 //
       
  3684 EXPORT_C void CEikStatusPaneBase::SetFaded( TBool /*aFaded*/ )
       
  3685 	{
       
  3686 	}
       
  3687 
       
  3688 
       
  3689 // ---------------------------------------------------------------------------
       
  3690 // CEikStatusPaneBase::HandleResourceChange
       
  3691 // Passes the HandleResourceChange() signal to all sub parts
       
  3692 // of the status pane.
       
  3693 // ---------------------------------------------------------------------------
       
  3694 //
       
  3695 EXPORT_C void CEikStatusPaneBase::HandleResourceChange( TInt aType )
       
  3696 	{
       
  3697 	if ( aType == KEikDynamicLayoutVariantSwitch )
       
  3698 		{
       
  3699         TBool landscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
  3700         TInt  currentLayoutResId( CurrentLayoutResId() );
       
  3701 		TInt  resId( 0 );
       
  3702 
       
  3703         if ( IsApp() )
       
  3704             {
       
  3705             // Check if current layout is supported in this orientation and
       
  3706             // if it has been set by the application...
       
  3707             if ( currentLayoutResId == AVKONENV->StatusPaneResIdForCurrentLayout( currentLayoutResId ) &&
       
  3708                     ( currentLayoutResId == iExtension->iLastLandscapeResourceId ||
       
  3709                     currentLayoutResId == iExtension->iLastPortraitResourceId ) )
       
  3710                 {
       
  3711                 // ...supported, then we use it !
       
  3712                 resId = currentLayoutResId;
       
  3713                 }
       
  3714             // ...if not, then check the last ID app has used when calling
       
  3715             // SwitchLayout(), and if it's supported in this orientation...
       
  3716             else if (iExtension->iLastRequestedResourceId != 0 &&
       
  3717                     ( landscape && SupportedLandscapeResId( iExtension->iLastRequestedResourceId ) ||
       
  3718                     ( !landscape && SupportedPortraitResId( iExtension->iLastRequestedResourceId ) ) ) )
       
  3719                 {
       
  3720                 resId = iExtension->iLastRequestedResourceId;
       
  3721                 }
       
  3722             else
       
  3723                 {
       
  3724                 // ...not supported, then find most suitable one...
       
  3725                 // Get the last layout used in this orientation
       
  3726                 resId = LastUsedResourceId();
       
  3727 
       
  3728                 // If suitable layout still not found for some reason
       
  3729                 // then default to initial one.
       
  3730                 if ( resId == 0 )
       
  3731                     {
       
  3732                     resId = InitialUsedResourceId();
       
  3733                     }
       
  3734                 }
       
  3735 		    }
       
  3736 		else
       
  3737 		    {
       
  3738 		    resId = currentLayoutResId;
       
  3739 		    }
       
  3740 
       
  3741         // Reset current layout so that layout for the new
       
  3742         // orientation/language is used.
       
  3743 		// Note, drawing is not done in this case, as it is assumed that the
       
  3744 		// controls will draw themselves if necessary.
       
  3745 		// This prevents double drawing.
       
  3746 
       
  3747 	    CAknStatuspaneClearer* clearer = Clearer();
       
  3748 		if ( clearer )
       
  3749 			{
       
  3750 			clearer->UnBlank();
       
  3751 			// Disable statuspane own blanker, if screenblanker does blanking.
       
  3752 			clearer->DisableBlank( EBlankDisableLevelHigh );
       
  3753 			}
       
  3754 
       
  3755 		TRAP_IGNORE( DoSwitchLayoutL( resId, ENoDraw ) );
       
  3756 		if ( clearer )
       
  3757 			{
       
  3758 	        clearer->SetDefaultShape();
       
  3759 	        clearer->SetSkinBackgroundContext( CurrentLayoutResId() );
       
  3760 	        clearer->SetOrdinalPosition( 0 );
       
  3761 			clearer->EnableBlank();
       
  3762 			}
       
  3763 		}
       
  3764     else if ( aType == KAknsMessageSkinChange )
       
  3765         {
       
  3766         CEikStatusPaneContainer::PrepareBackgroundBaseContext(
       
  3767             iExtension->iCommonBgContext,
       
  3768             CurrentLayoutResId(),
       
  3769             ENoDraw );
       
  3770 
       
  3771 		CAknStatuspaneClearer* clearer = Clearer();
       
  3772 		if ( clearer )
       
  3773 			{
       
  3774         	clearer->SetSkinBackgroundContext( CurrentLayoutResId() );
       
  3775 			}
       
  3776         }
       
  3777     // The following fixes EAKH-78RBFS
       
  3778     else if ( aType == KEikMessageUnfadeWindows )
       
  3779         {
       
  3780         DoDrawNow( EDrawDeferred );
       
  3781         }
       
  3782 
       
  3783 	const TInt count = iControls->Count();
       
  3784 	for ( TInt ii = 0; ii < count; ++ii )
       
  3785 		{
       
  3786 		iControls->At( ii )->HandleResourceChange( aType );
       
  3787 		}
       
  3788 	}
       
  3789 
       
  3790 
       
  3791 // ---------------------------------------------------------------------------
       
  3792 // CEikStatusPaneBase::IsVisible
       
  3793 // Returns the visibility of the status pane.
       
  3794 // Same as CCoeControl::IsVisible().
       
  3795 // ---------------------------------------------------------------------------
       
  3796 //
       
  3797 EXPORT_C TBool CEikStatusPaneBase::IsVisible() const
       
  3798 	{
       
  3799 	return iFlags & KEikStatusPaneBaseVisibleBit;
       
  3800 	}
       
  3801 
       
  3802 
       
  3803 // ---------------------------------------------------------------------------
       
  3804 // CEikStatusPaneBase::IsDimmed
       
  3805 // Returns the dimming state of the status pane.
       
  3806 // Same as CCoeControl::IsDimmed().
       
  3807 // ---------------------------------------------------------------------------
       
  3808 //
       
  3809 EXPORT_C TBool CEikStatusPaneBase::IsDimmed() const
       
  3810 	{
       
  3811 	return iFlags & KEikStatusPaneBaseDimmedBit;
       
  3812 	}
       
  3813 
       
  3814 
       
  3815 // ---------------------------------------------------------------------------
       
  3816 // CEikStatusPaneBase::IsFaded
       
  3817 // Returns EFalse.
       
  3818 // Fading is now handled by Window Server and the Application Framework.
       
  3819 // ---------------------------------------------------------------------------
       
  3820 //
       
  3821 EXPORT_C TBool CEikStatusPaneBase::IsFaded() const
       
  3822 	{
       
  3823 	return iAvkonAppUiBase->IsFaded();
       
  3824 	}
       
  3825 
       
  3826 
       
  3827 // ---------------------------------------------------------------------------
       
  3828 // CEikStatusPaneBase::PaneCapabilities
       
  3829 // Returns the capabilities of a sub pane.
       
  3830 // ---------------------------------------------------------------------------
       
  3831 //
       
  3832 EXPORT_C CEikStatusPaneBase::TPaneCapabilities CEikStatusPaneBase::PaneCapabilities(
       
  3833     TPaneId aPaneId ) const
       
  3834 	{
       
  3835 	TPaneCapabilities caps;
       
  3836 	TEikStatusPaneInit* init = NULL;
       
  3837 	TRAPD( err, init = &iModel->PaneInits()->FindL( aPaneId ) );
       
  3838 	if ( !err )
       
  3839 		{
       
  3840 		caps.SetPresent();
       
  3841 		if ( init && init->AppOwned() )
       
  3842 			{
       
  3843 			caps.SetAppOwned();
       
  3844 			}
       
  3845 		if ( iModel->CurrentLayout()->Find( aPaneId ) != NULL )
       
  3846 			{
       
  3847 			caps.SetInCurrentLayout();
       
  3848 			}
       
  3849 		}
       
  3850 	return caps;
       
  3851 	}
       
  3852 
       
  3853 
       
  3854 // ---------------------------------------------------------------------------
       
  3855 // CEikStatusPaneBase::ReportSizeChange
       
  3856 // Reports status pane size change to the observer.
       
  3857 // ---------------------------------------------------------------------------
       
  3858 //
       
  3859 void CEikStatusPaneBase::ReportSizeChange()
       
  3860 	{
       
  3861     // If Aknlayout is used, then it is possible that statuspane
       
  3862     // panes can be located almost "everywhere" in the screen area.
       
  3863     // Notify here first CBA about size change so that it can adjust itself.
       
  3864     if ( iModel && iModel->AknLayoutUsed( CurrentLayoutResId() ) )
       
  3865         {
       
  3866         CEikButtonGroupContainer* cba = iEikEnv.AppUiFactory()->Cba();
       
  3867         TRect cbaBoundingRect( 0, 0, 0, 0 ); // dummy
       
  3868         if ( cba )
       
  3869         	{
       
  3870             cba->SetBoundingRect( cbaBoundingRect );
       
  3871         	}
       
  3872         }
       
  3873 
       
  3874 
       
  3875     // Now let observers adjust their sizes etc.
       
  3876 	if ( iObserver )
       
  3877 		{
       
  3878 		iObserver->HandleStatusPaneSizeChange();
       
  3879 		}
       
  3880 
       
  3881     // If this statuspane is in embedded app, then inform
       
  3882     // also embedding app about the statuspane size change. This prevents
       
  3883     // embedding app from clipping serverside pane drawing.
       
  3884     CEikAppUi* appUi = iEikEnv.EikAppUi();
       
  3885 	if ( appUi && appUi->ContainerAppUi() )
       
  3886 		{
       
  3887 		appUi = appUi->ContainerAppUi();
       
  3888 		MEikAppUiFactory* factory = iEikEnv.AppUiFactory( *appUi );
       
  3889 		if ( factory )
       
  3890 			{
       
  3891 			CEikStatusPane* statusPane = factory->StatusPane();
       
  3892 			if ( statusPane && statusPane != this )
       
  3893 			    {
       
  3894 				statusPane->ReportSizeChange();
       
  3895 			    }
       
  3896 			}
       
  3897 		}
       
  3898 
       
  3899 #ifdef RD_SCALABLE_UI_V2
       
  3900     // Notify touch pane of size change.
       
  3901     CAknTouchPane* touchPane = iAvkonAppUi->TouchPane();
       
  3902     if ( touchPane )
       
  3903         {
       
  3904         TInt initial = InitialUsedResourceId();
       
  3905         TInt last    = iExtension ? iExtension->iLastRequestedResourceId : NULL;
       
  3906         touchPane->HandleStatusPaneSizeChange( initial, last );
       
  3907         }
       
  3908 #endif // RD_SCALABLE_UI_V2
       
  3909 	}
       
  3910 
       
  3911 
       
  3912 // ---------------------------------------------------------------------------
       
  3913 // CEikStatusPaneBase::CurrentLayoutResId
       
  3914 // Returns the current status pane layout resource ID.
       
  3915 // ---------------------------------------------------------------------------
       
  3916 //
       
  3917 EXPORT_C TInt CEikStatusPaneBase::CurrentLayoutResId() const
       
  3918 	{
       
  3919 	if ( iModel )
       
  3920 	    {
       
  3921 	    return iModel->CurrentLayoutResId();
       
  3922 	    }
       
  3923 	else
       
  3924 	    {
       
  3925 	    return KErrNotFound;
       
  3926 	    }
       
  3927 	}
       
  3928 
       
  3929 
       
  3930 // ---------------------------------------------------------------------------
       
  3931 // CEikStatusPaneBase::OkToChangeStatusPaneNow
       
  3932 // ---------------------------------------------------------------------------
       
  3933 //
       
  3934 EXPORT_C TBool CEikStatusPaneBase::OkToChangeStatusPaneNow()
       
  3935 	{
       
  3936 	return ETrue;
       
  3937 	}
       
  3938 
       
  3939 
       
  3940 // ---------------------------------------------------------------------------
       
  3941 // CEikStatusPaneBase::TSetRectAndVisibility::TSetRectAndVisibility
       
  3942 // Constructor of the visitor class for setting sub-pane rects and
       
  3943 // visibilities.
       
  3944 // ---------------------------------------------------------------------------
       
  3945 //
       
  3946 CEikStatusPaneBase::TSetRectAndVisibility::TSetRectAndVisibility(
       
  3947     TBool aIsApp, CEikStatusPaneBase* aStatusPane )
       
  3948     : iIsApp( aIsApp ), iStatusPane( aStatusPane )
       
  3949 	{
       
  3950 	}
       
  3951 
       
  3952 
       
  3953 // ---------------------------------------------------------------------------
       
  3954 // CEikStatusPaneBase::TSetRectAndVisibility::VisitL
       
  3955 // Visit method for setting the rect and visibility of sub-panes.
       
  3956 // ---------------------------------------------------------------------------
       
  3957 //
       
  3958 void CEikStatusPaneBase::TSetRectAndVisibility::VisitL(
       
  3959     CEikStatusPaneLayoutTree* aNode )
       
  3960 	{
       
  3961 	TBool appOwned =
       
  3962 	    iStatusPane->iModel->PaneInits()->FindL( aNode->Id() ).AppOwned();
       
  3963 
       
  3964 	if ( COMPARE_BOOLS( appOwned, iIsApp ) )
       
  3965 		{
       
  3966 		CEikStatusPaneContainer* cont = iStatusPane->Find( aNode->Id() );
       
  3967 		if (NULL != cont)
       
  3968 		    {
       
  3969             cont->SetRect( aNode->Rect() );
       
  3970             cont->MakeVisible( iStatusPane->IsVisible() );
       
  3971 		    }
       
  3972 		}
       
  3973 	}
       
  3974 
       
  3975 
       
  3976 // ---------------------------------------------------------------------------
       
  3977 // CEikStatusPaneBase::TPaneCapabilities::TPaneCapabilities
       
  3978 // Constructor for TPaneCapabilities object.
       
  3979 // ---------------------------------------------------------------------------
       
  3980 //
       
  3981 CEikStatusPaneBase::TPaneCapabilities::TPaneCapabilities() : iFlags( 0 )
       
  3982 	{
       
  3983 	}
       
  3984 
       
  3985 
       
  3986 // ---------------------------------------------------------------------------
       
  3987 // CEikStatusPaneBase::SetLastUsedResourceId
       
  3988 // Sets the status pane layout resource ID last used.
       
  3989 // ---------------------------------------------------------------------------
       
  3990 //
       
  3991 void CEikStatusPaneBase::SetLastUsedResourceId( TInt aResourceId )
       
  3992     {
       
  3993     if ( !iExtension )
       
  3994     	{
       
  3995         return;
       
  3996     	}
       
  3997 
       
  3998 	iExtension->iLastRequestedResourceId = aResourceId;
       
  3999 
       
  4000     // Check if the resource ID is supported in the current orientation.
       
  4001     // Without this check it may happen that iLastPortraitResourceId gets
       
  4002     // status pane resource of landscape status pane. If this would happen
       
  4003     // following portrait status pane layout can fallback to wrong layout.
       
  4004     //
       
  4005     // if (aResourceId == AVKONENV->StatusPaneResIdForCurrentLayout(aResourceId))
       
  4006 	//
       
  4007 	// NOTE: Check mentioned above has been commented out because it may
       
  4008 	// cause other problems if there are other layout id mappings used in
       
  4009 	// addition to landscape/portrait mappings.
       
  4010 	// It should be enough to use Layout_Meta_Data::IsLandscapeOrientation()
       
  4011 	// when checking the orientation instead of the screendevice,
       
  4012 	// so no confusions should appear.
       
  4013 
       
  4014     // Update last used resource ID in the current orientation so that
       
  4015     // we can restore it when orientation changes back.
       
  4016 	//
       
  4017 	// It is important to check orientation from layout instead of
       
  4018 	// the screendevice because of delayed layout switch
       
  4019     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  4020         {
       
  4021         iExtension->iLastLandscapeResourceId = aResourceId;
       
  4022         }
       
  4023     else
       
  4024         {
       
  4025         iExtension->iLastPortraitResourceId = aResourceId;
       
  4026         }
       
  4027     }
       
  4028 
       
  4029 
       
  4030 // ---------------------------------------------------------------------------
       
  4031 // CEikStatusPaneBase::LastUsedResourceId
       
  4032 // Returns the status pane layout resource ID last used.
       
  4033 // ---------------------------------------------------------------------------
       
  4034 //
       
  4035 TInt CEikStatusPaneBase::LastUsedResourceId()
       
  4036     {
       
  4037     if ( !iExtension )
       
  4038     	{
       
  4039         return 0;
       
  4040     	}
       
  4041 
       
  4042 	// It is important to check orientation from layout instead of the
       
  4043 	// screendevice because of delayed layout switch.
       
  4044     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  4045         {
       
  4046         return iExtension->iLastLandscapeResourceId;
       
  4047         }
       
  4048     else
       
  4049         {
       
  4050         return iExtension->iLastPortraitResourceId;
       
  4051         }
       
  4052     }
       
  4053 
       
  4054 
       
  4055 // ---------------------------------------------------------------------------
       
  4056 // CEikStatusPaneBase::ReadInitialUsedResourceIdL
       
  4057 // Reads the initial status pane ID from resource.
       
  4058 // ---------------------------------------------------------------------------
       
  4059 //
       
  4060 TInt CEikStatusPaneBase::ReadInitialUsedResourceIdL( TInt aCoreResId )
       
  4061     {
       
  4062 	TResourceReader res;
       
  4063 	iEikEnv.CreateResourceReaderLC( res, aCoreResId );
       
  4064    	const TInt count = res.ReadInt16();
       
  4065 
       
  4066 	for ( TInt ii = 0; ii < count; ++ii )
       
  4067 		{
       
  4068 		TEikStatusPaneInit init;
       
  4069 		init.LoadDefaults( res );
       
  4070 		}
       
  4071 
       
  4072     // This is the only thing in the resource that we are interested in...
       
  4073     TInt defaultResource = res.ReadUint32();
       
  4074 	CleanupStack::PopAndDestroy();	// res
       
  4075 
       
  4076     return defaultResource;
       
  4077     }
       
  4078 
       
  4079 
       
  4080 // ---------------------------------------------------------------------------
       
  4081 // CEikStatusPaneBase::InitialUsedResourceId
       
  4082 // Sets the initial status pane resource ID.
       
  4083 // ---------------------------------------------------------------------------
       
  4084 //
       
  4085 void CEikStatusPaneBase::SetInitialUsedResourceId( TInt aResourceId )
       
  4086     {
       
  4087     if ( !iExtension )
       
  4088     	{
       
  4089         return;
       
  4090     	}
       
  4091     iExtension->iInitialResourceId = aResourceId;
       
  4092     }
       
  4093 
       
  4094 
       
  4095 // ---------------------------------------------------------------------------
       
  4096 // CEikStatusPaneBase::InitialUsedResourceId
       
  4097 // Returns the initially used status pane resource ID.
       
  4098 // ---------------------------------------------------------------------------
       
  4099 //
       
  4100 TInt CEikStatusPaneBase::InitialUsedResourceId()
       
  4101     {
       
  4102     if ( !iExtension )
       
  4103     	{
       
  4104         return 0;
       
  4105     	}
       
  4106 
       
  4107     return iExtension->iInitialResourceId;
       
  4108     }
       
  4109 
       
  4110 
       
  4111 // ---------------------------------------------------------------------------
       
  4112 // CEikStatusPaneBase::Clearer
       
  4113 // Returns pointer to the status pane blanker.
       
  4114 // ---------------------------------------------------------------------------
       
  4115 //
       
  4116 CAknStatuspaneClearer* CEikStatusPaneBase::Clearer()
       
  4117     {
       
  4118     return iExtension->iBlankStatuspane;
       
  4119     }
       
  4120 
       
  4121 
       
  4122 // ---------------------------------------------------------------------------
       
  4123 // CEikStatusPaneBase::DisableClearer
       
  4124 // Disables or enables the status pane blanker.
       
  4125 // ---------------------------------------------------------------------------
       
  4126 //
       
  4127 EXPORT_C void CEikStatusPaneBase::DisableClearer( TBool aDisabled )
       
  4128     {
       
  4129   	CAknStatuspaneClearer* clearer = Clearer();
       
  4130     if ( aDisabled )
       
  4131     	{
       
  4132 		if ( clearer )
       
  4133 			{
       
  4134 	    	clearer->DisableBlank( EBlankDisableLevelNormal );
       
  4135 	    	clearer->UnBlank();
       
  4136 			}
       
  4137     	}
       
  4138     else
       
  4139     	{
       
  4140     	if ( clearer )
       
  4141     		{
       
  4142     		clearer->EnableBlank();
       
  4143     		}
       
  4144     	}
       
  4145     }
       
  4146 
       
  4147 
       
  4148 // ---------------------------------------------------------------------------
       
  4149 // CEikStatusPaneBase::CommonPrepareForAppExit
       
  4150 // Prepares for application exit.
       
  4151 // ---------------------------------------------------------------------------
       
  4152 //
       
  4153 EXPORT_C void CEikStatusPaneBase::CommonPrepareForAppExit()
       
  4154 	{
       
  4155 	if ( IsApp() )
       
  4156 		{
       
  4157     	// Blank statuspane during app exit.
       
  4158     	CAknStatuspaneClearer* clearer = Clearer();
       
  4159     	if ( clearer )
       
  4160     		{
       
  4161 	    	clearer->EnableBlank();
       
  4162 		    clearer->SetSkinBackgroundContext( CurrentLayoutResId(), ETrue );
       
  4163 			clearer->SetDefaultShape();
       
  4164 		    clearer->SetOrdinalPosition( 0 );
       
  4165 			clearer->Blank();
       
  4166     		}
       
  4167 		}
       
  4168 	}
       
  4169 
       
  4170 
       
  4171 // ---------------------------------------------------------------------------
       
  4172 // CEikStatusPaneBase::DataSubscriber
       
  4173 // Returns pointer to the status pane data subscriber.
       
  4174 // ---------------------------------------------------------------------------
       
  4175 //
       
  4176 CAknStatusPaneDataSubscriber*  CEikStatusPaneBase::DataSubscriber() const
       
  4177 	{
       
  4178 	if ( iExtension )
       
  4179 		{
       
  4180 		return iExtension->iDataSubscriber;
       
  4181 		}
       
  4182 	else
       
  4183 		{
       
  4184 		return NULL;
       
  4185 		}
       
  4186 	}
       
  4187 
       
  4188 
       
  4189 // ---------------------------------------------------------------------------
       
  4190 // CEikStatusPane::NewL
       
  4191 // Factory method for the application side status pane.
       
  4192 // ---------------------------------------------------------------------------
       
  4193 //
       
  4194 EXPORT_C CEikStatusPane* CEikStatusPane::NewL( CEikonEnv& aEikEnv,
       
  4195                                                RWindowGroup* aParent,
       
  4196                                                TInt aCoreStatusPaneModelResId,
       
  4197                                                TInt aAppStatusPaneModelId )
       
  4198 	{
       
  4199 	CEikStatusPane* self =
       
  4200 	    new (ELeave) CEikStatusPane( aEikEnv, aParent, aAppStatusPaneModelId );
       
  4201 	CleanupStack::PushL( self );
       
  4202 	self->ConstructL( aCoreStatusPaneModelResId );
       
  4203     CleanupStack::Pop( self );
       
  4204 	return self;
       
  4205 	}
       
  4206 
       
  4207 
       
  4208 // ---------------------------------------------------------------------------
       
  4209 // CEikStatusPane::CreateModelL
       
  4210 // Creates the status pane model.
       
  4211 // ---------------------------------------------------------------------------
       
  4212 //
       
  4213 CEikStatusPaneModelBase* CEikStatusPane::CreateModelL( TInt aCoreResId ) const
       
  4214 	{
       
  4215 	return CEikAppStatusPaneModel::NewL(
       
  4216 	    iEikEnv, aCoreResId, iAppDeclId, ETrue );
       
  4217 	}
       
  4218 
       
  4219 
       
  4220 // ---------------------------------------------------------------------------
       
  4221 // CEikStatusPane::IsApp
       
  4222 // ---------------------------------------------------------------------------
       
  4223 //
       
  4224 TBool CEikStatusPane::IsApp() const
       
  4225 	{
       
  4226 	return ETrue;
       
  4227 	}
       
  4228 
       
  4229 
       
  4230 // ---------------------------------------------------------------------------
       
  4231 // CEikStatusPane::CEikStatusPane
       
  4232 // C++ constructor.
       
  4233 // ---------------------------------------------------------------------------
       
  4234 //
       
  4235 CEikStatusPane::CEikStatusPane( CEikonEnv& aEikEnv,
       
  4236                                 RWindowGroup* aParent,
       
  4237                                 TInt aAppStatusPaneModelId )
       
  4238     : CEikStatusPaneBase( aEikEnv, aParent ),
       
  4239       iAppDeclId( aAppStatusPaneModelId )
       
  4240 	{
       
  4241 	}
       
  4242 
       
  4243 
       
  4244 // ---------------------------------------------------------------------------
       
  4245 // CEikStatusPane::~CEikStatusPane
       
  4246 // Destructor.
       
  4247 // ---------------------------------------------------------------------------
       
  4248 //
       
  4249 EXPORT_C CEikStatusPane::~CEikStatusPane()
       
  4250 	{
       
  4251 	// If this is an embedded app, tell the underlying statuspane
       
  4252 	// to unhide itself.
       
  4253 	CEikAppUi* appUi = iEikEnv.EikAppUi();
       
  4254 	if ( appUi && appUi->ContainerAppUi() )
       
  4255 		{
       
  4256 		appUi = appUi->ContainerAppUi();
       
  4257 		MEikAppUiFactory* factory = iEikEnv.AppUiFactory( *appUi );
       
  4258 		if ( factory )
       
  4259 			{
       
  4260 			CEikStatusPane* statusPane = factory->StatusPane();
       
  4261 			if ( statusPane )
       
  4262 			    {
       
  4263 				statusPane->HideAppPanes( EFalse );
       
  4264 			    }
       
  4265 			}
       
  4266 		}
       
  4267 
       
  4268 	delete iDelayedForegroundObserver;
       
  4269     iEikEnv.RemoveForegroundObserver( *this );
       
  4270 	}
       
  4271 
       
  4272 
       
  4273 // ---------------------------------------------------------------------------
       
  4274 // CEikStatusPane::ConstructL
       
  4275 // Second-phase constructor.
       
  4276 // ---------------------------------------------------------------------------
       
  4277 //
       
  4278 void CEikStatusPane::ConstructL( TInt aCoreResId )
       
  4279 	{
       
  4280 	BaseConstructL( aCoreResId );
       
  4281 
       
  4282 	if ( iAppDeclId != EEikStatusPaneUseDefaults )
       
  4283 		{
       
  4284 	    SetInitialUsedResourceId(
       
  4285 	        ReadInitialUsedResourceIdL( aCoreResId, iAppDeclId ) );
       
  4286 		}
       
  4287 
       
  4288     iEikEnv.AddForegroundObserverL( *this );
       
  4289 	CAknStatusPaneDataSubscriber* subscriber = DataSubscriber();
       
  4290 	// Syncronize data from server here so that we have
       
  4291     // up to date state before first draw.
       
  4292 	if ( subscriber )
       
  4293 		{
       
  4294 		subscriber->RefreshDataL();
       
  4295 		}
       
  4296 
       
  4297 	CAknStatuspaneClearer* clearer = Clearer();
       
  4298 	if ( clearer )
       
  4299 		{
       
  4300 		clearer->SetOrdinalPosition( 0 );
       
  4301 		RAknUiServer* client = CAknSgcClient::AknSrv();
       
  4302 		TInt appResInServerside = client->CurrentAppStatuspaneResource();
       
  4303 		TInt appResInClientside = CurrentLayoutResId();
       
  4304 
       
  4305 	   	RRegion region;
       
  4306 	   	CleanupClosePushL( region );
       
  4307 	   	GetShapeL( region, ETrue, ETrue );
       
  4308 	    OptimizeClearerWindowShape( appResInServerside,
       
  4309 	                                appResInClientside,
       
  4310 	                                region );
       
  4311 		clearer->SetShape( region );
       
  4312 	    clearer->SetSkinBackgroundContext( CurrentLayoutResId() );
       
  4313 		CleanupStack::PopAndDestroy( &region );
       
  4314 		clearer->Blank( KDefaultUnblankTimeout );
       
  4315 	    clearer->DisableBlank( EBlankDisableLevelNormal );
       
  4316 		iDelayedForegroundObserver = CAknDelayedForegroundObserver::NewL( this );
       
  4317 		// This is not really needed (?). Consumes about 60ms in app startup
       
  4318 		//DoDrawNow(EDrawNow);
       
  4319 		}
       
  4320 	else
       
  4321 		{
       
  4322 		DoDrawNow( EDrawDeferred );
       
  4323 		}
       
  4324     }
       
  4325 
       
  4326 
       
  4327 // ---------------------------------------------------------------------------
       
  4328 // CEikStatusPane::MakeVisible
       
  4329 // Makes status pane visible or non-visible.
       
  4330 // ---------------------------------------------------------------------------
       
  4331 //
       
  4332 EXPORT_C void CEikStatusPane::MakeVisible( TBool aVisible )
       
  4333 	{
       
  4334 	// This call must be made before the setting the refresh levels
       
  4335 	// in order for the incall status bubble to be hidden when
       
  4336 	// status pane is made non-visible.
       
  4337 	CEikStatusPaneBase::MakeVisible( aVisible );
       
  4338 
       
  4339 	CAknStatusPaneDataSubscriber* subscriber = DataSubscriber();
       
  4340 	if ( subscriber )
       
  4341 		{
       
  4342 		if ( !aVisible )
       
  4343 			{
       
  4344 			subscriber->SetRefreshLevel(
       
  4345 			    CAknStatusPaneDataSubscriber::ERefreshLevelNone, EFalse );
       
  4346 			}
       
  4347 		else
       
  4348 			{
       
  4349 			subscriber->SetRefreshLevel(
       
  4350 			    CAknStatusPaneDataSubscriber::ERefreshLevelMedium, EFalse );
       
  4351 			}
       
  4352 		}
       
  4353 
       
  4354 	ApplyCurrentFlags();
       
  4355 	}
       
  4356 
       
  4357 
       
  4358 // ---------------------------------------------------------------------------
       
  4359 // CEikStatusPane::SetDimmed
       
  4360 // Sets status pane dimmed/undimmed.
       
  4361 // ---------------------------------------------------------------------------
       
  4362 //
       
  4363 EXPORT_C void CEikStatusPane::SetDimmed( TBool aDimmed )
       
  4364 	{
       
  4365 	CEikStatusPaneBase::SetDimmed( aDimmed );
       
  4366 	ApplyCurrentFlags();
       
  4367 	}
       
  4368 
       
  4369 
       
  4370 // ---------------------------------------------------------------------------
       
  4371 // CEikStatusPane::SetFaded
       
  4372 // Handled by Window Server and Application Framework.
       
  4373 // ---------------------------------------------------------------------------
       
  4374 //
       
  4375 EXPORT_C void CEikStatusPane::SetFaded( TBool /*aFaded*/ )
       
  4376 	{
       
  4377 	}
       
  4378 
       
  4379 
       
  4380 // ---------------------------------------------------------------------------
       
  4381 // CEikStatusPane::HandleResourceChange
       
  4382 // Passes the HandleResourceChange() signal to all sub parts
       
  4383 // of the status pane.
       
  4384 // ---------------------------------------------------------------------------
       
  4385 //
       
  4386 EXPORT_C void CEikStatusPane::HandleResourceChange( TInt aType )
       
  4387 	{
       
  4388 	CEikStatusPaneBase::HandleResourceChange( aType );
       
  4389 
       
  4390     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  4391         {
       
  4392         // CEikStatusPaneBase::HandleResourceChange has set all panes visible
       
  4393         // by default. If we are embedding app, then hide the panes here.
       
  4394         TBool embedding = ( this != Current() );
       
  4395         HideAppPanes( embedding );
       
  4396         }
       
  4397 
       
  4398 	if ( aType == KEikMessageEmbedLevelChange )
       
  4399 		{
       
  4400         // Report statuspane change if this is NOT in embedded app
       
  4401         CEikAppUi* appUi = iEikEnv.EikAppUi();
       
  4402 	    if ( appUi && !appUi->ContainerAppUi() )
       
  4403 		    {
       
  4404             ReportSizeChange();
       
  4405 		    }
       
  4406 		const TBool appPaneVis = ( this == Current() );
       
  4407 		HideAppPanes( !appPaneVis );
       
  4408 		if ( appPaneVis )
       
  4409 			{
       
  4410 			// Function doesn't actually leave
       
  4411 			TRAP_IGNORE( ApplyCurrentSettingsL() );
       
  4412 			}
       
  4413 		}
       
  4414 	}
       
  4415 
       
  4416 
       
  4417 // ---------------------------------------------------------------------------
       
  4418 // CEikStatusPane::ApplyCurrentSettingsL
       
  4419 // Synchronises the server status pane layout with the
       
  4420 // application status pane.
       
  4421 // ---------------------------------------------------------------------------
       
  4422 //
       
  4423 EXPORT_C void CEikStatusPane::ApplyCurrentSettingsL()
       
  4424 	{
       
  4425 	static_cast<CEikAppStatusPaneModel*>( iModel )->ApplyCurrentLayoutL();
       
  4426 	ApplyCurrentFlags();
       
  4427 	}
       
  4428 
       
  4429 
       
  4430 // ---------------------------------------------------------------------------
       
  4431 // CEikStatusPane::ApplyCurrentFlags
       
  4432 // Applies current flags to the server side.
       
  4433 // ---------------------------------------------------------------------------
       
  4434 //
       
  4435 void CEikStatusPane::ApplyCurrentFlags()
       
  4436 	{
       
  4437 	TRAP_IGNORE( CAknSgcClient::HandleChangeL() );
       
  4438 	}
       
  4439 
       
  4440 
       
  4441 // ---------------------------------------------------------------------------
       
  4442 // CEikStatusPane::OkToChangeStatusPaneNow
       
  4443 // ---------------------------------------------------------------------------
       
  4444 //
       
  4445 EXPORT_C TBool CEikStatusPane::OkToChangeStatusPaneNow()
       
  4446 	{
       
  4447 	return ETrue;
       
  4448 	}
       
  4449 
       
  4450 
       
  4451 // ---------------------------------------------------------------------------
       
  4452 // CEikStatusPane::PrepareForAppExit
       
  4453 // Prepares for application exit.
       
  4454 // ---------------------------------------------------------------------------
       
  4455 //
       
  4456 EXPORT_C void CEikStatusPane::PrepareForAppExit()
       
  4457 	{
       
  4458 	CommonPrepareForAppExit();
       
  4459 	CAknSgcClient::PrepareForAppExit();
       
  4460 	}
       
  4461 
       
  4462 
       
  4463 // ---------------------------------------------------------------------------
       
  4464 // CEikStatusPane::HandleGainingForeground
       
  4465 // Handles gaining foreground.
       
  4466 // ---------------------------------------------------------------------------
       
  4467 //
       
  4468 void CEikStatusPane::HandleGainingForeground()
       
  4469 	{
       
  4470 	// Make sure no delayed calls are active.
       
  4471 	if ( iDelayedForegroundObserver )
       
  4472 		{
       
  4473 		iDelayedForegroundObserver->StopDelayedObservation();
       
  4474 		}
       
  4475 
       
  4476     CAknStatuspaneClearer* clearer = Clearer();
       
  4477 	if ( clearer )
       
  4478 		{
       
  4479 		TInt appResInClientside = CurrentLayoutResId();
       
  4480 		RAknUiServer* client = CAknSgcClient::AknSrv();
       
  4481 		if ( client )
       
  4482 			{
       
  4483 	   		client->SetCurrentAppStatuspaneResource( appResInClientside );
       
  4484 			}
       
  4485 
       
  4486 		// Enable window redraw storing when we are foreground.
       
  4487 		const TInt count = iControls->Count();
       
  4488 		for ( TInt ii = 0; ii < count; ++ii )
       
  4489 			{
       
  4490 			RWindow* window =
       
  4491 			    static_cast<RWindow*>( iControls->At(ii)->DrawableWindow() );
       
  4492 			SetStoreHandler( window, KEnableRedrawStoring );
       
  4493 			}
       
  4494 		}
       
  4495 
       
  4496     // Report statuspane change if we are in embedded app.
       
  4497     CEikAppUi* appUi = iEikEnv.EikAppUi();
       
  4498 	if ( appUi && appUi->ContainerAppUi() )
       
  4499 		{
       
  4500         ReportSizeChange();
       
  4501 		}
       
  4502     }
       
  4503 
       
  4504 
       
  4505 // ---------------------------------------------------------------------------
       
  4506 // CEikStatusPane::HandleLosingForeground
       
  4507 // Handles losing foreground.
       
  4508 // ---------------------------------------------------------------------------
       
  4509 //
       
  4510 void CEikStatusPane::HandleLosingForeground()
       
  4511 	{
       
  4512     CAknStatuspaneClearer* clearer = Clearer();
       
  4513 	if ( clearer )
       
  4514 		{
       
  4515 		//
       
  4516 		// Window redraw storing is disabled here to avoid flicker when
       
  4517 		// foreground next time is gained because of the status pane clearer.
       
  4518 		//
       
  4519 		RAknUiServer* client = CAknSgcClient::AknSrv();
       
  4520 		TInt appResInClientside = CurrentLayoutResId();
       
  4521 		TInt appResInServerside = client->StatusPaneResourceId();
       
  4522 		TBool faded = EFalse;
       
  4523 		client->IsSystemFaded( faded );
       
  4524 		// Fading is checked so that we don't disable redrawing during
       
  4525 		// fade because unfading looks ugly if redrawing is disabled.
       
  4526 		if ( appResInClientside != appResInServerside || !faded )
       
  4527 			{
       
  4528 			const TInt count = iControls->Count();
       
  4529 			for ( TInt ii = 0; ii < count; ++ii )
       
  4530 				{
       
  4531 				RWindow* window =
       
  4532 				    static_cast<RWindow*>( iControls->At( ii )->DrawableWindow() );
       
  4533 				SetStoreHandler( window, EFalse );
       
  4534 				}
       
  4535 
       
  4536 			// Make sure no delayed HandleLosingForeground-calls are active.
       
  4537 			if ( iDelayedForegroundObserver )
       
  4538 				{
       
  4539 				iDelayedForegroundObserver->StopDelayedObservation();
       
  4540 				}
       
  4541 			}
       
  4542 		else if ( iDelayedForegroundObserver &&
       
  4543 		          !iDelayedForegroundObserver->IsDelayedCallbackActive() )
       
  4544 			{
       
  4545 			// If we could not yet turn redraw storing off, we try few times
       
  4546 			// with timer. If not succesful, then result may be some
       
  4547 			// additional flicker when becoming to foreground again.
       
  4548 			iDelayedForegroundObserver->StartDelayedForegroundLossObservation(
       
  4549 			    1000000, 15 ); // 1s interval, 15 times.
       
  4550 			}
       
  4551 		}
       
  4552 	}
       
  4553 
       
  4554 
       
  4555 // ---------------------------------------------------------------------------
       
  4556 // CEikStatusPane::DoHandleLosingForegroundL
       
  4557 // Handles losing foreground.
       
  4558 // ---------------------------------------------------------------------------
       
  4559 //
       
  4560 void CEikStatusPane::DoHandleLosingForegroundL()
       
  4561     {
       
  4562     }
       
  4563 
       
  4564 
       
  4565 
       
  4566 // ---------------------------------------------------------------------------
       
  4567 // CEikStatusPane::HideAppPanes
       
  4568 // Hides the application owned sub-panes.
       
  4569 // ---------------------------------------------------------------------------
       
  4570 //
       
  4571 void CEikStatusPane::HideAppPanes( TBool aHide )
       
  4572 	{
       
  4573 	CEikStatusPaneSetInit* paneSet = iModel->PaneInits();
       
  4574 	const TInt count = paneSet->Count();
       
  4575 	for ( TInt ii = 0; ii < count; ii++ )
       
  4576 		{
       
  4577 		TEikStatusPaneInit& paneInit = (*paneSet)[ii];
       
  4578 		if ( paneInit.AppOwned() )
       
  4579 			{
       
  4580 			CEikStatusPaneContainer* container = Find( paneInit.Id() );
       
  4581 			if ( container )
       
  4582 				{
       
  4583 				if ( aHide )
       
  4584 					{
       
  4585 					if ( container->IsVisible() )
       
  4586 						{
       
  4587 						paneInit.SetHidden();
       
  4588 						container->MakeVisible( !aHide );
       
  4589 						}
       
  4590 					}
       
  4591 				else
       
  4592 					{
       
  4593 					if ( paneInit.IsHidden() )
       
  4594 						{
       
  4595 						paneInit.ClearHidden();
       
  4596 						container->MakeVisible( !aHide );
       
  4597 						}
       
  4598 					}
       
  4599 				}
       
  4600 			}
       
  4601 		}
       
  4602 	}
       
  4603 
       
  4604 
       
  4605 // ---------------------------------------------------------------------------
       
  4606 // CEikStatusPane::ReadInitialUsedResourceIdL
       
  4607 // Reads the inital status pane resource ID.
       
  4608 // ---------------------------------------------------------------------------
       
  4609 //
       
  4610 TInt CEikStatusPane::ReadInitialUsedResourceIdL( TInt aCoreResId,
       
  4611                                                  TInt aAppStatusPaneModelResId )
       
  4612     {
       
  4613     TInt  id    = 0;
       
  4614     TBool found = EFalse;
       
  4615     TInt  ii    = 0;
       
  4616 
       
  4617     // First check if given aAppStatusPaneModelResId
       
  4618     // is one of the legal resource IDs.
       
  4619 	TResourceReader res;
       
  4620 	iEikEnv.CreateResourceReaderLC( res, aCoreResId );
       
  4621    	const TInt count = res.ReadInt16();
       
  4622 
       
  4623 	for ( ii = 0; ii < count; ++ii )
       
  4624 		{
       
  4625 		TEikStatusPaneInit init;
       
  4626 		init.LoadDefaults( res );
       
  4627 		}
       
  4628 
       
  4629     TInt defaultResource = res.ReadUint32();
       
  4630 
       
  4631    	const TInt layoutCount = res.ReadInt16();
       
  4632 	for ( ii = 0; ii < layoutCount; ++ii )
       
  4633 		{
       
  4634 		TInt layoutRes = res.ReadInt32();
       
  4635 		if ( aAppStatusPaneModelResId == layoutRes )
       
  4636 		    {
       
  4637 		    id    = aAppStatusPaneModelResId;
       
  4638 		    found = ETrue;
       
  4639 		    }
       
  4640 		}
       
  4641 
       
  4642 	CleanupStack::PopAndDestroy();	// res
       
  4643 
       
  4644     // If ID is not any of the valid resources, then read app model.
       
  4645     if ( !found )
       
  4646         {
       
  4647     	TResourceReader res2;
       
  4648     	iEikEnv.CreateResourceReaderLC( res2, aAppStatusPaneModelResId );
       
  4649         // This is the only thing in the resource that we are interested in...
       
  4650 
       
  4651         TInt appId = res2.ReadUint32();
       
  4652 
       
  4653         // App may have set it to use default statuspane layout.
       
  4654         if ( appId != EEikStatusPaneUseDefaults )
       
  4655         	{
       
  4656        	    id = appId;
       
  4657         	}
       
  4658         else
       
  4659         	{
       
  4660             id = defaultResource;
       
  4661         	}
       
  4662 
       
  4663     	CleanupStack::PopAndDestroy();	// res2
       
  4664         }
       
  4665 
       
  4666     return id;
       
  4667     }
       
  4668 
       
  4669 
       
  4670 // ===========================================================================
       
  4671 // CAknStatuspaneClearer, class for drawing a blank statuspane.
       
  4672 // ===========================================================================
       
  4673 
       
  4674 // ---------------------------------------------------------------------------
       
  4675 // CAknStatuspaneClearer::NewLC
       
  4676 // Two-phase constructor.
       
  4677 // ---------------------------------------------------------------------------
       
  4678 //
       
  4679 CAknStatuspaneClearer* CAknStatuspaneClearer::NewLC( RWindowGroup& aParent,
       
  4680                                                      TInt aStatuspaneLayoutId,
       
  4681                                                      TBool aOwnWindowGroup )
       
  4682 	{
       
  4683 	CAknStatuspaneClearer* self = new (ELeave) CAknStatuspaneClearer;
       
  4684 	CleanupStack::PushL( self );
       
  4685 	self->ConstructL( aParent, aStatuspaneLayoutId, aOwnWindowGroup );
       
  4686 	AKNTASHOOK_ADDL( self, "CAknStatuspaneClearer" );
       
  4687 	return self;
       
  4688 	}
       
  4689 
       
  4690 
       
  4691 // ---------------------------------------------------------------------------
       
  4692 // CAknStatuspaneClearer::NewL
       
  4693 // Two-phase constructor.
       
  4694 // ---------------------------------------------------------------------------
       
  4695 //
       
  4696 CAknStatuspaneClearer* CAknStatuspaneClearer::NewL( RWindowGroup& aParent,
       
  4697                                                     TInt aStatuspaneLayoutId,
       
  4698                                                     TBool aOwnWindowGroup )
       
  4699 	{
       
  4700 	CAknStatuspaneClearer* self =
       
  4701 	    CAknStatuspaneClearer::NewLC( aParent,
       
  4702 	                                  aStatuspaneLayoutId,
       
  4703 	                                  aOwnWindowGroup );
       
  4704 	CleanupStack::Pop( self );
       
  4705 	return self;
       
  4706 	}
       
  4707 
       
  4708 
       
  4709 // ---------------------------------------------------------------------------
       
  4710 // CAknStatuspaneClearer::~CAknStatuspaneClearer
       
  4711 // Destructor.
       
  4712 // ---------------------------------------------------------------------------
       
  4713 //
       
  4714 CAknStatuspaneClearer::~CAknStatuspaneClearer()
       
  4715 	{
       
  4716 	AKNTASHOOK_REMOVE();
       
  4717     delete iBgContext;
       
  4718 
       
  4719     if ( iUnblankTimer )
       
  4720     	{
       
  4721    	    iUnblankTimer->Cancel();
       
  4722         delete iUnblankTimer;
       
  4723     	}
       
  4724 
       
  4725     if ( iOwnWindowGroup )
       
  4726     	{
       
  4727     	iParent->Close();
       
  4728     	}
       
  4729 	}
       
  4730 
       
  4731 
       
  4732 // ---------------------------------------------------------------------------
       
  4733 // CAknStatuspaneClearer::SetSkinBackgroundContext
       
  4734 // Sets the blanker's skin background context.
       
  4735 // ---------------------------------------------------------------------------
       
  4736 //
       
  4737 void CAknStatuspaneClearer::SetSkinBackgroundContext( TInt aStatuspaneLayoutId,
       
  4738                                                       TBool aDrawNavi)
       
  4739     {
       
  4740     CEikStatusPaneContainer::PrepareBackgroundContext( iBgContext,
       
  4741                                                        aStatuspaneLayoutId,
       
  4742                                                        aDrawNavi );
       
  4743     iStatuspaneLayoutId = aStatuspaneLayoutId;
       
  4744     }
       
  4745 
       
  4746 
       
  4747 // ---------------------------------------------------------------------------
       
  4748 // CAknStatuspaneClearer::Blank
       
  4749 // Blanks the status pane for a specific time.
       
  4750 // ---------------------------------------------------------------------------
       
  4751 //
       
  4752 void CAknStatuspaneClearer::Blank( TInt aUnblankTimeout )
       
  4753     {
       
  4754     if (!iBlankDisableLevel)
       
  4755         {
       
  4756         Blank();
       
  4757         }
       
  4758 
       
  4759 	InitTimer( aUnblankTimeout, aUnblankTimeout );
       
  4760     }
       
  4761 
       
  4762 
       
  4763 // ---------------------------------------------------------------------------
       
  4764 // CAknStatuspaneClearer::Blank
       
  4765 // Blanks the status pane.
       
  4766 // ---------------------------------------------------------------------------
       
  4767 //
       
  4768 void CAknStatuspaneClearer::Blank()
       
  4769     {
       
  4770     if ( !iBlankDisableLevel )
       
  4771         {
       
  4772         MakeVisible( ETrue );
       
  4773     	DrawNow();
       
  4774         }
       
  4775     }
       
  4776 
       
  4777 
       
  4778 // ---------------------------------------------------------------------------
       
  4779 // CAknStatuspaneClearer::IsBlank
       
  4780 // Checks if status pane is currently blanked.
       
  4781 // ---------------------------------------------------------------------------
       
  4782 //
       
  4783 TBool CAknStatuspaneClearer::IsBlank()
       
  4784     {
       
  4785     return IsVisible();
       
  4786     }
       
  4787 
       
  4788 
       
  4789 // ---------------------------------------------------------------------------
       
  4790 // CAknStatuspaneClearer::UnBlank
       
  4791 // Unblanks the status pane.
       
  4792 // ---------------------------------------------------------------------------
       
  4793 //
       
  4794 void CAknStatuspaneClearer::UnBlank()
       
  4795     {
       
  4796     MakeVisible( EFalse );
       
  4797     }
       
  4798 
       
  4799 
       
  4800 // ---------------------------------------------------------------------------
       
  4801 // CAknStatuspaneClearer::SetShape
       
  4802 // Sets the blanker shape.
       
  4803 // ---------------------------------------------------------------------------
       
  4804 //
       
  4805 void CAknStatuspaneClearer::SetShape( TRegion& aRegion )
       
  4806     {
       
  4807 	DrawableWindow()->SetShape( aRegion );
       
  4808 	SetRect( AknLayout::screen().Rect() );
       
  4809     }
       
  4810 
       
  4811 
       
  4812 // ---------------------------------------------------------------------------
       
  4813 // CAknStatuspaneClearer::SetDefaultShape
       
  4814 // Sets the default blanker shape.
       
  4815 // ---------------------------------------------------------------------------
       
  4816 //
       
  4817 void CAknStatuspaneClearer::SetDefaultShape()
       
  4818     {
       
  4819 	RRegion shape;
       
  4820     CEikStatusPaneBase* sp = CEikStatusPaneBase::Current();
       
  4821     if ( sp )
       
  4822         {
       
  4823         // Add all statuspane panes to shape.
       
  4824         TRAPD( err, sp->GetShapeL( shape, ETrue, ETrue ) );
       
  4825         if ( err == KErrNone )
       
  4826             {
       
  4827             DrawableWindow()->SetShape( shape );
       
  4828             SetRect( AknLayout::screen().Rect() );
       
  4829             }
       
  4830         }
       
  4831     shape.Close();
       
  4832     }
       
  4833 
       
  4834 
       
  4835 // ---------------------------------------------------------------------------
       
  4836 // CAknStatuspaneClearer::ConstructL
       
  4837 // Second-phase constructor.
       
  4838 // ---------------------------------------------------------------------------
       
  4839 //
       
  4840 void CAknStatuspaneClearer::ConstructL( RWindowGroup& aParent,
       
  4841                                         TInt aLayoutId,
       
  4842                                         TBool aOwnWindowGroup )
       
  4843 	{
       
  4844 	if ( aOwnWindowGroup )
       
  4845 		{
       
  4846 		RWindowGroup wg = RWindowGroup( iCoeEnv->WsSession() );
       
  4847 		iParent = &wg;
       
  4848 
       
  4849 	    User::LeaveIfError( iParent->Construct( (TUint32) iParent ) );
       
  4850 	    iParent->SetOrdinalPosition( 0, ECoeWinPriorityMedium );
       
  4851     	iParent->EnableReceiptOfFocus( EFalse );
       
  4852 		}
       
  4853 	else
       
  4854 		{
       
  4855 		iParent = &aParent;
       
  4856 		}
       
  4857 
       
  4858 	iOwnWindowGroup = aOwnWindowGroup;
       
  4859 
       
  4860 	CreateWindowL( iParent );
       
  4861 
       
  4862    	iUnblankTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
  4863 
       
  4864     SetDefaultShape();
       
  4865 
       
  4866 	SetOrdinalPosition( 0 );
       
  4867 
       
  4868     // No blank active
       
  4869 	UnBlank();
       
  4870 
       
  4871 	ActivateL();
       
  4872 
       
  4873     iBgContext = CAknsMaskedLayerBackgroundControlContext::NewL(
       
  4874         KAknsIIDQsnBgAreaStatus, TRect(0,0,1,1), ETrue, ELayerFlatN + 1 );
       
  4875 
       
  4876     SetSkinBackgroundContext( aLayoutId );
       
  4877 	}
       
  4878 
       
  4879 
       
  4880 // ---------------------------------------------------------------------------
       
  4881 // CAknStatuspaneClearer::Draw
       
  4882 // Draws the blanker.
       
  4883 // ---------------------------------------------------------------------------
       
  4884 //
       
  4885 void CAknStatuspaneClearer::Draw( const TRect& /*aRect*/ ) const
       
  4886 	{
       
  4887 	CWindowGc& gc = SystemGc();
       
  4888     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  4889     AknsDrawUtils::Background( skin, iBgContext, this, gc, Rect() );
       
  4890     iEikonEnv->WsSession().Flush();
       
  4891 
       
  4892     return;
       
  4893 	}
       
  4894 
       
  4895 
       
  4896 // ---------------------------------------------------------------------------
       
  4897 // CAknStatuspaneClearer::SetOrdinalPosition
       
  4898 // Sets the window group ordinal position.
       
  4899 // ---------------------------------------------------------------------------
       
  4900 //
       
  4901 void CAknStatuspaneClearer::SetOrdinalPosition( TInt aPosition )
       
  4902     {
       
  4903     DrawableWindow()->SetOrdinalPosition( aPosition );
       
  4904     }
       
  4905 
       
  4906 
       
  4907 // ---------------------------------------------------------------------------
       
  4908 // CAknStatuspaneClearer::EnableBlank
       
  4909 // Enables the blanker.
       
  4910 // ---------------------------------------------------------------------------
       
  4911 //
       
  4912 void CAknStatuspaneClearer::EnableBlank()
       
  4913     {
       
  4914     iBlankDisableLevel = 0;
       
  4915     }
       
  4916 
       
  4917 
       
  4918 // ---------------------------------------------------------------------------
       
  4919 // CAknStatuspaneClearer::DisableBlank
       
  4920 // Sets the blank disable level.
       
  4921 // ---------------------------------------------------------------------------
       
  4922 //
       
  4923 void CAknStatuspaneClearer::DisableBlank( TInt aDisableLevel )
       
  4924     {
       
  4925     iBlankDisableLevel = aDisableLevel;
       
  4926     }
       
  4927 
       
  4928 
       
  4929 // ---------------------------------------------------------------------------
       
  4930 // CAknStatuspaneClearer::InitTimer
       
  4931 // Starts the unblank timer.
       
  4932 // ---------------------------------------------------------------------------
       
  4933 //
       
  4934 void CAknStatuspaneClearer::InitTimer( TInt aDelay, TInt aInterval )
       
  4935     {
       
  4936     CancelTimer();
       
  4937     if ( iUnblankTimer &&
       
  4938          !iUnblankTimer->IsActive() )  // start timer if not already started
       
  4939         {
       
  4940         iUnblankTimer->Start(
       
  4941             TTimeIntervalMicroSeconds32( aDelay ),
       
  4942 		    TTimeIntervalMicroSeconds32( aInterval ),
       
  4943             TCallBack( CAknStatuspaneClearer::TimerEvent, this ) );
       
  4944         }
       
  4945     }
       
  4946 
       
  4947 
       
  4948 // ---------------------------------------------------------------------------
       
  4949 // CAknStatuspaneClearer::CancelTimer
       
  4950 // Cancels the unblank timer.
       
  4951 // ---------------------------------------------------------------------------
       
  4952 //
       
  4953 void CAknStatuspaneClearer::CancelTimer()
       
  4954     {
       
  4955    	if ( iUnblankTimer && iUnblankTimer->IsActive() )
       
  4956     	{
       
  4957    		iUnblankTimer->Cancel();
       
  4958     	}
       
  4959     }
       
  4960 
       
  4961 
       
  4962 // ---------------------------------------------------------------------------
       
  4963 // CAknStatuspaneClearer::TimerEvent
       
  4964 // Static callback function for delayed unblanking.
       
  4965 // ---------------------------------------------------------------------------
       
  4966 //
       
  4967 TInt CAknStatuspaneClearer::TimerEvent( TAny* aPtr )
       
  4968     {
       
  4969     static_cast<CAknStatuspaneClearer*>( aPtr )->DoTimerEvent();
       
  4970     return TRUE;
       
  4971     }
       
  4972 
       
  4973 
       
  4974 // ---------------------------------------------------------------------------
       
  4975 // CAknStatuspaneClearer::DoTimerEvent
       
  4976 // Callback function for delayed unblanking.
       
  4977 // ---------------------------------------------------------------------------
       
  4978 //
       
  4979 void CAknStatuspaneClearer::DoTimerEvent()
       
  4980     {
       
  4981     UnBlank();
       
  4982     CancelTimer();
       
  4983     }
       
  4984 
       
  4985 
       
  4986 // ---------------------------------------------------------------------------
       
  4987 // CAknStatuspaneClearer::BlankDisabled
       
  4988 // Returns the current blank disable level.
       
  4989 // ---------------------------------------------------------------------------
       
  4990 //
       
  4991 TInt CAknStatuspaneClearer::BlankDisabled()
       
  4992     {
       
  4993     return iBlankDisableLevel;
       
  4994     }
       
  4995 
       
  4996 // End of file