|
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 <aknsbasicbackgroundcontrolcontext.h> |
|
22 #include <aknsskininstance.h> |
|
23 #include <aknsutils.h> |
|
24 #include <aknutils.h> |
|
25 #include <aknsdrawutils.h> |
|
26 #include <gulicon.h> |
|
27 #include <akniconutils.h> |
|
28 #include <fbs.h> |
|
29 #include <BAUTILS.h> |
|
30 #include <eikbtgpc.h> |
|
31 #include <stringloader.h> |
|
32 #include <eikon.hrh> |
|
33 #include <avkon.hrh> |
|
34 #include <AknBidiTextUtils.h> |
|
35 #include <LayoutMetaData.cdl.h> |
|
36 #include "CCnUiSignInControl.h" |
|
37 #include "MCnUiWaitNoteObserver.h" |
|
38 #include <IMPSConnectionUiNG.rsg> |
|
39 #include <ChatNG.mbg> |
|
40 #include <AnimationConfig.h> |
|
41 #include <pathinfo.h> |
|
42 |
|
43 const TInt KMaxLength = 28; |
|
44 const TInt KDriveAndColon = 2; |
|
45 _LIT( KFileName, "z:\\resource\\apps\\chatng.mif" ); |
|
46 _LIT( KGifFileName, "signon.gif" ); |
|
47 |
|
48 CCnUiSignInControl* CCnUiSignInControl::NewL( const TDesC& aLabelText, MCnUiWaitNoteObserver* aObserver ) |
|
49 { |
|
50 CCnUiSignInControl* self = CCnUiSignInControl::NewLC( aLabelText, aObserver ); |
|
51 CleanupStack::Pop(); //self |
|
52 return self; |
|
53 } |
|
54 |
|
55 CCnUiSignInControl* CCnUiSignInControl::NewLC( const TDesC& aLabelText, MCnUiWaitNoteObserver* aObserver ) |
|
56 { |
|
57 CCnUiSignInControl* self = new ( ELeave ) CCnUiSignInControl( aObserver ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL( aLabelText ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 CCnUiSignInControl::CCnUiSignInControl( MCnUiWaitNoteObserver* aObserver ) : iObserver( aObserver ) |
|
64 { |
|
65 } |
|
66 |
|
67 void CCnUiSignInControl::ConstructL( const TDesC& aLabelText ) |
|
68 { |
|
69 CreateWindowL(); |
|
70 TRect clientRect; |
|
71 AknLayoutUtils::LayoutMetricsRect ( AknLayoutUtils::EMainPane, clientRect ); |
|
72 SetCanDrawOutsideRect(); |
|
73 |
|
74 //////////create status label///////////////////////////////////////////////// |
|
75 iLabel = new( ELeave ) CEikLabel; |
|
76 iLabel->SetContainerWindowL( *this ); |
|
77 iLabel->SetLabelAlignment( ELayoutAlignCenter ); |
|
78 iLabel->SetBrushStyleFromContext(); |
|
79 if ( AknLayoutUtils::Variant() == EApacVariant ) |
|
80 { |
|
81 iLabel->SetFont( ApacPlain16() ); |
|
82 } |
|
83 else |
|
84 { |
|
85 iLabel->SetFont( LatinBold17() ); |
|
86 } |
|
87 AssignSignInText( aLabelText ); |
|
88 |
|
89 TInt xPos = clientRect.iTl.iX + 20; |
|
90 TInt yPos = ( clientRect.iBr.iY * 9 ) / 16; |
|
91 iLabel->SetExtent( TPoint( xPos, yPos ), TSize( clientRect.iBr.iX - 40, 60 ) ); |
|
92 iLabel->SetBackground( this ); |
|
93 iLabel->MakeVisible( ETrue ); |
|
94 ///////////////////////////////////////////////////////////////////////////////// |
|
95 |
|
96 ///////////Sign-in Background//////////////////////////////////////////////////// |
|
97 CFbsBitmap* bitmap; |
|
98 CFbsBitmap* mask; |
|
99 TSize size; |
|
100 AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EMainPane, size ); |
|
101 AknIconUtils::CreateIconL( bitmap, mask, KFileName, EMbmChatngQgn_graf_im_signin_screen, EMbmChatngQgn_graf_im_signin_screen_mask ); |
|
102 AknIconUtils::SetSize( bitmap, size, EAspectRatioPreserved ); |
|
103 AknIconUtils::SetSize( mask, size, EAspectRatioPreserved ); |
|
104 |
|
105 CleanupStack::PushL( bitmap ); |
|
106 CleanupStack::PushL( mask ); |
|
107 iImage = CGulIcon::NewL( bitmap, mask ); |
|
108 CleanupStack::Pop( 2 ); // bitmap and mask |
|
109 ////////////////////////////////////////////////////////////////////////////////// |
|
110 |
|
111 ////////////Sign-in Animation///////////////////////////////////////////////////// |
|
112 TInt err = iFs.Connect(); |
|
113 if ( err ) |
|
114 { |
|
115 User::Leave( err ); |
|
116 } |
|
117 // Get ROM and C drives |
|
118 TBuf<KDriveAndColon> romDrive; |
|
119 romDrive = PathInfo::RomRootPath().Left( KDriveAndColon ); |
|
120 |
|
121 TFileName fn; |
|
122 iFs.PrivatePath( fn ); |
|
123 BaflUtils::EnsurePathExistsL( iFs, fn ); |
|
124 fn.Insert( 0, romDrive ); |
|
125 fn.Append( KGifFileName ); |
|
126 |
|
127 CICLAnimationDataProvider* aGifProvider; |
|
128 aGifProvider = new ( ELeave ) CICLAnimationDataProvider; |
|
129 CleanupStack::PushL( aGifProvider ); |
|
130 aGifProvider->SetFileL( iFs, fn ); |
|
131 CleanupStack::Pop( aGifProvider ); |
|
132 |
|
133 TAnimationConfig aGifConfig; |
|
134 aGifConfig.iFlags = TAnimationConfig::ELoop; |
|
135 aGifConfig.iData = 100; |
|
136 |
|
137 iGifImage = CBasicAnimation::NewL( aGifProvider , TPoint( 0, 0 ), CEikonEnv::Static()->WsSession(), Window() ); |
|
138 TInt animXPos = clientRect.Width() / 2 - 20; |
|
139 TInt animYPos = yPos - 45; |
|
140 iGifImage->SetPosition( TPoint( animXPos, animYPos ) ); |
|
141 iGifImage->Start( aGifConfig ); |
|
142 //////////////////////////////////////////////////////////////////////////////////// |
|
143 |
|
144 ////////Create a CBA for use with this control////////////////////////////////////// |
|
145 iPopoutCba = CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::ECba, |
|
146 CEikButtonGroupContainer::EHorizontal, this, R_AVKON_SOFTKEYS_CANCEL ); |
|
147 |
|
148 iPopoutCba->MakeVisible( ETrue ); |
|
149 //////////////////////////////////////////////////////////////////////////////////// |
|
150 |
|
151 // Sets rectangle of frame. |
|
152 SetRect( clientRect ); |
|
153 |
|
154 ActivateL(); |
|
155 // Activates the window. (Ready to draw |
|
156 MakeVisible( ETrue ); |
|
157 } |
|
158 |
|
159 // Fix codescanner warning: Pointer access in destructors |
|
160 void CCnUiSignInControl::MakeCbaInvisible() |
|
161 { |
|
162 iPopoutCba->MakeVisible( EFalse ); |
|
163 } |
|
164 CCnUiSignInControl::~CCnUiSignInControl() |
|
165 { |
|
166 iObserver = NULL; |
|
167 |
|
168 MakeVisible( EFalse ); |
|
169 delete iLabel; |
|
170 |
|
171 MakeCbaInvisible(); |
|
172 delete iPopoutCba; |
|
173 |
|
174 delete iImage; |
|
175 iFs.Close(); |
|
176 delete iGifImage; |
|
177 } |
|
178 |
|
179 void CCnUiSignInControl::SizeChanged() |
|
180 { |
|
181 // |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------- |
|
185 // CCnUiSignInControl::CountComponentControls() const |
|
186 // --------------------------------------------------------- |
|
187 // |
|
188 TInt CCnUiSignInControl::CountComponentControls() const |
|
189 { |
|
190 return 1; // return numberr of controls inside this container |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------- |
|
194 // CCnUiSignInControl::ComponentControl(TInt aIndex) const |
|
195 // --------------------------------------------------------- |
|
196 // |
|
197 CCoeControl* CCnUiSignInControl::ComponentControl( TInt aIndex ) const |
|
198 { |
|
199 switch ( aIndex ) |
|
200 { |
|
201 case 0: |
|
202 return iLabel; |
|
203 default: |
|
204 return NULL; |
|
205 } |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------- |
|
209 // CCnUiSignInControl::Draw(const TRect& aRect) const |
|
210 // --------------------------------------------------------- |
|
211 // |
|
212 void CCnUiSignInControl::Draw( const TRect& aRect ) const |
|
213 { |
|
214 CWindowGc& gc = SystemGc(); |
|
215 // gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
216 // gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
217 // gc.DrawRect( aRect ); |
|
218 |
|
219 if ( iImage ) |
|
220 { |
|
221 //TSize imageSize = iImage->Bitmap()->SizeInPixels(); |
|
222 TSize imageSize; |
|
223 AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EMainPane, imageSize ); |
|
224 TInt leftPadding = 0; |
|
225 TInt upperPadding = 0; |
|
226 if ( imageSize.iWidth < Rect().Width() ) |
|
227 { |
|
228 leftPadding = ( Rect().Width() - imageSize.iWidth ) / 2; |
|
229 } |
|
230 |
|
231 if ( imageSize.iHeight < Rect().Height() ) |
|
232 { |
|
233 upperPadding = ( Rect().Height() - imageSize.iHeight ) / 2; |
|
234 } |
|
235 |
|
236 gc.Clear(); //(rect); |
|
237 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
238 gc.BitBltMasked( TPoint( leftPadding, upperPadding ), iImage->Bitmap(), aRect, iImage->Mask(), EFalse ); |
|
239 } |
|
240 |
|
241 if ( iGifImage ) |
|
242 { |
|
243 iGifImage->Draw( gc ); |
|
244 } |
|
245 } |
|
246 |
|
247 void CCnUiSignInControl::Draw( CWindowGc& /*aGc*/, const CCoeControl& /*aControl*/, const TRect& /*aRect*/ ) const |
|
248 { |
|
249 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
250 } |
|
251 |
|
252 void CCnUiSignInControl::ProcessCommandL( TInt aCommandId ) |
|
253 { |
|
254 //TO DO |
|
255 // Respond to softkey events |
|
256 switch ( aCommandId ) |
|
257 { |
|
258 case EAknSoftkeyCancel: |
|
259 if ( iObserver ) |
|
260 { |
|
261 iObserver->HandleWaitNoteCancel(); |
|
262 } |
|
263 break; |
|
264 } |
|
265 } |
|
266 |
|
267 void CCnUiSignInControl::HideStatus() |
|
268 { |
|
269 iPopoutCba->MakeVisible( EFalse ); |
|
270 } |
|
271 |
|
272 void CCnUiSignInControl::StopAnimation() |
|
273 { |
|
274 iGifImage->Stop(); |
|
275 } |
|
276 void CCnUiSignInControl::AssignSignInText( const TDesC& aLabelText ) |
|
277 { |
|
278 TInt aTempLength = aLabelText.Length(); |
|
279 if ( aTempLength > KMaxLength ) |
|
280 { |
|
281 TPtrC aTempPtr; |
|
282 aTempPtr.Set( aLabelText.Left( KMaxLength ) ); |
|
283 TBuf<56> aTruncateRecipient( aTempPtr ); |
|
284 aTruncateRecipient.Append( _L( "\n" ) ); |
|
285 aTruncateRecipient.Append( aLabelText.Right( aTempLength - KMaxLength ) ); |
|
286 iLabel->SetTextL( aTruncateRecipient ); |
|
287 } |
|
288 else |
|
289 { |
|
290 iLabel->SetTextL( aLabelText ); |
|
291 } |
|
292 } |
|
293 TKeyResponse CCnUiSignInControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
294 { |
|
295 if ( ( aType == EEventKey ) && ( aKeyEvent.iCode == EKeyOK ) ) |
|
296 { |
|
297 if ( iObserver ) |
|
298 { |
|
299 iObserver->HandleWaitNoteCancel(); |
|
300 } |
|
301 return EKeyWasConsumed; |
|
302 } |
|
303 return EKeyWasNotConsumed; |
|
304 } |
|
305 |
|
306 void CCnUiSignInControl::HandleResourceChange( TInt aType ) |
|
307 { |
|
308 CCoeControl::HandleResourceChange( aType ); |
|
309 TRect rect; |
|
310 AknLayoutUtils::LayoutMetricsRect ( AknLayoutUtils::EMainPane, rect ); |
|
311 SetRect( rect ); |
|
312 |
|
313 TInt xPos = rect.iTl.iX + 20; |
|
314 TInt yPos = ( rect.iBr.iY * 9 ) / 16; |
|
315 |
|
316 if ( LandscapeOrientation() ) |
|
317 { |
|
318 delete iImage; |
|
319 iImage = NULL; |
|
320 |
|
321 CFbsBitmap* aChangedBitmap; |
|
322 CFbsBitmap* aChangedMask; |
|
323 AknIconUtils::CreateIconL( aChangedBitmap, aChangedMask, KFileName, EMbmChatngQgn_graf_im_signin_screen, EMbmChatngQgn_graf_im_signin_screen_mask ); |
|
324 AknIconUtils::SetSize( aChangedBitmap, rect.Size(), EAspectRatioPreserved ); |
|
325 AknIconUtils::SetSize( aChangedMask, rect.Size(), EAspectRatioPreserved ); |
|
326 |
|
327 CleanupStack::PushL( aChangedBitmap ); |
|
328 CleanupStack::PushL( aChangedMask ); |
|
329 iImage = CGulIcon::NewL( aChangedBitmap, aChangedMask ); |
|
330 CleanupStack::Pop( 2 ); // bitmap and mask |
|
331 |
|
332 iLabel->SetExtent( TPoint( xPos, yPos ), TSize( rect.iBr.iX - 40, 60 ) ); |
|
333 } |
|
334 DrawNow(); |
|
335 } |
|
336 |
|
337 // ---------------------------------------------------------------------------- |
|
338 // CCnUiSignInControl::LandscapeOrientation |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 TBool CCnUiSignInControl::LandscapeOrientation() const |
|
342 { |
|
343 TBool landscape = EFalse; |
|
344 landscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
345 return landscape; |
|
346 } |
|
347 |
|
348 // End of File |