|
1 /* |
|
2 * Copyright (c) 2006 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: Text style class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_ALFTEXTSTYLE_H |
|
21 #define C_ALFTEXTSTYLE_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <gdi.h> // for TRgb |
|
25 #include <alf/alftexture.h> |
|
26 |
|
27 class CAlfEnv; |
|
28 class CAlfGenComponent; |
|
29 class THuiFont; |
|
30 class CAlfTextStyleManager; |
|
31 |
|
32 /** |
|
33 * CAlfTextStyle presents an abstract text style implementation. |
|
34 * Its main purpose is to act as an encapsulation of a particular text style. |
|
35 * Usage: |
|
36 * @code |
|
37 * |
|
38 * //Get Textstyle manager from environment |
|
39 * CAlfTextStyleManager* styleMgr = &iEnv->TextStyleManager(); |
|
40 * |
|
41 * //Get textstyle |
|
42 * TInt styleId = styleMgr->CreatePlatformTextStyleL(); |
|
43 * CAlfTextstyle* style = styleMgr->TextStyle( styleId ); |
|
44 * |
|
45 * //Customise textstyle |
|
46 * style->SetStrikeThrough( ETrue ); |
|
47 * style->SetUnderline( ETrue ); |
|
48 * |
|
49 * //Assign style to text visual |
|
50 * textVisual->SetTextStyle( style->Id() ); |
|
51 * |
|
52 * //Cleanup |
|
53 * styleMgr->DeleteTextStyle( styleId ); |
|
54 * delete iEnv; |
|
55 * |
|
56 * @endcode |
|
57 * |
|
58 * @see CAlfTextStyleManager |
|
59 * Derived platform dependant classes will implement their own version of this class |
|
60 */ |
|
61 NONSHARABLE_CLASS( CAlfTextStyle ): public CBase |
|
62 { |
|
63 |
|
64 public: |
|
65 |
|
66 /* Constructors and destructor. */ |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 ~CAlfTextStyle(); |
|
72 |
|
73 /** |
|
74 * Constructs a new CAlfTextStyle object. |
|
75 * |
|
76 * @param aEnv Current Alf environment. |
|
77 * @param aId The unique ID of this text style. Created by CAlfTextStyleManager. |
|
78 * @param aImplementationId Describes the type of text style that is created (platform text style, etc.) |
|
79 * @param aConstructionParams Construction parameters. |
|
80 */ |
|
81 static CAlfTextStyle* NewL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams); |
|
82 |
|
83 /** |
|
84 * Constructs a new CAlfTextStyle object and leaves it into the cleanup stack. |
|
85 * |
|
86 * @param aEnv Current Alf environment. |
|
87 * @param aId The unique ID of this text style. Created by CAlfTextStyleManager. |
|
88 * @param aImplementationId Describes the type of text style that is created (platform text style, etc.) |
|
89 * @param aConstructionParams Construction parameters. |
|
90 */ |
|
91 static CAlfTextStyle* NewLC(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams); |
|
92 |
|
93 /** |
|
94 * Returns the S60 font style id of this text style. Ids are defined in avkon.hrh in |
|
95 * TAknLogicalFontId enumeration. |
|
96 * |
|
97 * @return The S60 font style id of this text style. |
|
98 */ |
|
99 TInt FontStyleId() const; |
|
100 |
|
101 /** |
|
102 * Sets the S60 font style id for this text style. Alf representation of the text style |
|
103 * stores this attribute for its own reference. Setting font style id here only |
|
104 * sets the font style id in alf private data. Does not set the font style id in |
|
105 * hitchcock core. |
|
106 * Ids are defined in avkon.hrh in TAknLogicalFontId enumeration. |
|
107 * |
|
108 * @param aFontStyleId The S60 font style id. |
|
109 */ |
|
110 void SetFontStyleId(TInt aFontStyleId); |
|
111 |
|
112 /** |
|
113 * Returns the parent id of this text style. Text styles can be cascaded |
|
114 * so that the child text styles use the parameters of their parents unless |
|
115 * the parameters are explicitly overridden in the child. |
|
116 * |
|
117 * @return the parent id of this text style. |
|
118 */ |
|
119 IMPORT_C TInt ParentId() const; |
|
120 |
|
121 /** |
|
122 * Sets the parent style for this text style. The parent style has to be created |
|
123 * through the CAlfTextStyleManager. Parent Id of a preconfigured text style |
|
124 * cannot be changed. |
|
125 * @See TAlfPreconfiguredTextStyle |
|
126 * |
|
127 * @param aParentId the parent style for this text style |
|
128 * @see CAlfTextStyleManager |
|
129 */ |
|
130 IMPORT_C void SetParentId(TInt aParentId); |
|
131 |
|
132 /** |
|
133 * Returns the id of the text style. This id is set by the CAlfTextStyleManager. |
|
134 * |
|
135 * @return The unique id of this text style. |
|
136 */ |
|
137 IMPORT_C TInt Id() const; |
|
138 |
|
139 /** |
|
140 * Returns the text color of this text style. |
|
141 * |
|
142 * @return A TRgb object that represents the color of the text used with this |
|
143 * text style. |
|
144 */ |
|
145 IMPORT_C TRgb TextColor() const; |
|
146 |
|
147 /** |
|
148 * Sets the color of the text rasterized with this style. Text color of a preconfigured |
|
149 * text style cannot be changed. |
|
150 * @See TAlfPreconfiguredTextStyle |
|
151 * |
|
152 * @param aTextColor The color of the text to be set. |
|
153 */ |
|
154 IMPORT_C void SetTextColor(const TRgb& aTextColor); |
|
155 |
|
156 /** |
|
157 * Gets text style text size attribute in twips. |
|
158 * |
|
159 * @param aIsDecoratedSize If true, the decoration size (the area reserved for decoration) |
|
160 * is added to the actual text size. The decoration here means |
|
161 * various effects that can be added to the text, for example a |
|
162 * shadow. |
|
163 * |
|
164 * @return The actual text size in twips plus the decoration size if decorated size |
|
165 * was requested. . |
|
166 */ |
|
167 IMPORT_C TInt TextSizeInTwips(TBool aIsDecoratedSize = EFalse) const; |
|
168 |
|
169 /** |
|
170 * Sets the text size of this style in screen size independent units (twips). Text size |
|
171 * of a preconfigured text style cannot be changed. |
|
172 * @See TAlfPreconfiguredTextStyle |
|
173 * |
|
174 * @param aTextSizeInTwips Size of the text in twips. |
|
175 * @param aIsDecoratedSize If true, the decoration size is subtracted from the text size |
|
176 * to ensure that the rasterized text will fit into the reserved |
|
177 * area including the decoration. The decoration here means various |
|
178 * effects that can be added to the text, for example a shadow . |
|
179 */ |
|
180 IMPORT_C void SetTextSizeInTwips(TInt aTextSizeInTwips, TBool aIsDecoratedSize = EFalse); |
|
181 |
|
182 /** |
|
183 * Gets text style text size attribute in pixels. |
|
184 * |
|
185 * @param aIsDecoratedSize If true, the decoration size (the area reserved for decoration) |
|
186 * is added to the actual text size. The decoration here means |
|
187 * various effects that can be added to the text, for example a |
|
188 * shadow. |
|
189 * |
|
190 * @return The actual text size in pixels plus the decoration size if decorated size |
|
191 * was requested. |
|
192 */ |
|
193 IMPORT_C TInt TextSizeInPixels(TBool aIsDecoratedSize = EFalse) const; |
|
194 |
|
195 /** |
|
196 * Sets the text size of this style in pixels. Text size of a preconfigured |
|
197 * text style cannot be changed. |
|
198 * @See TAlfPreconfiguredTextStyle |
|
199 * |
|
200 * @param aTextSizeInPixels Size of the text in pixels. |
|
201 * @param aIsDecoratedSize If true, the decoration size is subtracted from the text size |
|
202 * to ensure that the rasterized text will fit into the reserved |
|
203 * area including the decoration. The decoration here means various |
|
204 * effects that can be added to the text, for example a shadow . |
|
205 */ |
|
206 IMPORT_C void SetTextSizeInPixels(TInt aTextSizeInPixels, TBool aIsDecoratedSize = EFalse); |
|
207 |
|
208 /** |
|
209 * Indicates whether the text is rasterized in bold or normal. |
|
210 * |
|
211 * @return Boolean indicating whether text is bold or not. |
|
212 */ |
|
213 IMPORT_C TBool IsBold() const; |
|
214 |
|
215 /** |
|
216 * Sets the bold on and off in the text style. Setting bold on and off is |
|
217 * not possible for a preconfigured text style. |
|
218 * @See TAlfPreconfiguredTextStyle |
|
219 * |
|
220 * @param aIsBold True for bold and false normal. |
|
221 */ |
|
222 IMPORT_C void SetBold(TBool aIsBold); |
|
223 |
|
224 /** |
|
225 * Indicates whether the text is rasterized in italic or normal. |
|
226 * |
|
227 * @return Boolean indicating whether text is italic or not. |
|
228 */ |
|
229 IMPORT_C TBool IsItalic() const; |
|
230 |
|
231 /** |
|
232 * Sets the italic on and off in the text style. Setting italic on and off is |
|
233 * not possible for a preconfigured text style. |
|
234 * @See TAlfPreconfiguredTextStyle |
|
235 * |
|
236 * @param aIsItalic True for italic and false for normal. |
|
237 */ |
|
238 IMPORT_C void SetItalic(TBool aIsItalic); |
|
239 |
|
240 /** |
|
241 * Indicates whether the text is underlined or not. |
|
242 * |
|
243 * @return Boolean indicating whether text is underlined. |
|
244 */ |
|
245 IMPORT_C TBool IsUnderline() const; |
|
246 |
|
247 /** |
|
248 * Sets the underlining on and off in the text style. Setting underline on and off is |
|
249 * not possible for a preconfigured text style. |
|
250 * @See TAlfPreconfiguredTextStyle |
|
251 * |
|
252 * @param aIsUnderline True for underlined and false for normal text. |
|
253 */ |
|
254 IMPORT_C void SetUnderline(TBool aIsUnderline); |
|
255 |
|
256 /** |
|
257 * Indicates whether the text is struck through or not. |
|
258 * |
|
259 * @return Boolean indicating whether text has a strike through or not. |
|
260 */ |
|
261 IMPORT_C TBool IsStrikeThrough() const; |
|
262 |
|
263 /** |
|
264 * Sets the strike through on and off in the text style. Setting strike through on |
|
265 * and off is not possible for a preconfigured text style. |
|
266 * @See TAlfPreconfiguredTextStyle |
|
267 * |
|
268 * @param aIsStrikeThrough True for text with strike through and false for normal text. |
|
269 */ |
|
270 IMPORT_C void SetStrikeThrough(TBool aIsStrikeThrough); |
|
271 |
|
272 /** |
|
273 * Gets the typeface in use for the text style. |
|
274 * The typeface may be blank. |
|
275 * |
|
276 * @param on return, contains the typeface information. |
|
277 */ |
|
278 void GetTypeface(TTypeface& aTypeface) const; |
|
279 |
|
280 /** |
|
281 * Gets the typeface in use for the text style. |
|
282 * The typeface may be zero length, but the pointer returned will not be NULL |
|
283 * |
|
284 * @return a descriptor on the heap containing the typeface name, owned by the caller. |
|
285 */ |
|
286 IMPORT_C HBufC* TypefaceNameL() const; |
|
287 |
|
288 /** |
|
289 * Sets the text style text pane height in pixels. |
|
290 * |
|
291 * @note This means that the text size (i.e. the return value from calling @c TextSizeInPixels) |
|
292 * will be in general smaller than the text pane height, as the text pane is intended to match |
|
293 * the font's maximum extent. |
|
294 * @note In order to convert a height from a metric value into pixels, use @c CHuiVisual::LocalToDisplay. |
|
295 * |
|
296 * @param aTextPaneHeight The new text style text pane height in pixels. |
|
297 * @param aIsDecoratedSize If true, the decoration size is subtracted from the text pane height |
|
298 * to ensure that the rasterized text will fit into the reserved area including the |
|
299 * decoration. The decoration here means various effects that can be added to the |
|
300 * text, for example a shadow. |
|
301 */ |
|
302 IMPORT_C void SetTextPaneHeightInPixels(TInt aTextPaneHeight, TBool aIsDecoratedSize = EFalse); |
|
303 |
|
304 /** |
|
305 * Return associated CAlfGenComponent object. |
|
306 */ |
|
307 CAlfGenComponent* Comms() const; |
|
308 |
|
309 /** |
|
310 * Return associated serverside object. |
|
311 */ |
|
312 TInt ServerHandle() const; |
|
313 |
|
314 #ifdef ALF_RASTER_TEXT |
|
315 public: // internal utils |
|
316 |
|
317 THuiFont* Font() const; // returns used font, either own ir parent style |
|
318 THuiFont* OwnFont(); // ensures that style has its own font override and returns that |
|
319 void SetFont(THuiFont* aFont); |
|
320 void ReportChanged(); // propagate changes on mesh (asynch) |
|
321 void RasterizeLineL(const TDesC& aTextLine, CAlfTexture** aTargetTexture); // uploads rasterized texture to scene |
|
322 TSize LineExtentsL(const TDesC& aTextLine); // measures the extents for given text |
|
323 void SetManager(CAlfTextStyleManager* aManager); |
|
324 #endif |
|
325 protected: |
|
326 /** |
|
327 * Constructor. |
|
328 */ |
|
329 CAlfTextStyle(); |
|
330 |
|
331 /** |
|
332 * Second phase constructor. |
|
333 */ |
|
334 void ConstructL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams); |
|
335 |
|
336 private: |
|
337 |
|
338 // Private data. Own. |
|
339 struct TPrivateData; |
|
340 TPrivateData* iData; |
|
341 |
|
342 }; |
|
343 |
|
344 #endif // C_ALFTEXTSTYLE_H |