|
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\e32cons.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __E32CONS_H__ |
|
19 #define __E32CONS_H__ |
|
20 #include <e32base.h> |
|
21 #include <e32keys.h> |
|
22 // |
|
23 |
|
24 /** |
|
25 @publishedAll |
|
26 @released |
|
27 |
|
28 Defines a default console width that can be used when creating a console. |
|
29 |
|
30 @see CConsoleBase::Create() |
|
31 */ |
|
32 const TInt KDefaultConsWidth=78; |
|
33 |
|
34 /** |
|
35 @publishedAll |
|
36 @released |
|
37 |
|
38 Defines a default console height that can be used when creating a console. |
|
39 |
|
40 @see CConsoleBase::Create() |
|
41 */ |
|
42 const TInt KDefaultConsHeight=18; |
|
43 |
|
44 /** |
|
45 @publishedAll |
|
46 @released |
|
47 |
|
48 Implies a full size screen console when passed as the width and height |
|
49 values when creating a console. |
|
50 |
|
51 @see CConsoleBase::Create() |
|
52 */ |
|
53 const TInt KConsFullScreen=-1; |
|
54 |
|
55 |
|
56 /** |
|
57 @publishedAll |
|
58 @released |
|
59 |
|
60 Defines a set of text attributes used for consoles that support colour. |
|
61 |
|
62 @see CColorConsoleBase::SetTextAttribute(). |
|
63 */ |
|
64 enum TTextAttribute |
|
65 { |
|
66 ETextAttributeNormal, /**< Defines the normal text attribute. */ |
|
67 ETextAttributeBold, /**< Defines the bold text attribute. */ |
|
68 ETextAttributeInverse, /**< Defines the inverse text attribute. */ |
|
69 ETextAttributeHighlight/**< Defines the highlight text attribute.*/ |
|
70 }; |
|
71 |
|
72 |
|
73 /** |
|
74 @publishedAll |
|
75 @released |
|
76 |
|
77 A base class that defines a console interface. |
|
78 */ |
|
79 class CConsoleBase : public CBase |
|
80 { |
|
81 public: |
|
82 IMPORT_C virtual ~CConsoleBase(); |
|
83 IMPORT_C TKeyCode Getch(); |
|
84 IMPORT_C void Printf(TRefByValue<const TDesC> aFmt,...); |
|
85 IMPORT_C void SetPos(TInt aX); |
|
86 IMPORT_C void SetPos(TInt aX,TInt aY); |
|
87 IMPORT_C TInt WhereX() const; |
|
88 IMPORT_C TInt WhereY() const; |
|
89 // Pure virtual |
|
90 |
|
91 |
|
92 /** |
|
93 Creates a new console window. |
|
94 |
|
95 @param aTitle The title text for the console. |
|
96 This should not be longer than 256 characters. |
|
97 @param aSize The size of the console window. |
|
98 |
|
99 @return KErrNone, if successful; otherwise one of the other |
|
100 system wide error codes. |
|
101 */ |
|
102 virtual TInt Create(const TDesC &aTitle,TSize aSize) =0; |
|
103 |
|
104 |
|
105 /** |
|
106 Gets a keystroke from the console window, asynchronously. |
|
107 |
|
108 @param aStatus The request status object. |
|
109 */ |
|
110 virtual void Read(TRequestStatus &aStatus) =0; |
|
111 |
|
112 |
|
113 /** |
|
114 Cancels any outstanding request to get a keystroke from the console window. |
|
115 */ |
|
116 virtual void ReadCancel() =0; |
|
117 |
|
118 |
|
119 /** |
|
120 Writes the content of the specified descriptor to the console window. |
|
121 |
|
122 @param aDes Descriptor containing the characters to be written to |
|
123 the console window. |
|
124 */ |
|
125 virtual void Write(const TDesC &aDes) =0; |
|
126 |
|
127 |
|
128 /** |
|
129 Gets the current cursor position relative to the console window. |
|
130 |
|
131 @return The current cursor position. |
|
132 */ |
|
133 virtual TPoint CursorPos() const =0; |
|
134 |
|
135 |
|
136 /** |
|
137 Puts the cursor at the absolute position in the window. |
|
138 |
|
139 @param aPoint The cursor position. |
|
140 */ |
|
141 virtual void SetCursorPosAbs(const TPoint &aPoint) =0; |
|
142 |
|
143 |
|
144 /** |
|
145 Puts the cursor at the specified position relative |
|
146 to the current cursor position. |
|
147 |
|
148 @param aPoint The cursor position. |
|
149 */ |
|
150 virtual void SetCursorPosRel(const TPoint &aPoint) =0; |
|
151 |
|
152 |
|
153 /** |
|
154 Sets the percentage height of the cursor. |
|
155 |
|
156 @param aPercentage The percentage height. This is a value from 0 to 100. |
|
157 If 0 is specified, then no cursor is displayed. |
|
158 */ |
|
159 virtual void SetCursorHeight(TInt aPercentage) =0; |
|
160 |
|
161 |
|
162 /** |
|
163 Sets a new console title. |
|
164 |
|
165 @param aTitle The title text for the console. |
|
166 This should not be longer than 256 characters. |
|
167 */ |
|
168 virtual void SetTitle(const TDesC &aTitle) =0; |
|
169 |
|
170 |
|
171 /** |
|
172 Clears the console. |
|
173 */ |
|
174 virtual void ClearScreen() =0; |
|
175 |
|
176 |
|
177 /** |
|
178 Clears the console from the current cursor position to |
|
179 the end of the line. |
|
180 */ |
|
181 virtual void ClearToEndOfLine() =0; |
|
182 |
|
183 |
|
184 /** |
|
185 Gets the size of the console. |
|
186 */ |
|
187 virtual TSize ScreenSize() const =0; |
|
188 |
|
189 |
|
190 /** |
|
191 Gets the current key code value. |
|
192 |
|
193 @return The key code value. |
|
194 */ |
|
195 virtual TKeyCode KeyCode() const =0; |
|
196 |
|
197 /** |
|
198 Gets the current key modifiers. |
|
199 |
|
200 @return The key modifiers. |
|
201 */ |
|
202 virtual TUint KeyModifiers() const =0; |
|
203 protected: |
|
204 IMPORT_C CConsoleBase(); |
|
205 protected: |
|
206 IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
207 }; |
|
208 |
|
209 |
|
210 class CProxyConsole; |
|
211 |
|
212 /** |
|
213 @publishedAll |
|
214 @released |
|
215 |
|
216 Adds colour support to the basic console interface. |
|
217 */ |
|
218 class CColorConsoleBase : public CConsoleBase |
|
219 { |
|
220 public: |
|
221 |
|
222 /** |
|
223 Sets the text attribute as defined by TTextAttribute. |
|
224 |
|
225 @param anAttribute The text attribute to be set. |
|
226 */ |
|
227 virtual void SetTextAttribute(TTextAttribute /*anAttribute*/); |
|
228 protected: |
|
229 IMPORT_C virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1); |
|
230 |
|
231 friend class CProxyConsole; |
|
232 }; |
|
233 // |
|
234 |
|
235 /** |
|
236 @publishedAll |
|
237 @released |
|
238 */ |
|
239 extern "C" { |
|
240 IMPORT_C TAny *NewConsole(); |
|
241 } |
|
242 #endif |
|
243 |