|
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: Definition of the class CPbkxRclBaseDlg. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <AknsListBoxBackgroundControlContext.h> |
|
21 #include <AknsConstants.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <eikfrlb.h> |
|
24 #include <eikfrlbd.h> |
|
25 #include <eikclb.h> |
|
26 #include <eikclbd.h> |
|
27 |
|
28 #include "cpbkxrclbasedlg.h" |
|
29 #include "cpbkxrclsearchresultlistbox.h" |
|
30 #include "cpbkxrclresultinfolistbox.h" |
|
31 #include "cpbkxrclsearchresultlistbox.h" |
|
32 #include "cpbkxrclresultinfolistbox.h" |
|
33 #include "engine.hrh" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CPbkxRclBaseDlg::CPbkxRclBaseDlg |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CPbkxRclBaseDlg::CPbkxRclBaseDlg( |
|
42 TInt& aIndex, |
|
43 CDesCArray* aArray, |
|
44 MEikCommandObserver* aCommand, |
|
45 TBool aColumnListBox ) : |
|
46 CAknSelectionListDialog( aIndex, aArray, aCommand ), |
|
47 iListItemId( KAknsIIDQgnFsGrafContactsContent ), |
|
48 iListBottomId( KAknsIIDQsnBgColumnA ), |
|
49 iHighlightId( KAknsIIDQgnFsList ), |
|
50 iHighlightCenterId( KAknsIIDQgnFsListCenter ), |
|
51 iHighlightTextColorId( KAknsIIDFsHighlightColors ), |
|
52 iTextColorId( KAknsIIDFsTextColors ), |
|
53 iColumnListBox( aColumnListBox ) |
|
54 { |
|
55 FUNC_LOG; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CPbkxRclBaseDlg::ConstructL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CPbkxRclBaseDlg::ConstructL( TInt aResourceId ) |
|
63 { |
|
64 FUNC_LOG; |
|
65 CAknSelectionListDialog::ConstructL( aResourceId ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CPbkxRclBaseDlg::~CPbkxRclBaseDlg |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CPbkxRclBaseDlg::~CPbkxRclBaseDlg() |
|
73 { |
|
74 FUNC_LOG; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CPbkxRclBaseDlg::HandleResourceChange |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CPbkxRclBaseDlg::HandleResourceChange( TInt aType ) |
|
82 { |
|
83 FUNC_LOG; |
|
84 CEikDialog::HandleResourceChange( aType ); |
|
85 if ( aType == KAknsMessageSkinChange ) |
|
86 { |
|
87 UpdateGraphics(); |
|
88 UpdateColors(); |
|
89 } |
|
90 else if ( aType == KEikMessageColorSchemeChange ) |
|
91 { |
|
92 UpdateColors(); |
|
93 } |
|
94 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
95 { |
|
96 |
|
97 // for some reason formatted cell listbox loses settings |
|
98 // when layout is switched |
|
99 if ( !iColumnListBox ) |
|
100 { |
|
101 UpdateGraphics(); |
|
102 UpdateColors(); |
|
103 } |
|
104 } |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CPbkxRclBaseDlg::IsAcceptableListBoxType |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CPbkxRclBaseDlg::IsAcceptableListBoxType( |
|
112 TInt aControlType, |
|
113 TBool& aIsFormattedCellList ) const |
|
114 { |
|
115 FUNC_LOG; |
|
116 if ( aControlType == ERclSearchResultListBox ) |
|
117 { |
|
118 aIsFormattedCellList = EFalse; |
|
119 return ETrue; |
|
120 } |
|
121 else if ( aControlType == ERclResultInfoListBox ) |
|
122 { |
|
123 aIsFormattedCellList = ETrue; |
|
124 return ETrue; |
|
125 } |
|
126 else |
|
127 { |
|
128 return CAknSelectionListDialog::IsAcceptableListBoxType( |
|
129 aControlType, |
|
130 aIsFormattedCellList ); |
|
131 } |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CPbkxRclBaseDlg::CreateCustomControlL |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 SEikControlInfo CPbkxRclBaseDlg::CreateCustomControlL( TInt aControlType ) |
|
139 { |
|
140 FUNC_LOG; |
|
141 if ( aControlType == ERclSearchResultListBox ) |
|
142 { |
|
143 CCoeControl* control = new ( ELeave ) CPbkxRclSearchResultListBox(); |
|
144 SEikControlInfo info = { control, 0, 0 }; |
|
145 return info; |
|
146 } |
|
147 else if ( aControlType == ERclResultInfoListBox ) |
|
148 { |
|
149 CCoeControl* control = new ( ELeave ) CPbkxRclResultInfoListBox(); |
|
150 SEikControlInfo info = { control, 0, 0 }; |
|
151 return info; |
|
152 } |
|
153 else |
|
154 { |
|
155 return CAknSelectionListDialog::CreateCustomControlL( aControlType ); |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CPbkxRclBaseDlg::UpdateGraphics |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CPbkxRclBaseDlg::UpdateGraphics() |
|
164 { |
|
165 FUNC_LOG; |
|
166 |
|
167 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
168 |
|
169 CAknsListBoxBackgroundControlContext* bgContext = NULL; |
|
170 CFormattedCellListBoxItemDrawer* fItemDrawer = NULL; |
|
171 CColumnListBoxItemDrawer* cItemDrawer = NULL; |
|
172 |
|
173 // set first to this value, then change if those are not found |
|
174 iHighlightId = KAknsIIDQgnFsList; |
|
175 iHighlightCenterId = KAknsIIDQgnFsListCenter; |
|
176 |
|
177 if ( iColumnListBox ) |
|
178 { |
|
179 CEikColumnListBox* listBox = |
|
180 static_cast<CEikColumnListBox*>( ListBox() ); |
|
181 cItemDrawer = listBox->ItemDrawer(); |
|
182 bgContext = |
|
183 static_cast<CAknsListBoxBackgroundControlContext*>( |
|
184 cItemDrawer->ColumnData()->SkinBackgroundContext() ); |
|
185 } |
|
186 else |
|
187 { |
|
188 CEikFormattedCellListBox* listBox = |
|
189 static_cast<CEikFormattedCellListBox*>( ListBox() ); |
|
190 fItemDrawer = listBox->ItemDrawer(); |
|
191 bgContext = |
|
192 static_cast<CAknsListBoxBackgroundControlContext*>( |
|
193 fItemDrawer->FormattedCellData()->SkinBackgroundContext() ); |
|
194 } |
|
195 |
|
196 if ( skin->GetCachedItemData( iListItemId ) ) |
|
197 { |
|
198 bgContext->SetBitmap( iListItemId ); |
|
199 bgContext->SetTiledBitmap( iListItemId ); |
|
200 } |
|
201 |
|
202 if ( skin->GetCachedItemData( iListBottomId ) ) |
|
203 { |
|
204 bgContext->SetBottomBitmap( iListBottomId ); |
|
205 } |
|
206 |
|
207 if ( skin->GetCachedItemData( iHighlightId ) && |
|
208 skin->GetCachedItemData( iHighlightCenterId ) ) |
|
209 { |
|
210 if ( iColumnListBox ) |
|
211 { |
|
212 cItemDrawer->ColumnData()->SetSkinHighlightFrame( |
|
213 &iHighlightId, |
|
214 &iHighlightCenterId ); |
|
215 } |
|
216 else |
|
217 { |
|
218 fItemDrawer->FormattedCellData()->SetSkinHighlightFrame( |
|
219 &iHighlightId, |
|
220 &iHighlightCenterId ); |
|
221 } |
|
222 } |
|
223 else |
|
224 { |
|
225 // put defaults if fs specific items are not found |
|
226 iHighlightId = KAknsIIDQsnFrList; |
|
227 iHighlightCenterId = KAknsIIDQsnFrListCenter; |
|
228 if ( iColumnListBox ) |
|
229 { |
|
230 cItemDrawer->ColumnData()->SetSkinHighlightFrame( |
|
231 &iHighlightId, |
|
232 &iHighlightCenterId ); |
|
233 } |
|
234 else |
|
235 { |
|
236 fItemDrawer->FormattedCellData()->SetSkinHighlightFrame( |
|
237 &iHighlightId, |
|
238 &iHighlightCenterId ); |
|
239 } |
|
240 } |
|
241 |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CPbkxRclBaseDlg::UpdateColors |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void CPbkxRclBaseDlg::UpdateColors() |
|
249 { |
|
250 FUNC_LOG; |
|
251 |
|
252 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
253 |
|
254 CPbkxRclResultInfoItemDrawer* fItemDrawer = NULL; |
|
255 CPbkxRclSearchResultItemDrawer* cItemDrawer = NULL; |
|
256 |
|
257 if ( iColumnListBox ) |
|
258 { |
|
259 CEikColumnListBox* listBox = |
|
260 static_cast<CEikColumnListBox*>( ListBox() ); |
|
261 cItemDrawer = static_cast<CPbkxRclSearchResultItemDrawer*>( |
|
262 listBox->ItemDrawer() ); |
|
263 } |
|
264 else |
|
265 { |
|
266 CEikFormattedCellListBox* listBox = |
|
267 static_cast<CEikFormattedCellListBox*>( ListBox() ); |
|
268 fItemDrawer = static_cast<CPbkxRclResultInfoItemDrawer*>( |
|
269 listBox->ItemDrawer() ); |
|
270 } |
|
271 |
|
272 TRgb newColor; |
|
273 |
|
274 // highlight text color |
|
275 TInt error = AknsUtils::GetCachedColor( |
|
276 skin, |
|
277 newColor, |
|
278 iHighlightTextColorId, |
|
279 EAknsCIFsHighlightColorsCG1 ); |
|
280 |
|
281 |
|
282 if ( error == KErrNone ) |
|
283 { |
|
284 if ( iColumnListBox ) |
|
285 { |
|
286 cItemDrawer->SetHighlightColor( newColor ); |
|
287 } |
|
288 else |
|
289 { |
|
290 fItemDrawer->SetHighlightColor( newColor ); |
|
291 } |
|
292 } |
|
293 else |
|
294 { |
|
295 if ( iColumnListBox ) |
|
296 { |
|
297 cItemDrawer->ResetColors( ETrue ); |
|
298 } |
|
299 else |
|
300 { |
|
301 fItemDrawer->ResetColors( ETrue ); |
|
302 } |
|
303 } |
|
304 |
|
305 // text color |
|
306 error = AknsUtils::GetCachedColor( |
|
307 skin, |
|
308 newColor, |
|
309 iTextColorId, |
|
310 EAknsCIFsTextColorsCG7 ); |
|
311 |
|
312 |
|
313 if ( error == KErrNone ) |
|
314 { |
|
315 if ( iColumnListBox ) |
|
316 { |
|
317 cItemDrawer->SetColor( newColor ); |
|
318 } |
|
319 else |
|
320 { |
|
321 fItemDrawer->SetColor( newColor ); |
|
322 } |
|
323 } |
|
324 else |
|
325 { |
|
326 if ( iColumnListBox ) |
|
327 { |
|
328 cItemDrawer->ResetColors(); |
|
329 } |
|
330 else |
|
331 { |
|
332 fItemDrawer->ResetColors(); |
|
333 } |
|
334 } |
|
335 } |
|
336 |