1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/aknenv.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,536 @@
1.4 +/*
1.5 +* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +#if !defined(__AVKON_ENV_H__)
1.22 +#define __AVKON_ENV_H__
1.23 +
1.24 +// INCLUDES
1.25 +#include <eikenv.h>
1.26 +#include <eiksbfrm.h>
1.27 +#include <eikcba.h>
1.28 +#include <eikmobs.h>
1.29 +#include <eikmenub.h>
1.30 +#include <eikappui.h>
1.31 +#include <AknLayout2Id.h> // for TAknLayoutId
1.32 +#include <AknDef.h> // for TAknUiZoom
1.33 +
1.34 +// FORWARD DECLARATIONS
1.35 +namespace AknLayout { class CInstance; }
1.36 +namespace LayoutPack { class CInstance; }
1.37 +
1.38 +class CCdlEngineRef;
1.39 +class MAknEditingStateIndicator;
1.40 +class MAknIntermediateState;
1.41 +class CAknAppUi;
1.42 +class CAknWaitDialog;
1.43 +class CEikListBox;
1.44 +class CAknSettingCache;
1.45 +class CAknFontRegistry;
1.46 +class CLafSystemFont;
1.47 +class TAknLayoutConfigScreenMode;
1.48 +class CCdlRefs;
1.49 +class CTransitionManager;
1.50 +class CAknCommandMediator;
1.51 +// Since there is no include of aknsystemfont.h we need the typedef CLafSystemFont here as well
1.52 +// Hence this requires parallel maintenance.
1.53 +typedef CLafSystemFont CAknSystemFont;
1.54 +
1.55 +// MACROS
1.56 +// Color Macros
1.57 +/** Color indirection macros
1.58 + *
1.59 + * This macro takes number from LAF specification and converts it to TRgb for
1.60 + * use to draw things.
1.61 + */
1.62 +
1.63 +// Color macros
1.64 +#define AKN_LAF_COLOR_ENV(env,nn) CAknEnv::AvkonColor(nn)
1.65 +#define AKN_LAF_COLOR(nn) CAknEnv::AvkonColor(nn)
1.66 +#define AKN_LAF_COLOR_STATIC(nn) CAknEnv::AvkonColor(nn)
1.67 +
1.68 + // Avkon layout
1.69 +// IMPORT_C const AknLayout::CInstance& AknLayout() const;
1.70 +
1.71 +
1.72 +// CLASS DECLARATION
1.73 +
1.74 +/**
1.75 +* This class is a Series 60 extension to @c CEikonEnv.
1.76 +* Every Avkon application is provided with an instance of @c CAvkEnv by the
1.77 +* framework, which can be accessed through the @c iAvkonEnv macro.
1.78 +*
1.79 +* @since Series 60 0.9
1.80 +*/
1.81 +class CAknEnv : public CBase
1.82 + {
1.83 +public:
1.84 + /**
1.85 + * Gets the @c CAknEnv maintained by the framework for the application.
1.86 + * Compare @c CCoeEnv::Static().
1.87 + *
1.88 + * This function should never be run in a thread where such a static Avkon
1.89 + * environment does not exist. Code that may run on the server side of an
1.90 + * application server is one such case.
1.91 + * @return A static @c CAknEnv.
1.92 + */
1.93 + IMPORT_C static CAknEnv* Static();
1.94 +
1.95 + /**
1.96 + * Destructor.
1.97 + */
1.98 + IMPORT_C ~CAknEnv();
1.99 +public:
1.100 + // this one creates an empty dialog. for list queries and popup lists with
1.101 + // "No Data" in it.
1.102 + /**
1.103 + * Executes empty popup list.
1.104 + *
1.105 + * @param aEmptyText Text indicating empty popup list. NULL if
1.106 + * @c R_AVKON_EMPTY_POPUP_LIST_TEXT used.
1.107 + */
1.108 +
1.109 + IMPORT_C void ExecuteEmptyPopupListL(const TDesC *aEmptyText=0);
1.110 +
1.111 + /**
1.112 + * Executes empty popup list.
1.113 + * @c aSoftkeyId is soft key rescource used, but shown without left soft
1.114 + * key (except @c R_AVKON_SOFTKEYS_OK_EMPTY).
1.115 + *
1.116 + * @param aEmptyText Text indicating empty popup list. NULL if
1.117 + * @c R_AVKON_EMPTY_POPUP_LIST_TEXT used.
1.118 + * @param aTitle A title of the popup list.
1.119 + * @param aSoftKeyId CBA resource to be used as a base. 0 if
1.120 + * @c R_AVKON_SOFTKEYS_CANCEL is used.
1.121 + */
1.122 + IMPORT_C void ExecuteEmptyPopupListL(const TDesC *aEmptyText,
1.123 + const TDesC *aTitle,
1.124 + TInt aSoftkeyId=0);
1.125 +
1.126 +public:
1.127 + /**
1.128 + * Set the FEP menu observer.
1.129 + *
1.130 + * @param aObserver the FEP menu observer.
1.131 + */
1.132 + IMPORT_C void SetFepMenuObserver(MEikMenuObserver* aObserver);
1.133 +
1.134 + /**
1.135 + * Get the FEP menu observer.
1.136 + *
1.137 + * @return Pointer to the FEP menu observer.
1.138 + */
1.139 + IMPORT_C MEikMenuObserver* FepMenuObserver();
1.140 +
1.141 + /**
1.142 + * Get the editing state indicator.
1.143 + *
1.144 + * @return Pointer to the editing state indicator.
1.145 + */
1.146 + IMPORT_C MAknEditingStateIndicator* EditingStateIndicator();
1.147 +
1.148 +
1.149 + /**
1.150 + * Swap the editing state indicator.
1.151 + *
1.152 + * @param aIndicator The new editing state indicator.
1.153 + * @return The old editing state indicator.
1.154 + */
1.155 + IMPORT_C MAknEditingStateIndicator* SwapEditingStateIndicator(
1.156 + MAknEditingStateIndicator* aIndicator);
1.157 +
1.158 + /**
1.159 + * Exit foreground application.
1.160 + */
1.161 + IMPORT_C static void ExitForegroundAppL();
1.162 +
1.163 +public: // Intermediate states support
1.164 + /**
1.165 + * Register the control implementing intermediate states.
1.166 + * Call @c iAvkonEnv->RegisterIntermediateState(this) in control's
1.167 + * @c ActivateL().
1.168 + *
1.169 + * @param aState The control implementing intermediate states.
1.170 + */
1.171 + IMPORT_C void RegisterIntermediateStateL(MAknIntermediateState *aState);
1.172 +
1.173 + /**
1.174 + * Unregister the control implementing intermediate states.
1.175 + * Call @c iAvkonEnv->UnRegisterIntermediateState(this) in control's
1.176 + * destructor.
1.177 + *
1.178 + * @param aState The control implementing intermediate states.
1.179 + */
1.180 + IMPORT_C void UnRegisterIntermediateState(MAknIntermediateState *aState);
1.181 +
1.182 + /**
1.183 + * Closes all intermediate states as a low-priority process.
1.184 + */
1.185 + IMPORT_C void CloseAllIntermediateStates();
1.186 +
1.187 +public:
1.188 + /**
1.189 + * Run application shutter.
1.190 + */
1.191 + IMPORT_C static void RunAppShutter();
1.192 +
1.193 + /**
1.194 + * Get pointer to the most embedded application UI with Dialog Shutter
1.195 + * running.
1.196 + *
1.197 + * @return Pointer to the most embedded application UI with Dialog Shutter
1.198 + * running. @c NULL if no any Dialog Shutter running.
1.199 + */
1.200 + IMPORT_C static CAknAppUi* AppWithShutterRunning();
1.201 +
1.202 + /**
1.203 + * Stop the scheduler. If the waiting control can't stop the scheduler
1.204 + * immediately, then trying to show a busy note.
1.205 + * @param aWait Scheduler object to be stopped.
1.206 + */
1.207 + IMPORT_C static void StopSchedulerWaitWithBusyMessage(
1.208 + CActiveSchedulerWait& aWait);
1.209 +
1.210 +public:
1.211 + /**
1.212 + * Create CBA observer. The possible existing one is removed first.
1.213 + * @param aCba A control which @c ProcessCommandL handles the command.
1.214 + * @param aListBox Stored to data member @c iListBox.
1.215 + */
1.216 + IMPORT_C void CreateCbaObserverL(CEikButtonGroupContainer *aCba,
1.217 + CEikListBox *aListBox);
1.218 +
1.219 + /**
1.220 + * Remove CBA observer.
1.221 + */
1.222 + IMPORT_C void RemoveCbaObserver();
1.223 +
1.224 +
1.225 + /**
1.226 + * Remove CBA observer if the right one.
1.227 + * @param aCba CBA to be checked.
1.228 + */
1.229 + IMPORT_C void InformCbaDeletion(CEikButtonGroupContainer *aCba);
1.230 +
1.231 + /**
1.232 + * Requests mediation of MSK commmands from specified CBA to the
1.233 + * given observer. When called for the first time, this method creates
1.234 + * an observer that is added to specified CBA to observe MSK commands
1.235 + * and to mediate all received events to the given observer. The created
1.236 + * observer exists until the CAknEnv instance is destroyed. All subsequent
1.237 + * calls to this method replace the previously requested mediation.
1.238 + *
1.239 + * @param aCba CBA whose MSK is to be observed.
1.240 + * @param aCommandObserver An observer for which the commands are sent.
1.241 + */
1.242 + IMPORT_C void RequestCommandMediationL( CEikButtonGroupContainer& aCba,
1.243 + MEikCommandObserver& aCommandObserver );
1.244 +
1.245 + /**
1.246 + * Ends mediating MSK commands to specified command observer. If commands
1.247 + * are being mediated to the specifed observer, the command mediator is
1.248 + * removed from the CBA to end mediation.
1.249 + *
1.250 + * @param aCommandObserver An observer.
1.251 + */
1.252 + IMPORT_C void EndCommandMediation( MEikCommandObserver& aCommandObserver );
1.253 +
1.254 +public:
1.255 + /**
1.256 + * Get current layout ID.
1.257 + * @since Series 60 2.0
1.258 + * @param aCurrentLayoutId On return, contains current layout ID.
1.259 + */
1.260 + IMPORT_C void GetCurrentLayoutId(TAknLayoutId& aCurrentLayoutId) const;
1.261 +
1.262 + /**
1.263 + * Get current global zoom
1.264 + * @since 3.1
1.265 + * @param aCurrentGlobalUiZoom On return, contains current global zoom.
1.266 + */
1.267 + IMPORT_C void GetCurrentGlobalUiZoom(TAknUiZoom& aCurrentGlobalUiZoom) const;
1.268 +
1.269 +public:
1.270 + /**
1.271 + * Tells the type of status pane layout for UI.
1.272 + * @since Series 60 2.0
1.273 + * @param aResId resource id for current layout.
1.274 + * @return Resource id equivalent type of status pane layout.
1.275 + */
1.276 + IMPORT_C TInt StatusPaneResIdForCurrentLayout(TInt aResId) const;
1.277 +
1.278 +public:
1.279 + /**
1.280 + * Requests Window Server client buffer used by the application to
1.281 + * be of at least the given size. All code that wants to increase
1.282 + * (to avoid flicker) or decrease (to save RAM) the buffer compared
1.283 + * to the default size should call this method instead of using
1.284 + * WS interface directly. A list of all requests is maintained
1.285 + * and the highest request is always effective. Only if there are no
1.286 + * requests done, the default buffer size is used.
1.287 + *
1.288 + * @since Series 60 2.0
1.289 + *
1.290 + * @param aRequestedBufferSize requested Window Server client buffer size.
1.291 + *
1.292 + * @return Request ID. This is used when the request is canceled.
1.293 + * In OOM situation, @c KErrNoMemory is returned.
1.294 + * @c CancelWsBufferRequest ignores negative values as error codes
1.295 + * so it is OK to pass any value returned by this method to
1.296 + * @c CancelWsBufferRequest.
1.297 + */
1.298 + IMPORT_C TInt RequestWsBuffer( TInt aRequestedBufferSize );
1.299 +
1.300 + /**
1.301 + * Cancels a request made by call @c RequestWsBuffer. This should be
1.302 + * called in order to save RAM when higher than normal buffer size is
1.303 + * no longer required.
1.304 + *
1.305 + * @since Series 60 2.0
1.306 + *
1.307 + * @param aRequestID The request ID returned by the
1.308 + * @c RequestWsBuffer call which is to be canceled.
1.309 + * Negative values are treated as error codes and ignored.
1.310 + */
1.311 + IMPORT_C void CancelWsBufferRequest( TInt aRequestID );
1.312 +
1.313 +public:
1.314 + /**
1.315 + * @internal to Series 60
1.316 + */
1.317 + IMPORT_C CAknSettingCache& SettingCache() const;
1.318 +
1.319 + /**
1.320 + * Access to the registry of CAknLayoutFont pointers. Used for runtime
1.321 + * checking of CFont pointers.
1.322 + *
1.323 + * @internal to Series 60
1.324 + * @since Series 60 2.8
1.325 + *
1.326 + * @return Reference to the registry
1.327 + */
1.328 + CAknFontRegistry& FontRegistry() const;
1.329 +
1.330 + /**
1.331 + * Access to the system font array that is owned by CEikonEnv. The member accessed by this
1.332 + * is set during CEikonEnv construction and may be null during application startup.
1.333 + *
1.334 + * @internal to Series 60
1.335 + * @since Series 60 2.8
1.336 + *
1.337 + * @return Pointer to the system font array
1.338 + */
1.339 + CArrayPtr<CAknSystemFont>* SystemFontArray() const;
1.340 +
1.341 + void UpdateSystemFontsL();
1.342 +
1.343 + static void ShutOrHideAppL();
1.344 +
1.345 +public: // layout
1.346 +
1.347 + /**
1.348 + * Load an appropriate Avkon layout.
1.349 + *
1.350 + * @since Series 60 2.6
1.351 + * @return @c EFalse if the layout is already loaded.
1.352 + */
1.353 + IMPORT_C TBool LoadAknLayoutL();
1.354 + /**
1.355 + * Load an appropriate Avkon layout for a particular screen mode.
1.356 + *
1.357 + * @since Series 60 3.1
1.358 + * @param aScreenMode The screen mode which the layout is required for
1.359 + * @return @c EFalse if the layout is already loaded.
1.360 + */
1.361 + IMPORT_C TBool LoadAknLayoutL(const TAknLayoutConfigScreenMode& aScreenMode);
1.362 +
1.363 + /**
1.364 + * Re-load the current Avkon layout, in case there are new layout instances present.
1.365 + *
1.366 + * @since Series 60 5.1
1.367 + */
1.368 + void ReloadAknLayoutL();
1.369 +
1.370 + // Avkon layout
1.371 + /**
1.372 + * Accessor method to layout.
1.373 + *
1.374 + * @since Series 60 2.6
1.375 + * @return Reference to the Layout.
1.376 + */
1.377 + IMPORT_C const AknLayout::CInstance& AknLayout() const;
1.378 +
1.379 +public: // color support
1.380 + /**
1.381 + * Gets the TRgb value of the entry at the specified index in the colour
1.382 + * lookup table.
1.383 + *
1.384 + * @since Series 60 0.9
1.385 + * @param The aIndex of the colour lookup table, integer between 0 and 255.
1.386 + * @return The TRgb value of the colour lookup table at the aIndex.
1.387 + */
1.388 + IMPORT_C static TRgb AvkonColor( TInt );
1.389 +
1.390 +public: // split view support
1.391 + /**
1.392 + * Checks if split view is active.
1.393 + * @since Series 60 5.0
1.394 + * @return ETrue if split view is active.
1.395 + */
1.396 + IMPORT_C TBool SplitViewActive() const;
1.397 +
1.398 + /**
1.399 + * Sets split view flag.
1.400 + * @since Series 60 5.0
1.401 + * @param aSplitViewActive Etrue if split view is active.
1.402 + */
1.403 + void SplitViewActive( const TBool aSplitViewActive );
1.404 +
1.405 + void TransitionEvent(TInt aEvent, const TUid& aAppUid);
1.406 + void TransitionEvent(TInt aEvent);
1.407 + TBool HasBlank() const;
1.408 +
1.409 +public: // future language
1.410 + /*
1.411 + * Check if the feature language is same.
1.412 + * @param aFeatureLanguage feature language (e.g. KFeatureIdJapanese)
1.413 + * @return ETrue if the arg is same as iFeatureLanguage.
1.414 + * @since 3.1
1.415 + */
1.416 + TBool IsFeatureLanguage(TInt aFeatureLanguage);
1.417 +
1.418 +private:
1.419 +
1.420 + void SetWsBufferSize();
1.421 + void SetWsBufferSize( TInt aRequestedBufferSize );
1.422 +
1.423 + // Only these can use run info array, so it cannot get messed up
1.424 + // by simultaneous use.
1.425 + friend class AknBidiTextUtils;
1.426 + friend class TAknTextWrapper;
1.427 +
1.428 + /**
1.429 + * Returns run info array owned by AknEnv.
1.430 + *
1.431 + * @param aLength Length of the array is returned here.
1.432 + *
1.433 + * @return Run info array owned by AknEnv.
1.434 + */
1.435 + TBidirectionalState::TRunInfo* RunInfoArray( TInt& aLength ) const;
1.436 +
1.437 + /**
1.438 + * Tests how big run info array the given text requires and
1.439 + * tries to increase the size of the array if required.
1.440 + *
1.441 + * @param aLogicalText Text in logical order.
1.442 + *
1.443 + * @return KErrNone or KErrNoMemory.
1.444 + */
1.445 + TInt PrepareRunInfoArray( const TDesC& aLogicalText );
1.446 +
1.447 + /**
1.448 + * Tries to increase the size of the run info array if
1.449 + * it is currently smaller than given length.
1.450 + *
1.451 + * @param aLength Length of the new run info array to be allocated.
1.452 + *
1.453 + * @return KErrNone or KErrNoMemory.
1.454 + */
1.455 + TInt SetRequiredRunInfoArraySize( TInt aLength );
1.456 +
1.457 + void SetLayoutRequirementsL();
1.458 + void AssertLayoutLoaded();
1.459 + TBool TryLoadAknLayoutL(TAknLayoutId aId, const TAknLayoutConfigScreenMode& aScreenMode, TAknUiZoom aUiZoom);
1.460 + TBool LoadAknLayoutL(TAknLayoutId aId, const TAknLayoutConfigScreenMode& aScreenMode, TAknUiZoom aUiZoom);
1.461 + TAknUiZoom ResolveCurrentUiZoom();
1.462 +
1.463 + /**
1.464 + * Use the currently loaded layout to set the values of the font size array used by CCoeFontProvider.
1.465 + */
1.466 + void SetConeFontSizeArrayL() const;
1.467 +
1.468 +private:
1.469 + static TInt RealCloseIntermediateStates(TAny *aEnv);
1.470 + static TInt SchedulerStoppedCallBack(TAny* aWaitNote);
1.471 + void DoSchedulerStoppedCallBack();
1.472 +
1.473 +private:
1.474 + friend class LafEnv;
1.475 +
1.476 + IMPORT_C static void InstallAknEnvAsExtensionL(CEikonEnv* aEnv);
1.477 + IMPORT_C CAknEnv();
1.478 + IMPORT_C void ConstructL();
1.479 +
1.480 +public:
1.481 + /**
1.482 + * Return if Transparency is Enabled .
1.483 + *
1.484 + * @since 5.0
1.485 + *
1.486 + * @return if Transparency is Enabled.
1.487 + */
1.488 + IMPORT_C TBool TransparencyEnabled() const;
1.489 +
1.490 +private:
1.491 + MEikMenuObserver* iFepMenuObserver;
1.492 + MAknEditingStateIndicator* iEditStateIndicator;
1.493 +private:
1.494 + CArrayPtr<MAknIntermediateState> *iStateArray;
1.495 + CArrayPtr<CBase> *iDeleteArray;
1.496 + CIdle *iIdle;
1.497 + CAknWaitDialog* iBusyMsgDialog;
1.498 + TInt iBusyMsgCount;
1.499 + MEikCommandObserver *iCbaCommandObserver;
1.500 + CAknSettingCache* iSettingCache;
1.501 + TBidirectionalState::TRunInfo* iRunInfoArray;
1.502 + TInt iRunInfoArrayLength;
1.503 +
1.504 + struct TWsBufferRequest
1.505 + {
1.506 + TInt iRequestID;
1.507 + TInt iRequestedSize;
1.508 + };
1.509 +
1.510 + RArray<TWsBufferRequest> iWsBufferRequestArray;
1.511 + TInt iRequestIdCounter;
1.512 + TInt iCurrentWsBufferRequest;
1.513 +
1.514 + // cache for layout parameters
1.515 + TAknLayoutId iLastLayoutId;
1.516 + TInt iLastScreenMode;
1.517 + TAknUiZoom iLastZoom;
1.518 +
1.519 + CEikonEnv* iCoeEnv;
1.520 + CAknFontRegistry* iFontRegistry; // Owned register of CAknLayoutFont pointers
1.521 + CCdlEngineRef* iCdlEngRef;
1.522 + const AknLayout::CInstance* iLayout;
1.523 + CArrayPtr<CAknSystemFont>* iSystemFontArray; // Not owned. System Font array is owned by CEikonEnv
1.524 + TBool iSplitViewActive;
1.525 + CTransitionManager* iTransitionManager;
1.526 + CAknCommandMediator* iCommandMediator;
1.527 + /*
1.528 + * Set the feature language Id
1.529 + * If device uses Japanese language variant, KFeatureIdJapanese is set.
1.530 + * @since 3.1
1.531 + */
1.532 + TInt iFeatureLanguage;
1.533 + };
1.534 +
1.535 +
1.536 +#define iAvkonEnv (STATIC_CAST(CAknEnv*,iEikonEnv->Extension()))
1.537 +#define AVKONENV (STATIC_CAST(CAknEnv*, CEikonEnv::Static()->Extension()))
1.538 +
1.539 +#endif