kernel/eka/include/ws_std.h
changeset 0 a41df078684a
child 19 4a8fed1c0ef6
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1995-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32\include\ws_std.h
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #ifndef __WS_STD_H__
       
    24 #define __WS_STD_H__
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <e32base_private.h>
       
    28 #include <e32cons.h>
       
    29 #include <e32twin.h>
       
    30 #include <e32ver.h>
       
    31 #include <e32svr.h>
       
    32 #include <e32hal.h>
       
    33 #include <e32uid.h>
       
    34 //
       
    35 #include <twintnotifier.h>
       
    36 //
       
    37 const TInt KW32MajorVersionNumber=1;
       
    38 const TInt KW32MinorVersionNumber=0;
       
    39 const TInt KMessageSlots=3;
       
    40 //
       
    41 
       
    42 typedef TUint8 TColorIndex;
       
    43 
       
    44 enum TConsolePanic
       
    45 	{
       
    46 	EConsServerFailed,
       
    47 	EConsNotSupportedYet
       
    48 	};
       
    49 //
       
    50 enum TWsPanic
       
    51 	{
       
    52 	EPrematureOperation,
       
    53 	ETooManyWindowsOpen,
       
    54 	EWindowTooWide,
       
    55 	EWindowTooThin,
       
    56 	EWindowTooHigh,
       
    57 	EWindowTooShort,
       
    58 	EWindowOutOfMemory,
       
    59 	EDoubleReadRequest,
       
    60 	};
       
    61 //
       
    62 enum TWsFault
       
    63 	{
       
    64 	ECreateScheduler,
       
    65 	ECreateServer,
       
    66 	EStartServer,
       
    67 	ECreateEvent,
       
    68 	ECreateShell,
       
    69 	ESchedulerError,
       
    70 	EWindowsInitialisation,
       
    71 	ENoKeyboardTranslator,
       
    72 	ECreateNotifierSemaphore,
       
    73 	ECreateNotifierThread,
       
    74 	ELocaleDll,
       
    75 	EChangeLocale,
       
    76 	};
       
    77 //
       
    78 struct SWsKey
       
    79 	{
       
    80 	TKeyData iKeyData;
       
    81     TInt iType;
       
    82     TPoint iMousePos;
       
    83 	TSglQueLink iLink;
       
    84 	};
       
    85 
       
    86 struct ColorInformation
       
    87 	{
       
    88 	TColorIndex iFg;
       
    89 	TColorIndex iBg;	
       
    90 	};
       
    91 //
       
    92 class CScreenDriver;
       
    93 class CWsWindow : public CBase
       
    94 	{
       
    95 	friend class CEvent;
       
    96 	friend class CWsSession;
       
    97 	friend class CNotifierSession;
       
    98     friend class CKeyRepeat;
       
    99 private:
       
   100 	enum
       
   101 		{
       
   102 		EBackgroundNumber=0,
       
   103 		EMaxOpenWindows=64,
       
   104 		ENormalAttribute=7,
       
   105 		EMouseCharacter=219,
       
   106 		ECursorPeriodicPriority=2000
       
   107 		};
       
   108 public:
       
   109 	CWsWindow();
       
   110 	static void New();
       
   111 	inline static void WaitOnService() {ServiceMutex.Wait();}
       
   112 	inline static void SignalService() {ServiceMutex.Signal();}
       
   113 	static TBool RawEventMode();
       
   114 	static void QueueRawEvent(TRawEvent& anEvent);
       
   115 	void CreateL(const TSize &aSize);
       
   116 
       
   117 private:
       
   118 	~CWsWindow();
       
   119 	void Display();
       
   120 	TBool IsTop() const;
       
   121 	void MakeTopWindow();
       
   122 	void SetClip();
       
   123 	void Clear();
       
   124 	void WriteCharacter(const TText *aCharacter);
       
   125 	void CarriageReturn();
       
   126 	void LineFeed();
       
   127 	void Write(const TDesC &aBuffer);
       
   128 	void Refresh();
       
   129 	void SaveEdges();
       
   130 	void RestoreEdges();
       
   131 	void SetWiew();
       
   132 	TBool IsInClippedTextArea(const TPoint& aPoint) const;
       
   133 	void SetCursor();
       
   134 	static void TextFill(TText *aBuffer, TInt aLength, const TText *aValue);
       
   135 	static TInt Offset(const TPoint &aPosition,const TSize &aSize);
       
   136 	static void RotateWindowsForwards();
       
   137 	static void RotateWindowsBackwards();
       
   138 	static void BeginUpdateScreen();
       
   139 	static void EndUpdateScreen();
       
   140 	static void DrainAllReadRequests();
       
   141     static void ControlInformAllMouse(TBool anIndicator);
       
   142 #if defined(_UNICODE)
       
   143 	static TInt IsHankaku(const TText aCode);
       
   144 	static TInt FitInWidth(TText* aDest,TInt aWidth,TInt aAsciiCol,TText aCode);
       
   145 	static TInt OffsetHZa(const TText* aDest,const TPoint& aPosition,const TSize& aSize,TInt& aX);
       
   146 	static TInt OffsetHZwP(const TText* aDest,const TPoint& aPosition,const TSize& aSize,TPoint& aP);
       
   147 	static TInt OffsetHZ(const TText* aDest,const TPoint& aPosition,const TSize& aSize);
       
   148 	static TText GetCharFromOffset(const TText* aDest,const TPoint& aPosition,const TSize& aSize);
       
   149 	static TText *GetCpFromOffset(const TText* aDest,const TPoint& aPosition,const TSize& aSize);
       
   150 #endif
       
   151 	void ScrollUp();
       
   152 	void Left();
       
   153 	void Right();
       
   154 	void FormFeed();
       
   155 	void BackSpace();
       
   156 	void HorizontalTab();
       
   157 	TBool IsRectVisible(TRect& aRect) const;
       
   158 	void SetFrame();
       
   159 	void DrainReadRequest();
       
   160 	TBool EnqueReadRequest(const RMessage2& aMessage);
       
   161 	void DequeReadRequest();
       
   162 	void InformMouse(TPoint aPos);
       
   163 	void QueueWindowKey(TKeyData &aKeystroke);
       
   164 	void DoMouseLeftButton();
       
   165 	void ControlMaximised(TBool anIndicator);
       
   166 	void ControlOnTop(TBool anIndicator);
       
   167 	static void Delete();
       
   168 	static CWsWindow *TopWindow();
       
   169 	static CWsWindow *BottomWindow();
       
   170 	static TInt8 NewNumberL();
       
   171 	static void ReleaseNumber(TInt8 aNumber);
       
   172 	static void Redraw();
       
   173 	static void KeyPress(TKeyData& aKeystroke);
       
   174 	static void QueueTopWindowKey(TKeyData& aKeystroke);
       
   175 	static void InformTopMouse(TPoint aPos);
       
   176 	static TInt ChangeTopWindowSize(TSize aGrowth);
       
   177 	static TInt SlideTopWindowRelative(TPoint aDirection);
       
   178 	static TInt MoveTopWindowRelative(TPoint aDirection);
       
   179 	static void ControlTopWindowMaximised(TBool anIndicator);
       
   180 	static TInt FlashCursor(TAny *aParameter);
       
   181 	static void ResetVisibilityMap();
       
   182 	static void UpdateScreen(TPoint &aPosition,TInt aLength,TInt8 aNumber,TText *aTextBuffer,ColorInformation *anAttributeBuffer);
       
   183 	static void Background();
       
   184 	static void TurnMouseOff();
       
   185 	static void TurnMouseOn();
       
   186 	static void MouseMove(TPoint aGraphicsPosition);
       
   187 	static void MouseLeftButton();
       
   188 	static void MouseLeftButtonUp();
       
   189 	static CWsWindow *MouseWindow();
       
   190 	static void ChangeUIColors();
       
   191 	static TInt SetMode(TVideoMode aMode);
       
   192 	TSize Size();
       
   193 	TPoint CursorPosition();
       
   194 	void WriteDone();
       
   195 	void SetView();
       
   196 	void SetFull();
       
   197 	void ClearToEndOfLine();
       
   198 	void NewLine();
       
   199 	void SetCursorHeight(TInt aPercentage);
       
   200 	void SetTitle(const TDesC &aName);
       
   201 	void SetSize(const TSize &aSize); 
       
   202 	void SetWindowPosAbs(const TPoint &aPosition);
       
   203 	void SetCursorPosAbs(const TPoint &aPosition);
       
   204 	void SetCursorPosRel(const TPoint &aPosition);
       
   205 	void ControlScrollBars(TBool anIndicator);
       
   206 	void ControlWrapLock(TBool anIndicator);
       
   207     void ControlPointerEvents(TBool anIndicator);
       
   208 	void ControlScrollLock(TBool anIndicator);
       
   209 	void ControlVisibility(TBool anIndicator);
       
   210 	void ControlAllowResize(TBool anIndicator);
       
   211 	void ControlCursorRequired(TBool anIndicator);
       
   212 	void ControlNewLineMode(TBool anIndicator);
       
   213 	void ControlRawEventMode(TBool anIndicator);
       
   214     void QueueWindowRawEvent(TRawEvent& anEvent);
       
   215 	void MouseSlide();
       
   216 	void SetTextAttribute(TTextAttribute anAttribute);
       
   217 
       
   218 private:
       
   219 	TInt8 iNumber;
       
   220 	TSize iCurrentSize;
       
   221 	TSize iClippedSize;
       
   222 	TBool iIsVisible;
       
   223 	TPoint iViewOrigin;
       
   224 	TSize iViewSize;
       
   225 	TPoint iCurrentOffset;
       
   226 	TText *iTextBuffer;
       
   227 	ColorInformation *iAttributeBuffer;
       
   228     TUint8 iFillAttribute;
       
   229 	TBool iCursorRequired;
       
   230 	TBool iCursorIsOn;
       
   231 	TPoint iCursorPos;
       
   232 	TPoint iLastCursorPos;
       
   233 	TText iCursor;
       
   234 	TBool iScrollLock;
       
   235     TBool iWrapLock;
       
   236 	TBool iNewLineMode;
       
   237 	TBool iOnTop;
       
   238 	TBool iAllowResize;
       
   239 	TBool iAllowSlide;
       
   240 	TBool iReadIsValid;
       
   241 	TDblQueLink iLink;
       
   242     static TSize ScreenSize;
       
   243 	static CScreenDriver *ScreenDriver;
       
   244 	static TDblQue<CWsWindow> WQueue;
       
   245 	static TInt8 *VisibilityMap;
       
   246 	static TPoint MousePos;
       
   247 	static TSize FontSize;
       
   248 	static CBitMapAllocator *Numbers;
       
   249 	static CPeriodic *CursorPeriodic;
       
   250 	static TText *BlankLineText;
       
   251 	static ColorInformation *BlankLineAttributes;
       
   252 	static TBool MouseIsCaptured;
       
   253 	static RMutex MouseMutex;
       
   254 	static RMutex ServiceMutex;
       
   255 	static TInt Count;
       
   256 	static const TText Cursors[101];
       
   257 	static CWsWindow* RawEventWindow;
       
   258 	static TPoint ScrollWithMouse;
       
   259 	static TPoint MoveWithMouse;
       
   260 	static TPoint ResizeWithMouse;
       
   261 	static TInt ScrollSpeed;
       
   262 	static TColorIndex ScreenColor;
       
   263 	static TColorIndex WindowBgColor;
       
   264 	static TColorIndex BorderColor;
       
   265 	static TColorIndex IndexOf[8];
       
   266 	TSglQue<SWsKey> iKQueue;
       
   267 	RMessage2 iReadRequest;
       
   268 	TPoint iMaximumOrigin;
       
   269 	TSize iMaximumSize;
       
   270 	TPoint iMinimumOrigin;
       
   271 	TSize iMinimumSize;
       
   272     TBool iHasScrollBars;
       
   273     TBool iPointerEvents;
       
   274     TFileName iTitle;
       
   275 	RMessage2 iMessage;
       
   276 	TColorIndex iFgColor;
       
   277 	TColorIndex iBgColor;
       
   278 	};
       
   279 
       
   280 class CWsSession : public CSession2
       
   281 	{
       
   282 public:
       
   283 	enum
       
   284 		{
       
   285 		EConsoleCreate,
       
   286 		EConsoleSet,
       
   287 		EConsoleClearScreen,
       
   288 		EConsoleClearToEndOfLine,
       
   289 		EConsoleSetWindowPosAbs,
       
   290 		EConsoleSetCursorHeight,
       
   291 		EConsoleSetCursorPosAbs,
       
   292 		EConsoleSetCursorPosRel,
       
   293 		EConsoleCursorPos,
       
   294 		EConsoleControl,
       
   295 		EConsoleWrite,
       
   296 		EConsoleRead,
       
   297 		EConsoleReadCancel,
       
   298 		EConsoleDestroy,
       
   299 		EConsoleSetTitle,
       
   300 		EConsoleSetSize,
       
   301 		EConsoleSize,
       
   302 		EConsoleScreenSize,
       
   303 		EConsoleSetMode,
       
   304 		EConsoleSetPaletteEntry,
       
   305 		EConsoleGetPaletteEntry,
       
   306 		EConsoleSetTextColors,
       
   307 		EConsoleSetUIColors,
       
   308 		EConsoleSetTextAttribute
       
   309 		};
       
   310 public:
       
   311 	CWsSession();
       
   312 	~CWsSession();
       
   313 	void Attach(CWsWindow* aWindow);
       
   314 	virtual void ServiceL(const RMessage2& aMessage);
       
   315 	virtual void ServiceError(const RMessage2& aMessage,TInt aError);
       
   316 private:
       
   317 	CWsWindow* iWindow;
       
   318 	RMessagePtr2 iCurMsg;
       
   319 	TInt iTestFast;
       
   320 	};
       
   321 //
       
   322 class CWsServer : public CServer2
       
   323 	{
       
   324 public:
       
   325 	enum {EPriority=1000};
       
   326 public:
       
   327 	static void New();
       
   328 	~CWsServer();
       
   329 	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
       
   330 private:
       
   331 	CWsServer(TInt aPriority);
       
   332 	};
       
   333 //
       
   334 class CKeyRepeat : public CTimer
       
   335     {
       
   336 public:
       
   337     enum { EKeyRepeatPriority=1990 };
       
   338 
       
   339     CKeyRepeat(TInt aPriority);
       
   340     void ConstructL();
       
   341     void Request(TKeyData& aKeyData);
       
   342     virtual void RunL();
       
   343     void SetRepeatTime(TInt aDelay,TInt aRate);
       
   344     void RepeatTime(TInt& aDelay,TInt& aRate);
       
   345 
       
   346     TKeyData iKeyData;
       
   347 private:
       
   348     enum { EDefaultKeyRepeatDelay=500000, EDefaultKeyRepeatRate=30000 };
       
   349 
       
   350     TInt iDelay;
       
   351     TInt iRate;
       
   352     };
       
   353 //
       
   354 class CEvent : public CActive
       
   355 	{
       
   356 public:
       
   357 	enum {EPriority=2000};
       
   358 public:
       
   359 	static void New();
       
   360 	~CEvent();
       
   361 	void Request();
       
   362 	virtual void DoCancel();
       
   363 	virtual void RunL();
       
   364 protected:
       
   365 	CEvent(TInt aPriority);
       
   366 private:
       
   367 	TRawEventBuf iEvent;
       
   368 	static CCaptureKeys *CaptureKeys;
       
   369     TInt iRepeatScanCode;
       
   370 	};
       
   371 //
       
   372 class CWsActiveScheduler : public CActiveScheduler
       
   373 	{
       
   374 public:
       
   375 	static void New();
       
   376 	virtual void Error(TInt anError) const;
       
   377 	};
       
   378 //
       
   379 #include "w32disp.h"
       
   380 //
       
   381 GLREF_C TInt WindowServerThread(TAny *anArg);
       
   382 GLREF_C void Panic(TWsPanic aPanic);
       
   383 GLREF_C void Fault(TWsFault aFault);
       
   384 //
       
   385 IMPORT_C void Panic(TConsolePanic aPanic);
       
   386 
       
   387 #endif	// __WS_STD_H__