|
1 /* |
|
2 * Copyright (c) 1997-2009 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 #ifndef __TXTFRMAT_H__ |
|
20 #define __TXTFRMAT_H__ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <gdi.h> |
|
25 |
|
26 |
|
27 // Classes declared in this file: |
|
28 class TTabStop; |
|
29 class TParaBorder; |
|
30 class TBullet; |
|
31 class TParaBorderArray; |
|
32 class CParaFormat; |
|
33 class TParaFormatMask; |
|
34 class TFontPresentation; |
|
35 class TCharFormat; |
|
36 class TCharFormatMask; |
|
37 |
|
38 /** |
|
39 Provides support for system colours, in addition to literal colours, in |
|
40 text formatting. |
|
41 |
|
42 The base class TRgb stores the 24-bit literal colour value using a TUint32. |
|
43 TLogicalRgb uses the MSB from iValue2 data member as an 8-bit index. The |
|
44 purpose of the index is to allow applications to use logical colours. If the |
|
45 index is zero, the value is not a logical colour; it is treated as an ordinary |
|
46 TRgb value. If the index is non zero (1-255), the colour should be translated by the |
|
47 application into a system colour. Indices 254 and 255 are reserved for the |
|
48 system foreground and background colours, respectively and should be translated |
|
49 into them. Translation from index to RGB colour occurs in the implementation of |
|
50 MFormParam::SystemColor(). |
|
51 |
|
52 All colours in the Text and Text Attributes API are stored using TLogicalRgb |
|
53 values and are initialised to either TLogicalRgb::ESystemForegroundColor or |
|
54 TLogicalRgb::ESystemBackgroundColor. |
|
55 |
|
56 This system allows an application to set its text colours once, perhaps using |
|
57 the system-wide colour scheme, rather than having to set the colours each |
|
58 time a text object is created. It is also compatible with legacy code which |
|
59 expects TRgb rather than TLogicalRgb values: for example, the logical |
|
60 foreground and background colours have their bottom three bytes filled with |
|
61 black and white respectively so that code which expects TRgb values can still |
|
62 use them. |
|
63 @publishedAll |
|
64 @released |
|
65 */ |
|
66 class TLogicalRgb : public TRgb |
|
67 { |
|
68 public: |
|
69 |
|
70 /* |
|
71 Reserved colour indices for default foreground and background colours, |
|
72 and colours for the selection highlight. The top 128 indices (128-255) |
|
73 are reserved for future expansion, but the first 126 non-zero indices |
|
74 (1-127) can be used by the GUI as convenient. |
|
75 */ |
|
76 enum |
|
77 { |
|
78 ESystemSelectionForegroundIndex = 252, |
|
79 ESystemSelectionBackgroundIndex = 253, |
|
80 /** Index reserved for the system foreground colour (=254). */ |
|
81 ESystemForegroundIndex = 254, |
|
82 /** Index reserved for the system background colour (=255). */ |
|
83 ESystemBackgroundIndex = 255 |
|
84 }; |
|
85 |
|
86 |
|
87 |
|
88 /** Used to construct TLogicalRgb objects which should use either the |
|
89 system foreground or background colour. */ |
|
90 enum TSystemColor |
|
91 { |
|
92 ESystemSelectionForegroundColor = ESystemSelectionForegroundIndex << 24, |
|
93 ESystemSelectionBackgroundColor = ESystemSelectionBackgroundIndex << 24, |
|
94 /** The system foreground colour. */ |
|
95 ESystemForegroundColor = ESystemForegroundIndex << 24, |
|
96 /** The system background colour. */ |
|
97 ESystemBackgroundColor = (ESystemBackgroundIndex << 24) | 0xFFFFFF |
|
98 }; |
|
99 |
|
100 /** Constructs a new TLogicalRgb object. */ |
|
101 TLogicalRgb() : |
|
102 iValue2(0) |
|
103 { |
|
104 } |
|
105 |
|
106 /** Constructs the object with a 32-bit integer. The index is stored in the |
|
107 MSB of iValue2 data member. A TRgb value may be stored in the base TRgb class. |
|
108 @param aValue Integer holding the logical colour index. */ |
|
109 TLogicalRgb(TUint32 aValue): |
|
110 iValue2(aValue & 0xFF000000) |
|
111 { |
|
112 SetInternal((TUint32)aValue | 0xFF000000); |
|
113 } |
|
114 |
|
115 /** Constructs the object with a TSystemColor value. |
|
116 @param aValue Identifies whether the colour is the system foreground or |
|
117 system background colour. */ |
|
118 TLogicalRgb(TSystemColor aValue) : |
|
119 iValue2((TUint32)aValue & 0xFF000000) |
|
120 { |
|
121 SetInternal((TUint32)aValue | 0xFF000000); |
|
122 } |
|
123 |
|
124 /** Constructs a new TLogicalRgb object from an existing one. */ |
|
125 TLogicalRgb(const TRgb& aRgb) : |
|
126 TRgb(aRgb), |
|
127 iValue2(0) |
|
128 { |
|
129 } |
|
130 |
|
131 /** Returns the logical colour's index value. Zero indicates that the value |
|
132 is not a logical colour; it is an ordinary TRgb value. 254 and 255 indicate |
|
133 the system foreground and background colours, respectively. |
|
134 @return The index: between zero and 255 inclusive. */ |
|
135 TUint SystemColorIndex() const |
|
136 { |
|
137 return iValue2 >> 24; |
|
138 } |
|
139 |
|
140 /** Sets the logical colour's index value. |
|
141 @param aIndex The new index value (between 1 and 253 inclusive). */ |
|
142 void SetSystemColorIndex(TUint aIndex) |
|
143 { |
|
144 iValue2 = aIndex << 24; |
|
145 } |
|
146 |
|
147 private: |
|
148 TUint32 iValue2; |
|
149 |
|
150 }; |
|
151 |
|
152 /** |
|
153 Indicates which format attributes are relevant when setting or sensing text |
|
154 formatting. |
|
155 @publishedAll |
|
156 @released |
|
157 */ |
|
158 enum TTextFormatAttribute |
|
159 { |
|
160 // Paragraph format attributes. |
|
161 /** Language of the paragraph for proofing. */ |
|
162 EAttParaLanguage, |
|
163 /** Background colour of the paragraph. */ |
|
164 EAttFillColor, |
|
165 /** Leading text margin. */ |
|
166 EAttLeftMargin, |
|
167 /** Trailing text margin. */ |
|
168 EAttRightMargin, |
|
169 /** First line leading indent. */ |
|
170 EAttIndent, |
|
171 /** Horizontal alignment of paragraph. */ |
|
172 EAttAlignment, |
|
173 /** Vertical paragraph alignment. */ |
|
174 EAttVerticalAlignment, |
|
175 /** Inter-line spacing. */ |
|
176 EAttLineSpacing, |
|
177 /** Control for EAttLineSpacing. */ |
|
178 EAttLineSpacingControl, |
|
179 /** Space above paragraph. */ |
|
180 EAttSpaceBefore, |
|
181 /** Space below paragraph. */ |
|
182 EAttSpaceAfter, |
|
183 /** Whether a page break can occur within the paragraph. */ |
|
184 EAttKeepTogether, |
|
185 /** Whether a page break can occur between this and the next paragraph. */ |
|
186 EAttKeepWithNext, |
|
187 /** Whether a page break should be inserted before this paragraph. */ |
|
188 EAttStartNewPage, |
|
189 /** Whether the last line of a paragraph can appear by itself at the top of a new |
|
190 page, (widow), or the first line of a paragraph can appear by itself at the |
|
191 bottom of the page, (orphan). */ |
|
192 EAttWidowOrphan, |
|
193 /** Whether the paragraph should line wrap at the right margin. */ |
|
194 EAttWrap, |
|
195 /** Distance between paragraph border and enclosed text. */ |
|
196 EAttBorderMargin, |
|
197 /** Top of paragraph border. */ |
|
198 EAttTopBorder, |
|
199 /** Bottom of paragraph border. */ |
|
200 EAttBottomBorder, |
|
201 /** Left-hand side of paragraph border. */ |
|
202 EAttLeftBorder, |
|
203 /** Right-hand side of paragraph border. */ |
|
204 EAttRightBorder, |
|
205 /** Bullet point associated with paragraph. */ |
|
206 EAttBullet, |
|
207 /** Spacing between default tab stops. */ |
|
208 EAttDefaultTabWidth, |
|
209 /** Tab stop. */ |
|
210 EAttTabStop, |
|
211 |
|
212 // Character format attributes. |
|
213 /** Language of individual characters within a paragraph for proofing. */ |
|
214 EAttCharLanguage, |
|
215 /** Text colour. */ |
|
216 EAttColor, |
|
217 /** Text highlight colour. */ |
|
218 EAttFontHighlightColor, |
|
219 /** Text highlight style. */ |
|
220 EAttFontHighlightStyle, |
|
221 /** Font height. */ |
|
222 EAttFontHeight, |
|
223 /** Font posture (i.e. italics). */ |
|
224 EAttFontPosture, |
|
225 /** Font stroke weight (i.e. bold). */ |
|
226 EAttFontStrokeWeight, |
|
227 /** Subscript, superscript or normal print position. */ |
|
228 EAttFontPrintPos, |
|
229 /** Underlining. */ |
|
230 EAttFontUnderline, |
|
231 /** Strikethrough. */ |
|
232 EAttFontStrikethrough, |
|
233 /** The typeface name. */ |
|
234 EAttFontTypeface, |
|
235 /** Vertical picture alignment. */ |
|
236 EAttFontPictureAlignment, |
|
237 /** Hidden text. */ |
|
238 EAttFontHiddenText, |
|
239 |
|
240 /** Used internally to indicate the count of all attributes. */ |
|
241 ETextFormatAttributeCount |
|
242 }; |
|
243 |
|
244 /* |
|
245 Following enum and variable should not be used by external developers. |
|
246 */ |
|
247 enum {EVariableLengthValue = 0}; |
|
248 |
|
249 const TInt KMaxStyleName = 0x20; |
|
250 const TInt KMaxParaAttributes = EAttTabStop; |
|
251 const TInt KMaxCharAttributes = EAttFontHiddenText - KMaxParaAttributes; |
|
252 const TInt KTabNotFound = -1; |
|
253 |
|
254 /** |
|
255 A tab stop. |
|
256 |
|
257 This is a position on a page used to align columns of text. It has a twips |
|
258 position and an alignment. The twips position is the width in twips (1/1440th |
|
259 of an inch) of the tab stop, i.e. the number of twips from the start of the |
|
260 line at which text can be inserted. It uniquely identifies the tab stop. The |
|
261 alignment (left, right, or centre) indicates how text inserted at the tab |
|
262 stop should be aligned. |
|
263 |
|
264 Tab stops are paragraph format attributes. They are owned by the CParaFormat |
|
265 class, through which tab stops can be added and removed. |
|
266 @publishedAll |
|
267 @released |
|
268 */ |
|
269 class TTabStop |
|
270 { |
|
271 public: |
|
272 /** Text alignment at the tab stop. */ |
|
273 enum TTabType |
|
274 { |
|
275 /** No tab. */ |
|
276 ENullTab, |
|
277 /** Text is aligned to the tab stop's leading edge (left for |
|
278 left-to-right paragraphs, right for right-to-left paragraphs). */ |
|
279 ELeftTab, |
|
280 /** Text is aligned to the tab stop's trailing edge (right for |
|
281 left-to-right paragraphs, left for right-to-left paragraphs). */ |
|
282 ECenteredTab, |
|
283 /** Text is right aligned at the tab stop. */ |
|
284 ERightTab |
|
285 }; |
|
286 public: |
|
287 IMPORT_C TTabStop(); |
|
288 IMPORT_C TTabStop(const TTabStop& aTabStop); |
|
289 IMPORT_C TTabStop& operator=(const TTabStop& aTabStop); |
|
290 IMPORT_C TBool operator==(const TTabStop& aTabStop) const; |
|
291 inline TBool operator!=(const TTabStop& aTabStop) const; |
|
292 public: |
|
293 /** The twips position. This is the width in twips of the tab stop, i.e. |
|
294 the number of twips from the start of the line at which text can be |
|
295 inserted. */ |
|
296 TUint32 iTwipsPosition; |
|
297 /** Text alignment at the tab stop. */ |
|
298 TTabType iType; |
|
299 }; |
|
300 |
|
301 /** |
|
302 Defines the characteristics of one of the four sides of a paragraph border. |
|
303 |
|
304 These are the line style, thickness and colour. Paragraph borders are paragraph |
|
305 format attributes. They are owned by the CParaFormat class which allows |
|
306 paragraph borders to be added and removed. The CParaFormat::TParaBorderSide |
|
307 enumeration identifies which side of the paragraph the object applies to. |
|
308 @publishedAll |
|
309 @released |
|
310 */ |
|
311 class TParaBorder |
|
312 { |
|
313 public: |
|
314 |
|
315 /** Line styles. */ |
|
316 enum TLineStyle |
|
317 { |
|
318 /** No line style. */ |
|
319 ENullLineStyle, |
|
320 /** Solid line. */ |
|
321 ESolid, |
|
322 /** Double solid line. */ |
|
323 EDouble, |
|
324 /** Dotted line. */ |
|
325 EDotted, |
|
326 /** Dashed line. */ |
|
327 EDashed, |
|
328 /** Alternating dots and dashes. */ |
|
329 EDotDash, |
|
330 /** Alternating sequence of two dots and a dash. */ |
|
331 EDotDotDash |
|
332 }; |
|
333 // |
|
334 IMPORT_C TParaBorder(); |
|
335 IMPORT_C TBool operator==(const TParaBorder& aParaBorder) const; |
|
336 inline TBool operator!=(const TParaBorder& aParaBorder) const; |
|
337 public: |
|
338 /** The line style. By default, ENullLineStyle. */ |
|
339 TLineStyle iLineStyle; |
|
340 /** The line thickness in twips. By default, zero. */ |
|
341 TInt iThickness; |
|
342 /** The line colour. By default, the system's default foreground colour. */ |
|
343 TLogicalRgb iColor; |
|
344 /** ETrue indicates that the line colour is set to the default or current |
|
345 text colour, overriding iColor. EFalse indicates that the iColor value is |
|
346 used. By default, ETrue. */ |
|
347 TBool iAutoColor; |
|
348 }; |
|
349 |
|
350 /** |
|
351 Stores the four sides of a paragraph border. |
|
352 |
|
353 Paragraph borders sides are set individually using functions provided by class |
|
354 CParaFormat. |
|
355 @publishedAll |
|
356 @released |
|
357 */ |
|
358 class TParaBorderArray |
|
359 { |
|
360 public: |
|
361 TParaBorder iBorder[4]; |
|
362 }; |
|
363 |
|
364 /** |
|
365 A bullet point. |
|
366 |
|
367 This is a paragraph format attribute, stored as the iBullet member of class |
|
368 CParaFormat. |
|
369 |
|
370 Bullet points have a typeface, height, colour and a character code (defines |
|
371 the symbol displayed). Single level bullets only are supported. Bullets may |
|
372 also have a hanging indent. If set, this means that the rest of the paragraph |
|
373 following the line containing the bullet point is indented. |
|
374 @publishedAll |
|
375 @released |
|
376 */ |
|
377 class TBullet |
|
378 { |
|
379 public: |
|
380 IMPORT_C TBullet(); |
|
381 IMPORT_C TBool operator ==(const TBullet& aBullet) const; |
|
382 inline TBool operator !=(const TBullet& aBullet) const; |
|
383 |
|
384 /** |
|
385 Identifies the bullet style. |
|
386 |
|
387 Note: Styles other than ENullStyle and EBulletStyle are not currently supported. |
|
388 They have the same effect as the EBulletStyle. |
|
389 */ |
|
390 enum TStyle |
|
391 { |
|
392 /** |
|
393 No bullet. Used for style layers that override a bullet with the absence of a bullet. |
|
394 */ |
|
395 ENullStyle, |
|
396 /** |
|
397 A bullet point. Character with code 0x2022 is used by default. |
|
398 */ |
|
399 EBulletStyle, |
|
400 EArabicNumberStyle, |
|
401 ESmallRomanNumberStyle, |
|
402 ECapitalRomanNumberStyle, |
|
403 ESmallLetterStyle, |
|
404 ECapitalLetterStyle |
|
405 }; |
|
406 |
|
407 /** Paragraph alignment */ |
|
408 enum TAlignment |
|
409 { |
|
410 /** Paragraph left aligned. */ |
|
411 ELeftAlign, |
|
412 /** Paragraph centre aligned. */ |
|
413 ECenterAlign, |
|
414 /** Paragraph right aligned. */ |
|
415 ERightAlign |
|
416 }; |
|
417 |
|
418 /** The Unicode character used to represent the bullet point. By default |
|
419 0x2022. */ |
|
420 TChar iCharacterCode; // the bullet or other symbol used if iStyle is EBulletStyle |
|
421 /** The height in twips of the font used for the bullet point character. |
|
422 By default, zero. */ |
|
423 TUint iHeightInTwips; |
|
424 /** The typeface used for the bullet point character. */ |
|
425 TTypeface iTypeface; |
|
426 /** ETrue to indent the rest of the paragraph from the bullet point. |
|
427 EFalse to align the bullet point character with the rest of the paragraph. */ |
|
428 TBool iHangingIndent; |
|
429 /** The colour of the bullet point character. By default, the system's |
|
430 default foreground colour. */ |
|
431 TLogicalRgb iColor; |
|
432 TStyle iStyle; // is this a bullet or a number or a letter? |
|
433 TInt iStartNumber; // the number of the first paragraph in a run of paragraphs in this style |
|
434 TAlignment iAlignment; // alignment of the bullet or number within the margin |
|
435 }; |
|
436 |
|
437 /** |
|
438 A transient container of paragraph format attributes, including tab stops, |
|
439 bullet points and paragraph borders. |
|
440 |
|
441 Rich and global text objects store paragraph formatting using paragraph format |
|
442 layers (see class CParaFormatLayer). The CParaFormat class is used to store |
|
443 the relevant attribute values when setting or sensing a CParaFormatLayer. |
|
444 It is normally used in combination with a TParaFormatMask, to specify which |
|
445 attributes are relevant to the function concerned. |
|
446 |
|
447 On construction, all CParaFormat member data is initialised. The attributes |
|
448 which are not explicitly set are assigned default values. |
|
449 @publishedAll |
|
450 @released |
|
451 */ |
|
452 class CParaFormat: public CBase |
|
453 { |
|
454 public: |
|
455 /** Miscellaneous constants. */ |
|
456 enum |
|
457 { |
|
458 /** The maximum number of paragraph borders (= 4). */ |
|
459 EMaxParaBorder = 4 |
|
460 }; |
|
461 |
|
462 /** Paragraph border sides */ |
|
463 enum TParaBorderSide |
|
464 { |
|
465 /** The border at the top of the paragraph. */ |
|
466 EParaBorderTop, |
|
467 /** The border at the bottom of the paragraph. */ |
|
468 EParaBorderBottom, |
|
469 /** The border on the left hand side. */ |
|
470 EParaBorderLeft, |
|
471 /** The border on the right hand side. */ |
|
472 EParaBorderRight |
|
473 }; |
|
474 |
|
475 /** Line spacing control */ |
|
476 enum TLineSpacingControl |
|
477 { |
|
478 /** Twips line spacing must be at least as wide as the |
|
479 iLineSpacingInTwips value. */ |
|
480 ELineSpacingAtLeastInTwips, |
|
481 /** Twips line spacing must be exactly the iLineSpacingInTwips value. */ |
|
482 ELineSpacingExactlyInTwips, |
|
483 /** Pixels line spacing must be at least as wide as the line spacing |
|
484 value in pixels. */ |
|
485 ELineSpacingAtLeastInPixels, |
|
486 /** Pixels line spacing must be exactly the same as the line spacing |
|
487 value in pixels. */ |
|
488 ELineSpacingExactlyInPixels |
|
489 }; |
|
490 |
|
491 /** Paragraph alignment */ |
|
492 enum TAlignment |
|
493 { |
|
494 /** Paragraph aligned to the leading margin (left for left-to-right |
|
495 paragraphs, right for right-to-left paragraphs). */ |
|
496 ELeftAlign, |
|
497 /** Paragraph top aligned. */ |
|
498 ETopAlign = ELeftAlign, |
|
499 /** Paragraph centre aligned. */ |
|
500 ECenterAlign, |
|
501 /** Paragraph aligned to the trailing margin (right for left-to-right |
|
502 paragraphs, left for right-to-left paragraphs). */ |
|
503 ERightAlign, |
|
504 /** Paragraph bottom aligned. */ |
|
505 EBottomAlign = ERightAlign, |
|
506 /** Paragraph justified. */ |
|
507 EJustifiedAlign, |
|
508 /** Used by the spreadsheet application. Unlike ETopAlign and |
|
509 EBottomAlign, provides no default implementation. */ |
|
510 EUnspecifiedAlign, |
|
511 /** User-defined paragraph alignment. */ |
|
512 ECustomAlign, |
|
513 /** Absolute left alignment */ |
|
514 EAbsoluteLeftAlign, |
|
515 /** Absolute right alignment */ |
|
516 EAbsoluteRightAlign |
|
517 }; |
|
518 |
|
519 /** Attribute sense mode */ |
|
520 enum TParaFormatGetMode |
|
521 { |
|
522 /** Indicates that all paragraph format attributes are written to the |
|
523 result when sensing paragraph format attributes. */ |
|
524 EAllAttributes, |
|
525 /** Indicates that tabs, bullets and borders are not sensed. */ |
|
526 EFixedAttributes |
|
527 }; |
|
528 |
|
529 IMPORT_C static CParaFormat* NewL(); |
|
530 IMPORT_C static CParaFormat* NewLC(); |
|
531 IMPORT_C static CParaFormat* NewL(const CParaFormat& aFormat); |
|
532 IMPORT_C CParaFormat(); |
|
533 IMPORT_C ~CParaFormat(); |
|
534 IMPORT_C void ResetNonDestructive(); // preserves any allocated tabs, bullets or borders. |
|
535 IMPORT_C void Reset(); // full reset, deletes and nulls any allocated tabs, bullets or borders. |
|
536 IMPORT_C void CopyL(const CParaFormat& aFormat, const TParaFormatMask& aMask); |
|
537 IMPORT_C void CopyL(const CParaFormat& aFormat); |
|
538 IMPORT_C void Strip(); // Cleans up this paragraph format. |
|
539 IMPORT_C TBool IsEqual(const CParaFormat& aFormat, const TParaFormatMask& aMask) const; |
|
540 IMPORT_C TBool IsEqual(const CParaFormat& aFormat) const; |
|
541 IMPORT_C void StoreTabL(const TTabStop& aTabStop); |
|
542 IMPORT_C void RemoveTab(TInt aTabTwipsPosition); |
|
543 inline void RemoveAllTabs(); |
|
544 IMPORT_C const TTabStop TabStop(TInt aTabIndex) const; |
|
545 inline TInt TabCount() const; |
|
546 IMPORT_C TInt LocateTab(TInt aTabTwipsPosition) const; |
|
547 IMPORT_C void SetParaBorderL(TParaBorderSide aSide, const TParaBorder& aBorder); // Overwrites any existing border for that side |
|
548 IMPORT_C void RemoveAllBorders(); |
|
549 IMPORT_C const TParaBorder ParaBorder(TParaBorderSide aSide) const; |
|
550 |
|
551 /** Tests whether any paragraph borders have been set. |
|
552 |
|
553 @return ETrue if any paragraph borders have been set, EFalse if not. */ |
|
554 inline TBool BordersPresent() const { return iParaBorderArray != NULL;} |
|
555 |
|
556 inline TParaBorder* ParaBorderPtr(TParaBorderSide aSide) |
|
557 |
|
558 /** Gets a pointer to the paragraph border on the side specified. If no |
|
559 paragraph border array has been allocated, returns NULL. |
|
560 |
|
561 @param aSide The side for the paragraph border. |
|
562 @return Pointer to the paragraph border on the specified side. */ |
|
563 { return iParaBorderArray ? &iParaBorderArray->iBorder[aSide] : NULL; } |
|
564 IMPORT_C TBool AllBordersEqual(const CParaFormat& aFormat) const; |
|
565 IMPORT_C TBool IsBorderEqual(TParaBorderSide aSide, const CParaFormat& aFormat) const; |
|
566 private: |
|
567 CParaFormat(const CParaFormat& aFormat); |
|
568 void CreateTabListL(); |
|
569 enum |
|
570 { |
|
571 ETabStoreGranularity = 2 |
|
572 }; |
|
573 |
|
574 CParaFormat& operator=(const CParaFormat& aParaFormat); // intentionally unimplemented |
|
575 private: |
|
576 CArrayFixFlat<TTabStop>* iTabList; // ordered list of tab stops; null if none |
|
577 TParaBorderArray* iParaBorderArray; // array of paragraph borders; null if none |
|
578 public: |
|
579 /** The background colour of the paragraph. By default the default system |
|
580 background colour. This colour applies to the area bounded by the paragraph |
|
581 border, if one exists. */ |
|
582 TLogicalRgb iFillColor; |
|
583 /** The language of the paragraph for proofing. By default |
|
584 KParaDefaultLanguage. Used for example when spell checking a document |
|
585 which contains text in more than one language, so that the program |
|
586 recognises the text as being in another language. */ |
|
587 TInt32 iLanguage; |
|
588 /** The width in twips of the leading margin (left for left-to-right |
|
589 paragraphs, right for right-to-left paragraphs). By default |
|
590 KParaDefaultLeftMargin (zero). */ |
|
591 TInt32 iLeftMarginInTwips; |
|
592 /** The width in twips of the trailing margin (right for left-to-right |
|
593 paragraphs, left for right-to-left paragraphs). By default |
|
594 KParaDefaultRightMargin (zero). */ |
|
595 TInt32 iRightMarginInTwips; |
|
596 /** An indent for the first line in the paragraph, relative to the leading |
|
597 margin (left for left-to-right paragraphs, right for right-to-left |
|
598 paragraphs). By default KParaDefaultIndent (zero). */ |
|
599 TInt32 iIndentInTwips; |
|
600 /** Horizontal alignment of paragraph. By default KParaDefaultHorizAlign |
|
601 (left). */ |
|
602 TAlignment iHorizontalAlignment; |
|
603 /** Vertical alignment of paragraph, (intended for use by spreadsheet |
|
604 applications). By default KParaDefaultVertAlign (unspecified). */ |
|
605 TAlignment iVerticalAlignment; |
|
606 /** Inter-line spacing within the paragraph, in twips. By default |
|
607 KParaDefaultLineSpacing (200 twips). */ |
|
608 TInt32 iLineSpacingInTwips; // distance between successive baselines |
|
609 /** Control for the iLineSpacingInTwips value. By default, |
|
610 KParaDefaultLineSpacingControl (ELineSpacingAtLeastInTwips). */ |
|
611 TLineSpacingControl iLineSpacingControl; // whether iLineSpacingInTwips means 'at least' or 'exactly' |
|
612 /** Space above paragraph. By default KParaDefaultSpaceBefore (zero). */ |
|
613 TInt32 iSpaceBeforeInTwips; |
|
614 /** Space below paragraph. By default KParaDefaultSpaceAfter (zero). */ |
|
615 TInt32 iSpaceAfterInTwips; |
|
616 /** Prevents a page break within paragraph if ETrue. By default |
|
617 KParaDefaultKeepTogether (EFalse). */ |
|
618 TBool iKeepTogether; |
|
619 /** Prevents a page break between this paragraph and the following |
|
620 paragraph if ETrue. By default, KParaDefaultKeepWithNext (EFalse). */ |
|
621 TBool iKeepWithNext; |
|
622 /** Inserts a page break immediately before this paragraph if ETrue. |
|
623 By default, KParaDefaultStartNewPage (EFalse). */ |
|
624 TBool iStartNewPage; |
|
625 /** Prevents the printing of the last line of a paragraph at the top |
|
626 of the page (referred to as a widow), or the first line of a paragraph |
|
627 at the bottom of the page, (referred to as an orphan). By default, |
|
628 KParaDefaultWidowOrphan (EFalse). */ |
|
629 TBool iWidowOrphan; |
|
630 /** Specifies whether the paragraph should line wrap at the right margin. |
|
631 By default KParaDefaultWrap (ETrue). */ |
|
632 TBool iWrap; |
|
633 /** Distance in twips between the paragraph border and the enclosed text. |
|
634 By default KParaDefaultBorderMargin (zero). */ |
|
635 TInt32 iBorderMarginInTwips; |
|
636 /** The bullet point associated with the paragraph. A NULL value indicates |
|
637 no bullet point. By default NULL. */ |
|
638 TBullet* iBullet; |
|
639 /** Specifies the default tab stop width. By default KParaDefaultTabWidth |
|
640 (360 twips). */ |
|
641 TUint32 iDefaultTabWidthInTwips; |
|
642 }; |
|
643 |
|
644 /** |
|
645 Masks the paragraph format attributes which are involved when setting and |
|
646 sensing paragraph formatting. |
|
647 |
|
648 Used in conjunction with an object of class CParaFormat. When setting formatting, |
|
649 only the attributes which are set in the mask will participate in the relevant |
|
650 function. When sensing formatting, on return, the mask indicates which attributes |
|
651 were sensed from the format layer, and were not taken from the default values. |
|
652 @publishedAll |
|
653 @released |
|
654 */ |
|
655 class TParaFormatMask |
|
656 { |
|
657 public: |
|
658 inline TParaFormatMask(); |
|
659 inline void SetAttrib(TTextFormatAttribute aAttribute); |
|
660 inline void ClearAttrib(TTextFormatAttribute aAttribute); |
|
661 IMPORT_C void SetAll(); |
|
662 IMPORT_C void ClearAll(); |
|
663 inline TBool AttribIsSet(TTextFormatAttribute aAttribute) const; |
|
664 inline TBool IsNull() const; |
|
665 IMPORT_C TBool operator==(const TParaFormatMask& aMask) const; |
|
666 inline TBool operator!=(const TParaFormatMask& aMask) const; |
|
667 |
|
668 private: |
|
669 TUint32 iGuard; |
|
670 }; |
|
671 |
|
672 /** |
|
673 Specifies the font-independent character format attributes, including bold, |
|
674 italics and underlining. |
|
675 |
|
676 An instance of this class is owned by the character formatting container (class |
|
677 TCharFormat). |
|
678 @publishedAll |
|
679 @released |
|
680 */ |
|
681 class TFontPresentation |
|
682 { |
|
683 public: |
|
684 |
|
685 /** Highlight style */ |
|
686 enum TFontHighlightStyle |
|
687 { |
|
688 /** No highlighting used. */ |
|
689 EFontHighlightNone, |
|
690 /** Normal (square cornered) highlighting used. */ |
|
691 EFontHighlightNormal, |
|
692 /** Rounded corner highlighting used. */ |
|
693 EFontHighlightRounded, |
|
694 /** Text is drawn offset towards the bottom-right in the highlight |
|
695 colour, (iHighlightColor) before being drawn again in the text colour, |
|
696 (iTextColor) creating a shadow effect. */ |
|
697 EFontHighlightShadow, |
|
698 /** Placeholder for "unrecognised word" highlighting style for FEPs */ |
|
699 EFontHighlightNoMatchesIndicator, |
|
700 /** First custom highlighting style is used. |
|
701 @see MFormCustomDraw::DrawText(). */ |
|
702 EFontHighlightFirstCustomStyle = 128, |
|
703 /** Second custom highlighting style is used. |
|
704 @see MFormCustomDraw::DrawText(). */ |
|
705 EFontHighlightLastCustomStyle = 255 |
|
706 }; |
|
707 |
|
708 |
|
709 /** Vertical picture alignment */ |
|
710 enum TAlignment |
|
711 { |
|
712 /** The top of the picture is aligned flush with the top of the font's |
|
713 ascent, so that the picture may descend below the line. */ |
|
714 EAlignTop, |
|
715 /** The bottom of the picture is aligned flush with the bottom of the |
|
716 font's descent so that the picture may extend above the line. */ |
|
717 EAlignBottom, |
|
718 /** The picture is aligned so that its centre is positioned at the |
|
719 baseline of the line. */ |
|
720 EAlignCentered, |
|
721 /** The bottom of the picture is aligned with the baseline of the font. |
|
722 This is the default. */ |
|
723 EAlignBaseLine |
|
724 }; |
|
725 // |
|
726 IMPORT_C TFontPresentation(); |
|
727 // |
|
728 // Enquiry function |
|
729 IMPORT_C TBool IsEqual(const TFontPresentation& aFontPresentation, const TCharFormatMask& aMask) const; |
|
730 public: |
|
731 /** The text colour. By default, the default system foreground colour. */ |
|
732 TLogicalRgb iTextColor; |
|
733 /** The highlight colour for selected text. Only takes effect if |
|
734 iHighlightStyle is not EFontHighlightNone. By default, the default system |
|
735 foreground colour. */ |
|
736 TLogicalRgb iHighlightColor; // Background color |
|
737 /** Style for character highlighting. By default EFontHighlightNone. */ |
|
738 TFontHighlightStyle iHighlightStyle; |
|
739 /** The value of the strikethrough attribute. By default EStrikethroughOff. */ |
|
740 TFontStrikethrough iStrikethrough; |
|
741 /** The value of the underline attribute. By default EUnderlineOff. */ |
|
742 TFontUnderline iUnderline; |
|
743 /** Specifies whether or not text is hidden. Note that hidden text is not |
|
744 currently supported by the text layout engine. This attribute is provided |
|
745 to preserve information when copying from and to devices which support |
|
746 hidden text. By default EFalse. */ |
|
747 TBool iHiddenText; |
|
748 /** The vertical alignment of a picture character. By default |
|
749 EAlignBaseLine. */ |
|
750 TAlignment iPictureAlignment; |
|
751 }; |
|
752 |
|
753 /** |
|
754 A transient container of character format attributes, including |
|
755 font-dependent and font-independent attributes. |
|
756 |
|
757 The font-independent attributes are stored in a TFontPresentation object. |
|
758 Rich and global text objects store character formatting using character format |
|
759 layers (see class CCharFormatLayer). The TCharFormat class is used to store |
|
760 the relevant attribute values when setting or sensing a CCharFormatLayer. |
|
761 It is normally used in combination with a TCharFormatMask, to specify which |
|
762 attributes are relevant to the function concerned. |
|
763 @publishedAll |
|
764 @released |
|
765 */ |
|
766 class TCharFormat |
|
767 { |
|
768 public: |
|
769 IMPORT_C TCharFormat(); |
|
770 IMPORT_C TCharFormat(const TDesC &aTypefaceName, TInt aHeight); |
|
771 // |
|
772 // Enquiry functions |
|
773 IMPORT_C TBool IsEqual(const TCharFormat& aFormat, const TCharFormatMask& aMask) const; |
|
774 IMPORT_C TBool IsEqual(const TCharFormat& aFormat) const; |
|
775 public: |
|
776 /** Specifies the language of individual characters for proofing. Used for |
|
777 example when spell checking a document which contains text in more than one |
|
778 language, so that the program recognises the text as being in another |
|
779 language. Language is also a paragraph format attribute. If the language |
|
780 setting of a character is different from the language setting of the |
|
781 containing paragraph, the character's setting takes precedence. */ |
|
782 TInt32 iLanguage; |
|
783 /** Font independent character format attributes. */ |
|
784 TFontPresentation iFontPresentation; |
|
785 /** Device independent font specification. */ |
|
786 TFontSpec iFontSpec; |
|
787 }; |
|
788 |
|
789 /** |
|
790 Masks the character format attributes which are involved when setting and |
|
791 sensing character formatting. |
|
792 |
|
793 Used in conjunction with an object of class TCharFormat. |
|
794 |
|
795 When setting formatting, only the attributes which are set in the mask should |
|
796 participate in the relevant function. When sensing formatting, on return, |
|
797 the mask indicates which attributes were sensed from the format layer, and |
|
798 were not taken from the default values. |
|
799 @publishedAll |
|
800 @released |
|
801 */ |
|
802 class TCharFormatMask |
|
803 { |
|
804 public: |
|
805 inline TCharFormatMask(); |
|
806 inline void SetAttrib(TTextFormatAttribute aAttribute); |
|
807 inline void ClearAttrib(TTextFormatAttribute aAttribute); |
|
808 inline TBool AttribIsSet(TTextFormatAttribute aAttribute) const; |
|
809 IMPORT_C void SetAll(); |
|
810 IMPORT_C void ClearAll(); |
|
811 inline TBool IsNull()const; |
|
812 IMPORT_C TBool operator==(const TCharFormatMask& aMask) const; |
|
813 inline TBool operator!=(const TCharFormatMask& aMask) const; |
|
814 |
|
815 private: |
|
816 TUint32 iGuard; |
|
817 }; |
|
818 |
|
819 #include <txtfrmat.inl> |
|
820 |
|
821 #endif |