|
1 /* |
|
2 * Copyright (c) 2006-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: AppUi class of application |
|
15 * Since : 3.2 |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <gulicon.h> |
|
22 #include <aknutils.h> |
|
23 #include <akniconutils.h> |
|
24 #include <LayoutMetaData.cdl.h> |
|
25 #include "CCASplashScreen.h" |
|
26 #include "CCASplashScreenControl.h" |
|
27 #include "CCAAppUi.h" |
|
28 #include <ChatNG.mbg> |
|
29 |
|
30 _LIT( KFileName, "z:\\resource\\apps\\chatng.mif" ); |
|
31 |
|
32 CCASplashScreenControl* CCASplashScreenControl::NewL( CCASplashScreen &aParent ) |
|
33 { |
|
34 CCASplashScreenControl* self = CCASplashScreenControl::NewLC( aParent ); |
|
35 CleanupStack::Pop(); //self |
|
36 return self; |
|
37 } |
|
38 |
|
39 CCASplashScreenControl* CCASplashScreenControl::NewLC( CCASplashScreen &aParent ) |
|
40 { |
|
41 CCASplashScreenControl* self = new ( ELeave ) CCASplashScreenControl( aParent ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 CCASplashScreenControl::CCASplashScreenControl( CCASplashScreen &aParent ) |
|
48 : iParent( aParent ), iSplashDismissed( EFalse ) |
|
49 { |
|
50 } |
|
51 |
|
52 void CCASplashScreenControl::ConstructL() |
|
53 { |
|
54 CreateWindowL(); |
|
55 SetExtentToWholeScreen(); |
|
56 ActivateL(); |
|
57 MakeVisible( ETrue ); |
|
58 } |
|
59 |
|
60 CCASplashScreenControl::~CCASplashScreenControl() |
|
61 { |
|
62 delete iSplashImage; |
|
63 } |
|
64 |
|
65 void CCASplashScreenControl::SizeChanged() |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CCASplashScreenControl::CountComponentControls() const |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 TInt CCASplashScreenControl::CountComponentControls() const |
|
74 { |
|
75 return 0; // return nbr of controls inside this container |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CCASplashScreenControl::ComponentControl(TInt aIndex) const |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 CCoeControl* CCASplashScreenControl::ComponentControl( TInt aIndex ) const |
|
83 { |
|
84 switch ( aIndex ) |
|
85 { |
|
86 //case 0: |
|
87 // return iLabel; |
|
88 default: |
|
89 return NULL; |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CCASplashScreenControl::Draw(const TRect& aRect) const |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CCASplashScreenControl::Draw( const TRect& /*aRect*/ ) const |
|
98 { |
|
99 CWindowGc& gc = SystemGc(); |
|
100 |
|
101 if ( iSplashImage ) |
|
102 { |
|
103 TSize splashSize = iSplashImage->Bitmap()->SizeInPixels(); |
|
104 // DLINFO(( "Splash image size: width=%d height=%d", |
|
105 // splashSize.iWidth, splashSize.iHeight )); |
|
106 |
|
107 // calculate the splash image upper left point position |
|
108 // so that the image is centered. |
|
109 TInt leftPadding = 0; |
|
110 TInt upperPadding = 0; |
|
111 if ( splashSize.iWidth < Rect().Width() ) |
|
112 { |
|
113 leftPadding = ( Rect().Width() - splashSize.iWidth ) / 2; |
|
114 } |
|
115 |
|
116 if ( splashSize.iHeight < Rect().Height() ) |
|
117 { |
|
118 upperPadding = ( Rect().Height() - splashSize.iHeight ) / 2; |
|
119 } |
|
120 |
|
121 TRect rect = TRect( TPoint( 0, 0 ), splashSize ); |
|
122 gc.Clear(); //(rect); |
|
123 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
124 gc.BitBltMasked( TPoint( leftPadding, upperPadding ), iSplashImage->Bitmap(), rect, iSplashImage->Mask(), EFalse ); |
|
125 } |
|
126 |
|
127 } |
|
128 |
|
129 |
|
130 TKeyResponse CCASplashScreenControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
131 { |
|
132 if ( ( iDismissable && !iSplashDismissed ) || ( ( aType == EEventKey ) && ( aKeyEvent.iCode == EKeyNo ) ) ) |
|
133 { |
|
134 iParent.DismissSplashScreen(); |
|
135 iSplashDismissed = ETrue; |
|
136 |
|
137 return EKeyWasConsumed; |
|
138 } |
|
139 else |
|
140 { |
|
141 return EKeyWasNotConsumed; |
|
142 } |
|
143 |
|
144 |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CCASplashScreenControl::HandleControlEventL( |
|
149 // CCoeControl* aControl,TCoeEvent aEventType) |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CCASplashScreenControl::HandleControlEventL( |
|
153 CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ ) |
|
154 { |
|
155 } |
|
156 |
|
157 void CCASplashScreenControl::ShowSplashScreen( CGulIcon* aSplashImage, |
|
158 /*MNcdSkinData* aSkinData,*/ |
|
159 TBool aDismissable ) |
|
160 { |
|
161 delete iSplashImage; |
|
162 iSplashImage = NULL; |
|
163 |
|
164 iSplashImage = aSplashImage; |
|
165 |
|
166 iDismissable = aDismissable; |
|
167 |
|
168 // iSkinData = aSkinData; |
|
169 } |
|
170 |
|
171 void CCASplashScreenControl::HandleResourceChange( TInt aType ) |
|
172 { |
|
173 CCoeControl::HandleResourceChange( aType ); |
|
174 |
|
175 TRect rect = iEikonEnv->EikAppUi()->ApplicationRect(); |
|
176 SetRect( rect ); |
|
177 |
|
178 TSize screenSize; |
|
179 AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EScreen, |
|
180 screenSize ); |
|
181 if ( LandscapeOrientation() ) |
|
182 { |
|
183 delete iSplashImage; |
|
184 iSplashImage = NULL; |
|
185 |
|
186 CFbsBitmap* aChangedBitmap; |
|
187 CFbsBitmap* aChangedMask; |
|
188 AknIconUtils::CreateIconL( aChangedBitmap, aChangedMask, KFileName, EMbmChatngQgn_graf_im_splash_screen, EMbmChatngQgn_graf_im_splash_screen_mask ); |
|
189 AknIconUtils::SetSize( aChangedBitmap, screenSize, EAspectRatioPreserved ); |
|
190 AknIconUtils::SetSize( aChangedMask, screenSize, EAspectRatioPreserved ); |
|
191 |
|
192 CleanupStack::PushL( aChangedBitmap ); |
|
193 CleanupStack::PushL( aChangedMask ); |
|
194 iSplashImage = CGulIcon::NewL( aChangedBitmap, aChangedMask ); |
|
195 CleanupStack::Pop( 2 ); // bitmap and mask |
|
196 } |
|
197 DrawNow(); |
|
198 /* |
|
199 TRect rect = iEikonEnv->EikAppUi()->ApplicationRect(); |
|
200 |
|
201 SetRect( rect ); |
|
202 |
|
203 delete iSplashImage; |
|
204 iSplashImage = NULL; |
|
205 |
|
206 if ( InLandScapeMode() ) |
|
207 { |
|
208 TRAP_IGNORE( iSplashImage = iSkinData->GetSplashScreenLandscapeL() ); |
|
209 } |
|
210 else |
|
211 { |
|
212 TRAP_IGNORE( iSplashImage = iSkinData->GetSplashScreenPortraitL() ); |
|
213 } |
|
214 */ |
|
215 // DrawDeferred(); |
|
216 // DrawNow(); |
|
217 } |
|
218 |
|
219 // ---------------------------------------------------------------------------- |
|
220 // CCASplashScreenControl::LandscapeOrientation |
|
221 // ---------------------------------------------------------------------------- |
|
222 // |
|
223 TBool CCASplashScreenControl::LandscapeOrientation() const |
|
224 { |
|
225 TBool landscape = EFalse; |
|
226 landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
227 return landscape; |
|
228 } |
|
229 |
|
230 |
|
231 // End of File |