|
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: Implementation of main view's container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <barsread.h> |
|
22 #include <StringLoader.h> |
|
23 #include <AknIconArray.h> |
|
24 #include <gulicon.h> |
|
25 #include <aknconsts.h> |
|
26 #include <aknlists.h> |
|
27 #include <avkon.mbg> |
|
28 #include <eikclbd.h> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <mpxmainview.rsg> |
|
31 #include <mpxmainview.mbg> |
|
32 #include <mpxconstants.h> |
|
33 #include <mpxlog.h> |
|
34 #include <mpxuser.h> |
|
35 #include "mpxmainviewcontainer.h" |
|
36 #include "mpxmainview.hlp.hrh" |
|
37 #include "mpxmainview.hrh" |
|
38 #include "mpxmainviewimp.h" |
|
39 |
|
40 // CONSTANTS |
|
41 _LIT( KMPXMainViewIconFile, "mpxmainview.mbm" ); |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // C++ default constructor can NOT contain any code, that |
|
47 // might leave. |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CMPXMainViewContainer::CMPXMainViewContainer( |
|
51 CMPXMainViewImp* aView ) : |
|
52 iView( aView ) |
|
53 { |
|
54 // pass |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 void CMPXMainViewContainer::ConstructL( const TRect& aRect ) |
|
62 { |
|
63 MPX_FUNC( "CMPXMainViewContainer::ConstructL()" ); |
|
64 |
|
65 SetMopParent( iView ); |
|
66 |
|
67 CreateWindowL(); |
|
68 |
|
69 SetRect( aRect ); |
|
70 |
|
71 CreateListBoxL(); |
|
72 |
|
73 ActivateL(); |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // Destructor |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CMPXMainViewContainer::~CMPXMainViewContainer() |
|
81 { |
|
82 MPX_DEBUG1( "-->CMPXMainViewContainer::~CMPXMainViewContainer" ); |
|
83 delete iListBox; |
|
84 MPX_DEBUG1( "<--CMPXMainViewContainer::~CMPXMainViewContainer" ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // Set layout for all elements and set sizes for icons. |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CMPXMainViewContainer::UpdateLayout() |
|
92 { |
|
93 MPX_FUNC( "CMPXMainViewContainer::UpdateLayout" ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // Returns a pointer to the listbox |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CEikTextListBox* CMPXMainViewContainer::ListBox() |
|
101 { |
|
102 return iListBox; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Create list box |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CMPXMainViewContainer::CreateListBoxL() |
|
110 { |
|
111 MPX_FUNC( "CMPXMainViewContainer::CreateListBox" ); |
|
112 |
|
113 iListBox = new ( ELeave ) CAknDoubleLargeStyleListBox(); |
|
114 iListBox->SetContainerWindowL( *this ); |
|
115 iListBox->CreateScrollBarFrameL( ETrue ); |
|
116 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
117 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
118 |
|
119 TResourceReader rReader; |
|
120 iCoeEnv->CreateResourceReaderLC( rReader, R_MPX_MAIN_VIEW_LBX ); |
|
121 // construct's iListBox from resource file |
|
122 iListBox->ConstructFromResourceL( rReader ); |
|
123 CleanupStack::PopAndDestroy(); |
|
124 |
|
125 // Enable Marquee |
|
126 CEikFormattedCellListBox* eikListbox = |
|
127 static_cast<CEikFormattedCellListBox*>( iListBox ); |
|
128 eikListbox->EnableExtendedDrawingL(); |
|
129 eikListbox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
130 eikListbox->ItemDrawer()->FormattedCellData()->SetMarqueeParams( |
|
131 KMaxTInt, 6, 1000000, 100000); // Magic: loop forever, other params as default |
|
132 |
|
133 iListBox->SetListBoxObserver( iView ); |
|
134 iListBox->View()->SetListEmptyTextL( KNullDesC ); |
|
135 |
|
136 SizeChanged(); |
|
137 iListBox->ActivateL(); |
|
138 |
|
139 // List box icons |
|
140 TParse mbmFileName; |
|
141 mbmFileName.Set( KMPXMainViewIconFile, |
|
142 &KDC_APP_RESOURCE_DIR, NULL ); |
|
143 TFileName iconFile( mbmFileName.FullName() ); |
|
144 User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) ); |
|
145 |
|
146 // Prepare icon array for listbox |
|
147 CAknIconArray* icons = new ( ELeave ) |
|
148 CAknIconArray( 2 ); // magic: array granularity |
|
149 CleanupStack::PushL( icons ); |
|
150 |
|
151 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
152 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
153 skin, |
|
154 KAknsIIDNone, |
|
155 iconFile, |
|
156 EMbmMpxmainviewQgn_indi_mup_default_album, |
|
157 EMbmMpxmainviewQgn_indi_mup_default_album_mask ); |
|
158 icons->AppendL( icon ); |
|
159 |
|
160 icon = AknsUtils::CreateGulIconL( |
|
161 skin, |
|
162 KAknsIIDNone, |
|
163 iconFile, |
|
164 EMbmMpxmainviewQgn_graf_mup_npv_defalbumart_transp, |
|
165 EMbmMpxmainviewQgn_graf_mup_npv_defalbumart_transp_mask ); |
|
166 icons->AppendL( icon ); |
|
167 |
|
168 AppendIconToArrayL( icons, |
|
169 KAknsIIDQgnIndiMupPlay, |
|
170 KAknsIIDQsnIconColors, |
|
171 EAknsCIQsnIconColorsCG26, |
|
172 iconFile, |
|
173 EMbmMpxmainviewQgn_graf_mup_npv_icon_play, |
|
174 EMbmMpxmainviewQgn_graf_mup_npv_icon_play_mask ); |
|
175 |
|
176 AppendIconToArrayL( icons, |
|
177 KAknsIIDQgnIndiMupPause, |
|
178 KAknsIIDQsnIconColors, |
|
179 EAknsCIQsnIconColorsCG26, |
|
180 iconFile, |
|
181 EMbmMpxmainviewQgn_graf_mup_npv_icon_pause, |
|
182 EMbmMpxmainviewQgn_graf_mup_npv_icon_pause_mask ); |
|
183 |
|
184 icon = AknsUtils::CreateGulIconL( |
|
185 skin, |
|
186 KAknsIIDNone, |
|
187 iconFile, |
|
188 EMbmMpxmainviewQgn_indi_mup_default_album_pcast, |
|
189 EMbmMpxmainviewQgn_indi_mup_default_album_pcast_mask ); |
|
190 icons->AppendL( icon ); |
|
191 |
|
192 static_cast<CEikFormattedCellListBox*>( iListBox )->ItemDrawer()-> |
|
193 FormattedCellData()->SetIconArray( icons ); |
|
194 CleanupStack::Pop( icons ); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // Append icon to array |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CMPXMainViewContainer::AppendIconToArrayL( |
|
202 CAknIconArray* aArray, |
|
203 const TAknsItemID& aID, |
|
204 const TAknsItemID& aColorId, |
|
205 TInt aColorIndex, |
|
206 const TDesC& aMbmFile, |
|
207 TInt aBitmapId, |
|
208 TInt aMaskId ) |
|
209 { |
|
210 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
211 |
|
212 CFbsBitmap* bitmap = NULL; |
|
213 CFbsBitmap* mask = NULL; |
|
214 |
|
215 AknsUtils::CreateColorIconLC( |
|
216 skin, // aInstance |
|
217 aID, // aID |
|
218 aColorId, // aColorID |
|
219 aColorIndex, // aColorIndex |
|
220 bitmap, // aBitmap |
|
221 mask, // aMask |
|
222 aMbmFile, // aFilename |
|
223 aBitmapId, // aFileBitmapId |
|
224 aMaskId, // aFileBitmapId |
|
225 KRgbBlack ); // aDefaultColor |
|
226 |
|
227 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
228 icon->SetBitmapsOwnedExternally( EFalse ); |
|
229 |
|
230 // icon now owns the bitmaps, no need to keep on cleanup stack. |
|
231 CleanupStack::Pop(2); // mask, bitmap |
|
232 bitmap = NULL; |
|
233 mask = NULL; |
|
234 |
|
235 CleanupStack::PushL( icon ); |
|
236 aArray->AppendL( icon ); |
|
237 |
|
238 // aArray now owns the icon, no need to delete. |
|
239 CleanupStack::Pop(); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // From CCoeControl |
|
244 // Responds to changes to the size and position of the contents of this |
|
245 // control. |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 void CMPXMainViewContainer::SizeChanged() |
|
249 { |
|
250 MPX_FUNC( "CMPXMainViewContainer::SizeChanged" ); |
|
251 |
|
252 if ( iListBox ) |
|
253 { |
|
254 AknLayoutUtils::LayoutControl( iListBox, Rect(), |
|
255 AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) ); |
|
256 } |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // From CCoeControl |
|
261 // Gets the number of controls contained in a compound control. |
|
262 // --------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CMPXMainViewContainer::CountComponentControls() const |
|
265 { |
|
266 MPX_FUNC( "CMPXMainViewContainer::CountComponentControls" ); |
|
267 TInt count( 0 ); |
|
268 |
|
269 if ( iListBox ) |
|
270 { |
|
271 count++; |
|
272 } |
|
273 return count; |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // From CCoeControl |
|
278 // Gets an indexed component of a compound control. |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 CCoeControl* CMPXMainViewContainer::ComponentControl( TInt aIndex ) const |
|
282 { |
|
283 MPX_FUNC( "CMPXMainViewContainer::ComponentControl" ); |
|
284 CCoeControl* control = NULL; |
|
285 switch ( aIndex ) |
|
286 { |
|
287 case 0: |
|
288 { |
|
289 control = iListBox; // Returns the pointer to listbox object. |
|
290 break; |
|
291 } |
|
292 default: |
|
293 { |
|
294 // Exception : Returns NULL. SHOULD NEVER HAPPEN! |
|
295 break; |
|
296 } |
|
297 } |
|
298 return control; |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // From CCoeControl |
|
303 // Handles key events. |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 TKeyResponse CMPXMainViewContainer::OfferKeyEventL( |
|
307 const TKeyEvent& aKeyEvent, |
|
308 TEventCode aType ) |
|
309 { |
|
310 MPX_DEBUG4( "CMPXMainViewContainer::OfferKeyEventL(iCode=%d, iScanCode=%d, aType=%d)", |
|
311 aKeyEvent.iCode, aKeyEvent.iScanCode, aType ); |
|
312 |
|
313 TKeyResponse response = EKeyWasNotConsumed; |
|
314 |
|
315 if ( iListBox ) |
|
316 { |
|
317 response = iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
318 } |
|
319 return response; |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // From CCoeControl |
|
324 // Handles a change to the control's resources. |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 void CMPXMainViewContainer::HandleResourceChange( TInt aType ) |
|
328 { |
|
329 CCoeControl::HandleResourceChange( aType ); |
|
330 |
|
331 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
332 { |
|
333 SetRect( iView->ClientRect() ); |
|
334 } |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // From CCoeControl |
|
339 // Gets the control's help context. |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 void CMPXMainViewContainer::GetHelpContext( |
|
343 TCoeHelpContext& aContext ) const |
|
344 { |
|
345 aContext.iMajor = KAppUidMusicPlayerX; |
|
346 aContext.iContext = KMUS_HLP_LIB_LIBRARY_VIEW; |
|
347 } |
|
348 |
|
349 // End of File |