Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
25 #include <coetextdrawer.h>
27 #if defined(USE_IH_RAISE_EVENT)
28 #include <systemmonitor/raiseevent.h>
29 #include <test/testinstrumentation.h>
32 class CVwsSessionWrapper;
33 class MVwsSessionWrapperObserver;
34 class TCoeInputCapabilities; // forward declaration of class defined in COEINPUT.H
37 class TResourceReader;
38 class RGenericPointerArray;
39 class CCoeFep; // must derive from CBase
40 class CCoeFontProvider;
45 /** UI Control framework active object priorities.
46 These are in addition to the values contained in the TPriority enum in class CActive.
53 EActivePriorityClockTimer=300,
55 EActivePriorityIpcEventsHigh=200,
57 EActivePriorityFepLoader=150,
59 EActivePriorityWsEvents=100,
61 EActivePriorityRedrawEvents=50,
63 EActivePriorityDefault=0,
65 EActivePriorityLogonA=-10
69 /** Interface providing notification when there is a change in the currently
72 This happens either on application start-up, or as a result of a different
73 front end processor having been installed.
75 Anyone requiring this notification should derive from this class and implement
76 its pure virtual function. Derived classes also need to call CCoeEnv::AddObserverOfLoadedFepL()
77 during construction, and CCoeEnv::RemoveObserverOfLoadedFep() in their destructor.
81 class MCoeObserverOfLoadedFep
84 /** Handles a change in the loaded FEP.
86 The function is called if a new FEP is loaded, or if the current one is unloaded. */
87 virtual void HandleChangeInLoadedFep()=0;
89 IMPORT_C MCoeObserverOfLoadedFep();
92 IMPORT_C virtual void MCoeObserverOfLoadedFep_Reserved_1();
93 IMPORT_C virtual void MCoeObserverOfLoadedFep_Reserved_2();
95 TInt iMCoeObserverOfLoadedFep_Reserved1;
99 /** Interface providing notification if any control gains or loses focus or is
102 The FEP framework uses this class to observe when a target control changes
103 for reasons unrelated to the FEP.
105 Anything that needs such notification should derive from this class and implement
106 its two pure virtual functions.
108 In addition, derived classes need to call CCoeEnv::AddFocusObserverL() during
109 construction, and CCoeEnv::RemoveFocusObserver() in their destructors.
114 class MCoeFocusObserver
117 /** Handles changes in focus. The function is called if any control gains or loses
119 virtual void HandleChangeInFocus()=0;
120 /** Handles the destruction of any control. It is called by the framework if any
121 control is destroyed. */
122 virtual void HandleDestructionOfFocusedItem()=0;
124 IMPORT_C MCoeFocusObserver();
126 IMPORT_C virtual void MCoeFocusObserver_Reserved_1();
127 IMPORT_C virtual void MCoeFocusObserver_Reserved_2();
129 TInt iMCoeFocusObserver_Reserved1;
132 /** An interface which enables message windows to observe resource changes.
134 Resource change observers should be added to the control environment using
135 CCoeEnv::AddResourceChangeObserverL().
139 class MCoeResourceChangeObserver
142 /** Handles a change to the application's resources. */
143 virtual void HandleResourceChange()=0;
145 IMPORT_C MCoeResourceChangeObserver();
147 IMPORT_C virtual void MCoeResourceChangeObserver_Reserved_1();
148 IMPORT_C virtual void MCoeResourceChangeObserver_Reserved_2();
150 TInt iMCoeResourceChangeObserver_Reserved1;
153 /** Interface providing notification of foreground/background changes.
155 The FEP framework class, CCoeFep, derives from MCoeForegroundObserver, which
156 enables FEPs to receive notification when the target application (which receives
157 the FEP's output) goes into the foreground or background.
159 Anything that needs this notification should derive from this class and override
160 its two pure virtual functions.
162 In addition, derived classes also need to call CCoeEnv::AddForegroundObserverL()
163 during construction, and CCoeEnv::RemoveForegroundObserver() in their destructors.
168 class MCoeForegroundObserver
171 /** Handles the application coming to the foreground. */
172 virtual void HandleGainingForeground()=0;
173 /** Handles the application going into the background. */
174 virtual void HandleLosingForeground()=0;
176 IMPORT_C MCoeForegroundObserver();
178 IMPORT_C virtual void MCoeForegroundObserver_Reserved_1();
179 IMPORT_C virtual void MCoeForegroundObserver_Reserved_2();
181 TInt iMCoeForegroundObserver_Reserved1;
185 /** Interface for handling incoming window server messages.
187 This interface is used to enable FEPs to keep their settings synchronised
188 across all running instances.
190 Anything that needs to be notified of messages that get sent by the window server's
191 message-sending service should derive from this class and override its pure
194 In addition, derived classes also need to call CCoeEnv::AddMessageObserverL()
195 during construction and CCoeEnv::RemoveMessageObserver() in their destructors.
199 class MCoeMessageObserver
202 /** Message response flags. */
203 enum TMessageResponse
205 /** Message not handled. */
207 /** Message handled. */
211 /** Handles window server messages.
213 Implementations should return EMessageHandled if they are able to handle the
214 message, or EMessageNotHandled if the message is not appropriate to this observer.
216 @param aClientHandleOfTargetWindowGroup The window group that the message
217 was sent to. Many implementations will not need this information.
218 @param aMessageUid The message UID.
219 @param aMessageParameters The message parameters.
220 @return Indicates whether the message was handled or not handled
222 virtual TMessageResponse HandleMessageL(TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid, const TDesC8& aMessageParameters)=0;
224 IMPORT_C MCoeMessageObserver();
226 IMPORT_C virtual void MCoeMessageObserver_Reserved_1();
227 IMPORT_C virtual void MCoeMessageObserver_Reserved_2();
230 /** Mix-in interface for handling window visibility messages.
234 class MCoeMessageMonitorObserver
237 /** Received windows messages for monitoring.
238 @param aEvent The windows server event data.*/
239 virtual void MonitorWsMessage(const TWsEvent& aEvent)=0;
241 IMPORT_C virtual void MCoeMessageMonitorObserver_Reserved_1();
242 IMPORT_C virtual void MCoeMessageMonitorObserver_Reserved_2();
245 // classes defined in FEPBASE, declared here
246 class MCoeFepObserver;
252 typedef void (*TCoeFepObserverFunction)(MCoeFepObserver& aFepObserver);
258 class CCoeFepParameters : public CBase
261 static CCoeFepParameters* NewLC();
263 inline CCoeFepParameters() {}
267 /** Implements the active scheduler presupposed by the control environment.
272 class CCoeScheduler : public CBaActiveScheduler
275 IMPORT_C CCoeScheduler(CCoeEnv* aCoeEnv);
276 IMPORT_C virtual void WaitForAnyRequest();
277 IMPORT_C virtual void DisplayError(TInt aError) const;
278 /** Gets the control environment.
280 @return A pointer to the control environment. */
281 inline CCoeEnv* CoeEnv() {return iCoeEnv;}
282 TBool Flush() const; // not to be called from outside CONE
283 void SetFlush(TBool aFlush); // not to be called from outside CONE
285 // from CBaActiveScheduler
286 IMPORT_C virtual void Reserved_1();
287 IMPORT_C virtual void Reserved_2();
295 /** Control environment.
297 CCoeEnv provides an active environment for creating controls. It implements
298 active objects and an active scheduler, which provide access to the window
299 server, simplifying the API for application programs. It also provides utility
300 functions that are useful to many applications.
302 When a standard event occurs, the active scheduler calls CCoeEnv::RunL().
303 When a redraw event occurs, it calls CCoeRedrawer::RunL(). Priority key events
304 must be accessed using the Window Server API directly.
306 Note: standard events are all events except redraw events and priority key events.
310 class CCoeEnv : public CActive, public MObjectProvider
314 IMPORT_C static TVersion Version();
315 IMPORT_C static CCoeEnv* Static();
316 // Construction and destruction
319 IMPORT_C void ConstructL();
320 IMPORT_C void ConstructL(TBool aInitialFocusState);
321 IMPORT_C void ConstructL(TBool aInitialFocusState, TInt aDefaultScreenNumber);
322 IMPORT_C void ConstructL(TBool aInitialFocusState, TInt aDefaultScreenNumber, TInt aWindowGroupID);
323 IMPORT_C CCoeAppUi* SetAppUi(CCoeAppUi* aAppUi);
324 IMPORT_C void ExecuteD();
325 IMPORT_C void Execute();
326 IMPORT_C void RunL();
327 IMPORT_C void DoCancel();
328 IMPORT_C void PrepareToExit();
329 IMPORT_C virtual void DestroyEnvironment();
330 IMPORT_C void DisableExitChecks(TBool aDisable);
331 IMPORT_C virtual void HandleError(TInt aError);
333 inline CCoeAppUi* AppUi() const;
334 inline RFs& FsSession() const;
335 inline RWsSession& WsSession() const;
336 inline RWindowGroup& RootWin() const;
337 inline CWsScreenDevice* ScreenDevice() const;
338 inline CWindowGc& SystemGc() const;
339 inline const CFont* NormalFont() const;
340 inline const TWsEvent& LastEvent() const;
341 inline TBool IsSchedulerRunning() const;
343 IMPORT_C CWindowGc* CreateGcL();
344 IMPORT_C CWindowGc* SwapSystemGc(CWindowGc* aGc);
345 IMPORT_C void Flush(TTimeIntervalMicroSeconds32 aDelay=0);
346 IMPORT_C void SuppressNextFlush();
347 IMPORT_C TBool IsWservEventPending() const;
348 IMPORT_C TBool IsRedrawEventPending() const;
349 // Fonts (legacy API)
350 IMPORT_C CFbsFont* CreateDeviceFontL(CGraphicsDevice* aDevice,const TFontSpec& aFontSpec);
351 IMPORT_C CFbsFont* CreateScreenFontL(const TFontSpec& aFontSpec);
352 IMPORT_C void ReleaseScreenFont(CFont* aFont) const;
354 IMPORT_C const CCoeFontProvider& DefaultFontProvider() const;
356 IMPORT_C CCoeTextDrawerBase& DefaultTextDrawer() const;
358 IMPORT_C TZoomFactor ZoomFactor() const;
359 IMPORT_C void SetZoomFactor(const TZoomFactor& aZoomFactor);
361 IMPORT_C TInt AddResourceFileL(const TDesC& aFileName);
362 IMPORT_C void DeleteResourceFile(TInt aOffset);
363 IMPORT_C TBool IsResourceAvailableL(TInt aResourceId) const;
364 IMPORT_C void CreateResourceReaderLC(TResourceReader& aReader,TInt aResourceId) const;
365 inline void ReadResource(TDes& aDes,TInt aResourceId) const;
366 inline void ReadResourceL(TDes& aDes,TInt aResourceId) const;
367 inline HBufC* AllocReadResourceL(TInt aResourceId) const;
368 inline HBufC* AllocReadResourceLC(TInt aResourceId) const;
369 inline CDesCArrayFlat* ReadDesCArrayResourceL(TInt aResourceId);
370 IMPORT_C void ReadResourceAsDes8(TDes8& aDes,TInt aResourceId) const; /** @deprecated 7.0*/
371 IMPORT_C void ReadResourceAsDes8L(TDes8& aDes,TInt aResourceId) const;
372 IMPORT_C HBufC8* AllocReadResourceAsDes8L(TInt aResourceId) const;
373 IMPORT_C HBufC8* AllocReadResourceAsDes8LC(TInt aResourceId) const;
374 IMPORT_C CDesC8ArrayFlat* ReadDesC8ArrayResourceL(TInt aResourceId);
375 IMPORT_C void ReadResourceAsDes16(TDes16& aDes,TInt aResourceId) const; /** @deprecated 7.0*/
376 IMPORT_C void ReadResourceAsDes16L(TDes16& aDes,TInt aResourceId) const;
377 IMPORT_C HBufC16* AllocReadResourceAsDes16L(TInt aResourceId) const;
378 IMPORT_C HBufC16* AllocReadResourceAsDes16LC(TInt aResourceId) const;
379 IMPORT_C CDesC16ArrayFlat* ReadDesC16ArrayResourceL(TInt aResourceId);
380 IMPORT_C void Format128(TDes& aDes,TInt aResourceId,...);
381 IMPORT_C void Format256(TDes& aDes,TInt aResourceId,...);
383 IMPORT_C void LeaveWithErrorText(const TDesC& aMsg,const TDesC* aContextText=NULL);
385 IMPORT_C void SimulateKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
387 IMPORT_C void AddObserverOfLoadedFepL(MCoeObserverOfLoadedFep& aObserverOfLoadedFep);
388 IMPORT_C void RemoveObserverOfLoadedFep(MCoeObserverOfLoadedFep& aObserverOfLoadedFep);
389 IMPORT_C void AddFepObserverL(MCoeFepObserver& aFepObserver);
390 IMPORT_C void RemoveFepObserver(MCoeFepObserver& aFepObserver);
391 IMPORT_C void ForEachFepObserverCall(TCoeFepObserverFunction aFepObserverFunction);
392 void EnsureCorrectFepIsLoadedL();
393 void EnsureSpecifiedFepIsLoadedL(TUid aFepUid);
394 IMPORT_C void InstallFepL(TUid aFepUid);
395 IMPORT_C void InstallFepL(TUid aFepUid, const TBool aLeave);
396 IMPORT_C void AvailableFepsL(RArray<TUid>& aUids, CDesCArray* aDisplayNames);
397 IMPORT_C void ExecuteFepSettingsDialogL(TUid aFepUid);
398 IMPORT_C CCoeFep* Fep() const;
399 IMPORT_C TUid FepUid() const;
400 IMPORT_C void InputCapabilitiesChanged();
401 // Control focus handling
402 IMPORT_C void AddFocusObserverL(MCoeFocusObserver& aFocusObserver);
403 IMPORT_C void RemoveFocusObserver(MCoeFocusObserver& aFocusObserver);
404 IMPORT_C void SyncNotifyFocusObserversOfChangeInFocus();
405 void NotifyFocusObserversOfDestructionOfFocusedItem();
406 // Application focus (foreground) handling
407 IMPORT_C void BringOwnerToFront();
408 IMPORT_C void AddForegroundObserverL(MCoeForegroundObserver& aForegroundObserver);
409 IMPORT_C void RemoveForegroundObserver(MCoeForegroundObserver& aForegroundObserver);
410 void NotifyForegroundObserversOfGainingForeground();
411 void NotifyForegroundObserversOfLosingForeground();
412 // Resource change handling
413 IMPORT_C void AddResourceChangeObserverL(MCoeResourceChangeObserver& aResourceChangeObserver);
414 IMPORT_C void RemoveResourceChangeObserver(MCoeResourceChangeObserver& aResourceChangeObserver);
415 void NotifyResourceObserversOfChangeInResource();
416 // Window server message handling
417 IMPORT_C void AddMessageObserverL(MCoeMessageObserver& aMessageObserver);
418 IMPORT_C void RemoveMessageObserver(MCoeMessageObserver& aMessageObserver);
419 IMPORT_C void AddMessageMonitorObserverL(MCoeMessageMonitorObserver& aMessageMonitorObserver);
420 IMPORT_C void RemoveMessageMonitorObserver(MCoeMessageMonitorObserver& aMessageMonitorObserver);
421 void NotifyMessageMonitorObserversOfEvent(const TWsEvent& aEvent);
423 IMPORT_C static CCoeStatic* Static(TUid aUid);
424 IMPORT_C CCoeStatic* FindStatic(TUid aUid);
425 #if defined(SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS)
427 IMPORT_C CWsScreenDevice* ScreenDevice(TInt aScreenNumber) const;
428 IMPORT_C RWindowGroup* RootWin(TInt aScreenNumber) const;
430 public: // *** Do not use! API liable to change ***
431 TInt AppStartupInstrumentationEventIdBase();
432 public: // Internal to Symbian
433 IMPORT_C void GetMessageNotifyingObserversLC(TUint32 aClientHandleOfTargetWindowGroup, TUid& aMessageUid, TPtr8& aMessageParameters, const TWsEvent& aMessageEvent);
434 IMPORT_C TBool DisableShutdownChecks() const;
435 protected: // Internal to Symbian
436 IMPORT_C void SetAppStartupInstrumentationEventIdBaseL(TInt aAppStartupInstrumentationEventIdBase);
437 IMPORT_C void DestroyEnvironmentStatic();
438 IMPORT_C void DestroyEnvironmentEnd();
439 IMPORT_C TInt CoeEnvConstructorError() const;
440 private: // reserved virtual function space
441 IMPORT_C virtual void Reserved_1();
442 IMPORT_C virtual void Reserved_2();
443 private: // from CActive
444 IMPORT_C TInt RunError(TInt aError);
445 protected: // from MObjectProvider
446 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
448 IMPORT_C virtual void DestroyScreen();
449 inline TDes& ErrorText();
450 inline TDes& ErrorContextText();
451 public: // but not exported
453 CVwsSessionWrapper* InitViewServerSessionL(MVwsSessionWrapperObserver& aObserver);
454 void AddStatic(CCoeStatic* aStatic);
455 void QueueNotificationToFocusObserversOfChangeInFocus();
456 TInt FocusObserverNotificationIdentifier() const;
457 TBool FocusObserverNotificationIsStillPending(TInt aFocusObserverNotificationIdentifier) const;
458 void RefetchPixelMappingL();
459 TBool ControlStateChange();
461 void CreateActiveSchedulerL();
462 void ConnectToFileServerL();
463 void ConnectToWindowServerL();
464 void InitScreenL( TInt aDefaultScreenNumber );
465 void InitRootWindowL(TBool aInitialFocusState, TInt aWindowGroupID=0);
466 void InitSystemGcL();
467 IMPORT_C virtual void InitSystemFontsL();
468 IMPORT_C virtual TInt ResourceFileVersionNumber() const;
469 RResourceFile& ResourceFileForId(TInt aResourceId) const;
470 void DestroyAllResourceFiles();
471 void AddObserverL(TAny* aObserver, RGenericPointerArray& aArray);
472 void RemoveObserver(TAny* aObserver, RGenericPointerArray& aArray);
473 void UpdateStatic(CCoeAppUi* aNewAppUi);
474 void SetInitialHandleCount();
475 TUint InitialHandleCount() const;
476 RResourceFile* DoResourceFileForIdL(TInt aResourceId) const;
477 #if defined(SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS)
478 void PopulateArrayOfScreenItemsL();
479 void DeleteArrayOfScreensItems();
484 RWsSession iWsSession;
485 RWindowGroup iRootWin;
486 CWindowGc* iSystemGc;
487 const CFont* iNormalFont;
488 CWsScreenDevice* iScreen;
490 CArrayFix<RResourceFile>* iResourceFileArray;
492 enum TFlags // used in the bottom 16 bits only of iEnvFlags
494 ENoShutdownChecks =0x0001,
495 EExtraPointerIsErrorCode =0x0002,
496 ESchedulerIsRunning =0x0004
500 TDes* iErrorContextText;
501 CCoeEnvExtra* iExtra;
502 CTrapCleanup* iCleanup;
506 /** Base class for creating singleton objects that will be stored by CCoeEnv.
508 Each object must have a unique TUid.
510 Symbian OS does not provide writeable global static data. Singleton objects
511 provide its equivalent in thread local storage, which is supported.
513 This behaviour is useful for objects in which only one copy is ever needed
514 in the thread or application, e.g. in alert windows.
518 class CCoeStatic : public CBase
521 /** Scope of access to the singleton object. */
524 /** Access from the entire thread. */
526 /** Access from an appUi in that thread. */
529 /** The default destruction priority if none is specified in the constructor */
530 enum {EDefaultDestructionPriority=100};
532 IMPORT_C ~CCoeStatic();
534 IMPORT_C CCoeStatic();
535 IMPORT_C CCoeStatic(TUid aUid,TScope=EThread);
536 IMPORT_C CCoeStatic(TUid aUid,TInt aDestructionPriority,TScope aScope=EThread);
538 IMPORT_C virtual void CCoeStatic_Reserved1();
539 IMPORT_C virtual void CCoeStatic_Reserved2();
541 void DoConstruction(const TUid& aUid,TInt aDestructionPriority,TScope aScope);
542 void SetCsAppUi(CCoeAppUi* aAppUi);
543 CCoeAppUi* CsAppUi() const;
544 TScope CsScope() const;
545 inline TInt DestructionPriority() const {return iCsLink.iPriority;}
549 TUint iCsAppUiAndScope;
550 TInt iCCoeStatic_Reserved1;
552 friend class CCoeEnv;
553 friend class CCoeEnvExtra;
556 #include <coemain.inl>
558 #endif // __COEMAIN_H__