25
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 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:
|
|
15 |
* A compound control class. It is responsible for drawing and updating
|
|
16 |
* a set of labels, and a progress bar.
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#include <AknUtils.h>
|
|
24 |
#include <AknsUtils.h>
|
|
25 |
#include <eikprogi.h>
|
|
26 |
#include <aknenv.h>
|
|
27 |
#include <applayout.cdl.h>
|
|
28 |
#include <aknview.h>
|
|
29 |
#include <aknViewAppUi.h>
|
|
30 |
#include <AknDef.h>
|
|
31 |
#include <AknsConstants.h>
|
|
32 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
33 |
|
|
34 |
#include "CVRLabel.h"
|
|
35 |
#include "CVRStateInfoPanel.h"
|
|
36 |
#include "MVRStateInfoModel.h"
|
|
37 |
#include "voicerecorder.hrh"
|
|
38 |
#include "VRConsts.h"
|
|
39 |
|
|
40 |
// CONSTANTS
|
|
41 |
const TInt KVRLabelMap[] =
|
|
42 |
{
|
|
43 |
CVRStateInfoPanel::ELabelName,
|
|
44 |
CVRStateInfoPanel::ELabelDate,
|
|
45 |
CVRStateInfoPanel::ELabelQuality,
|
|
46 |
CVRStateInfoPanel::ELabelStatus,
|
|
47 |
CVRStateInfoPanel::ELabelMax,
|
|
48 |
CVRStateInfoPanel::ELabelMin,
|
|
49 |
CVRStateInfoPanel::ELabelQualityText
|
|
50 |
};
|
|
51 |
|
|
52 |
_LIT( KVREmptyLabel, " " );
|
|
53 |
|
|
54 |
|
|
55 |
// ================= MEMBER FUNCTIONS ========================================
|
|
56 |
|
|
57 |
// ----------------------------------------------------------------------------
|
|
58 |
// CVRStateInfoPanel::CVRStateInfoPanel
|
|
59 |
//
|
|
60 |
// ----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
CVRStateInfoPanel::CVRStateInfoPanel( MVRStateInfoModel* aModel )
|
|
63 |
: iModel( aModel ), iLabels( ENumLabels ), iPBposition( 0 )
|
|
64 |
{
|
|
65 |
if ( iModel )
|
|
66 |
{
|
|
67 |
iModel->SetStateInfoObserver( this );
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
// ----------------------------------------------------------------------------
|
|
73 |
// CVRStateInfoPanel::CVRStateInfoPanel
|
|
74 |
//
|
|
75 |
// ----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
CVRStateInfoPanel::CVRStateInfoPanel( MVRStateInfoModel* aModel,
|
|
78 |
TUid aParentViewUid )
|
|
79 |
: iModel( aModel ),
|
|
80 |
iLabels( ENumLabels ),
|
|
81 |
iParentViewUid( aParentViewUid ),
|
|
82 |
iPBposition( 0 )
|
|
83 |
{
|
|
84 |
if ( iModel )
|
|
85 |
{
|
|
86 |
iModel->SetStateInfoObserver( this );
|
|
87 |
iModel->SetStateInfoPanelObserver( this );
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
// ----------------------------------------------------------------------------
|
|
93 |
// CVRStateInfoPanel::~CVRStateInfoPanel
|
|
94 |
//
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
CVRStateInfoPanel::~CVRStateInfoPanel()
|
|
98 |
{
|
|
99 |
if ( iModel )
|
|
100 |
{
|
|
101 |
iModel->SetStateInfoObserver( NULL );
|
|
102 |
}
|
|
103 |
iLabels.ResetAndDestroy();
|
|
104 |
delete iProgressBar;
|
|
105 |
iSkin = NULL;
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
// ----------------------------------------------------------------------------
|
|
110 |
// CVRStateInfoPanel::ConstructL
|
|
111 |
//
|
|
112 |
// ----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
void CVRStateInfoPanel::ConstructL()
|
|
115 |
{
|
|
116 |
// New skin instance is loaded
|
|
117 |
iSkin = AknsUtils::SkinInstance();
|
|
118 |
|
|
119 |
// Create labels
|
|
120 |
for ( TInt i = 0; i < ENumLabels; i++ )
|
|
121 |
{
|
|
122 |
CVRLabel* label = CVRLabel::NewLC( *this );
|
|
123 |
|
|
124 |
// Set the MOP-parent so that the labels can get the
|
|
125 |
// skin context from rec view container
|
|
126 |
label->SetMopParent( this );
|
|
127 |
iLabels.AppendL( label );
|
|
128 |
CleanupStack::Pop(); // label;
|
|
129 |
|
|
130 |
// Set initial text for label
|
|
131 |
TBuf< VRLABELMAXLENGTH > str;
|
|
132 |
iModel->GetLabel( str, i );
|
|
133 |
label->SetText( str );
|
|
134 |
}
|
|
135 |
|
|
136 |
CreateProgressBarL();
|
|
137 |
UpdateLayoutL();
|
|
138 |
}
|
|
139 |
|
|
140 |
|
|
141 |
// ----------------------------------------------------------------------------
|
|
142 |
// CVRStateInfoPanel::CreateProgressBarL
|
|
143 |
//
|
|
144 |
// ----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CVRStateInfoPanel::CreateProgressBarL()
|
|
147 |
{
|
|
148 |
delete iProgressBar;
|
|
149 |
iProgressBar = NULL;
|
|
150 |
|
|
151 |
// Create progress bar
|
|
152 |
CEikProgressInfo::SInfo info = ProgressInfo();
|
|
153 |
|
|
154 |
iProgressBar = new( ELeave ) CEikProgressInfo( info );
|
|
155 |
iProgressBar->SetContainerWindowL( *this );
|
|
156 |
|
|
157 |
// Set the MOP-parent so that the progress bar can get the
|
|
158 |
// skin context from rec view container
|
|
159 |
iProgressBar->SetMopParent( this );
|
|
160 |
iProgressBar->ConstructL();
|
|
161 |
|
|
162 |
iProgressBar->ActivateL();
|
|
163 |
AknLayoutUtils::LayoutControl( iProgressBar, Rect(),
|
|
164 |
AppLayout::Voice_Recorder_elements_Line_4() );
|
|
165 |
}
|
|
166 |
|
|
167 |
|
|
168 |
// ----------------------------------------------------------------------------
|
|
169 |
// CVRStateInfoPanel::SizeChanged
|
|
170 |
//
|
|
171 |
// ----------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CVRStateInfoPanel::SizeChanged()
|
|
174 |
{
|
|
175 |
TAknTextComponentLayout layoutText;
|
|
176 |
|
|
177 |
for ( TInt i = 0; i < ENumLabels; i++ )
|
|
178 |
{
|
|
179 |
switch ( KVRLabelMap[i] )
|
|
180 |
{
|
|
181 |
case 0:
|
|
182 |
layoutText = AknLayoutScalable_Apps::vorec_t1();
|
|
183 |
break;
|
|
184 |
case 1:
|
|
185 |
layoutText = AknLayoutScalable_Apps::vorec_t2();
|
|
186 |
break;
|
|
187 |
case 2:
|
|
188 |
layoutText = AknLayoutScalable_Apps::vorec_t3();
|
|
189 |
break;
|
|
190 |
case 3:
|
|
191 |
layoutText = AknLayoutScalable_Apps::vorec_t4();
|
|
192 |
break;
|
|
193 |
case 4:
|
|
194 |
layoutText = AknLayoutScalable_Apps::vorec_t5();
|
|
195 |
break;
|
|
196 |
case 5:
|
|
197 |
layoutText = AknLayoutScalable_Apps::vorec_t6();
|
|
198 |
break;
|
|
199 |
case 6:
|
|
200 |
layoutText = AknLayoutScalable_Apps::vorec_t7();
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
AknLayoutUtils::LayoutLabel( iLabels.At( i ), Rect(), layoutText.LayoutLine() );
|
|
204 |
|
|
205 |
CCoeControl* label( iLabels.At( i ) );
|
|
206 |
TRgb color( KRgbBlack );
|
|
207 |
AknsUtils::GetCachedColor( iSkin, color, KAknsIIDQsnTextColors,
|
|
208 |
EAknsCIQsnTextColorsCG6 );
|
|
209 |
// We can ignore the error, it only means we will have wrong color
|
|
210 |
TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *label,
|
|
211 |
EColorLabelText, color ) );
|
|
212 |
}
|
|
213 |
|
|
214 |
// There's nothing rational to do here if it leaves
|
|
215 |
TRAP_IGNORE( CreateProgressBarL() );
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
// ----------------------------------------------------------------------------
|
|
220 |
// CVRStateInfoPanel::Draw
|
|
221 |
//
|
|
222 |
// ----------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
void CVRStateInfoPanel::Draw( const TRect& /*aRect*/ ) const
|
|
225 |
{
|
|
226 |
}
|
|
227 |
|
|
228 |
|
|
229 |
// ----------------------------------------------------------------------------
|
|
230 |
// CVRStateInfoPanel::CountComponentControls
|
|
231 |
//
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
TInt CVRStateInfoPanel::CountComponentControls() const
|
|
235 |
{
|
|
236 |
TInt componentCount( 0 );
|
|
237 |
if ( iProgressBar )
|
|
238 |
{
|
|
239 |
componentCount = ENumLabels + 1; // +1 means iProgressBar
|
|
240 |
}
|
|
241 |
return componentCount;
|
|
242 |
}
|
|
243 |
|
|
244 |
|
|
245 |
// ----------------------------------------------------------------------------
|
|
246 |
// CVRStateInfoPanel::ComponentControl
|
|
247 |
//
|
|
248 |
// ----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
CCoeControl* CVRStateInfoPanel::ComponentControl( TInt aIndex ) const
|
|
251 |
{
|
|
252 |
if ( aIndex < ENumLabels )
|
|
253 |
{
|
|
254 |
return iLabels.At( aIndex );
|
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
return iProgressBar;
|
|
259 |
}
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
// ----------------------------------------------------------------------------
|
|
264 |
// CVRStateInfoPanel::Update
|
|
265 |
//
|
|
266 |
// ----------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
void CVRStateInfoPanel::Update( TVRUpdateCommand /*aCommand*/ )
|
|
269 |
{
|
|
270 |
for ( TInt i = 0; i < ENumLabels; i++ )
|
|
271 |
{
|
|
272 |
TBuf< VRLABELMAXLENGTH > str;
|
|
273 |
iModel->GetLabel( str, i );
|
|
274 |
if ( str.Length() < 1 )
|
|
275 |
{
|
|
276 |
// "" doesn't empty the label, so use space
|
|
277 |
str = KVREmptyLabel;
|
|
278 |
}
|
|
279 |
iLabels.At( i )->SetTextAndDraw( str );
|
|
280 |
}
|
|
281 |
|
|
282 |
UpdateProgressBar();
|
|
283 |
|
|
284 |
}
|
|
285 |
|
|
286 |
|
|
287 |
// ----------------------------------------------------------------------------
|
|
288 |
// CVRStateInfoPanel::UpdateLayoutL
|
|
289 |
//
|
|
290 |
// ----------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
void CVRStateInfoPanel::UpdateLayoutL()
|
|
293 |
{
|
|
294 |
SizeChanged();
|
|
295 |
}
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
// ----------------------------------------------------------------------------
|
|
300 |
// CVRStateInfoPanel::ProgressInfo
|
|
301 |
//
|
|
302 |
// ----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
CEikProgressInfo::SInfo CVRStateInfoPanel::ProgressInfo()
|
|
305 |
{
|
|
306 |
CEikProgressInfo::SInfo info;
|
|
307 |
|
|
308 |
TAknWindowLineLayout infobarLayout =
|
|
309 |
AppLayout::Voice_Recorder_elements_Line_4();
|
|
310 |
TAknLayoutRect infobarRect;
|
|
311 |
infobarRect.LayoutRect( Rect(), infobarLayout );
|
|
312 |
|
|
313 |
info.iWidth = infobarRect.Rect().Width();
|
|
314 |
info.iHeight = infobarRect.Rect().Height();
|
|
315 |
|
|
316 |
return info;
|
|
317 |
}
|
|
318 |
|
|
319 |
|
|
320 |
// ----------------------------------------------------------------------------
|
|
321 |
// CVRStateInfoPanel::HandleResourceChangeL
|
|
322 |
//
|
|
323 |
// ----------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CVRStateInfoPanel::HandleResourceChangeL( TInt aType )
|
|
326 |
{
|
|
327 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
328 |
{
|
|
329 |
UpdateLayoutL();
|
|
330 |
}
|
|
331 |
else if ( aType == KAknsMessageSkinChange )
|
|
332 |
{
|
|
333 |
// New skin instance is loaded
|
|
334 |
iSkin = AknsUtils::SkinInstance();
|
|
335 |
}
|
|
336 |
|
|
337 |
for ( TInt i = 0; i < ENumLabels; i++ )
|
|
338 |
{
|
|
339 |
if ( i < iLabels.Count() )
|
|
340 |
{
|
|
341 |
iLabels.At( i )->HandleResourceChange( aType );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
iProgressBar->HandleResourceChange( aType );
|
|
346 |
UpdateProgressBar();
|
|
347 |
|
|
348 |
CCoeControl::HandleResourceChange( aType );
|
|
349 |
}
|
|
350 |
|
|
351 |
|
|
352 |
// ----------------------------------------------------------------------------
|
|
353 |
// CVRStateInfoPanel::UpdateProgressBar
|
|
354 |
//
|
|
355 |
// ----------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CVRStateInfoPanel::UpdateProgressBar()
|
|
358 |
{
|
|
359 |
|
|
360 |
if ( iProgressBar )
|
|
361 |
{
|
|
362 |
if ( iModel->HasProgressBar() )
|
|
363 |
{
|
|
364 |
iProgressBar->SetFinalValue( I64INT( iModel->Duration().Int64() /
|
|
365 |
KVRSecondAsMicroSeconds ) );
|
|
366 |
iProgressBar->SetAndDraw( I64INT( iModel->Position().Int64() /
|
|
367 |
KVRSecondAsMicroSeconds ) );
|
|
368 |
iProgressBar->MakeVisible( ETrue );
|
|
369 |
|
|
370 |
iPBposition = I64INT( iModel->Position().Int64() /
|
|
371 |
KVRSecondAsMicroSeconds );
|
|
372 |
}
|
|
373 |
else
|
|
374 |
{
|
|
375 |
iProgressBar->MakeVisible( EFalse );
|
|
376 |
}
|
|
377 |
}
|
|
378 |
}
|
|
379 |
|
|
380 |
|
|
381 |
// ----------------------------------------------------------------------------
|
|
382 |
// CVRStateInfoPanel::HandlePointerEventL
|
|
383 |
// From CCoeControl
|
|
384 |
// ----------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
void CVRStateInfoPanel::HandlePointerEventL( const TPointerEvent&
|
|
387 |
aPointerEvent )
|
|
388 |
{
|
|
389 |
if( AknLayoutUtils::PenEnabled() && iModel->HasProgressBar() &&
|
|
390 |
iProgressBar )
|
|
391 |
{
|
|
392 |
CCoeControl::HandlePointerEventL( aPointerEvent );
|
|
393 |
|
|
394 |
switch( aPointerEvent.iType )
|
|
395 |
{
|
|
396 |
case TPointerEvent::EButton1Down:
|
|
397 |
{
|
|
398 |
TRect progressBarRect( iProgressBar->Rect() );
|
|
399 |
// Check if pressed position is in progress bar's rect
|
|
400 |
if( progressBarRect.Contains( aPointerEvent.iPosition ) )
|
|
401 |
{
|
|
402 |
HandleProgressBarTouchL( progressBarRect,
|
|
403 |
aPointerEvent.iPosition.iX );
|
|
404 |
}
|
|
405 |
break;
|
|
406 |
}
|
|
407 |
case TPointerEvent::EDrag:
|
|
408 |
{
|
|
409 |
TRect progressBarRect( iProgressBar->Rect() );
|
|
410 |
if( progressBarRect.Contains( aPointerEvent.iPosition ) )
|
|
411 |
{
|
|
412 |
HandleProgressBarTouchL( progressBarRect,
|
|
413 |
aPointerEvent.iPosition.iX );
|
|
414 |
}
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
case TPointerEvent::EButton1Up:
|
|
418 |
{
|
|
419 |
break;
|
|
420 |
}
|
|
421 |
default:
|
|
422 |
{
|
|
423 |
break;
|
|
424 |
}
|
|
425 |
}
|
|
426 |
}
|
|
427 |
}
|
|
428 |
|
|
429 |
|
|
430 |
// ----------------------------------------------------------------------------
|
|
431 |
// CVRStateInfoPanel::HandleProgressBarTouchL
|
|
432 |
//
|
|
433 |
// ----------------------------------------------------------------------------
|
|
434 |
//
|
|
435 |
void CVRStateInfoPanel::HandleProgressBarTouchL( TRect aPBRect,
|
|
436 |
TInt aPressedPoint )
|
|
437 |
{
|
|
438 |
if ( AknLayoutUtils::PenEnabled() )
|
|
439 |
{
|
|
440 |
#ifdef _DEBUG
|
|
441 |
RDebug::Print( _L( "VoiceRecorder: HandleProgressBarTouchL enter" ) );
|
|
442 |
#endif
|
|
443 |
// Progress Bar start and end points
|
|
444 |
TInt pbEndPoint( aPBRect.iBr.iX );
|
|
445 |
TInt pbStartPoint( aPBRect.iTl.iX );
|
|
446 |
|
|
447 |
TInt totalPBLength( pbEndPoint - pbStartPoint );
|
|
448 |
// calculate what is the time position that was pressed in
|
|
449 |
// the progress bar
|
|
450 |
TTimeIntervalMicroSeconds newPosition(
|
|
451 |
( ( aPressedPoint - pbStartPoint ) *
|
|
452 |
iModel->Duration().Int64() ) /
|
|
453 |
totalPBLength );
|
|
454 |
|
|
455 |
// Round the position to the nearest second value
|
|
456 |
TInt roundedNewPosition( RoundMicroSecsToSecs( newPosition ) );
|
|
457 |
|
|
458 |
// Performace issue. Send command only if value has changed
|
|
459 |
if ( roundedNewPosition != iPBposition )
|
|
460 |
{
|
|
461 |
iPBposition = roundedNewPosition;
|
|
462 |
|
|
463 |
CAknViewAppUi* appUi = reinterpret_cast< CAknViewAppUi* >(
|
|
464 |
CEikonEnv::Static()->EikAppUi() );
|
|
465 |
CAknView* view = appUi->View( iParentViewUid );
|
|
466 |
|
|
467 |
// inform the view that position has changed.
|
|
468 |
view->HandleCommandL( ECmdSetNewPosition );
|
|
469 |
}
|
|
470 |
#ifdef _DEBUG
|
|
471 |
RDebug::Print( _L( "VoiceRecorder: HandleProgressBarTouchL exit" ) );
|
|
472 |
#endif
|
|
473 |
|
|
474 |
} // PenEnabled
|
|
475 |
|
|
476 |
}
|
|
477 |
|
|
478 |
|
|
479 |
// ----------------------------------------------------------------------------
|
|
480 |
// CVRStateInfoPanel::RoundMicroSecsToSecs
|
|
481 |
// Rounds aMicroSecs value to nearest second value (Round)
|
|
482 |
// ----------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
TInt CVRStateInfoPanel::RoundMicroSecsToSecs( TTimeIntervalMicroSeconds
|
|
485 |
aMicroSecs )
|
|
486 |
{
|
|
487 |
// Rounds to secondss resolution (Floor)
|
|
488 |
Int64 secondsInMicroSecs( ( ( aMicroSecs.Int64() /
|
|
489 |
KVRSecondAsMicroSeconds ) *
|
|
490 |
KVRSecondAsMicroSeconds ) );
|
|
491 |
|
|
492 |
// takes the leftover part in seconds resolution
|
|
493 |
Int64 leftoversInMicroSecs ( aMicroSecs.Int64() - secondsInMicroSecs );
|
|
494 |
|
|
495 |
// Nearer to upper sec value
|
|
496 |
if ( leftoversInMicroSecs / ( KVRSecondAsMilliSeconds ) >
|
|
497 |
KVRHalfSecondAsMilliSeconds )
|
|
498 |
{
|
|
499 |
// + 1 sec
|
|
500 |
return ( ( secondsInMicroSecs + KVRSecondAsMicroSeconds ) /
|
|
501 |
KVRSecondAsMicroSeconds );
|
|
502 |
}
|
|
503 |
// Nearer to lower sec value
|
|
504 |
else
|
|
505 |
{
|
|
506 |
return secondsInMicroSecs / KVRSecondAsMicroSeconds;
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
|
|
511 |
// ----------------------------------------------------------------------------
|
|
512 |
// CVRStateInfoPanel::ProgressBarPosition
|
|
513 |
// Just returns the current progress bar position
|
|
514 |
// ----------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
TInt CVRStateInfoPanel::ProgressBarPosition() const
|
|
517 |
{
|
|
518 |
return iPBposition;
|
|
519 |
}
|
|
520 |
|
|
521 |
// End of file
|