|
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_twin.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include "ws_std.h" |
|
19 |
|
20 extern "C" |
|
21 EXPORT_C TAny* NewConsole() |
|
22 // |
|
23 // Create a new console window. |
|
24 // |
|
25 { |
|
26 return new CConsoleTextWin; |
|
27 } |
|
28 |
|
29 CConsoleTextWin *CConsoleTextWin::NewL(const TDesC &aTitle,TSize aSize) |
|
30 // |
|
31 // Create a new console window. Leave on any error. |
|
32 // |
|
33 { |
|
34 |
|
35 CConsoleTextWin *pC=new(ELeave) CConsoleTextWin; |
|
36 User::LeaveIfError(pC->iConsole.Init(aTitle,aSize)); |
|
37 return(pC); |
|
38 } |
|
39 |
|
40 CConsoleTextWin::CConsoleTextWin() |
|
41 // |
|
42 // Constrcutor |
|
43 // |
|
44 {} |
|
45 |
|
46 CConsoleTextWin::~CConsoleTextWin() |
|
47 // |
|
48 // Destructor |
|
49 // |
|
50 { |
|
51 |
|
52 iConsole.Close(); |
|
53 } |
|
54 |
|
55 TInt CConsoleTextWin::Create(const TDesC &aTitle,TSize aSize) |
|
56 // |
|
57 // Create a new console window. |
|
58 // |
|
59 { |
|
60 |
|
61 TInt r=iConsole.Init(aTitle,aSize); |
|
62 if (r==KErrNone) |
|
63 { |
|
64 r=iConsole.Control(_L("+Maximize +NewLine -Lock -Wrap")); |
|
65 } |
|
66 return(r); |
|
67 } |
|
68 |
|
69 void CConsoleTextWin::Read(TRequestStatus &aStatus) |
|
70 // |
|
71 // Asynchronous get keystroke from window |
|
72 // |
|
73 { |
|
74 |
|
75 iConsole.Read(iKey,aStatus); |
|
76 } |
|
77 |
|
78 |
|
79 void ConsServerCheck(TInt aResult, TInt aLine) |
|
80 { |
|
81 if(aResult!=KErrNone) |
|
82 { |
|
83 #ifdef _DEBUG |
|
84 RDebug::Printf("EConsServerFailed with %d at line %d",aResult,aLine); |
|
85 #endif |
|
86 (void)aLine; |
|
87 Panic(EConsServerFailed); |
|
88 } |
|
89 } |
|
90 |
|
91 |
|
92 void CConsoleTextWin::ReadCancel() |
|
93 // |
|
94 // Cancel asynchronous read request |
|
95 // |
|
96 { |
|
97 |
|
98 TInt r=iConsole.ReadCancel(); |
|
99 ConsServerCheck(r,__LINE__); |
|
100 } |
|
101 |
|
102 void CConsoleTextWin::Write(const TDesC &aDes) |
|
103 // |
|
104 // Write to the console. |
|
105 // |
|
106 { |
|
107 |
|
108 TInt r=iConsole.Write(aDes); |
|
109 ConsServerCheck(r,__LINE__); |
|
110 } |
|
111 |
|
112 TPoint CConsoleTextWin::CursorPos() const |
|
113 // |
|
114 // Read current cursor position relative to the window |
|
115 // |
|
116 { |
|
117 |
|
118 TPoint p; |
|
119 TInt r=iConsole.CursorPos(p); |
|
120 ConsServerCheck(r,__LINE__); |
|
121 return(p); |
|
122 } |
|
123 |
|
124 void CConsoleTextWin::SetCursorPosAbs(const TPoint &aPosition) |
|
125 // |
|
126 // Position the cursor in the window buffer |
|
127 // |
|
128 { |
|
129 |
|
130 TInt r=iConsole.SetCursorPosAbs(aPosition); |
|
131 ConsServerCheck(r,__LINE__); |
|
132 } |
|
133 |
|
134 void CConsoleTextWin::SetCursorPosRel(const TPoint &aVector) |
|
135 // |
|
136 // Position the cursor in the window buffer |
|
137 // |
|
138 { |
|
139 |
|
140 TInt r=iConsole.SetCursorPosRel(aVector); |
|
141 ConsServerCheck(r,__LINE__); |
|
142 } |
|
143 |
|
144 void CConsoleTextWin::SetCursorHeight(TInt aPercentage) |
|
145 // |
|
146 // Set the percentage height of the cursor |
|
147 // |
|
148 { |
|
149 |
|
150 TInt r=iConsole.SetCursorHeight(aPercentage); |
|
151 ConsServerCheck(r,__LINE__); |
|
152 } |
|
153 |
|
154 void CConsoleTextWin::SetTitle(const TDesC &aTitle) |
|
155 // |
|
156 // Set the console window title |
|
157 // |
|
158 { |
|
159 |
|
160 TInt r=iConsole.SetTitle(aTitle); |
|
161 ConsServerCheck(r,__LINE__); |
|
162 } |
|
163 |
|
164 void CConsoleTextWin::ClearScreen() |
|
165 // |
|
166 // Clear screen |
|
167 // |
|
168 { |
|
169 |
|
170 TInt r=iConsole.ClearScreen(); |
|
171 ConsServerCheck(r,__LINE__); |
|
172 } |
|
173 |
|
174 void CConsoleTextWin::ClearToEndOfLine() |
|
175 // |
|
176 // Clear window from current cursor position to the end of the line |
|
177 // |
|
178 { |
|
179 |
|
180 TInt r=iConsole.ClearToEndOfLine(); |
|
181 ConsServerCheck(r,__LINE__); |
|
182 } |
|
183 |
|
184 TSize CConsoleTextWin::ScreenSize() const |
|
185 // |
|
186 // Return the current screen size |
|
187 // |
|
188 { |
|
189 |
|
190 TSize s; |
|
191 TInt r=iConsole.Size(s); |
|
192 ConsServerCheck(r,__LINE__); |
|
193 return(s); |
|
194 } |
|
195 |
|
196 TKeyCode CConsoleTextWin::KeyCode() const |
|
197 // |
|
198 // Return the current keycode |
|
199 // |
|
200 { |
|
201 |
|
202 return(iKey.Code()); |
|
203 } |
|
204 |
|
205 TUint CConsoleTextWin::KeyModifiers() const |
|
206 // |
|
207 // Return the current key modifiers |
|
208 // |
|
209 { |
|
210 |
|
211 return(iKey.Modifiers()); |
|
212 } |
|
213 |
|
214 void CConsoleTextWin::SetTextAttribute(TTextAttribute anAttribute) |
|
215 // |
|
216 // Set text attribute |
|
217 // |
|
218 { |
|
219 |
|
220 iConsole.SetTextAttribute(anAttribute); |
|
221 } |
|
222 |
|
223 RConsole &CConsoleTextWin::Console() |
|
224 // |
|
225 // Return the console object. |
|
226 // |
|
227 { |
|
228 |
|
229 return(iConsole); |
|
230 } |