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