1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Provides the CAknFepUICtrlEEPControl definition |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #ifndef C_AKNFEPUICTRLEEPCONTROL_H |
|
31 #define C_AKNFEPUICTRLEEPCONTROL_H |
|
32 |
|
33 #include <e32std.h> |
|
34 #include <e32base.h> |
|
35 #include <coecntrl.h> |
|
36 |
|
37 #include "insertionpoint.h" |
|
38 |
|
39 class CAknFepUiLayoutDataMgr; |
|
40 /** |
|
41 * The editable entry pane control class. |
|
42 * |
|
43 * @lib aknfepuiavkonplugin.dll |
|
44 * @since S60 v5.0 |
|
45 */ |
|
46 const TInt KLROffset = 5; |
|
47 const TInt KCursorResetOffset = 20; |
|
48 const TInt KCursorResetStartOffset = 85; |
|
49 const TInt KDenominator = 100; |
|
50 |
|
51 class CAknFepUICtrlEEPControl : public CCoeControl, public MRefreshObserver |
|
52 { |
|
53 public: |
|
54 /** |
|
55 * The display style for the text. |
|
56 */ |
|
57 enum TDspStyle |
|
58 { |
|
59 ENomal, |
|
60 EUnderline, |
|
61 EHighlight, |
|
62 EUnderlineHighlight |
|
63 }; |
|
64 |
|
65 class TSegment |
|
66 { |
|
67 public: |
|
68 /** |
|
69 * C++ constructor. |
|
70 * |
|
71 * @since S60 v5.0 |
|
72 * @param None. |
|
73 * @return self object. |
|
74 */ |
|
75 TSegment( TInt aBeg, TInt aEnd, TDspStyle aStyle ); |
|
76 |
|
77 /** |
|
78 * Compare the Index |
|
79 * |
|
80 * @since S60 v5.0 |
|
81 * |
|
82 * @param s1 the TSegment object. |
|
83 * @param s2 the TSegment object. |
|
84 * @return index |
|
85 */ |
|
86 static TInt |
|
87 CompareByBegIndex( const TSegment& s1, const TSegment& s2 ); |
|
88 TInt iBegin; |
|
89 TInt iEnd; |
|
90 TDspStyle iStyle; |
|
91 }; |
|
92 |
|
93 /** |
|
94 * NewL function. |
|
95 * |
|
96 * @since S60 v5.0 |
|
97 * @param aParent. the RWindow object. |
|
98 * @return self object. |
|
99 */ |
|
100 static CAknFepUICtrlEEPControl* NewL( RWindow& aParent, CAknFepUiLayoutDataMgr* aLafDataMgr ); |
|
101 |
|
102 /** |
|
103 * NewLC function. |
|
104 * |
|
105 * @since S60 v5.0 |
|
106 * @param aParent. the RWindow object. |
|
107 * @return self object. |
|
108 */ |
|
109 static CAknFepUICtrlEEPControl* NewLC( RWindow& aParent, CAknFepUiLayoutDataMgr* aLafDataMgr ); |
|
110 |
|
111 |
|
112 /** |
|
113 * Cancel and destroy. |
|
114 * |
|
115 * @since S60 v5.0 |
|
116 * |
|
117 * @return none. |
|
118 */ |
|
119 virtual ~CAknFepUICtrlEEPControl( ); |
|
120 |
|
121 /** |
|
122 * From CCoeControl |
|
123 * Draw the control. |
|
124 * |
|
125 * @since S60 v5.0 |
|
126 * @param aRect need to draw rect. |
|
127 * @return None. |
|
128 */ |
|
129 virtual void Draw( const TRect& aRect ) const; |
|
130 |
|
131 /** |
|
132 * From CCoeControl |
|
133 * |
|
134 * @since S60 v5.0 |
|
135 * @param None. |
|
136 * @return None. |
|
137 */ |
|
138 virtual void SizeChanged( ); |
|
139 |
|
140 /** |
|
141 * From MRefreshObserver |
|
142 * Called by the cursor object. |
|
143 * |
|
144 * @since S60 v5.0 |
|
145 * @param None. |
|
146 * @return None. |
|
147 */ |
|
148 void Refresh(); |
|
149 |
|
150 /** |
|
151 * Set the visual text and store it into member data buffer. |
|
152 * |
|
153 * @since S60 v5.0 |
|
154 * @param aDes. The buffer you want to display. |
|
155 * @return None. |
|
156 */ |
|
157 void SetText( const TDesC& aDes ); |
|
158 |
|
159 /** |
|
160 * Set the cursor position in the visual text rect. |
|
161 * |
|
162 * @since S60 v5.0 |
|
163 * @param aIndex. it represent the cursor should appear in front of aIndex character. |
|
164 * @return. error code. 0 for success. |
|
165 */ |
|
166 TInt SetCursorPosition( TInt aIndex ); |
|
167 |
|
168 /** |
|
169 * Get the cursor position in visual text. |
|
170 * |
|
171 * @since S60 v5.0 |
|
172 * @param None. |
|
173 * @return. The cursor position. |
|
174 */ |
|
175 TInt GetCursorPosition( ); |
|
176 |
|
177 /** |
|
178 * Set the underlined text beginning index and ending index. |
|
179 * |
|
180 * @since S60 v5.0 |
|
181 * @param aBeg. the beginning index for underlined text. |
|
182 * @param aEnd. the ending index for underlined text. |
|
183 * @return. error code, 0 for success. |
|
184 */ |
|
185 TInt SetUnderline( TInt aBeg, TInt aEnd ); |
|
186 |
|
187 /** |
|
188 * Set the highlighted text beginning index and ending index. |
|
189 * |
|
190 * @since S60 v5.0 |
|
191 * @param aBeg. the beginning index for highlighted text. |
|
192 * @param aEnd. the ending index for highlighted text. |
|
193 * @param aColor. the color of highlighted text, KRgbRed by default. |
|
194 * @return. error code, 0 for success. |
|
195 */ |
|
196 TInt SetHighlight( TInt aBeg, TInt aEnd ); |
|
197 |
|
198 /** |
|
199 * Add a TSegment into iArray to identify the segment with a specified style. |
|
200 * |
|
201 * @since S60 v5.0 |
|
202 * @param aBeg. the beginning index. |
|
203 * @param aEnd. the ending index. |
|
204 * @param aType. the specified style. |
|
205 */ |
|
206 void SetSegmentL ( TInt aBeg, TInt aEnd, TDspStyle aStyle ); |
|
207 |
|
208 /** |
|
209 * Add a TSegment into iArray to identify the segment with a specified style. |
|
210 * |
|
211 * @since S60 v5.0 |
|
212 * @param aBeg. the beginning index. |
|
213 * @param aEnd. the ending index. |
|
214 * @param aType. the specified style. |
|
215 */ |
|
216 void SetSegment ( TInt aBeg, TInt aEnd, TDspStyle aStyle ); |
|
217 |
|
218 /** |
|
219 * Active the cursor,the cursor will be appeared with a glint. |
|
220 * |
|
221 * @since S60 v5.0 |
|
222 * @param None. |
|
223 * @return None. |
|
224 */ |
|
225 void ActiveCursor( ); |
|
226 |
|
227 /** |
|
228 * Deactive the cursor, the cursor will be gray and with no glint. |
|
229 * |
|
230 * @since S60 v5.0 |
|
231 * @param None. |
|
232 * @return None. |
|
233 */ |
|
234 void DeactiveCursor( ); |
|
235 |
|
236 /** |
|
237 * Enable the cursor. |
|
238 * |
|
239 * @since S60 v5.0 |
|
240 * @param None. |
|
241 * @return None. |
|
242 */ |
|
243 void EnableCursor( ); |
|
244 |
|
245 /** |
|
246 * Disable the cursor. |
|
247 * |
|
248 * @since S60 v5.0 |
|
249 * @param None. |
|
250 * @return None. |
|
251 */ |
|
252 void DisableCursor( ); |
|
253 |
|
254 /** |
|
255 * Move cursor to the left by a specified stride. |
|
256 * |
|
257 * @since S60 v5.0 |
|
258 * @param aStride. specify the stride. |
|
259 * @return. error code, 0 for success. |
|
260 */ |
|
261 TInt MoveCursorLeft( TInt aStride ); |
|
262 |
|
263 /** |
|
264 * Move cursor to the right by a specified stride. |
|
265 * |
|
266 * @since S60 v5.0 |
|
267 * @param aStride. specify the stride. |
|
268 * @return. error code, 0 for success. |
|
269 */ |
|
270 TInt MoveCursorRight( TInt aStride ); |
|
271 |
|
272 /** |
|
273 * Reset all its member data to initialized state. |
|
274 * |
|
275 * @since S60 v5.0 |
|
276 * @param None. |
|
277 * @return None. |
|
278 */ |
|
279 void ResetAll( ); |
|
280 |
|
281 private: |
|
282 |
|
283 /** |
|
284 * C++ constructor. |
|
285 * |
|
286 * @since S60 v5.0 |
|
287 * @param None. |
|
288 */ |
|
289 CAknFepUICtrlEEPControl(CAknFepUiLayoutDataMgr* aLafDataMgr); |
|
290 |
|
291 /** |
|
292 * Two-phrase constructor. |
|
293 * |
|
294 * @since S60 v5.0 |
|
295 * @param None. |
|
296 * @return None. |
|
297 */ |
|
298 void ConstructL( RWindow& aParent ); |
|
299 |
|
300 /** |
|
301 * Calculate the frame rect. |
|
302 * |
|
303 * @since S60 v5.0 |
|
304 * @param aOuterRect. a output param for storing the outer rect. |
|
305 * @param aInnerRect. a output param for storing the inner rect. |
|
306 * @return None. |
|
307 */ |
|
308 void CalculateFrameRects( TRect& aOuterRect, TRect& aInnerRect ) const; |
|
309 |
|
310 private: |
|
311 //Data. |
|
312 |
|
313 /** |
|
314 * Laf data manager. |
|
315 */ |
|
316 CAknFepUiLayoutDataMgr* iLafDataMgr; |
|
317 |
|
318 /** |
|
319 * Store visual text. |
|
320 * Own |
|
321 */ |
|
322 HBufC* iBuffer; |
|
323 |
|
324 /** |
|
325 * Whether cursor should be drawn on the screen. |
|
326 */ |
|
327 TBool isCursorDraw; |
|
328 |
|
329 /** |
|
330 * The cursor pointer. |
|
331 * Own |
|
332 */ |
|
333 CInsertionPoint* iInsertionPoint; |
|
334 |
|
335 /** |
|
336 * The cursor position in visual text. |
|
337 */ |
|
338 TInt iCursorPosition; |
|
339 |
|
340 /** |
|
341 * the color for highlighted text. |
|
342 */ |
|
343 TRgb iHighlightColor; |
|
344 |
|
345 /** |
|
346 * The color for non-highlighted text. |
|
347 */ |
|
348 TRgb iDefaultTextColor; |
|
349 |
|
350 /** |
|
351 * Distinguish different segment with a different format to its context. |
|
352 */ |
|
353 RPointerArray<TSegment> iArray; |
|
354 }; |
|
355 |
|
356 #include "aknfepuictrleepcontrol.inl" |
|
357 |
|
358 #endif /* C_AKNFEPUICTRLEEPCONTROL_H */ |
|
359 |
|
360 // End of file |
|