williamr@4: /* williamr@4: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: williamr@4: * williamr@4: */ williamr@4: williamr@4: #if !defined(__AVKON_ENV_H__) williamr@4: #define __AVKON_ENV_H__ williamr@4: williamr@4: // INCLUDES williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include // for TAknLayoutId williamr@4: #include // for TAknUiZoom williamr@4: williamr@4: // FORWARD DECLARATIONS williamr@4: namespace AknLayout { class CInstance; } williamr@4: namespace LayoutPack { class CInstance; } williamr@4: williamr@4: class CCdlEngineRef; williamr@4: class MAknEditingStateIndicator; williamr@4: class MAknIntermediateState; williamr@4: class CAknAppUi; williamr@4: class CAknWaitDialog; williamr@4: class CEikListBox; williamr@4: class CAknSettingCache; williamr@4: class CAknFontRegistry; williamr@4: class CLafSystemFont; williamr@4: class TAknLayoutConfigScreenMode; williamr@4: class CCdlRefs; williamr@4: class CTransitionManager; williamr@4: class CAknCommandMediator; williamr@4: // Since there is no include of aknsystemfont.h we need the typedef CLafSystemFont here as well williamr@4: // Hence this requires parallel maintenance. williamr@4: typedef CLafSystemFont CAknSystemFont; williamr@4: williamr@4: // MACROS williamr@4: // Color Macros williamr@4: /** Color indirection macros williamr@4: * williamr@4: * This macro takes number from LAF specification and converts it to TRgb for williamr@4: * use to draw things. williamr@4: */ williamr@4: williamr@4: // Color macros williamr@4: #define AKN_LAF_COLOR_ENV(env,nn) CAknEnv::AvkonColor(nn) williamr@4: #define AKN_LAF_COLOR(nn) CAknEnv::AvkonColor(nn) williamr@4: #define AKN_LAF_COLOR_STATIC(nn) CAknEnv::AvkonColor(nn) williamr@4: williamr@4: // Avkon layout williamr@4: // IMPORT_C const AknLayout::CInstance& AknLayout() const; williamr@4: williamr@4: williamr@4: // CLASS DECLARATION williamr@4: williamr@4: /** williamr@4: * This class is a Series 60 extension to @c CEikonEnv. williamr@4: * Every Avkon application is provided with an instance of @c CAvkEnv by the williamr@4: * framework, which can be accessed through the @c iAvkonEnv macro. williamr@4: * williamr@4: * @since Series 60 0.9 williamr@4: */ williamr@4: class CAknEnv : public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: * Gets the @c CAknEnv maintained by the framework for the application. williamr@4: * Compare @c CCoeEnv::Static(). williamr@4: * williamr@4: * This function should never be run in a thread where such a static Avkon williamr@4: * environment does not exist. Code that may run on the server side of an williamr@4: * application server is one such case. williamr@4: * @return A static @c CAknEnv. williamr@4: */ williamr@4: IMPORT_C static CAknEnv* Static(); williamr@4: williamr@4: /** williamr@4: * Destructor. williamr@4: */ williamr@4: IMPORT_C ~CAknEnv(); williamr@4: public: williamr@4: // this one creates an empty dialog. for list queries and popup lists with williamr@4: // "No Data" in it. williamr@4: /** williamr@4: * Executes empty popup list. williamr@4: * williamr@4: * @param aEmptyText Text indicating empty popup list. NULL if williamr@4: * @c R_AVKON_EMPTY_POPUP_LIST_TEXT used. williamr@4: */ williamr@4: williamr@4: IMPORT_C void ExecuteEmptyPopupListL(const TDesC *aEmptyText=0); williamr@4: williamr@4: /** williamr@4: * Executes empty popup list. williamr@4: * @c aSoftkeyId is soft key rescource used, but shown without left soft williamr@4: * key (except @c R_AVKON_SOFTKEYS_OK_EMPTY). williamr@4: * williamr@4: * @param aEmptyText Text indicating empty popup list. NULL if williamr@4: * @c R_AVKON_EMPTY_POPUP_LIST_TEXT used. williamr@4: * @param aTitle A title of the popup list. williamr@4: * @param aSoftKeyId CBA resource to be used as a base. 0 if williamr@4: * @c R_AVKON_SOFTKEYS_CANCEL is used. williamr@4: */ williamr@4: IMPORT_C void ExecuteEmptyPopupListL(const TDesC *aEmptyText, williamr@4: const TDesC *aTitle, williamr@4: TInt aSoftkeyId=0); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Set the FEP menu observer. williamr@4: * williamr@4: * @param aObserver the FEP menu observer. williamr@4: */ williamr@4: IMPORT_C void SetFepMenuObserver(MEikMenuObserver* aObserver); williamr@4: williamr@4: /** williamr@4: * Get the FEP menu observer. williamr@4: * williamr@4: * @return Pointer to the FEP menu observer. williamr@4: */ williamr@4: IMPORT_C MEikMenuObserver* FepMenuObserver(); williamr@4: williamr@4: /** williamr@4: * Get the editing state indicator. williamr@4: * williamr@4: * @return Pointer to the editing state indicator. williamr@4: */ williamr@4: IMPORT_C MAknEditingStateIndicator* EditingStateIndicator(); williamr@4: williamr@4: williamr@4: /** williamr@4: * Swap the editing state indicator. williamr@4: * williamr@4: * @param aIndicator The new editing state indicator. williamr@4: * @return The old editing state indicator. williamr@4: */ williamr@4: IMPORT_C MAknEditingStateIndicator* SwapEditingStateIndicator( williamr@4: MAknEditingStateIndicator* aIndicator); williamr@4: williamr@4: /** williamr@4: * Exit foreground application. williamr@4: */ williamr@4: IMPORT_C static void ExitForegroundAppL(); williamr@4: williamr@4: public: // Intermediate states support williamr@4: /** williamr@4: * Register the control implementing intermediate states. williamr@4: * Call @c iAvkonEnv->RegisterIntermediateState(this) in control's williamr@4: * @c ActivateL(). williamr@4: * williamr@4: * @param aState The control implementing intermediate states. williamr@4: */ williamr@4: IMPORT_C void RegisterIntermediateStateL(MAknIntermediateState *aState); williamr@4: williamr@4: /** williamr@4: * Unregister the control implementing intermediate states. williamr@4: * Call @c iAvkonEnv->UnRegisterIntermediateState(this) in control's williamr@4: * destructor. williamr@4: * williamr@4: * @param aState The control implementing intermediate states. williamr@4: */ williamr@4: IMPORT_C void UnRegisterIntermediateState(MAknIntermediateState *aState); williamr@4: williamr@4: /** williamr@4: * Closes all intermediate states as a low-priority process. williamr@4: */ williamr@4: IMPORT_C void CloseAllIntermediateStates(); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Run application shutter. williamr@4: */ williamr@4: IMPORT_C static void RunAppShutter(); williamr@4: williamr@4: /** williamr@4: * Get pointer to the most embedded application UI with Dialog Shutter williamr@4: * running. williamr@4: * williamr@4: * @return Pointer to the most embedded application UI with Dialog Shutter williamr@4: * running. @c NULL if no any Dialog Shutter running. williamr@4: */ williamr@4: IMPORT_C static CAknAppUi* AppWithShutterRunning(); williamr@4: williamr@4: /** williamr@4: * Stop the scheduler. If the waiting control can't stop the scheduler williamr@4: * immediately, then trying to show a busy note. williamr@4: * @param aWait Scheduler object to be stopped. williamr@4: */ williamr@4: IMPORT_C static void StopSchedulerWaitWithBusyMessage( williamr@4: CActiveSchedulerWait& aWait); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Create CBA observer. The possible existing one is removed first. williamr@4: * @param aCba A control which @c ProcessCommandL handles the command. williamr@4: * @param aListBox Stored to data member @c iListBox. williamr@4: */ williamr@4: IMPORT_C void CreateCbaObserverL(CEikButtonGroupContainer *aCba, williamr@4: CEikListBox *aListBox); williamr@4: williamr@4: /** williamr@4: * Remove CBA observer. williamr@4: */ williamr@4: IMPORT_C void RemoveCbaObserver(); williamr@4: williamr@4: williamr@4: /** williamr@4: * Remove CBA observer if the right one. williamr@4: * @param aCba CBA to be checked. williamr@4: */ williamr@4: IMPORT_C void InformCbaDeletion(CEikButtonGroupContainer *aCba); williamr@4: williamr@4: /** williamr@4: * Requests mediation of MSK commmands from specified CBA to the williamr@4: * given observer. When called for the first time, this method creates williamr@4: * an observer that is added to specified CBA to observe MSK commands williamr@4: * and to mediate all received events to the given observer. The created williamr@4: * observer exists until the CAknEnv instance is destroyed. All subsequent williamr@4: * calls to this method replace the previously requested mediation. williamr@4: * williamr@4: * @param aCba CBA whose MSK is to be observed. williamr@4: * @param aCommandObserver An observer for which the commands are sent. williamr@4: */ williamr@4: IMPORT_C void RequestCommandMediationL( CEikButtonGroupContainer& aCba, williamr@4: MEikCommandObserver& aCommandObserver ); williamr@4: williamr@4: /** williamr@4: * Ends mediating MSK commands to specified command observer. If commands williamr@4: * are being mediated to the specifed observer, the command mediator is williamr@4: * removed from the CBA to end mediation. williamr@4: * williamr@4: * @param aCommandObserver An observer. williamr@4: */ williamr@4: IMPORT_C void EndCommandMediation( MEikCommandObserver& aCommandObserver ); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Get current layout ID. williamr@4: * @since Series 60 2.0 williamr@4: * @param aCurrentLayoutId On return, contains current layout ID. williamr@4: */ williamr@4: IMPORT_C void GetCurrentLayoutId(TAknLayoutId& aCurrentLayoutId) const; williamr@4: williamr@4: /** williamr@4: * Get current global zoom williamr@4: * @since 3.1 williamr@4: * @param aCurrentGlobalUiZoom On return, contains current global zoom. williamr@4: */ williamr@4: IMPORT_C void GetCurrentGlobalUiZoom(TAknUiZoom& aCurrentGlobalUiZoom) const; williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Tells the type of status pane layout for UI. williamr@4: * @since Series 60 2.0 williamr@4: * @param aResId resource id for current layout. williamr@4: * @return Resource id equivalent type of status pane layout. williamr@4: */ williamr@4: IMPORT_C TInt StatusPaneResIdForCurrentLayout(TInt aResId) const; williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Requests Window Server client buffer used by the application to williamr@4: * be of at least the given size. All code that wants to increase williamr@4: * (to avoid flicker) or decrease (to save RAM) the buffer compared williamr@4: * to the default size should call this method instead of using williamr@4: * WS interface directly. A list of all requests is maintained williamr@4: * and the highest request is always effective. Only if there are no williamr@4: * requests done, the default buffer size is used. williamr@4: * williamr@4: * @since Series 60 2.0 williamr@4: * williamr@4: * @param aRequestedBufferSize requested Window Server client buffer size. williamr@4: * williamr@4: * @return Request ID. This is used when the request is canceled. williamr@4: * In OOM situation, @c KErrNoMemory is returned. williamr@4: * @c CancelWsBufferRequest ignores negative values as error codes williamr@4: * so it is OK to pass any value returned by this method to williamr@4: * @c CancelWsBufferRequest. williamr@4: */ williamr@4: IMPORT_C TInt RequestWsBuffer( TInt aRequestedBufferSize ); williamr@4: williamr@4: /** williamr@4: * Cancels a request made by call @c RequestWsBuffer. This should be williamr@4: * called in order to save RAM when higher than normal buffer size is williamr@4: * no longer required. williamr@4: * williamr@4: * @since Series 60 2.0 williamr@4: * williamr@4: * @param aRequestID The request ID returned by the williamr@4: * @c RequestWsBuffer call which is to be canceled. williamr@4: * Negative values are treated as error codes and ignored. williamr@4: */ williamr@4: IMPORT_C void CancelWsBufferRequest( TInt aRequestID ); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * @internal to Series 60 williamr@4: */ williamr@4: IMPORT_C CAknSettingCache& SettingCache() const; williamr@4: williamr@4: /** williamr@4: * Access to the registry of CAknLayoutFont pointers. Used for runtime williamr@4: * checking of CFont pointers. williamr@4: * williamr@4: * @internal to Series 60 williamr@4: * @since Series 60 2.8 williamr@4: * williamr@4: * @return Reference to the registry williamr@4: */ williamr@4: CAknFontRegistry& FontRegistry() const; williamr@4: williamr@4: /** williamr@4: * Access to the system font array that is owned by CEikonEnv. The member accessed by this williamr@4: * is set during CEikonEnv construction and may be null during application startup. williamr@4: * williamr@4: * @internal to Series 60 williamr@4: * @since Series 60 2.8 williamr@4: * williamr@4: * @return Pointer to the system font array williamr@4: */ williamr@4: CArrayPtr* SystemFontArray() const; williamr@4: williamr@4: void UpdateSystemFontsL(); williamr@4: williamr@4: static void ShutOrHideAppL(); williamr@4: williamr@4: public: // layout williamr@4: williamr@4: /** williamr@4: * Load an appropriate Avkon layout. williamr@4: * williamr@4: * @since Series 60 2.6 williamr@4: * @return @c EFalse if the layout is already loaded. williamr@4: */ williamr@4: IMPORT_C TBool LoadAknLayoutL(); williamr@4: /** williamr@4: * Load an appropriate Avkon layout for a particular screen mode. williamr@4: * williamr@4: * @since Series 60 3.1 williamr@4: * @param aScreenMode The screen mode which the layout is required for williamr@4: * @return @c EFalse if the layout is already loaded. williamr@4: */ williamr@4: IMPORT_C TBool LoadAknLayoutL(const TAknLayoutConfigScreenMode& aScreenMode); williamr@4: williamr@4: /** williamr@4: * Re-load the current Avkon layout, in case there are new layout instances present. williamr@4: * williamr@4: * @since Series 60 5.1 williamr@4: */ williamr@4: void ReloadAknLayoutL(); williamr@4: williamr@4: // Avkon layout williamr@4: /** williamr@4: * Accessor method to layout. williamr@4: * williamr@4: * @since Series 60 2.6 williamr@4: * @return Reference to the Layout. williamr@4: */ williamr@4: IMPORT_C const AknLayout::CInstance& AknLayout() const; williamr@4: williamr@4: public: // color support williamr@4: /** williamr@4: * Gets the TRgb value of the entry at the specified index in the colour williamr@4: * lookup table. williamr@4: * williamr@4: * @since Series 60 0.9 williamr@4: * @param The aIndex of the colour lookup table, integer between 0 and 255. williamr@4: * @return The TRgb value of the colour lookup table at the aIndex. williamr@4: */ williamr@4: IMPORT_C static TRgb AvkonColor( TInt ); williamr@4: williamr@4: public: // split view support williamr@4: /** williamr@4: * Checks if split view is active. williamr@4: * @since Series 60 5.0 williamr@4: * @return ETrue if split view is active. williamr@4: */ williamr@4: IMPORT_C TBool SplitViewActive() const; williamr@4: williamr@4: /** williamr@4: * Sets split view flag. williamr@4: * @since Series 60 5.0 williamr@4: * @param aSplitViewActive Etrue if split view is active. williamr@4: */ williamr@4: void SplitViewActive( const TBool aSplitViewActive ); williamr@4: williamr@4: void TransitionEvent(TInt aEvent, const TUid& aAppUid); williamr@4: void TransitionEvent(TInt aEvent); williamr@4: TBool HasBlank() const; williamr@4: williamr@4: public: // future language williamr@4: /* williamr@4: * Check if the feature language is same. williamr@4: * @param aFeatureLanguage feature language (e.g. KFeatureIdJapanese) williamr@4: * @return ETrue if the arg is same as iFeatureLanguage. williamr@4: * @since 3.1 williamr@4: */ williamr@4: TBool IsFeatureLanguage(TInt aFeatureLanguage); williamr@4: williamr@4: private: williamr@4: williamr@4: void SetWsBufferSize(); williamr@4: void SetWsBufferSize( TInt aRequestedBufferSize ); williamr@4: williamr@4: // Only these can use run info array, so it cannot get messed up williamr@4: // by simultaneous use. williamr@4: friend class AknBidiTextUtils; williamr@4: friend class TAknTextWrapper; williamr@4: williamr@4: /** williamr@4: * Returns run info array owned by AknEnv. williamr@4: * williamr@4: * @param aLength Length of the array is returned here. williamr@4: * williamr@4: * @return Run info array owned by AknEnv. williamr@4: */ williamr@4: TBidirectionalState::TRunInfo* RunInfoArray( TInt& aLength ) const; williamr@4: williamr@4: /** williamr@4: * Tests how big run info array the given text requires and williamr@4: * tries to increase the size of the array if required. williamr@4: * williamr@4: * @param aLogicalText Text in logical order. williamr@4: * williamr@4: * @return KErrNone or KErrNoMemory. williamr@4: */ williamr@4: TInt PrepareRunInfoArray( const TDesC& aLogicalText ); williamr@4: williamr@4: /** williamr@4: * Tries to increase the size of the run info array if williamr@4: * it is currently smaller than given length. williamr@4: * williamr@4: * @param aLength Length of the new run info array to be allocated. williamr@4: * williamr@4: * @return KErrNone or KErrNoMemory. williamr@4: */ williamr@4: TInt SetRequiredRunInfoArraySize( TInt aLength ); williamr@4: williamr@4: void SetLayoutRequirementsL(); williamr@4: void AssertLayoutLoaded(); williamr@4: TBool TryLoadAknLayoutL(TAknLayoutId aId, const TAknLayoutConfigScreenMode& aScreenMode, TAknUiZoom aUiZoom); williamr@4: TBool LoadAknLayoutL(TAknLayoutId aId, const TAknLayoutConfigScreenMode& aScreenMode, TAknUiZoom aUiZoom); williamr@4: TAknUiZoom ResolveCurrentUiZoom(); williamr@4: williamr@4: /** williamr@4: * Use the currently loaded layout to set the values of the font size array used by CCoeFontProvider. williamr@4: */ williamr@4: void SetConeFontSizeArrayL() const; williamr@4: williamr@4: private: williamr@4: static TInt RealCloseIntermediateStates(TAny *aEnv); williamr@4: static TInt SchedulerStoppedCallBack(TAny* aWaitNote); williamr@4: void DoSchedulerStoppedCallBack(); williamr@4: williamr@4: private: williamr@4: friend class LafEnv; williamr@4: williamr@4: IMPORT_C static void InstallAknEnvAsExtensionL(CEikonEnv* aEnv); williamr@4: IMPORT_C CAknEnv(); williamr@4: IMPORT_C void ConstructL(); williamr@4: williamr@4: public: williamr@4: /** williamr@4: * Return if Transparency is Enabled . williamr@4: * williamr@4: * @since 5.0 williamr@4: * williamr@4: * @return if Transparency is Enabled. williamr@4: */ williamr@4: IMPORT_C TBool TransparencyEnabled() const; williamr@4: williamr@4: private: williamr@4: MEikMenuObserver* iFepMenuObserver; williamr@4: MAknEditingStateIndicator* iEditStateIndicator; williamr@4: private: williamr@4: CArrayPtr *iStateArray; williamr@4: CArrayPtr *iDeleteArray; williamr@4: CIdle *iIdle; williamr@4: CAknWaitDialog* iBusyMsgDialog; williamr@4: TInt iBusyMsgCount; williamr@4: MEikCommandObserver *iCbaCommandObserver; williamr@4: CAknSettingCache* iSettingCache; williamr@4: TBidirectionalState::TRunInfo* iRunInfoArray; williamr@4: TInt iRunInfoArrayLength; williamr@4: williamr@4: struct TWsBufferRequest williamr@4: { williamr@4: TInt iRequestID; williamr@4: TInt iRequestedSize; williamr@4: }; williamr@4: williamr@4: RArray iWsBufferRequestArray; williamr@4: TInt iRequestIdCounter; williamr@4: TInt iCurrentWsBufferRequest; williamr@4: williamr@4: // cache for layout parameters williamr@4: TAknLayoutId iLastLayoutId; williamr@4: TInt iLastScreenMode; williamr@4: TAknUiZoom iLastZoom; williamr@4: williamr@4: CEikonEnv* iCoeEnv; williamr@4: CAknFontRegistry* iFontRegistry; // Owned register of CAknLayoutFont pointers williamr@4: CCdlEngineRef* iCdlEngRef; williamr@4: const AknLayout::CInstance* iLayout; williamr@4: CArrayPtr* iSystemFontArray; // Not owned. System Font array is owned by CEikonEnv williamr@4: TBool iSplitViewActive; williamr@4: CTransitionManager* iTransitionManager; williamr@4: CAknCommandMediator* iCommandMediator; williamr@4: /* williamr@4: * Set the feature language Id williamr@4: * If device uses Japanese language variant, KFeatureIdJapanese is set. williamr@4: * @since 3.1 williamr@4: */ williamr@4: TInt iFeatureLanguage; williamr@4: }; williamr@4: williamr@4: williamr@4: #define iAvkonEnv (STATIC_CAST(CAknEnv*,iEikonEnv->Extension())) williamr@4: #define AVKONENV (STATIC_CAST(CAknEnv*, CEikonEnv::Static()->Extension())) williamr@4: williamr@4: #endif