|
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: CMSBaseContainer class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eikclbd.h> |
|
22 |
|
23 #include <aknlists.h> |
|
24 #include <barsread.h> |
|
25 #include <AknIconArray.h> |
|
26 #include <AknQueryDialog.h> |
|
27 #include <aknnotewrappers.h> |
|
28 #include <akncontext.h> |
|
29 |
|
30 #include "msbasecontainer.h" |
|
31 #include "msconstants.h" |
|
32 #include "msdebug.h" |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================================= |
|
35 |
|
36 // -------------------------------------------------------------------------- |
|
37 // CMSBaseContainer::CMSBaseContainer() |
|
38 // Default constructor. |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 CMSBaseContainer::CMSBaseContainer() |
|
42 { |
|
43 LOG(_L("[MediaServant]\t CMSBaseContainer::CMSBaseContainer")); |
|
44 |
|
45 iCoeEnv = CEikonEnv::Static(); |
|
46 } |
|
47 |
|
48 // -------------------------------------------------------------------------- |
|
49 // CMSBaseContainer::~CMSBaseContainer() |
|
50 // Destructor. |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CMSBaseContainer::~CMSBaseContainer() |
|
54 { |
|
55 LOG(_L("[MediaServant]\t CMSBaseContainer::~CMSBaseContainer")); |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CMSBaseContainer::SetListBoxFromResourceL() |
|
60 // Sets listbox from resource using ConstructFromResourceL() of |
|
61 // CEikColumnListBox class. |
|
62 // -------------------------------------------------------------------------- |
|
63 // |
|
64 void CMSBaseContainer::SetListBoxFromResourceL( |
|
65 CEikColumnListBox* aListBox, const TInt aResourceId ) |
|
66 { |
|
67 LOG(_L("[MediaServant]\t CMSBaseContainer::SetListBoxFromResourceL \ |
|
68 column listbox")); |
|
69 |
|
70 if ( aListBox && aResourceId ) |
|
71 { |
|
72 aListBox->SetContainerWindowL( *this ); |
|
73 |
|
74 TResourceReader reader; |
|
75 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
76 aListBox->ConstructFromResourceL( reader ); |
|
77 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
78 |
|
79 // Creates scrollbar. |
|
80 CreateScrollbarL( aListBox ); |
|
81 } |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CMSBaseContainer::SetListBoxFromResourceL() |
|
86 // Sets listbox from resource using ConstructFromResourceL() of |
|
87 // CEikFormattedCellListBox class. |
|
88 // -------------------------------------------------------------------------- |
|
89 // |
|
90 void CMSBaseContainer::SetListBoxFromResourceL( |
|
91 CEikFormattedCellListBox* aListBox, |
|
92 const TInt aResourceId ) |
|
93 { |
|
94 LOG(_L("[MediaServant]\t CMSBaseContainer::SetListBoxFromResourceL \ |
|
95 formatted cell listbox")); |
|
96 |
|
97 if ( aListBox && aResourceId ) |
|
98 { |
|
99 aListBox->SetContainerWindowL( *this ); |
|
100 |
|
101 TResourceReader reader; |
|
102 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
103 aListBox->ConstructFromResourceL( reader ); |
|
104 CleanupStack::PopAndDestroy(); // resource stuffs. |
|
105 |
|
106 // Creates scrollbar. |
|
107 CreateScrollbarL( aListBox ); |
|
108 } |
|
109 } |
|
110 |
|
111 // -------------------------------------------------------------------------- |
|
112 // CMSBaseContainer::AppendItemToListBoxArrayL() |
|
113 // Appends item to the list |
|
114 // -------------------------------------------------------------------------- |
|
115 // |
|
116 void CMSBaseContainer::AppendItemToListBoxArrayL( CEikListBox* aListBox, |
|
117 CTextListBoxModel* aModel, |
|
118 TInt aIconIndex, |
|
119 TDesC& aPrimaryText, |
|
120 TDesC& aSecondaryText ) |
|
121 { |
|
122 LOG(_L("[MediaServant]\t CMSBaseContainer::AppendItemToListBoxArrayL")); |
|
123 |
|
124 |
|
125 if ( aListBox && aModel ) |
|
126 { |
|
127 MDesCArray *itemList = aModel->ItemTextArray(); |
|
128 CDesCArray *itemArray = static_cast<CDesCArray*>( itemList ); |
|
129 |
|
130 TBuf<2> iconIndex; // magic: maximum icon count is 99 |
|
131 iconIndex.AppendNum( aIconIndex ); |
|
132 |
|
133 TInt newLen = iconIndex.Length() + |
|
134 KSlashT().Length() + |
|
135 (&aPrimaryText ? aPrimaryText.Length() : 0) + |
|
136 KSlashT().Length() + |
|
137 (&aSecondaryText ? aSecondaryText.Length() : 0); |
|
138 |
|
139 HBufC* newText = HBufC::NewMaxLC( newLen ); |
|
140 |
|
141 // Create new item string |
|
142 TPtr newTPtr = newText->Des(); |
|
143 |
|
144 newTPtr.Copy( iconIndex ); |
|
145 newTPtr.Append( KSlashT ); |
|
146 |
|
147 if ( &aPrimaryText ) |
|
148 { |
|
149 newTPtr.Append( aPrimaryText ); |
|
150 } |
|
151 newTPtr.Append( KSlashT ); |
|
152 |
|
153 if ( &aSecondaryText ) |
|
154 { |
|
155 newTPtr.Append( aSecondaryText ); |
|
156 } |
|
157 |
|
158 itemArray->AppendL(newTPtr); |
|
159 CleanupStack::PopAndDestroy( newText ); |
|
160 |
|
161 aListBox->HandleItemAdditionL(); |
|
162 } |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CMSBaseContainer::AppendItemToListBoxArrayL() |
|
167 // Appends item to the list |
|
168 // -------------------------------------------------------------------------- |
|
169 // |
|
170 void CMSBaseContainer::AppendItemToListBoxArrayL( CEikListBox* aListBox, |
|
171 CTextListBoxModel* aModel, |
|
172 TInt aIconIndex, |
|
173 TDesC& aItemText ) |
|
174 { |
|
175 LOG(_L("[MediaServant]\t CMSBaseContainer::AppendItemToListBoxArrayL")); |
|
176 |
|
177 |
|
178 if ( aListBox && aModel ) |
|
179 { |
|
180 MDesCArray *itemList = aModel->ItemTextArray(); |
|
181 CDesCArray *itemArray = static_cast<CDesCArray*>( itemList ); |
|
182 |
|
183 TBuf<2> iconIndex; // maximum icon count is 99 |
|
184 iconIndex.AppendNum( aIconIndex ); |
|
185 |
|
186 TInt newLen = iconIndex.Length() + |
|
187 KSlashT().Length() + |
|
188 (&aItemText ? aItemText.Length() : 0) + |
|
189 KSlashT().Length() + |
|
190 iconIndex.Length(); |
|
191 |
|
192 HBufC* newText = HBufC::NewMaxLC( newLen ); |
|
193 |
|
194 // Create new item string |
|
195 TPtr newTPtr = newText->Des(); |
|
196 |
|
197 newTPtr.Copy( iconIndex ); |
|
198 newTPtr.Append( KSlashT ); |
|
199 |
|
200 if ( &aItemText ) |
|
201 { |
|
202 newTPtr.Append( aItemText ); |
|
203 } |
|
204 newTPtr.Append( KSlashT ); |
|
205 |
|
206 itemArray->AppendL(newTPtr); |
|
207 CleanupStack::PopAndDestroy( newText ); |
|
208 |
|
209 aListBox->HandleItemAdditionL(); |
|
210 } |
|
211 } |
|
212 |
|
213 // -------------------------------------------------------------------------- |
|
214 // CMSBaseContainer::AppendIconToArrayL() |
|
215 // Adds icon to iconarray |
|
216 // -------------------------------------------------------------------------- |
|
217 // |
|
218 void CMSBaseContainer::AppendIconToArrayL(CAknIconArray* aArray, |
|
219 MAknsSkinInstance* aSkin, |
|
220 const TDesC& aMbmFile, |
|
221 const TAknsItemID& aID, |
|
222 TInt aBitmapId, |
|
223 TInt aMaskId) |
|
224 { |
|
225 LOG(_L("[MediaServant]\t CMSBaseContainer::AppendIconToArrayL")); |
|
226 |
|
227 __ASSERT_DEBUG( aArray, User::Leave(KErrArgument) ); |
|
228 |
|
229 CFbsBitmap* bitmap = NULL; |
|
230 CFbsBitmap* mask = NULL; |
|
231 |
|
232 AknsUtils::CreateIconLC(aSkin, aID, |
|
233 bitmap, mask, aMbmFile, aBitmapId, aMaskId); |
|
234 |
|
235 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
236 icon->SetBitmapsOwnedExternally(EFalse); |
|
237 |
|
238 // icon now owns the bitmaps, no need to keep on cleanup stack. |
|
239 CleanupStack::Pop(mask); |
|
240 CleanupStack::Pop(bitmap); |
|
241 bitmap = NULL; |
|
242 mask = NULL; |
|
243 |
|
244 CleanupStack::PushL(icon); |
|
245 |
|
246 aArray->AppendL(icon); |
|
247 |
|
248 // aArray now owns the icon, no need to delete. |
|
249 CleanupStack::Pop(icon); |
|
250 |
|
251 } |
|
252 |
|
253 // -------------------------------------------------------------------------- |
|
254 // CMSBaseContainer::CreateScrollbarL() |
|
255 // Creates scrollbar. |
|
256 // -------------------------------------------------------------------------- |
|
257 // |
|
258 void CMSBaseContainer::CreateScrollbarL( CEikListBox* aListBox ) |
|
259 { |
|
260 LOG(_L("[MediaServant]\t CMSBaseContainer::CreateScrollbarL")); |
|
261 |
|
262 if ( aListBox ) |
|
263 { |
|
264 // Creates scrollbar. |
|
265 aListBox->CreateScrollBarFrameL( ETrue ); |
|
266 aListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
267 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
268 } |
|
269 } |
|
270 |
|
271 // -------------------------------------------------------------------------- |
|
272 // CMSBaseContainer::UpdateScrollBar() |
|
273 // Update scroll bar. |
|
274 // -------------------------------------------------------------------------- |
|
275 // |
|
276 void CMSBaseContainer::ShowNoteL ( TInt aResource, TInt aError ) |
|
277 { |
|
278 LOG(_L("[MediaServant]\t CMSBaseContainer::ShowNoteL")); |
|
279 |
|
280 // Show error note |
|
281 CAknInformationNote* dlg = new(ELeave)CAknInformationNote(); |
|
282 TBuf<KMaxFileName> errorText; |
|
283 iCoeEnv->ReadResourceL(errorText, aResource ); |
|
284 errorText.AppendNum( aError ); |
|
285 dlg->ExecuteLD(errorText); |
|
286 } |
|
287 |
|
288 // -------------------------------------------------------------------------- |
|
289 // CMSBaseContainer::SetContextPaneIconL() |
|
290 // Sets context pane icon. |
|
291 // -------------------------------------------------------------------------- |
|
292 // |
|
293 void CMSBaseContainer::SetContextPaneIconL( const CFbsBitmap* aIconBitmap, |
|
294 const CFbsBitmap* aIconMask ) |
|
295 { |
|
296 LOG(_L("[MediaServant]\t CMSBaseContainer::SetContextPaneIconL")); |
|
297 |
|
298 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
299 CleanupStack::PushL( statusPane ); |
|
300 CAknContextPane* contextPane = ( CAknContextPane * )statusPane-> |
|
301 ControlL( TUid::Uid( EEikStatusPaneUidContext ) ); |
|
302 CleanupStack::Pop( statusPane ); |
|
303 contextPane->SetPicture( aIconBitmap, aIconMask ); |
|
304 } |
|
305 |
|
306 // -------------------------------------------------------------------------- |
|
307 // CMSBaseContainer::SetDefaultContextPaneIconL() |
|
308 // Sets default context pane icon. |
|
309 // -------------------------------------------------------------------------- |
|
310 // |
|
311 void CMSBaseContainer::SetDefaultContextPaneIconL() |
|
312 { |
|
313 LOG(_L("[MediaServant]\t CMSBaseContainer::SetDefaultContextPaneIconL")); |
|
314 |
|
315 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
316 CleanupStack::PushL( statusPane ); |
|
317 CAknContextPane* contextPane = ( CAknContextPane * )statusPane-> |
|
318 ControlL( TUid::Uid( EEikStatusPaneUidContext ) ); |
|
319 CleanupStack::Pop( statusPane ); |
|
320 contextPane->SetPictureToDefaultL(); |
|
321 } |
|
322 |
|
323 // End of File |