First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\ws_std.h
27 #include <e32base_private.h>
35 #include <twintnotifier.h>
37 const TInt KW32MajorVersionNumber=1;
38 const TInt KW32MinorVersionNumber=0;
39 const TInt KMessageSlots=3;
42 typedef TUint8 TColorIndex;
70 EWindowsInitialisation,
71 ENoKeyboardTranslator,
72 ECreateNotifierSemaphore,
73 ECreateNotifierThread,
86 struct ColorInformation
93 class CWsWindow : public CBase
96 friend class CWsSession;
97 friend class CNotifierSession;
98 friend class CKeyRepeat;
106 ECursorPeriodicPriority=2000
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);
121 void MakeTopWindow();
124 void WriteCharacter(const TText *aCharacter);
125 void CarriageReturn();
127 void Write(const TDesC &aBuffer);
132 TBool IsInClippedTextArea(const TPoint& aPoint) const;
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);
156 void HorizontalTab();
157 TBool IsRectVisible(TRect& aRect) const;
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);
193 TPoint CursorPosition();
197 void ClearToEndOfLine();
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);
216 void SetTextAttribute(TTextAttribute anAttribute);
225 TPoint iCurrentOffset;
227 ColorInformation *iAttributeBuffer;
228 TUint8 iFillAttribute;
229 TBool iCursorRequired;
232 TPoint iLastCursorPos;
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;
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;
270 TPoint iMinimumOrigin;
272 TBool iHasScrollBars;
273 TBool iPointerEvents;
276 TColorIndex iFgColor;
277 TColorIndex iBgColor;
280 class CWsSession : public CSession2
288 EConsoleClearToEndOfLine,
289 EConsoleSetWindowPosAbs,
290 EConsoleSetCursorHeight,
291 EConsoleSetCursorPosAbs,
292 EConsoleSetCursorPosRel,
304 EConsoleSetPaletteEntry,
305 EConsoleGetPaletteEntry,
306 EConsoleSetTextColors,
308 EConsoleSetTextAttribute
313 void Attach(CWsWindow* aWindow);
314 virtual void ServiceL(const RMessage2& aMessage);
315 virtual void ServiceError(const RMessage2& aMessage,TInt aError);
318 RMessagePtr2 iCurMsg;
322 class CWsServer : public CServer2
325 enum {EPriority=1000};
329 virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
331 CWsServer(TInt aPriority);
334 class CKeyRepeat : public CTimer
337 enum { EKeyRepeatPriority=1990 };
339 CKeyRepeat(TInt aPriority);
341 void Request(TKeyData& aKeyData);
343 void SetRepeatTime(TInt aDelay,TInt aRate);
344 void RepeatTime(TInt& aDelay,TInt& aRate);
348 enum { EDefaultKeyRepeatDelay=500000, EDefaultKeyRepeatRate=30000 };
354 class CEvent : public CActive
357 enum {EPriority=2000};
362 virtual void DoCancel();
365 CEvent(TInt aPriority);
368 static CCaptureKeys *CaptureKeys;
369 TInt iRepeatScanCode;
372 class CWsActiveScheduler : public CActiveScheduler
376 virtual void Error(TInt anError) const;
381 GLREF_C TInt WindowServerThread(TAny *anArg);
382 GLREF_C void Panic(TWsPanic aPanic);
383 GLREF_C void Fault(TWsFault aFault);
385 IMPORT_C void Panic(TConsolePanic aPanic);
387 #endif // __WS_STD_H__