1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /* |
|
21 * File: ExtProgressContainer.cpp |
|
22 * Created: 14-10-2005 |
|
23 * Author: |
|
24 * |
|
25 */ |
|
26 |
|
27 #include "ExtProgressContainer.h" |
|
28 #include "ExtProgressAnimationControl.h" |
|
29 |
|
30 #include <eikprogi.h> |
|
31 #include <AknUtils.h> |
|
32 #include <eiklabel.h> |
|
33 #include <aknsbasicbackgroundcontrolcontext.h> |
|
34 #include <aknsdrawutils.h> |
|
35 #include <gdi.h> |
|
36 |
|
37 // Constants |
|
38 const TInt KProgressBarDefaultFinalValue = 20; |
|
39 const TInt KProgressBarDefaultHeight = 15; |
|
40 const TInt KProgressBarDefaultWidth = 240; |
|
41 |
|
42 // Positions |
|
43 const TReal KContTX = 0.00; |
|
44 const TReal KContTY = 0.20; |
|
45 const TReal KContBX = 1.00; |
|
46 const TReal KContBY = 1.00; |
|
47 |
|
48 const TReal KLabelTX = 0.10; |
|
49 const TReal KLabelTY = 0.10; |
|
50 const TReal KLabelBX = 0.90; |
|
51 const TReal KLabelBY = 0.30; |
|
52 |
|
53 const TReal KAnimTX = 0.10; |
|
54 const TReal KAnimTY = 0.30; |
|
55 const TReal KAnimBX = 0.90; |
|
56 const TReal KAnimBY = 0.80; |
|
57 |
|
58 const TReal KProgTX = 0.10; |
|
59 const TReal KProgTY = 0.80; |
|
60 //const TReal KProgBX = 0.70; |
|
61 //const TReal KProgBY = 0.90; |
|
62 |
|
63 |
|
64 |
|
65 //============================================================================= |
|
66 CExtProgressContainer * CExtProgressContainer::NewL (const TRect& aRect, CCoeControl* aParent) |
|
67 { |
|
68 CExtProgressContainer* self = new (ELeave) CExtProgressContainer(); |
|
69 CleanupStack::PushL(self); |
|
70 self->ConstructL(aRect, aParent); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 //============================================================================= |
|
76 CExtProgressContainer::CExtProgressContainer () |
|
77 { |
|
78 } |
|
79 |
|
80 //============================================================================= |
|
81 CExtProgressContainer::~CExtProgressContainer () |
|
82 { |
|
83 delete iProgressInfo; |
|
84 delete iAnimationControl; |
|
85 delete iLabel; |
|
86 delete iBgContext; |
|
87 } |
|
88 |
|
89 //============================================================================= |
|
90 void CExtProgressContainer::ConstructL (const TRect& aRect, CCoeControl* aParent) |
|
91 { |
|
92 SetContainerWindowL(*aParent); |
|
93 |
|
94 TRect rect; |
|
95 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); |
|
96 TSize size = rect.Size(); |
|
97 SetRect(TRect |
|
98 (static_cast<TInt>(size.iWidth * KContTX + 0.5), |
|
99 static_cast<TInt>(size.iHeight * KContTY + 0.5), |
|
100 static_cast<TInt>(size.iWidth * KContBX + 0.5), |
|
101 static_cast<TInt>(size.iHeight * KContBY + 0.5))); |
|
102 |
|
103 |
|
104 iLabel = new(ELeave) CEikLabel; |
|
105 iLabel->SetContainerWindowL(*this); |
|
106 |
|
107 iAnimationControl = CExtProgressAnimationControl::NewL(aRect, aParent); |
|
108 iAnimationControl->SetObserver(this); |
|
109 iAnimationControl->SetContainerWindowL(*this); |
|
110 |
|
111 // Set Progress Bar property, coding directly |
|
112 CEikProgressInfo::SInfo info; |
|
113 |
|
114 info.iHeight = KProgressBarDefaultHeight; |
|
115 info.iWidth = KProgressBarDefaultWidth; |
|
116 info.iSplitsInBlock = 0; |
|
117 info.iTextType = EEikProgressTextNone; |
|
118 info.iFinalValue = KProgressBarDefaultFinalValue; |
|
119 |
|
120 iProgressInfo = new( ELeave ) CEikProgressInfo( info ); |
|
121 |
|
122 iProgressInfo->ConstructL(); |
|
123 iProgressInfo->SetContainerWindowL(*this); |
|
124 |
|
125 SizeChanged(); |
|
126 |
|
127 ActivateL(); |
|
128 } |
|
129 |
|
130 //============================================================================= |
|
131 void CExtProgressContainer::HandleControlEventL( |
|
132 CCoeControl* /*aControl*/,TCoeEvent aEventType) |
|
133 { |
|
134 if (aEventType == MCoeControlObserver::EEventStateChanged ) |
|
135 { |
|
136 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
137 } |
|
138 |
|
139 } |
|
140 |
|
141 //============================================================================= |
|
142 TInt CExtProgressContainer::CountComponentControls() const |
|
143 { |
|
144 return 3; |
|
145 } |
|
146 |
|
147 //============================================================================= |
|
148 CCoeControl* CExtProgressContainer::ComponentControl(TInt aIndex) const |
|
149 { |
|
150 CCoeControl* ret = NULL; |
|
151 switch (aIndex) |
|
152 { |
|
153 case 0: |
|
154 { |
|
155 ret = iLabel; |
|
156 break; |
|
157 } |
|
158 case 1: |
|
159 { |
|
160 ret = iAnimationControl; |
|
161 break; |
|
162 } |
|
163 case 2: |
|
164 { |
|
165 ret = iProgressInfo; |
|
166 break; |
|
167 } |
|
168 default: |
|
169 { |
|
170 break; |
|
171 } |
|
172 |
|
173 } |
|
174 |
|
175 return ret; |
|
176 } |
|
177 |
|
178 //============================================================================= |
|
179 CEikProgressInfo* CExtProgressContainer::GetProgressInfoL() |
|
180 { |
|
181 return iProgressInfo; |
|
182 } |
|
183 |
|
184 //============================================================================= |
|
185 CExtProgressAnimationControl* CExtProgressContainer::GetAnimationControlL() |
|
186 { |
|
187 return iAnimationControl; |
|
188 } |
|
189 |
|
190 //============================================================================= |
|
191 void CExtProgressContainer::SetTextL(const TDesC &aText) |
|
192 { |
|
193 iLabel->SetTextL(aText); |
|
194 DrawNow(); |
|
195 } |
|
196 |
|
197 |
|
198 //============================================================================= |
|
199 void CExtProgressContainer::Draw(const TRect& aRect) const |
|
200 { |
|
201 CWindowGc& gc = SystemGc(); |
|
202 |
|
203 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
204 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
205 |
|
206 AknsDrawUtils::Background( skin, cc, this, gc, aRect ); |
|
207 // AknsDrawUtils::Background( skin, cc, iLabel, gc, aRect ); |
|
208 // AknsDrawUtils::Background( skin, cc, iProgressInfo, gc, aRect ); |
|
209 // AknsDrawUtils::Background( skin, cc, iAnimationControl, gc, aRect ); |
|
210 |
|
211 // Just draw a rectangle round the edge of the control. |
|
212 // CWindowGc& gc=SystemGc(); |
|
213 //gc.Clear(aRect); |
|
214 //gc.SetClippingRect(aRect); |
|
215 //gc.DrawRect(Rect()); |
|
216 } |
|
217 |
|
218 |
|
219 //============================================================================= |
|
220 void CExtProgressContainer::SizeChanged() |
|
221 { |
|
222 TRect rect( Rect() ); |
|
223 if ( iBgContext ) |
|
224 { |
|
225 iBgContext->SetRect( rect ); |
|
226 } |
|
227 |
|
228 TSize size= rect.Size(); |
|
229 |
|
230 if (iLabel) |
|
231 { |
|
232 iLabel->SetRect(TRect |
|
233 (static_cast<TInt>(size.iWidth * KLabelTX + 0.5), |
|
234 static_cast<TInt>(size.iHeight * KLabelTY + 0.5), |
|
235 static_cast<TInt>(size.iWidth * KLabelBX + 0.5), |
|
236 static_cast<TInt>(size.iHeight * KLabelBY + 0.5 ))); |
|
237 } |
|
238 |
|
239 if (iAnimationControl ) |
|
240 { |
|
241 iAnimationControl->SetRect(TRect |
|
242 (static_cast<TInt>(size.iWidth * KAnimTX + 0.5), |
|
243 static_cast<TInt>(size.iHeight * KAnimTY + 0.5), |
|
244 static_cast<TInt>(size.iWidth * KAnimBX + 0.5), |
|
245 static_cast<TInt>(size.iHeight * KAnimBY + 0.5))); |
|
246 } |
|
247 |
|
248 if (iProgressInfo) |
|
249 { |
|
250 TSize minSize = iProgressInfo->MinimumSize(); |
|
251 |
|
252 iProgressInfo->SetExtent(TPoint |
|
253 (static_cast<TInt>(size.iWidth * KProgTX + 0.5), |
|
254 static_cast<TInt>(size.iHeight * KProgTY + 0.5)), |
|
255 minSize); |
|
256 |
|
257 /* |
|
258 iProgressInfo->SetPosition(TPoint |
|
259 (size.iWidth * KProgTX, |
|
260 size.iHeight * KProgTY)); |
|
261 |
|
262 iProgressInfo->SetExtent(TRect |
|
263 (size.iWidth * KProgTX, |
|
264 size.iHeight * KProgTY, |
|
265 size.iWidth * KProgBX, |
|
266 size.iHeight * KProgBY)); |
|
267 */ |
|
268 } |
|
269 |
|
270 } |
|
271 |
|
272 //============================================================================= |
|
273 TTypeUid::Ptr CExtProgressContainer::MopSupplyObject( TTypeUid aId ) |
|
274 { |
|
275 if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext ) |
|
276 { |
|
277 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
278 } |
|
279 return CCoeControl::MopSupplyObject( aId ); |
|
280 } |
|
281 |
|
282 //============================================================================= |
|
283 TSize CExtProgressContainer::MinimumSize() |
|
284 { |
|
285 return Rect().Size(); |
|
286 } |
|
287 |
|
288 //============================================================================= |
|
289 void CExtProgressContainer::Test() |
|
290 { |
|
291 |
|
292 |
|
293 } |
|
294 |
|
295 // End of File |
|