|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "BrowserSelectElementItemDrawer.h" |
|
22 #include "BrowserSelectElementModel.h" |
|
23 #include "BrCtlDialogsProvider.h" |
|
24 |
|
25 #include <gulicon.h> |
|
26 #include <AknIconArray.h> |
|
27 #include <AknsUtils.h> |
|
28 |
|
29 #include <data_caging_path_literals.hrh> |
|
30 |
|
31 // CONSTANTS |
|
32 #include "BrowserDialogsProviderConstants.h" |
|
33 |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ========================================= |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CBrowserSelectElementItemDrawer::CBrowserSelectElementItemDrawer |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 CBrowserSelectElementItemDrawer::CBrowserSelectElementItemDrawer( |
|
42 MTextListBoxModel& aTextListBoxModel, |
|
43 const CFont& aFont, |
|
44 CFormattedCellListBoxData& aFormattedCellData, |
|
45 TBrCtlSelectOptionType aBrCtlSelectOptionType, |
|
46 const CArrayFix<TBrCtlSelectOptionData>& aOptions ) |
|
47 : |
|
48 CFormattedCellListBoxItemDrawer( &aTextListBoxModel, |
|
49 &aFont, |
|
50 &aFormattedCellData ), |
|
51 iOptions( aOptions ), |
|
52 iBrCtlSelectOptionType( aBrCtlSelectOptionType ) |
|
53 { |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CBrowserSelectElementItemDrawer::LoadIconsL |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 void CBrowserSelectElementItemDrawer::LoadIconsL() |
|
61 { |
|
62 TInt selected; |
|
63 TInt selectedm; |
|
64 TInt deselected; |
|
65 TInt deselectedm; |
|
66 CGulIcon* newIcon; |
|
67 CGulIcon* icon; |
|
68 CFbsBitmap *newIconBmp; |
|
69 CFbsBitmap *newIconMaskBmp; |
|
70 TAknsItemID selectOn(KAknsIIDQgnPropCheckboxOn); |
|
71 TAknsItemID selectOff(KAknsIIDQgnPropCheckboxOff); |
|
72 |
|
73 // selected option |
|
74 CArrayPtrFlat<CGulIcon>* icons = |
|
75 new ( ELeave ) CAknIconArray( KGranularityMedium ); |
|
76 CleanupStack::PushL( icons ); |
|
77 |
|
78 if ( iBrCtlSelectOptionType != ESelectTypeMultiple ) |
|
79 { |
|
80 selected = EMbmAvkonQgn_prop_radiobutt_on; |
|
81 selectedm = EMbmAvkonQgn_prop_radiobutt_on_mask; |
|
82 deselected = EMbmAvkonQgn_prop_radiobutt_off; |
|
83 deselectedm = EMbmAvkonQgn_prop_radiobutt_off_mask; |
|
84 selectOn = KAknsIIDQgnPropRadiobuttOn; |
|
85 selectOff = KAknsIIDQgnPropRadiobuttOff; |
|
86 } |
|
87 else |
|
88 { |
|
89 selected = EMbmAvkonQgn_prop_checkbox_on; |
|
90 selectedm = EMbmAvkonQgn_prop_checkbox_on_mask; |
|
91 deselected = EMbmAvkonQgn_prop_checkbox_off; |
|
92 deselectedm = EMbmAvkonQgn_prop_checkbox_off_mask; |
|
93 } |
|
94 |
|
95 TParse* fp = new(ELeave) TParse(); |
|
96 |
|
97 TInt err = fp->Set( AknIconUtils::AvkonIconFileName(), |
|
98 &KDC_RESOURCE_FILES_DIR, |
|
99 NULL ); |
|
100 if ( err != KErrNone) |
|
101 { |
|
102 User::Leave( err ); |
|
103 } |
|
104 |
|
105 TFileName fileName = fp->FullName(); |
|
106 delete fp; |
|
107 |
|
108 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
109 selectOn, |
|
110 newIconBmp, |
|
111 newIconMaskBmp, |
|
112 fileName, |
|
113 selected, |
|
114 selectedm); |
|
115 newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp); |
|
116 CleanupStack::PushL( newIcon ); |
|
117 icons->AppendL( newIcon ); |
|
118 CleanupStack::Pop( newIcon ); |
|
119 |
|
120 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
121 selectOff, |
|
122 newIconBmp, |
|
123 newIconMaskBmp, |
|
124 fileName, |
|
125 deselected, |
|
126 deselectedm); |
|
127 newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp); |
|
128 CleanupStack::PushL( newIcon ); |
|
129 icons->AppendL( newIcon ); |
|
130 CleanupStack::Pop( newIcon ); |
|
131 |
|
132 // optiongroup |
|
133 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap; |
|
134 CleanupStack::PushL( bitmap ); |
|
135 CleanupStack::PushL( newIcon ); |
|
136 User::LeaveIfError( bitmap->Create(TSize(1,1),EColor64K)); |
|
137 CleanupStack::Pop( newIcon ); |
|
138 |
|
139 CFbsBitmap* mask = new ( ELeave ) CFbsBitmap; |
|
140 CleanupStack::PushL( mask ); |
|
141 User::LeaveIfError( mask->Create(TSize(1,1),EGray2)); |
|
142 |
|
143 icon = CGulIcon::NewL( bitmap, mask ); |
|
144 CleanupStack::PushL( icon ); |
|
145 icons->AppendL( icon ); |
|
146 |
|
147 CleanupStack::Pop( icon ); |
|
148 |
|
149 CleanupStack::Pop( mask ); |
|
150 CleanupStack::Pop( bitmap ); |
|
151 |
|
152 CleanupStack::Pop( icons ); |
|
153 ColumnData()->SetIconArray( icons ); |
|
154 } |
|
155 |
|
156 // ---------------------------------------------------------------------------- |
|
157 // CBrowserSelectElementItemDrawer::DrawItem |
|
158 // ---------------------------------------------------------------------------- |
|
159 // |
|
160 void CBrowserSelectElementItemDrawer::DrawItem( TInt aItemIndex, |
|
161 TPoint aItemRectPos, |
|
162 TBool aItemIsSelected, |
|
163 TBool aItemIsCurrent, |
|
164 TBool aViewIsEmphasized, |
|
165 TBool aViewIsDimmed ) const |
|
166 { |
|
167 TBool selected = aItemIsSelected; |
|
168 TBool currentIsOptGr = EFalse; |
|
169 |
|
170 if( ((CBrowserSelectElementModel*)iModel)->Filter() ) |
|
171 { |
|
172 if ((iOptions.At(((CBrowserSelectElementModel*)iModel)->Filter() |
|
173 ->FilteredItemIndex(aItemIndex)).IsOptGroup() )) |
|
174 { |
|
175 currentIsOptGr = ETrue; |
|
176 selected = EFalse; |
|
177 } |
|
178 } |
|
179 |
|
180 CFormattedCellListBoxItemDrawer::DrawItem( |
|
181 aItemIndex, |
|
182 aItemRectPos, |
|
183 selected, |
|
184 aItemIsCurrent, |
|
185 aViewIsEmphasized, |
|
186 aViewIsDimmed ); |
|
187 |
|
188 // this separator isn't specified in details |
|
189 if ( aItemIndex && currentIsOptGr ) |
|
190 { |
|
191 iGc->SetPenColor( AKN_LAF_COLOR( KBrCtlOptgroupSeparatorColor ) ); |
|
192 iGc->DrawLine( aItemRectPos + TSize( KBrCtlOptgroupSeparatorOffsetX1 , |
|
193 KBrCtlOptgroupSeparatorOffsetY ), |
|
194 aItemRectPos + TSize( KBrCtlOptgroupSeparatorOffsetX2 , |
|
195 KBrCtlOptgroupSeparatorOffsetY ) ); |
|
196 } |
|
197 } |
|
198 |
|
199 // End of file |