83
|
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: Xuikon Bitmap Plugin.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include <AknsUtils.h>
|
|
18 |
#include <AknsDrawUtils.h>
|
|
19 |
#include <AknsConstants.h>
|
|
20 |
#include <barsread.h>
|
|
21 |
#include <debug.h>
|
|
22 |
|
|
23 |
#include "xnnodepluginif.h"
|
|
24 |
#include "xndomproperty.h"
|
|
25 |
#include "xnproperty.h"
|
|
26 |
#include "xncontroladapter.h"
|
|
27 |
|
|
28 |
#include "xnanimationadapter.h"
|
|
29 |
|
|
30 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
31 |
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
// CXnAnimationAdapter::NewL
|
|
34 |
// Symbian static 1st phase constructor
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CXnAnimationAdapter* CXnAnimationAdapter::NewL(CXnNodePluginIf& aNode)
|
|
38 |
{
|
|
39 |
CXnAnimationAdapter* self = new( ELeave ) CXnAnimationAdapter( aNode );
|
|
40 |
|
|
41 |
CleanupStack::PushL( self );
|
|
42 |
self->ConstructL( aNode );
|
|
43 |
CleanupStack::Pop();
|
|
44 |
|
|
45 |
return self;
|
|
46 |
}
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CXnAnimationAdapter::ConstructL
|
|
50 |
// Symbian 2nd phase constructor can leave.
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
void CXnAnimationAdapter::ConstructL(CXnNodePluginIf& aNode)
|
|
54 |
{
|
|
55 |
CXnControlAdapter::ConstructL( aNode );
|
|
56 |
iSkinId = KAknsIIDNone;
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// CXnAnimationAdapter::CXnAnimationAdapter
|
|
61 |
// C++ default constructor
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CXnAnimationAdapter::CXnAnimationAdapter(CXnNodePluginIf& aNode) : iNode( aNode )
|
|
65 |
{
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CXnAnimationAdapter::~CXnAnimationAdapter
|
|
70 |
// C++ destructor
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CXnAnimationAdapter::~CXnAnimationAdapter()
|
|
74 |
{
|
|
75 |
StopAnimation();
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
// CXnAnimationAdapter::Draw
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CXnAnimationAdapter::Draw(const TRect& aRect) const
|
|
84 |
{
|
|
85 |
CXnControlAdapter::Draw( aRect );
|
|
86 |
AknsDrawUtils::DrawCachedImage( AknsUtils::SkinInstance(),
|
|
87 |
SystemGc(), aRect, iSkinId );
|
|
88 |
}
|
|
89 |
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
// CXnAnimationAdapter::HandlePropertyChangeL
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
void CXnAnimationAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty )
|
|
95 |
{
|
|
96 |
if( aProperty )
|
|
97 |
{
|
|
98 |
const TDesC8& name( aProperty->Property()->Name( ) );
|
|
99 |
|
|
100 |
if( name == XnPropertyNames::style::common::KDisplay )
|
|
101 |
{
|
|
102 |
const TDesC8& display( aProperty->StringValue() );
|
|
103 |
|
|
104 |
if( display == XnPropertyNames::style::common::display::KBlock )
|
|
105 |
{
|
|
106 |
StartAnimation();
|
|
107 |
}
|
|
108 |
else
|
|
109 |
{
|
|
110 |
StopAnimation();
|
|
111 |
}
|
|
112 |
}
|
|
113 |
}
|
|
114 |
}
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// CXnAnimationAdapter::DoEnterPowerSaveModeL
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CXnAnimationAdapter::DoEnterPowerSaveModeL( TModeEvent /*aEvent*/ )
|
|
121 |
{
|
|
122 |
iInPowerSaveMode = ETrue;
|
|
123 |
StopAnimation();
|
|
124 |
}
|
|
125 |
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
// CXnAnimationAdapter::DoExitPowerSaveModeL
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
void CXnAnimationAdapter::DoExitPowerSaveModeL( TModeEvent /*aEvent*/ )
|
|
131 |
{
|
|
132 |
iInPowerSaveMode = EFalse;
|
|
133 |
StartAnimation();
|
|
134 |
}
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
// CXnNewstickerAdapter::MakeVisible()
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CXnAnimationAdapter::MakeVisible( TBool aVisible )
|
|
141 |
{
|
|
142 |
TBool visible( IsVisible() ? ETrue : EFalse );
|
|
143 |
if ( visible == aVisible ) { return; }
|
|
144 |
|
|
145 |
CCoeControl::MakeVisible( aVisible );
|
|
146 |
|
|
147 |
if ( aVisible )
|
|
148 |
{
|
|
149 |
StartAnimation();
|
|
150 |
}
|
|
151 |
else
|
|
152 |
{
|
|
153 |
StopAnimation();
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
// -----------------------------------------------------------------------------
|
|
158 |
// CXnAnimationAdapter::Update
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CXnAnimationAdapter::Update()
|
|
162 |
{
|
|
163 |
if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
|
|
164 |
{
|
|
165 |
switch( iSkinId.iMinor )
|
|
166 |
{
|
|
167 |
case EAknsMinorGenericQgnHomeRefreshing1:
|
|
168 |
{
|
|
169 |
iSkinId.Set(KAknsIIDQgnHomeRefreshing2);
|
|
170 |
}
|
|
171 |
break;
|
|
172 |
case EAknsMinorGenericQgnHomeRefreshing2:
|
|
173 |
{
|
|
174 |
iSkinId.Set(KAknsIIDQgnHomeRefreshing3);
|
|
175 |
}
|
|
176 |
break;
|
|
177 |
case EAknsMinorGenericQgnHomeRefreshing3:
|
|
178 |
{
|
|
179 |
iSkinId.Set(KAknsIIDQgnHomeRefreshing4);
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
case EAknsMinorGenericQgnHomeRefreshing4:
|
|
183 |
{
|
|
184 |
iSkinId.Set(KAknsIIDQgnHomeRefreshing1);
|
|
185 |
}
|
|
186 |
break;
|
|
187 |
default :
|
|
188 |
break;
|
|
189 |
};
|
|
190 |
DrawNow();
|
|
191 |
}
|
|
192 |
}
|
|
193 |
|
|
194 |
// ----------------------------------------------------------------------------
|
|
195 |
// CXnAnimationAdapter::PeriodicTimerCallBack(TAny* aAny)
|
|
196 |
// The call back function.
|
|
197 |
// ----------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
TInt CXnAnimationAdapter::TimerCallBack(TAny* aAny)
|
|
200 |
{
|
|
201 |
__PRINTS( "CXnAnimationAdapter::TimerCallback, timer runs" );
|
|
202 |
CXnAnimationAdapter* self = static_cast<CXnAnimationAdapter*> (aAny);
|
|
203 |
|
|
204 |
// Update widget
|
|
205 |
self->Update();
|
|
206 |
|
|
207 |
return KErrNone; // Return value ignored by CPeriodic
|
|
208 |
}
|
|
209 |
|
|
210 |
// ----------------------------------------------------------------------------
|
|
211 |
// CXnAnimationAdapter::StartAnimation()
|
|
212 |
// ----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CXnAnimationAdapter::StartAnimation()
|
|
215 |
{
|
|
216 |
if ( !iPeriodicTimer && IsVisible() && !iInPowerSaveMode )
|
|
217 |
{
|
|
218 |
TRAPD(err, iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle) );
|
|
219 |
if ( err == KErrNone )
|
|
220 |
{
|
|
221 |
const TInt KPeriodicTimerInterval = 100000; // 0.1 sec
|
|
222 |
iPeriodicTimer->Start( KPeriodicTimerInterval,
|
|
223 |
KPeriodicTimerInterval, TCallBack( TimerCallBack, this ) );
|
|
224 |
iSkinId = KAknsIIDQgnHomeRefreshing1;
|
|
225 |
}
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
// ----------------------------------------------------------------------------
|
|
230 |
// CXnAnimationAdapter::StopAnimation()
|
|
231 |
// ----------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void CXnAnimationAdapter::StopAnimation()
|
|
234 |
{
|
|
235 |
if ( iPeriodicTimer && iPeriodicTimer->IsActive() )
|
|
236 |
{
|
|
237 |
iPeriodicTimer->Cancel();
|
|
238 |
}
|
|
239 |
delete iPeriodicTimer;
|
|
240 |
iPeriodicTimer = NULL;
|
|
241 |
iSkinId = KAknsIIDNone;
|
|
242 |
}
|
|
243 |
|
|
244 |
// End of File
|
|
245 |
|