33
|
1 |
/*
|
|
2 |
* Copyright (c) 2003, 2004 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: Class for displaying level indicator icons
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// USER
|
|
20 |
#include "musuilevelindicator.h"
|
|
21 |
#include "musuilevelindicatorobserver.h"
|
|
22 |
#include "muslogger.h"
|
|
23 |
#include "musresourcefinderutil.h"
|
|
24 |
#include "musuiactivetimer.h"
|
|
25 |
#include <musuiicons.mbg>
|
|
26 |
#include <musui.rsg>
|
|
27 |
|
|
28 |
// SYSTEM
|
|
29 |
#include <aknslider.h>
|
|
30 |
#include <barsread.h>
|
|
31 |
#include <AknUtils.h>
|
|
32 |
#include <AknsUtils.h>
|
|
33 |
#include <data_caging_path_literals.hrh>
|
|
34 |
#include <gulicon.h>
|
|
35 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
36 |
#include <AknsDrawUtils.h>
|
|
37 |
|
|
38 |
|
|
39 |
// CONSTANTS
|
|
40 |
const TInt KMusUiLevelDisableTime = 4000000;
|
|
41 |
const TInt KMusUiSliderEventDelay = 300000;
|
|
42 |
|
|
43 |
|
|
44 |
_LIT( KMyBitmapRomFile, "Z:\\resource\\apps\\musuiicons.mif" );
|
|
45 |
//_LIT( KMyBitmapRamFile, "C:\\resource\\apps\\musuiicons.mif" );
|
|
46 |
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CMusUiLevelIndicator::CMusUiLevelIndicator(
|
|
53 |
TInt aMinLevel,
|
|
54 |
TInt aMaxLevel,
|
|
55 |
MMusUiLevelIndicatorObserver* aObserver )
|
|
56 |
: iMinLevel( aMinLevel ),
|
|
57 |
iMaxLevel( aMaxLevel ),
|
|
58 |
iObserver( aObserver )
|
|
59 |
{
|
|
60 |
MUS_LOG( "mus: mus: [MUSUI ] -> CMusUiLevelIndicator::CMusUiLevelIndicator()" );
|
|
61 |
// pass
|
|
62 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::CMusUiLevelIndicator()" );
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CMusUiLevelIndicator* CMusUiLevelIndicator::NewL(
|
|
71 |
TAknOrientation aLayout,
|
|
72 |
TInt aMinLevel,
|
|
73 |
TInt aMaxLevel,
|
|
74 |
CCoeControl* aParent,
|
|
75 |
const TRect& aRect,
|
|
76 |
MMusUiLevelIndicatorObserver* aObserver )
|
|
77 |
{
|
|
78 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::NewL()" );
|
|
79 |
|
|
80 |
CMusUiLevelIndicator* self = NewLC( aLayout,
|
|
81 |
aMinLevel,
|
|
82 |
aMaxLevel,
|
|
83 |
aParent,
|
|
84 |
aRect,
|
|
85 |
aObserver );
|
|
86 |
CleanupStack::Pop( self );
|
|
87 |
|
|
88 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::NewL()" );
|
|
89 |
|
|
90 |
return self;
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CMusUiLevelIndicator* CMusUiLevelIndicator::NewLC(
|
|
99 |
TAknOrientation aLayout,
|
|
100 |
TInt aMinLevel,
|
|
101 |
TInt aMaxLevel,
|
|
102 |
CCoeControl* aParent,
|
|
103 |
const TRect& aRect,
|
|
104 |
MMusUiLevelIndicatorObserver* aObserver )
|
|
105 |
{
|
|
106 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::NewLC()" );
|
|
107 |
|
|
108 |
CMusUiLevelIndicator* self = new ( ELeave ) CMusUiLevelIndicator(
|
|
109 |
aMinLevel,
|
|
110 |
aMaxLevel,
|
|
111 |
aObserver );
|
|
112 |
CleanupStack::PushL( self );
|
|
113 |
self->ConstructL( aLayout, aParent, aRect );
|
|
114 |
|
|
115 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::NewLC()" );
|
|
116 |
|
|
117 |
return self;
|
|
118 |
}
|
|
119 |
|
|
120 |
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
CMusUiLevelIndicator::~CMusUiLevelIndicator()
|
|
126 |
{
|
|
127 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::~CMusUiLevelIndicator()" );
|
|
128 |
|
|
129 |
delete iSlider;
|
|
130 |
delete iSliderEventTimer;
|
|
131 |
delete iDisableLevelTimer;
|
|
132 |
|
|
133 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::~CMusUiLevelIndicator()" );
|
|
134 |
}
|
|
135 |
|
|
136 |
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
// -----------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
void CMusUiLevelIndicator::ConstructL( TAknOrientation aLayout,
|
|
142 |
CCoeControl* aParent,
|
|
143 |
const TRect& aRect )
|
|
144 |
{
|
|
145 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::ConstructL()" );
|
|
146 |
|
|
147 |
SetRect(aRect);
|
|
148 |
|
|
149 |
if( iMinLevel > iMaxLevel )
|
|
150 |
{
|
|
151 |
User::Leave( KErrArgument );
|
|
152 |
}
|
|
153 |
|
|
154 |
iDisableLevelTimer = CMusUiActiveTimer::NewL( this );
|
|
155 |
iSliderEventTimer = CMusUiActiveTimer::NewL( this );
|
|
156 |
|
|
157 |
iSlider = new CAknSlider();
|
|
158 |
|
|
159 |
TResourceReader reader;
|
|
160 |
|
|
161 |
if( aLayout == EAknOrientationHorizontal )
|
|
162 |
{
|
|
163 |
iEikonEnv->CreateResourceReaderLC( reader, R_MUS_SLIDER_HORIZONTAL );
|
|
164 |
MUS_LOG( "mus: [MUSUI ] -> ConstructFromResourceL" );
|
|
165 |
iSlider->ConstructFromResourceL( aParent, 0, reader);
|
|
166 |
CleanupStack::PopAndDestroy(); // reader
|
|
167 |
iSlider->SetRange( iMinLevel, iMaxLevel );
|
|
168 |
iSlider->SetRect( aRect );
|
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
iEikonEnv->CreateResourceReaderLC( reader, R_MUS_SLIDER_VERTICAL );
|
|
173 |
iSlider->ConstructFromResourceL( aParent, 0 ,reader);
|
|
174 |
CleanupStack::PopAndDestroy(); // reader
|
|
175 |
TRect rect = TRect( TPoint( (aRect.iBr.iX - iSlider->Size().iWidth),(aRect.iTl.iY) ),TSize( iSlider->Size() ) );
|
|
176 |
iSlider->SetRect(rect);
|
|
177 |
|
|
178 |
/* Draw the Min and Max Zoom */
|
|
179 |
TParse parse;
|
|
180 |
parse.Set( KMyBitmapRomFile, &KDC_APP_RESOURCE_DIR, NULL );
|
|
181 |
CFbsBitmap* bitmap = NULL;
|
|
182 |
CFbsBitmap* mask = NULL;
|
|
183 |
AknsUtils::CreateIconL(AknsUtils::SkinInstance(),
|
|
184 |
KAknsIIDQsnBgScreen,
|
|
185 |
bitmap,
|
|
186 |
mask,
|
|
187 |
parse.FullName(),
|
|
188 |
EMbmMusuiiconsQgn_indi_browser_tb_zoom_in,
|
|
189 |
EMbmMusuiiconsQgn_indi_browser_tb_zoom_in_mask);
|
|
190 |
iSlider->SetGraphics(CAknSlider::EElemEmptyLeftCap,bitmap,mask);
|
|
191 |
AknsUtils::CreateIconL(AknsUtils::SkinInstance(),
|
|
192 |
KAknsIIDQsnBgScreen,
|
|
193 |
bitmap,
|
|
194 |
mask,
|
|
195 |
parse.FullName(),
|
|
196 |
EMbmMusuiiconsQgn_indi_browser_tb_zoom_out,
|
|
197 |
EMbmMusuiiconsQgn_indi_browser_tb_zoom_out_mask);
|
|
198 |
iSlider->SetGraphics(CAknSlider::EElemEmptyRightCap,bitmap,mask);
|
|
199 |
}
|
|
200 |
|
|
201 |
iSlider->HandleResourceChange(
|
|
202 |
KEikMessageCaptionedControlEditableStateChange );
|
|
203 |
iSlider->SetObserver( this );
|
|
204 |
iSlider->SetPositionIndicators( CAknSlider::EPosMarker );
|
|
205 |
iSlider->SetTicksEnabled( EFalse );
|
|
206 |
iSlider->EnableDrag();
|
|
207 |
iSlider->SetStepSize( 1 );
|
|
208 |
|
|
209 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::ConstructL()" );
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
// -----------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
// -----------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void CMusUiLevelIndicator::SetLevelL( TMusUiIndicatorType aType,
|
|
218 |
TInt aLevel,
|
|
219 |
TBool aUseTimer )
|
|
220 |
{
|
|
221 |
MUS_LOG1( "mus: [MUSUI ] -> CMusUiLevelIndicator::SetLevelL( %d ) ",
|
|
222 |
aLevel );
|
|
223 |
if ( aLevel >= iMinLevel && aLevel <= iMaxLevel )
|
|
224 |
{
|
|
225 |
switch(aType)
|
|
226 |
{
|
|
227 |
case EMusUiIndicatorTypeZoom:
|
|
228 |
{
|
|
229 |
iZoomLevel=aLevel;
|
|
230 |
break;
|
|
231 |
}
|
|
232 |
case EMusUiIndicatorTypeBrightness:
|
|
233 |
{
|
|
234 |
iBrightnessLevel=aLevel;
|
|
235 |
break;
|
|
236 |
}
|
|
237 |
case EMusUiIndicatorTypeDuration:
|
|
238 |
{
|
|
239 |
iDurationLevel=aLevel;
|
|
240 |
break;
|
|
241 |
}
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
// Set it to the slider
|
|
246 |
if ( !iSliderEventTimer->IsActive() )
|
|
247 |
{
|
|
248 |
iSlider->SetValueL( aLevel );
|
|
249 |
}
|
|
250 |
|
|
251 |
DrawNow();
|
|
252 |
|
|
253 |
if ( aUseTimer )
|
|
254 |
{
|
|
255 |
iDisableLevelTimer->After( KMusUiLevelDisableTime );
|
|
256 |
}
|
|
257 |
|
|
258 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::SetLevelL()" );
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
// -----------------------------------------------------------------------------
|
|
263 |
//
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
TInt CMusUiLevelIndicator::GetLevel( TMusUiIndicatorType aType )
|
|
267 |
{
|
|
268 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::GetLevel()" );
|
|
269 |
|
|
270 |
TInt ret=KErrNotFound;
|
|
271 |
|
|
272 |
switch(aType)
|
|
273 |
{
|
|
274 |
case EMusUiIndicatorTypeZoom:
|
|
275 |
{
|
|
276 |
ret=iZoomLevel;
|
|
277 |
break;
|
|
278 |
}
|
|
279 |
case EMusUiIndicatorTypeBrightness:
|
|
280 |
{
|
|
281 |
ret=iBrightnessLevel;
|
|
282 |
break;
|
|
283 |
}
|
|
284 |
|
|
285 |
case EMusUiIndicatorTypeDuration:
|
|
286 |
{
|
|
287 |
ret = iSlider->Value();
|
|
288 |
break;
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::GetLevel()" );
|
|
293 |
return ret;
|
|
294 |
}
|
|
295 |
|
|
296 |
|
|
297 |
// -----------------------------------------------------------------------------
|
|
298 |
//
|
|
299 |
// -----------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CMusUiLevelIndicator::SetRange( TInt aMinLevel,
|
|
302 |
TInt aMaxLevel,
|
|
303 |
TBool aUseTimer)
|
|
304 |
{
|
|
305 |
MUS_LOG2( "mus: [MUSUI ] -> CMusUiLevelIndicator::SetRange( %d - %d ) ",
|
|
306 |
aMinLevel, aMaxLevel );
|
|
307 |
|
|
308 |
if( aMinLevel < aMaxLevel )
|
|
309 |
{
|
|
310 |
iMinLevel = aMinLevel;
|
|
311 |
iMaxLevel = aMaxLevel;
|
|
312 |
iSlider->SetRange( iMinLevel, iMaxLevel );
|
|
313 |
}
|
|
314 |
|
|
315 |
if ( aUseTimer )
|
|
316 |
{
|
|
317 |
iDisableLevelTimer->After( KMusUiLevelDisableTime );
|
|
318 |
}
|
|
319 |
|
|
320 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::SetRange()" );
|
|
321 |
}
|
|
322 |
|
|
323 |
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
//
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
void CMusUiLevelIndicator::SetIndicatorType( TMusUiIndicatorType aType )
|
|
329 |
{
|
|
330 |
iIndicatorType = aType;
|
|
331 |
}
|
|
332 |
|
|
333 |
|
|
334 |
// -----------------------------------------------------------------------------
|
|
335 |
//
|
|
336 |
// -----------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
TMusUiIndicatorType CMusUiLevelIndicator::GetIndicatorType()
|
|
339 |
{
|
|
340 |
return iIndicatorType;
|
|
341 |
}
|
|
342 |
|
|
343 |
|
|
344 |
// -----------------------------------------------------------------------------
|
|
345 |
//
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
//
|
|
348 |
void CMusUiLevelIndicator::SizeChanged()
|
|
349 |
{
|
|
350 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::SizeChanged()" );
|
|
351 |
|
|
352 |
if ( iSlider )
|
|
353 |
{
|
|
354 |
iSlider->SetRect( Rect() );
|
|
355 |
}
|
|
356 |
|
|
357 |
DrawNow();
|
|
358 |
|
|
359 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::SizeChanged()" );
|
|
360 |
}
|
|
361 |
|
|
362 |
|
|
363 |
// -----------------------------------------------------------------------------
|
|
364 |
//
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
void CMusUiLevelIndicator::Draw( const TRect& aRect ) const
|
|
367 |
{
|
|
368 |
CWindowGc& gc = SystemGc();
|
|
369 |
gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
|
|
370 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
371 |
gc.Clear( aRect );
|
|
372 |
}
|
|
373 |
|
|
374 |
|
|
375 |
// -----------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
TInt CMusUiLevelIndicator::CountComponentControls() const
|
|
380 |
{
|
|
381 |
return 1; // return nbr of controls inside this container
|
|
382 |
}
|
|
383 |
|
|
384 |
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
// Called by framework to retrieve the control specified by index.
|
|
387 |
// -----------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
CCoeControl* CMusUiLevelIndicator::ComponentControl( TInt aIndex ) const
|
|
390 |
{
|
|
391 |
switch ( aIndex )
|
|
392 |
{
|
|
393 |
case 0:
|
|
394 |
{
|
|
395 |
return iSlider;
|
|
396 |
}
|
|
397 |
default:
|
|
398 |
{
|
|
399 |
return NULL;
|
|
400 |
}
|
|
401 |
}
|
|
402 |
}
|
|
403 |
|
|
404 |
|
|
405 |
// -----------------------------------------------------------------------------
|
|
406 |
//
|
|
407 |
// -----------------------------------------------------------------------------
|
|
408 |
//
|
|
409 |
void CMusUiLevelIndicator::HandleResourceChange( TInt aType )
|
|
410 |
{
|
|
411 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiLevelIndicator::HandleResourceChange()" );
|
|
412 |
|
|
413 |
if( aType==KEikDynamicLayoutVariantSwitch )
|
|
414 |
{
|
|
415 |
if ( iSlider ) // Force a re-layout
|
|
416 |
{
|
|
417 |
iSlider->SetRect( Rect() );
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
DrawNow();
|
|
422 |
|
|
423 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiLevelIndicator::HandleResourceChange()" );
|
|
424 |
}
|
|
425 |
|
|
426 |
|
|
427 |
// -----------------------------------------------------------------------------
|
|
428 |
//
|
|
429 |
// -----------------------------------------------------------------------------
|
|
430 |
//
|
|
431 |
void CMusUiLevelIndicator::HandleControlEventL( CCoeControl* aControl,
|
|
432 |
TCoeEvent aEventType)
|
|
433 |
{
|
|
434 |
// No logging due to huge amount of events
|
|
435 |
|
|
436 |
if ( aControl == iSlider &&
|
|
437 |
aEventType == MCoeControlObserver::EEventStateChanged )
|
|
438 |
{
|
|
439 |
// Restart the disable timer if running
|
|
440 |
if ( iDisableLevelTimer->IsActive() )
|
|
441 |
{
|
|
442 |
iDisableLevelTimer->After( KMusUiLevelDisableTime );
|
|
443 |
}
|
|
444 |
|
|
445 |
if ( iObserver )
|
|
446 |
{
|
|
447 |
iSliderEventTimer->After( KMusUiSliderEventDelay );
|
|
448 |
}
|
|
449 |
}
|
|
450 |
|
|
451 |
// No logging due to huge amount of events
|
|
452 |
}
|
|
453 |
|
|
454 |
|
|
455 |
// -----------------------------------------------------------------------------
|
|
456 |
//
|
|
457 |
// -----------------------------------------------------------------------------
|
|
458 |
//
|
|
459 |
void CMusUiLevelIndicator::TimerComplete( CMusUiActiveTimer* aTimer )
|
|
460 |
{
|
|
461 |
if ( aTimer == iSliderEventTimer )
|
|
462 |
{
|
|
463 |
MUS_LOG( "mus: [MUSUI ] Slider event timer complete" );
|
|
464 |
|
|
465 |
if ( iObserver )
|
|
466 |
{
|
|
467 |
iObserver->IndicatorLevelChanged( iSlider->Value() );
|
|
468 |
}
|
|
469 |
}
|
|
470 |
else if ( aTimer == iDisableLevelTimer )
|
|
471 |
{
|
|
472 |
MUS_LOG( "mus: [MUSUI ] Slider visibility timer complete" );
|
|
473 |
|
|
474 |
if ( iObserver )
|
|
475 |
{
|
|
476 |
iObserver->SetLevelIndicatorVisibility( EFalse );
|
|
477 |
}
|
|
478 |
}
|
|
479 |
else
|
|
480 |
{
|
|
481 |
// NOP
|
|
482 |
}
|
|
483 |
}
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
// End of File
|
|
488 |
|
|
489 |
|
|
490 |
|