|
1 /* |
|
2 * Copyright (c) 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: Contains the implementation of response area item |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CESMRRESPONSEITEM_H |
|
19 #define CESMRRESPONSEITEM_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <coecntrl.h> |
|
23 #include "esmrcommands.h" |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class CMRLabel; |
|
27 class CMRImage; |
|
28 |
|
29 // CLASS DECLARATIONS |
|
30 /** |
|
31 * Response area contains four response items. One item contains icon and text, |
|
32 * (e.g. unchecked icon and "Accept" as a text) except the first topic line that |
|
33 * doesn't have the icon. Topic item might have text in two lines depending on |
|
34 * the text length and screen orientation. Item is highlighted by drawing svg graphic |
|
35 * to the background. Only highlighted item can be selected by pressing "OK" key. |
|
36 */ |
|
37 NONSHARABLE_CLASS( CESMRResponseItem ) : public CCoeControl |
|
38 { |
|
39 public: |
|
40 static CESMRResponseItem* NewL( TESMRCommand aCmd, |
|
41 const TDesC& aItemText, |
|
42 TBool aHasIcon ); |
|
43 static CESMRResponseItem* NewLC( TESMRCommand aCmd, |
|
44 const TDesC& aItemText, |
|
45 TBool aHasIcon ); |
|
46 ~CESMRResponseItem(); |
|
47 |
|
48 public: // From CCoeControl |
|
49 TInt CountComponentControls() const; |
|
50 CCoeControl* ComponentControl( TInt aInd ) const; |
|
51 void SizeChanged(); |
|
52 void SetContainerWindowL( const CCoeControl& aContainer ); |
|
53 |
|
54 public: // New methods |
|
55 /** |
|
56 * Sets the highlight item on. |
|
57 */ |
|
58 void SetHighlight(); |
|
59 |
|
60 /** |
|
61 * Sets the highlight item off. |
|
62 */ |
|
63 void RemoveHighlight(); |
|
64 /** |
|
65 * Changes the icon from checked to unchecked or vice versa |
|
66 * depending on the parameter. |
|
67 * |
|
68 * @param aChecked - ETrue draws the checked icon |
|
69 * EFalse draws the unchecked icon |
|
70 */ |
|
71 |
|
72 void ChangeIconL( TBool aChecked ); |
|
73 /** |
|
74 * Sets font for the text in this item |
|
75 * |
|
76 * @param Font to be set |
|
77 */ |
|
78 void SetFont( const CFont* aFont ); |
|
79 |
|
80 /** |
|
81 * Sets text for this item. When called for the first time |
|
82 * text is captured and that text is always wrappen again when |
|
83 * calling this method. This is done because orientation of |
|
84 * the screen might change. |
|
85 * |
|
86 * @param Text for the item |
|
87 */ |
|
88 void SetTextL( const TDesC& aItemText ); |
|
89 |
|
90 /** |
|
91 * Sets response topic text to Response label. Setting text is done |
|
92 * in two phases (SetTextL and SetTextToLabelL), so that correct Rect |
|
93 * has been set before trying to wrap the text into Label. |
|
94 */ |
|
95 void SetTextToLabelL(); |
|
96 |
|
97 /** |
|
98 * Counts the number of lines that item needs for the text. |
|
99 * This is called to give enough space for the item. |
|
100 * |
|
101 * @return Number of text lines. |
|
102 */ |
|
103 TInt ItemTextLineCount(); |
|
104 |
|
105 /** |
|
106 * Returns the command id attached to this item. |
|
107 * |
|
108 * @return A command id |
|
109 */ |
|
110 TESMRCommand CommandId() const; |
|
111 |
|
112 /** |
|
113 * Set the label underlined. |
|
114 * |
|
115 * @param set underline true or false. |
|
116 * @return void |
|
117 */ |
|
118 void SetUnderlineL( TBool aUndreline ); |
|
119 |
|
120 private: // Implementation |
|
121 CMRImage* IconL(TBool aChecked ); |
|
122 void Draw( const TRect& aRect ) const; |
|
123 |
|
124 private: // private construction |
|
125 CESMRResponseItem(TESMRCommand aCmd); |
|
126 void ConstructL( const TDesC& aItemText, TBool aHasIcon ); |
|
127 |
|
128 private: // data |
|
129 /// Own: Label for item's text |
|
130 CMRLabel* iSelectionLabel; |
|
131 /// Own: Checkbox icon |
|
132 CMRImage* iIcon; |
|
133 /// Own: Items text |
|
134 HBufC* iItemText; |
|
135 /// Item's command id |
|
136 TESMRCommand iCmd; |
|
137 /// Flag for the item highlight status |
|
138 TBool iHighlighted; |
|
139 /// Flag for telling whether the item needs the icon |
|
140 TBool iHasIcon; |
|
141 /// Original text length |
|
142 TInt iOriginalTextLength; |
|
143 }; |
|
144 |
|
145 #endif // CESMRRESPONSEITEM_H |
|
146 |
|
147 // End of file |