sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\ws_std.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __WS_STD_H__ sl@0: #define __WS_STD_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: // sl@0: #include sl@0: // sl@0: const TInt KW32MajorVersionNumber=1; sl@0: const TInt KW32MinorVersionNumber=0; sl@0: const TInt KMessageSlots=3; sl@0: // sl@0: sl@0: typedef TUint8 TColorIndex; sl@0: sl@0: enum TConsolePanic sl@0: { sl@0: EConsServerFailed, sl@0: EConsNotSupportedYet sl@0: }; sl@0: // sl@0: enum TWsPanic sl@0: { sl@0: EPrematureOperation, sl@0: ETooManyWindowsOpen, sl@0: EWindowTooWide, sl@0: EWindowTooThin, sl@0: EWindowTooHigh, sl@0: EWindowTooShort, sl@0: EWindowOutOfMemory, sl@0: EDoubleReadRequest, sl@0: }; sl@0: // sl@0: enum TWsFault sl@0: { sl@0: ECreateScheduler, sl@0: ECreateServer, sl@0: EStartServer, sl@0: ECreateEvent, sl@0: ECreateShell, sl@0: ESchedulerError, sl@0: EWindowsInitialisation, sl@0: ENoKeyboardTranslator, sl@0: ECreateNotifierSemaphore, sl@0: ECreateNotifierThread, sl@0: ELocaleDll, sl@0: EChangeLocale, sl@0: }; sl@0: // sl@0: struct SWsKey sl@0: { sl@0: TKeyData iKeyData; sl@0: TInt iType; sl@0: TPoint iMousePos; sl@0: TSglQueLink iLink; sl@0: }; sl@0: sl@0: struct ColorInformation sl@0: { sl@0: TColorIndex iFg; sl@0: TColorIndex iBg; sl@0: }; sl@0: // sl@0: class CScreenDriver; sl@0: class CWsWindow : public CBase sl@0: { sl@0: friend class CEvent; sl@0: friend class CWsSession; sl@0: friend class CNotifierSession; sl@0: friend class CKeyRepeat; sl@0: private: sl@0: enum sl@0: { sl@0: EBackgroundNumber=0, sl@0: EMaxOpenWindows=64, sl@0: ENormalAttribute=7, sl@0: EMouseCharacter=219, sl@0: ECursorPeriodicPriority=2000 sl@0: }; sl@0: public: sl@0: CWsWindow(); sl@0: static void New(); sl@0: inline static void WaitOnService() {ServiceMutex.Wait();} sl@0: inline static void SignalService() {ServiceMutex.Signal();} sl@0: static TBool RawEventMode(); sl@0: static void QueueRawEvent(TRawEvent& anEvent); sl@0: void CreateL(const TSize &aSize); sl@0: sl@0: private: sl@0: ~CWsWindow(); sl@0: void Display(); sl@0: TBool IsTop() const; sl@0: void MakeTopWindow(); sl@0: void SetClip(); sl@0: void Clear(); sl@0: void WriteCharacter(const TText *aCharacter); sl@0: void CarriageReturn(); sl@0: void LineFeed(); sl@0: void Write(const TDesC &aBuffer); sl@0: void Refresh(); sl@0: void SaveEdges(); sl@0: void RestoreEdges(); sl@0: void SetWiew(); sl@0: TBool IsInClippedTextArea(const TPoint& aPoint) const; sl@0: void SetCursor(); sl@0: static void TextFill(TText *aBuffer, TInt aLength, const TText *aValue); sl@0: static TInt Offset(const TPoint &aPosition,const TSize &aSize); sl@0: static void RotateWindowsForwards(); sl@0: static void RotateWindowsBackwards(); sl@0: static void BeginUpdateScreen(); sl@0: static void EndUpdateScreen(); sl@0: static void DrainAllReadRequests(); sl@0: static void ControlInformAllMouse(TBool anIndicator); sl@0: #if defined(_UNICODE) sl@0: static TInt IsHankaku(const TText aCode); sl@0: static TInt FitInWidth(TText* aDest,TInt aWidth,TInt aAsciiCol,TText aCode); sl@0: static TInt OffsetHZa(const TText* aDest,const TPoint& aPosition,const TSize& aSize,TInt& aX); sl@0: static TInt OffsetHZwP(const TText* aDest,const TPoint& aPosition,const TSize& aSize,TPoint& aP); sl@0: static TInt OffsetHZ(const TText* aDest,const TPoint& aPosition,const TSize& aSize); sl@0: static TText GetCharFromOffset(const TText* aDest,const TPoint& aPosition,const TSize& aSize); sl@0: static TText *GetCpFromOffset(const TText* aDest,const TPoint& aPosition,const TSize& aSize); sl@0: #endif sl@0: void ScrollUp(); sl@0: void Left(); sl@0: void Right(); sl@0: void FormFeed(); sl@0: void BackSpace(); sl@0: void HorizontalTab(); sl@0: TBool IsRectVisible(TRect& aRect) const; sl@0: void SetFrame(); sl@0: void DrainReadRequest(); sl@0: TBool EnqueReadRequest(const RMessage2& aMessage); sl@0: void DequeReadRequest(); sl@0: void InformMouse(TPoint aPos); sl@0: void QueueWindowKey(TKeyData &aKeystroke); sl@0: void DoMouseLeftButton(); sl@0: void ControlMaximised(TBool anIndicator); sl@0: void ControlOnTop(TBool anIndicator); sl@0: static void Delete(); sl@0: static CWsWindow *TopWindow(); sl@0: static CWsWindow *BottomWindow(); sl@0: static TInt8 NewNumberL(); sl@0: static void ReleaseNumber(TInt8 aNumber); sl@0: static void Redraw(); sl@0: static void KeyPress(TKeyData& aKeystroke); sl@0: static void QueueTopWindowKey(TKeyData& aKeystroke); sl@0: static void InformTopMouse(TPoint aPos); sl@0: static TInt ChangeTopWindowSize(TSize aGrowth); sl@0: static TInt SlideTopWindowRelative(TPoint aDirection); sl@0: static TInt MoveTopWindowRelative(TPoint aDirection); sl@0: static void ControlTopWindowMaximised(TBool anIndicator); sl@0: static TInt FlashCursor(TAny *aParameter); sl@0: static void ResetVisibilityMap(); sl@0: static void UpdateScreen(TPoint &aPosition,TInt aLength,TInt8 aNumber,TText *aTextBuffer,ColorInformation *anAttributeBuffer); sl@0: static void Background(); sl@0: static void TurnMouseOff(); sl@0: static void TurnMouseOn(); sl@0: static void MouseMove(TPoint aGraphicsPosition); sl@0: static void MouseLeftButton(); sl@0: static void MouseLeftButtonUp(); sl@0: static CWsWindow *MouseWindow(); sl@0: static void ChangeUIColors(); sl@0: static TInt SetMode(TVideoMode aMode); sl@0: TSize Size(); sl@0: TPoint CursorPosition(); sl@0: void WriteDone(); sl@0: void SetView(); sl@0: void SetFull(); sl@0: void ClearToEndOfLine(); sl@0: void NewLine(); sl@0: void SetCursorHeight(TInt aPercentage); sl@0: void SetTitle(const TDesC &aName); sl@0: void SetSize(const TSize &aSize); sl@0: void SetWindowPosAbs(const TPoint &aPosition); sl@0: void SetCursorPosAbs(const TPoint &aPosition); sl@0: void SetCursorPosRel(const TPoint &aPosition); sl@0: void ControlScrollBars(TBool anIndicator); sl@0: void ControlWrapLock(TBool anIndicator); sl@0: void ControlPointerEvents(TBool anIndicator); sl@0: void ControlScrollLock(TBool anIndicator); sl@0: void ControlVisibility(TBool anIndicator); sl@0: void ControlAllowResize(TBool anIndicator); sl@0: void ControlCursorRequired(TBool anIndicator); sl@0: void ControlNewLineMode(TBool anIndicator); sl@0: void ControlRawEventMode(TBool anIndicator); sl@0: void QueueWindowRawEvent(TRawEvent& anEvent); sl@0: void MouseSlide(); sl@0: void SetTextAttribute(TTextAttribute anAttribute); sl@0: sl@0: private: sl@0: TInt8 iNumber; sl@0: TSize iCurrentSize; sl@0: TSize iClippedSize; sl@0: TBool iIsVisible; sl@0: TPoint iViewOrigin; sl@0: TSize iViewSize; sl@0: TPoint iCurrentOffset; sl@0: TText *iTextBuffer; sl@0: ColorInformation *iAttributeBuffer; sl@0: TUint8 iFillAttribute; sl@0: TBool iCursorRequired; sl@0: TBool iCursorIsOn; sl@0: TPoint iCursorPos; sl@0: TPoint iLastCursorPos; sl@0: TText iCursor; sl@0: TBool iScrollLock; sl@0: TBool iWrapLock; sl@0: TBool iNewLineMode; sl@0: TBool iOnTop; sl@0: TBool iAllowResize; sl@0: TBool iAllowSlide; sl@0: TBool iReadIsValid; sl@0: TDblQueLink iLink; sl@0: static TSize ScreenSize; sl@0: static CScreenDriver *ScreenDriver; sl@0: static TDblQue WQueue; sl@0: static TInt8 *VisibilityMap; sl@0: static TPoint MousePos; sl@0: static TSize FontSize; sl@0: static CBitMapAllocator *Numbers; sl@0: static CPeriodic *CursorPeriodic; sl@0: static TText *BlankLineText; sl@0: static ColorInformation *BlankLineAttributes; sl@0: static TBool MouseIsCaptured; sl@0: static RMutex MouseMutex; sl@0: static RMutex ServiceMutex; sl@0: static TInt Count; sl@0: static const TText Cursors[101]; sl@0: static CWsWindow* RawEventWindow; sl@0: static TPoint ScrollWithMouse; sl@0: static TPoint MoveWithMouse; sl@0: static TPoint ResizeWithMouse; sl@0: static TInt ScrollSpeed; sl@0: static TColorIndex ScreenColor; sl@0: static TColorIndex WindowBgColor; sl@0: static TColorIndex BorderColor; sl@0: static TColorIndex IndexOf[8]; sl@0: TSglQue iKQueue; sl@0: RMessage2 iReadRequest; sl@0: TPoint iMaximumOrigin; sl@0: TSize iMaximumSize; sl@0: TPoint iMinimumOrigin; sl@0: TSize iMinimumSize; sl@0: TBool iHasScrollBars; sl@0: TBool iPointerEvents; sl@0: TFileName iTitle; sl@0: RMessage2 iMessage; sl@0: TColorIndex iFgColor; sl@0: TColorIndex iBgColor; sl@0: }; sl@0: sl@0: class CWsSession : public CSession2 sl@0: { sl@0: public: sl@0: enum sl@0: { sl@0: EConsoleCreate, sl@0: EConsoleSet, sl@0: EConsoleClearScreen, sl@0: EConsoleClearToEndOfLine, sl@0: EConsoleSetWindowPosAbs, sl@0: EConsoleSetCursorHeight, sl@0: EConsoleSetCursorPosAbs, sl@0: EConsoleSetCursorPosRel, sl@0: EConsoleCursorPos, sl@0: EConsoleControl, sl@0: EConsoleWrite, sl@0: EConsoleRead, sl@0: EConsoleReadCancel, sl@0: EConsoleDestroy, sl@0: EConsoleSetTitle, sl@0: EConsoleSetSize, sl@0: EConsoleSize, sl@0: EConsoleScreenSize, sl@0: EConsoleSetMode, sl@0: EConsoleSetPaletteEntry, sl@0: EConsoleGetPaletteEntry, sl@0: EConsoleSetTextColors, sl@0: EConsoleSetUIColors, sl@0: EConsoleSetTextAttribute sl@0: }; sl@0: public: sl@0: CWsSession(); sl@0: ~CWsSession(); sl@0: void Attach(CWsWindow* aWindow); sl@0: virtual void ServiceL(const RMessage2& aMessage); sl@0: virtual void ServiceError(const RMessage2& aMessage,TInt aError); sl@0: private: sl@0: CWsWindow* iWindow; sl@0: RMessagePtr2 iCurMsg; sl@0: TInt iTestFast; sl@0: }; sl@0: // sl@0: class CWsServer : public CServer2 sl@0: { sl@0: public: sl@0: enum {EPriority=1000}; sl@0: public: sl@0: static void New(); sl@0: ~CWsServer(); sl@0: virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; sl@0: private: sl@0: CWsServer(TInt aPriority); sl@0: }; sl@0: // sl@0: class CKeyRepeat : public CTimer sl@0: { sl@0: public: sl@0: enum { EKeyRepeatPriority=1990 }; sl@0: sl@0: CKeyRepeat(TInt aPriority); sl@0: void ConstructL(); sl@0: void Request(TKeyData& aKeyData); sl@0: virtual void RunL(); sl@0: void SetRepeatTime(TInt aDelay,TInt aRate); sl@0: void RepeatTime(TInt& aDelay,TInt& aRate); sl@0: sl@0: TKeyData iKeyData; sl@0: private: sl@0: enum { EDefaultKeyRepeatDelay=500000, EDefaultKeyRepeatRate=30000 }; sl@0: sl@0: TInt iDelay; sl@0: TInt iRate; sl@0: }; sl@0: // sl@0: class CEvent : public CActive sl@0: { sl@0: public: sl@0: enum {EPriority=2000}; sl@0: public: sl@0: static void New(); sl@0: ~CEvent(); sl@0: void Request(); sl@0: virtual void DoCancel(); sl@0: virtual void RunL(); sl@0: protected: sl@0: CEvent(TInt aPriority); sl@0: private: sl@0: TRawEventBuf iEvent; sl@0: static CCaptureKeys *CaptureKeys; sl@0: TInt iRepeatScanCode; sl@0: }; sl@0: // sl@0: class CWsActiveScheduler : public CActiveScheduler sl@0: { sl@0: public: sl@0: static void New(); sl@0: virtual void Error(TInt anError) const; sl@0: }; sl@0: // sl@0: #include "w32disp.h" sl@0: // sl@0: GLREF_C TInt WindowServerThread(TAny *anArg); sl@0: GLREF_C void Panic(TWsPanic aPanic); sl@0: GLREF_C void Fault(TWsFault aFault); sl@0: // sl@0: IMPORT_C void Panic(TConsolePanic aPanic); sl@0: sl@0: #endif // __WS_STD_H__