// COEAUI.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__COEAUI_H__)
#define __COEAUI_H__

#if !defined(__E32STD_H__)
#include <e32std.h>
#endif

#if !defined(__E32BASE_H__)
#include <e32base.h>
#endif

#if !defined(__W32STD_H__)
#include <w32std.h>
#endif

#if !defined(__COEDEF_H__)
#include <coedef.h>
#endif

#if !defined(__COEAUIB_H__)
#include <coeauib.h>
#endif

class CCoeEnv;
class CCoeControl;

enum
	{
	ECoeStackPriorityDefault=0,
	ECoeStackPriorityMenu=10,
	ECoeStackPriorityDialog=50,
	ECoeStackPriorityAlert=200,
	ECoeStackPriorityFep=250,
	ECoeStackPriorityEnvironmentFilter=300
	};

enum
	{
	ECoeStackFlagStandard			= 0, // the default value
	ECoeStackFlagRefusesAllKeys		= 0x01,
	ECoeStackFlagRefusesFocus		= 0x02,
	ECoeStackFlagOwnershipTransfered= 0x04,
	ECoeStackFlagSharable			= 0x08
	};

class CCoeControlStack;

class CCoeAppUi : public CCoeAppUiBase
	{
public:
	IMPORT_C CCoeAppUi();
	IMPORT_C ~CCoeAppUi();
	IMPORT_C void ConstructL(CCoeAppUi* aPrevious=NULL);
public: // new functions
	IMPORT_C void AddToStackL(CCoeControl* aControl,TInt aPriority=ECoeStackPriorityDefault,TInt aStackingFlags=ECoeStackFlagStandard);
	IMPORT_C void RemoveFromStack(CCoeControl* aControl);
	IMPORT_C void UpdateStackedControlFlags(CCoeControl* aControl,TInt aFlags,TInt aMask);
	IMPORT_C void HandleStackChanged();
	IMPORT_C TBool IsDisplayingMenuOrDialog() const; 
	IMPORT_C TBool IsDisplayingControlBetweenPriorities(TInt aLowerPriority, TInt aHigherPriority) const;
protected: // from CCoeAppUiBase
	IMPORT_C void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination);
	IMPORT_C void Reserved_1();
	IMPORT_C void Reserved_2();
private: // new functions
	IMPORT_C virtual void HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
	IMPORT_C virtual void HandleForegroundEventL(TBool aForeground);
	IMPORT_C virtual void HandleSwitchOnEventL(CCoeControl* aDestination);
	IMPORT_C virtual void HandleSystemEventL(const TWsEvent& aEvent);
	IMPORT_C virtual void HandleMessageReadyL();
	IMPORT_C virtual void HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent);
	IMPORT_C virtual void SetAndDrawFocus(TBool aFocus);
	CCoeControl* TopFocusableControl() const;
	CCoeControl* TopFocusedControl() const;
	TInt FindPos(CCoeControl* aControl) const;
	void SetFocusToControl(CCoeControl* aControl,TBool aFocus);
protected:
	CCoeEnv* iCoeEnv;
private:
	CCoeControlStack* iStack;
	};

#endif
