|
1 /* |
|
2 * Copyright (c) 2003-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: CMIDChoiceGroupElement encapsulates a ChoiceGroup |
|
15 * listbox entry (text, image, selection state and all) |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CMIDCHOICEGROUPELEMENT_H |
|
21 #define CMIDCHOICEGROUPELEMENT_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> // e32def, e32std |
|
25 // using CGulIcon API in several places related to choice group |
|
26 // and for iIcon memeber |
|
27 #include <gulicon.h> |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // Element flags |
|
34 #define CGEF_SELECTED 0x01 |
|
35 #define CGEF_OWNSICON 0x02 |
|
36 |
|
37 |
|
38 // DATA TYPES |
|
39 |
|
40 // EXTERNAL DATA STRUCTURES |
|
41 |
|
42 // FUNCTION PROTOTYPES |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 |
|
46 // CLASS DEFINITIONS |
|
47 NONSHARABLE_CLASS(CMIDChoiceGroupElement) : public CBase |
|
48 { |
|
49 public: |
|
50 static CMIDChoiceGroupElement* NewL(); |
|
51 |
|
52 // Destructor |
|
53 virtual ~CMIDChoiceGroupElement(); |
|
54 |
|
55 // Set element text |
|
56 void SetTextL(const TDesC& aText); |
|
57 |
|
58 // Get element text |
|
59 const TPtrC Text() const |
|
60 { |
|
61 return iText ? iText->Des() : TPtrC(KNullDesC); |
|
62 } |
|
63 |
|
64 // Get listbox line ("<i>\t<j>\tText"), where i is an index to |
|
65 // the selection icon and j to the element image (given as param) |
|
66 const TPtrC LboxText(TInt aImageIndex); |
|
67 |
|
68 // Set icon. If owned, an icon is deleted by the element |
|
69 void SetIcon(CGulIcon* aIcon, TBool aElementOwnsIcon = ETrue); |
|
70 |
|
71 // Set icon from bitmaps. If owned, an icon is deleted by the element |
|
72 void SetIconL( |
|
73 CFbsBitmap& aBitmap, |
|
74 CFbsBitmap* aMask = NULL, |
|
75 TBool aElementOwnsIcon = ETrue); |
|
76 |
|
77 // Get icon |
|
78 CGulIcon* Icon() const |
|
79 { |
|
80 return iIcon; |
|
81 } |
|
82 |
|
83 // Set element to be selected (preserve original flags) |
|
84 void SetSelected(TBool aSelected = ETrue) |
|
85 { |
|
86 aSelected ? (iFlags |= CGEF_SELECTED) : (iFlags &= ~CGEF_SELECTED); |
|
87 } |
|
88 |
|
89 // Element selection state query method |
|
90 TBool IsSelected() const |
|
91 { |
|
92 return (iFlags & CGEF_SELECTED); |
|
93 } |
|
94 |
|
95 // Get flags |
|
96 TInt Flags() const |
|
97 { |
|
98 return iFlags; |
|
99 } |
|
100 |
|
101 protected: |
|
102 |
|
103 private: |
|
104 CMIDChoiceGroupElement(); |
|
105 private: |
|
106 |
|
107 // Type flags |
|
108 TInt iFlags; |
|
109 |
|
110 // Element text |
|
111 HBufC* iText; |
|
112 |
|
113 // Listbox line |
|
114 HBufC* iLboxText; |
|
115 |
|
116 // Icon |
|
117 CGulIcon* iIcon; |
|
118 |
|
119 }; |
|
120 |
|
121 #endif // CMIDCHOICEGROUPELEMENT_H |
|
122 |