|
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: radio button - control in Training UI application |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_TRUIAPPRADIOBUTTON_H |
|
20 #define C_TRUIAPPRADIOBUTTON_H |
|
21 |
|
22 // includes |
|
23 #include <coecntrl.h> |
|
24 |
|
25 // Class declaration |
|
26 class MTruiRadioButtonObserver; |
|
27 |
|
28 /** |
|
29 * CTruiRadioButton is a new component for selecting own/preset model |
|
30 * in shortcut edit view. |
|
31 * @lib avkon.lib |
|
32 */ |
|
33 |
|
34 class CTruiRadioButton: public CCoeControl, public MCoeControlObserver |
|
35 { |
|
36 public: |
|
37 /* Flags for radion button status. */ |
|
38 enum TRadioButtonStatus |
|
39 { |
|
40 ENonSelected = 0, |
|
41 ESelected |
|
42 }; |
|
43 |
|
44 /* Flags for button type. */ |
|
45 enum TSelectionType |
|
46 { |
|
47 ERadioButton = 0, |
|
48 ECheckBox |
|
49 }; |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * @param aParent the parent control for choice list |
|
54 * @param aTextArray the items' text that will be displayed in radion button. |
|
55 * @param aStatusArray the selected status for each radio button. |
|
56 * @param aSelectionType The type of the selection type, radio or checkbox |
|
57 * @return Pointer to CTruiRadioButton's instance |
|
58 */ |
|
59 static CTruiRadioButton* NewL( CCoeControl* aParent, |
|
60 TSelectionType aSelectionType, |
|
61 MTruiRadioButtonObserver* aObserver = NULL ); |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 * @param aParent the parent control for choice list |
|
66 * @param aTextArray the items' text that will be displayed in radion button. |
|
67 * @param aStatusArray The selected status for each radio button. |
|
68 * @param aSelectionType The type of the selection type, radio or checkbox |
|
69 * @return Pointer to CTruiRadioButton's instance |
|
70 */ |
|
71 static CTruiRadioButton* NewLC( CCoeControl* aParent, |
|
72 TSelectionType aSelectionType, |
|
73 MTruiRadioButtonObserver* aObserver = NULL ); |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 ~CTruiRadioButton(); |
|
78 |
|
79 /** |
|
80 * Convert texts into Label and update them in radio buttons |
|
81 */ |
|
82 void HandleItemAdditionL(); |
|
83 |
|
84 /** |
|
85 * Add one item to radio button |
|
86 * @param aText The text of the radio button. |
|
87 * @param aStatus The current selected status of the radio button |
|
88 */ |
|
89 void AddItem( const HBufC* aText, TRadioButtonStatus aStatus ); |
|
90 |
|
91 /** |
|
92 * Return the status array |
|
93 */ |
|
94 inline const RArray<TRadioButtonStatus>& StatusArray() const |
|
95 { |
|
96 return iStatusArray; |
|
97 }; |
|
98 |
|
99 /** |
|
100 * Handle pointer on radio button |
|
101 * |
|
102 * @param aIndex The index of the button group item. |
|
103 * @param aEventType The event type. |
|
104 */ |
|
105 void HandlePointerRadioButtonL( TInt aIndex, TCoeEvent aEventType ); |
|
106 |
|
107 /** |
|
108 * Handle pointer on checkbox |
|
109 * |
|
110 * @param aIndex The index of the button group item. |
|
111 * @param aEventType The event type. |
|
112 */ |
|
113 void HandlePointerCheckBox( TInt aIndex, TCoeEvent aEventType ); |
|
114 |
|
115 inline void SetMultilineLayout( const TAknMultiLineTextLayout& aMultilineLayout ) |
|
116 { |
|
117 iMultilineLayout = aMultilineLayout; |
|
118 }; |
|
119 |
|
120 // from CCoeControl |
|
121 /** |
|
122 * Return the control's minisize. |
|
123 */ |
|
124 TSize MinimumSize(); |
|
125 |
|
126 private: |
|
127 |
|
128 /** |
|
129 * C++ Default Constructor |
|
130 */ |
|
131 CTruiRadioButton( MTruiRadioButtonObserver* aObserver, |
|
132 TSelectionType aSelectionType ); |
|
133 |
|
134 /** |
|
135 * 2nd phase constructor |
|
136 * @param aParent the parent control for choice list |
|
137 * @param aTextArray the items' text that will be displayed in radion button. |
|
138 * @param aStatusArray the selected status for each radio button. |
|
139 */ |
|
140 void ConstructL( CCoeControl* aParent ); |
|
141 |
|
142 /** |
|
143 * Create radio button's bitmap. |
|
144 */ |
|
145 void CreateBitmapForRadioButtonL(); |
|
146 |
|
147 /** |
|
148 * Get cached color of skin for label control |
|
149 * |
|
150 * @param aColor The color of Label will be set |
|
151 */ |
|
152 TInt GetCachedLabelTextColor( TRgb& aColor ); |
|
153 |
|
154 /** |
|
155 * Load layouts for icons from LAF. |
|
156 * |
|
157 * @param aVarity Varity for LAF |
|
158 */ |
|
159 void LoadIconsLayout( TInt aVarity ); |
|
160 |
|
161 /** |
|
162 * Convert logical name to visual name for label when needed. |
|
163 * |
|
164 * @param aLabel The label is used to show text |
|
165 * @param aLogicalTxt The logical text which is needed to be converted. |
|
166 * @param aFont The font of label text |
|
167 * @param aLineWidth The line width of each text of label |
|
168 */ |
|
169 void ConvertToVisualForEdwinL( CEikLabel* aLabel, const TDesC& aLogicalTxt, |
|
170 const CFont& aFont, TInt aLineWidth ); |
|
171 |
|
172 /** |
|
173 * Clip text of label to fit label width. |
|
174 * |
|
175 * @param aLabel The label is used to show text |
|
176 * @param aIndex The index of text in text array |
|
177 */ |
|
178 void ClipToFitLabelL( CEikLabel* aLabel, TInt aIndex ); |
|
179 |
|
180 // from MCoeControlObserver |
|
181 /** |
|
182 * From MCoeControlObserver. Handles an event from an observed control. |
|
183 * @param aControl The control that sent the event. |
|
184 * @param aEventType The event type. |
|
185 */ |
|
186 void HandleControlEventL( CCoeControl* aControl,TCoeEvent aEventType ); |
|
187 |
|
188 // from CCoeControl |
|
189 /** |
|
190 * Responds to changes to the size and position of the contents of this control. |
|
191 */ |
|
192 void SizeChanged(); |
|
193 |
|
194 /** |
|
195 * Draws control to given area |
|
196 * @param aRect The rectangle that should be drawn by the control. |
|
197 */ |
|
198 void Draw( const TRect& aRect ) const; |
|
199 |
|
200 /** |
|
201 * Gets the number of controls contained in a compound control. |
|
202 * @return The number of component controls contained by this control. |
|
203 */ |
|
204 TInt CountComponentControls() const; |
|
205 |
|
206 /** |
|
207 * Gets an indexed component of a compound control. |
|
208 * @param aIndex The index of the control. |
|
209 * @return The component control with an index of aIndex. |
|
210 */ |
|
211 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
212 |
|
213 /** |
|
214 * Gets an indexed component of a compound control. |
|
215 * @param aIndex The index of the control. |
|
216 * @return The component control with an index of aIndex. |
|
217 */ |
|
218 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
219 |
|
220 /** |
|
221 * From CoeControl. |
|
222 * Handles a change to the control's resources. |
|
223 * |
|
224 * @param aType A message UID value. |
|
225 */ |
|
226 void HandleResourceChange( TInt aType ); |
|
227 |
|
228 private: // data |
|
229 |
|
230 /** |
|
231 * The control array store all sub-controls |
|
232 * Own |
|
233 */ |
|
234 CArrayPtrFlat<CCoeControl>* iControlArray; |
|
235 |
|
236 /** |
|
237 * The array to store the current status for each radio button |
|
238 * Own |
|
239 */ |
|
240 RArray<TRadioButtonStatus> iStatusArray; |
|
241 |
|
242 /** |
|
243 * The text array to store the text for each radio button |
|
244 * Own |
|
245 */ |
|
246 RPointerArray<HBufC> iTextArray; |
|
247 |
|
248 /** |
|
249 * The bitmap for selected radio button. |
|
250 * Own |
|
251 */ |
|
252 CFbsBitmap* iRadioButtonSelectedBmp; |
|
253 |
|
254 /** |
|
255 * The bitmap mask for selected radio button. |
|
256 * Own |
|
257 */ |
|
258 CFbsBitmap* iRadioButtonSelectedBmpm; |
|
259 |
|
260 /** |
|
261 * The bitmap for non-selected radio button. |
|
262 * Own |
|
263 */ |
|
264 CFbsBitmap* iRadioButtonNonSelectedBmp; |
|
265 |
|
266 /** |
|
267 * The bitmap mask for non-selected radio button. |
|
268 * Own |
|
269 */ |
|
270 CFbsBitmap* iRadioButtonNonSelectedBmpm; |
|
271 |
|
272 /** |
|
273 * The observer used to notify the current selected item changed |
|
274 * Not own |
|
275 */ |
|
276 MTruiRadioButtonObserver* iObserver; |
|
277 |
|
278 /** |
|
279 * The observer used to notify the current selected item changed |
|
280 * Not own |
|
281 */ |
|
282 TSelectionType iSelectionType; |
|
283 |
|
284 /** |
|
285 * Array to store TAknLayoutRect for icons |
|
286 * |
|
287 * Own |
|
288 */ |
|
289 RArray<TAknLayoutRect> iIconLayout; |
|
290 |
|
291 TBool iTactileSupported; |
|
292 |
|
293 /** |
|
294 * MultilineLayout for edwin |
|
295 * |
|
296 */ |
|
297 TAknMultiLineTextLayout iMultilineLayout; |
|
298 }; |
|
299 |
|
300 #endif // C_TRUIAPPRADIOBUTTON_H |
|
301 |