|
1 /* |
|
2 * Copyright (c) 2010 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: CCoeControl to show a logo at camera application startup |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <fbs.h> |
|
19 #include <e32math.h> |
|
20 #include <e32debug.h> |
|
21 #include <akniconutils.h> |
|
22 #include <cameraapp.mbg> |
|
23 #include "camlogging.h" |
|
24 #include "camstartuplogo.h" |
|
25 |
|
26 _LIT(KCamBitmapFile, "z:\\resource\\apps\\cameraapp.mif"); |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Two-phased constructor |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CCamStartupLogo* CCamStartupLogo::NewL(CCamStartupLogoController& aController, |
|
33 const TRect& aRect) |
|
34 { |
|
35 PRINT(_L("Camera => CCamStartupLogo::NewL")) |
|
36 CCamStartupLogo* self = new (ELeave) CCamStartupLogo(aController, aRect); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 |
|
41 PRINT(_L("Camera <= CCamStartupLogo::NewL")) |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // C++ constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CCamStartupLogo::CCamStartupLogo(CCamStartupLogoController& aController, |
|
50 const TRect& aRect) |
|
51 : iRect(aRect), iController(aController) |
|
52 { |
|
53 // No implementation needed |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Destructor |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CCamStartupLogo::~CCamStartupLogo() |
|
61 { |
|
62 iController.RemoveObserver(this); |
|
63 |
|
64 delete iLogo; |
|
65 delete iLogoMask; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // 2nd phase constructor |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CCamStartupLogo::ConstructL() |
|
73 { |
|
74 PRINT(_L("Camera => CCamStartupLogo::ConstructL")) |
|
75 |
|
76 iController.AddObserver(this); |
|
77 |
|
78 if (iController.State() == EStartupLogoVisible) |
|
79 { |
|
80 ShowL(); |
|
81 } |
|
82 |
|
83 PRINT(_L("Camera <= CCamStartupLogo::ConstructL")) |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CCamStartupLogo::StartupLogoControllerStateChanged |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CCamStartupLogo::StartupLogoControllerStateChanged( |
|
91 TStartupLogoState aNewState) |
|
92 { |
|
93 PRINT(_L("Camera => CCamStartupLogo::StartupLogoControllerStateChanged")) |
|
94 |
|
95 if (aNewState == EStartupLogoNotVisible) |
|
96 { |
|
97 Hide(); |
|
98 } |
|
99 else if (aNewState == EStartupLogoVisible) |
|
100 { |
|
101 TRAP_IGNORE(ShowL()); |
|
102 } |
|
103 else |
|
104 { |
|
105 PRINT(_L("Camera <> StartupLogoControllerStateChanged - unknown state")) |
|
106 } |
|
107 |
|
108 PRINT(_L("Camera <= CCamStartupLogo::StartupLogoControllerStateChanged")) |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CCamStartupLogo::ShowL |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CCamStartupLogo::ShowL() |
|
116 { |
|
117 PRINT(_L("Camera => CCamStartupLogo::ShowL")) |
|
118 |
|
119 if (!iLogo || !iLogoMask) |
|
120 { |
|
121 delete iLogo; |
|
122 iLogo = NULL; |
|
123 delete iLogoMask; |
|
124 iLogoMask = NULL; |
|
125 |
|
126 TTime t0; |
|
127 t0.UniversalTime(); |
|
128 |
|
129 AknIconUtils::CreateIconL(iLogo, |
|
130 iLogoMask, |
|
131 KCamBitmapFile, |
|
132 EMbmCameraappQgn_menu_cams, |
|
133 EMbmCameraappQgn_menu_cams_mask); |
|
134 |
|
135 TSize logoSize(iRect.Size().iWidth/2, iRect.Size().iHeight/2); |
|
136 AknIconUtils::SetSize(iLogo, logoSize); |
|
137 |
|
138 TTime t1; |
|
139 t1.UniversalTime(); |
|
140 |
|
141 PRINT1(_L("Camera <> Startup icon load took %d us"), I64LOW(t1.MicroSecondsFrom(t0).Int64())) |
|
142 } |
|
143 |
|
144 if (!iWindowCreated) |
|
145 { |
|
146 CreateWindowL(); |
|
147 iWindowCreated = ETrue; |
|
148 } |
|
149 |
|
150 if (!IsActivated()) |
|
151 { |
|
152 ActivateL(); |
|
153 } |
|
154 |
|
155 SetExtentToWholeScreen(); |
|
156 |
|
157 MakeVisible(ETrue); |
|
158 RDrawableWindow* window = DrawableWindow(); |
|
159 if (window) |
|
160 { |
|
161 window->SetOrdinalPosition(0); |
|
162 } |
|
163 |
|
164 PRINT(_L("Camera <= CCamStartupLogo::ShowL")) |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CCamStartupLogo::Hide |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CCamStartupLogo::Hide() |
|
172 { |
|
173 PRINT(_L("Camera => CCamStartupLogo::Hide")) |
|
174 |
|
175 MakeVisible(EFalse); |
|
176 |
|
177 if (iWindowCreated) |
|
178 { |
|
179 CloseWindow(); |
|
180 iWindowCreated = EFalse; |
|
181 } |
|
182 |
|
183 delete iLogo; |
|
184 iLogo = NULL; |
|
185 delete iLogoMask; |
|
186 iLogoMask = NULL; |
|
187 |
|
188 PRINT(_L("Camera <= CCamStartupLogo::Hide")) |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CCamStartupLogo::Draw |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CCamStartupLogo::Draw(const TRect& /*aRect*/) const |
|
196 { |
|
197 PRINT(_L("Camera <> CCamStartupLogo::Draw")) |
|
198 |
|
199 CWindowGc& gc = SystemGc(); |
|
200 |
|
201 gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
202 gc.SetBrushColor(TRgb::Color16MA(0xFF000000)); // opaque black |
|
203 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
204 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
205 gc.DrawRect(Rect()); |
|
206 |
|
207 if (iLogo && iLogoMask) |
|
208 { |
|
209 TSize logoSize(iLogo->SizeInPixels()); |
|
210 TPoint logoTl(iRect.Center().iX - logoSize.iWidth / 2, |
|
211 iRect.Center().iY - logoSize.iHeight / 2); |
|
212 gc.BitBltMasked(logoTl, iLogo, TRect(logoSize), iLogoMask, EFalse); |
|
213 } |
|
214 } |
|
215 |