|
1 /* |
|
2 * Copyright (c) 2002 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 the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Helper class to put animation to contextPane. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "BrowserAnimation.h" |
|
24 #include "logger.h" |
|
25 |
|
26 #include <aknappui.h> |
|
27 #include <eikspane.h> |
|
28 #include <akncontext.h> |
|
29 #include <AknBitmapAnimation.h> |
|
30 #include <barsread.h> // for TResourceReader |
|
31 #include <AknsUtils.h> // for TAknsItemID |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CBrowserAnimation::NewL() |
|
37 // --------------------------------------------------------- |
|
38 // |
|
39 CBrowserAnimation* CBrowserAnimation::NewL( TInt aResourceId ) |
|
40 { |
|
41 LOG_ENTERFN("Anim::NewL"); |
|
42 CBrowserAnimation* self = new( ELeave )CBrowserAnimation; |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aResourceId ); |
|
45 CleanupStack::Pop(); // self |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CBrowserAnimation::~CBrowserAnimation() |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 CBrowserAnimation::~CBrowserAnimation() |
|
54 { |
|
55 delete iAnimation; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CBrowserAnimation::StartL() |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 void CBrowserAnimation::StartL() |
|
63 { |
|
64 LOG_ENTERFN("Anim::StartL"); |
|
65 if ( iAnimation && !iIsRunning ) |
|
66 { |
|
67 // Getting status pane control |
|
68 CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, |
|
69 CEikonEnv::Static()->EikAppUi() ) |
|
70 ->StatusPane(); |
|
71 |
|
72 // Fetch pointer to contextpane |
|
73 CAknContextPane* contextPane = STATIC_CAST( CAknContextPane*, |
|
74 sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ); |
|
75 |
|
76 //this sets an empty bitmap to the contextpanes background to |
|
77 //avoid to have the original one in the back of the animation |
|
78 //the ownership is taken by the contextpane |
|
79 CFbsBitmap *emptyFbsBitmap = new (ELeave) CFbsBitmap(); |
|
80 |
|
81 CleanupStack::PushL( emptyFbsBitmap ); |
|
82 emptyFbsBitmap->Create( TSize(1, 1), ENone); |
|
83 CEikImage * emptyEikImage = new (ELeave) CEikImage( ); |
|
84 emptyEikImage->SetBitmap( emptyFbsBitmap ); |
|
85 contextPane->SetPicture( emptyEikImage ); |
|
86 CleanupStack::Pop();//emptyFbsBitmap ownership is taken |
|
87 |
|
88 iAnimation->StartAnimationL(); // displays the animation |
|
89 iIsRunning = ETrue; |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CBrowserAnimation::StopL() |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CBrowserAnimation::StopL() |
|
98 { |
|
99 LOG_ENTERFN("Anim::StopL"); |
|
100 if ( iAnimation && iIsRunning ) // Is the animation running? |
|
101 { |
|
102 iAnimation->CancelAnimation(); // ends the animation |
|
103 iIsRunning = EFalse; |
|
104 |
|
105 // Getting status pane control |
|
106 CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, |
|
107 CEikonEnv::Static()->EikAppUi() )->StatusPane(); |
|
108 |
|
109 // Fetch pointer to contextpane |
|
110 CAknContextPane* contextPane = NULL; |
|
111 TRAP_IGNORE( contextPane = STATIC_CAST( CAknContextPane*, sp->ControlL |
|
112 ( TUid::Uid( EEikStatusPaneUidContext ) ) ) ); |
|
113 |
|
114 if ( contextPane ) |
|
115 { |
|
116 contextPane->SetPictureToDefaultL(); |
|
117 contextPane->DrawNow(); // draw original icon |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CBrowserAnimation::ConstructL() |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CBrowserAnimation::ConstructL( TInt aResourceId ) |
|
127 { |
|
128 LOG_ENTERFN("Anim::ConstructL"); |
|
129 PERFLOG_LOCAL_INIT |
|
130 PERFLOG_STOPWATCH_START |
|
131 // Getting status pane control |
|
132 CEikStatusPane* sp = STATIC_CAST( CAknAppUi*, |
|
133 CEikonEnv::Static()->EikAppUi() ) ->StatusPane(); |
|
134 |
|
135 if ((sp && sp->PaneCapabilities( |
|
136 TUid::Uid(EEikStatusPaneUidContext)).IsInCurrentLayout())) |
|
137 { |
|
138 // Fetch pointer to contextpane |
|
139 CAknContextPane* contextPane = |
|
140 STATIC_CAST( CAknContextPane*, |
|
141 sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ); |
|
142 |
|
143 iAnimation = CAknBitmapAnimation::NewL(); |
|
144 iAnimation->SetContainerWindowL( *contextPane ); |
|
145 |
|
146 TResourceReader rr; |
|
147 TAknsItemID animationSkinID; |
|
148 animationSkinID.Set( EAknsMajorAvkon, aResourceId ); |
|
149 |
|
150 if( !iAnimation->ConstructFromSkinL( animationSkinID ) ) |
|
151 { |
|
152 iAnimation->ControlEnv()->CreateResourceReaderLC( rr, aResourceId ); |
|
153 iAnimation->ConstructFromResourceL( rr ); // read from resource |
|
154 CleanupStack::PopAndDestroy(); // rr |
|
155 } |
|
156 |
|
157 iAnimation->SetRect(contextPane->Rect()); |
|
158 PERFLOG_STOP_WRITE("Animation ConstructL phase 1") |
|
159 #if 0 |
|
160 // Start and stop animation out of the screen. |
|
161 // This way it saves context pane's content as background frame. |
|
162 const TInt KWmlAnimationDummyPos = 1000; |
|
163 iAnimation->SetPosition( TPoint( KWmlAnimationDummyPos, |
|
164 KWmlAnimationDummyPos ) ); |
|
165 iAnimation->SetRect(contextPane->Rect()); |
|
166 PERFLOG_STOPWATCH_START |
|
167 StartL(); |
|
168 StopL(); |
|
169 iAnimation->SetPosition( TPoint( 0, 0 ) ); |
|
170 PERFLOG_STOP_WRITE("Animation ConstructL phase 2") |
|
171 #endif |
|
172 } |
|
173 } |
|
174 |
|
175 // End of File |