|
1 /* |
|
2 * Copyright (c) 2005-2008 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: CSysApShutdownImage implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknappui.h> |
|
21 #include <AknIconUtils.h> |
|
22 #include <AknUtils.h> |
|
23 #include <coemain.h> |
|
24 #include <barsread.h> //use of TResourceReader |
|
25 #include <sysap.mbg> |
|
26 #include "SysApShutdownImage.h" |
|
27 #include "SysAp.hrh" |
|
28 #include <data_caging_path_literals.hrh> |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================== |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CSysApShutdownImage::NewL() |
|
34 // ---------------------------------------------------------------------------- |
|
35 |
|
36 CSysApShutdownImage* CSysApShutdownImage::NewL() |
|
37 { |
|
38 TRACES( RDebug::Print( _L("CSysApSystemAgentObserver::NewL") ) ); |
|
39 CSysApShutdownImage* self = new ( ELeave ) CSysApShutdownImage(); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(); //self |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CSysApShutdownImage::ConstructL() |
|
48 // ---------------------------------------------------------------------------- |
|
49 |
|
50 void CSysApShutdownImage::ConstructL() |
|
51 { |
|
52 TRACES( RDebug::Print(_L("CSysApShutdownImage::ConstructL" ) ) ); |
|
53 CreateWindowL(); |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CSysApShutdownImage::CSysApShutdownImage() |
|
58 // ---------------------------------------------------------------------------- |
|
59 |
|
60 CSysApShutdownImage::CSysApShutdownImage() |
|
61 { |
|
62 TRACES( RDebug::Print(_L("CSysApShutdownImage::CSysApShutdownImage()" ) ) ); |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CSysApShutdownImage::ShowShutdownImage() |
|
67 // ---------------------------------------------------------------------------- |
|
68 |
|
69 void CSysApShutdownImage::ShowShutdownImageL(TInt aBitmapId) |
|
70 { |
|
71 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:start" ) ) ); |
|
72 TInt err ( 0 ); |
|
73 |
|
74 SetRect(iAvkonAppUi->ApplicationRect()); |
|
75 ActivateL(); |
|
76 |
|
77 if ( aBitmapId ) |
|
78 { |
|
79 _LIT( KDirAndFile, "z:sysap.mif" ); |
|
80 TParse* fp = new (ELeave) TParse(); |
|
81 CleanupStack::PushL(fp); |
|
82 fp->Set( KDirAndFile, &KDC_APP_BITMAP_DIR, NULL ); |
|
83 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL shutdown image: %S" ), &(fp->FullName())) ); |
|
84 RFs fs; |
|
85 |
|
86 err = fs.Connect(); |
|
87 if ( err == KErrNone ) |
|
88 { |
|
89 CleanupClosePushL(fs); |
|
90 TFindFile findFile( fs ); |
|
91 err = findFile.FindByPath( fp->FullName(), NULL ); |
|
92 |
|
93 if ( err != KErrNone ) |
|
94 { |
|
95 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL: shutdown image not found, err=%d"), err ) ); |
|
96 } |
|
97 else |
|
98 { |
|
99 delete iBitmap; |
|
100 iBitmap = NULL; |
|
101 // Ownership of bitmap is transferred to CSysApShutdownImage in CreateIconL |
|
102 iBitmap = AknIconUtils::CreateIconL( fp->FullName(), aBitmapId ); |
|
103 TAknLayoutRect bitmapRect; |
|
104 bitmapRect.LayoutRect( Rect(), AKN_LAYOUT_WINDOW_screen ); |
|
105 AknIconUtils::SetSize( iBitmap, bitmapRect.Rect().Size(), EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
106 TInt xDelta=0; // for x coordinates |
|
107 TInt yDelta=0; // for y coordinates |
|
108 TSize bmpSizeInPixels = iBitmap->SizeInPixels(); |
|
109 //center image to the center of the screen |
|
110 TRect rect = Rect(); |
|
111 xDelta=( rect.Width() - bmpSizeInPixels.iWidth ) / 2; |
|
112 yDelta=( rect.Height() - bmpSizeInPixels.iHeight ) / 2; |
|
113 TPoint pos = TPoint( xDelta , yDelta ); // displacement vector |
|
114 //pos += rect.iTl; // bitmap top left corner position |
|
115 CWindowGc& gc = SystemGc(); |
|
116 ActivateGc(); |
|
117 Window().Invalidate( rect ); |
|
118 Window().BeginRedraw( rect ); |
|
119 gc.Clear(); |
|
120 gc.BitBlt( pos, iBitmap ); // CWindowGc member function |
|
121 Window().EndRedraw(); |
|
122 DeactivateGc(); |
|
123 ControlEnv()->WsSession().Flush(); // force draw of the context |
|
124 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL:end" ) ) ); |
|
125 } |
|
126 } |
|
127 |
|
128 CleanupStack::PopAndDestroy(2); //fp, fs |
|
129 } |
|
130 else |
|
131 { |
|
132 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
133 DrawDeferred(); |
|
134 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
135 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShowShutdownImageL - Bitmap not defined, blank screen only" ) ) ); |
|
136 CWindowGc& gc = SystemGc(); |
|
137 ActivateGc(); |
|
138 Window().Invalidate(); |
|
139 Window().BeginRedraw(); |
|
140 gc.SetBrushColor(KRgbWhite); |
|
141 gc.Clear(); |
|
142 Window().EndRedraw(); |
|
143 DeactivateGc(); |
|
144 ControlEnv()->WsSession().Flush(); // force draw of the context |
|
145 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
146 } |
|
147 |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CSysApShutdownImage::ShutdownCoeControlWindow() |
|
152 // ---------------------------------------------------------------------------- |
|
153 |
|
154 RWindow& CSysApShutdownImage::ShutdownCoeControlWindow() |
|
155 { |
|
156 TRACES( RDebug::Print(_L("CSysApShutdownImage::ShutdownCoeControlWindow()" ) ) ); |
|
157 return Window(); |
|
158 } |
|
159 |
|
160 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
161 // --------------------------------------------------------------------------- |
|
162 // CSysApShutdownImage::SetComponent |
|
163 // |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CSysApShutdownImage::SetComponent( CCoeControl& aComponent ) |
|
167 { |
|
168 TRACES( RDebug::Print(_L("CSysApShutdownImage::SetComponent()" ) ) ); |
|
169 |
|
170 iComponent = &aComponent; |
|
171 |
|
172 TRACES( RDebug::Print(_L("CSysApShutdownImage::SetComponent(): End" ) ) ); |
|
173 } |
|
174 |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CSysApShutdownImage::RemoveComponent |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CSysApShutdownImage::RemoveComponent() |
|
182 { |
|
183 TRACES( RDebug::Print(_L("CSysApShutdownImage::RemoveComponent()" ) ) ); |
|
184 |
|
185 iComponent = NULL; |
|
186 |
|
187 TRACES( RDebug::Print(_L("CSysApShutdownImage::RemoveComponent(): End" ) ) ); |
|
188 } |
|
189 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
190 |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CSysApShutdownImage::~CSysApShutdownImage() |
|
194 // ---------------------------------------------------------------------------- |
|
195 |
|
196 CSysApShutdownImage::~CSysApShutdownImage() |
|
197 { |
|
198 delete iBitmap; |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------------------------------- |
|
202 // CSysApShutdownImage::ComponentControl(TInt /*aIndex*/) |
|
203 // ---------------------------------------------------------------------------- |
|
204 |
|
205 CCoeControl* CSysApShutdownImage::ComponentControl(TInt /*aIndex*/) const |
|
206 { |
|
207 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
208 return iComponent; |
|
209 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
210 return NULL; |
|
211 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
212 } |
|
213 |
|
214 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
215 // --------------------------------------------------------------------------- |
|
216 // CSysApShutdownImage::SizeChanged |
|
217 // |
|
218 // --------------------------------------------------------------------------- |
|
219 void CSysApShutdownImage::SizeChanged() |
|
220 { |
|
221 TRACES( RDebug::Print(_L("CSysApShutdownImage::SizeChanged()" ) ) ); |
|
222 |
|
223 if ( iComponent ) |
|
224 { |
|
225 iComponent->SetRect( Rect() ); |
|
226 } |
|
227 |
|
228 DrawNow(); |
|
229 |
|
230 TRACES( RDebug::Print(_L("CSysApShutdownImage::SizeChanged(): End" ) ) ); |
|
231 } |
|
232 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CSysApShutdownImage::CountComponentControls() |
|
236 // ---------------------------------------------------------------------------- |
|
237 |
|
238 TInt CSysApShutdownImage::CountComponentControls() const |
|
239 { |
|
240 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
241 if ( iComponent ) return 1; |
|
242 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
243 return 0; // return nbr of controls inside this container |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CSysApShutdownImage::Draw(const TRect& /*aRect*/ ) |
|
248 // ---------------------------------------------------------------------------- |
|
249 |
|
250 void CSysApShutdownImage::Draw(const TRect& /*aRect*/ ) const |
|
251 { |
|
252 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
253 TRACES( RDebug::Print(_L("CSysApShutdownImage::Draw()" ) ) ); |
|
254 TRACES( RDebug::Print(_L("CSysApShutdownImage: height: %d, width: %d" ), Rect().Height(), Rect().Width() ) ); |
|
255 |
|
256 CWindowGc& gc = SystemGc(); |
|
257 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
258 gc.SetBrushColor( KRgbWhite ); |
|
259 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
260 gc.Clear( Rect() ); |
|
261 |
|
262 TRACES( RDebug::Print(_L("CSysApShutdownImage::Draw(): End" ) ) ); |
|
263 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION |
|
264 } |
|
265 |
|
266 // ---------------------------------------------------------------------------- |
|
267 // CSysApShutdownImage::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
268 // ---------------------------------------------------------------------------- |
|
269 |
|
270 void CSysApShutdownImage::HandleControlEventL( |
|
271 CCoeControl* /*aControl*/, |
|
272 TCoeEvent /*aEventType*/) |
|
273 { |
|
274 //pure virtual from MCoeControlObserver |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CSysApShutdownImage::HandleControlEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
279 // ---------------------------------------------------------------------------- |
|
280 |
|
281 TKeyResponse CSysApShutdownImage::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
282 { |
|
283 return EKeyWasNotConsumed; |
|
284 } |
|
285 |
|
286 // End of File |