|
1 /* |
|
2 * Copyright (c) 2007 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: Visualiser class of the button. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_FSCONTROLBUTTONVISUALISER_H |
|
20 #define C_FSCONTROLBUTTONVISUALISER_H |
|
21 |
|
22 #include <gdi.h> |
|
23 //<cmail> SF |
|
24 #include <alf/alfgc.h> |
|
25 #include <alf/alftexturemanager.h> |
|
26 //</cmail> |
|
27 #include "fscontrolbuttonconst.h" |
|
28 |
|
29 class CAlfControl; |
|
30 class CAlfVisual; |
|
31 class CAlfLayout; |
|
32 class CAlfTextVisual; |
|
33 class CAlfGridLayout; |
|
34 class CAlfDeckLayout; |
|
35 class CAlfAnchorLayout; |
|
36 class CAlfImageVisual; |
|
37 class TAlfTextStyle; |
|
38 class TAlfTimedPoint; |
|
39 class CAlfTexture; |
|
40 class CAlfGradientBrush; |
|
41 class CAlfImageBrush; |
|
42 class CFsControlButtonModel; |
|
43 class CFsControlButtonLayoutData; |
|
44 class CFsTextStyleManager; |
|
45 class TCharFormat; |
|
46 |
|
47 /** |
|
48 * Visualiser class of the button. |
|
49 * |
|
50 * @code |
|
51 * |
|
52 * @endcode |
|
53 * |
|
54 * @lib fs_generic.lib |
|
55 */ |
|
56 class CFsControlButtonVisualiser : public CBase, |
|
57 public MAlfTextureLoadingCompletedObserver |
|
58 { |
|
59 |
|
60 public: |
|
61 |
|
62 /** |
|
63 * Two-phased constructor.. |
|
64 */ |
|
65 static CFsControlButtonVisualiser* NewL( |
|
66 CAlfControl& aParent, |
|
67 CAlfDeckLayout& aParentLayout, |
|
68 CFsTextStyleManager* aTextStyleManager ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 IMPORT_C virtual ~CFsControlButtonVisualiser(); |
|
74 |
|
75 /** |
|
76 * Attaches model to visualiser. |
|
77 * |
|
78 * @param aButtonModel button's model. |
|
79 */ |
|
80 IMPORT_C virtual void InitializeL( CFsControlButtonModel& aButtonModel ); |
|
81 |
|
82 /** |
|
83 * Refreshes button on the display. |
|
84 */ |
|
85 IMPORT_C virtual void Refresh(); |
|
86 |
|
87 /** |
|
88 * Refreshes button on the display placing it at specified point. |
|
89 * |
|
90 * @param aStartAt start point of the buton. |
|
91 */ |
|
92 IMPORT_C virtual void Refresh( TPoint aStartAt ); |
|
93 |
|
94 /** |
|
95 * Retrieves end X coordinate of the button. |
|
96 * |
|
97 * @return X coordinate of the bottom right point of the button. |
|
98 */ |
|
99 TInt GetBottomRight() const; |
|
100 |
|
101 /** |
|
102 * Retrieves position of the button. |
|
103 * |
|
104 * @return start point of the button. |
|
105 */ |
|
106 const TAlfTimedPoint Pos() const; |
|
107 |
|
108 /** |
|
109 * Retrieves size of the button. |
|
110 * |
|
111 * @return size of the button. |
|
112 */ |
|
113 const TAlfTimedPoint Size() const; |
|
114 |
|
115 /** |
|
116 * Sets background image of the button. Ownership of the object is transfered. |
|
117 * |
|
118 * @param aImage Image brush that is used at background. |
|
119 */ |
|
120 IMPORT_C virtual void SetBackgroundImageL( CAlfImageBrush* aImage ); |
|
121 |
|
122 /** |
|
123 * Sets button's background color. |
|
124 * |
|
125 * @param aColor background color to be set. |
|
126 */ |
|
127 IMPORT_C virtual void SetBackgroundColor( const TRgb& aColor ); |
|
128 |
|
129 /** |
|
130 * Clears button's background color. Button is transparent. |
|
131 */ |
|
132 IMPORT_C virtual void ClearBackgroundColor(); |
|
133 |
|
134 /** |
|
135 * Clears button's background image. |
|
136 */ |
|
137 IMPORT_C virtual void ClearBackgroundImage(); |
|
138 |
|
139 /** |
|
140 * Sets alignment of element of the button. |
|
141 * |
|
142 * @param aButtonElem element to be aligned. |
|
143 * @param aHAlign horizontal alignement of element. |
|
144 * @param aVAlign vertical alignement of element. |
|
145 */ |
|
146 IMPORT_C virtual void SetElemAlignL( |
|
147 TFsControlButtonElem aButtonElem, |
|
148 TAlfAlignHorizontal aHAlign, |
|
149 TAlfAlignVertical aVAlign ); |
|
150 |
|
151 /** |
|
152 * Set new height for the button text. |
|
153 * Setting a negative or zero value changes the value back to default. |
|
154 * |
|
155 * @param aTextHeight Height in pixels. |
|
156 */ |
|
157 IMPORT_C virtual void SetTextHeight( const TInt aTextHeight ); |
|
158 |
|
159 /** |
|
160 * Change the current font. |
|
161 * |
|
162 * @param aFontSpec Font specification. |
|
163 */ |
|
164 IMPORT_C virtual void SetTextFontL( const TFontSpec& aFontSpec ); |
|
165 |
|
166 /** |
|
167 * Updates element content from the model. |
|
168 * |
|
169 * @param aButtonElem element to be updated. |
|
170 */ |
|
171 IMPORT_C virtual void UpdateElementL( TFsControlButtonElem aButtonElem ); |
|
172 |
|
173 /** |
|
174 * Retrieves width of the button. |
|
175 * |
|
176 * @return width of the button. |
|
177 */ |
|
178 TInt Width() const; |
|
179 |
|
180 /** |
|
181 * Updates size of button. |
|
182 */ |
|
183 IMPORT_C virtual void UpdateButtonSize(); |
|
184 |
|
185 /** |
|
186 * Retrieves the background layout of the button. |
|
187 * |
|
188 * @return Background layout of the button. |
|
189 */ |
|
190 CAlfLayout* Layout(); |
|
191 |
|
192 /** |
|
193 * Retrieves the content layout of the button. |
|
194 * |
|
195 * @return Content layout of the button. |
|
196 */ |
|
197 CAlfLayout* ContentLayout(); |
|
198 |
|
199 /** |
|
200 * Enables button. |
|
201 */ |
|
202 IMPORT_C virtual void ShowL(); |
|
203 |
|
204 /** |
|
205 * Disables button. |
|
206 */ |
|
207 IMPORT_C virtual void Hide(); |
|
208 |
|
209 /** |
|
210 * Checks if button is visible or not. |
|
211 * |
|
212 * @return ETrue if visible, EFalse if hidden. |
|
213 */ |
|
214 TBool IsVisible() const; |
|
215 |
|
216 /** |
|
217 * Sets parent layout. |
|
218 * |
|
219 * @param aParentLayout layout of parent control. |
|
220 */ |
|
221 void SetParentLayoutL( CAlfDeckLayout* aParentLayout ); |
|
222 |
|
223 /** |
|
224 * Sets parent control. |
|
225 * |
|
226 * @param aParentControl parent control. |
|
227 */ |
|
228 void SetParentControlL( CAlfControl* aParentControl ); |
|
229 |
|
230 /** |
|
231 * Assign a new text style manager. |
|
232 * |
|
233 * @param aTextStyleManager New text style manager. |
|
234 */ |
|
235 void SetTextStyleManager( CFsTextStyleManager* aTextStyleManager ); |
|
236 |
|
237 /** |
|
238 * Update elemets after texture loading is completed. |
|
239 * |
|
240 * @param aTexture Reference to the texture that has been loaded. |
|
241 * @param aTextureId Id of the texture in the texture manager. Can be used |
|
242 * to identify the loaded texture, provided that an id was assigned to the |
|
243 * texture. |
|
244 * @param aErrorCode KErrNone if the load was successful, otherwise one of |
|
245 * the system-wide error codes indicating reason why the texture loading |
|
246 * failed. |
|
247 */ |
|
248 IMPORT_C virtual void TextureLoadingCompleted( |
|
249 CAlfTexture& aTexture, TInt aTextureId, TInt aErrorCode ); |
|
250 |
|
251 /** |
|
252 * Enables focus drawing for item and draws it. |
|
253 * NOTE: Do not change focus state. Item might be focused altough |
|
254 * selector is not visible. |
|
255 * @param aShow If ETrue visibility of focus is drawn if |
|
256 * EFalse visibility of focus is hidden. |
|
257 */ |
|
258 void MakeFocusVisible( TBool aShow ); |
|
259 |
|
260 protected: |
|
261 |
|
262 /** |
|
263 * Sets colors and bitmaps for drawing button in "focused" state. |
|
264 */ |
|
265 IMPORT_C virtual void PrepareDrawFocused(); |
|
266 |
|
267 /** |
|
268 * Sets colors and bitmaps for drawing button in "normal |
|
269 * (no focus, enabled)" state. |
|
270 */ |
|
271 IMPORT_C virtual void PrepareDrawNormal(); |
|
272 |
|
273 /** |
|
274 * Sets colors and bitmaps for drawing button in "dimmed" state. |
|
275 */ |
|
276 IMPORT_C virtual void PrepareDrawDimmed(); |
|
277 |
|
278 protected: |
|
279 |
|
280 /** |
|
281 * Constructor. |
|
282 * |
|
283 * @param aParent parent control. |
|
284 * @param aParentLayout layout of parent control. |
|
285 * @param aTextStyleManager Text style manager. |
|
286 */ |
|
287 IMPORT_C CFsControlButtonVisualiser( |
|
288 CAlfControl& aParent, |
|
289 CAlfDeckLayout& aParentLayout, |
|
290 CFsTextStyleManager* aTextStyleManager ); |
|
291 |
|
292 /** |
|
293 * Constructor. |
|
294 */ |
|
295 IMPORT_C CFsControlButtonVisualiser(); |
|
296 |
|
297 /** |
|
298 * Second phase constructor. |
|
299 */ |
|
300 IMPORT_C virtual void ConstructL(); |
|
301 |
|
302 /** |
|
303 * Creates needed visuals for specified button type. |
|
304 */ |
|
305 IMPORT_C virtual void CreateButtonVisualsL(); |
|
306 |
|
307 /** |
|
308 * Calculates button size according to content. |
|
309 * |
|
310 * @return size of button. |
|
311 */ |
|
312 IMPORT_C virtual TInt CalculateButtonSize(); |
|
313 |
|
314 /** |
|
315 * Updates position of button. |
|
316 */ |
|
317 void UpdateButtonPos(); |
|
318 |
|
319 /** |
|
320 * Updates size of columns in grid layouter for button's elements. |
|
321 * |
|
322 * @param aButtonType type of button. |
|
323 */ |
|
324 IMPORT_C virtual void UpdateElementsSizeL( |
|
325 TFsControlButtonType aButtonType ); |
|
326 |
|
327 /** |
|
328 * Sets text styles for specified button type. |
|
329 */ |
|
330 IMPORT_C virtual void UpdateTextStyles(); |
|
331 |
|
332 /** |
|
333 * Sets alignment of specified image of the button. |
|
334 * |
|
335 * @param aImage image to be aligned. |
|
336 * @param aHAlign horizontal alignement of element. |
|
337 * @param aVAlign vertical alignement of element. |
|
338 */ |
|
339 IMPORT_C virtual void SetImageAlign( CAlfImageVisual* aImage, |
|
340 TAlfAlignHorizontal aHAlign, |
|
341 TAlfAlignVertical aVAlign ); |
|
342 |
|
343 /** |
|
344 * Sets alignment of specified text of the button. |
|
345 * |
|
346 * @param aText text to be aligned. |
|
347 * @param aHAlign horizontal alignement of element. |
|
348 * @param aVAlign vertical alignement of element. |
|
349 */ |
|
350 IMPORT_C virtual void SetTextAlign( CAlfTextVisual* aText, |
|
351 TAlfAlignHorizontal aHAlign, |
|
352 TAlfAlignVertical aVAlign ); |
|
353 |
|
354 /** |
|
355 * Updates bar layout. |
|
356 */ |
|
357 void UpdateBarLayout(); |
|
358 |
|
359 /** |
|
360 * Resolve the character format from current text visual. |
|
361 * |
|
362 * @param aCharFormat Place holder for resolved character format. |
|
363 * @param aTextVisual Text visual. |
|
364 */ |
|
365 void ResolveCharFormat( |
|
366 TCharFormat& aCharFormat, |
|
367 CAlfTextVisual* aTextVisual ); |
|
368 |
|
369 protected: // data |
|
370 |
|
371 /** |
|
372 * Parent control. |
|
373 * Not own. |
|
374 */ |
|
375 CAlfControl* iParent; |
|
376 |
|
377 /** |
|
378 * Model of the button. |
|
379 * Not owned. |
|
380 */ |
|
381 CFsControlButtonModel* iButtonModel; |
|
382 |
|
383 /** |
|
384 * Layout of the button control. |
|
385 * Owned (because of possibility to change visualiser - |
|
386 * old one has to be removed from parent and layout tree). |
|
387 */ |
|
388 CAlfLayout* iButtonLayout; |
|
389 |
|
390 /** |
|
391 * Layout for button content. |
|
392 * Not own. |
|
393 */ |
|
394 CAlfLayout* iButtonContentLayout; |
|
395 |
|
396 /** |
|
397 * Visual for first line of text. |
|
398 * Not own. |
|
399 */ |
|
400 CAlfTextVisual* iLabelFirstLine; |
|
401 |
|
402 /** |
|
403 * Visual for second line of text. |
|
404 * Not own. |
|
405 */ |
|
406 CAlfTextVisual* iLabelSecondLine; |
|
407 |
|
408 /** |
|
409 * Height of the button's text in pixels. |
|
410 */ |
|
411 TInt iTextHeight; |
|
412 |
|
413 /** |
|
414 * Font specification. |
|
415 * Owned. |
|
416 */ |
|
417 TFontSpec* iTextFontSpec; |
|
418 |
|
419 /** |
|
420 * Flag to determine if the text size has been changed. |
|
421 */ |
|
422 TBool iTextHeightSet; |
|
423 |
|
424 /** |
|
425 * Visual for the A icon. |
|
426 * Not own. |
|
427 */ |
|
428 CAlfImageVisual* iIconA; |
|
429 |
|
430 /** |
|
431 * Container for icon A. |
|
432 * Not own. |
|
433 */ |
|
434 CAlfLayout* iIconAContainer; |
|
435 |
|
436 /** |
|
437 * Visual for the B icon. |
|
438 * Not own. |
|
439 */ |
|
440 CAlfImageVisual* iIconB; |
|
441 |
|
442 /** |
|
443 * Container for icon B. |
|
444 * Not own. |
|
445 */ |
|
446 CAlfLayout* iIconBContainer; |
|
447 |
|
448 /** |
|
449 * Background color. |
|
450 * Owned. |
|
451 */ |
|
452 CAlfGradientBrush* iBgColorBrush; |
|
453 |
|
454 /** |
|
455 * Brush with background image. |
|
456 * Owned. |
|
457 */ |
|
458 CAlfImageBrush* iBgBrush; |
|
459 |
|
460 /** |
|
461 * Layout of the parent control. |
|
462 * Not owned. |
|
463 */ |
|
464 CAlfDeckLayout* iParentLayout; |
|
465 |
|
466 /** |
|
467 * Flag for recalculate positions of icons. |
|
468 */ |
|
469 TBool iUpdateIconsAlign; |
|
470 |
|
471 /** |
|
472 * First draw. |
|
473 */ |
|
474 TBool iFirstDraw; |
|
475 |
|
476 /** |
|
477 * Horizontal alignement of A icon. |
|
478 */ |
|
479 TAlfAlignHorizontal iAIconHAlign; |
|
480 |
|
481 /** |
|
482 * Vertical alignement of A icon. |
|
483 */ |
|
484 TAlfAlignVertical iAIconVAlign; |
|
485 |
|
486 /** |
|
487 * Horizontal alignement of B icon. |
|
488 */ |
|
489 TAlfAlignHorizontal iBIconHAlign; |
|
490 |
|
491 /** |
|
492 * Vertical alignement of B icon. |
|
493 */ |
|
494 TAlfAlignVertical iBIconVAlign; |
|
495 |
|
496 /** |
|
497 * Flag for visible/hidden state. |
|
498 */ |
|
499 TBool iVisible; |
|
500 |
|
501 /** |
|
502 * Visual for button pane. |
|
503 * Not own. |
|
504 */ |
|
505 CAlfVisual* iButtonPane; |
|
506 |
|
507 /** |
|
508 * Background color. |
|
509 */ |
|
510 TRgb iBackgroundColor; |
|
511 |
|
512 /** |
|
513 * Text style manager. |
|
514 * Not own. |
|
515 */ |
|
516 CFsTextStyleManager* iTextStyleManager; |
|
517 |
|
518 /** |
|
519 * States that can focus been drawn. |
|
520 */ |
|
521 TBool iDrawFocus; |
|
522 |
|
523 }; |
|
524 |
|
525 |
|
526 #endif // C_FSCONTROLBUTTONVISUALISER_H |