author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 11:51:19 +0300 | |
branch | RCL_3 |
changeset 62 | f0c0788c4de2 |
parent 57 | 2c87b2808fd7 |
child 67 | 756ad29ed18e |
permissions | -rw-r--r-- |
54 | 1 |
/* |
57
2c87b2808fd7
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
54
diff
changeset
|
2 |
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
54 | 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: Implemantation for CCamBatteryPaneDrawer class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "cambatterypanedrawer.h" |
|
20 |
||
21 |
#include <AknIconUtils.h> |
|
22 |
#include <AknUtils.h> |
|
23 |
#include <cameraapp.mbg> |
|
24 |
#include <aknconsts.h> // KAvkonBitmapFile |
|
25 |
#include <fbs.h> // FbsBitmap |
|
26 |
#include <AknsUtils.h> |
|
27 |
#include <AknIconUtils.h> |
|
28 |
#include <akniconconfig.h> |
|
29 |
#include <AknLayoutDef.h> // TAknWindowLineLayout |
|
30 |
#include <aknlayoutscalable_avkon.cdl.h> |
|
31 |
#include <aknlayoutscalable_apps.cdl.h> |
|
32 |
#include <layoutmetadata.cdl.h> |
|
33 |
||
34 |
#include <cameraapp.rsg> |
|
35 |
#include <vgacamsettings.rsg> |
|
36 |
||
37 |
#include "CamUtility.h" |
|
38 |
#include "cambitmapitem.h" |
|
39 |
||
40 |
const TInt KCamDefaultBatteryCellHeight = 3; |
|
41 |
const TInt KCamDefaultBatteryCellMargin = 1; |
|
42 |
||
43 |
const TInt KBatteryStrengthIcons[] = |
|
44 |
{ |
|
45 |
EMbmCameraappQgn_indi_cam4_battery_strength_0, |
|
46 |
EMbmCameraappQgn_indi_cam4_battery_strength_1, |
|
47 |
EMbmCameraappQgn_indi_cam4_battery_strength_2, |
|
48 |
EMbmCameraappQgn_indi_cam4_battery_strength_3, |
|
49 |
EMbmCameraappQgn_indi_cam4_battery_strength_4, |
|
50 |
EMbmCameraappQgn_indi_cam4_battery_strength_5, |
|
51 |
EMbmCameraappQgn_indi_cam4_battery_strength_6, |
|
52 |
EMbmCameraappQgn_indi_cam4_battery_strength_7 |
|
53 |
}; |
|
54 |
||
55 |
// --------------------------------------------------------------------------- |
|
56 |
// CCamBatteryPaneDrawer::CCamBatteryPaneDrawer |
|
57 |
// --------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
CCamBatteryPaneDrawer::CCamBatteryPaneDrawer() |
|
60 |
{ |
|
61 |
} |
|
62 |
||
63 |
// --------------------------------------------------------------------------- |
|
64 |
// CCamBatteryPaneDrawer::~CCamBatteryPaneDrawer |
|
65 |
// --------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
CCamBatteryPaneDrawer::~CCamBatteryPaneDrawer() |
|
68 |
{ |
|
69 |
PRINT ( _L("Camera => ~CCamBatteryPaneDrawer") ); |
|
70 |
||
71 |
DeleteIcons(); |
|
72 |
||
73 |
PRINT ( _L("Camera <= ~CCamBatteryPaneDrawer") ); |
|
74 |
} |
|
75 |
||
76 |
// --------------------------------------------------------------------------- |
|
77 |
// CCamBatteryPaneDrawer::NewL |
|
78 |
// --------------------------------------------------------------------------- |
|
79 |
// |
|
80 |
CCamBatteryPaneDrawer* CCamBatteryPaneDrawer::NewL() |
|
81 |
{ |
|
82 |
PRINT ( _L("Camera => CCamBatteryPaneDrawer::NewL") ); |
|
83 |
||
84 |
CCamBatteryPaneDrawer* self = new (ELeave) CCamBatteryPaneDrawer(); |
|
85 |
||
86 |
CleanupStack::PushL( self ); |
|
87 |
self->ConstructL(); |
|
88 |
CleanupStack::Pop(); // self |
|
89 |
PRINT ( _L("Camera <= CCamBatteryPaneDrawer::NewL") ); |
|
90 |
return self; |
|
91 |
} |
|
92 |
||
93 |
// --------------------------------------------------------------------------- |
|
94 |
// CCamBatteryPaneDrawer::ConstructL |
|
95 |
// --------------------------------------------------------------------------- |
|
96 |
// |
|
97 |
void CCamBatteryPaneDrawer::ConstructL() |
|
98 |
{ |
|
99 |
PRINT( _L("Camera => CCamBatteryPaneDrawer::ConstructL") ); |
|
100 |
||
101 |
// Load icon bitmaps |
|
102 |
LoadIconsL(); |
|
103 |
// Load/calculate layout data |
|
104 |
LoadLayoutsL(); |
|
105 |
||
106 |
PRINT( _L("Camera <= CCamBatteryPaneDrawer::ConstructL") ); |
|
107 |
} |
|
108 |
||
109 |
// --------------------------------------------------------------------------- |
|
110 |
// CCamBatteryPaneDrawer::SetBatteryStrength |
|
111 |
// --------------------------------------------------------------------------- |
|
112 |
// |
|
113 |
void CCamBatteryPaneDrawer::SetBatteryStrength( TInt aBatteryStrength ) |
|
114 |
{ |
|
115 |
iBatteryStrength = aBatteryStrength; |
|
116 |
} |
|
117 |
||
118 |
// --------------------------------------------------------------------------- |
|
119 |
// CCamBatteryPaneDrawer::SetLocation |
|
120 |
// --------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
void CCamBatteryPaneDrawer::SetLocation( const TPoint& aLocation ) |
|
123 |
{ |
|
124 |
iRect = TRect( aLocation, iRect.Size() ); |
|
125 |
} |
|
126 |
||
127 |
// --------------------------------------------------------------------------- |
|
128 |
// CCamBatteryPaneDrawer::LoadIconsL |
|
129 |
// --------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
void CCamBatteryPaneDrawer::LoadIconsL() |
|
132 |
{ |
|
133 |
PRINT( _L("Camera => CCamBatteryPaneDrawer::LoadIconsL") ); |
|
134 |
||
135 |
// Delete existing icon bitmaps |
|
136 |
DeleteIcons(); |
|
137 |
||
138 |
for( TInt index = KMinBatteryStrength; index <= KMaxBatteryStrength; index++ ) |
|
139 |
{ |
|
140 |
iBatteryIcons.AppendL( CCamBitmapItem::NewL( KBatteryStrengthIcons[index], |
|
141 |
KBatteryStrengthIcons[index] + 1) ); |
|
142 |
} |
|
143 |
||
144 |
PRINT( _L("Camera <= CCamBatteryPaneDrawer::LoadIconsL") ); |
|
145 |
} |
|
146 |
||
147 |
||
148 |
// --------------------------------------------------------------------------- |
|
149 |
// CCamBatteryPaneDrawer::Rect |
|
150 |
// --------------------------------------------------------------------------- |
|
151 |
// |
|
152 |
TRect CCamBatteryPaneDrawer::Rect() const |
|
153 |
{ |
|
154 |
return iRect; |
|
155 |
} |
|
156 |
||
157 |
// --------------------------------------------------------------------------- |
|
158 |
// CCamBatteryPaneDrawer::Draw |
|
159 |
// --------------------------------------------------------------------------- |
|
160 |
// |
|
161 |
void CCamBatteryPaneDrawer::Draw( CBitmapContext& aGc ) const |
|
162 |
{ |
|
163 |
iBatteryIcons[ iBatteryStrength ]->Draw( aGc ); |
|
164 |
} |
|
165 |
||
166 |
// --------------------------------------------------------------------------- |
|
167 |
// CCamBatteryPaneDrawer::ClearBattery |
|
168 |
// --------------------------------------------------------------------------- |
|
169 |
// |
|
170 |
void CCamBatteryPaneDrawer::ClearBattery( CBitmapContext& aGc ) const |
|
171 |
{ |
|
172 |
PRINT( _L("Camera => CCamBatteryPaneDrawer::ClearBattery") ); |
|
173 |
||
174 |
// Get the battery pane rectangle |
|
175 |
const TRect rect = Rect(); |
|
176 |
aGc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
177 |
aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
178 |
aGc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
179 |
aGc.SetBrushColor( TRgb::Color16MA( 0 ) ); |
|
180 |
aGc.Clear( rect ); //DrawRect( rect ); |
|
181 |
PRINT( _L("Camera <= CCamBatteryPaneDrawer::ClearBattery") ); |
|
182 |
} |
|
183 |
||
184 |
// --------------------------------------------------------------------------- |
|
185 |
// CCamBatteryPaneDrawer::LoadLayoutsL |
|
186 |
// --------------------------------------------------------------------------- |
|
187 |
// |
|
188 |
void CCamBatteryPaneDrawer::LoadLayoutsL() |
|
189 |
{ |
|
190 |
PRINT( _L("Camera => CCamBatteryPaneDrawer::LoadLayoutsL") ); |
|
57
2c87b2808fd7
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
54
diff
changeset
|
191 |
if ( AknLayoutUtils::PenEnabled() ) |
54 | 192 |
{ |
193 |
TouchLayoutL(); |
|
194 |
} |
|
195 |
else |
|
196 |
{ |
|
197 |
NonTouchLayoutL(); |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
||
202 |
// --------------------------------------------------------------------------- |
|
203 |
// CCamBatteryPaneDrawer::DeleteIcons |
|
204 |
// --------------------------------------------------------------------------- |
|
205 |
// |
|
206 |
void CCamBatteryPaneDrawer::DeleteIcons() |
|
207 |
{ |
|
208 |
iBatteryIcons.ResetAndDestroy(); |
|
209 |
} |
|
210 |
||
211 |
// --------------------------------------------------------------------------- |
|
212 |
// CCamBatteryPaneDrawer::HandleResourceChange |
|
213 |
// --------------------------------------------------------------------------- |
|
214 |
// |
|
215 |
void CCamBatteryPaneDrawer::HandleResourceChange( TInt /* aType */ ) |
|
216 |
{ |
|
217 |
PRINT( _L("Camera => CCamBatteryPaneDrawer::HandleResourceChange") ); |
|
218 |
||
219 |
// Called when either skin or color scheme has changed. |
|
220 |
// We need to reload icons and re-create the battery color bitmap. |
|
221 |
||
222 |
||
223 |
// Reload icons |
|
224 |
TRAP_IGNORE(LoadIconsL()); |
|
225 |
TRAP_IGNORE(LoadLayoutsL()); |
|
226 |
||
227 |
PRINT( _L("Camera <= CCamBatteryPaneDrawer::HandleResourceChange") ); |
|
228 |
} |
|
229 |
||
230 |
// --------------------------------------------------------------------------- |
|
231 |
// CCamBatteryPaneDrawer::NonTouchLayout |
|
232 |
// --------------------------------------------------------------------------- |
|
233 |
void CCamBatteryPaneDrawer::NonTouchLayoutL() |
|
234 |
{ |
|
235 |
TRect screen; |
|
236 |
TAknLayoutRect indicatorsPane; |
|
237 |
TAknLayoutRect batteryPane; |
|
238 |
TInt cba = AknLayoutUtils::CbaLocation() == |
|
239 |
AknLayoutUtils::EAknCbaLocationLeft? |
|
240 |
AknLayoutUtils::EAknCbaLocationLeft : 0; |
|
241 |
||
242 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
243 |
indicatorsPane.LayoutRect( screen, |
|
244 |
AknLayoutScalable_Apps::cam6_indi_pane( cba )); |
|
245 |
batteryPane.LayoutRect( indicatorsPane.Rect(), |
|
246 |
AknLayoutScalable_Apps::cam6_battery_pane( cba ) ); |
|
247 |
iRect = batteryPane.Rect(); |
|
248 |
||
249 |
TInt batteryIconsCount = iBatteryIcons.Count(); |
|
250 |
for( TInt index = 0; index < batteryIconsCount; index++ ) |
|
251 |
{ |
|
252 |
iBatteryIcons[index]->SetLayoutL( iRect ); |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
// --------------------------------------------------------------------------- |
|
257 |
// CCamBatteryPaneDrawer::TouchLayoutL |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
void CCamBatteryPaneDrawer::TouchLayoutL() |
|
260 |
{ |
|
261 |
TRect screen; |
|
262 |
TAknLayoutRect indicatorsPane; |
|
263 |
TAknLayoutRect batteryPane; |
|
264 |
TInt var = Layout_Meta_Data::IsLandscapeOrientation(); |
|
265 |
||
266 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen ); |
|
267 |
indicatorsPane.LayoutRect( screen, |
|
268 |
AknLayoutScalable_Apps::cam4_indicators_pane( var ).LayoutLine() ); |
|
269 |
batteryPane.LayoutRect( indicatorsPane.Rect(), |
|
270 |
AknLayoutScalable_Apps::cam4_battery_pane( var ).LayoutLine() ); |
|
271 |
iRect = batteryPane.Rect(); |
|
272 |
||
273 |
TInt batteryIconsCount = iBatteryIcons.Count(); |
|
274 |
for( TInt index = 0; index < batteryIconsCount; index++ ) |
|
275 |
{ |
|
276 |
iBatteryIcons[index]->SetLayoutL( iRect ); |
|
277 |
} |
|
278 |
||
279 |
} |
|
280 |
||
281 |
// End of file |
|
282 |