|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "musuistatuspanehandler.h" |
|
21 #include "musuidefinitions.h" |
|
22 #include "muslogger.h" // debug logging |
|
23 #include <musui.mbg> |
|
24 |
|
25 #include <eikspane.h> |
|
26 #include <barsread.h> |
|
27 #include <StringLoader.h> |
|
28 #include <akntitle.h> |
|
29 #include <aknenv.h> |
|
30 #include <akncontext.h> |
|
31 #include <AknIndicatorContainer.h> |
|
32 #include <aknnavi.h> // Navi pane container ( CAknNavigationControlContainer ) |
|
33 #include <AknVolumePopup.h> |
|
34 #include <eikapp.h> |
|
35 #include <eikenv.h> |
|
36 #include <eikappui.h> |
|
37 |
|
38 |
|
39 // constants |
|
40 #define KMUSMBMFILENAME iEikonEnvironment.EikAppUi()->Application()->BitmapStoreName() |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMusUiStatusPaneHandler* CMusUiStatusPaneHandler::NewL( CEikonEnv& aEikonEnv ) |
|
48 { |
|
49 CMusUiStatusPaneHandler* self = |
|
50 new ( ELeave ) CMusUiStatusPaneHandler( aEikonEnv ); |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler() |
|
63 { |
|
64 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler" ); |
|
65 |
|
66 delete iNaviPaneText; |
|
67 delete iMediaControl; |
|
68 delete iVolumePopup; |
|
69 |
|
70 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::~CMusUiStatusPaneHandler" ); |
|
71 } |
|
72 |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMusUiStatusPaneHandler::CMusUiStatusPaneHandler( CEikonEnv& aEikonEnv ) |
|
79 :iEikonEnvironment( aEikonEnv ) |
|
80 { |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CMusUiStatusPaneHandler::ConstructL() |
|
89 { |
|
90 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::ConstructL" ); |
|
91 |
|
92 CEikStatusPane* statusPane = iEikonEnvironment.AppUiFactory()->StatusPane(); |
|
93 |
|
94 iNaviPane = STATIC_CAST( |
|
95 CAknNavigationControlContainer*, |
|
96 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
97 iTitlePane = STATIC_CAST( |
|
98 CAknTitlePane*, |
|
99 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
100 iContextPane = STATIC_CAST( |
|
101 CAknContextPane*, |
|
102 statusPane->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ); |
|
103 |
|
104 iVolumePopup = CAknVolumePopup::ConstructFromResourceL( |
|
105 R_AVKON_NAVI_PANE_VOLUME_INDICATOR ); |
|
106 |
|
107 iMediaControl = CreateMediaNaviL(); |
|
108 |
|
109 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::ConstructL" ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // Updates statuspane icons |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMusUiStatusPaneHandler::SetStatusPaneIconsL( TInt32 aIconId, |
|
118 TInt32 aIconMaskId ) |
|
119 { |
|
120 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetStatusPaneIconsL" ) |
|
121 |
|
122 iContextPane->SetPictureFromFileL( KMUSMBMFILENAME, aIconId, aIconMaskId ); |
|
123 |
|
124 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetStatusPaneIconsL" ) |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // Updates statuspane icons |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CMusUiStatusPaneHandler::SetStatusPaneIconsL( CFbsBitmap* aBitmap ) |
|
133 { |
|
134 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetStatusPaneIconsL" ); |
|
135 CEikImage* image = new (ELeave) CEikImage(); |
|
136 image->SetBitmap( aBitmap ); |
|
137 CEikImage* oldImage = iContextPane->SwapPicture( image ); |
|
138 delete oldImage; |
|
139 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetStatusPaneIconsL" ); |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // Hides navi-pane decorators and clears text |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CMusUiStatusPaneHandler::ClearNaviPaneL() |
|
148 { |
|
149 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::ClearNaviPaneL" ); |
|
150 delete iNaviPaneText; |
|
151 iNaviPaneText = NULL; |
|
152 |
|
153 // Pushes default decorator object (empty one) to top of the stack |
|
154 // and draws it |
|
155 iNaviPane->PushDefaultL(); |
|
156 |
|
157 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::ClearNaviPaneL" ); |
|
158 } |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // Sets title-pane text |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CMusUiStatusPaneHandler::SetTitleL( const TDesC& aTitle ) |
|
166 { |
|
167 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetTitleL" ); |
|
168 iTitlePane->SetTextL( aTitle ); |
|
169 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetTitleL" ); |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CMusUiStatusPaneHandler::SetTitleFromResourceL( TInt aResourceId ) |
|
178 { |
|
179 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetTitleFromResourceL" ); |
|
180 HBufC* titlePaneTitle = StringLoader::LoadLC( aResourceId ); |
|
181 iTitlePane->SetTextL( *titlePaneTitle ); |
|
182 CleanupStack::PopAndDestroy( titlePaneTitle ); |
|
183 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetTitleFromResourceL" ); |
|
184 } |
|
185 |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // Get the current volume setting. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CMusUiStatusPaneHandler::GetVolumeControlValue() const |
|
192 { |
|
193 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::GetVolumeControlValue" ); |
|
194 |
|
195 TInt volume = iVolumePopup->Value(); |
|
196 |
|
197 MUS_LOG1( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::GetVolumeControlValue: [%d]", |
|
198 volume ); |
|
199 return volume; |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // Activates volume control. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CMusUiStatusPaneHandler::ActivateVolumeControlL( TInt aVolume ) |
|
208 { |
|
209 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::ActivateVolumeControlL" ); |
|
210 |
|
211 if ( aVolume < KMusVolumeMuted || aVolume > KMusVolumeMaximum ) |
|
212 { |
|
213 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetVolumeControlValue: returning" ); |
|
214 return; |
|
215 } |
|
216 |
|
217 iVolumePopup->SetValue( aVolume ); |
|
218 iVolumePopup->ShowVolumePopupL(); |
|
219 |
|
220 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::ActivateVolumeControlL" ); |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // Activate media navi pane. |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CMusUiStatusPaneHandler::ActivateNaviPaneMediaL() |
|
229 { |
|
230 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::ActivateNaviPaneMediaL" ); |
|
231 iNaviPane->PushL( *iMediaControl ); |
|
232 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::ActivateNaviPaneMediaL" ); |
|
233 } |
|
234 |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CMusUiStatusPaneHandler::ShowNaviPaneIconL( |
|
241 TMusUiNaviMediaDecorator aIcon ) |
|
242 { |
|
243 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::ShowNaviPaneIconL" ); |
|
244 CMusUiNaviMediaDecorator* mediaNavi = |
|
245 static_cast<CMusUiNaviMediaDecorator*>( |
|
246 iMediaControl->DecoratedControl() ); |
|
247 mediaNavi->ShowIcon( aIcon ); |
|
248 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::ShowNaviPaneIconL" ); |
|
249 } |
|
250 |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // Sets navi-pane label for left side |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CMusUiStatusPaneHandler::SetLeftLabelL( const TDesC& aLabel ) |
|
257 { |
|
258 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetLeftLabelL" ); |
|
259 |
|
260 static_cast<CMusUiNaviMediaDecorator*> |
|
261 ( iMediaControl->DecoratedControl() )->SetLeftLabelL( aLabel ); |
|
262 iNaviPane->DrawNow(); |
|
263 |
|
264 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetLeftLabelL" ); |
|
265 } |
|
266 |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // Sets navi-pane label for right side |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void CMusUiStatusPaneHandler::SetRightLabelL( const TDesC& aLabel ) |
|
273 { |
|
274 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::SetRightLabelL" ); |
|
275 |
|
276 static_cast<CMusUiNaviMediaDecorator*> |
|
277 ( iMediaControl->DecoratedControl() )->SetRightLabelL( aLabel ); |
|
278 iNaviPane->DrawNow(); |
|
279 |
|
280 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::SetRightLabelL" ); |
|
281 } |
|
282 |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // Create media navi pane. |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 CAknNavigationDecorator* CMusUiStatusPaneHandler::CreateMediaNaviL() |
|
289 { |
|
290 MUS_LOG( "mus: [MUSUI ] -> CMusUiStatusPaneHandler::CreateMediaNaviL" ); |
|
291 CMusUiNaviMediaDecorator* naviDecorator = CMusUiNaviMediaDecorator::NewL(); |
|
292 CleanupStack::PushL( naviDecorator ); |
|
293 |
|
294 CAknNavigationDecorator* decoratedFolder = |
|
295 CAknNavigationDecorator::NewL( |
|
296 iNaviPane, |
|
297 naviDecorator, |
|
298 CAknNavigationDecorator::ENotSpecified ); |
|
299 CleanupStack::Pop( naviDecorator );// decoratedFolder owns naviDecorator now |
|
300 |
|
301 CleanupStack::PushL( decoratedFolder ); |
|
302 decoratedFolder->SetContainerWindowL( *iNaviPane ); |
|
303 naviDecorator->SetContainerWindowL( *decoratedFolder ); |
|
304 CleanupStack::Pop( decoratedFolder ); |
|
305 |
|
306 decoratedFolder->MakeScrollButtonVisible( EFalse ); |
|
307 |
|
308 MUS_LOG( "mus: [MUSUI ] <- CMusUiStatusPaneHandler::CreateMediaNaviL" ); |
|
309 return decoratedFolder; |
|
310 } |
|
311 |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // Get Volump Popup control pointer |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 CAknVolumePopup* CMusUiStatusPaneHandler::GetVolumePopup() const |
|
318 { |
|
319 return iVolumePopup; |
|
320 } |
|
321 |
|
322 |
|
323 // end of file |