|
1 /* |
|
2 * Copyright (c) 1997-1999 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikprogi.h> |
|
20 #include <eikon.hrh> |
|
21 #include <eikpanic.h> |
|
22 #include <coemain.h> |
|
23 #include <barsread.h> |
|
24 #include <gulbordr.h> |
|
25 #include <eikenv.h> |
|
26 |
|
27 #include <gulcolor.h> |
|
28 #include <avkon.mbg> |
|
29 #include <aknconsts.h> |
|
30 |
|
31 #include <AknsUtils.h> |
|
32 #include <AknsDrawUtils.h> |
|
33 |
|
34 #include <AknUtils.h> // for arabic texts support |
|
35 |
|
36 #include <AknIconUtils.h> |
|
37 |
|
38 #include <applayout.cdl.h> |
|
39 #include <aknlayoutscalable_avkon.cdl.h> |
|
40 #include <aknappui.h> |
|
41 #include <bitdev.h> |
|
42 using namespace AppLayout; |
|
43 |
|
44 const TInt KDefaultSpaceBetweenBlocks=1; |
|
45 |
|
46 class CEikProgressInfoExtension : public CBase |
|
47 { |
|
48 public: |
|
49 CEikProgressInfoExtension(); |
|
50 ~CEikProgressInfoExtension(); |
|
51 |
|
52 void DeleteBitmaps(); |
|
53 |
|
54 CFbsBitmap* iFrameLeft; |
|
55 CFbsBitmap* iFrameCenter; |
|
56 CFbsBitmap* iFrameRight; |
|
57 |
|
58 CFbsBitmap* iFrameLeftMask; |
|
59 CFbsBitmap* iFrameCenterMask; |
|
60 CFbsBitmap* iFrameRightMask; |
|
61 |
|
62 CFbsBitmap* iOldBackgroundBitmapMask; |
|
63 }; |
|
64 |
|
65 CEikProgressInfoExtension::CEikProgressInfoExtension() |
|
66 { |
|
67 } |
|
68 CEikProgressInfoExtension::~CEikProgressInfoExtension() |
|
69 { |
|
70 } |
|
71 |
|
72 void CEikProgressInfoExtension::DeleteBitmaps() |
|
73 { |
|
74 delete iFrameLeft; |
|
75 iFrameLeft = NULL; |
|
76 delete iFrameCenter; |
|
77 iFrameCenter = NULL; |
|
78 delete iFrameRight; |
|
79 iFrameRight = NULL; |
|
80 delete iFrameLeftMask; |
|
81 iFrameLeftMask = NULL; |
|
82 delete iFrameCenterMask; |
|
83 iFrameCenterMask = NULL; |
|
84 delete iFrameRightMask; |
|
85 iFrameRightMask = NULL; |
|
86 delete iOldBackgroundBitmapMask; |
|
87 iOldBackgroundBitmapMask = NULL; |
|
88 } |
|
89 |
|
90 EXPORT_C CEikProgressInfo::~CEikProgressInfo() |
|
91 { |
|
92 DeleteBitmaps(); |
|
93 delete iExtension; |
|
94 AknsUtils::DeregisterControlPosition(this); |
|
95 } |
|
96 |
|
97 EXPORT_C CEikProgressInfo::CEikProgressInfo() |
|
98 { |
|
99 __DECLARE_NAME(_S("CEikProgressInfo")); |
|
100 } |
|
101 |
|
102 EXPORT_C CEikProgressInfo::CEikProgressInfo(const SInfo& aProgInfo) |
|
103 { |
|
104 __DECLARE_NAME(_S("CEikProgressInfo")); |
|
105 iInfo=aProgInfo; |
|
106 Construct(); |
|
107 } |
|
108 |
|
109 void CEikProgressInfo::Construct() |
|
110 { |
|
111 SetNonFocusing(); |
|
112 iBorder=TGulBorder(TGulBorder::ENone); |
|
113 |
|
114 iLayout.iFillColor= iEikonEnv->ControlColor(EColorControlHighlightBackground, *this); //KEikProgressInfoDefaultFillColor; |
|
115 iLayout.iEmptyColor=iEikonEnv->ControlColor(EColorControlBackground, *this); //KEikProgressInfoDefaultEmptyColor; |
|
116 iLayout.iFillTextColor=iEikonEnv->ControlColor(EColorControlHighlightText, *this); //KEikProgressInfoDefaultFillTextColor; |
|
117 iLayout.iEmptyTextColor=iEikonEnv->ControlColor(EColorControlText, *this); //KEikProgressInfoDefaultEmptyTextColor; |
|
118 |
|
119 iLayout.iGapBetweenBlocks=KDefaultSpaceBetweenBlocks; |
|
120 if (iInfo.iHeight) |
|
121 iHeightWasSupplied=ETrue; |
|
122 } |
|
123 |
|
124 // AKNLAF start |
|
125 EXPORT_C void CEikProgressInfo::ConstructL() |
|
126 { |
|
127 // /* TODO: Commented out temporarily. Do we need this? |
|
128 |
|
129 // TAknLayoutRect voiceRecordRect, prNoteRect, addInfoRect; |
|
130 // voiceRecordRect.LayoutRect(Rect(), Voice_Recorder_elements_Line_4()); |
|
131 // prNoteRect.LayoutRect(Rect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_2); |
|
132 // addInfoRect.LayoutRect(Rect(), AKN_LAYOUT_WINDOW_Note_with_additional_information_popup_window_elements_Line_2( 1 )); |
|
133 // TInt voiceRecordWidth = voiceRecordRect.Rect().Width(); |
|
134 // TInt prNoteWidth = prNoteRect.Rect().Width(); |
|
135 // TInt addInfoWidth = addInfoRect.Rect().Width(); |
|
136 // __ASSERT_ALWAYS( iInfo.iWidth==voiceRecordWidth/*Voice_Recorder_elements_Line_4().iW*/ |
|
137 // || iInfo.iWidth==prNoteWidth/*AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_2.iW*/ |
|
138 // || iInfo.iWidth==addInfoWidth/*AKN_LAYOUT_WINDOW_Note_with_additional_information_popup_window_elements_Line_2( 1 ).iW*/, |
|
139 // Panic(EEikPanicOutOfRange) ); |
|
140 // */ |
|
141 iExtension = new (ELeave) CEikProgressInfoExtension; |
|
142 LoadBitmapsL(); |
|
143 } |
|
144 // AKNLAF end |
|
145 |
|
146 EXPORT_C void CEikProgressInfo::ConstructFromResourceL(TResourceReader &aReader) |
|
147 { |
|
148 iInfo.iTextType=(TEikProgressTextType)aReader.ReadInt16(); |
|
149 iInfo.iSplitsInBlock=aReader.ReadInt16(); |
|
150 iInfo.iFinalValue=aReader.ReadInt32(); |
|
151 iInfo.iWidth=aReader.ReadInt32(); |
|
152 iInfo.iHeight=aReader.ReadInt32(); |
|
153 Construct(); |
|
154 ConstructL(); |
|
155 } |
|
156 |
|
157 EXPORT_C void CEikProgressInfo::SetLayout(const SLayout& aLayout) |
|
158 { |
|
159 iLayout=aLayout; |
|
160 } |
|
161 |
|
162 EXPORT_C void CEikProgressInfo::SetBorder(const TGulBorder& aBorder) |
|
163 { |
|
164 iBorder=aBorder; |
|
165 } |
|
166 |
|
167 void CEikProgressInfo::CheckSizeCalculated() |
|
168 { |
|
169 if (!iLayout.iFont) |
|
170 iLayout.iFont=iCoeEnv->NormalFont(); |
|
171 if (iSize.iWidth) |
|
172 return; |
|
173 if (!iHeightWasSupplied) |
|
174 iInfo.iHeight=iLayout.iFont->HeightInPixels()+1; |
|
175 const TSize margins=iBorder.SizeDelta(); |
|
176 iSize.SetSize(iInfo.iWidth+margins.iWidth,iInfo.iHeight+margins.iHeight); |
|
177 } |
|
178 |
|
179 EXPORT_C void CEikProgressInfo::SetFinalValue(TInt aFinalValue) |
|
180 { |
|
181 iInfo.iFinalValue=aFinalValue? aFinalValue : 1; |
|
182 } |
|
183 |
|
184 EXPORT_C void CEikProgressInfo::SizeChanged() |
|
185 { |
|
186 const TSize margins=iBorder.SizeDelta(); |
|
187 iInfo.iWidth=iSize.iWidth-margins.iWidth; |
|
188 iInfo.iHeight=iSize.iHeight-margins.iHeight; |
|
189 |
|
190 SetBitmapSizes(); |
|
191 |
|
192 AknsUtils::RegisterControlPosition(this); |
|
193 } |
|
194 |
|
195 EXPORT_C TSize CEikProgressInfo::MinimumSize() |
|
196 { |
|
197 if (!iLayout.iFont) |
|
198 iLayout.iFont=iCoeEnv->NormalFont(); |
|
199 if (!iHeightWasSupplied) |
|
200 iInfo.iHeight=iLayout.iFont->HeightInPixels()+1; |
|
201 const TSize margins=iBorder.SizeDelta(); |
|
202 return TSize(iInfo.iWidth+margins.iWidth,iInfo.iHeight+margins.iHeight); |
|
203 } |
|
204 |
|
205 EXPORT_C void CEikProgressInfo::ActivateL() |
|
206 { |
|
207 CheckSizeCalculated(); |
|
208 CCoeControl::ActivateL(); |
|
209 SetBitmapSizes(); |
|
210 } |
|
211 |
|
212 // AKNLAF start |
|
213 EXPORT_C void CEikProgressInfo::Draw(const TRect& /*aRect*/) const |
|
214 { |
|
215 CWindowGc& gc = SystemGc(); |
|
216 DrawProgressBarForeground(gc); |
|
217 DrawProgressBarBackground(gc); |
|
218 } |
|
219 |
|
220 void CEikProgressInfo::DrawPartial() const |
|
221 { |
|
222 ActivateGc(); |
|
223 DrawProgressBarForeground(SystemGc()); |
|
224 DeactivateGc(); |
|
225 } |
|
226 |
|
227 TInt CEikProgressInfo::FilledWidth() const |
|
228 { |
|
229 const TInt64 infoWidth = iInfo.iWidth; |
|
230 const TInt64 currentValue = iCurrentValue; |
|
231 const TInt64 width = infoWidth * currentValue / iInfo.iFinalValue; |
|
232 return I64LOW(width); |
|
233 } |
|
234 |
|
235 void CEikProgressInfo::DrawProgressBarForeground(CWindowGc& aGc) const |
|
236 { |
|
237 if (!iBitmap) |
|
238 { |
|
239 return; |
|
240 } |
|
241 |
|
242 TRect visibleRect = TRect( 0, 0, FilledWidth(), iInfo.iHeight ); |
|
243 |
|
244 if (iBitmapMask) |
|
245 { |
|
246 aGc.BitBltMasked(TPoint(iPosition.iX, iPosition.iY), iBitmap, visibleRect, iBitmapMask, EFalse); |
|
247 } |
|
248 else |
|
249 { |
|
250 aGc.BitBlt(TPoint(iPosition.iX, iPosition.iY), iBitmap, visibleRect); |
|
251 } |
|
252 } |
|
253 |
|
254 void CEikProgressInfo::DrawProgressBarBackground(CWindowGc& aGc) const |
|
255 { |
|
256 if (!iExtension) |
|
257 { |
|
258 return; |
|
259 } |
|
260 |
|
261 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
262 |
|
263 TRect backgroundFrameRect = TRect( 0, 0, iInfo.iWidth, iInfo.iHeight ); |
|
264 |
|
265 TInt filledWidth = FilledWidth(); |
|
266 TRect backRedrawRect(TPoint(iPosition.iX + filledWidth, iPosition.iY), TSize(backgroundFrameRect.Width() - filledWidth, backgroundFrameRect.Height())); |
|
267 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
268 AknsDrawUtils::Background( skin, cc, this, aGc, backRedrawRect ); |
|
269 |
|
270 aGc.BitBltMasked( TPoint( iPosition.iX, iPosition.iY ), |
|
271 iExtension->iFrameLeft, |
|
272 TRect( iExtension->iFrameLeft->SizeInPixels() ), |
|
273 iExtension->iFrameLeftMask, |
|
274 EFalse); |
|
275 |
|
276 aGc.BitBltMasked( TPoint( iPosition.iX + iExtension->iFrameLeft->SizeInPixels().iWidth, |
|
277 iPosition.iY), iExtension->iFrameCenter, |
|
278 TRect( iExtension->iFrameCenter->SizeInPixels() ), |
|
279 iExtension->iFrameCenterMask, EFalse); |
|
280 |
|
281 aGc.BitBltMasked( TPoint( iPosition.iX + iExtension->iFrameLeft->SizeInPixels().iWidth + |
|
282 iExtension->iFrameCenter->SizeInPixels().iWidth, |
|
283 iPosition.iY), iExtension->iFrameRight, |
|
284 TRect( iExtension->iFrameRight->SizeInPixels() ), |
|
285 iExtension->iFrameRightMask, EFalse); |
|
286 } |
|
287 // AKNLAF end |
|
288 |
|
289 |
|
290 EXPORT_C const TDesC* CEikProgressInfo::EvaluateText(TDes& aTextBuf) const |
|
291 { |
|
292 if (!iInfo.iTextType) |
|
293 return(NULL); |
|
294 _LIT(KTextPercent,"%3d%%"); |
|
295 _LIT(KOver,"%c"); |
|
296 if (iInfo.iTextType==EEikProgressTextPercentage) |
|
297 aTextBuf.Format(KTextPercent,iCurrentValue*100/iInfo.iFinalValue); |
|
298 else |
|
299 aTextBuf.Format(KOver,iCurrentValue,iInfo.iFinalValue); |
|
300 // Support for arabic indic digits: |
|
301 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(aTextBuf); |
|
302 return(&aTextBuf); // subclassers may wish to use their own buffer |
|
303 } |
|
304 |
|
305 EXPORT_C void CEikProgressInfo::SetAndDraw(TInt aValue) |
|
306 { |
|
307 if (aValue < 0) |
|
308 aValue = 0; |
|
309 else if (aValue > iInfo.iFinalValue) |
|
310 { |
|
311 //aValue = iInfo.iFinalValue; |
|
312 //no need for redrawing |
|
313 return; |
|
314 } |
|
315 |
|
316 if(iCurrentValue != aValue) |
|
317 { |
|
318 TInt oldWidth = FilledWidth(); |
|
319 iCurrentValue = aValue; |
|
320 if( FilledWidth() != oldWidth ) |
|
321 { |
|
322 DrawNow(); |
|
323 } |
|
324 } |
|
325 } |
|
326 |
|
327 EXPORT_C void CEikProgressInfo::IncrementAndDraw(TInt aInc) |
|
328 { |
|
329 SetAndDraw(iCurrentValue+aInc); |
|
330 } |
|
331 |
|
332 /** |
|
333 * Gets the list of logical colors employed in the drawing of the control, |
|
334 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
335 * |
|
336 * @since ER5U |
|
337 */ |
|
338 EXPORT_C void CEikProgressInfo::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
339 { |
|
340 CEikBorderedControl::GetColorUseListL(aColorUseList); |
|
341 |
|
342 TInt commonAttributes = TCoeColorUse::EContents|TCoeColorUse::ENormal|TCoeColorUse::ENeutral; |
|
343 TCoeColorUse colorUse; |
|
344 |
|
345 colorUse.SetLogicalColor(EColorControlText); |
|
346 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|commonAttributes); |
|
347 aColorUseList.AppendL(colorUse); |
|
348 |
|
349 colorUse.SetLogicalColor(EColorControlHighlightText); |
|
350 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EHighlights|commonAttributes); |
|
351 aColorUseList.AppendL(colorUse); |
|
352 |
|
353 colorUse.SetLogicalColor(EColorControlBackground); |
|
354 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EActive|commonAttributes); |
|
355 aColorUseList.AppendL(colorUse); |
|
356 |
|
357 colorUse.SetLogicalColor(EColorControlHighlightBackground); |
|
358 colorUse.SetUse(TCoeColorUse::EBack|TCoeColorUse::EHighlights|commonAttributes); |
|
359 aColorUseList.AppendL(colorUse); |
|
360 } |
|
361 |
|
362 /** |
|
363 * Handles a change to the control's resources of type aType |
|
364 * which are shared across the environment, e.g. colors or fonts. |
|
365 * |
|
366 * @since ER5U |
|
367 */ |
|
368 EXPORT_C void CEikProgressInfo::HandleResourceChange(TInt aType) |
|
369 { |
|
370 if (aType == KAknsMessageSkinChange) |
|
371 { |
|
372 //load the new skin graphics |
|
373 DeleteBitmaps(); |
|
374 TRAP_IGNORE(LoadBitmapsL()); |
|
375 SetBitmapSizes(); |
|
376 } |
|
377 |
|
378 CEikBorderedControl::HandleResourceChange(aType); |
|
379 } |
|
380 |
|
381 // from CCoeControl |
|
382 /** |
|
383 * Writes the internal state of the control and its components to aStream. |
|
384 * Does nothing in release mode. |
|
385 * Designed to be overidden and base called by subclasses. |
|
386 * |
|
387 * @internal |
|
388 * @since App-Framework_6.1 |
|
389 */ |
|
390 #ifndef _DEBUG |
|
391 EXPORT_C void CEikProgressInfo::WriteInternalStateL(RWriteStream&) const |
|
392 {} |
|
393 #else |
|
394 EXPORT_C void CEikProgressInfo::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
395 { |
|
396 CEikBorderedControl::WriteInternalStateL(aWriteStream); |
|
397 } |
|
398 #endif |
|
399 |
|
400 EXPORT_C void CEikProgressInfo::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
401 { |
|
402 CEikBorderedControl::HandlePointerEventL(aPointerEvent); |
|
403 } |
|
404 |
|
405 EXPORT_C void* CEikProgressInfo::ExtensionInterface( TUid /*aInterface*/ ) |
|
406 { |
|
407 return NULL; |
|
408 } |
|
409 |
|
410 EXPORT_C void CEikProgressInfo::Reserved_2() |
|
411 { |
|
412 } |
|
413 |
|
414 void CEikProgressInfo::LoadBitmapsL() |
|
415 { |
|
416 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
417 |
|
418 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafBarProgress, |
|
419 iBitmap, iBitmapMask, KAvkonBitmapFile, |
|
420 EMbmAvkonQgn_graf_bar_progress, |
|
421 EMbmAvkonQgn_graf_bar_progress_mask ); |
|
422 |
|
423 // Preserve icon data to improve performance, because the icon is subsequently |
|
424 // scaled to different sizes. No need to call DestroyIconData in this case. |
|
425 // It is done automatically, when iBitmap is deleted. |
|
426 AknIconUtils::PreserveIconData( iBitmap ); |
|
427 |
|
428 if ( iExtension ) |
|
429 { |
|
430 // Load the three frame icons and assign a proper size to them. |
|
431 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafBarFrameSideL, |
|
432 iExtension->iFrameLeft, iExtension->iFrameLeftMask, KAvkonBitmapFile, |
|
433 EMbmAvkonQgn_graf_bar_frame_side_l, |
|
434 EMbmAvkonQgn_graf_bar_frame_side_l_mask ); |
|
435 |
|
436 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafBarFrameCenter, |
|
437 iExtension->iFrameCenter, iExtension->iFrameCenterMask, KAvkonBitmapFile, |
|
438 EMbmAvkonQgn_graf_bar_frame_center, |
|
439 EMbmAvkonQgn_graf_bar_frame_center_mask ); |
|
440 |
|
441 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafBarFrameSideR, |
|
442 iExtension->iFrameRight, iExtension->iFrameRightMask, KAvkonBitmapFile, |
|
443 EMbmAvkonQgn_graf_bar_frame_side_r, |
|
444 EMbmAvkonQgn_graf_bar_frame_side_r_mask ); |
|
445 } |
|
446 } |
|
447 |
|
448 void CEikProgressInfo::SetBitmapSizes() |
|
449 { |
|
450 TRect barRect ( TSize ( iInfo.iWidth, iInfo.iHeight ) ); |
|
451 AknIconUtils::SetSize( iBitmap, barRect.Size(), EAspectRatioNotPreserved ); |
|
452 |
|
453 if ( iExtension ) |
|
454 { |
|
455 TAknLayoutRect frameLayout; |
|
456 frameLayout.LayoutRect( barRect, AknLayoutScalable_Avkon::wait_border_pane_g1() ); |
|
457 AknIconUtils::SetSize( iExtension->iFrameLeft, frameLayout.Rect().Size(), EAspectRatioNotPreserved ); |
|
458 frameLayout.LayoutRect( barRect, AknLayoutScalable_Avkon::wait_border_pane_g2() ); |
|
459 AknIconUtils::SetSize( iExtension->iFrameCenter, frameLayout.Rect().Size(), EAspectRatioNotPreserved ); |
|
460 frameLayout.LayoutRect( barRect, AknLayoutScalable_Avkon::wait_border_pane_g3() ); |
|
461 AknIconUtils::SetSize( iExtension->iFrameRight, frameLayout.Rect().Size(), EAspectRatioNotPreserved ); |
|
462 } |
|
463 } |
|
464 |
|
465 void CEikProgressInfo::DeleteBitmaps() |
|
466 { |
|
467 //delete iBackgroundBitmapMask; // AKNLAF |
|
468 //iBackgroundBitmapMask = NULL; |
|
469 if (iExtension) |
|
470 iExtension->DeleteBitmaps(); |
|
471 delete iBackgroundBitmap; // AKNLAF |
|
472 iBackgroundBitmap = NULL; |
|
473 delete iBitmap; // AKNLAF |
|
474 iBitmap = NULL; |
|
475 delete iBitmapMask; |
|
476 iBitmapMask = NULL; |
|
477 } |