|
1 /* |
|
2 * Copyright (c) 1997-1999 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__EIKGTED_H__) |
|
20 #define __EIKGTED_H__ |
|
21 |
|
22 #if !defined(__EIKEDWIN_H__) |
|
23 #include <eikedwin.h> |
|
24 #endif |
|
25 |
|
26 |
|
27 #if !defined(__BADESCA_H__) |
|
28 #include <badesca.h> |
|
29 #endif |
|
30 |
|
31 #if !defined(__EIKON_HRH__) |
|
32 #include <eikon.hrh> |
|
33 #endif |
|
34 |
|
35 class CGlobalText; |
|
36 class CControlEnv; |
|
37 class CEikDialogToolBar; |
|
38 class CPrintSetup; |
|
39 class CTextPageRegionPrinter; |
|
40 class CEikDialogToolBar; |
|
41 |
|
42 /** |
|
43 * Global text editor. |
|
44 * |
|
45 * This is an edit window which supports globally formatted text. Supports |
|
46 * a line cursor and provides functions which make it easy to launch various |
|
47 * dialogs, for instance search, replace, set font etc. |
|
48 * |
|
49 * @since Symbian 5.0 |
|
50 */ |
|
51 class CEikGlobalTextEditor : public CEikEdwin |
|
52 { |
|
53 |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Font style |
|
58 */ |
|
59 enum TFontStyleFlags |
|
60 { |
|
61 /** Normal font */ |
|
62 EStandard =0x00, |
|
63 |
|
64 /** Bolded font */ |
|
65 EBold =0x01, |
|
66 |
|
67 /** Italic font */ |
|
68 EItalic =0x02, |
|
69 |
|
70 /** Underlined font */ |
|
71 EUnderline =0x04 |
|
72 }; |
|
73 |
|
74 public: // construction and destruction |
|
75 |
|
76 /** |
|
77 * C++ default constructor. |
|
78 */ |
|
79 IMPORT_C CEikGlobalTextEditor(); |
|
80 |
|
81 /** |
|
82 * C++ default constructor. |
|
83 * |
|
84 * @param aBorder The editor's border. |
|
85 */ |
|
86 IMPORT_C CEikGlobalTextEditor(const TGulBorder& aBorder); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 IMPORT_C ~CEikGlobalTextEditor(); |
|
92 |
|
93 /** |
|
94 * By Default symbian 2nd phase constructor is private. |
|
95 * |
|
96 * Completes construction of the global text editor. |
|
97 * |
|
98 * The editor's paragraph and character formatting is set to |
|
99 * default values. |
|
100 * |
|
101 * @param aParent The editor's parent control. Omit if the |
|
102 * editor has no parent. |
|
103 * @param aNumberOfLines The editor's number of lines. |
|
104 * @param aTextLimit The maximum length of the editor in characters. |
|
105 * @param aEdwinFlags The editor's flags. See @c CEikEdwin::TFlags. |
|
106 * @param aFontControlFlags A set of flags that specify which font |
|
107 * controls should appear, e.g. specifying @c EGulFontControlBold |
|
108 * removes the bold checkbox control. The default shows all. |
|
109 * For possible values, see @c gulftflg.hrh. |
|
110 * @param aFontNameFlags The editor's font name flags. For possible |
|
111 * values, see @c gulftflg.hrh. |
|
112 */ |
|
113 IMPORT_C void ConstructL(const CCoeControl* aParent, |
|
114 TInt aNumberOfLines, |
|
115 TInt aTextLimit, |
|
116 TInt aEdwinFlags, |
|
117 TInt aFontControlFlags, |
|
118 TInt aFontNameFlags); |
|
119 |
|
120 // This feature is not supported in Avkon; type made more general for |
|
121 // source compatibility |
|
122 |
|
123 /** |
|
124 * Not implemented. |
|
125 * |
|
126 * @param aButtonGroup Not used |
|
127 */ |
|
128 IMPORT_C void SetButtonGroup(CCoeControl* aButtonGroup); |
|
129 |
|
130 // This feature is not supported in Avkon |
|
131 /** |
|
132 * Not implemented. |
|
133 * |
|
134 * @param aBitmap Not used |
|
135 */ |
|
136 IMPORT_C void SetLineCursorBitmapL(CFbsBitmap* aBitmap); |
|
137 |
|
138 public: // formatting dialogs |
|
139 |
|
140 /** |
|
141 * Runs a dialog enabling a user to set the font. |
|
142 * |
|
143 * Updates the button group to reflect any text formatting applied. |
|
144 * |
|
145 * @param aFontFlags = EGulNoSymbolFonts Specifies which font types should |
|
146 * appear in the list. For possible values see @c gulftflg.hrh. |
|
147 * @param aGraphicsDevice = NULL The graphics device. This is used to get |
|
148 * the list of available fonts. If NULL the default screen device |
|
149 * is used. |
|
150 * @param aFontControlFlags = EGulFontControlAll A set of flags that specify |
|
151 * which font controls should appear in the dialog e.g. specifying |
|
152 * @c EGulFontControlBold removes the bold checkbox control. |
|
153 * The default shows all. For possible values see @c gulftflg.hrh. |
|
154 * @return @c ETrue if user made a change and pressed @c OK. |
|
155 * @c EFalse if user pressed cancel or made no changes. |
|
156 */ |
|
157 IMPORT_C TBool RunFontDialogL(TInt aFontFlags=EGulNoSymbolFonts, |
|
158 CGraphicsDevice* aGraphicsDevice=NULL, |
|
159 TInt aFontControlFlags=EGulFontControlAll); |
|
160 |
|
161 /** |
|
162 * Runs a dialog enabling an user to set tab position. |
|
163 * |
|
164 * @param aPageWidth Width of the page in twips. |
|
165 */ |
|
166 IMPORT_C void RunTabsDialogL(TInt aPageWidth); |
|
167 |
|
168 /** |
|
169 * Runs indents dialog. |
|
170 * |
|
171 * Changes the paragraph format to indent all text. |
|
172 * |
|
173 * @param aPageWidth Width of page in twips. |
|
174 */ |
|
175 IMPORT_C void RunIndentsDialogL(TInt aPageWidth); |
|
176 |
|
177 /** |
|
178 * Sets the Graphics device to be used. |
|
179 * |
|
180 * @param aGraphicsDevice Wanted graphics device. |
|
181 */ |
|
182 IMPORT_C void SetGraphicsDevice(CGraphicsDevice* aGraphicsDevice); |
|
183 |
|
184 /** |
|
185 * Runs the find dialog. |
|
186 * Enables an user to specify the text for which to search for. |
|
187 */ |
|
188 IMPORT_C void RunFindDialogL(); |
|
189 |
|
190 /** |
|
191 * Runs the find dialog again. |
|
192 */ |
|
193 IMPORT_C void RunFindAgainDialogL(); |
|
194 |
|
195 /** |
|
196 * Runs the replace dialog. |
|
197 * |
|
198 * Enables the user to specify the text to be searched for and the |
|
199 * replacement for that text. Can replace single or multiple occurances. |
|
200 */ |
|
201 IMPORT_C void RunReplaceDialogL(); |
|
202 |
|
203 /** |
|
204 * Sets up the find model, the find list and the replace list ready |
|
205 * for find or replace operations. |
|
206 * |
|
207 * @param aModel The find model to be used. |
|
208 * @param aFindList The find list to be used. |
|
209 * @param aReplaceList The replace list to be used. |
|
210 */ |
|
211 IMPORT_C void InitFindL(SEdwinFindModel*& aModel, |
|
212 CDesCArray*& aFindList, |
|
213 CDesCArray*& aReplaceList); |
|
214 |
|
215 /** |
|
216 * Searches for text. |
|
217 * |
|
218 * Returns @c ETrue if text is found. |
|
219 * |
|
220 * Used by @c RunFindDialogL(), @c RunFindAgainDialogL() and |
|
221 * @c RunReplaceDialogL() methods. |
|
222 * |
|
223 * @return @c ETrue if the text is found @c EFalse otherwise. |
|
224 */ |
|
225 IMPORT_C TBool DoFindL(); |
|
226 |
|
227 /** |
|
228 * Runs a dialog enabling a user to set one of text alignment, spacing or |
|
229 * borders. |
|
230 * |
|
231 * Depending on the user's choice another dialog is run enabling them to |
|
232 * set their requirements. |
|
233 * |
|
234 * @param aCommand User selected command. One of @c EEikCmdParaAlign, |
|
235 * @c EEikCmdParaSpacing or @c EEikCmdParaBorder. |
|
236 */ |
|
237 IMPORT_C void RunParaDialogsL(TInt aCommand); |
|
238 |
|
239 /** |
|
240 * Runs a dialog enabling a user to do pagination. |
|
241 * |
|
242 * @param aPrintSetup The printer setup. |
|
243 * @param aCharsPerPage Page table (array of characters per page). |
|
244 * @return @c ETrue if pagination is succesfull @c EFalse otherwise. |
|
245 */ |
|
246 IMPORT_C TBool RunPaginateDialogL(CPrintSetup* aPrintSetup, |
|
247 CArrayFix<TInt>* aCharsPerPage); |
|
248 |
|
249 public: // other functions |
|
250 |
|
251 /** |
|
252 * Gets the global text that is being edited. |
|
253 * |
|
254 * @return The global text being edited. |
|
255 */ |
|
256 IMPORT_C CGlobalText* GlobalText() const; |
|
257 |
|
258 /** |
|
259 * Applies the paragraph formatting and updates the screen layout. |
|
260 * |
|
261 * The attributes which are set in the mask are read from @c aParaMask. |
|
262 * The attributes which are not set in the mask are not changed. |
|
263 * |
|
264 * @param aParaFormat Contains the new paragraph formatting values |
|
265 * to apply. |
|
266 * @param aParaMask Bitmask specifying the paragraph format attributes |
|
267 * to change. |
|
268 */ |
|
269 IMPORT_C void ApplyParaFormatL(CParaFormat* aParaFormat, |
|
270 TParaFormatMask& aParaMask); |
|
271 |
|
272 /** |
|
273 * Applies the character formatting and updates the screen layout. |
|
274 * |
|
275 * The attributes which are set in the mask are read from @c aCharFormat. |
|
276 * The attributes which are not set in the mask are not changed. |
|
277 * |
|
278 * @param aCharFormat Contain the new character formatting values |
|
279 * to apply. |
|
280 * @param aCharMask Bitmask specifying the character format attributes |
|
281 * to change. |
|
282 */ |
|
283 IMPORT_C void ApplyCharFormatL(TCharFormat& aCharFormat, |
|
284 TCharFormatMask& aCharMask); |
|
285 |
|
286 /** |
|
287 * Toggles format in the current selection. |
|
288 * |
|
289 * For a global text editor the format change is applied globally. |
|
290 * For a rich text editor where there is no selection the format |
|
291 * change is applied to the word at the current cursor position. |
|
292 * |
|
293 * @param aFontFlag The format attribute toggle. See the |
|
294 * @c TFontStyleFlags enum. |
|
295 */ |
|
296 IMPORT_C void BoldItalicUnderlineEventL(TInt aFontFlag); |
|
297 |
|
298 /** |
|
299 * Update the buttons in the button group so that they reflect the |
|
300 * formatting of the global text object. |
|
301 */ |
|
302 IMPORT_C void UpdateButtonGroup(); |
|
303 |
|
304 public: // from CCoeControl |
|
305 |
|
306 /** |
|
307 * From @c CCoeControl. |
|
308 * |
|
309 * Completes construction of the global text editor from a resource file. |
|
310 * |
|
311 * The editor's paragraph and character formatting is set to default |
|
312 * values. |
|
313 * |
|
314 * See the @c GTXTED resource struct |
|
315 * |
|
316 * @param aReader A reader positioned for reading from a @c GTXTED |
|
317 * resource. |
|
318 */ |
|
319 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); |
|
320 |
|
321 /** |
|
322 * From @c CCoeControl. |
|
323 * |
|
324 * Handles key events. |
|
325 * |
|
326 * @param aKeyEvent The key code and modifier |
|
327 * @param aType The type of the event: e.g. Key up. |
|
328 * @return @c EKeyWasConsumed if the event was handled. |
|
329 * @c EKeyWasNotConsumed if the event was not handled. |
|
330 */ |
|
331 IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
332 TEventCode aType); |
|
333 /** |
|
334 * From @c CCoeControl. |
|
335 * |
|
336 * Sets the editor ready for drawing. |
|
337 */ |
|
338 IMPORT_C void ActivateL(); |
|
339 |
|
340 /** |
|
341 * From @c CCoeControl. |
|
342 * |
|
343 * Handles pointer events. |
|
344 * |
|
345 * @param aPointerEvent Pointer to an event that is to be handled. |
|
346 */ |
|
347 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
348 |
|
349 public: // from CEikEdwin |
|
350 |
|
351 /** |
|
352 * From @c CEikEdwin. |
|
353 * |
|
354 * Gets the width of a line cursor in pixels. |
|
355 * |
|
356 * @return The width of the line cursor in pixels. |
|
357 */ |
|
358 IMPORT_C TInt LineCursorWidth() const; |
|
359 |
|
360 protected: |
|
361 |
|
362 /** |
|
363 * Completes the second-phase construction of a @c CEikEdwin object. |
|
364 * This protected function is called by @c ConstructL() and |
|
365 * @c ConstructFromResourceL() after the @c Edwin’s size, flags and |
|
366 * text limit have been set. Derived classes should call either this |
|
367 * function or @c CEikEdwin’s @c ConstructL() or |
|
368 * @c ConstructFromResourceL() functions during their construction |
|
369 * before initialising their own members. |
|
370 */ |
|
371 IMPORT_C void BaseConstructL(); |
|
372 |
|
373 protected: //from CCoeControl |
|
374 |
|
375 /** |
|
376 * From @c CCoeControl. |
|
377 * |
|
378 * Writes the internal state to the specified stream. Does nothing |
|
379 * in release mode. |
|
380 * |
|
381 * @param aWriteStream The stream to write to. |
|
382 */ |
|
383 IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
384 |
|
385 private: // from CoeControl |
|
386 |
|
387 IMPORT_C void Reserved_2(); |
|
388 |
|
389 private: |
|
390 |
|
391 /** |
|
392 * From CAknControl |
|
393 */ |
|
394 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
395 |
|
396 private: // from CEikEdwin |
|
397 |
|
398 IMPORT_C void Reserved_3(); |
|
399 |
|
400 private: |
|
401 |
|
402 void CheckDocumentNotEmptyL(); |
|
403 |
|
404 void CreateFindModelL(); |
|
405 |
|
406 void GetTextForFindL(); |
|
407 |
|
408 protected: |
|
409 |
|
410 /** |
|
411 * Stores the object's global character formatting. |
|
412 */ |
|
413 CCharFormatLayer* iCharFormatLayer; |
|
414 |
|
415 /** |
|
416 * Stores the object's global paragraph formatting. |
|
417 */ |
|
418 CParaFormatLayer* iParaFormatLayer; |
|
419 |
|
420 private: |
|
421 |
|
422 CDesCArray* iFindList; |
|
423 |
|
424 CDesCArray* iReplaceList; |
|
425 |
|
426 SEdwinFindModel* iFindModel; |
|
427 |
|
428 CEikDialogToolBar* iButGroup; |
|
429 |
|
430 TInt iLineCursorWidth; |
|
431 |
|
432 CFbsBitmap* iLineCursor; |
|
433 |
|
434 TInt iFontControlFlags; |
|
435 |
|
436 TInt iFontNameFlags; |
|
437 |
|
438 CGraphicsDevice* iGraphicsDevice; |
|
439 |
|
440 TInt iSpare[4]; |
|
441 }; |
|
442 |
|
443 |
|
444 #endif // __EIKGTED_H__ |
|
445 |
|
446 // enf of file |