|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Interface of normal button and multidisplay button |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CAKNFEPCTRLMULTIMODEBUTTON_H |
|
20 #define C_CAKNFEPCTRLMULTIMODEBUTTON_H |
|
21 |
|
22 // system includes |
|
23 #include <AknsConstants.h> |
|
24 #include <peninputlayoutbasecontrol.h> |
|
25 #include <peninputlayoutbutton.h> |
|
26 //#include <peninputbutton.h> |
|
27 #include <peninputcommonbutton.h> |
|
28 |
|
29 // forward declarations |
|
30 class TResourceReader; |
|
31 |
|
32 struct TAknFepModeIndicator |
|
33 { |
|
34 /** |
|
35 * Range id of button |
|
36 */ |
|
37 TInt iRangeId; |
|
38 |
|
39 /** |
|
40 * Real mode(case) of button |
|
41 */ |
|
42 TInt iModeId; |
|
43 |
|
44 /** |
|
45 * Permitted or not |
|
46 */ |
|
47 TBool iPermitted; |
|
48 }; |
|
49 |
|
50 /** |
|
51 * Basic functionality for multi display modes graphic buttons |
|
52 * It provides creation from resource and can react according to SizeChanged Msg |
|
53 * |
|
54 * @lib fepcommonctrls.lib |
|
55 * @since Series 60 release 4.0 |
|
56 */ |
|
57 class CAknFepCtrlMultiModeButton : public CAknFepCtrlCommonButton |
|
58 { |
|
59 public: |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * |
|
64 * @since S60 v3.2 |
|
65 * @param aUiLayout An instance of CFepUiLayout |
|
66 * @param aControlId The control id of input range button |
|
67 * @return The pointer point to CAknFepCtrlMultiModeButton type object |
|
68 */ |
|
69 IMPORT_C static CAknFepCtrlMultiModeButton* NewL(CFepUiLayout* aUiLayout, TInt aControlId, |
|
70 TAknsItemID aNormalID = KAknsIIDQsnFrFunctionButtonNormal, |
|
71 TAknsItemID aPressedID = KAknsIIDQsnFrFunctionButtonPressed, |
|
72 TAknsItemID aInactiveID = KAknsIIDQsnFrFunctionButtonInactive); |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 * |
|
77 * @since S60 v3.2 |
|
78 * @param aUiLayout An instance of CFepUiLayout |
|
79 * @param aControlId The control id of input range button |
|
80 * @return The pointer point to CAknFepCtrlMultiModeButton type object |
|
81 */ |
|
82 IMPORT_C static CAknFepCtrlMultiModeButton* NewLC(CFepUiLayout* aUiLayout, TInt aControlId, |
|
83 TAknsItemID aNormalID = KAknsIIDQsnFrFunctionButtonNormal, |
|
84 TAknsItemID aPressedID = KAknsIIDQsnFrFunctionButtonPressed, |
|
85 TAknsItemID aInactiveID = KAknsIIDQsnFrFunctionButtonInactive); |
|
86 |
|
87 /** |
|
88 * Destructor. |
|
89 * |
|
90 * @since S60 v3.2 |
|
91 */ |
|
92 IMPORT_C virtual ~CAknFepCtrlMultiModeButton(); |
|
93 |
|
94 /** |
|
95 * This function creates the button from resource. |
|
96 * The function will leave if the count of display modes is invalid |
|
97 * |
|
98 * @since S60 v3.2 |
|
99 * @param aReader A Reader which is created against the AKN_FEP_MULTIPLE_IMAGE_BUTTON resource type |
|
100 * @return None |
|
101 */ |
|
102 IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); |
|
103 |
|
104 /** |
|
105 * This function creates button from resource, before calling |
|
106 * this function, caller should set resource id of button first |
|
107 * |
|
108 * @since S60 v3.2 |
|
109 * @return None |
|
110 */ |
|
111 IMPORT_C void ConstructFromResourceL(); |
|
112 |
|
113 /** |
|
114 * Add new display mode to button from resource reader |
|
115 * |
|
116 * @since S60 v3.2 |
|
117 * @param aReader A Reader which is created against the AKN_FEP_BUTTON_IMAGE resource type |
|
118 * @return None |
|
119 */ |
|
120 IMPORT_C void AddModeL(TResourceReader& aReader); |
|
121 |
|
122 /** |
|
123 * Set button to given display mode |
|
124 * |
|
125 * @since S60 v3.2 |
|
126 * @param aType The image type of button, active or nonactive |
|
127 * @param aModeIndex The index of given display mode |
|
128 * @return None |
|
129 */ |
|
130 IMPORT_C void SetCurrentModeL(const TButtonBmpType aType, const TInt aModeIndex); |
|
131 |
|
132 /** |
|
133 * Get the mode index of next display mode |
|
134 * |
|
135 * @since S60 v3.2 |
|
136 * @return Next display mode of button |
|
137 */ |
|
138 IMPORT_C TInt NextMode() const; |
|
139 |
|
140 /** |
|
141 * Set font color for text shown in button |
|
142 * |
|
143 * @since S60 v3.2 |
|
144 * @return None |
|
145 */ |
|
146 IMPORT_C void SetFontColor(const TRgb aFontColor); |
|
147 |
|
148 /** |
|
149 * Set shadow font color for text shown in button |
|
150 * |
|
151 * @since S60 v3.2 |
|
152 * @return None |
|
153 */ |
|
154 IMPORT_C void SetShadowFontColor(const TRgb aShadowFontColor); |
|
155 |
|
156 /** |
|
157 * This function handles the SizeChanged event, it resizes all images and rects |
|
158 * |
|
159 * @since S60 v3.2 |
|
160 * @param aRect New button extent |
|
161 * @param aIsReloadImages Whether resize images as well, |
|
162 * if only the position of the button changed, no need to reset the images as well |
|
163 * @return Nothing |
|
164 */ |
|
165 IMPORT_C void SizeChanged(TRect aRect, TRect aInnerRect = TRect(), |
|
166 TBool aIsReloadImages = EFalse); |
|
167 |
|
168 /** |
|
169 * This function used to set permitted mode(case) in given range |
|
170 * |
|
171 * @since S60 v3.2 |
|
172 * @param aRangId Range id |
|
173 * @param aRealCaseId The real case id |
|
174 * @param aPermit ETrue means permit given range and case, otherwise EFalse |
|
175 * @return KErrNone if operation successfully, KErrNotSupported otherwise |
|
176 */ |
|
177 IMPORT_C TInt SetPermittedModes(const TInt aRangeId, const TInt aRealCaseId, TBool aPermit); |
|
178 |
|
179 /** |
|
180 * This function used to set permitted range, all case in given range will be enable or not |
|
181 * |
|
182 * @since S60 v3.2 |
|
183 * @param aRangId Range id |
|
184 * @param aPermit ETrue means permit given range, otherwise EFalse |
|
185 * @return KErrNone if operation successfully, KErrNotSupported otherwise |
|
186 */ |
|
187 IMPORT_C TInt SetPermittedRange(const TInt aRangeId, TBool aPermit); |
|
188 |
|
189 /** |
|
190 * Enable all modes |
|
191 * |
|
192 * @since S60 v3.2 |
|
193 * @return None |
|
194 */ |
|
195 IMPORT_C void EnableAllModes(); |
|
196 |
|
197 /** |
|
198 * Disable all modes |
|
199 * |
|
200 * @since S60 v3.2 |
|
201 * @return None |
|
202 */ |
|
203 IMPORT_C void DisableAllModes(); |
|
204 |
|
205 IMPORT_C void DisableOneModes(const TInt aRangeId); |
|
206 |
|
207 /** |
|
208 * Judge if given range supported by this button |
|
209 * |
|
210 * @since S60 v3.2 |
|
211 * @param aRange Given range id |
|
212 * @return ETrue if given range supported, otherwise EFalse |
|
213 */ |
|
214 IMPORT_C TBool IsGivenRangeSupported(const TInt aRange); |
|
215 |
|
216 /** |
|
217 * Set range |
|
218 * |
|
219 * @since S60 v3.2 |
|
220 * @param aRange The given range |
|
221 * @return KErrNone if operation successfully, otherwise KErrNotSupported |
|
222 */ |
|
223 IMPORT_C TInt SetRange(const TInt aRange); |
|
224 |
|
225 /** |
|
226 * Get current active range |
|
227 * |
|
228 * @since S60 v3.2 |
|
229 * @return Current active range if it is permitted, otherwise KErrNotSupported |
|
230 */ |
|
231 IMPORT_C TInt CurrentRange() const; |
|
232 |
|
233 /** |
|
234 * Get range of given mode index |
|
235 * |
|
236 * @since S60 v3.2 |
|
237 * @param aModeIndex Index of given mode |
|
238 * @return Range of given mode if mode exist, otherwise KErrNotSupported |
|
239 */ |
|
240 IMPORT_C TInt RangeOfGivenMode(TInt aModeIndex) const; |
|
241 |
|
242 /** |
|
243 * Get real case by given mode index |
|
244 * |
|
245 * @since S60 v3.2 |
|
246 * @param aModeIndex Index of given mode |
|
247 * @return Real case of given mode index if index valid, otherwise KErrNotFound |
|
248 */ |
|
249 IMPORT_C TInt GetRealCaseByMode(TInt aModeIndex) const; |
|
250 |
|
251 /** |
|
252 * Get range list |
|
253 * |
|
254 * @since S60 v3.2 |
|
255 * @param aList Carry the range list on return |
|
256 * @return None |
|
257 */ |
|
258 void GetRangeListL(RArray<TInt>& aList); |
|
259 |
|
260 /** |
|
261 * Get index of current display mode |
|
262 * |
|
263 * @since S60 v3.2 |
|
264 * @return Index of current display mode of button |
|
265 */ |
|
266 inline TInt CurrentMode() const; |
|
267 |
|
268 /** |
|
269 * Get counts of display modes |
|
270 * |
|
271 * @since S60 v3.2 |
|
272 * @return Counts of display modes of button |
|
273 */ |
|
274 inline TInt NumberOfModes() const; |
|
275 |
|
276 /** |
|
277 * Set font for text shown in button |
|
278 * |
|
279 * @since S60 v3.2 |
|
280 * @param aFont The font to be set for button |
|
281 * @return None |
|
282 */ |
|
283 inline void SetFont(const CFont* aFont); |
|
284 |
|
285 /** |
|
286 * Set font for text shown in button |
|
287 * |
|
288 * @since S60 v3.2 |
|
289 * @param aShadowFont The font to be set for shadow text on button |
|
290 * @return None |
|
291 */ |
|
292 inline void SetShadowFont(const CFont* aShadowFont); |
|
293 |
|
294 protected: |
|
295 |
|
296 /** |
|
297 * C++ default constructor. |
|
298 */ |
|
299 IMPORT_C CAknFepCtrlMultiModeButton(CFepUiLayout* aUiLayout, |
|
300 TInt aControlId, |
|
301 TAknsItemID aNormalID = KAknsIIDQsnFrFunctionButtonNormal, |
|
302 TAknsItemID aPressedID = KAknsIIDQsnFrFunctionButtonPressed, |
|
303 TAknsItemID aInactiveID = KAknsIIDQsnFrFunctionButtonInactive); |
|
304 |
|
305 /** |
|
306 * Judge if image resource of button already exist |
|
307 * |
|
308 * @since S60 v3.2 |
|
309 * @param aResId The image resource id |
|
310 * @return ETrue if image resource already exist, EFalse otherwise |
|
311 */ |
|
312 IMPORT_C TBool ImageAlreadyExist(const TInt32 aResId); |
|
313 |
|
314 /** |
|
315 * Set bitmaps for button according to desired display mode |
|
316 * |
|
317 * @since S60 v3.2 |
|
318 * @param aType The image type for button, can be active or nonactive etc. |
|
319 * @param aMode The desired display mode index |
|
320 * @return None |
|
321 */ |
|
322 IMPORT_C void SetButtonBmpL(const TButtonBmpType aType , const TInt aMode); |
|
323 |
|
324 /** |
|
325 * Display text for button according to current display mode |
|
326 * |
|
327 * @since S60 v3.2 |
|
328 * @return None |
|
329 */ |
|
330 IMPORT_C void DisplayText(); |
|
331 |
|
332 /** |
|
333 * Draws UI |
|
334 * |
|
335 * @since S60 v3.2 |
|
336 * @return None |
|
337 */ |
|
338 IMPORT_C void Draw(); |
|
339 |
|
340 void ResizeBitmaps(TSize aSize); |
|
341 |
|
342 private: |
|
343 |
|
344 /** |
|
345 * Duplicate bitmap |
|
346 * |
|
347 * @since S60 v3.2 |
|
348 * @param aSourceBmp The source bitmap |
|
349 * @return Pointer to created bitmap |
|
350 */ |
|
351 CFbsBitmap* DuplicateBitmapL(CFbsBitmap* aSourceBmp); |
|
352 |
|
353 /** |
|
354 * Transfer bitmap ownship from multimode button to outside. |
|
355 * |
|
356 * @since S60 v3.2 |
|
357 * @param aRemoved The bitmap to be transfered |
|
358 * @return None |
|
359 */ |
|
360 void TransferOwnership(CFbsBitmap* aRemoved); |
|
361 |
|
362 private: // data |
|
363 /** |
|
364 * Array of foreground bitmaps in different modes |
|
365 */ |
|
366 RPointerArray<CFbsBitmap> iForegroundBmpList; |
|
367 /** |
|
368 * Array of foreground mask bitmaps in different modes |
|
369 */ |
|
370 RPointerArray<CFbsBitmap> iForegroundMaskBmpList; |
|
371 /** |
|
372 * Froground bitmap's position |
|
373 */ |
|
374 TRect iForgroundBmpRect; |
|
375 |
|
376 |
|
377 /** |
|
378 * Array of image resource Id list |
|
379 */ |
|
380 RArray<TInt32> iImageResIdList; |
|
381 |
|
382 /** |
|
383 * The index of current display mode |
|
384 */ |
|
385 TInt iCurrentMode; |
|
386 |
|
387 /** |
|
388 * The counts of display modes of button |
|
389 */ |
|
390 TInt iNumberOfModes; |
|
391 |
|
392 /** |
|
393 * Font of text shown in button |
|
394 */ |
|
395 const CFont* iFont; |
|
396 |
|
397 /** |
|
398 * Font of shadow text shown in button |
|
399 */ |
|
400 const CFont* iShadowFont; |
|
401 |
|
402 /** |
|
403 * Font color of text shown in button |
|
404 */ |
|
405 TRgb iFontColor; |
|
406 |
|
407 /** |
|
408 * Shadow Font color of text shown in button |
|
409 */ |
|
410 TRgb iShadowFontColor; |
|
411 |
|
412 /** |
|
413 * Array of text shown on button |
|
414 */ |
|
415 RPointerArray<HBufC> iModeTextList; |
|
416 |
|
417 /** |
|
418 * Array of owned bitmap |
|
419 */ |
|
420 //RPointerArray<CFbsBitmap> iOwnedBitmaps; |
|
421 |
|
422 /** |
|
423 * Array of modes |
|
424 */ |
|
425 RPointerArray<TAknFepModeIndicator> iModesList; |
|
426 |
|
427 /** |
|
428 * Current bitmap type, active or nonactive |
|
429 */ |
|
430 TButtonBmpType iCurrentBmpType; |
|
431 }; |
|
432 |
|
433 #include "peninputmultimodebutton.inl" |
|
434 |
|
435 #endif // C_CAKNFEPCTRLMULTIMODEBUTTON_H |
|
436 |
|
437 // End Of File |