66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-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 CMIDGaugeItem
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <coemain.h>
|
|
20 |
#include <e32std.h>
|
|
21 |
#include <eikcapc.h>
|
|
22 |
// CAknSlider - needed for iSlider member
|
|
23 |
#include <aknslider.h>
|
|
24 |
// macros for resources
|
|
25 |
#include <lcdui.rsg>
|
|
26 |
// using TMifAvkon enumeration
|
|
27 |
#include <avkon.mbg>
|
|
28 |
// Api for skin instance
|
|
29 |
// and creating icons
|
|
30 |
#include <AknsUtils.h>
|
|
31 |
|
|
32 |
// needed CEikProgressInfo API for iProgressInfo member
|
|
33 |
// control used to indicate the progress of an operation
|
|
34 |
#include <eikprogi.h>
|
|
35 |
#include <eikon.hrh>
|
|
36 |
#include <eikpanic.h>
|
|
37 |
// using TResourceReader class in ConstructSliderL (interactive gauge)
|
|
38 |
// interprets resource data read from a resource file
|
|
39 |
#include <barsread.h>
|
|
40 |
#include <gulbordr.h>
|
|
41 |
#include <eikenv.h>
|
|
42 |
// API use to retrieve info if pen is enabled (PenEnabled) in HandlePointerEventL function
|
|
43 |
#include <AknUtils.h> // for arabic texts support
|
|
44 |
#include <gulcolor.h>
|
|
45 |
|
|
46 |
// using AknsDrawUtils for drawing background
|
|
47 |
#include <AknsDrawUtils.h>
|
|
48 |
#include <applayout.cdl.h>
|
|
49 |
|
|
50 |
// for MAknsControlContext::SupplyMopObject method
|
|
51 |
#include <AknsFrameBackgroundControlContext.h>
|
|
52 |
// LAF
|
|
53 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
54 |
|
|
55 |
#include <AknDef.h> // For layout change event definitions
|
|
56 |
|
|
57 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
58 |
#include <touchfeedback.h>
|
|
59 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
60 |
|
|
61 |
#include <j2me/jdebug.h>
|
|
62 |
#include "CMIDGaugeItem.h"
|
|
63 |
// API used for obtain info about command count for IsSelectable function
|
|
64 |
#include "CMIDCommandList.h"
|
|
65 |
// API for iLabelControl (inherited from CMIDControlItem)
|
|
66 |
#include "CMIDItemLabel.h"
|
|
67 |
// using TlsStruct for creating bitmap storage
|
|
68 |
#include "CMIDMenuHandler.h"
|
|
69 |
#include "CMIDUtils.h"
|
|
70 |
#include "CMIDUIManager.h"
|
|
71 |
// Using of CAknBitmapAnimation for iBitmapAnimation
|
|
72 |
#include <AknBitmapAnimation.h>
|
|
73 |
|
|
74 |
//
|
|
75 |
// Constants
|
|
76 |
//
|
|
77 |
const TInt KDelayInMicroSeconds = 50000;
|
|
78 |
const TInt KContRunningAnimFramesCount = 7;
|
|
79 |
const TInt KIncUpdatingAnimFramesCount = 19;
|
|
80 |
// Divider to correct pointerEvent y-coordinate close to graphics center
|
|
81 |
const TInt KSliderHeightDivider = 3;
|
|
82 |
|
|
83 |
|
|
84 |
// class CGaugeTimer
|
|
85 |
|
|
86 |
inline CMIDGaugeItem::CGaugeTimer::CGaugeTimer(CMIDGaugeItem& aGauge)
|
|
87 |
:CTimer(CActive::EPriorityStandard),iGauge(aGauge)
|
|
88 |
{
|
|
89 |
CActiveScheduler::Add(this);
|
|
90 |
}
|
|
91 |
|
|
92 |
CMIDGaugeItem::CGaugeTimer* CMIDGaugeItem::CGaugeTimer::NewL(CMIDGaugeItem& aGauge)
|
|
93 |
{
|
|
94 |
CGaugeTimer* self = new(ELeave) CGaugeTimer(aGauge);
|
|
95 |
CleanupStack::PushL(self);
|
|
96 |
self->ConstructL();
|
|
97 |
CleanupStack::Pop(self);
|
|
98 |
return self;
|
|
99 |
}
|
|
100 |
|
|
101 |
void CMIDGaugeItem::CGaugeTimer::RunL()
|
|
102 |
{
|
|
103 |
if (!iGauge.iGaugeFrameData)
|
|
104 |
{
|
|
105 |
//if the bitmaps haven't been created it means we are inside an alert,
|
|
106 |
//which is using its own bitmaps for the gauge animation.
|
|
107 |
//Return without restarting the timer
|
|
108 |
return;
|
|
109 |
}
|
|
110 |
|
|
111 |
iGauge.iValue++;
|
|
112 |
|
|
113 |
if (iGauge.iValue >= iGauge.iGaugeFrameData->iContRunBitmap.Count())
|
|
114 |
{
|
|
115 |
iGauge.iValue = 0;
|
|
116 |
}
|
|
117 |
|
|
118 |
CMIDNonInteractiveGauge* nig = static_cast<CMIDNonInteractiveGauge*>(&iGauge);
|
|
119 |
nig->DoSafeDraw();
|
|
120 |
|
|
121 |
After(TTimeIntervalMicroSeconds32(KDelayInMicroSeconds));
|
|
122 |
}
|
|
123 |
|
|
124 |
|
|
125 |
// class CMIDGaugeItem
|
|
126 |
|
|
127 |
|
|
128 |
TInt CMIDGaugeItem::GetValue()
|
|
129 |
{
|
|
130 |
return iValue;
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
CMIDGaugeItem::CMIDGaugeItem(CMIDUIManager* aUIManager)
|
|
138 |
: CMIDControlItem(EDefault, aUIManager),
|
|
139 |
iIndefiniteState(EIncrementalIdle),
|
|
140 |
iGaugeFrameData(NULL)
|
|
141 |
{
|
|
142 |
iMMidItem = this;
|
|
143 |
}
|
|
144 |
|
|
145 |
CMIDGaugeItem::~CMIDGaugeItem()
|
|
146 |
{
|
|
147 |
if (iGaugeFrameData)
|
|
148 |
{
|
|
149 |
iGaugeFrameData->iNumInstances--;
|
|
150 |
|
|
151 |
if (!(iGaugeFrameData->iNumInstances))
|
|
152 |
{
|
|
153 |
// delete bitmaps from thread-local bitmap storage
|
|
154 |
DeleteBitmapsInTls();
|
|
155 |
iGaugeFrameData->Close();
|
|
156 |
delete iGaugeFrameData;
|
|
157 |
iUIManager->SetGaugeItemData(NULL);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
void CMIDGaugeItem::BaseConstructL(const TDesC& aLabel,TInt aMaxValue,TInt aInitialValue)
|
|
164 |
{
|
|
165 |
DEBUG("CMIDGaugeItem::BaseConstructL <");
|
|
166 |
|
|
167 |
CMIDControlItem::ConstructL();
|
|
168 |
SetLabelL(aLabel);
|
|
169 |
|
|
170 |
iLabelControl->SetWidthL(FormClientAreaWidth());
|
|
171 |
|
|
172 |
if (aMaxValue == 0)
|
|
173 |
{
|
|
174 |
aMaxValue = 1;
|
|
175 |
}
|
|
176 |
|
|
177 |
iMaxValue = aMaxValue;
|
|
178 |
iValue = aInitialValue;
|
|
179 |
|
|
180 |
iIndefinite = (aMaxValue == EIndefinite) ? ETrue : EFalse;
|
|
181 |
|
|
182 |
if (iIndefinite)
|
|
183 |
{
|
|
184 |
iIndefiniteState = aInitialValue;
|
|
185 |
iValue = 0;
|
|
186 |
}
|
|
187 |
|
|
188 |
DEBUG("CMIDGaugeItem::BaseConstructL >");
|
|
189 |
}
|
|
190 |
|
|
191 |
void CMIDGaugeItem::CreateBitmapsIfNeededL()
|
|
192 |
{
|
|
193 |
if (iGaugeFrameData)
|
|
194 |
{
|
|
195 |
return;
|
|
196 |
}
|
|
197 |
iGaugeFrameData = reinterpret_cast< TGaugeFrameData* >(iUIManager->GetGaugeItemData());
|
|
198 |
if (iGaugeFrameData)
|
|
199 |
{
|
|
200 |
iGaugeFrameData->iNumInstances++;
|
|
201 |
}
|
|
202 |
else
|
|
203 |
{
|
|
204 |
// Create shared data
|
|
205 |
iGaugeFrameData = new(ELeave) TGaugeFrameData;
|
|
206 |
iGaugeFrameData->Clean();
|
|
207 |
iUIManager->SetGaugeItemData(reinterpret_cast< void* >(iGaugeFrameData));
|
|
208 |
// Initialize data
|
|
209 |
CreateBitmapsInTlsL();
|
|
210 |
// Resize data
|
|
211 |
ResizeBitmapsInTlsL();
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
|
|
216 |
void CMIDGaugeItem::CreateBitmapsInTlsL()
|
|
217 |
{
|
|
218 |
// check if thread-local bitmap storage is created
|
|
219 |
if (!iGaugeFrameData)
|
|
220 |
{
|
|
221 |
return;
|
|
222 |
}
|
|
223 |
|
|
224 |
// eventually delete existing bitmaps
|
|
225 |
DeleteBitmapsInTls();
|
|
226 |
|
|
227 |
// skin instance and default bitmaps file
|
|
228 |
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
|
|
229 |
TFileName avkonbmpFilename = AknIconUtils::AvkonIconFileName();
|
|
230 |
|
|
231 |
// for bitmap loading
|
|
232 |
const TAknsItemID* aknsItemId;
|
|
233 |
TInt bitmapId;
|
|
234 |
TInt bitmapMaskId;
|
|
235 |
CFbsBitmap* bitmap;
|
|
236 |
CFbsBitmap* bitmapMask;
|
|
237 |
TInt i;
|
|
238 |
|
|
239 |
// continuous running bitmaps
|
|
240 |
for (i=0; i<KContRunningAnimFramesCount; i++)
|
|
241 |
{
|
|
242 |
switch (i)
|
|
243 |
{
|
|
244 |
case 0:
|
|
245 |
aknsItemId = &KAknsIIDQgnGrafBarWait1;
|
|
246 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_1;
|
|
247 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_1_mask;
|
|
248 |
break;
|
|
249 |
case 1:
|
|
250 |
aknsItemId = &KAknsIIDQgnGrafBarWait2;
|
|
251 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_2;
|
|
252 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_2_mask;
|
|
253 |
break;
|
|
254 |
case 2:
|
|
255 |
aknsItemId = &KAknsIIDQgnGrafBarWait3;
|
|
256 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_3;
|
|
257 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_3_mask;
|
|
258 |
break;
|
|
259 |
case 3:
|
|
260 |
aknsItemId = &KAknsIIDQgnGrafBarWait4;
|
|
261 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_4;
|
|
262 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_4_mask;
|
|
263 |
break;
|
|
264 |
case 4:
|
|
265 |
aknsItemId = &KAknsIIDQgnGrafBarWait5;
|
|
266 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_5;
|
|
267 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_5_mask;
|
|
268 |
break;
|
|
269 |
case 5:
|
|
270 |
aknsItemId = &KAknsIIDQgnGrafBarWait6;
|
|
271 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_6;
|
|
272 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_6_mask;
|
|
273 |
break;
|
|
274 |
default:
|
|
275 |
aknsItemId = &KAknsIIDQgnGrafBarWait7;
|
|
276 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_7;
|
|
277 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
278 |
break;
|
|
279 |
}
|
|
280 |
|
|
281 |
AknsUtils::CreateIconL(skinInstance, *aknsItemId, bitmap,
|
|
282 |
bitmapMask, avkonbmpFilename, bitmapId, bitmapMaskId);
|
|
283 |
|
|
284 |
TInt appendErr1 = iGaugeFrameData->iContRunBitmap.Append(bitmap);
|
|
285 |
TInt appendErr2 = iGaugeFrameData->iContRunBitmapMask.Append(bitmapMask);
|
|
286 |
|
|
287 |
if (appendErr1 != KErrNone)
|
|
288 |
{
|
|
289 |
delete bitmap;
|
|
290 |
}
|
|
291 |
if (appendErr2 != KErrNone)
|
|
292 |
{
|
|
293 |
delete bitmapMask;
|
|
294 |
}
|
|
295 |
if ((appendErr1 != KErrNone) || (appendErr2 != KErrNone))
|
|
296 |
{
|
|
297 |
User::LeaveIfError((appendErr1 != KErrNone) ? appendErr1 : appendErr2);
|
|
298 |
}
|
|
299 |
}
|
|
300 |
|
|
301 |
// incremental updating bitmaps
|
|
302 |
// (bitmaps masks ids "EMbmAvkonQgn_graf_bar_wait_increm_mask" -
|
|
303 |
// "EMbmAvkonQgn_graf_bar_wait_increm_19_mask" are not defined and that's
|
|
304 |
// why masks for continuous running animation are used instead)
|
|
305 |
for (i=0; i<KIncUpdatingAnimFramesCount; i++)
|
|
306 |
{
|
|
307 |
switch (i)
|
|
308 |
{
|
|
309 |
case 0:
|
|
310 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem;
|
|
311 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm;
|
|
312 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_1_mask;
|
|
313 |
break;
|
|
314 |
case 1:
|
|
315 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem02;
|
|
316 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_02;
|
|
317 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_2_mask;
|
|
318 |
break;
|
|
319 |
case 2:
|
|
320 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem03;
|
|
321 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_03;
|
|
322 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_3_mask;
|
|
323 |
break;
|
|
324 |
case 3:
|
|
325 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem04;
|
|
326 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_04;
|
|
327 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_4_mask;
|
|
328 |
break;
|
|
329 |
case 4:
|
|
330 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem05;
|
|
331 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_05;
|
|
332 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_5_mask;
|
|
333 |
break;
|
|
334 |
case 5:
|
|
335 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem06;
|
|
336 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_06;
|
|
337 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_6_mask;
|
|
338 |
break;
|
|
339 |
case 6:
|
|
340 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem07;
|
|
341 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_07;
|
|
342 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
343 |
break;
|
|
344 |
case 7:
|
|
345 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem08;
|
|
346 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_08;
|
|
347 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
348 |
break;
|
|
349 |
case 8:
|
|
350 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem09;
|
|
351 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_09;
|
|
352 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
353 |
break;
|
|
354 |
case 9:
|
|
355 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem10;
|
|
356 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_10;
|
|
357 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
358 |
break;
|
|
359 |
case 10:
|
|
360 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem11;
|
|
361 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_11;
|
|
362 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
363 |
break;
|
|
364 |
case 11:
|
|
365 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem12;
|
|
366 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_12;
|
|
367 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
368 |
break;
|
|
369 |
case 12:
|
|
370 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem13;
|
|
371 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_13;
|
|
372 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
373 |
break;
|
|
374 |
case 13:
|
|
375 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem14;
|
|
376 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_14;
|
|
377 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
378 |
break;
|
|
379 |
case 14:
|
|
380 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem15;
|
|
381 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_15;
|
|
382 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
383 |
break;
|
|
384 |
case 15:
|
|
385 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem16;
|
|
386 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_16;
|
|
387 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
388 |
break;
|
|
389 |
case 16:
|
|
390 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem17;
|
|
391 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_17;
|
|
392 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
393 |
break;
|
|
394 |
case 17:
|
|
395 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem18;
|
|
396 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_18;
|
|
397 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
398 |
break;
|
|
399 |
default:
|
|
400 |
aknsItemId = &KAknsIIDQgnGrafBarWaitIncrem19;
|
|
401 |
bitmapId = EMbmAvkonQgn_graf_bar_wait_increm_19;
|
|
402 |
bitmapMaskId = EMbmAvkonQgn_graf_bar_wait_7_mask;
|
|
403 |
break;
|
|
404 |
}
|
|
405 |
|
|
406 |
AknsUtils::CreateIconL(skinInstance, *aknsItemId, bitmap,
|
|
407 |
bitmapMask, avkonbmpFilename, bitmapId, bitmapMaskId);
|
|
408 |
|
|
409 |
TInt appendErr1 = iGaugeFrameData->iIncUpdBitmap.Append(bitmap);
|
|
410 |
TInt appendErr2 = iGaugeFrameData->iIncUpdBitmapMask.Append(bitmapMask);
|
|
411 |
|
|
412 |
if (appendErr1 != KErrNone)
|
|
413 |
{
|
|
414 |
delete bitmap;
|
|
415 |
}
|
|
416 |
if (appendErr2 != KErrNone)
|
|
417 |
{
|
|
418 |
delete bitmapMask;
|
|
419 |
}
|
|
420 |
if ((appendErr1 != KErrNone) || (appendErr2 != KErrNone))
|
|
421 |
{
|
|
422 |
User::LeaveIfError((appendErr1 != KErrNone) ? appendErr1 : appendErr2);
|
|
423 |
}
|
|
424 |
}
|
|
425 |
|
|
426 |
// continuous idle bitmap
|
|
427 |
// (bitmap mask id "EMbmAvkonQgn_graf_bar_wait_idle_mask" is not
|
|
428 |
// defined and that's why mask for continuous running animation is used instead)
|
|
429 |
AknsUtils::CreateIconL(skinInstance, KAknsIIDQgnGrafBarWaitIdle,
|
|
430 |
iGaugeFrameData->iContIdleBitmap,
|
|
431 |
iGaugeFrameData->iContIdleBitmapMask,
|
|
432 |
avkonbmpFilename,
|
|
433 |
EMbmAvkonQgn_graf_bar_wait_idle, EMbmAvkonQgn_graf_bar_wait_1_mask);
|
|
434 |
|
|
435 |
// incremental idle bitmap
|
|
436 |
// (bitmap mask id "EMbmAvkonQgn_graf_bar_wait_increm_idle_mask" is not
|
|
437 |
// defined and that's why mask for continuous running animation is used instead)
|
|
438 |
AknsUtils::CreateIconL(skinInstance, KAknsIIDQgnGrafBarWaitIncremIdle,
|
|
439 |
iGaugeFrameData->iIncIdleBitmap,
|
|
440 |
iGaugeFrameData->iIncIdleBitmapMask,
|
|
441 |
avkonbmpFilename,
|
|
442 |
EMbmAvkonQgn_graf_bar_wait_increm_idle,
|
|
443 |
EMbmAvkonQgn_graf_bar_wait_1_mask);
|
|
444 |
|
|
445 |
// bar frame bitmaps (left, center and right part of frame)
|
|
446 |
AknsUtils::CreateIconL(skinInstance, KAknsIIDQgnGrafBarFrameSideL,
|
|
447 |
iGaugeFrameData->iFrameL, iGaugeFrameData->iFrameLMask,
|
|
448 |
avkonbmpFilename, EMbmAvkonQgn_graf_bar_frame_side_l,
|
|
449 |
EMbmAvkonQgn_graf_bar_frame_side_l_mask);
|
|
450 |
|
|
451 |
AknsUtils::CreateIconL(skinInstance, KAknsIIDQgnGrafBarFrameCenter,
|
|
452 |
iGaugeFrameData->iFrameCenter, iGaugeFrameData->iFrameCenterMask,
|
|
453 |
avkonbmpFilename, EMbmAvkonQgn_graf_bar_frame_center,
|
|
454 |
EMbmAvkonQgn_graf_bar_frame_center_mask);
|
|
455 |
|
|
456 |
AknsUtils::CreateIconL(skinInstance, KAknsIIDQgnGrafBarFrameSideR,
|
|
457 |
iGaugeFrameData->iFrameR, iGaugeFrameData->iFrameRMask,
|
|
458 |
avkonbmpFilename, EMbmAvkonQgn_graf_bar_frame_side_r,
|
|
459 |
EMbmAvkonQgn_graf_bar_frame_side_r_mask);
|
|
460 |
}
|
|
461 |
|
|
462 |
|
|
463 |
void CMIDGaugeItem::DeleteBitmapsInTls()
|
|
464 |
{
|
|
465 |
// check if thread-local bitmap storage is created
|
|
466 |
if (!iGaugeFrameData)
|
|
467 |
{
|
|
468 |
return;
|
|
469 |
}
|
|
470 |
|
|
471 |
// continuous running bitmaps
|
|
472 |
TInt i;
|
|
473 |
|
|
474 |
for (i=0; i < iGaugeFrameData->iContRunBitmap.Count(); i++)
|
|
475 |
{
|
|
476 |
delete iGaugeFrameData->iContRunBitmap[i];
|
|
477 |
}
|
|
478 |
iGaugeFrameData->iContRunBitmap.Reset();
|
|
479 |
|
|
480 |
for (i=0; i < iGaugeFrameData->iContRunBitmapMask.Count(); i++)
|
|
481 |
{
|
|
482 |
delete iGaugeFrameData->iContRunBitmapMask[i];
|
|
483 |
}
|
|
484 |
iGaugeFrameData->iContRunBitmapMask.Reset();
|
|
485 |
|
|
486 |
// incremental updating bitmaps
|
|
487 |
for (i=0; i < iGaugeFrameData->iIncUpdBitmap.Count(); i++)
|
|
488 |
{
|
|
489 |
delete iGaugeFrameData->iIncUpdBitmap[i];
|
|
490 |
}
|
|
491 |
iGaugeFrameData->iIncUpdBitmap.Reset();
|
|
492 |
|
|
493 |
for (i=0; i < iGaugeFrameData->iIncUpdBitmapMask.Count(); i++)
|
|
494 |
{
|
|
495 |
delete iGaugeFrameData->iIncUpdBitmapMask[i];
|
|
496 |
}
|
|
497 |
iGaugeFrameData->iIncUpdBitmapMask.Reset();
|
|
498 |
|
|
499 |
// continuous idle bitmap
|
|
500 |
delete iGaugeFrameData->iContIdleBitmap;
|
|
501 |
iGaugeFrameData->iContIdleBitmap = NULL;
|
|
502 |
|
|
503 |
delete iGaugeFrameData->iContIdleBitmapMask;
|
|
504 |
iGaugeFrameData->iContIdleBitmapMask = NULL;
|
|
505 |
|
|
506 |
// incremental idle bitmap
|
|
507 |
delete iGaugeFrameData->iIncIdleBitmap;
|
|
508 |
iGaugeFrameData->iIncIdleBitmap = NULL;
|
|
509 |
|
|
510 |
delete iGaugeFrameData->iIncIdleBitmapMask;
|
|
511 |
iGaugeFrameData->iIncIdleBitmapMask = NULL;
|
|
512 |
|
|
513 |
// frame bitmaps
|
|
514 |
delete iGaugeFrameData->iFrameL;
|
|
515 |
iGaugeFrameData->iFrameL = NULL;
|
|
516 |
|
|
517 |
delete iGaugeFrameData->iFrameLMask;
|
|
518 |
iGaugeFrameData->iFrameLMask = NULL;
|
|
519 |
|
|
520 |
delete iGaugeFrameData->iFrameCenter;
|
|
521 |
iGaugeFrameData->iFrameCenter = NULL;
|
|
522 |
|
|
523 |
delete iGaugeFrameData->iFrameCenterMask;
|
|
524 |
iGaugeFrameData->iFrameCenterMask = NULL;
|
|
525 |
|
|
526 |
delete iGaugeFrameData->iFrameR;
|
|
527 |
iGaugeFrameData->iFrameR = NULL;
|
|
528 |
|
|
529 |
delete iGaugeFrameData->iFrameRMask;
|
|
530 |
iGaugeFrameData->iFrameRMask = NULL;
|
|
531 |
}
|
|
532 |
|
|
533 |
|
|
534 |
void CMIDGaugeItem::ResizeBitmapsInTlsL()
|
|
535 |
{
|
|
536 |
// check if thread-local bitmap storage is created
|
|
537 |
if (!iGaugeFrameData)
|
|
538 |
{
|
|
539 |
return;
|
|
540 |
}
|
|
541 |
|
|
542 |
// get layout info
|
|
543 |
TRect formRect;
|
|
544 |
TRect waitGaugeRect;
|
|
545 |
TRect waitGaugeBarRect;
|
|
546 |
TRect waitGaugeBarFrameLRect;
|
|
547 |
TRect waitGaugeBarFrameCRect;
|
|
548 |
TRect waitGaugeBarFrameRRect;
|
|
549 |
TAknLayoutRect layoutRect;
|
|
550 |
TSize waitGaugeBarRectSize;
|
|
551 |
|
|
552 |
formRect = FormClientAreaRect();
|
|
553 |
|
|
554 |
layoutRect.LayoutRect(formRect,
|
|
555 |
AknLayoutScalable_Avkon::form2_midp_gauge_wait_pane().LayoutLine());
|
|
556 |
waitGaugeRect = layoutRect.Rect();
|
|
557 |
|
|
558 |
layoutRect.LayoutRect(waitGaugeRect,
|
|
559 |
AknLayoutScalable_Avkon::form2_midp_wait_pane(1).LayoutLine());
|
|
560 |
waitGaugeBarRect = layoutRect.Rect();
|
|
561 |
|
|
562 |
layoutRect.LayoutRect(waitGaugeBarRect,
|
|
563 |
AknLayoutScalable_Avkon::form2_midp_wait_pane_g1().LayoutLine());
|
|
564 |
waitGaugeBarFrameLRect = layoutRect.Rect();
|
|
565 |
|
|
566 |
layoutRect.LayoutRect(waitGaugeBarRect,
|
|
567 |
AknLayoutScalable_Avkon::form2_midp_wait_pane_g2().LayoutLine());
|
|
568 |
waitGaugeBarFrameCRect = layoutRect.Rect();
|
|
569 |
|
|
570 |
layoutRect.LayoutRect(waitGaugeBarRect,
|
|
571 |
AknLayoutScalable_Avkon::form2_midp_wait_pane_g3().LayoutLine());
|
|
572 |
waitGaugeBarFrameRRect = layoutRect.Rect();
|
|
573 |
|
|
574 |
waitGaugeBarRectSize = waitGaugeBarRect.Size();
|
|
575 |
|
|
576 |
// resize bitmaps
|
|
577 |
TInt i;
|
|
578 |
|
|
579 |
// continuous running bitmaps
|
|
580 |
for (i=0; i < iGaugeFrameData->iContRunBitmap.Count(); i++)
|
|
581 |
{
|
|
582 |
CFbsBitmap* bitmap = iGaugeFrameData->iContRunBitmap[i];
|
|
583 |
|
|
584 |
if (bitmap->SizeInPixels() != waitGaugeBarRectSize)
|
|
585 |
{
|
|
586 |
User::LeaveIfError(AknIconUtils::SetSize(bitmap,
|
|
587 |
waitGaugeBarRectSize, EAspectRatioNotPreserved));
|
|
588 |
}
|
|
589 |
}
|
|
590 |
|
|
591 |
for (i=0; i < iGaugeFrameData->iContRunBitmapMask.Count(); i++)
|
|
592 |
{
|
|
593 |
CFbsBitmap* bitmap = iGaugeFrameData->iContRunBitmapMask[i];
|
|
594 |
|
|
595 |
if (bitmap->SizeInPixels() != waitGaugeBarRectSize)
|
|
596 |
{
|
|
597 |
User::LeaveIfError(AknIconUtils::SetSize(bitmap,
|
|
598 |
waitGaugeBarRectSize, EAspectRatioNotPreserved));
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
// incremental updating bitmaps
|
|
603 |
for (i=0; i < iGaugeFrameData->iIncUpdBitmap.Count(); i++)
|
|
604 |
{
|
|
605 |
CFbsBitmap* bitmap = iGaugeFrameData->iIncUpdBitmap[i];
|
|
606 |
|
|
607 |
if (bitmap->SizeInPixels() != waitGaugeBarRectSize)
|
|
608 |
{
|
|
609 |
User::LeaveIfError(AknIconUtils::SetSize(bitmap,
|
|
610 |
waitGaugeBarRectSize, EAspectRatioNotPreserved));
|
|
611 |
}
|
|
612 |
}
|
|
613 |
|
|
614 |
for (i=0; i < iGaugeFrameData->iIncUpdBitmapMask.Count(); i++)
|
|
615 |
{
|
|
616 |
CFbsBitmap* bitmap = iGaugeFrameData->iIncUpdBitmapMask[i];
|
|
617 |
|
|
618 |
if (bitmap->SizeInPixels() != waitGaugeBarRectSize)
|
|
619 |
{
|
|
620 |
User::LeaveIfError(AknIconUtils::SetSize(bitmap,
|
|
621 |
waitGaugeBarRectSize, EAspectRatioNotPreserved));
|
|
622 |
}
|
|
623 |
}
|
|
624 |
|
|
625 |
// continuous idle bitmap
|
|
626 |
if (iGaugeFrameData->iContIdleBitmap && (iGaugeFrameData->
|
|
627 |
iContIdleBitmap->SizeInPixels() != waitGaugeBarRectSize))
|
|
628 |
{
|
|
629 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
630 |
iGaugeFrameData->iContIdleBitmap, waitGaugeBarRectSize,
|
|
631 |
EAspectRatioNotPreserved));
|
|
632 |
}
|
|
633 |
|
|
634 |
if (iGaugeFrameData->iContIdleBitmapMask && (iGaugeFrameData->
|
|
635 |
iContIdleBitmapMask->SizeInPixels() != waitGaugeBarRectSize))
|
|
636 |
{
|
|
637 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
638 |
iGaugeFrameData->iContIdleBitmapMask, waitGaugeBarRectSize,
|
|
639 |
EAspectRatioNotPreserved));
|
|
640 |
}
|
|
641 |
|
|
642 |
// incremental idle bitmap
|
|
643 |
if (iGaugeFrameData->iIncIdleBitmap && (iGaugeFrameData->
|
|
644 |
iIncIdleBitmap->SizeInPixels() != waitGaugeBarRectSize))
|
|
645 |
{
|
|
646 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
647 |
iGaugeFrameData->iIncIdleBitmap, waitGaugeBarRectSize,
|
|
648 |
EAspectRatioNotPreserved));
|
|
649 |
}
|
|
650 |
|
|
651 |
if (iGaugeFrameData->iIncIdleBitmapMask && (iGaugeFrameData->
|
|
652 |
iIncIdleBitmapMask->SizeInPixels() != waitGaugeBarRectSize))
|
|
653 |
{
|
|
654 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
655 |
iGaugeFrameData->iIncIdleBitmapMask, waitGaugeBarRectSize,
|
|
656 |
EAspectRatioNotPreserved));
|
|
657 |
}
|
|
658 |
|
|
659 |
// frame bitmaps
|
|
660 |
if (iGaugeFrameData->iFrameL && (iGaugeFrameData->
|
|
661 |
iFrameL->SizeInPixels() != waitGaugeBarFrameLRect.Size()))
|
|
662 |
{
|
|
663 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
664 |
iGaugeFrameData->iFrameL, waitGaugeBarFrameLRect.Size(),
|
|
665 |
EAspectRatioNotPreserved));
|
|
666 |
}
|
|
667 |
|
|
668 |
if (iGaugeFrameData->iFrameLMask && (iGaugeFrameData->
|
|
669 |
iFrameLMask->SizeInPixels() != waitGaugeBarFrameLRect.Size()))
|
|
670 |
{
|
|
671 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
672 |
iGaugeFrameData->iFrameLMask, waitGaugeBarFrameLRect.Size(),
|
|
673 |
EAspectRatioNotPreserved));
|
|
674 |
}
|
|
675 |
|
|
676 |
if (iGaugeFrameData->iFrameCenter && (iGaugeFrameData->
|
|
677 |
iFrameCenter->SizeInPixels() != waitGaugeBarFrameCRect.Size()))
|
|
678 |
{
|
|
679 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
680 |
iGaugeFrameData->iFrameCenter, waitGaugeBarFrameCRect.Size(),
|
|
681 |
EAspectRatioNotPreserved));
|
|
682 |
}
|
|
683 |
|
|
684 |
if (iGaugeFrameData->iFrameCenterMask && (iGaugeFrameData->
|
|
685 |
iFrameCenterMask->SizeInPixels() != waitGaugeBarFrameCRect.Size()))
|
|
686 |
{
|
|
687 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
688 |
iGaugeFrameData->iFrameCenterMask, waitGaugeBarFrameCRect.Size(),
|
|
689 |
EAspectRatioNotPreserved));
|
|
690 |
}
|
|
691 |
|
|
692 |
if (iGaugeFrameData->iFrameR && (iGaugeFrameData->
|
|
693 |
iFrameR->SizeInPixels() != waitGaugeBarFrameRRect.Size()))
|
|
694 |
{
|
|
695 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
696 |
iGaugeFrameData->iFrameR, waitGaugeBarFrameRRect.Size(),
|
|
697 |
EAspectRatioNotPreserved));
|
|
698 |
}
|
|
699 |
|
|
700 |
if (iGaugeFrameData->iFrameRMask && (iGaugeFrameData->
|
|
701 |
iFrameRMask->SizeInPixels() != waitGaugeBarFrameRRect.Size()))
|
|
702 |
{
|
|
703 |
User::LeaveIfError(AknIconUtils::SetSize(
|
|
704 |
iGaugeFrameData->iFrameRMask, waitGaugeBarFrameRRect.Size(),
|
|
705 |
EAspectRatioNotPreserved));
|
|
706 |
}
|
|
707 |
}
|
|
708 |
|
|
709 |
void CMIDGaugeItem::ColorChange(TInt aType)
|
|
710 |
{
|
|
711 |
// call default implementation
|
|
712 |
CMIDControlItem::ColorChange(aType);
|
|
713 |
|
|
714 |
// recreate bitmaps (current bitmaps are deleted in CreateBitmapsInTlsBitmapsL())
|
|
715 |
TRAPD(createErr, CreateBitmapsInTlsL());
|
|
716 |
|
|
717 |
if (createErr != KErrNone)
|
|
718 |
{
|
|
719 |
DEBUG_INT("CMIDGaugeItem::ColorChange() - Exception from CreateBitmapsInTlsL. Error = %d ", createErr);
|
|
720 |
}
|
|
721 |
|
|
722 |
TRAPD(resizeErr, ResizeBitmapsInTlsL());
|
|
723 |
|
|
724 |
if (resizeErr != KErrNone)
|
|
725 |
{
|
|
726 |
DEBUG_INT("CMIDGaugeItem::ColorChange() - Exception from ResizeBitmapsInTlsL. Error = %d ", resizeErr);
|
|
727 |
}
|
|
728 |
}
|
|
729 |
|
|
730 |
void CMIDGaugeItem::HandleForegroundL(TBool /*aForeground*/)
|
|
731 |
{
|
|
732 |
// Empty implementation. Inherited by CMIDNonInteractiveGauge.
|
|
733 |
}
|
|
734 |
|
|
735 |
#ifdef RD_SCALABLE_UI_V2
|
|
736 |
void CMIDGaugeItem::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
737 |
{
|
|
738 |
if (AknLayoutUtils::PenEnabled())
|
|
739 |
{
|
|
740 |
if (IsSelectable())
|
|
741 |
{
|
|
742 |
CMIDControlItem::HandlePointerEventL(aPointerEvent);
|
|
743 |
}
|
|
744 |
}
|
|
745 |
}
|
|
746 |
#endif // RD_SCALABLE_UI_V2
|
|
747 |
|
|
748 |
|
|
749 |
/**
|
|
750 |
* An interactive Gauge will always be selectable. A non-interactive
|
|
751 |
* Gauge will only be selectable if it has at least one Command.
|
|
752 |
*/
|
|
753 |
TBool CMIDGaugeItem::IsSelectable() const
|
|
754 |
{
|
|
755 |
return (iCommandList->Count() > 0 || !IsNonFocusing());
|
|
756 |
}
|
|
757 |
|
|
758 |
void CMIDGaugeItem::FocusChanged(TDrawNow aDrawNow)
|
|
759 |
{
|
|
760 |
CMIDControlItem::FocusChanged(aDrawNow);
|
|
761 |
}
|
|
762 |
|
|
763 |
void CMIDGaugeItem::SetLabelL(const TDesC& aLabel)
|
|
764 |
{
|
|
765 |
CMIDControlItem::SetLabelL(aLabel);
|
|
766 |
}
|
|
767 |
|
|
768 |
void CMIDGaugeItem::SetLayoutL(TLayout aLayout)
|
|
769 |
{
|
|
770 |
CMIDItem::SetLayoutL(aLayout);
|
|
771 |
}
|
|
772 |
|
|
773 |
void CMIDGaugeItem::Dispose()
|
|
774 |
{
|
|
775 |
delete this;
|
|
776 |
}
|
|
777 |
|
|
778 |
void CMIDGaugeItem::AddCommandL(MMIDCommand* aCommand)
|
|
779 |
{
|
|
780 |
CMIDItem::AddCommandL(aCommand);
|
|
781 |
}
|
|
782 |
|
|
783 |
void CMIDGaugeItem::RemoveCommand(MMIDCommand* aCommand)
|
|
784 |
{
|
|
785 |
CMIDItem::RemoveCommand(aCommand);
|
|
786 |
}
|
|
787 |
|
|
788 |
void CMIDGaugeItem::SetDefaultCommand(MMIDCommand* aCommand)
|
|
789 |
{
|
|
790 |
CMIDItem::SetDefaultCommand(aCommand);
|
|
791 |
}
|
|
792 |
|
|
793 |
void CMIDGaugeItem::SetPreferredSizeL(const TSize& aSize)
|
|
794 |
{
|
|
795 |
CMIDItem::SetPreferredSize(aSize,MinimumSize());
|
|
796 |
}
|
|
797 |
|
|
798 |
TSize CMIDGaugeItem::PreferredSize() const
|
|
799 |
{
|
|
800 |
return ResetPreferredSize();
|
|
801 |
}
|
|
802 |
|
|
803 |
TSize CMIDGaugeItem::MinimumSize() const
|
|
804 |
{
|
|
805 |
CCoeControl* control = const_cast<CMIDGaugeItem*>(this);
|
|
806 |
return control->MinimumSize();
|
|
807 |
}
|
|
808 |
|
|
809 |
TInt CMIDGaugeItem::GetIndefiniteState() const
|
|
810 |
{
|
|
811 |
return iIndefiniteState;
|
|
812 |
}
|
|
813 |
//////////////////////////////////////////////////////////////////////////////
|
|
814 |
|
|
815 |
// ---------------------------------------------------------------------------
|
|
816 |
//
|
|
817 |
// ---------------------------------------------------------------------------
|
|
818 |
//
|
|
819 |
MMIDGauge* CMIDNonInteractiveGauge::NewL(
|
|
820 |
const TDesC& aLabel,TInt aMaxValue,TInt aInitialValue, CMIDUIManager* aUIManager)
|
|
821 |
{
|
|
822 |
CMIDNonInteractiveGauge* self = new(ELeave) CMIDNonInteractiveGauge(aUIManager);
|
|
823 |
CleanupStack::PushL(self);
|
|
824 |
self->BaseConstructL(aLabel, aMaxValue, aInitialValue);
|
|
825 |
self->ConstructL();
|
|
826 |
CleanupStack::Pop(self);
|
|
827 |
return self;
|
|
828 |
}
|
|
829 |
|
|
830 |
CMIDNonInteractiveGauge::~CMIDNonInteractiveGauge()
|
|
831 |
{
|
|
832 |
DisposeTimer();
|
|
833 |
delete iProgressInfo;
|
|
834 |
delete iBitmapAnimation;
|
|
835 |
}
|
|
836 |
|
|
837 |
// ---------------------------------------------------------------------------
|
|
838 |
//
|
|
839 |
// ---------------------------------------------------------------------------
|
|
840 |
//
|
|
841 |
CMIDNonInteractiveGauge::CMIDNonInteractiveGauge(CMIDUIManager* aUIManager)
|
|
842 |
: CMIDGaugeItem(aUIManager),
|
|
843 |
iBitmapAnimation(NULL),
|
|
844 |
iTimer(NULL),
|
|
845 |
iIsInForeground(ETrue)
|
|
846 |
{
|
|
847 |
SetFocusing(EFalse);
|
|
848 |
}
|
|
849 |
|
|
850 |
void CMIDNonInteractiveGauge::ConstructL()
|
|
851 |
{
|
|
852 |
UpdateMemberVariables();
|
|
853 |
ConstructProgressInfoL();
|
|
854 |
ActivateL();
|
|
855 |
}
|
|
856 |
|
|
857 |
void CMIDNonInteractiveGauge::UpdateMemberVariables()
|
|
858 |
{
|
|
859 |
TRect formRect = FormClientAreaRect();
|
|
860 |
|
|
861 |
iWaitGaugeRect.LayoutRect(formRect,
|
|
862 |
AknLayoutScalable_Avkon::form2_midp_gauge_wait_pane().LayoutLine());
|
|
863 |
|
|
864 |
iWaitBarRect.LayoutRect(iWaitGaugeRect.Rect(),
|
|
865 |
AknLayoutScalable_Avkon::form2_midp_wait_pane(1).LayoutLine());
|
|
866 |
|
|
867 |
iWaitBarSize = iWaitBarRect.Rect().Size();
|
|
868 |
|
|
869 |
// WaitBar position in relation to CCoeControl (CMIDControlItem Rect) area
|
|
870 |
// Note that label height has to be added to the y coordinate
|
|
871 |
iProgressInfoWithLabelHeightTl = iWaitBarRect.Rect().iTl - formRect.iTl;
|
|
872 |
|
|
873 |
iItemheightWithoutLabel = iWaitGaugeRect.Rect().Height() +
|
|
874 |
iWaitGaugeRect.Rect().iTl.iY - formRect.iTl.iY + ItemContentBottomMargin();
|
|
875 |
}
|
|
876 |
|
|
877 |
|
|
878 |
// ---------------------------------------------------------------------------
|
|
879 |
// CMIDNonInteractiveGauge::InstallGaugeTimerWhenNeededL
|
|
880 |
// If continuous-running NonInteractiveGauge is in foreground,
|
|
881 |
// appended to form, bitmap animation is not used and
|
|
882 |
// animation timer is not created then create it.
|
|
883 |
// In all other cases the timer is not needed and disposed.
|
|
884 |
// ---------------------------------------------------------------------------
|
|
885 |
//
|
|
886 |
void CMIDNonInteractiveGauge::InstallGaugeTimerWhenNeededL()
|
|
887 |
{
|
|
888 |
if (iForm && iIsInForeground &&
|
|
889 |
iIndefiniteState == EContinuousRunning &&
|
|
890 |
!BitmapAnimationUsed() && !iTimer)
|
|
891 |
{
|
|
892 |
iTimer = CGaugeTimer::NewL(*this);
|
|
893 |
iTimer->After(TTimeIntervalMicroSeconds32(KDelayInMicroSeconds));
|
|
894 |
}
|
|
895 |
else
|
|
896 |
{
|
|
897 |
DisposeTimer();
|
|
898 |
}
|
|
899 |
}
|
|
900 |
|
|
901 |
void CMIDNonInteractiveGauge::ConstructProgressInfoL()
|
|
902 |
{
|
|
903 |
ASSERT(!iProgressInfo);
|
|
904 |
|
|
905 |
CEikProgressInfo::SInfo info;
|
|
906 |
info.iFinalValue = iIndefinite ? 100 : iMaxValue;
|
|
907 |
info.iSplitsInBlock = 0;
|
|
908 |
info.iTextType = EEikProgressTextPercentage;
|
|
909 |
|
|
910 |
info.iWidth = iWaitBarSize.iWidth;
|
|
911 |
info.iHeight = iWaitBarSize.iHeight;
|
|
912 |
|
|
913 |
iProgressInfo = new(ELeave) CEikProgressInfo(info);
|
|
914 |
iProgressInfo->ConstructL();
|
|
915 |
iProgressInfo->SetContainerWindowL(*this);
|
|
916 |
iProgressInfo->SetAndDraw(iValue);
|
|
917 |
|
|
918 |
if (IsActivated())
|
|
919 |
{
|
|
920 |
iProgressInfo->ActivateL();
|
|
921 |
}
|
|
922 |
}
|
|
923 |
|
|
924 |
void CMIDNonInteractiveGauge::SetValueL(TInt aValue)
|
|
925 |
{
|
|
926 |
if (iIndefinite)
|
|
927 |
{
|
|
928 |
// indefinite gauge will not be updated when it is inserted in form
|
|
929 |
// and the form is sent to background
|
|
930 |
TBool updateGauge = (iForm) ? iIsInForeground : EFalse;
|
|
931 |
|
|
932 |
// update gauge state
|
|
933 |
TInt oldIndefiniteState = iIndefiniteState;
|
|
934 |
iIndefiniteState = aValue;
|
|
935 |
DisposeTimer();
|
|
936 |
|
|
937 |
if (BitmapAnimationUsed() && aValue != EContinuousRunning)
|
|
938 |
{
|
|
939 |
// Stoping of animation.
|
|
940 |
iBitmapAnimation->CancelAnimation();
|
|
941 |
delete iBitmapAnimation;
|
|
942 |
iBitmapAnimation = NULL;
|
|
943 |
}
|
|
944 |
else if (!BitmapAnimationUsed() && aValue == EContinuousRunning)
|
|
945 |
{
|
|
946 |
// Create new bitmap animation
|
|
947 |
CreateNewBitmapAnimationIfNeededL();
|
|
948 |
}
|
|
949 |
|
|
950 |
switch (iIndefiniteState)
|
|
951 |
{
|
|
952 |
case EContinuousIdle:
|
|
953 |
case EIncrementalIdle:
|
|
954 |
iValue = 0;
|
|
955 |
break;
|
|
956 |
case EContinuousRunning:
|
|
957 |
InstallGaugeTimerWhenNeededL();
|
|
958 |
break;
|
|
959 |
case EIncrementalUpdating:
|
|
960 |
|
|
961 |
// update gauge's state
|
|
962 |
if (updateGauge)
|
|
963 |
{
|
|
964 |
if (iIndefiniteState != oldIndefiniteState)
|
|
965 |
{
|
|
966 |
iValue = -1;
|
|
967 |
}
|
|
968 |
iValue++;
|
|
969 |
if (iGaugeFrameData && iValue >= iGaugeFrameData->iIncUpdBitmap.Count())
|
|
970 |
{
|
|
971 |
iValue = 0;
|
|
972 |
}
|
|
973 |
}
|
|
974 |
break;
|
|
975 |
default:
|
|
976 |
ASSERT(EFalse);
|
|
977 |
}
|
|
978 |
|
|
979 |
// update gauge in alert
|
|
980 |
if (iGaugeToAlertListner)
|
|
981 |
{
|
|
982 |
iGaugeToAlertListner->UpdateGaugeInAlertL(iValue);
|
|
983 |
}
|
|
984 |
|
|
985 |
// Eventually notify alert dialog that indefinite state changed
|
|
986 |
if (iGaugeToAlertListner && (iIndefiniteState != oldIndefiniteState))
|
|
987 |
{
|
|
988 |
iGaugeToAlertListner->GaugeTypeInAlertChangedL();
|
|
989 |
}
|
|
990 |
|
|
991 |
// Redraw gauge if it should be updated or if it's type changed
|
|
992 |
if (updateGauge || (iIndefiniteState != oldIndefiniteState))
|
|
993 |
{
|
|
994 |
DoSafeDraw();
|
|
995 |
}
|
|
996 |
}
|
|
997 |
else
|
|
998 |
{
|
|
999 |
// Bitmap animation is used with indefinite only
|
|
1000 |
if (BitmapAnimationUsed())
|
|
1001 |
{
|
|
1002 |
// Stoping of animation.
|
|
1003 |
iBitmapAnimation->CancelAnimation();
|
|
1004 |
delete iBitmapAnimation;
|
|
1005 |
iBitmapAnimation = NULL;
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
iValue = aValue;
|
|
1009 |
|
|
1010 |
if (iGaugeToAlertListner)
|
|
1011 |
{
|
|
1012 |
iGaugeToAlertListner->UpdateGaugeInAlertL(iValue);
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
DoSafeDraw();
|
|
1016 |
}
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
void CMIDNonInteractiveGauge::SetGaugeListenerFromAlert(
|
|
1020 |
MMIDGaugeToAlertListner* aGaugeToAlertListner)
|
|
1021 |
{
|
|
1022 |
iGaugeToAlertListner = aGaugeToAlertListner;
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
void CMIDNonInteractiveGauge::SetMaxValueL(TInt aMaxValue)
|
|
1026 |
{
|
|
1027 |
// is new max value indefinite?
|
|
1028 |
if (aMaxValue == EIndefinite)
|
|
1029 |
{
|
|
1030 |
if (!iIndefinite)
|
|
1031 |
{
|
|
1032 |
// set gauge state to indefinite
|
|
1033 |
iIndefinite = ETrue;
|
|
1034 |
iMaxValue = EIndefinite;
|
|
1035 |
|
|
1036 |
// set indefinite state to other type than with which
|
|
1037 |
// SetValueL function will be called in order to detect change
|
|
1038 |
// of gauge type in this function
|
|
1039 |
iIndefiniteState = EContinuousIdle+1;
|
|
1040 |
SetValueL(EContinuousIdle);
|
|
1041 |
}
|
|
1042 |
}
|
|
1043 |
else
|
|
1044 |
{
|
|
1045 |
// If old value was indefinite and new one is not
|
|
1046 |
// recreate progress bar, otherwise progress bar wont be updated
|
|
1047 |
if (iMaxValue == EIndefinite && iMaxValue != aMaxValue)
|
|
1048 |
{
|
|
1049 |
// update progressinfo
|
|
1050 |
delete iProgressInfo;
|
|
1051 |
iProgressInfo = NULL;
|
|
1052 |
ConstructProgressInfoL();
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
// no timer needed for definite gauge
|
|
1056 |
DisposeTimer();
|
|
1057 |
|
|
1058 |
// set gauge state to definite
|
|
1059 |
iIndefinite = EFalse;
|
|
1060 |
iMaxValue = aMaxValue;
|
|
1061 |
|
|
1062 |
// check gauge's value
|
|
1063 |
if (iValue > iMaxValue)
|
|
1064 |
{
|
|
1065 |
iValue = iMaxValue;
|
|
1066 |
}
|
|
1067 |
else if (iValue < 0)
|
|
1068 |
{
|
|
1069 |
iValue = 0;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
// eventually update gauge in alert
|
|
1073 |
if (iGaugeToAlertListner)
|
|
1074 |
{
|
|
1075 |
iGaugeToAlertListner->GaugeTypeInAlertChangedL();
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
// redraw
|
|
1079 |
DoSafeDraw();
|
|
1080 |
}
|
|
1081 |
}
|
|
1082 |
|
|
1083 |
TSize CMIDNonInteractiveGauge::MinimumSize()
|
|
1084 |
{
|
|
1085 |
if (!iLabelControl || (iLabelControl->Text()->Length() == 0))
|
|
1086 |
{
|
|
1087 |
// item doesn't have label
|
|
1088 |
return TSize(FormClientAreaWidth(), iItemheightWithoutLabel);
|
|
1089 |
}
|
|
1090 |
else // item has label
|
|
1091 |
{
|
|
1092 |
return TSize(FormClientAreaWidth(),
|
|
1093 |
iItemheightWithoutLabel + OneLineLabelHeight());
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
TInt CMIDNonInteractiveGauge::CountComponentControls() const
|
|
1098 |
{
|
|
1099 |
if (iIndefinite)
|
|
1100 |
{
|
|
1101 |
if (BitmapAnimationUsed())
|
|
1102 |
{
|
|
1103 |
return 2; // to be able to access iBitmapAnimation
|
|
1104 |
}
|
|
1105 |
|
|
1106 |
return 1; // we will draw the gauge in our Draw() method
|
|
1107 |
}
|
|
1108 |
else
|
|
1109 |
{
|
|
1110 |
return 2;
|
|
1111 |
}
|
|
1112 |
}
|
|
1113 |
|
|
1114 |
CCoeControl* CMIDNonInteractiveGauge::ComponentControl(TInt aIndex) const
|
|
1115 |
{
|
|
1116 |
switch (aIndex)
|
|
1117 |
{
|
|
1118 |
case 0:
|
|
1119 |
return iLabelControl;
|
|
1120 |
case 1:
|
|
1121 |
if (BitmapAnimationUsed())
|
|
1122 |
{
|
|
1123 |
return iBitmapAnimation;
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
return iProgressInfo;
|
|
1127 |
default:
|
|
1128 |
return NULL;
|
|
1129 |
}
|
|
1130 |
}
|
|
1131 |
|
|
1132 |
/** Unlike other items, this one here draw the backgorund as well because its draw
|
|
1133 |
method is called without drawing the form first. Other items only draw the control.
|
|
1134 |
*/
|
|
1135 |
void CMIDNonInteractiveGauge::Draw(const TRect& /*aRect*/) const
|
|
1136 |
{
|
|
1137 |
CWindowGc& gc=SystemGc();
|
|
1138 |
|
|
1139 |
// get drawing position
|
|
1140 |
TRect rect(Rect());
|
|
1141 |
|
|
1142 |
// draw background and control
|
|
1143 |
CMIDControlItem::Draw(rect);
|
|
1144 |
|
|
1145 |
|
|
1146 |
// draw non-interactive gauge graphics
|
|
1147 |
if (iIndefinite && iGaugeFrameData)
|
|
1148 |
{
|
|
1149 |
// If Gauge animated in current skin, is drawn by iBitmapAnimation.
|
|
1150 |
// Otherwise is drawn in this block of code.
|
|
1151 |
if (!BitmapAnimationUsed())
|
|
1152 |
{
|
|
1153 |
CFbsBitmap* bitmap = NULL;
|
|
1154 |
CFbsBitmap* bitmapMask = NULL;
|
|
1155 |
|
|
1156 |
// Finding of correct bitmap and bitmapMask from TLS
|
|
1157 |
switch (iIndefiniteState)
|
|
1158 |
{
|
|
1159 |
case EContinuousIdle:
|
|
1160 |
bitmap = iGaugeFrameData->iContIdleBitmap;
|
|
1161 |
bitmapMask = iGaugeFrameData->iContIdleBitmapMask;
|
|
1162 |
break;
|
|
1163 |
case EIncrementalIdle:
|
|
1164 |
bitmap = iGaugeFrameData->iIncIdleBitmap;
|
|
1165 |
bitmapMask = iGaugeFrameData->iIncIdleBitmapMask;
|
|
1166 |
break;
|
|
1167 |
case EContinuousRunning:
|
|
1168 |
if ((iValue>=0) &&
|
|
1169 |
(iValue < iGaugeFrameData->iContRunBitmap.Count()))
|
|
1170 |
{
|
|
1171 |
bitmap = iGaugeFrameData->iContRunBitmap[iValue];
|
|
1172 |
}
|
|
1173 |
if ((iValue>=0) &&
|
|
1174 |
(iValue < iGaugeFrameData->iContRunBitmapMask.Count()))
|
|
1175 |
{
|
|
1176 |
bitmapMask = iGaugeFrameData->iContRunBitmapMask[iValue];
|
|
1177 |
}
|
|
1178 |
break;
|
|
1179 |
case EIncrementalUpdating:
|
|
1180 |
if ((iValue>=0) &&
|
|
1181 |
(iValue < iGaugeFrameData->iIncUpdBitmap.Count()))
|
|
1182 |
{
|
|
1183 |
bitmap = iGaugeFrameData->iIncUpdBitmap[iValue];
|
|
1184 |
}
|
|
1185 |
if ((iValue>=0) &&
|
|
1186 |
(iValue < iGaugeFrameData->iIncUpdBitmapMask.Count()))
|
|
1187 |
{
|
|
1188 |
bitmapMask = iGaugeFrameData->iIncUpdBitmapMask[iValue];
|
|
1189 |
}
|
|
1190 |
break;
|
|
1191 |
default:
|
|
1192 |
ASSERT(EFalse);
|
|
1193 |
}
|
|
1194 |
|
|
1195 |
// get drawing position
|
|
1196 |
TPoint drawPosition = Position() + iProgressInfoWithLabelHeightTl +
|
|
1197 |
TPoint(0,LabelHeight());
|
|
1198 |
|
|
1199 |
// draw gague bar
|
|
1200 |
if (bitmap && bitmapMask)
|
|
1201 |
{
|
|
1202 |
TSize bitmapSize = bitmap->SizeInPixels();
|
|
1203 |
TRect bitmapRect = TRect(0, 0, bitmapSize.iWidth, bitmapSize.iHeight);
|
|
1204 |
gc.BitBltMasked(drawPosition, bitmap, bitmapRect, bitmapMask, EFalse);
|
|
1205 |
}
|
|
1206 |
else if (bitmap)
|
|
1207 |
{
|
|
1208 |
gc.BitBlt(drawPosition, bitmap);
|
|
1209 |
}
|
|
1210 |
}
|
|
1211 |
}
|
|
1212 |
|
|
1213 |
TPoint drawPositionFrame = Position() + iProgressInfoWithLabelHeightTl +
|
|
1214 |
TPoint(0,LabelHeight());
|
|
1215 |
// draw gague bar frame
|
|
1216 |
if (iGaugeFrameData && iGaugeFrameData->iFrameL && iGaugeFrameData->iFrameLMask &&
|
|
1217 |
iGaugeFrameData->iFrameCenter && iGaugeFrameData->iFrameCenterMask &&
|
|
1218 |
iGaugeFrameData->iFrameR && iGaugeFrameData->iFrameRMask)
|
|
1219 |
{
|
|
1220 |
// draw of left frame of gauge bar
|
|
1221 |
gc.BitBltMasked(drawPositionFrame, iGaugeFrameData->iFrameL,
|
|
1222 |
TRect(iGaugeFrameData->iFrameL->SizeInPixels()),
|
|
1223 |
iGaugeFrameData->iFrameLMask, EFalse);
|
|
1224 |
|
|
1225 |
// draw of central frame of gauge bar
|
|
1226 |
drawPositionFrame.iX += iGaugeFrameData->iFrameL->SizeInPixels().iWidth;
|
|
1227 |
|
|
1228 |
gc.BitBltMasked(drawPositionFrame, iGaugeFrameData->iFrameCenter,
|
|
1229 |
TRect(iGaugeFrameData->iFrameCenter->SizeInPixels()),
|
|
1230 |
iGaugeFrameData->iFrameCenterMask, EFalse);
|
|
1231 |
|
|
1232 |
// draw of right frame of gauge bar
|
|
1233 |
drawPositionFrame.iX += iGaugeFrameData->iFrameCenter->SizeInPixels().iWidth;
|
|
1234 |
|
|
1235 |
gc.BitBltMasked(drawPositionFrame, iGaugeFrameData->iFrameR,
|
|
1236 |
TRect(iGaugeFrameData->iFrameR->SizeInPixels()),
|
|
1237 |
iGaugeFrameData->iFrameRMask, EFalse);
|
|
1238 |
}
|
|
1239 |
}
|
|
1240 |
|
|
1241 |
void CMIDNonInteractiveGauge::SizeChanged()
|
|
1242 |
{
|
|
1243 |
// Base implemation
|
|
1244 |
CMIDControlItem::SizeChanged();
|
|
1245 |
|
|
1246 |
// If Gauge is animated, the animation will be resized.
|
|
1247 |
if (BitmapAnimationUsed())
|
|
1248 |
{
|
|
1249 |
// Stoping of animation.
|
|
1250 |
iBitmapAnimation->CancelAnimation();
|
|
1251 |
// Resizing of animation
|
|
1252 |
SetAnimationSize();
|
|
1253 |
|
|
1254 |
// Start of animation
|
|
1255 |
TRAPD(errStart, iBitmapAnimation->StartAnimationL());
|
|
1256 |
if (errStart != KErrNone)
|
|
1257 |
{
|
|
1258 |
DEBUG_INT("CMIDNonInteractiveGauge::SizeChanged() - Exception from CAknBitmapAnimation::StartAnimationL(). Error = %d ", errStart);
|
|
1259 |
}
|
|
1260 |
|
|
1261 |
// Setting of animation mode (cycle).
|
|
1262 |
TRAPD(errSet, iBitmapAnimation->Animation().SetPlayModeL(CBitmapAnimClientData::ECycle));
|
|
1263 |
if (errSet != KErrNone)
|
|
1264 |
{
|
|
1265 |
DEBUG_INT("CMIDNonInteractiveGauge::SizeChanged() - Exception from RBitmapAnim::SetPlayModeL(). Error = %d ", errSet);
|
|
1266 |
}
|
|
1267 |
|
|
1268 |
}
|
|
1269 |
|
|
1270 |
// Resizing of label.
|
|
1271 |
iLabelControl->SetExtent(Position(), TSize(FormClientAreaWidth(), LabelHeight()));
|
|
1272 |
|
|
1273 |
// Positioning progress bar
|
|
1274 |
TPoint p = Position() + iProgressInfoWithLabelHeightTl + TPoint(0,LabelHeight());
|
|
1275 |
iProgressInfo->SetExtent(p, iProgressInfo->Size());
|
|
1276 |
}
|
|
1277 |
|
|
1278 |
void CMIDNonInteractiveGauge::SetContainerWindowL(const CCoeControl& aContainer)
|
|
1279 |
{
|
|
1280 |
CreateBitmapsIfNeededL();
|
|
1281 |
CMIDControlItem::SetContainerWindowL(aContainer);
|
|
1282 |
iProgressInfo->SetContainerWindowL(*this);
|
|
1283 |
#ifdef RD_SCALABLE_UI_V2
|
|
1284 |
//Enable cancelation of long tap i.e. up event is grabbed from long tap animation
|
|
1285 |
DrawableWindow()->SetPointerGrab(ETrue);
|
|
1286 |
#endif //RD_SCALABLE_UI_V2
|
|
1287 |
}
|
|
1288 |
|
|
1289 |
void CMIDNonInteractiveGauge::DisposeTimer()
|
|
1290 |
{
|
|
1291 |
if (iTimer)
|
|
1292 |
iTimer->Cancel();
|
|
1293 |
delete iTimer;
|
|
1294 |
iTimer = NULL;
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
void CMIDNonInteractiveGauge::DoSafeDraw()
|
|
1298 |
{
|
|
1299 |
if (iForm && DrawableWindow())
|
|
1300 |
{
|
|
1301 |
if (!iIndefinite && iProgressInfo->DrawableWindow())
|
|
1302 |
{
|
|
1303 |
iProgressInfo->SetFinalValue(iMaxValue);
|
|
1304 |
iProgressInfo->SetAndDraw(iValue);
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
DrawNow();
|
|
1308 |
}
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
void CMIDNonInteractiveGauge::HandleForegroundL(TBool aForeground)
|
|
1312 |
{
|
|
1313 |
// synchronize foreground flag
|
|
1314 |
iIsInForeground = aForeground;
|
|
1315 |
|
|
1316 |
InstallGaugeTimerWhenNeededL();
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
#ifdef RD_SCALABLE_UI_V2
|
|
1320 |
void CMIDNonInteractiveGauge::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
1321 |
{
|
|
1322 |
if (AknLayoutUtils::PenEnabled())
|
|
1323 |
{
|
|
1324 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
1325 |
if (!iForm->TryDetectLongTapL(aPointerEvent) &&
|
|
1326 |
!iForm->IsFocusChangingWithPen())
|
|
1327 |
{
|
|
1328 |
switch (aPointerEvent.iType)
|
|
1329 |
{
|
|
1330 |
case TPointerEvent::EButton1Down:
|
|
1331 |
case TPointerEvent::EButton1Up:
|
|
1332 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
1333 |
if (feedback)
|
|
1334 |
{
|
|
1335 |
feedback->InstantFeedback(ETouchFeedbackList);
|
|
1336 |
}
|
|
1337 |
break;
|
|
1338 |
}
|
|
1339 |
}
|
|
1340 |
#else
|
|
1341 |
iForm->TryDetectLongTapL(aPointerEvent);
|
|
1342 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
1343 |
|
|
1344 |
}
|
|
1345 |
}
|
|
1346 |
#endif // RD_SCALABLE_UI_V2
|
|
1347 |
|
|
1348 |
TInt CMIDNonInteractiveGauge::ItemPreferredHeightWithoutLabel()
|
|
1349 |
{
|
|
1350 |
return iItemheightWithoutLabel;
|
|
1351 |
}
|
|
1352 |
|
|
1353 |
TInt CMIDNonInteractiveGauge::GetMaxValue()
|
|
1354 |
{
|
|
1355 |
return iMaxValue;
|
|
1356 |
}
|
|
1357 |
|
|
1358 |
/* ResolutionChange
|
|
1359 |
*
|
|
1360 |
* This method is called after dynamic resolution change
|
|
1361 |
*/
|
|
1362 |
|
|
1363 |
void CMIDNonInteractiveGauge::ResolutionChange(TInt /*aType*/)
|
|
1364 |
{
|
|
1365 |
// update member variables
|
|
1366 |
UpdateMemberVariables();
|
|
1367 |
|
|
1368 |
// resize bitmaps in TLS
|
|
1369 |
TRAPD(resizeErr, ResizeBitmapsInTlsL());
|
|
1370 |
if (resizeErr != KErrNone)
|
|
1371 |
{
|
|
1372 |
DEBUG_INT("CMIDNonInteractiveGauge::ResolutionChange() - Exception from ResizeBitmapsInTlsL. Error = %d ", resizeErr);
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
// update progressinfo
|
|
1376 |
delete iProgressInfo;
|
|
1377 |
iProgressInfo = NULL;
|
|
1378 |
TRAPD(err, ConstructProgressInfoL());
|
|
1379 |
if (err != KErrNone)
|
|
1380 |
{
|
|
1381 |
DEBUG_INT("NonInteractiveGauge::ResolutionChange - Exception from ConstructProgressInfoL. Error = %d", err);
|
|
1382 |
}
|
|
1383 |
}
|
|
1384 |
|
|
1385 |
void CMIDNonInteractiveGauge::ConstructAnimation(CAknBitmapAnimation* aBitmapAnimation)
|
|
1386 |
{
|
|
1387 |
// Setting aBitmapAnimation context into this (first stage).
|
|
1388 |
aBitmapAnimation->CopyControlContextFrom(this);
|
|
1389 |
aBitmapAnimation->SetMopParent(this);
|
|
1390 |
|
|
1391 |
// Setting of CCoeBrushAndPenContext for aBitmapAnimation
|
|
1392 |
CCoeBrushAndPenContext* brushAndPenContext = NULL;
|
|
1393 |
TRAPD(err, brushAndPenContext = CCoeBrushAndPenContext::NewL());
|
|
1394 |
if (err != KErrNone)
|
|
1395 |
{
|
|
1396 |
DEBUG_INT("CMIDNonInteractiveGauge::ResolutionChange() - Exception fromCCoeBrushAndPenContext::NewL. Error = %d ", err);
|
|
1397 |
}
|
|
1398 |
|
|
1399 |
// Setting aBitmapAnimation context into this (second stage).
|
|
1400 |
aBitmapAnimation->SetControlContext(brushAndPenContext);
|
|
1401 |
|
|
1402 |
// If iBitmapAnimation exists, it have to been deleted.
|
|
1403 |
if (iBitmapAnimation)
|
|
1404 |
{
|
|
1405 |
delete iBitmapAnimation;
|
|
1406 |
iBitmapAnimation = NULL;
|
|
1407 |
}
|
|
1408 |
|
|
1409 |
// Set aAnimation like iBitmapAnimation
|
|
1410 |
iBitmapAnimation = aBitmapAnimation;
|
|
1411 |
|
|
1412 |
// Timer is not needed when iBitmapAnimation is used
|
|
1413 |
DisposeTimer();
|
|
1414 |
}
|
|
1415 |
|
|
1416 |
|
|
1417 |
void CMIDNonInteractiveGauge::ItemAddedToFormL()
|
|
1418 |
{
|
|
1419 |
// call parent's implementation
|
|
1420 |
CMIDGaugeItem::ItemAddedToFormL();
|
|
1421 |
|
|
1422 |
// Creates new bitmapAnimation, it sets bitmapAnimation to IBitmapAnimation
|
|
1423 |
CreateNewBitmapAnimationIfNeededL();
|
|
1424 |
|
|
1425 |
// If bitmapAnimation does not exist create bitmap in TLS.
|
|
1426 |
if (!BitmapAnimationUsed())
|
|
1427 |
{
|
|
1428 |
// Create Bitmap in TLS.
|
|
1429 |
CreateBitmapsIfNeededL();
|
|
1430 |
}
|
|
1431 |
|
|
1432 |
// Install timer when needed and able to be installed.
|
|
1433 |
InstallGaugeTimerWhenNeededL();
|
|
1434 |
}
|
|
1435 |
|
|
1436 |
|
|
1437 |
void CMIDNonInteractiveGauge::ItemRemovedFromForm()
|
|
1438 |
{
|
|
1439 |
// call parent's implementation
|
|
1440 |
CMIDGaugeItem::ItemRemovedFromForm();
|
|
1441 |
|
|
1442 |
// Timer is not needed when item is removed from form.
|
|
1443 |
DisposeTimer();
|
|
1444 |
|
|
1445 |
// if indefinite ni-gauge is removed from form then no notifications
|
|
1446 |
// about moving to foreground/background are sent and so in order to ensure
|
|
1447 |
// full functionality it is assumed that gauge is in foreground
|
|
1448 |
TRAPD(err, HandleForegroundL(ETrue));
|
|
1449 |
|
|
1450 |
if (err != KErrNone)
|
|
1451 |
{
|
|
1452 |
DEBUG_INT("CMIDNonInteractiveGauge::ItemRemovedFromForm() - \
|
|
1453 |
Exception from HandleForegroundL. Error = %d ", err);
|
|
1454 |
}
|
|
1455 |
|
|
1456 |
// When NonInteractiveGauge was removed from form, then animation
|
|
1457 |
// must be deleted because uses form's window.
|
|
1458 |
if (iBitmapAnimation)
|
|
1459 |
{
|
|
1460 |
delete iBitmapAnimation;
|
|
1461 |
iBitmapAnimation = NULL;
|
|
1462 |
}
|
|
1463 |
}
|
|
1464 |
|
|
1465 |
void CMIDNonInteractiveGauge::CreateNewBitmapAnimationIfNeededL()
|
|
1466 |
{
|
|
1467 |
if (iMaxValue == EIndefinite && iIndefiniteState == EContinuousRunning
|
|
1468 |
&& DrawableWindow())
|
|
1469 |
{
|
|
1470 |
// creating new instance of CAknBitmapAnimation
|
|
1471 |
// for Gauge animation in new skin
|
|
1472 |
CAknBitmapAnimation* bitmapAnimation = CAknBitmapAnimation::NewL();
|
|
1473 |
CleanupStack::PushL(bitmapAnimation);
|
|
1474 |
|
|
1475 |
// setting of window of bitmapAnimation to this
|
|
1476 |
bitmapAnimation->SetContainerWindowL(*this);
|
|
1477 |
|
|
1478 |
// costruction of bitmapAnimation by ID of Gauge
|
|
1479 |
bitmapAnimation->ConstructFromSkinL(GetAknsItemID());
|
|
1480 |
CleanupStack::Pop(bitmapAnimation);
|
|
1481 |
|
|
1482 |
TBool bitmapFrameCount =
|
|
1483 |
bitmapAnimation ?
|
|
1484 |
bitmapAnimation->BitmapAnimData()->FrameArray().Count() > 0 : EFalse;
|
|
1485 |
|
|
1486 |
// If bitmapAnimation exist, set bitmapAnimation to IBitmapAnimation.
|
|
1487 |
if (bitmapFrameCount)
|
|
1488 |
{
|
|
1489 |
ConstructAnimation(bitmapAnimation);
|
|
1490 |
}
|
|
1491 |
}
|
|
1492 |
}
|
|
1493 |
|
|
1494 |
void CMIDNonInteractiveGauge::ColorChange(TInt aType)
|
|
1495 |
{
|
|
1496 |
// The original CMIDNonInteractiveGauge::ColorChange is using
|
|
1497 |
// CleanupStack::PushL( bitmapAnimation ); in non-leavung method.
|
|
1498 |
// Codescanner notices this as an error.
|
|
1499 |
TRAPD(creatingErr, ColorChangeL(aType));
|
|
1500 |
if (creatingErr != KErrNone)
|
|
1501 |
{
|
|
1502 |
DEBUG_INT("CMIDNonInteractiveGauge::ColorChange() - \
|
|
1503 |
Exception. Error = %d ", creatingErr);
|
|
1504 |
}
|
|
1505 |
}
|
|
1506 |
|
|
1507 |
void CMIDNonInteractiveGauge::ColorChangeL(TInt aType)
|
|
1508 |
{
|
|
1509 |
// stopping and deleting iBitmapAnimation
|
|
1510 |
if (BitmapAnimationUsed())
|
|
1511 |
{
|
|
1512 |
iBitmapAnimation->CancelAnimation();
|
|
1513 |
delete iBitmapAnimation;
|
|
1514 |
iBitmapAnimation = NULL;
|
|
1515 |
}
|
|
1516 |
|
|
1517 |
// Creates new bitmapAnimation, it sets bitmapAnimation to IBitmapAnimation
|
|
1518 |
CreateNewBitmapAnimationIfNeededL();
|
|
1519 |
|
|
1520 |
// If bitmapAnimation exist sets correct size iBitmapAnimation.
|
|
1521 |
if (BitmapAnimationUsed())
|
|
1522 |
{
|
|
1523 |
// call of parent's implementation
|
|
1524 |
CMIDGaugeItem::ColorChange(aType);
|
|
1525 |
|
|
1526 |
// settting correct size iBitmapAnimation
|
|
1527 |
SetAnimationSize();
|
|
1528 |
|
|
1529 |
// Start of playing iBitmapAnimation
|
|
1530 |
TRAPD(errStart, iBitmapAnimation->StartAnimationL());
|
|
1531 |
if (errStart != KErrNone)
|
|
1532 |
{
|
|
1533 |
DEBUG_INT("CMIDNonInteractiveGauge::ColorChange() - \
|
|
1534 |
Exception from CAknBitmapAnimation::StartAnimation. \
|
|
1535 |
Error = %d ", errStart);
|
|
1536 |
}
|
|
1537 |
|
|
1538 |
// Setting of animation mode (cycle).
|
|
1539 |
TRAPD(errSet, iBitmapAnimation->Animation().SetPlayModeL(
|
|
1540 |
CBitmapAnimClientData::ECycle));
|
|
1541 |
if (errSet != KErrNone)
|
|
1542 |
{
|
|
1543 |
DEBUG_INT("CMIDNonInteractiveGauge::ColorChange() - \
|
|
1544 |
Exception from RBitmapAnim::SetPlayMode. \
|
|
1545 |
Error = %d ", errSet);
|
|
1546 |
}
|
|
1547 |
|
|
1548 |
// Timer is useless when iBitmapAnimation is used
|
|
1549 |
DisposeTimer();
|
|
1550 |
}
|
|
1551 |
else
|
|
1552 |
{
|
|
1553 |
// call parent's implementation
|
|
1554 |
CMIDGaugeItem::ColorChange(aType);
|
|
1555 |
}
|
|
1556 |
|
|
1557 |
// send resource change event to progress info
|
|
1558 |
if (iProgressInfo)
|
|
1559 |
{
|
|
1560 |
iProgressInfo->HandleResourceChange(aType);
|
|
1561 |
}
|
|
1562 |
}
|
|
1563 |
|
|
1564 |
void CMIDNonInteractiveGauge::UpdateProgressInfo(CEikProgressInfo* aProgressInfo) const
|
|
1565 |
{
|
|
1566 |
if (!iProgressInfo || !aProgressInfo)
|
|
1567 |
{
|
|
1568 |
return;
|
|
1569 |
}
|
|
1570 |
aProgressInfo->SetFinalValue(iProgressInfo->Info().iFinalValue);
|
|
1571 |
}
|
|
1572 |
|
|
1573 |
void CMIDNonInteractiveGauge::SetAnimationSize()
|
|
1574 |
{
|
|
1575 |
// When Gauge is animated and initialized, then Get the right rect for the animation.
|
|
1576 |
if (iBitmapAnimation && iForm)
|
|
1577 |
{
|
|
1578 |
TRect parentRect = FormClientAreaRect();
|
|
1579 |
TRect waitGaugeBarRect;
|
|
1580 |
TRect waitGaugeRect;
|
|
1581 |
TAknLayoutRect layoutRect;
|
|
1582 |
TSize waitGaugeBarRectSize;
|
|
1583 |
TRect animationRect;
|
|
1584 |
|
|
1585 |
// computing layout for whole Gauge
|
|
1586 |
layoutRect.LayoutRect(parentRect,
|
|
1587 |
AknLayoutScalable_Avkon::form2_midp_gauge_wait_pane().LayoutLine());
|
|
1588 |
waitGaugeRect = layoutRect.Rect();
|
|
1589 |
|
|
1590 |
// computing layout for animation rectagle
|
|
1591 |
layoutRect.LayoutRect(waitGaugeRect,
|
|
1592 |
AknLayoutScalable_Avkon::form2_midp_wait_pane(1).LayoutLine());
|
|
1593 |
waitGaugeBarRect = layoutRect.Rect();
|
|
1594 |
|
|
1595 |
// moving rectagle for animation to correct position
|
|
1596 |
waitGaugeBarRectSize = waitGaugeBarRect.Size();
|
|
1597 |
TPoint drawPosition = Position() + iProgressInfoWithLabelHeightTl +
|
|
1598 |
TPoint(0,LabelHeight());
|
|
1599 |
animationRect = TRect(drawPosition.iX, drawPosition.iY,
|
|
1600 |
drawPosition.iX + waitGaugeBarRectSize.iWidth,
|
|
1601 |
drawPosition.iY + waitGaugeBarRectSize.iHeight);
|
|
1602 |
|
|
1603 |
// setting EAspectRatioNotPreserved mode for SetRect;
|
|
1604 |
// This prevent of wrong scalling.
|
|
1605 |
iBitmapAnimation->SetScaleModeForAnimationFrames(EAspectRatioNotPreserved);
|
|
1606 |
|
|
1607 |
//Scalling of iBitmapAnimation
|
|
1608 |
iBitmapAnimation->SetRect(animationRect);
|
|
1609 |
}
|
|
1610 |
}
|
|
1611 |
|
|
1612 |
TAknsItemID CMIDNonInteractiveGauge::GetAknsItemID()
|
|
1613 |
{
|
|
1614 |
if (GetMaxValue() <= 0)
|
|
1615 |
{
|
|
1616 |
switch (GetIndefiniteState())
|
|
1617 |
{
|
|
1618 |
case MMIDGauge::EContinuousIdle: // continuous idle
|
|
1619 |
{
|
|
1620 |
return KAknsIIDQgnGrafBarWaitIdle;
|
|
1621 |
}
|
|
1622 |
case MMIDGauge::EContinuousRunning: // continuous running
|
|
1623 |
{
|
|
1624 |
return KAknsIIDQgnGrafBarWaitAnim;
|
|
1625 |
}
|
|
1626 |
case MMIDGauge::EIncrementalUpdating: //incremental updating
|
|
1627 |
{
|
|
1628 |
return KAknsIIDQgnGrafBarWaitIncrem;
|
|
1629 |
}
|
|
1630 |
case MMIDGauge::EIncrementalIdle: //incremental idle
|
|
1631 |
{
|
|
1632 |
return KAknsIIDQgnGrafBarWaitIncremIdle;
|
|
1633 |
}
|
|
1634 |
default:
|
|
1635 |
return KAknsIIDNone;
|
|
1636 |
}
|
|
1637 |
}
|
|
1638 |
return KAknsIIDNone;
|
|
1639 |
}
|
|
1640 |
|
|
1641 |
TBool CMIDNonInteractiveGauge::BitmapAnimationUsed() const
|
|
1642 |
{
|
|
1643 |
return iBitmapAnimation && iBitmapAnimation->BitmapAnimData() &&
|
|
1644 |
iBitmapAnimation->BitmapAnimData()->FrameArray().Count() > 0;
|
|
1645 |
}
|
|
1646 |
|
|
1647 |
TTypeUid::Ptr CMIDNonInteractiveGauge::MopSupplyObject(TTypeUid aId)
|
|
1648 |
{
|
|
1649 |
TTypeUid::Ptr ptr = TTypeUid::Null();
|
|
1650 |
|
|
1651 |
// When control context is requested we return new correct one.
|
|
1652 |
// Default implementation otherwise.
|
|
1653 |
if (aId.iUid == MAknsControlContext::ETypeId && iForm && IsFocused())
|
|
1654 |
{
|
|
1655 |
ptr = MAknsControlContext::SupplyMopObject(aId, BackgroundControlContext());
|
|
1656 |
}
|
|
1657 |
else
|
|
1658 |
{
|
|
1659 |
ptr = CMIDControlItem::MopSupplyObject(aId);
|
|
1660 |
}
|
|
1661 |
return ptr;
|
|
1662 |
}
|
|
1663 |
|
|
1664 |
CAknsFrameBackgroundControlContext* CMIDNonInteractiveGauge::BackgroundControlContext()
|
|
1665 |
{
|
|
1666 |
// It tries create new instance of CAknsFrameBackgroundControlContext.
|
|
1667 |
// When construction fails, the error is logged.
|
|
1668 |
CAknsFrameBackgroundControlContext* context = NULL;
|
|
1669 |
TRAPD(err, context = CAknsFrameBackgroundControlContext::NewL(
|
|
1670 |
KAknsIIDQsnFrInput, Rect(), Rect(), EFalse));
|
|
1671 |
if (err != KErrNone)
|
|
1672 |
{
|
|
1673 |
DEBUG_INT("CMIDNonInteractiveGauge::BackgroundControlContext -\
|
|
1674 |
CAknsFrameBackgroundControlContext::NewL failed with error number %d", err);
|
|
1675 |
context = NULL;
|
|
1676 |
}
|
|
1677 |
return context;
|
|
1678 |
}
|
|
1679 |
|
|
1680 |
// ---------------------------------------------------------------------------
|
|
1681 |
//
|
|
1682 |
// ---------------------------------------------------------------------------
|
|
1683 |
//
|
|
1684 |
|
|
1685 |
MMIDGauge* CMIDInteractiveGauge::NewL(
|
|
1686 |
const TDesC& aLabel,TInt aMaxValue,TInt aInitialValue, CMIDUIManager* aUIManager)
|
|
1687 |
{
|
|
1688 |
CMIDInteractiveGauge* self = new(ELeave) CMIDInteractiveGauge(aUIManager);
|
|
1689 |
CleanupStack::PushL(self);
|
|
1690 |
self->BaseConstructL(aLabel, aMaxValue, aInitialValue);
|
|
1691 |
self->ConstructL();
|
|
1692 |
|
|
1693 |
CleanupStack::Pop(self);
|
|
1694 |
|
|
1695 |
return self;
|
|
1696 |
}
|
|
1697 |
|
|
1698 |
CMIDInteractiveGauge::~CMIDInteractiveGauge()
|
|
1699 |
{
|
|
1700 |
}
|
|
1701 |
|
|
1702 |
|
|
1703 |
CMIDInteractiveGauge::CMIDInteractiveGauge(CMIDUIManager* aUIManager)
|
|
1704 |
: CMIDGaugeItem(aUIManager)
|
|
1705 |
{
|
|
1706 |
SetFocusing(ETrue);
|
|
1707 |
}
|
|
1708 |
|
|
1709 |
// ---------------------------------------------------------------------------
|
|
1710 |
//
|
|
1711 |
// ---------------------------------------------------------------------------
|
|
1712 |
//
|
|
1713 |
|
|
1714 |
void CMIDInteractiveGauge::ConstructL()
|
|
1715 |
{
|
|
1716 |
iIndefinite = (iMaxValue == EIndefinite);
|
|
1717 |
|
|
1718 |
UpdateMemberVariables();
|
|
1719 |
|
|
1720 |
ConstructSliderL();
|
|
1721 |
|
|
1722 |
ActivateL();
|
|
1723 |
}
|
|
1724 |
|
|
1725 |
void CMIDInteractiveGauge::UpdateMemberVariables()
|
|
1726 |
{
|
|
1727 |
TRect formRect = FormClientAreaRect();
|
|
1728 |
|
|
1729 |
iSliderGaugeRect.LayoutRect(formRect,
|
|
1730 |
AknLayoutScalable_Avkon::form2_midp_gauge_slider_pane().LayoutLine());
|
|
1731 |
|
|
1732 |
// Slider position in relation to CCoeControl (CMIDControlItem Rect) area
|
|
1733 |
iSliderPositionTl = iSliderGaugeRect.Rect().iTl - formRect.iTl;
|
|
1734 |
|
|
1735 |
iItemheightWithoutLabel = iSliderGaugeRect.Rect().Height() +
|
|
1736 |
iSliderPositionTl.iY + ItemContentBottomMargin();
|
|
1737 |
}
|
|
1738 |
|
|
1739 |
void CMIDInteractiveGauge::ConstructSliderL()
|
|
1740 |
{
|
|
1741 |
ASSERT(!iSlider);
|
|
1742 |
iSlider = new(ELeave) CAknSlider();
|
|
1743 |
TResourceReader reader;
|
|
1744 |
iCoeEnv->CreateResourceReaderLC(reader, R_MIDP_SLIDER_DEFAULT);
|
|
1745 |
iSlider->HandleResourceChange(KEikMessageCaptionedControlEditableStateChange);
|
|
1746 |
iSlider->ConstructFromResourceL(reader);
|
|
1747 |
CleanupStack::PopAndDestroy(); // reader
|
|
1748 |
|
|
1749 |
iSlider->SetRange(0, iMaxValue);
|
|
1750 |
iSlider->SetStepSize(1);
|
|
1751 |
iSlider->SetValueL(iValue);
|
|
1752 |
TBuf<10> number;
|
|
1753 |
number.Num(0);
|
|
1754 |
iSlider->SetMinimumTextL(number);
|
|
1755 |
number.Num(iMaxValue);
|
|
1756 |
iSlider->SetMaximumTextL(number);
|
|
1757 |
|
|
1758 |
iSlider->SetSize(TSize(iSliderGaugeRect.Rect().Width(), iSliderGaugeRect.Rect().Height()));
|
|
1759 |
}
|
|
1760 |
|
|
1761 |
void CMIDInteractiveGauge::SetValueL(TInt aValue)
|
|
1762 |
{
|
|
1763 |
iValue = aValue;
|
|
1764 |
iSlider->SetValueL(iValue);
|
|
1765 |
DoSafeDraw();
|
|
1766 |
}
|
|
1767 |
|
|
1768 |
void CMIDInteractiveGauge::SetMaxValueL(TInt aValue)
|
|
1769 |
{
|
|
1770 |
iMaxValue = aValue;
|
|
1771 |
if (iValue > iMaxValue)
|
|
1772 |
{
|
|
1773 |
iValue = iMaxValue;
|
|
1774 |
iSlider->SetValueL(iValue);
|
|
1775 |
}
|
|
1776 |
TBuf<10> number;
|
|
1777 |
number.Num(iMaxValue);
|
|
1778 |
iSlider->SetMaximumTextL(number);
|
|
1779 |
iSlider->SetRange(0, iMaxValue);
|
|
1780 |
DoSafeDraw();
|
|
1781 |
}
|
|
1782 |
|
|
1783 |
TSize CMIDInteractiveGauge::MinimumSize()
|
|
1784 |
{
|
|
1785 |
if (!iLabelControl || (iLabelControl->Text()->Length() == 0))
|
|
1786 |
{
|
|
1787 |
// item doesn't have label
|
|
1788 |
return TSize(FormClientAreaWidth(), iItemheightWithoutLabel);
|
|
1789 |
}
|
|
1790 |
else // item has label
|
|
1791 |
{
|
|
1792 |
return TSize(FormClientAreaWidth(), iItemheightWithoutLabel + OneLineLabelHeight());
|
|
1793 |
}
|
|
1794 |
}
|
|
1795 |
|
|
1796 |
TInt CMIDInteractiveGauge::CountComponentControls() const
|
|
1797 |
{
|
|
1798 |
return 2;
|
|
1799 |
}
|
|
1800 |
|
|
1801 |
CCoeControl* CMIDInteractiveGauge::ComponentControl(TInt aIndex) const
|
|
1802 |
{
|
|
1803 |
switch (aIndex)
|
|
1804 |
{
|
|
1805 |
case 0:
|
|
1806 |
return iLabelControl;
|
|
1807 |
case 1:
|
|
1808 |
return iSlider;
|
|
1809 |
default:
|
|
1810 |
return NULL;
|
|
1811 |
}
|
|
1812 |
}
|
|
1813 |
|
|
1814 |
void CMIDInteractiveGauge::Draw(const TRect& aRect) const
|
|
1815 |
{
|
|
1816 |
CMIDControlItem::Draw(aRect);
|
|
1817 |
}
|
|
1818 |
|
|
1819 |
void CMIDInteractiveGauge::SizeChanged()
|
|
1820 |
{
|
|
1821 |
CMIDControlItem::SizeChanged();
|
|
1822 |
|
|
1823 |
iLabelControl->SetExtent(Position() , TSize(FormClientAreaWidth(), LabelHeight()));
|
|
1824 |
iSlider->SetExtent(Position() +
|
|
1825 |
TSize(iSliderPositionTl.iX, LabelHeight()), iSlider->Size());
|
|
1826 |
}
|
|
1827 |
|
|
1828 |
void CMIDInteractiveGauge::PositionChanged()
|
|
1829 |
{
|
|
1830 |
iSlider->SetExtent(Position() +
|
|
1831 |
TSize(iSliderPositionTl.iX, LabelHeight()), iSlider->Size());
|
|
1832 |
}
|
|
1833 |
|
|
1834 |
void CMIDInteractiveGauge::SetContainerWindowL(const CCoeControl& aContainer)
|
|
1835 |
{
|
|
1836 |
CMIDControlItem::SetContainerWindowL(aContainer);
|
|
1837 |
iSlider->SetContainerWindowL(*this);
|
|
1838 |
#ifdef RD_SCALABLE_UI_V2
|
|
1839 |
if (AknLayoutUtils::PenEnabled())
|
|
1840 |
{
|
|
1841 |
iSlider->EnableDrag();
|
|
1842 |
}
|
|
1843 |
#endif // RD_SCALABLE_UI_V2
|
|
1844 |
SetObserver(iForm);
|
|
1845 |
}
|
|
1846 |
|
|
1847 |
void CMIDInteractiveGauge::DoSafeDraw()
|
|
1848 |
{
|
|
1849 |
if (DrawableWindow())
|
|
1850 |
{
|
|
1851 |
DrawNow();
|
|
1852 |
}
|
|
1853 |
}
|
|
1854 |
|
|
1855 |
TInt CMIDInteractiveGauge::ItemPreferredHeightWithoutLabel()
|
|
1856 |
{
|
|
1857 |
return iItemheightWithoutLabel;
|
|
1858 |
}
|
|
1859 |
|
|
1860 |
TKeyResponse CMIDInteractiveGauge::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
|
|
1861 |
{
|
|
1862 |
TBool valueChanged = EFalse;
|
|
1863 |
if (aType != EEventKey ||
|
|
1864 |
(aKeyEvent.iCode != EKeyLeftArrow && aKeyEvent.iCode != EKeyRightArrow) ||
|
|
1865 |
IsNonFocusing())
|
|
1866 |
{
|
|
1867 |
return EKeyWasNotConsumed;
|
|
1868 |
}
|
|
1869 |
iValue = iSlider->Value();
|
|
1870 |
if (aKeyEvent.iCode == EKeyLeftArrow)
|
|
1871 |
{
|
|
1872 |
if (iValue > 0)
|
|
1873 |
{
|
|
1874 |
iValue -= 1;
|
|
1875 |
iSlider->SetValueL(iValue);
|
|
1876 |
valueChanged = ETrue;
|
|
1877 |
}
|
|
1878 |
}
|
|
1879 |
else if (aKeyEvent.iCode == EKeyRightArrow)
|
|
1880 |
{
|
|
1881 |
if (iValue < iMaxValue)
|
|
1882 |
{
|
|
1883 |
iValue += 1;
|
|
1884 |
iSlider->SetValueL(iValue);
|
|
1885 |
valueChanged = ETrue;
|
|
1886 |
}
|
|
1887 |
}
|
|
1888 |
|
|
1889 |
if (valueChanged)
|
|
1890 |
{
|
|
1891 |
ReportEventL(MCoeControlObserver::EEventStateChanged);
|
|
1892 |
}
|
|
1893 |
DoSafeDraw();
|
|
1894 |
|
|
1895 |
return EKeyWasConsumed;
|
|
1896 |
}
|
|
1897 |
|
|
1898 |
#ifdef RD_SCALABLE_UI_V2
|
|
1899 |
void CMIDInteractiveGauge::HandlePointerEventL(const TPointerEvent &aPointerEvent)
|
|
1900 |
{
|
|
1901 |
if (AknLayoutUtils::PenEnabled())
|
|
1902 |
{
|
|
1903 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down && !iForm->PhysicsScrolling())
|
|
1904 |
{
|
|
1905 |
iPhysicsScrollingTriggered = EFalse;
|
|
1906 |
iOriginalSliderValue = iSlider->Value();
|
|
1907 |
}
|
|
1908 |
// Enlarge the control area by changing the pointer y-position
|
|
1909 |
// close to center of graphics area.
|
|
1910 |
TPointerEvent pEvent = aPointerEvent;
|
|
1911 |
TBool sliderArea = iSlider->Rect().Contains(aPointerEvent.iPosition);
|
|
1912 |
if (sliderArea)
|
|
1913 |
{
|
|
1914 |
pEvent.iPosition.iY = iSlider->Rect().iTl.iY +
|
|
1915 |
((iSlider->Rect().iBr.iY - iSlider->Rect().iTl.iY) /
|
|
1916 |
KSliderHeightDivider);
|
|
1917 |
}
|
|
1918 |
CMIDGaugeItem::HandlePointerEventL(pEvent);
|
|
1919 |
if (iValue != iSlider->Value() && !iForm->PhysicsScrolling())
|
|
1920 |
{
|
|
1921 |
iValue = iSlider->Value();
|
|
1922 |
ReportEventL(MCoeControlObserver::EEventStateChanged);
|
|
1923 |
return;
|
|
1924 |
}
|
|
1925 |
if (sliderArea && iForm->PhysicsScrolling() && !iPhysicsScrollingTriggered)
|
|
1926 |
{
|
|
1927 |
//Physics scrolling triggered, set new slider value.
|
|
1928 |
iPhysicsScrollingTriggered = ETrue;
|
|
1929 |
iSlider->SetValueL(iValue);
|
|
1930 |
return;
|
|
1931 |
}
|
|
1932 |
|
|
1933 |
iForm->TryDetectLongTapL(aPointerEvent);
|
|
1934 |
}
|
|
1935 |
}
|
|
1936 |
|
|
1937 |
#endif // RD_SCALABLE_UI_V2
|
|
1938 |
|
|
1939 |
/* ResolutionChange
|
|
1940 |
*
|
|
1941 |
* This method is called after dynamic resolution change
|
|
1942 |
*/
|
|
1943 |
void CMIDInteractiveGauge::ResolutionChange(TInt aType)
|
|
1944 |
{
|
|
1945 |
UpdateMemberVariables();
|
|
1946 |
iSlider->HandleResourceChange(aType);
|
|
1947 |
iSlider->SetSize(TSize(iSliderGaugeRect.Rect().Width(), iSliderGaugeRect.Rect().Height()));
|
|
1948 |
}
|
|
1949 |
|
|
1950 |
// End of File
|