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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMIDGAUGEITEM_H
|
|
20 |
#define CMIDGAUGEITEM_H
|
|
21 |
|
|
22 |
// CMIDControlItem inheritance in class declaration
|
|
23 |
// using TAknLayoutRect (indirect from CMIDForm.h)
|
|
24 |
#include <lcdui.h>
|
|
25 |
#include "CMIDControlItem.h"
|
|
26 |
|
|
27 |
/**
|
|
28 |
*
|
|
29 |
* This class uses a CTimer which could potentially keep the machine alive. One way round
|
|
30 |
* this is to use the MMIDEnvObserver to receive switch on/foreground events and so suspend
|
|
31 |
* the timer when in the backgound or when the user has turned the device off.
|
|
32 |
*
|
|
33 |
* This is not done in this reference API because an alternative view would be to place the
|
|
34 |
* responsibility on the MIDlet.
|
|
35 |
*
|
|
36 |
*/
|
|
37 |
|
|
38 |
class CEikProgressInfo;
|
|
39 |
class CAknSlider;
|
|
40 |
class CAknBitmapAnimation;
|
|
41 |
class CAknsFrameBackgroundControlContext;
|
|
42 |
|
|
43 |
/** This interface is implemented by the alert dialog (CMIDAlertDialog). The current
|
|
44 |
design is such that the alert dialog uses its own animations (loaded from resource)
|
|
45 |
when a gauge is added to an alert. So when the gauge java peer is updated (for example
|
|
46 |
because its value is changed) we need to notify the alert, which will then have to
|
|
47 |
update its animations or bitmaps.*/
|
|
48 |
class MMIDGaugeToAlertListner
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
/** For definite gauge items or if the gauge indefinite state does not change
|
|
52 |
we just need to tell the dialog to incremenat the frame or the anim status */
|
|
53 |
virtual void UpdateGaugeInAlertL(TInt aValue)=0;
|
|
54 |
|
|
55 |
/**
|
|
56 |
* Function is called when gauge type was changed.
|
|
57 |
*/
|
|
58 |
virtual void GaugeTypeInAlertChangedL()=0;
|
|
59 |
};
|
|
60 |
|
|
61 |
NONSHARABLE_CLASS(CMIDGaugeItem) : public CMIDControlItem, public MMIDGauge
|
|
62 |
{
|
|
63 |
public:
|
|
64 |
NONSHARABLE_CLASS(CGaugeTimer) : public CTimer
|
|
65 |
{
|
|
66 |
public:
|
|
67 |
static CGaugeTimer* NewL(CMIDGaugeItem& aGauge);
|
|
68 |
private:
|
|
69 |
CGaugeTimer(CMIDGaugeItem& aGauge);
|
|
70 |
void RunL();
|
|
71 |
private:
|
|
72 |
CMIDGaugeItem& iGauge;
|
|
73 |
};
|
|
74 |
public:
|
|
75 |
virtual ~CMIDGaugeItem();
|
|
76 |
#ifdef RD_SCALABLE_UI_V2
|
|
77 |
void HandlePointerEventL(const TPointerEvent &aPointerEvent);
|
|
78 |
#endif // RD_SCALABLE_UI_V2
|
|
79 |
//
|
|
80 |
// From MMIDGauge
|
|
81 |
//
|
|
82 |
virtual void SetValueL(TInt aValue) = 0;
|
|
83 |
virtual TInt GetValue();
|
|
84 |
virtual void SetMaxValueL(TInt aValue) = 0;
|
|
85 |
//
|
|
86 |
// From MMIDItem
|
|
87 |
//
|
|
88 |
virtual void SetLabelL(const TDesC& aLabel);
|
|
89 |
void SetLayoutL(TLayout aLayout);
|
|
90 |
void SetPreferredSizeL(const TSize& aSize);
|
|
91 |
TSize PreferredSize() const;
|
|
92 |
TSize MinimumSize() const;
|
|
93 |
void AddCommandL(MMIDCommand* aCommand);
|
|
94 |
void RemoveCommand(MMIDCommand* aCommand);
|
|
95 |
void SetDefaultCommand(MMIDCommand* aCommand);
|
|
96 |
|
|
97 |
TBool IsSelectable() const;
|
|
98 |
TInt GetIndefiniteState() const;
|
|
99 |
//
|
|
100 |
// From MMIDComponent
|
|
101 |
//
|
|
102 |
void Dispose();
|
|
103 |
virtual TType Type() const
|
|
104 |
{
|
|
105 |
return EGauge;
|
|
106 |
}
|
|
107 |
|
|
108 |
//
|
|
109 |
// From CMIDControlItem
|
|
110 |
//
|
|
111 |
void ColorChange(TInt aType);
|
|
112 |
|
|
113 |
/**
|
|
114 |
* Handles event when application switches to/from the foreground.
|
|
115 |
*
|
|
116 |
* @param aForeground ETrue to switch to the foreground. EFalse to switch
|
|
117 |
* from the foreground.
|
|
118 |
* @note Animation of non-interactive gauges is started/stopped.
|
|
119 |
*/
|
|
120 |
virtual void HandleForegroundL(TBool aForeground);
|
|
121 |
|
|
122 |
protected:
|
|
123 |
/**
|
|
124 |
* Ctor
|
|
125 |
* @param aUIManager UI manager
|
|
126 |
*
|
|
127 |
* @since s60
|
|
128 |
*/
|
|
129 |
CMIDGaugeItem(CMIDUIManager* aUIManager);
|
|
130 |
|
|
131 |
void BaseConstructL(const TDesC& aLabel,TInt aMaxValue,
|
|
132 |
TInt aInitialValue);
|
|
133 |
|
|
134 |
void FocusChanged(TDrawNow aDrawNow);
|
|
135 |
|
|
136 |
void CreateBitmapsIfNeededL();
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Creates bitmaps in thread-local bitmap storage.
|
|
140 |
*
|
|
141 |
* Thread-local bitmap storage has to be already created else has no effect.
|
|
142 |
*/
|
|
143 |
void CreateBitmapsInTlsL();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Deletes bitmaps from thread-local bitmap storage.
|
|
147 |
*
|
|
148 |
* Thread-local bitmap storage has to be already created else has no effect.
|
|
149 |
* Fuction does not delete thread-local bitmap storage.
|
|
150 |
*/
|
|
151 |
void DeleteBitmapsInTls();
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Resizes bitmaps in thread-local bitmap storage.
|
|
155 |
*
|
|
156 |
* Thread-local bitmap storage and bitmaps have to be already created else
|
|
157 |
* has no effect.
|
|
158 |
*/
|
|
159 |
void ResizeBitmapsInTlsL();
|
|
160 |
|
|
161 |
protected:
|
|
162 |
TBool iIndefinite;
|
|
163 |
TInt iIndefiniteState;
|
|
164 |
TInt iMaxValue;
|
|
165 |
TInt iValue;
|
|
166 |
|
|
167 |
/** Bitmaps are stored in the TLS so they can be shared across gauge items*/
|
|
168 |
struct TGaugeFrameData
|
|
169 |
{
|
|
170 |
TInt iNumInstances;
|
|
171 |
RArray<CFbsBitmap*> iContRunBitmap; // continuous running bitmaps
|
|
172 |
RArray<CFbsBitmap*> iContRunBitmapMask;
|
|
173 |
RArray<CFbsBitmap*> iIncUpdBitmap; // incremental updating bitmaps
|
|
174 |
RArray<CFbsBitmap*> iIncUpdBitmapMask;
|
|
175 |
CFbsBitmap* iContIdleBitmap; // continuous idle bitmap
|
|
176 |
CFbsBitmap* iContIdleBitmapMask;
|
|
177 |
CFbsBitmap* iIncIdleBitmap; // incremental idle bitmap
|
|
178 |
CFbsBitmap* iIncIdleBitmapMask;
|
|
179 |
CFbsBitmap* iFrameL; // frame bitmaps
|
|
180 |
CFbsBitmap* iFrameLMask;
|
|
181 |
CFbsBitmap* iFrameCenter;
|
|
182 |
CFbsBitmap* iFrameCenterMask;
|
|
183 |
CFbsBitmap* iFrameR;
|
|
184 |
CFbsBitmap* iFrameRMask;
|
|
185 |
|
|
186 |
/**
|
|
187 |
*
|
|
188 |
*
|
|
189 |
*/
|
|
190 |
void Clean()
|
|
191 |
{
|
|
192 |
iNumInstances = 1;
|
|
193 |
iContRunBitmap.Reset();
|
|
194 |
iContRunBitmapMask.Reset();
|
|
195 |
iIncUpdBitmap.Reset();
|
|
196 |
iIncUpdBitmapMask.Reset();
|
|
197 |
iContIdleBitmap = NULL;
|
|
198 |
iContIdleBitmapMask = NULL;
|
|
199 |
iIncIdleBitmap = NULL;
|
|
200 |
iIncIdleBitmapMask = NULL;
|
|
201 |
iFrameL = NULL;
|
|
202 |
iFrameLMask = NULL;
|
|
203 |
iFrameCenter = NULL;
|
|
204 |
iFrameCenterMask = NULL;
|
|
205 |
iFrameR = NULL;
|
|
206 |
iFrameRMask = NULL;
|
|
207 |
}
|
|
208 |
|
|
209 |
/**
|
|
210 |
*
|
|
211 |
*
|
|
212 |
*/
|
|
213 |
void Close()
|
|
214 |
{
|
|
215 |
iContRunBitmap.Close();
|
|
216 |
iContRunBitmapMask.Close();
|
|
217 |
iIncUpdBitmap.Close();
|
|
218 |
iIncUpdBitmapMask.Close();
|
|
219 |
}
|
|
220 |
};
|
|
221 |
|
|
222 |
/** An array of SVG bitmaps stored in the TLS so that it can be shared amongst gauge items*/
|
|
223 |
TGaugeFrameData* iGaugeFrameData;
|
|
224 |
|
|
225 |
friend class CGaugeTimer;
|
|
226 |
};
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
NONSHARABLE_CLASS(CMIDNonInteractiveGauge) : public CMIDGaugeItem
|
|
231 |
{
|
|
232 |
public:
|
|
233 |
~CMIDNonInteractiveGauge();
|
|
234 |
/**
|
|
235 |
* Double ctor
|
|
236 |
* @param aUIManager UI manager
|
|
237 |
*
|
|
238 |
* @since s60
|
|
239 |
*/
|
|
240 |
static MMIDGauge* NewL(
|
|
241 |
const TDesC& aLabel,TInt aMaxValue,TInt aInitialValue, CMIDUIManager* aUIManager);
|
|
242 |
|
|
243 |
//
|
|
244 |
// From MMIDGauge
|
|
245 |
//
|
|
246 |
virtual void SetValueL(TInt aValue);
|
|
247 |
virtual void SetMaxValueL(TInt aValue);
|
|
248 |
virtual TInt GetMaxValue();
|
|
249 |
|
|
250 |
// From CCoeControl
|
|
251 |
virtual TSize MinimumSize();
|
|
252 |
TInt CountComponentControls() const;
|
|
253 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
254 |
void Draw(const TRect& aRect) const;
|
|
255 |
void SizeChanged();
|
|
256 |
void SetContainerWindowL(const CCoeControl& aContainer);
|
|
257 |
void DoSafeDraw();
|
|
258 |
|
|
259 |
#ifdef RD_SCALABLE_UI_V2
|
|
260 |
void HandlePointerEventL(const TPointerEvent &aPointerEvent);
|
|
261 |
#endif // RD_SCALABLE_UI_V2
|
|
262 |
|
|
263 |
//
|
|
264 |
// From CMIDItem
|
|
265 |
//
|
|
266 |
TInt ItemPreferredHeightWithoutLabel();
|
|
267 |
//
|
|
268 |
// From CMIDControlItem
|
|
269 |
//
|
|
270 |
/**
|
|
271 |
* Handles event when application switches to/from the foreground.
|
|
272 |
*
|
|
273 |
* @param aForeground ETrue to switch to the foreground. EFalse to switch
|
|
274 |
* from the foreground.
|
|
275 |
* @note Animation of non-interactive gauges is started/stopped.
|
|
276 |
*/
|
|
277 |
void HandleForegroundL(TBool aForeground);
|
|
278 |
void ResolutionChange(TInt aType);
|
|
279 |
|
|
280 |
/**
|
|
281 |
* Handles addition of ni-gauge to form.
|
|
282 |
*/
|
|
283 |
void ItemAddedToFormL();
|
|
284 |
|
|
285 |
/**
|
|
286 |
* Handles removal of ni-gauge from form.
|
|
287 |
*/
|
|
288 |
void ItemRemovedFromForm();
|
|
289 |
|
|
290 |
/**
|
|
291 |
* Function is called when skin or color scheme change occurs.
|
|
292 |
*
|
|
293 |
* @param aType Type of change.
|
|
294 |
*/
|
|
295 |
void ColorChange(TInt aType);
|
|
296 |
|
|
297 |
void SetGaugeListenerFromAlert(MMIDGaugeToAlertListner* aGaugeToAlertListner);
|
|
298 |
|
|
299 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
300 |
|
|
301 |
private:
|
|
302 |
/**
|
|
303 |
* Ctor
|
|
304 |
* @param aUIManager UI manager
|
|
305 |
*
|
|
306 |
* @since s60
|
|
307 |
*/
|
|
308 |
CMIDNonInteractiveGauge(CMIDUIManager* aUIManager);
|
|
309 |
|
|
310 |
/**
|
|
311 |
* second pfase constructor
|
|
312 |
*/
|
|
313 |
void ConstructL();
|
|
314 |
void ConstructProgressInfoL();
|
|
315 |
friend class CMIDAlertDialog;
|
|
316 |
void UpdateProgressInfo(CEikProgressInfo* aProgressInfo) const;
|
|
317 |
void UpdateMemberVariables();
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Creats new instance of CAknBitmapAnimation for Gauge animation
|
|
321 |
* and sets it to iBitmapAnimation
|
|
322 |
*/
|
|
323 |
void CreateNewBitmapAnimationIfNeededL();
|
|
324 |
|
|
325 |
/**
|
|
326 |
* setting of size of iBitmapAnimation
|
|
327 |
*/
|
|
328 |
void SetAnimationSize();
|
|
329 |
|
|
330 |
/**
|
|
331 |
* End of construction of aBitmapAnimation and its setting up.
|
|
332 |
*/
|
|
333 |
void ConstructAnimation(CAknBitmapAnimation* aBitmapAnimation);
|
|
334 |
/**
|
|
335 |
* getting of correct TAknsItemID for current Gauge
|
|
336 |
* @return correct TAknsItemID
|
|
337 |
*/
|
|
338 |
TAknsItemID GetAknsItemID();
|
|
339 |
|
|
340 |
void ColorChangeL(TInt aType);
|
|
341 |
|
|
342 |
void DisposeTimer();
|
|
343 |
|
|
344 |
/**
|
|
345 |
* From CMIDGaugeItem.
|
|
346 |
* Starts animation timer (see iTimer) when needed.
|
|
347 |
* In case that timer is not needed, but has been created,
|
|
348 |
* it's disposed by this method.
|
|
349 |
*
|
|
350 |
* @since S60 v5.0
|
|
351 |
*/
|
|
352 |
void InstallGaugeTimerWhenNeededL();
|
|
353 |
|
|
354 |
/**
|
|
355 |
* Indicates that the current skin contains the animation and
|
|
356 |
* the animation has been instantiated to iBitmapAnimation.
|
|
357 |
*
|
|
358 |
* @return ETrue iBitmapAnimation has been created
|
|
359 |
* and the animation is useful.
|
|
360 |
* @since S60 v5.0
|
|
361 |
*/
|
|
362 |
TBool BitmapAnimationUsed() const;
|
|
363 |
|
|
364 |
/**
|
|
365 |
* Gets new correct instance of control context or null.
|
|
366 |
*
|
|
367 |
* @return New instance of CAknsFrameBackgroundControlContext.
|
|
368 |
* Instance maybe a null.
|
|
369 |
*
|
|
370 |
* @since S60 v5.0
|
|
371 |
*/
|
|
372 |
CAknsFrameBackgroundControlContext* BackgroundControlContext();
|
|
373 |
|
|
374 |
private:
|
|
375 |
CEikProgressInfo* iProgressInfo;
|
|
376 |
MMIDGaugeToAlertListner* iGaugeToAlertListner;
|
|
377 |
TAknLayoutRect iWaitGaugeRect; // form2_midp_gauge_wait_pane
|
|
378 |
TAknLayoutRect iWaitBarRect; // form2_midp_wait_pane
|
|
379 |
TSize iWaitBarSize; // Size of form2_midp_wait_pane
|
|
380 |
TInt iItemheightWithoutLabel; // Height of the GaugeItem without label
|
|
381 |
|
|
382 |
// WaitBar position in relation to CCoeControl (CMIDControlItem Rect) area
|
|
383 |
// Note that label height has to be added to the y coordinate
|
|
384 |
TPoint iProgressInfoWithLabelHeightTl; // Top left point of the progress info
|
|
385 |
CAknBitmapAnimation* iBitmapAnimation; // Animation for animated Gauge
|
|
386 |
CGaugeTimer* iTimer;
|
|
387 |
// Indicates that the application is in foreground
|
|
388 |
TBool iIsInForeground;
|
|
389 |
};
|
|
390 |
|
|
391 |
NONSHARABLE_CLASS(CMIDInteractiveGauge) : public CMIDGaugeItem
|
|
392 |
{
|
|
393 |
public:
|
|
394 |
~CMIDInteractiveGauge();
|
|
395 |
/**
|
|
396 |
* Double ctor
|
|
397 |
* @param aUIManager UI manager
|
|
398 |
*
|
|
399 |
* @since s60
|
|
400 |
*/
|
|
401 |
static MMIDGauge* NewL(
|
|
402 |
const TDesC& aLabel,TInt aMaxValue,TInt aInitialValue, CMIDUIManager* aUIManager);
|
|
403 |
|
|
404 |
//
|
|
405 |
// From MMIDGauge
|
|
406 |
//
|
|
407 |
virtual void SetValueL(TInt aValue);
|
|
408 |
virtual void SetMaxValueL(TInt aValue);
|
|
409 |
|
|
410 |
// From CCoeControl
|
|
411 |
virtual TSize MinimumSize();
|
|
412 |
TInt CountComponentControls() const;
|
|
413 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
414 |
void Draw(const TRect& aRect) const;
|
|
415 |
void SizeChanged();
|
|
416 |
void PositionChanged();
|
|
417 |
void SetContainerWindowL(const CCoeControl& aContainer);
|
|
418 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
419 |
#ifdef RD_SCALABLE_UI_V2
|
|
420 |
void HandlePointerEventL(const TPointerEvent &aPointerEvent);
|
|
421 |
#endif // RD_SCALABLE_UI_V2
|
|
422 |
void DoSafeDraw();
|
|
423 |
|
|
424 |
//
|
|
425 |
// From CMIDItem
|
|
426 |
//
|
|
427 |
TInt ItemPreferredHeightWithoutLabel();
|
|
428 |
//
|
|
429 |
// From CMIDControlItem
|
|
430 |
//
|
|
431 |
void ResolutionChange(TInt aType);
|
|
432 |
|
|
433 |
private:
|
|
434 |
|
|
435 |
/**
|
|
436 |
* Ctor
|
|
437 |
* @param aUIManager UI manager
|
|
438 |
*
|
|
439 |
* @since s60
|
|
440 |
*/
|
|
441 |
CMIDInteractiveGauge(CMIDUIManager* aUIManager);
|
|
442 |
|
|
443 |
void ConstructL();
|
|
444 |
void ConstructSliderL();
|
|
445 |
void UpdateMemberVariables();
|
|
446 |
|
|
447 |
private:
|
|
448 |
CAknSlider* iSlider;
|
|
449 |
TAknLayoutRect iSliderGaugeRect; // form2_midp_gauge_slider_pane
|
|
450 |
TInt iItemheightWithoutLabel; // Height of the GaugeItem without label
|
|
451 |
// Slider position in relation to CCoeControl (CMIDControlItem Rect) area
|
|
452 |
TPoint iSliderPositionTl; // Top left point of the slider control
|
|
453 |
TInt iOriginalSliderValue;
|
|
454 |
TBool iPhysicsScrollingTriggered;
|
|
455 |
};
|
|
456 |
|
|
457 |
|
|
458 |
#endif // CMIDGAUGEITEM_H
|
|
459 |
|
|
460 |
// End of File
|