|
1 /******************************************************************************* |
|
2 * Copyright (c) 2007, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #include <eikclbd.h> |
|
14 #include <barsread.h> |
|
15 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
16 #include <aknlistloadertfx.h> |
|
17 #include <aknlistboxtfxinternal.h> |
|
18 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
19 #include "swtlistboxlists.h" |
|
20 |
|
21 |
|
22 // ======== MEMBER FUNCTIONS ======== |
|
23 |
|
24 |
|
25 // |
|
26 // CSwtListBoxTemplate |
|
27 // |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CSwtListBoxTemplate<T, U, V>::NewL |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 template<class T, class U, class V> |
|
34 CSwtListBoxTemplate<T, U, V>* CSwtListBoxTemplate<T, U, V>::NewL() |
|
35 { |
|
36 CSwtListBoxTemplate<T, U, V>* list = new(ELeave) CSwtListBoxTemplate<T, U, V>; |
|
37 CleanupStack::PushL(list); |
|
38 list->ConstructL(); |
|
39 CleanupStack::Pop(); |
|
40 return list; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CSwtListBoxTemplate<T, U, V>::~CSwtListBoxTemplate |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 template<class T, class U, class V> |
|
48 CSwtListBoxTemplate<T, U, V>::~CSwtListBoxTemplate() |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CSwtListBoxTemplate<T, U, V>::CSwtListBoxTemplate |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 template<class T, class U, class V> |
|
57 CSwtListBoxTemplate<T, U, V>::CSwtListBoxTemplate() |
|
58 :T() |
|
59 { |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CSwtListBoxTemplate<T, U, V>::ConstructL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 template<class T, class U, class V> |
|
67 void CSwtListBoxTemplate<T, U, V>::ConstructL() |
|
68 { |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CSwtListBoxTemplate<T, U, V>::SetItemDrawerClippingRect |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 template<class T, class U, class V> |
|
76 void CSwtListBoxTemplate<T, U, V>::SetItemDrawerClippingRect(const TRect& aRect) |
|
77 { |
|
78 U* customItemDrawer = static_cast<U*>(T::ItemDrawer()); |
|
79 |
|
80 if (customItemDrawer) |
|
81 { |
|
82 customItemDrawer->SetCustomClippingRect(aRect); |
|
83 } |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CSwtListBoxTemplate<T, U, V>::SetMargins |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 template<class T, class U, class V> |
|
91 void CSwtListBoxTemplate<T, U, V>::SetMargins(TInt aHorizontal, TInt aVertical) |
|
92 { |
|
93 T::SetHorizontalMargin(aHorizontal); |
|
94 T::SetVerticalMargin(aVertical); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CSwtListBoxTemplate<T, U, V>::SizeChanged |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 template<class T, class U, class V> |
|
102 void CSwtListBoxTemplate<T, U, V>::SizeChanged() |
|
103 { |
|
104 T::SizeChanged(); |
|
105 TRAP_IGNORE(RectChangedL(ETrue)); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CSwtListBoxTemplate<T, U, V>::PositionChanged |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 template<class T, class U, class V> |
|
113 void CSwtListBoxTemplate<T, U, V>::PositionChanged() |
|
114 { |
|
115 T::PositionChanged(); |
|
116 TRAP_IGNORE(RectChangedL(EFalse)); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CSwtListBoxTemplate<T, U, V>::RectChangedL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 template<class T, class U, class V> |
|
124 void CSwtListBoxTemplate<T, U, V>::RectChangedL(TBool aDoHandleSizeChanged) |
|
125 { |
|
126 if (iListObserver && aDoHandleSizeChanged) |
|
127 { |
|
128 iListObserver->HandleSizeChangedL(); |
|
129 } |
|
130 |
|
131 TRect rect(ClientRect(T::Rect(), T::Border(), T::ScrollBarFrame(), EFalse)); |
|
132 T::SetViewRectFromClientRect(rect); |
|
133 CAknDoubleSpanScrollBar* vBar = static_cast<CAknDoubleSpanScrollBar*>( |
|
134 T::ScrollBarFrame()->VerticalScrollBar()); |
|
135 if (vBar) |
|
136 { |
|
137 // This will cause the scrollbar to be relocated in the right place |
|
138 vBar->SetFixedLayoutRect(TRect(0, 0, 0, 0)); |
|
139 } |
|
140 T::HandleViewRectSizeChangeL(); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CSwtListBoxTemplate<T, U, V>::SetItemHeightL |
|
145 // From CEikListBox |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 template<class T, class U, class V> |
|
149 void CSwtListBoxTemplate<T, U, V>::SetItemHeightL(TInt aHeight) |
|
150 { |
|
151 T::iItemHeight = aHeight; |
|
152 TRect rect(ClientRect(T::Rect(), T::Border(), T::ScrollBarFrame(), EFalse)); |
|
153 T::SetViewRectFromClientRect(rect); |
|
154 T::View()->SetItemHeight(aHeight); |
|
155 CAknDoubleSpanScrollBar* vBar = static_cast<CAknDoubleSpanScrollBar*>( |
|
156 T::ScrollBarFrame()->VerticalScrollBar()); |
|
157 if (vBar) |
|
158 { |
|
159 vBar->SetFixedLayoutRect(TRect(0, 0, 0, 0)); |
|
160 } |
|
161 T::HandleViewRectSizeChangeL(); |
|
162 } |
|
163 |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CSwtListBoxTemplate<T, U, V>::MopSupplyObject |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 template<class T, class U, class V> |
|
170 TTypeUid::Ptr CSwtListBoxTemplate<T, U, V>::MopSupplyObject(TTypeUid aId) |
|
171 { |
|
172 return CEikTextListBox::MopSupplyObject(aId); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CSwtListBoxTemplate<T, U, V>::ClientRect |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 template<class T, class U, class V> |
|
180 TRect CSwtListBoxTemplate<T, U, V>::ClientRect(TRect aRect, TGulBorder aBorder, |
|
181 CEikScrollBarFrame* aSbFrame, TBool aExcludeScrollBars) const |
|
182 { |
|
183 TRect clientRect(aBorder.InnerRect(aRect)); |
|
184 |
|
185 if (aSbFrame && !aExcludeScrollBars) |
|
186 { |
|
187 if (aSbFrame->ScrollBarExists(CEikScrollBar::EHorizontal) |
|
188 && aSbFrame->ScrollBarVisibility(CEikScrollBar::EHorizontal) |
|
189 != CEikScrollBarFrame::EOff) |
|
190 { |
|
191 TInt breadth(0); |
|
192 if (iListObserver) |
|
193 { |
|
194 breadth = iListObserver->Utils().ScrollBarBreadth( |
|
195 aSbFrame->GetScrollBarHandle(CEikScrollBar::EHorizontal)); |
|
196 } |
|
197 else |
|
198 { |
|
199 breadth = aSbFrame->ScrollBarBreadth(CEikScrollBar::EHorizontal); |
|
200 } |
|
201 clientRect.iBr.iY -= breadth; |
|
202 } |
|
203 if (aSbFrame->ScrollBarExists(CEikScrollBar::EVertical) |
|
204 && aSbFrame->ScrollBarVisibility(CEikScrollBar::EVertical) |
|
205 != CEikScrollBarFrame::EOff) |
|
206 { |
|
207 if (!AknLayoutUtils::LayoutMirrored()) |
|
208 { |
|
209 TInt breadth(0); |
|
210 if (iListObserver) |
|
211 { |
|
212 breadth = iListObserver->Utils().ScrollBarBreadth( |
|
213 aSbFrame->VerticalScrollBar()); |
|
214 } |
|
215 else |
|
216 { |
|
217 breadth = aSbFrame->ScrollBarBreadth(CEikScrollBar::EVertical); |
|
218 } |
|
219 clientRect.iBr.iX -= breadth; |
|
220 } |
|
221 } |
|
222 } |
|
223 |
|
224 return clientRect; |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CSwtListBoxTemplate<T, U, V>::SetListObserver |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 template<class T, class U, class V> |
|
232 void CSwtListBoxTemplate<T, U, V>::SetListObserver(MSwtListObserver* aListObserver) |
|
233 { |
|
234 iListObserver = aListObserver; |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // CSwtListBoxTemplate<T, U, V>::CreateItemDrawerL |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 template<class T, class U, class V> |
|
242 void CSwtListBoxTemplate<T, U, V>::CreateItemDrawerL() |
|
243 { |
|
244 V* columnData = V::NewL(); |
|
245 CleanupStack::PushL(columnData); |
|
246 T::iItemDrawer = new(ELeave) U(T::Model(), |
|
247 T::iCoeEnv->NormalFont(), columnData, this); |
|
248 CleanupStack::Pop(); |
|
249 } |
|
250 |
|
251 // |
|
252 // CSwtListBoxLists |
|
253 // |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // CSwtListBoxLists::NewListL |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 CEikTextListBox* CSwtListBoxLists::NewListL(TInt aListType) |
|
260 { |
|
261 ASSERT(IsListType(aListType)); |
|
262 CEikTextListBox* list = NULL; |
|
263 switch (aListType) |
|
264 { |
|
265 case ESwtLbSingle: |
|
266 list = CSwtListBoxSingle::NewL(); |
|
267 break; |
|
268 case ESwtLbSingleGraphic: |
|
269 list = CSwtListBoxSingleGraphic::NewL(); |
|
270 break; |
|
271 case ESwtLbSingleLarge: |
|
272 list = CSwtListBoxSingleLarge::NewL(); |
|
273 break; |
|
274 case ESwtLbSingleHeading: |
|
275 list = CSwtListBoxSingleHeading::NewL(); |
|
276 break; |
|
277 case ESwtLbSingleHeadingGraphic: |
|
278 list = CSwtListBoxSingleHeadingGraphic::NewL(); |
|
279 break; |
|
280 case ESwtLbDouble: |
|
281 list = CSwtListBoxDouble::NewL(); |
|
282 break; |
|
283 case ESwtLbDoubleGraphic: |
|
284 list = CSwtListBoxDoubleGraphic::NewL(); |
|
285 break; |
|
286 case ESwtLbDoubleLarge: |
|
287 list = CSwtListBoxDoubleLarge::NewL(); |
|
288 break; |
|
289 default: |
|
290 break; |
|
291 } |
|
292 return list; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // CSwtListBoxLists::SetListObserver |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 void CSwtListBoxLists::SetListObserver(TInt aListType, CEikTextListBox* aList, |
|
300 MSwtListObserver* aListObserver) |
|
301 { |
|
302 ASSERT(IsListType(aListType)); |
|
303 switch (aListType) |
|
304 { |
|
305 case ESwtLbSingle: |
|
306 STATIC_CAST(CSwtListBoxSingle*, aList)->SetListObserver(aListObserver); |
|
307 break; |
|
308 case ESwtLbSingleGraphic: |
|
309 STATIC_CAST(CSwtListBoxSingleGraphic*, aList)->SetListObserver(aListObserver); |
|
310 break; |
|
311 case ESwtLbSingleLarge: |
|
312 STATIC_CAST(CSwtListBoxSingleLarge*, aList)->SetListObserver(aListObserver); |
|
313 break; |
|
314 case ESwtLbSingleHeading: |
|
315 STATIC_CAST(CSwtListBoxSingleHeading*, aList)->SetListObserver(aListObserver); |
|
316 break; |
|
317 case ESwtLbSingleHeadingGraphic: |
|
318 STATIC_CAST(CSwtListBoxSingleHeadingGraphic*, aList)->SetListObserver(aListObserver); |
|
319 break; |
|
320 case ESwtLbDouble: |
|
321 STATIC_CAST(CSwtListBoxDouble*, aList)->SetListObserver(aListObserver); |
|
322 break; |
|
323 case ESwtLbDoubleGraphic: |
|
324 STATIC_CAST(CSwtListBoxDoubleGraphic*, aList)->SetListObserver(aListObserver); |
|
325 break; |
|
326 case ESwtLbDoubleLarge: |
|
327 STATIC_CAST(CSwtListBoxDoubleLarge*, aList)->SetListObserver(aListObserver); |
|
328 break; |
|
329 default: |
|
330 break; |
|
331 } |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CSwtListBoxLists::Cells |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CSwtListBoxLists::Cells( |
|
339 TInt aListType, |
|
340 RArray<TInt>& aCellArray) |
|
341 { |
|
342 ASSERT(IsListType(aListType)); |
|
343 for (TInt i = 0; (KSwtLbCells[aListType][i] != ECellInvalid) |
|
344 && (i < KMaxCellCount); i++) |
|
345 { |
|
346 aCellArray.Append(KSwtLbCells[aListType][i]); |
|
347 } |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // CSwtListBoxLists::IsListFormatted |
|
352 // --------------------------------------------------------------------------- |
|
353 // |
|
354 TBool CSwtListBoxLists::IsListFormatted(TInt aListType) |
|
355 { |
|
356 ASSERT(IsListType(aListType)); |
|
357 if (aListType > ESwtLbSingleHeadingGraphic) |
|
358 { |
|
359 return ETrue; |
|
360 } |
|
361 else |
|
362 { |
|
363 return EFalse; |
|
364 } |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CSwtListBoxLists::IsListType |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 TBool CSwtListBoxLists::IsListType(TInt aVal) |
|
372 { |
|
373 return aVal >= 0 && aVal < ESwtLbTypeCount; |
|
374 } |
|
375 |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // CSwtListBoxLists::SetItemDrawerClippingRect |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void CSwtListBoxLists::SetItemDrawerClippingRect(TInt aListType, |
|
382 CEikTextListBox* aList, const TRect& aRect) |
|
383 { |
|
384 ASSERT(IsListType(aListType)); |
|
385 |
|
386 switch (aListType) |
|
387 { |
|
388 case ESwtLbSingle: |
|
389 STATIC_CAST(CSwtListBoxSingle*, aList) |
|
390 ->SetItemDrawerClippingRect(aRect); |
|
391 break; |
|
392 case ESwtLbSingleGraphic: |
|
393 STATIC_CAST(CSwtListBoxSingleGraphic*, aList) |
|
394 ->SetItemDrawerClippingRect(aRect); |
|
395 break; |
|
396 case ESwtLbSingleLarge: |
|
397 STATIC_CAST(CSwtListBoxSingleLarge*, aList) |
|
398 ->SetItemDrawerClippingRect(aRect); |
|
399 break; |
|
400 case ESwtLbSingleHeading: |
|
401 STATIC_CAST(CSwtListBoxSingleHeading*, aList) |
|
402 ->SetItemDrawerClippingRect(aRect); |
|
403 break; |
|
404 case ESwtLbSingleHeadingGraphic: |
|
405 STATIC_CAST(CSwtListBoxSingleHeadingGraphic*, aList) |
|
406 ->SetItemDrawerClippingRect(aRect); |
|
407 break; |
|
408 case ESwtLbDouble: |
|
409 STATIC_CAST(CSwtListBoxDouble*, aList) |
|
410 ->SetItemDrawerClippingRect(aRect); |
|
411 break; |
|
412 case ESwtLbDoubleGraphic: |
|
413 STATIC_CAST(CSwtListBoxDoubleGraphic*, aList) |
|
414 ->SetItemDrawerClippingRect(aRect); |
|
415 break; |
|
416 case ESwtLbDoubleLarge: |
|
417 STATIC_CAST(CSwtListBoxDoubleLarge*, aList) |
|
418 ->SetItemDrawerClippingRect(aRect); |
|
419 break; |
|
420 default: |
|
421 break; |
|
422 } |
|
423 } |
|
424 |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CSwtListBoxLists::SetMargins |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 void CSwtListBoxLists::SetMargins(TInt aListType, |
|
431 CEikTextListBox* aList, TInt aHorizontal, TInt aVertical) |
|
432 { |
|
433 ASSERT(IsListType(aListType)); |
|
434 |
|
435 switch (aListType) |
|
436 { |
|
437 case ESwtLbSingle: |
|
438 STATIC_CAST(CSwtListBoxSingle*, aList) |
|
439 ->SetMargins(aHorizontal, aVertical); |
|
440 break; |
|
441 case ESwtLbSingleGraphic: |
|
442 STATIC_CAST(CSwtListBoxSingleGraphic*, aList) |
|
443 ->SetMargins(aHorizontal, aVertical); |
|
444 break; |
|
445 case ESwtLbSingleLarge: |
|
446 STATIC_CAST(CSwtListBoxSingleLarge*, aList) |
|
447 ->SetMargins(aHorizontal, aVertical); |
|
448 break; |
|
449 case ESwtLbSingleHeading: |
|
450 STATIC_CAST(CSwtListBoxSingleHeading*, aList) |
|
451 ->SetMargins(aHorizontal, aVertical); |
|
452 break; |
|
453 case ESwtLbSingleHeadingGraphic: |
|
454 STATIC_CAST(CSwtListBoxSingleHeadingGraphic*, aList) |
|
455 ->SetMargins(aHorizontal, aVertical); |
|
456 break; |
|
457 case ESwtLbDouble: |
|
458 STATIC_CAST(CSwtListBoxDouble*, aList) |
|
459 ->SetMargins(aHorizontal, aVertical); |
|
460 break; |
|
461 case ESwtLbDoubleGraphic: |
|
462 STATIC_CAST(CSwtListBoxDoubleGraphic*, aList) |
|
463 ->SetMargins(aHorizontal, aVertical); |
|
464 break; |
|
465 case ESwtLbDoubleLarge: |
|
466 STATIC_CAST(CSwtListBoxDoubleLarge*, aList) |
|
467 ->SetMargins(aHorizontal, aVertical); |
|
468 break; |
|
469 default: |
|
470 break; |
|
471 } |
|
472 } |
|
473 |
|
474 |
|
475 // The compiler does not automatically instantiate templates defined in other |
|
476 // files. Because of this, code written will often produce undefined symbol |
|
477 // errors when compiled with the compiler. You need to tell the compiler which |
|
478 // template instances you want, by explicitly instantiating them in the file |
|
479 // where they are defined. |
|
480 template class CSwtListBoxTemplate <CAknSingleStyleListBox, |
|
481 CSwtColumnListBoxItemDrawer, CColumnListBoxData>; |
|
482 template class CSwtListBoxTemplate <CAknSingleGraphicStyleListBox, |
|
483 CSwtColumnListBoxItemDrawer, CColumnListBoxData>; |
|
484 template class CSwtListBoxTemplate <CAknSingleLargeStyleListBox, |
|
485 CSwtColumnListBoxItemDrawer, CColumnListBoxData>; |
|
486 template class CSwtListBoxTemplate <CAknSingleHeadingStyleListBox, |
|
487 CSwtSingleHeadingStyleListBoxItemDrawer,CColumnListBoxData>; |
|
488 template class CSwtListBoxTemplate <CAknSingleGraphicHeadingStyleListBox, |
|
489 CSwtSingleHeadingStyleListBoxItemDrawer,CColumnListBoxData>; |
|
490 template class CSwtListBoxTemplate <CAknDoubleStyleListBox, |
|
491 CSwtFormattedCellListBoxItemDrawer, CFormattedCellListBoxData>; |
|
492 template class CSwtListBoxTemplate <CAknDoubleGraphicStyleListBox, |
|
493 CSwtFormattedCellListBoxItemDrawer, CFormattedCellListBoxData>; |
|
494 template class CSwtListBoxTemplate <CAknDoubleLargeStyleListBox, |
|
495 CSwtDoubleLargeStyleItemDrawer, CFormattedCellListBoxData>; |