|
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\ewsrv\co_cli.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "ws_std.h" |
|
19 |
|
20 TInt RConsole::Connect() |
|
21 { |
|
22 return CreateSession(KE32WindowServer,Version(),KMessageSlots); |
|
23 } |
|
24 |
|
25 EXPORT_C TInt RConsole::Create() |
|
26 // |
|
27 // Connect with the window server if connection not already made, |
|
28 // then create a default console window without displaying it |
|
29 // |
|
30 { |
|
31 |
|
32 if (Handle()==KNullHandle) |
|
33 { |
|
34 TInt r = Connect(); |
|
35 if (r!=KErrNone) |
|
36 return r; |
|
37 } |
|
38 return SendReceive(CWsSession::EConsoleCreate, TIpcArgs()); |
|
39 } |
|
40 |
|
41 EXPORT_C TInt RConsole::Init(const TDesC &aName,const TSize &aSize) |
|
42 // |
|
43 // Connect with the window server if connection not already made, |
|
44 // then open/display a console window on with the specified title. |
|
45 // |
|
46 { |
|
47 |
|
48 if (Handle()==KNullHandle) |
|
49 { |
|
50 TInt r = Connect(); |
|
51 if (r!=KErrNone) |
|
52 return r; |
|
53 } |
|
54 TPckgC<TSize> size(aSize); |
|
55 return SendReceive(CWsSession::EConsoleSet, TIpcArgs(&aName, &size)); |
|
56 } |
|
57 |
|
58 EXPORT_C TInt RConsole::SetTitle(const TDesC &aName) |
|
59 // |
|
60 // Change the title of the window |
|
61 // |
|
62 { |
|
63 |
|
64 return SendReceive(CWsSession::EConsoleSetTitle, TIpcArgs(&aName)); |
|
65 } |
|
66 |
|
67 EXPORT_C TInt RConsole::SetSize(const TSize &aSize) |
|
68 // |
|
69 // Change the underlying size of the window |
|
70 // |
|
71 { |
|
72 |
|
73 TPckgC<TSize> size(aSize); |
|
74 return SendReceive(CWsSession::EConsoleSetSize, TIpcArgs(&size)); |
|
75 } |
|
76 |
|
77 EXPORT_C TInt RConsole::Size(TSize &aSize) const |
|
78 // |
|
79 // Read the current window size |
|
80 // |
|
81 { |
|
82 |
|
83 TPckg<TSize> size(aSize); |
|
84 return SendReceive(CWsSession::EConsoleSize, TIpcArgs( (TDes8*)&size )); |
|
85 } |
|
86 |
|
87 EXPORT_C TInt RConsole::ScreenSize(TSize &aSize) const |
|
88 // |
|
89 // Read the screen size in characters |
|
90 // |
|
91 { |
|
92 |
|
93 TPckg<TSize> size(aSize); |
|
94 return SendReceive(CWsSession::EConsoleScreenSize, TIpcArgs( (TDes8*)&size )); |
|
95 } |
|
96 |
|
97 EXPORT_C TVersion RConsole::Version() |
|
98 // |
|
99 // Return the client side version number. |
|
100 // |
|
101 { |
|
102 |
|
103 return TVersion(KW32MajorVersionNumber,KW32MinorVersionNumber,KE32BuildVersionNumber); |
|
104 } |
|
105 |
|
106 EXPORT_C TInt RConsole::Write(const TDesC &aDes) |
|
107 // |
|
108 // Write to the console. |
|
109 // |
|
110 { |
|
111 |
|
112 return SendReceive(CWsSession::EConsoleWrite, TIpcArgs(&aDes)); |
|
113 } |
|
114 |
|
115 EXPORT_C TInt RConsole::ClearScreen() |
|
116 // |
|
117 // Clear window |
|
118 // |
|
119 { |
|
120 |
|
121 return SendReceive(CWsSession::EConsoleClearScreen, TIpcArgs()); |
|
122 } |
|
123 |
|
124 EXPORT_C TInt RConsole::ClearToEndOfLine() |
|
125 // |
|
126 // Clear window from current cursor position to the end of the line |
|
127 // |
|
128 { |
|
129 |
|
130 return SendReceive(CWsSession::EConsoleClearToEndOfLine, TIpcArgs()); |
|
131 } |
|
132 |
|
133 EXPORT_C TInt RConsole::Destroy() |
|
134 // |
|
135 // Remove and close down the window |
|
136 // |
|
137 { |
|
138 |
|
139 return SendReceive(CWsSession::EConsoleDestroy, TIpcArgs()); |
|
140 } |
|
141 |
|
142 EXPORT_C TInt RConsole::SetWindowPosAbs(const TPoint &aPosition) |
|
143 // |
|
144 // Position the window |
|
145 // |
|
146 { |
|
147 |
|
148 TPckgC<TPoint> point(aPosition); |
|
149 return SendReceive(CWsSession::EConsoleSetWindowPosAbs, TIpcArgs(&point)); |
|
150 } |
|
151 |
|
152 EXPORT_C TInt RConsole::SetCursorHeight(TInt aPercentage) |
|
153 // |
|
154 // Set the percentage height of the cursor |
|
155 // |
|
156 { |
|
157 |
|
158 return SendReceive(CWsSession::EConsoleSetCursorHeight, TIpcArgs(aPercentage)); |
|
159 } |
|
160 |
|
161 EXPORT_C TInt RConsole::SetCursorPosAbs(const TPoint &aPosition) |
|
162 // |
|
163 // Position the cursor in the window buffer |
|
164 // |
|
165 { |
|
166 |
|
167 TPckgC<TPoint> point(aPosition); |
|
168 return SendReceive(CWsSession::EConsoleSetCursorPosAbs, TIpcArgs(&point)); |
|
169 } |
|
170 |
|
171 EXPORT_C TInt RConsole::SetCursorPosRel(const TPoint &aVector) |
|
172 // |
|
173 // Position the cursor in the window buffer |
|
174 // |
|
175 { |
|
176 |
|
177 TPckg<TPoint> point(aVector); |
|
178 return SendReceive(CWsSession::EConsoleSetCursorPosRel, TIpcArgs(&point)); |
|
179 } |
|
180 |
|
181 EXPORT_C TInt RConsole::CursorPos(TPoint &aPosition) const |
|
182 // |
|
183 // Read current cursor position relative to the window |
|
184 // |
|
185 { |
|
186 |
|
187 TPckg<TPoint> point(aPosition); |
|
188 return SendReceive(CWsSession::EConsoleCursorPos, TIpcArgs( (TDes8*)&point )); |
|
189 } |
|
190 |
|
191 EXPORT_C TInt RConsole::Control(const TDesC &aDes) |
|
192 // |
|
193 // Control window properties |
|
194 // |
|
195 { |
|
196 |
|
197 return SendReceive(CWsSession::EConsoleControl, TIpcArgs(&aDes)); |
|
198 } |
|
199 |
|
200 EXPORT_C TInt RConsole::Read(TConsoleKey &aKeystroke) |
|
201 // |
|
202 // Synchronous get keystroke from window |
|
203 // |
|
204 { |
|
205 |
|
206 return SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke )); |
|
207 } |
|
208 |
|
209 EXPORT_C void RConsole::Read(TConsoleKey &aKeystroke,TRequestStatus &aStatus) |
|
210 // |
|
211 // Asynchronous get keystroke from window |
|
212 // |
|
213 { |
|
214 |
|
215 SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ), aStatus); |
|
216 } |
|
217 |
|
218 EXPORT_C TInt RConsole::ReadCancel() |
|
219 // |
|
220 // Cancel asynchronous read request |
|
221 // |
|
222 { |
|
223 |
|
224 return SendReceive(CWsSession::EConsoleReadCancel, TIpcArgs()); |
|
225 } |
|
226 |
|
227 EXPORT_C TInt RConsole::SetMode(TVideoMode aMode) |
|
228 // |
|
229 // |
|
230 // |
|
231 { |
|
232 |
|
233 if (Handle()==KNullHandle) |
|
234 { |
|
235 TInt r = Connect(); |
|
236 if (r!=KErrNone) |
|
237 return r; |
|
238 } |
|
239 return SendReceive(CWsSession::EConsoleSetMode, TIpcArgs(aMode)); |
|
240 } |
|
241 |
|
242 EXPORT_C void RConsole::SetPaletteEntry(TUint aIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue) |
|
243 // |
|
244 // |
|
245 // |
|
246 { |
|
247 |
|
248 if (Handle()==KNullHandle) |
|
249 { |
|
250 TInt r = Connect(); |
|
251 if (r!=KErrNone) |
|
252 return; |
|
253 } |
|
254 SendReceive(CWsSession::EConsoleSetPaletteEntry, TIpcArgs(aIndex,aRed,aGreen,aBlue)); |
|
255 } |
|
256 |
|
257 EXPORT_C void RConsole::GetPaletteEntry(TUint aIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue) |
|
258 // |
|
259 // |
|
260 // |
|
261 { |
|
262 |
|
263 if (Handle()==KNullHandle) |
|
264 { |
|
265 TInt r = Connect(); |
|
266 if (r!=KErrNone) |
|
267 return; |
|
268 } |
|
269 TPckg<TUint8> r(aRed); |
|
270 TPckg<TUint8> g(aGreen); |
|
271 TPckg<TUint8> b(aBlue); |
|
272 SendReceive(CWsSession::EConsoleGetPaletteEntry, TIpcArgs(aIndex, &r, &g, &b)); |
|
273 } |
|
274 |
|
275 EXPORT_C void RConsole::SetTextColors(TUint aFgColor,TUint aBgColor) |
|
276 // |
|
277 // |
|
278 // |
|
279 { |
|
280 |
|
281 if (Handle()==KNullHandle) |
|
282 { |
|
283 TInt r = Connect(); |
|
284 if (r!=KErrNone) |
|
285 return; |
|
286 } |
|
287 SendReceive(CWsSession::EConsoleSetTextColors, TIpcArgs(aFgColor, aBgColor)); |
|
288 } |
|
289 |
|
290 EXPORT_C void RConsole::SetUIColors(TUint aWindowBgColor,TUint aBorderColor,TUint aScreenColor) |
|
291 // |
|
292 // |
|
293 // |
|
294 { |
|
295 |
|
296 if (Handle()==KNullHandle) |
|
297 { |
|
298 TInt r = Connect(); |
|
299 if (r!=KErrNone) |
|
300 return; |
|
301 } |
|
302 SendReceive(CWsSession::EConsoleSetUIColors, TIpcArgs(aWindowBgColor, aBorderColor, aScreenColor)); |
|
303 } |
|
304 |
|
305 EXPORT_C void RConsole::SetTextAttribute(TTextAttribute aAttr) |
|
306 // |
|
307 // |
|
308 // |
|
309 { |
|
310 |
|
311 if (Handle()==KNullHandle) |
|
312 { |
|
313 TInt r = Connect(); |
|
314 if (r!=KErrNone) |
|
315 return; |
|
316 } |
|
317 SendReceive(CWsSession::EConsoleSetTextAttribute, TIpcArgs(aAttr)); |
|
318 } |