|
1 /* |
|
2 * Copyright (c) 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: test case for various list classes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikclbd.h> |
|
20 #include <aknlists.h> |
|
21 #include <barsread.h> |
|
22 #include <gulicon.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <akniconarray.h> |
|
25 |
|
26 #include <bctestlist.rsg> |
|
27 #include <bctestlist.mbg> |
|
28 #include "bctestlistbasecase.h" |
|
29 #include "bctestlistcontainer.h" |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ========================================= |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // C++ Default constructor. |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 CBCTestListBaseCase::CBCTestListBaseCase( |
|
39 CBCTestListContainer* aContainer, CEikonEnv* aEikEnv) |
|
40 : iContainer( aContainer ), iEikEnv( aEikEnv ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // Destructor. |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CBCTestListBaseCase::~CBCTestListBaseCase() |
|
49 { |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CBCTestListBaseCase::SetListBoxFromResourceL |
|
54 // Sets listbox from resource using ConstructFromResourceL() of |
|
55 // CEikColumnListBox class. |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 void CBCTestListBaseCase::SetListBoxFromResourceL( |
|
59 CEikColumnListBox* aListBox, const TInt aResourceId ) |
|
60 { |
|
61 if ( aListBox && aResourceId ) |
|
62 { |
|
63 aListBox->SetContainerWindowL( *iContainer ); |
|
64 |
|
65 TResourceReader reader; |
|
66 iEikEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
67 aListBox->ConstructFromResourceL( reader ); |
|
68 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
69 } |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CBCTestListBaseCase::SetListBoxFromResourceL |
|
74 // Sets listbox from resource using ConstructFromResourceL() of |
|
75 // CEikFormattedCellListBox class. |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 void CBCTestListBaseCase::SetListBoxFromResourceL( |
|
79 CEikFormattedCellListBox* aListBox, const TInt aResourceId ) |
|
80 { |
|
81 if ( aListBox && aResourceId ) |
|
82 { |
|
83 aListBox->SetContainerWindowL( *iContainer ); |
|
84 |
|
85 TResourceReader reader; |
|
86 iEikEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
87 aListBox->ConstructFromResourceL( reader ); |
|
88 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
89 } |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // CBCTestListBaseCase::SetListBoxFromInnerDescriptionL |
|
94 // Sets listbox from inner description using ConstructL() of CEikColumnListBox |
|
95 // class. |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 void CBCTestListBaseCase::SetListBoxFromInnerDescriptionL( |
|
99 CEikColumnListBox* aListBox, const TInt aFlags, CDesCArray* textArray ) |
|
100 { |
|
101 if ( aListBox ) |
|
102 { |
|
103 // Constructs listbox. |
|
104 aListBox->ConstructL( iContainer, aFlags ); |
|
105 |
|
106 if ( textArray ) |
|
107 { |
|
108 // Sets list item from resource. |
|
109 aListBox->Model()->SetItemTextArray( textArray ); |
|
110 aListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
111 } |
|
112 } |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CBCTestListBaseCase::SetListBoxFromInnerDescriptionL |
|
117 // Sets listbox from inner description using ConstructL() of |
|
118 // CEikFormattedCellListBox class. |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 void CBCTestListBaseCase::SetListBoxFromInnerDescriptionL( |
|
122 CEikFormattedCellListBox* aListBox, |
|
123 const TInt aFlags, |
|
124 CDesCArray* textArray ) |
|
125 { |
|
126 if ( aListBox ) |
|
127 { |
|
128 // Constructs listbox. |
|
129 aListBox->ConstructL( iContainer, aFlags ); |
|
130 |
|
131 if ( textArray ) |
|
132 { |
|
133 // Sets list item from resource. |
|
134 aListBox->Model()->SetItemTextArray( textArray ); |
|
135 aListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 // ---------------------------------------------------------------------------- |
|
141 // CBCTestListBaseCase::SetGraphicIconL( CEikColumnListBox* ) |
|
142 // Sets graphic icon using listbox as CEikColumnListBox. |
|
143 // ---------------------------------------------------------------------------- |
|
144 // |
|
145 void CBCTestListBaseCase::SetGraphicIconL( CEikColumnListBox* aListBox ) |
|
146 { |
|
147 if ( aListBox ) |
|
148 { |
|
149 // Creates gul icon. |
|
150 CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray( |
|
151 KBCTestListGraphicGulIconIndex ); |
|
152 |
|
153 CleanupStack::PushL( icons ); |
|
154 |
|
155 GraphicIconL( icons ); // Appends graphic data. |
|
156 |
|
157 // Sets graphics as ListBox icon. |
|
158 aListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
159 |
|
160 CleanupStack::Pop(); |
|
161 |
|
162 } |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CBCTestListBaseCase::SetGraphicIconL |
|
167 // Sets graphic icon using listbox as CEikFormattedCellListBox. |
|
168 // ---------------------------------------------------------------------------- |
|
169 // |
|
170 void CBCTestListBaseCase::SetGraphicIconL( |
|
171 CEikFormattedCellListBox* aListBox ) |
|
172 { |
|
173 if ( aListBox ) |
|
174 { |
|
175 // Creates gul icon. |
|
176 CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray( |
|
177 KBCTestListGraphicGulIconIndex ); |
|
178 |
|
179 CleanupStack::PushL( icons ); |
|
180 |
|
181 GraphicIconL( icons ); // Appends graphic data. |
|
182 |
|
183 // Sets graphics as ListBox icon. |
|
184 aListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
185 |
|
186 CleanupStack::Pop(); |
|
187 } |
|
188 } |
|
189 |
|
190 |
|
191 // ---------------------------------------------------------------------------- |
|
192 // CBCTestListBaseCase::GraphicIconL |
|
193 // Appends graphics data. |
|
194 // ---------------------------------------------------------------------------- |
|
195 // |
|
196 void CBCTestListBaseCase::GraphicIconL( CArrayPtr<CGulIcon>* aIcons ) |
|
197 { |
|
198 if ( aIcons ) |
|
199 { |
|
200 // Appends icon. |
|
201 CreateIconAndAddToArrayL(aIcons, KBCTestListMbmFileName, |
|
202 EMbmBctestlistQgn_indi_marked_add, |
|
203 EMbmBctestlistQgn_indi_marked_add_mask); |
|
204 } |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CBCTestListBaseCase::CreateIconAndAddToArrayL |
|
209 // Creates the icon and adds it to the array if it was successful |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 void CBCTestListBaseCase::CreateIconAndAddToArrayL( |
|
213 CArrayPtr<CGulIcon>*& aIconsArray, |
|
214 const TDesC& aIconFile, |
|
215 TInt aBitmap, TInt aMask/* = -1*/) |
|
216 { |
|
217 CGulIcon* icon = CGulIcon::NewLC(); |
|
218 CFbsBitmap* bitmap = NULL; |
|
219 CFbsBitmap* mask = NULL; |
|
220 if (aMask >= 0) |
|
221 { |
|
222 AknIconUtils::CreateIconL( bitmap, mask, aIconFile, aBitmap, aMask); |
|
223 } |
|
224 else |
|
225 { |
|
226 bitmap = AknIconUtils::CreateIconL( aIconFile, aBitmap); |
|
227 } |
|
228 |
|
229 if (bitmap) |
|
230 { |
|
231 icon->SetBitmap(bitmap); |
|
232 if (mask) |
|
233 icon->SetMask(mask); |
|
234 aIconsArray->AppendL(icon); |
|
235 CleanupStack::Pop(icon); |
|
236 } |
|
237 else |
|
238 { |
|
239 CleanupStack::PopAndDestroy(icon); |
|
240 } |
|
241 } |