1 /* |
|
2 * Copyright (c) 2002-2005 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: Implementation of button |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // system includes |
|
20 #include <barsread.h> |
|
21 #include <peninputlayout.h> |
|
22 #include <AknIconUtils.h> |
|
23 #include <coemain.h> |
|
24 #include <AknsUtils.h> |
|
25 #include <AknUtils.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 // user includes |
|
28 #include <peninputbutton.h> |
|
29 #include <peninputdragbutton.h> |
|
30 #include <peninputeventbutton.h> |
|
31 #include <peninputmultimodebutton.h> |
|
32 #include <peninputrepeatbutton.h> |
|
33 #include <peninputrawkeybutton.h> |
|
34 #include <peninputcommonbutton.h> |
|
35 #include <peninputmultiimagebutton.h> |
|
36 #include <peninputcommonctrls.hrh> |
|
37 #include <peninputcommonlayoutglobalenum.h> |
|
38 |
|
39 const TInt KInvalidBmp = -1 ; |
|
40 |
|
41 //default value for long press timer |
|
42 const TInt KLongPressInterval = 600000; |
|
43 |
|
44 //default value for repeat timer |
|
45 const TInt KRepeatInterval = 100000; |
|
46 |
|
47 //default text color and shadow text color |
|
48 const TUint32 KDefaultTextColor = 0x000000; |
|
49 const TUint32 KDefaultShadowTextColor = 0xffffff; |
|
50 const TInt32 KInvalidResId = -1; |
|
51 const TInt KInvalidEventId = 0xffff; |
|
52 //const TInt KFadingParamBlack = 255; |
|
53 //const TInt KFadingParamWhite = 0; |
|
54 |
|
55 const TInt KTransparency[256] = |
|
56 { |
|
57 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, |
|
58 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13, |
|
59 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 19, |
|
60 19, 19, 20, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 23, 24, 24, |
|
61 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, |
|
62 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, |
|
63 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 40, 40, 40, |
|
64 41, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 46, |
|
65 46, 46, 47, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 50, 51, 51, |
|
66 51, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 56, |
|
67 57, 57, 57, 58, 58, 58, 59, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, |
|
68 62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 67, 67, 67, |
|
69 68, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73, |
|
70 73, 73, 74, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77 |
|
71 }; |
|
72 // Invalid function icon color group |
|
73 const TInt KInvalidColorGroup = -1; |
|
74 |
|
75 // ======== MEMBER FUNCTIONS ======== |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CAknFepCtrlButton::CAknFepCtrlButton |
|
79 // C++ default constructor can NOT contain any code, that |
|
80 // might leave. |
|
81 // (other items were commented in a header). |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C CAknFepCtrlButton::CAknFepCtrlButton(CFepUiLayout* aUiLayout, TInt aControlId) |
|
85 : CButtonBase(TRect(), aUiLayout, aControlId), iFirstTimeConstruct(ETrue), iHighlight(EFalse) |
|
86 { |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAknFepCtrlButton::NewL |
|
91 // Two-phased constructor. |
|
92 // (other items were commented in a header). |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C CAknFepCtrlButton* CAknFepCtrlButton::NewL(CFepUiLayout* aUiLayout, TInt aControlId) |
|
96 { |
|
97 CAknFepCtrlButton* self = NewLC(aUiLayout, aControlId); |
|
98 CleanupStack::Pop(self); |
|
99 |
|
100 return self; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CAknFepCtrlButton::NewLC |
|
105 // Two-phased constructor. |
|
106 // (other items were commented in a header). |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C CAknFepCtrlButton* CAknFepCtrlButton::NewLC(CFepUiLayout* aUiLayout, TInt aControlId) |
|
110 { |
|
111 CAknFepCtrlButton* self = new (ELeave) CAknFepCtrlButton(aUiLayout, aControlId); |
|
112 CleanupStack::PushL(self); |
|
113 self->BaseConstructL(); |
|
114 |
|
115 return self; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // Destructor. |
|
120 // (other items were commented in a header). |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C CAknFepCtrlButton::~CAknFepCtrlButton() |
|
124 { |
|
125 iBmpList.Close(); |
|
126 iMaskBmpList.Close(); |
|
127 } |
|
128 // --------------------------------------------------------------------------- |
|
129 // CAknFepCtrlButton::ConstructFromResourceL |
|
130 // The order of the image ids in the CButtonBase class must not be changed |
|
131 // (other items were commented in a header). |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C void CAknFepCtrlButton::ConstructFromResourceL(TResourceReader& aReader) |
|
135 { |
|
136 if (!iFirstTimeConstruct) |
|
137 { |
|
138 iBmpList.Close(); |
|
139 iMaskBmpList.Close(); |
|
140 ResetBmpPool(); |
|
141 } |
|
142 |
|
143 TPtrC bmpFileName = aReader.ReadTPtrC(); // Read the file name of the bmps |
|
144 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
145 TInt colorgroup = aReader.ReadInt16(); |
|
146 TAknsItemID id; |
|
147 |
|
148 for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii) |
|
149 { |
|
150 // Get the image ids and mask ids from resource |
|
151 TInt bmpId = aReader.ReadInt16(); |
|
152 TInt bmpMskId = aReader.ReadInt16(); |
|
153 |
|
154 // read skin item id |
|
155 const TInt skinitemid = aReader.ReadInt16(); |
|
156 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
157 |
|
158 if (bmpId != KInvalidBmp) |
|
159 { |
|
160 CFbsBitmap* bmp = NULL; |
|
161 CFbsBitmap* maskbmp = NULL; |
|
162 |
|
163 if (bmpMskId != KInvalidBmp) |
|
164 { |
|
165 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
166 id, |
|
167 bmp, |
|
168 maskbmp, |
|
169 bmpFileName, |
|
170 bmpId, |
|
171 bmpMskId); |
|
172 |
|
173 // set maskbmp and size |
|
174 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
175 iMaskBmpList.Append(maskbmp); |
|
176 } |
|
177 else |
|
178 { |
|
179 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
180 id, |
|
181 bmp, |
|
182 bmpFileName, |
|
183 bmpId); |
|
184 } |
|
185 |
|
186 // set bmp and size |
|
187 SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
188 iBmpList.Append(bmp); |
|
189 } |
|
190 } |
|
191 |
|
192 if (!iFirstTimeConstruct) |
|
193 { |
|
194 ResizeBitmaps(Rect().Size()); |
|
195 Draw(); |
|
196 } |
|
197 |
|
198 iFirstTimeConstruct = EFalse; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // CAknFepCtrlButton::ConstructFromResourceL |
|
203 // (other items were commented in a header). |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C void CAknFepCtrlButton::ConstructFromResourceL() |
|
207 { |
|
208 if (iResourceId == KInvalidResId) |
|
209 { |
|
210 User::Leave(KErrArgument); |
|
211 } |
|
212 |
|
213 if (!iFirstTimeConstruct) |
|
214 { |
|
215 // need to remove original bmp and maskbmp |
|
216 iBmpList.Close(); |
|
217 iMaskBmpList.Close(); |
|
218 ResetBmpPool(); |
|
219 } |
|
220 |
|
221 TResourceReader reader; |
|
222 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
223 |
|
224 TPtrC bmpFileName = reader.ReadTPtrC(); // Read the file name of the bmps |
|
225 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
226 TInt colorgroup = reader.ReadInt16(); |
|
227 TAknsItemID id; |
|
228 |
|
229 for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii) |
|
230 { |
|
231 // Get the image ids and mask ids from resource |
|
232 TInt bmpId = reader.ReadInt16(); |
|
233 TInt bmpMskId = reader.ReadInt16(); |
|
234 |
|
235 // read skin item id |
|
236 const TInt skinitemid = reader.ReadInt16(); |
|
237 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
238 |
|
239 if (bmpId != KInvalidBmp) |
|
240 { |
|
241 CFbsBitmap* bmp = NULL; |
|
242 CFbsBitmap* maskbmp = NULL; |
|
243 |
|
244 if (bmpMskId != KInvalidBmp) |
|
245 { |
|
246 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
247 id, |
|
248 bmp, |
|
249 maskbmp, |
|
250 bmpFileName, |
|
251 bmpId, |
|
252 bmpMskId); |
|
253 |
|
254 // set maskbmp and size |
|
255 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
256 iMaskBmpList.Append(maskbmp); |
|
257 } |
|
258 else |
|
259 { |
|
260 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
261 id, |
|
262 bmp, |
|
263 bmpFileName, |
|
264 bmpId); |
|
265 } |
|
266 |
|
267 // set bmp and size |
|
268 SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
269 iBmpList.Append(bmp); |
|
270 } |
|
271 } |
|
272 |
|
273 CleanupStack::PopAndDestroy(); // reader |
|
274 |
|
275 if (!iFirstTimeConstruct) |
|
276 { |
|
277 ResizeBitmaps(Rect().Size()); |
|
278 Draw(); |
|
279 } |
|
280 |
|
281 iFirstTimeConstruct = EFalse; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // CAknFepCtrlButton::Draw |
|
286 // Draws UI |
|
287 // (other items were commented in a header). |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C void CAknFepCtrlButton::Draw() |
|
291 { |
|
292 if(!AbleToDraw()) |
|
293 return; |
|
294 |
|
295 if ( !BackgroundBmp() ) |
|
296 { |
|
297 CButtonBase::Draw(); |
|
298 } |
|
299 |
|
300 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
301 |
|
302 //mask bitmaps |
|
303 gc->Activate( MaskBitmapDevice() ); |
|
304 |
|
305 gc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
306 gc->SetBrushColor( TRgb(KOpaqueColor));//Non transparent at all |
|
307 gc->SetPenStyle(CGraphicsContext::ESolidPen ); |
|
308 gc->SetPenSize( PenSize()); |
|
309 gc->SetPenColor( TRgb(KOpaqueColor) ); |
|
310 gc->DrawRect(Rect()); |
|
311 |
|
312 // ----- draw bitmaps ----- |
|
313 gc->Activate( BitmapDevice() ); |
|
314 if ( BackgroundBmp() ) |
|
315 { |
|
316 TSize size=BackgroundBmp()->SizeInPixels(); |
|
317 |
|
318 gc->DrawBitmap(Rect(), BackgroundBmp(),size); |
|
319 } |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // CAknFepCtrlButton::SetActive |
|
324 // Set active for the button |
|
325 // (other items were commented in a header). |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 EXPORT_C void CAknFepCtrlButton::SetActive(TBool aActiveFlag) |
|
329 { |
|
330 if( IsDimmed() ) |
|
331 { |
|
332 return; |
|
333 } |
|
334 |
|
335 if(IsActive() != aActiveFlag) |
|
336 { |
|
337 CFepUiBaseCtrl::SetActive(aActiveFlag); |
|
338 if(aActiveFlag || iHighlight) |
|
339 { |
|
340 SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse)); |
|
341 SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue)); |
|
342 //Hide(EFalse); //active button won't be Hiden ??? |
|
343 } |
|
344 else |
|
345 { |
|
346 SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse)); |
|
347 SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue)); |
|
348 } |
|
349 if(BitGc()) |
|
350 { |
|
351 Draw(); |
|
352 UpdateArea(Rect(),EFalse); |
|
353 } |
|
354 } |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CAknFepCtrlButton::SetHighlight |
|
359 // Set highlight for the button |
|
360 // (other items were commented in a header). |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 EXPORT_C void CAknFepCtrlButton::SetHighlight(TBool aIsHighlight) |
|
364 { |
|
365 iHighlight = aIsHighlight; |
|
366 |
|
367 if ( iHighlight ) |
|
368 { |
|
369 SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse)); |
|
370 SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue)); |
|
371 } |
|
372 else |
|
373 { |
|
374 SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse)); |
|
375 SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue)); |
|
376 } |
|
377 Draw(); |
|
378 UpdateArea(Rect(), EFalse); |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // CAknFepCtrlButton::ResizeBitmaps |
|
383 // This methods shall be called by the container's SizeChanged handler |
|
384 // (other items were commented in a header). |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 void CAknFepCtrlButton::ResizeBitmaps(TSize aSize) |
|
388 { |
|
389 if (iMaskBmpList.Count() >= 1 && |
|
390 iMaskBmpList[0]->SizeInPixels() != aSize) |
|
391 { |
|
392 for( int ii = 0; ii < iMaskBmpList.Count(); ++ii ) |
|
393 { |
|
394 AknIconUtils::SetSize(iMaskBmpList[ii], aSize, EAspectRatioNotPreserved); |
|
395 } |
|
396 } |
|
397 |
|
398 if (iBmpList.Count() >= 1 && |
|
399 iBmpList[0]->SizeInPixels() != aSize) |
|
400 { |
|
401 for( int ii = 0; ii < iBmpList.Count(); ++ii ) |
|
402 { |
|
403 AknIconUtils::SetSize(iBmpList[ii], aSize, EAspectRatioNotPreserved); |
|
404 } |
|
405 } |
|
406 } |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // CAknFepCtrlButton::SizeChanged |
|
410 // This methods shall be called by the container's SizeChanged handler |
|
411 // (other items were commented in a header). |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 EXPORT_C void CAknFepCtrlButton::SizeChanged(TRect aNewRect, TBool aIsReloadImages) |
|
415 { |
|
416 if ((aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) && |
|
417 (ControlId() != EPeninupWindowCtrlIdArrowLeftBtn && |
|
418 ControlId() != EPeninupWindowCtrlIdArrowRightBtn)) |
|
419 { |
|
420 return; |
|
421 } |
|
422 |
|
423 SetRect(aNewRect); |
|
424 |
|
425 //if (aIsReloadImages) |
|
426 { |
|
427 ResizeBitmaps(aNewRect.Size()); |
|
428 } |
|
429 |
|
430 Draw(); |
|
431 UpdateArea(Rect(), EFalse); |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------------------------- |
|
435 // CAknFepCtrlButton::HandlePointerLeave |
|
436 // Handle pointer leave event |
|
437 // --------------------------------------------------------------------------- |
|
438 // |
|
439 void CAknFepCtrlButton::HandlePointerLeave(const TPoint& aPt) |
|
440 { |
|
441 if( IsDimmed() ) |
|
442 return; |
|
443 if( iHighlight ) |
|
444 { |
|
445 SetBackgroundBmp(iActiveBmp); |
|
446 SetBackgroundMaskBmp(iActiveMaskBmp); |
|
447 } |
|
448 |
|
449 else |
|
450 { |
|
451 SetBackgroundBmp(iNonActiveBkBmp); |
|
452 SetBackgroundMaskBmp(iNonActiveBkMaskBmp); |
|
453 } |
|
454 Draw(); |
|
455 UpdateArea(Rect(), EFalse); |
|
456 CFepUiBaseCtrl::HandlePointerLeave(aPt); |
|
457 return ; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CAknFepCtrlDragButton::CAknFepCtrlDragButton |
|
462 // C++ default constructor can NOT contain any code, that |
|
463 // might leave. |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 EXPORT_C CAknFepCtrlDragButton::CAknFepCtrlDragButton(CFepUiLayout* aUiLayout, TInt aControlId) |
|
467 : CDragBar(TRect(), aUiLayout, aControlId), iFirstTimeConstruct(ETrue) |
|
468 { |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // Destructor. |
|
473 // (other items were commented in a header). |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 EXPORT_C CAknFepCtrlDragButton::~CAknFepCtrlDragButton() |
|
477 { |
|
478 iBmpList.Close(); |
|
479 iMaskBmpList.Close(); |
|
480 |
|
481 DeleteForgroundRes(); |
|
482 delete iText; |
|
483 } |
|
484 |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CAknFepCtrlDragButton::NewL |
|
488 // Two-phased constructor. |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 EXPORT_C CAknFepCtrlDragButton* CAknFepCtrlDragButton::NewL(CFepUiLayout* aUiLayout, |
|
492 TInt aControlId) |
|
493 { |
|
494 CAknFepCtrlDragButton* self = NewLC(aUiLayout, aControlId); |
|
495 CleanupStack::Pop(self); |
|
496 |
|
497 return self; |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CAknFepCtrlDragButton::NewLC |
|
502 // Two-phased constructor. |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 EXPORT_C CAknFepCtrlDragButton* CAknFepCtrlDragButton::NewLC(CFepUiLayout* aUiLayout, |
|
506 TInt aControlId) |
|
507 { |
|
508 CAknFepCtrlDragButton* self = new (ELeave) CAknFepCtrlDragButton(aUiLayout, aControlId); |
|
509 CleanupStack::PushL(self); |
|
510 self->ConstructL(); |
|
511 |
|
512 return self; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CAknFepCtrlDragButton::ConstructFromResourceL |
|
517 // The order of the image ids in the CButtonBase class must not be changed |
|
518 // (other items were commented in a header). |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 EXPORT_C void CAknFepCtrlDragButton::ConstructFromResourceL(TResourceReader& aReader) |
|
522 { |
|
523 /* |
|
524 if (!iFirstTimeConstruct) |
|
525 { |
|
526 iBmpList.Close(); |
|
527 iMaskBmpList.Close(); |
|
528 ResetBmpPool(); |
|
529 } |
|
530 |
|
531 TPtrC bmpFileName = aReader.ReadTPtrC(); |
|
532 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
533 TAknsItemID id; |
|
534 |
|
535 for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii) |
|
536 { |
|
537 const TInt16 bmpId = aReader.ReadInt16(); |
|
538 const TInt16 bmpMskId = aReader.ReadInt16(); |
|
539 |
|
540 // read skin item id |
|
541 const TInt skinitemid = aReader.ReadInt16(); |
|
542 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
543 |
|
544 if (bmpId != KInvalidBmp) |
|
545 { |
|
546 CFbsBitmap* bmp = NULL; |
|
547 CFbsBitmap* maskbmp = NULL; |
|
548 |
|
549 if (bmpMskId != KInvalidBmp) |
|
550 { |
|
551 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
552 id, |
|
553 bmp, |
|
554 maskbmp, |
|
555 bmpFileName, |
|
556 bmpId, |
|
557 bmpMskId); |
|
558 |
|
559 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
560 iMaskBmpList.Append(maskbmp); |
|
561 } |
|
562 else |
|
563 { |
|
564 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
565 id, |
|
566 bmp, |
|
567 bmpFileName, |
|
568 bmpId); |
|
569 } |
|
570 |
|
571 SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
572 iBmpList.Append(bmp); |
|
573 } |
|
574 } |
|
575 |
|
576 if (!iFirstTimeConstruct) |
|
577 { |
|
578 ResizeBitmaps(Rect().Size()); |
|
579 Draw(); |
|
580 } |
|
581 |
|
582 iFirstTimeConstruct = EFalse;*/ |
|
583 if (!iFirstTimeConstruct) |
|
584 { |
|
585 DeleteForgroundRes(); |
|
586 } |
|
587 |
|
588 TPtrC bmpFileName = aReader.ReadTPtrC(); // Read the file name of the bmps |
|
589 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
590 TInt colorGroup = aReader.ReadInt16(); |
|
591 TAknsItemID id; |
|
592 |
|
593 // Get the image ids and mask ids from resource |
|
594 TInt bmpId = aReader.ReadInt16(); |
|
595 TInt bmpMskId = aReader.ReadInt16(); |
|
596 |
|
597 // read skin item id |
|
598 const TInt skinitemid = aReader.ReadInt16(); |
|
599 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
600 |
|
601 if (bmpId != KInvalidBmp) |
|
602 { |
|
603 if (bmpMskId != KInvalidBmp) |
|
604 { |
|
605 if( colorGroup == KInvalidColorGroup ) |
|
606 { |
|
607 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
608 id, |
|
609 iForgroundBmp, |
|
610 iForgroundBmpMask, |
|
611 bmpFileName, |
|
612 bmpId, |
|
613 bmpMskId); |
|
614 } |
|
615 else |
|
616 { |
|
617 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
618 id, |
|
619 KAknsIIDQsnIconColors, |
|
620 colorGroup, |
|
621 iForgroundBmp, |
|
622 iForgroundBmpMask, |
|
623 bmpFileName, |
|
624 bmpId, |
|
625 bmpMskId, |
|
626 AKN_LAF_COLOR( 0 ) ); |
|
627 } |
|
628 |
|
629 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
630 AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), |
|
631 EAspectRatioNotPreserved); |
|
632 |
|
633 /*CreateDimmedMaskL( iForgroundDimBmpMask, |
|
634 iForgroundBmpMask ); |
|
635 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), |
|
636 EAspectRatioNotPreserved);*/ |
|
637 } |
|
638 else |
|
639 { |
|
640 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
641 id, |
|
642 iForgroundBmp, |
|
643 bmpFileName, |
|
644 bmpId); |
|
645 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
646 } |
|
647 } |
|
648 |
|
649 if (!iFirstTimeConstruct) |
|
650 { |
|
651 //ResizeBitmaps(iForgroundBmpRect.Size()); |
|
652 Draw(); |
|
653 } |
|
654 |
|
655 iFirstTimeConstruct = EFalse; |
|
656 |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CAknFepCtrlDragButton::ConstructFromResourceL |
|
661 // (other items were commented in a header). |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 EXPORT_C void CAknFepCtrlDragButton::ConstructFromResourceL() |
|
665 { |
|
666 /* |
|
667 if (iResourceId == KInvalidResId) |
|
668 { |
|
669 User::Leave(KErrArgument); |
|
670 } |
|
671 |
|
672 if (!iFirstTimeConstruct) |
|
673 { |
|
674 iBmpList.Close(); |
|
675 iMaskBmpList.Close(); |
|
676 ResetBmpPool(); |
|
677 } |
|
678 |
|
679 TResourceReader reader; |
|
680 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
681 |
|
682 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
683 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
684 TAknsItemID id; |
|
685 |
|
686 for (TInt ii = 0; ii < EBtnBmpLastType + 1; ++ii) |
|
687 { |
|
688 const TInt16 bmpId = reader.ReadInt16(); |
|
689 const TInt16 bmpMskId = reader.ReadInt16(); |
|
690 |
|
691 // read skin item id |
|
692 const TInt skinitemid = reader.ReadInt16(); |
|
693 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
694 |
|
695 if (bmpId != KInvalidBmp) |
|
696 { |
|
697 CFbsBitmap* bmp = NULL; |
|
698 CFbsBitmap* maskbmp = NULL; |
|
699 |
|
700 if (bmpMskId != KInvalidBmp) |
|
701 { |
|
702 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
703 id, |
|
704 bmp, |
|
705 maskbmp, |
|
706 bmpFileName, |
|
707 bmpId, |
|
708 bmpMskId); |
|
709 |
|
710 SetMaskBitmapL(maskbmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
711 iMaskBmpList.Append(maskbmp); |
|
712 } |
|
713 else |
|
714 { |
|
715 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
716 id, |
|
717 bmp, |
|
718 bmpFileName, |
|
719 bmpId); |
|
720 } |
|
721 |
|
722 SetBitmapL(bmp, TButtonBmpType(EBtnBmpNonActive + ii)); |
|
723 iBmpList.Append(bmp); |
|
724 } |
|
725 } |
|
726 |
|
727 CleanupStack::PopAndDestroy(); // reader |
|
728 |
|
729 if (!iFirstTimeConstruct) |
|
730 { |
|
731 ResizeBitmaps(Rect().Size()); |
|
732 Draw(); |
|
733 } |
|
734 |
|
735 iFirstTimeConstruct = EFalse;*/ |
|
736 if (iResourceId == KInvalidResId) |
|
737 { |
|
738 return; |
|
739 } |
|
740 |
|
741 if (!iFirstTimeConstruct) |
|
742 { |
|
743 // need to remove original bmp and maskbmp |
|
744 DeleteForgroundRes(); |
|
745 } |
|
746 |
|
747 TResourceReader reader; |
|
748 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
749 |
|
750 TPtrC bmpFileName = reader.ReadTPtrC(); // Read the file name of the bmps |
|
751 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
752 TInt colorGroup = reader.ReadInt16(); |
|
753 TAknsItemID id; |
|
754 |
|
755 // Get the image ids and mask ids from resource |
|
756 TInt bmpId = reader.ReadInt16(); |
|
757 TInt bmpMskId = reader.ReadInt16(); |
|
758 |
|
759 // Read skin item id |
|
760 const TInt skinitemid = reader.ReadInt16(); |
|
761 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
762 |
|
763 if (bmpId != KInvalidBmp) |
|
764 { |
|
765 if (bmpMskId != KInvalidBmp) |
|
766 { |
|
767 if( colorGroup == KInvalidColorGroup ) |
|
768 { |
|
769 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
770 id, |
|
771 iForgroundBmp, |
|
772 iForgroundBmpMask, |
|
773 bmpFileName, |
|
774 bmpId, |
|
775 bmpMskId); |
|
776 } |
|
777 else |
|
778 { |
|
779 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
780 id, |
|
781 KAknsIIDQsnIconColors, |
|
782 colorGroup, |
|
783 iForgroundBmp, |
|
784 iForgroundBmpMask, |
|
785 bmpFileName, |
|
786 bmpId, |
|
787 bmpMskId, |
|
788 AKN_LAF_COLOR( 0 ) ); |
|
789 } |
|
790 |
|
791 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
792 AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), |
|
793 EAspectRatioNotPreserved); |
|
794 |
|
795 /*CreateDimmedMaskL( iForgroundDimBmpMask, iForgroundBmpMask ); |
|
796 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), |
|
797 EAspectRatioNotPreserved);*/ |
|
798 } |
|
799 else |
|
800 { |
|
801 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
802 id, |
|
803 iForgroundBmp, |
|
804 bmpFileName, |
|
805 bmpId); |
|
806 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
807 } |
|
808 } |
|
809 |
|
810 CleanupStack::PopAndDestroy(); // reader |
|
811 |
|
812 if (!iFirstTimeConstruct) |
|
813 { |
|
814 //ResizeBitmaps(iForgroundBmpRect.Size()); |
|
815 Draw(); |
|
816 } |
|
817 |
|
818 iFirstTimeConstruct = EFalse; |
|
819 |
|
820 } |
|
821 |
|
822 |
|
823 // --------------------------------------------------------------------------- |
|
824 // CAknFepCtrlDragButton::DeleteForgroundRes |
|
825 // This methods shall be called by the container's SizeChanged handler |
|
826 // (other items were commented in a header). |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 void CAknFepCtrlDragButton::DeleteForgroundRes() |
|
830 { |
|
831 if( iForgroundBmp ) |
|
832 { |
|
833 delete iForgroundBmp; |
|
834 iForgroundBmp = NULL; |
|
835 } |
|
836 if( iForgroundBmpMask ) |
|
837 { |
|
838 delete iForgroundBmpMask; |
|
839 iForgroundBmpMask = NULL; |
|
840 } |
|
841 if( iForgroundDimBmpMask ) |
|
842 { |
|
843 delete iForgroundDimBmpMask; |
|
844 iForgroundDimBmpMask = NULL; |
|
845 } |
|
846 } |
|
847 |
|
848 // --------------------------------------------------------------------------- |
|
849 // CAknFepCtrlDragButton::CreateDimmedMaskL |
|
850 // This methods shall be called by the container's SizeChanged handler |
|
851 // (other items were commented in a header). |
|
852 // --------------------------------------------------------------------------- |
|
853 // |
|
854 void CAknFepCtrlDragButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask, |
|
855 const CFbsBitmap* aMask |
|
856 /*TScaleMode aScaleMode*/ ) |
|
857 { |
|
858 if (aMask && aMask->DisplayMode() == EGray256) |
|
859 { |
|
860 delete aDimmedMask; |
|
861 aDimmedMask = NULL; |
|
862 |
|
863 aDimmedMask = new (ELeave) CFbsBitmap; |
|
864 |
|
865 User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); |
|
866 CleanupStack::PushL(aDimmedMask); |
|
867 |
|
868 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask); |
|
869 CleanupStack::PushL(bitmapDevice); |
|
870 |
|
871 CFbsBitGc* bitGc(NULL); |
|
872 User::LeaveIfError(bitmapDevice->CreateContext(bitGc)); |
|
873 CleanupStack::PushL(bitGc); |
|
874 |
|
875 bitGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
876 bitGc->BitBlt(TPoint(0, 0), aMask); |
|
877 |
|
878 aDimmedMask->LockHeap(); |
|
879 TInt w = aMask->SizeInPixels().iWidth; |
|
880 TInt h = aMask->SizeInPixels().iHeight; |
|
881 TInt dataStride = aMask->DataStride() - w; |
|
882 unsigned char* address = (unsigned char *)aDimmedMask->DataAddress(); |
|
883 |
|
884 for ( TInt i = 0; i < h; ++i ) |
|
885 { |
|
886 for ( TInt j = 0; j < w; ++j ) |
|
887 { |
|
888 *address = KTransparency[*address]; |
|
889 ++address; |
|
890 } |
|
891 address += dataStride; |
|
892 } |
|
893 |
|
894 aDimmedMask->UnlockHeap(); |
|
895 |
|
896 //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode); |
|
897 |
|
898 CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc |
|
899 CleanupStack::Pop(1); // aDimmedMask |
|
900 } |
|
901 |
|
902 } |
|
903 |
|
904 |
|
905 // --------------------------------------------------------------------------- |
|
906 // CAknFepCtrlDragButton::SetForgroundBmpRect |
|
907 // This methods shall be called by the container's SizeChanged handler |
|
908 // (other items were commented in a header). |
|
909 // --------------------------------------------------------------------------- |
|
910 // |
|
911 EXPORT_C void CAknFepCtrlDragButton::SetForgroundBmpRect(const TRect& aRect) |
|
912 { |
|
913 iForgroundBmpRect = aRect; |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // CAknFepCtrlDragButton::SetForegroundBmpL |
|
918 // (other items were commented in a header). |
|
919 // --------------------------------------------------------------------------- |
|
920 // |
|
921 EXPORT_C void CAknFepCtrlDragButton::SetForegroundBmpL(CFbsBitmap* aBmp, |
|
922 CFbsBitmap* aMaskBmp) |
|
923 { |
|
924 DeleteForgroundRes(); |
|
925 |
|
926 iForgroundBmp = aBmp; |
|
927 iForgroundBmpMask = aMaskBmp; |
|
928 |
|
929 ResizeBitmaps(iForgroundBmpRect.Size()); |
|
930 } |
|
931 |
|
932 EXPORT_C void CAknFepCtrlDragButton::Move(const TPoint& aOffset) |
|
933 { |
|
934 CButtonBase::Move(aOffset); |
|
935 iForgroundBmpRect.Move( aOffset ); |
|
936 } |
|
937 |
|
938 // --------------------------------------------------------------------------- |
|
939 // CAknFepCtrlDragButton::HandlePointerDownEventL |
|
940 // Handle button down event |
|
941 // (other items were commented in a header). |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlDragButton::HandlePointerDownEventL(const TPoint& aPt) |
|
945 { |
|
946 if( IsDimmed() ) |
|
947 return NULL; |
|
948 |
|
949 CDragBar::HandlePointerDownEventL(aPt); |
|
950 |
|
951 SetReady(ETrue); |
|
952 Draw(); |
|
953 UpdateArea(Rect(),EFalse); |
|
954 ReportEvent(EEventButtonDown); |
|
955 return this; |
|
956 } |
|
957 |
|
958 // --------------------------------------------------------------------------- |
|
959 // CAknFepCtrlDragButton::Draw |
|
960 // Draws UI |
|
961 // (other items were commented in a header). |
|
962 // --------------------------------------------------------------------------- |
|
963 // |
|
964 EXPORT_C void CAknFepCtrlDragButton::Draw() |
|
965 { |
|
966 if(!AbleToDraw()) |
|
967 return; |
|
968 |
|
969 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
970 |
|
971 //mask bitmaps |
|
972 DrawOpaqueMaskBackground(); |
|
973 TRect rect = Rect(); |
|
974 TRect innerRect = rect; |
|
975 innerRect.Shrink( 10, 10 ); |
|
976 |
|
977 // ----- draw bitmaps ----- |
|
978 gc->Activate( BitmapDevice() ); |
|
979 //gc->Clear(rect); |
|
980 |
|
981 CFbsBitmap* bmpMask = NULL; |
|
982 |
|
983 // Draw background |
|
984 if( IsDimmed() ) // Dimmed state |
|
985 { |
|
986 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
987 *gc, |
|
988 rect, |
|
989 innerRect, |
|
990 iInactiveImgID, |
|
991 KAknsIIDDefault ); |
|
992 if( iForgroundDimBmpMask ) |
|
993 { |
|
994 delete iForgroundDimBmpMask; |
|
995 iForgroundDimBmpMask = NULL; |
|
996 } |
|
997 TRAP_IGNORE(CreateDimmedMaskL( iForgroundDimBmpMask, |
|
998 iForgroundBmpMask )); |
|
999 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), |
|
1000 EAspectRatioNotPreserved); |
|
1001 bmpMask = iForgroundDimBmpMask; |
|
1002 } |
|
1003 else |
|
1004 { |
|
1005 // Normal state or pressed state |
|
1006 TAknsItemID ImgID = (IsDragging() | PointerDown()) ? iPressedImgID : iNormalImgID; |
|
1007 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
1008 *gc, |
|
1009 rect, |
|
1010 innerRect, |
|
1011 ImgID, |
|
1012 KAknsIIDDefault ); |
|
1013 bmpMask = iForgroundBmpMask; |
|
1014 } |
|
1015 |
|
1016 // Draw forground |
|
1017 if( iForgroundBmp ) |
|
1018 { |
|
1019 TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() ); |
|
1020 if( bmpMask ) |
|
1021 { |
|
1022 gc->BitBltMasked( iForgroundBmpRect.iTl, |
|
1023 iForgroundBmp, |
|
1024 srcRect, |
|
1025 bmpMask, |
|
1026 EFalse); |
|
1027 } |
|
1028 else |
|
1029 { |
|
1030 gc->BitBlt( iForgroundBmpRect.iTl, |
|
1031 iForgroundBmp, |
|
1032 srcRect ); |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 if (iText) |
|
1037 { |
|
1038 TAknLayoutText textLayout; |
|
1039 textLayout.LayoutText(Rect(), iTextFormat); |
|
1040 textLayout.DrawText(*gc, *iText); |
|
1041 } |
|
1042 } |
|
1043 |
|
1044 |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // CAknFepCtrlDragButton::ResizeBitmaps |
|
1047 // This methods shall be called by the container's SizeChanged handler |
|
1048 // (other items were commented in a header). |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // |
|
1051 void CAknFepCtrlDragButton::ResizeBitmaps(TSize aInnerSize) |
|
1052 { |
|
1053 /* |
|
1054 if (iMaskBmpList.Count() >= 1 && |
|
1055 iMaskBmpList[0]->SizeInPixels() != aSize) |
|
1056 { |
|
1057 for( TInt ii = 0; ii < iMaskBmpList.Count(); ++ii ) |
|
1058 { |
|
1059 AknIconUtils::SetSize(iMaskBmpList[ii], aSize, EAspectRatioNotPreserved); |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 if (iBmpList.Count() >= 1 && |
|
1064 iBmpList[0]->SizeInPixels() != aSize) |
|
1065 { |
|
1066 for( TInt ii = 0; ii < iBmpList.Count(); ++ii ) |
|
1067 { |
|
1068 AknIconUtils::SetSize(iBmpList[ii], aSize, EAspectRatioNotPreserved); |
|
1069 } |
|
1070 }*/ |
|
1071 if( iForgroundBmp && ( iForgroundBmp->SizeInPixels() != aInnerSize ) ) |
|
1072 { |
|
1073 AknIconUtils::SetSize( iForgroundBmp, aInnerSize, EAspectRatioNotPreserved ); |
|
1074 } |
|
1075 if( iForgroundBmpMask && ( iForgroundBmpMask->SizeInPixels() != aInnerSize ) ) |
|
1076 { |
|
1077 AknIconUtils::SetSize( iForgroundBmpMask, aInnerSize, EAspectRatioNotPreserved ); |
|
1078 } |
|
1079 |
|
1080 /*TRAP_IGNORE(CreateDimmedMaskL(iForgroundDimBmpMask, |
|
1081 iForgroundBmpMask)); */ |
|
1082 } |
|
1083 |
|
1084 // ----------------------------------------------------------------------------- |
|
1085 // CAknFepCtrlDragButton::SizeChanged |
|
1086 // This methods shall be called by the container's SizeChanged handler |
|
1087 // (other items were commented in a header). |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // |
|
1090 EXPORT_C void CAknFepCtrlDragButton::SizeChanged(TRect aNewRect, |
|
1091 TRect aInnerRect, |
|
1092 TBool aIsReloadImages) |
|
1093 { |
|
1094 // Reset the position and the extent of the button aera |
|
1095 /*if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) |
|
1096 { |
|
1097 return; |
|
1098 } |
|
1099 |
|
1100 SetRect(aNewRect); |
|
1101 |
|
1102 if (aIsReloadImages) |
|
1103 { |
|
1104 ResizeBitmaps(aNewRect.Size()); |
|
1105 } |
|
1106 |
|
1107 Draw(); |
|
1108 UpdateArea(Rect(), ETrue);*/ |
|
1109 |
|
1110 if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) |
|
1111 { |
|
1112 return; |
|
1113 } |
|
1114 |
|
1115 TRect oriRect = Rect(); |
|
1116 SetRect(aNewRect); |
|
1117 iForgroundBmpRect = aInnerRect; |
|
1118 |
|
1119 if (aIsReloadImages) |
|
1120 { |
|
1121 ResizeBitmaps(aInnerRect.Size() ); |
|
1122 } |
|
1123 RootControl()->ReDrawRect( oriRect ); |
|
1124 UpdateArea(oriRect, EFalse); |
|
1125 Draw(); |
|
1126 UpdateArea(Rect(), EFalse); |
|
1127 } |
|
1128 |
|
1129 // ----------------------------------------------------------------------------- |
|
1130 // CAknFepCtrlMultiModeButton::CAknFepCtrlMultiModeButton |
|
1131 // C++ default constructor can NOT contain any code, that |
|
1132 // might leave. |
|
1133 // (other items were commented in a header). |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // |
|
1136 EXPORT_C CAknFepCtrlMultiModeButton::CAknFepCtrlMultiModeButton(CFepUiLayout* aUiLayout, |
|
1137 TInt aControlId,TAknsItemID aNormalID, |
|
1138 TAknsItemID aPressedID,TAknsItemID aInactiveID) |
|
1139 : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID) |
|
1140 { |
|
1141 } |
|
1142 |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // CAknFepCtrlMultiModeButton::NewL |
|
1145 // Two-phased constructor. |
|
1146 // (other items were commented in a header). |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // |
|
1149 EXPORT_C CAknFepCtrlMultiModeButton* CAknFepCtrlMultiModeButton::NewL(CFepUiLayout* aUiLayout, |
|
1150 TInt aControlId,TAknsItemID aNormalID, |
|
1151 TAknsItemID aPressedID,TAknsItemID aInactiveID) |
|
1152 { |
|
1153 CAknFepCtrlMultiModeButton* self = NewLC(aUiLayout, aControlId, |
|
1154 aNormalID, aPressedID, aInactiveID); |
|
1155 CleanupStack::Pop(self); |
|
1156 |
|
1157 return self; |
|
1158 } |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // CAknFepCtrlMultiModeButton::NewLC |
|
1162 // Two-phased constructor. |
|
1163 // (other items were commented in a header). |
|
1164 // ----------------------------------------------------------------------------- |
|
1165 // |
|
1166 EXPORT_C CAknFepCtrlMultiModeButton* CAknFepCtrlMultiModeButton::NewLC(CFepUiLayout* aUiLayout, |
|
1167 TInt aControlId,TAknsItemID aNormalID, |
|
1168 TAknsItemID aPressedID,TAknsItemID aInactiveID) |
|
1169 { |
|
1170 CAknFepCtrlMultiModeButton* self = new (ELeave) CAknFepCtrlMultiModeButton(aUiLayout, |
|
1171 aControlId, |
|
1172 aNormalID, |
|
1173 aPressedID, |
|
1174 aInactiveID); |
|
1175 CleanupStack::PushL(self); |
|
1176 self->BaseConstructL(); |
|
1177 |
|
1178 return self; |
|
1179 } |
|
1180 |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // Destructor. |
|
1183 // (other items were commented in a header). |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // |
|
1186 EXPORT_C CAknFepCtrlMultiModeButton::~CAknFepCtrlMultiModeButton() |
|
1187 { |
|
1188 iImageResIdList.Close(); |
|
1189 iForegroundBmpList.ResetAndDestroy(); |
|
1190 iForegroundBmpList.Close(); |
|
1191 iForegroundMaskBmpList.ResetAndDestroy(); |
|
1192 iForegroundMaskBmpList.Close(); |
|
1193 |
|
1194 iModeTextList.ResetAndDestroy(); |
|
1195 iModeTextList.Close(); |
|
1196 |
|
1197 iModesList.ResetAndDestroy(); |
|
1198 iModesList.Close(); |
|
1199 } |
|
1200 |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // CAknFepCtrlMultiModeButton::ConstructFromResourceL |
|
1203 // The order of the image ids in the CButtonBase class must not be changed |
|
1204 // (other items were commented in a header). |
|
1205 // ----------------------------------------------------------------------------- |
|
1206 // |
|
1207 |
|
1208 EXPORT_C void CAknFepCtrlMultiModeButton::ConstructFromResourceL(TResourceReader& aReader) |
|
1209 { |
|
1210 if (!iFirstTimeConstruct) |
|
1211 { |
|
1212 iImageResIdList.Close(); |
|
1213 iForegroundBmpList.ResetAndDestroy(); |
|
1214 iForegroundBmpList.Close(); |
|
1215 iForegroundMaskBmpList.ResetAndDestroy(); |
|
1216 iForegroundMaskBmpList.Close(); |
|
1217 |
|
1218 iModeTextList.ResetAndDestroy(); |
|
1219 iModeTextList.Close(); |
|
1220 |
|
1221 |
|
1222 iModesList.ResetAndDestroy(); |
|
1223 iModesList.Close(); |
|
1224 |
|
1225 ResetBmpPool(); |
|
1226 } |
|
1227 |
|
1228 // read text color and shadow text color |
|
1229 TInt32 colorMajorSkinId = aReader.ReadInt32(); |
|
1230 const TInt skinitemid = aReader.ReadInt16(); |
|
1231 TInt textcoloridx = aReader.ReadInt16(); |
|
1232 TInt shadowtextcoloridx = aReader.ReadInt16(); |
|
1233 |
|
1234 TAknsItemID id; |
|
1235 |
|
1236 id.Set(TInt(colorMajorSkinId), skinitemid); |
|
1237 TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
1238 iFontColor, |
|
1239 id, |
|
1240 textcoloridx); |
|
1241 |
|
1242 if (error != KErrNone) |
|
1243 { |
|
1244 iFontColor = TRgb(KDefaultTextColor); |
|
1245 } |
|
1246 |
|
1247 SetFontColor(iFontColor); |
|
1248 |
|
1249 error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
1250 iShadowFontColor, |
|
1251 id, |
|
1252 shadowtextcoloridx); |
|
1253 |
|
1254 if (error != KErrNone) |
|
1255 { |
|
1256 iShadowFontColor = TRgb(KDefaultShadowTextColor); |
|
1257 } |
|
1258 |
|
1259 SetShadowFontColor(iShadowFontColor); |
|
1260 |
|
1261 const TInt16 countModes = aReader.ReadInt16(); // Read the count of different cases |
|
1262 |
|
1263 if (countModes <= 0) |
|
1264 { |
|
1265 User::Leave(KErrArgument); |
|
1266 } |
|
1267 |
|
1268 iNumberOfModes = 0; |
|
1269 |
|
1270 for (TInt ii = 0; ii < countModes; ii++) |
|
1271 { |
|
1272 AddModeL(aReader); |
|
1273 iNumberOfModes++; |
|
1274 } |
|
1275 |
|
1276 if (iFirstTimeConstruct) |
|
1277 { |
|
1278 if (iImageResIdList.Count() == 1) |
|
1279 { |
|
1280 // set background bimap for button |
|
1281 SetButtonBmpL(EBtnBmpNonActive, 0); |
|
1282 iCurrentBmpType = EBtnBmpNonActive; |
|
1283 } |
|
1284 |
|
1285 const TInt16 defaultModeIndex = aReader.ReadInt16(); |
|
1286 SetCurrentModeL(EBtnBmpNonActive, defaultModeIndex); |
|
1287 } |
|
1288 else |
|
1289 { |
|
1290 SetButtonBmpL(iCurrentBmpType, iCurrentMode); |
|
1291 Draw(); |
|
1292 } |
|
1293 |
|
1294 iFirstTimeConstruct = EFalse; |
|
1295 } |
|
1296 |
|
1297 // ----------------------------------------------------------------------------- |
|
1298 // CAknFepCtrlMultiModeButton::ConstructFromResourceL |
|
1299 // (other items were commented in a header). |
|
1300 // ----------------------------------------------------------------------------- |
|
1301 // |
|
1302 |
|
1303 EXPORT_C void CAknFepCtrlMultiModeButton::ConstructFromResourceL() |
|
1304 { |
|
1305 if (iResourceId == KInvalidResId) |
|
1306 { |
|
1307 return; |
|
1308 } |
|
1309 |
|
1310 if (!iFirstTimeConstruct) |
|
1311 { |
|
1312 iImageResIdList.Close(); |
|
1313 iForegroundBmpList.ResetAndDestroy(); |
|
1314 iForegroundBmpList.Close(); |
|
1315 iForegroundMaskBmpList.ResetAndDestroy(); |
|
1316 iForegroundMaskBmpList.Close(); |
|
1317 |
|
1318 iModeTextList.ResetAndDestroy(); |
|
1319 iModeTextList.Close(); |
|
1320 |
|
1321 |
|
1322 iModesList.ResetAndDestroy(); |
|
1323 iModesList.Close(); |
|
1324 |
|
1325 ResetBmpPool(); |
|
1326 } |
|
1327 |
|
1328 TResourceReader reader; |
|
1329 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
1330 |
|
1331 // read text color and shadow text color |
|
1332 TInt32 colorMajorSkinId = reader.ReadInt32(); |
|
1333 const TInt skinitemid = reader.ReadInt16(); |
|
1334 TInt textcoloridx = reader.ReadInt16(); |
|
1335 TInt shadowtextcoloridx = reader.ReadInt16(); |
|
1336 |
|
1337 TAknsItemID id; |
|
1338 |
|
1339 id.Set(TInt(colorMajorSkinId), skinitemid); |
|
1340 TInt error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
1341 iFontColor, |
|
1342 id, |
|
1343 textcoloridx); |
|
1344 |
|
1345 if (error != KErrNone) |
|
1346 { |
|
1347 iFontColor = TRgb(KDefaultTextColor); |
|
1348 } |
|
1349 |
|
1350 SetFontColor(iFontColor); |
|
1351 |
|
1352 error = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
1353 iShadowFontColor, |
|
1354 id, |
|
1355 shadowtextcoloridx); |
|
1356 |
|
1357 if (error != KErrNone) |
|
1358 { |
|
1359 iShadowFontColor = TRgb(KDefaultShadowTextColor); |
|
1360 } |
|
1361 |
|
1362 SetShadowFontColor(iShadowFontColor); |
|
1363 |
|
1364 const TInt16 countModes = reader.ReadInt16(); |
|
1365 |
|
1366 if (countModes <= 0) |
|
1367 { |
|
1368 User::Leave(KErrArgument); |
|
1369 } |
|
1370 |
|
1371 iNumberOfModes = 0; |
|
1372 |
|
1373 for (TInt ii = 0; ii < countModes; ii++) |
|
1374 { |
|
1375 AddModeL(reader); |
|
1376 iNumberOfModes++; |
|
1377 } |
|
1378 |
|
1379 |
|
1380 if (iFirstTimeConstruct) |
|
1381 { |
|
1382 if (iImageResIdList.Count() == 1) |
|
1383 { |
|
1384 // set background bimap for button |
|
1385 SetButtonBmpL(EBtnBmpNonActive, 0); |
|
1386 iCurrentBmpType = EBtnBmpNonActive; |
|
1387 } |
|
1388 |
|
1389 const TInt16 defaultModeIndex = reader.ReadInt16(); |
|
1390 SetCurrentModeL(EBtnBmpNonActive, defaultModeIndex); |
|
1391 } |
|
1392 else |
|
1393 { |
|
1394 ResizeBitmaps(iForgroundBmpRect.Size()); |
|
1395 SetButtonBmpL(iCurrentBmpType, iCurrentMode); |
|
1396 Draw(); |
|
1397 } |
|
1398 |
|
1399 CleanupStack::PopAndDestroy(); // reader |
|
1400 |
|
1401 iFirstTimeConstruct = EFalse; |
|
1402 |
|
1403 } |
|
1404 |
|
1405 // ----------------------------------------------------------------------------- |
|
1406 // CAknFepCtrlMultiModeButton::AddModeL |
|
1407 // Add new display mode from resource reader |
|
1408 // (other items were commented in a header). |
|
1409 // ----------------------------------------------------------------------------- |
|
1410 // |
|
1411 EXPORT_C void CAknFepCtrlMultiModeButton::AddModeL(TResourceReader& aReader) |
|
1412 { |
|
1413 const TInt32 imageResId = aReader.ReadInt32(); |
|
1414 iModeTextList.Append(aReader.ReadHBufCL()); |
|
1415 const TInt rangeId = aReader.ReadInt16(); |
|
1416 const TInt modeId = aReader.ReadInt16(); |
|
1417 |
|
1418 TAknFepModeIndicator* modeIndicator = new (ELeave) TAknFepModeIndicator; |
|
1419 CleanupStack::PushL(modeIndicator); |
|
1420 |
|
1421 modeIndicator->iRangeId = rangeId; |
|
1422 modeIndicator->iModeId = modeId; |
|
1423 modeIndicator->iPermitted = ETrue; |
|
1424 |
|
1425 iModesList.AppendL(modeIndicator); |
|
1426 CleanupStack::Pop(modeIndicator); // indicator |
|
1427 |
|
1428 if ( imageResId != KInvalidBmp ) |
|
1429 { |
|
1430 // switch mode means change image |
|
1431 TResourceReader reader; |
|
1432 CCoeEnv::Static()->CreateResourceReaderLC(reader, imageResId); |
|
1433 |
|
1434 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
1435 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
1436 TInt colorGroup = reader.ReadInt16(); |
|
1437 TAknsItemID id; |
|
1438 |
|
1439 for (TInt jj = 0; jj < /*EBtnBmpLastType +*/ 1; jj++) |
|
1440 { |
|
1441 const TInt16 bmpId = reader.ReadInt16(); |
|
1442 const TInt16 bmpMskId = reader.ReadInt16(); |
|
1443 const TInt16 skinitemid = reader.ReadInt16(); |
|
1444 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
1445 |
|
1446 if (bmpId != KInvalidBmp) |
|
1447 { |
|
1448 CFbsBitmap* bmp = NULL; |
|
1449 CFbsBitmap* maskbmp = NULL; |
|
1450 |
|
1451 if (bmpMskId != KInvalidBmp) |
|
1452 { |
|
1453 if( colorGroup == KInvalidColorGroup ) |
|
1454 { |
|
1455 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
1456 id, |
|
1457 bmp, |
|
1458 maskbmp, |
|
1459 bmpFileName, |
|
1460 bmpId, |
|
1461 bmpMskId); |
|
1462 } |
|
1463 else |
|
1464 { |
|
1465 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
1466 id, |
|
1467 KAknsIIDQsnIconColors, |
|
1468 colorGroup, |
|
1469 bmp, |
|
1470 maskbmp, |
|
1471 bmpFileName, |
|
1472 bmpId, |
|
1473 bmpMskId, |
|
1474 AKN_LAF_COLOR( 0 ) ); |
|
1475 |
|
1476 } |
|
1477 CleanupStack::PushL(maskbmp); |
|
1478 AknIconUtils::SetSize(maskbmp, iForgroundBmpRect.Size(), |
|
1479 EAspectRatioNotPreserved); |
|
1480 iForegroundMaskBmpList.AppendL(maskbmp); |
|
1481 CleanupStack::Pop(maskbmp); |
|
1482 |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
1487 id, |
|
1488 bmp, |
|
1489 bmpFileName, |
|
1490 bmpId); |
|
1491 |
|
1492 } |
|
1493 |
|
1494 CleanupStack::PushL(bmp); |
|
1495 AknIconUtils::SetSize(bmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
1496 iForegroundBmpList.AppendL(bmp); |
|
1497 CleanupStack::Pop(bmp); |
|
1498 |
|
1499 } |
|
1500 } |
|
1501 |
|
1502 CleanupStack::PopAndDestroy(); //reader |
|
1503 |
|
1504 iImageResIdList.Append(imageResId); |
|
1505 } |
|
1506 } |
|
1507 |
|
1508 // ----------------------------------------------------------------------------- |
|
1509 // CAknFepCtrlMultiModeButton::SetButtonBmp |
|
1510 // (other items were commented in a header). |
|
1511 // ----------------------------------------------------------------------------- |
|
1512 // |
|
1513 EXPORT_C void CAknFepCtrlMultiModeButton::SetButtonBmpL(const TButtonBmpType aType , |
|
1514 const TInt aMode) |
|
1515 { |
|
1516 if ( !ForgroundBmp() || |
|
1517 ForgroundBmp()->Handle() != iForegroundBmpList[aMode]->Handle() || |
|
1518 !ForgroundBmpMask() || |
|
1519 ForgroundBmpMask()->Handle() != iForegroundMaskBmpList[aMode]->Handle() ) |
|
1520 { |
|
1521 CFbsBitmap* bmp = new (ELeave) CFbsBitmap; |
|
1522 if(iForegroundMaskBmpList.Count() > 0 && iForegroundBmpList[aMode]) |
|
1523 { |
|
1524 CleanupStack::PushL( bmp ); |
|
1525 |
|
1526 User::LeaveIfError(bmp->Duplicate(iForegroundBmpList[aMode]->Handle())); |
|
1527 |
|
1528 CleanupStack::Pop( bmp ); |
|
1529 } |
|
1530 else |
|
1531 { |
|
1532 delete bmp; |
|
1533 bmp = NULL; |
|
1534 } |
|
1535 CFbsBitmap* maskbmp = new (ELeave) CFbsBitmap; |
|
1536 |
|
1537 if(iForegroundMaskBmpList.Count() > 0 && iForegroundMaskBmpList[aMode]) |
|
1538 { |
|
1539 CleanupStack::PushL( maskbmp ); |
|
1540 User::LeaveIfError(maskbmp->Duplicate(iForegroundMaskBmpList[aMode]->Handle())); |
|
1541 CleanupStack::Pop( maskbmp ); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 delete maskbmp; |
|
1546 maskbmp = NULL; |
|
1547 } |
|
1548 SetForegroundBmpL(bmp,maskbmp); |
|
1549 } |
|
1550 else if ( ForgroundBmp()->SizeInPixels() != iForegroundBmpList[aMode]->SizeInPixels() || |
|
1551 ForgroundBmpMask()->SizeInPixels() != iForegroundMaskBmpList[aMode]->SizeInPixels()) |
|
1552 { |
|
1553 ResizeBitmaps(iForegroundBmpList[aMode]->SizeInPixels()); |
|
1554 } |
|
1555 |
|
1556 if(aType == EBtnBmpActivePressed |
|
1557 || aType == EBtnBmpNonActivePressed) |
|
1558 { |
|
1559 SetHighlight(ETrue); |
|
1560 } |
|
1561 } |
|
1562 |
|
1563 // ----------------------------------------------------------------------------- |
|
1564 // CAknFepCtrlMultiModeButton::SetCurrentModeL |
|
1565 // (other items were commented in a header). |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // |
|
1568 EXPORT_C void CAknFepCtrlMultiModeButton::SetCurrentModeL(const TButtonBmpType aType, |
|
1569 const TInt aModeIndex) |
|
1570 { |
|
1571 if ((aModeIndex >= 0) && |
|
1572 (aModeIndex <= NumberOfModes()-1) && |
|
1573 (iModesList[aModeIndex]->iPermitted)) |
|
1574 { |
|
1575 iCurrentMode = aModeIndex; |
|
1576 |
|
1577 if (iImageResIdList.Count() > 1) |
|
1578 { |
|
1579 // change mode means change image |
|
1580 SetButtonBmpL(aType, iCurrentMode); |
|
1581 iCurrentBmpType = aType; |
|
1582 } |
|
1583 |
|
1584 Draw(); |
|
1585 UpdateArea(Rect()); |
|
1586 } |
|
1587 } |
|
1588 |
|
1589 // ----------------------------------------------------------------------------- |
|
1590 // CAknFepCtrlMultiModeButton::NextMode |
|
1591 // (other items were commented in a header). |
|
1592 // ----------------------------------------------------------------------------- |
|
1593 // |
|
1594 EXPORT_C TInt CAknFepCtrlMultiModeButton::NextMode() const |
|
1595 { |
|
1596 TInt startIndex = 0; |
|
1597 |
|
1598 if (iCurrentMode < (NumberOfModes() -1)) |
|
1599 { |
|
1600 startIndex = iCurrentMode + 1; |
|
1601 } |
|
1602 |
|
1603 TBool find = EFalse; |
|
1604 |
|
1605 while (!find && (startIndex != iCurrentMode)) |
|
1606 { |
|
1607 if (iModesList[startIndex]->iPermitted) |
|
1608 { |
|
1609 find = ETrue; |
|
1610 } |
|
1611 else |
|
1612 { |
|
1613 startIndex++; |
|
1614 |
|
1615 if (startIndex > (NumberOfModes()-1)) |
|
1616 { |
|
1617 startIndex = 0; |
|
1618 } |
|
1619 } |
|
1620 } |
|
1621 |
|
1622 if (find) |
|
1623 { |
|
1624 return startIndex; |
|
1625 } |
|
1626 else |
|
1627 { |
|
1628 return iCurrentMode; |
|
1629 } |
|
1630 } |
|
1631 |
|
1632 // ----------------------------------------------------------------------------- |
|
1633 // CAknFepCtrlMultiModeButton::ImageAlreadyExist |
|
1634 // (other items were commented in a header). |
|
1635 // ----------------------------------------------------------------------------- |
|
1636 // |
|
1637 EXPORT_C TBool CAknFepCtrlMultiModeButton::ImageAlreadyExist(const TInt32 aResId) |
|
1638 { |
|
1639 TBool findResId = EFalse; |
|
1640 |
|
1641 for (TInt i=0; i<iImageResIdList.Count(); i++) |
|
1642 { |
|
1643 if (aResId == iImageResIdList[i]) |
|
1644 { |
|
1645 findResId = ETrue; |
|
1646 |
|
1647 break; |
|
1648 } |
|
1649 } |
|
1650 |
|
1651 return findResId; |
|
1652 } |
|
1653 |
|
1654 // ----------------------------------------------------------------------------- |
|
1655 // CAknFepCtrlMultiModeButton::DisplayText |
|
1656 // (other items were commented in a header). |
|
1657 // ----------------------------------------------------------------------------- |
|
1658 // |
|
1659 EXPORT_C void CAknFepCtrlMultiModeButton::DisplayText() |
|
1660 { |
|
1661 if ((iFont) && (iShadowFont)) |
|
1662 { |
|
1663 // draw shadow text |
|
1664 BitGc()->UseFont(iShadowFont); |
|
1665 |
|
1666 BitGc()->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1667 BitGc()->SetBrushColor( KRgbBlack);//Non transparent at all |
|
1668 BitGc()->SetPenColor(iShadowFontColor); |
|
1669 BitGc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1670 BitGc()->SetPenSize( PenSize()); |
|
1671 |
|
1672 TPoint pointText; |
|
1673 TPoint pointShadowText; |
|
1674 |
|
1675 TInt leftMarginOfText = |
|
1676 (Rect().Width() - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode])))/2; |
|
1677 |
|
1678 pointText.iX = Rect().iTl.iX + leftMarginOfText; |
|
1679 pointText.iY = Rect().iTl.iY + Rect().Height()*3/4; |
|
1680 |
|
1681 pointShadowText.iX = pointText.iX + 1; |
|
1682 pointShadowText.iY = pointText.iY + 1; |
|
1683 |
|
1684 //BitGc()->DrawText(*(iModeTextList[iCurrentMode]), Rect(), Rect().Height()*3/4, CGraphicsContext::ECenter, Rect().Width()/2 - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode]))/2); |
|
1685 BitGc()->DrawText(*(iModeTextList[iCurrentMode]), pointShadowText); |
|
1686 |
|
1687 BitGc()->DiscardFont(); |
|
1688 |
|
1689 // draw text |
|
1690 BitGc()->UseFont(iFont); |
|
1691 |
|
1692 BitGc()->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1693 BitGc()->SetBrushColor( KRgbBlack);//Non transparent at all |
|
1694 BitGc()->SetPenColor(iFontColor); |
|
1695 BitGc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1696 BitGc()->SetPenSize( PenSize()); |
|
1697 |
|
1698 //BitGc()->DrawText(*(iModeTextList[iCurrentMode]), Rect(), Rect().Height()*3/4+1, CGraphicsContext::ECenter, Rect().Width()/2 - iFont->TextWidthInPixels(*(iModeTextList[iCurrentMode]))/2-1); |
|
1699 BitGc()->DrawText(*(iModeTextList[iCurrentMode]), pointText); |
|
1700 |
|
1701 BitGc()->DiscardFont(); |
|
1702 |
|
1703 //BitGc()->SetPenStyle(CGraphicsContext::ENullPen); |
|
1704 } |
|
1705 } |
|
1706 |
|
1707 // ----------------------------------------------------------------------------- |
|
1708 // CAknFepCtrlMultiModeButton::Draw |
|
1709 // (other items were commented in a header). |
|
1710 // ----------------------------------------------------------------------------- |
|
1711 // |
|
1712 EXPORT_C void CAknFepCtrlMultiModeButton::Draw() |
|
1713 { |
|
1714 if(!AbleToDraw()) |
|
1715 return; |
|
1716 |
|
1717 CAknFepCtrlCommonButton::Draw(); |
|
1718 //CButtonBase::Draw(); |
|
1719 if ( iModeTextList.Count() ) |
|
1720 { |
|
1721 if ((iModeTextList[iCurrentMode]) && (iModeTextList[iCurrentMode]->Length() > 0)) |
|
1722 { |
|
1723 DisplayText(); |
|
1724 } |
|
1725 } |
|
1726 } |
|
1727 |
|
1728 // ----------------------------------------------------------------------------- |
|
1729 // CAknFepCtrlMultiModeButton::SetFontColor |
|
1730 // (other items were commented in a header). |
|
1731 // ----------------------------------------------------------------------------- |
|
1732 // |
|
1733 EXPORT_C void CAknFepCtrlMultiModeButton::SetFontColor(const TRgb aFontColor) |
|
1734 { |
|
1735 iFontColor = aFontColor; |
|
1736 } |
|
1737 |
|
1738 // ----------------------------------------------------------------------------- |
|
1739 // CAknFepCtrlMultiModeButton::SetShadowFontColor |
|
1740 // (other items were commented in a header). |
|
1741 // ----------------------------------------------------------------------------- |
|
1742 // |
|
1743 EXPORT_C void CAknFepCtrlMultiModeButton::SetShadowFontColor(const TRgb aShadowFontColor) |
|
1744 { |
|
1745 iShadowFontColor = aShadowFontColor; |
|
1746 } |
|
1747 |
|
1748 // ----------------------------------------------------------------------------- |
|
1749 // CAknFepCtrlMultiModeButton::SetPermittedModes |
|
1750 // (other items were commented in a header). |
|
1751 // ----------------------------------------------------------------------------- |
|
1752 // |
|
1753 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetPermittedModes(const TInt aRangeId, |
|
1754 const TInt aRealCaseId, |
|
1755 TBool aPermit) |
|
1756 { |
|
1757 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1758 { |
|
1759 if ((iModesList[i]->iRangeId == aRangeId) && (iModesList[i]->iModeId == aRealCaseId)) |
|
1760 { |
|
1761 iModesList[i]->iPermitted = aPermit; |
|
1762 |
|
1763 return KErrNone; |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 return KErrNotSupported; |
|
1768 } |
|
1769 |
|
1770 // ----------------------------------------------------------------------------- |
|
1771 // CAknFepCtrlMultiModeButton::SetPermittedRange |
|
1772 // (other items were commented in a header). |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 // |
|
1775 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetPermittedRange(const TInt aRangeId, TBool aPermit) |
|
1776 { |
|
1777 TBool findRangeId = EFalse; |
|
1778 |
|
1779 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1780 { |
|
1781 if ((iModesList[i]->iRangeId == aRangeId) && (iModesList[i]->iPermitted != aPermit)) |
|
1782 { |
|
1783 iModesList[i]->iPermitted = aPermit; |
|
1784 findRangeId = ETrue; |
|
1785 } |
|
1786 } |
|
1787 |
|
1788 if (!findRangeId) |
|
1789 { |
|
1790 return KErrNotSupported; |
|
1791 } |
|
1792 else |
|
1793 { |
|
1794 return KErrNone; |
|
1795 } |
|
1796 } |
|
1797 |
|
1798 // ----------------------------------------------------------------------------- |
|
1799 // CAknFepCtrlMultiModeButton::EnableAllModes |
|
1800 // (other items were commented in a header). |
|
1801 // ----------------------------------------------------------------------------- |
|
1802 // |
|
1803 EXPORT_C void CAknFepCtrlMultiModeButton::EnableAllModes() |
|
1804 { |
|
1805 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1806 { |
|
1807 iModesList[i]->iPermitted = ETrue; |
|
1808 } |
|
1809 } |
|
1810 |
|
1811 // ----------------------------------------------------------------------------- |
|
1812 // CAknFepCtrlMultiModeButton::DisableAllModes |
|
1813 // (other items were commented in a header). |
|
1814 // ----------------------------------------------------------------------------- |
|
1815 // |
|
1816 EXPORT_C void CAknFepCtrlMultiModeButton::DisableAllModes() |
|
1817 { |
|
1818 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1819 { |
|
1820 iModesList[i]->iPermitted = EFalse; |
|
1821 } |
|
1822 } |
|
1823 |
|
1824 // ----------------------------------------------------------------------------- |
|
1825 // CAknFepCtrlMultiModeButton::DisableAllModes |
|
1826 // (other items were commented in a header). |
|
1827 // ----------------------------------------------------------------------------- |
|
1828 // |
|
1829 EXPORT_C void CAknFepCtrlMultiModeButton::DisableOneModes(const TInt aRangeId) |
|
1830 { |
|
1831 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1832 { |
|
1833 if(iModesList[i]->iRangeId == aRangeId) |
|
1834 { |
|
1835 iModesList[i]->iPermitted = EFalse; |
|
1836 TRAP_IGNORE(SetCurrentModeL(EBtnBmpNonActive, NextMode())); |
|
1837 } |
|
1838 } |
|
1839 } |
|
1840 |
|
1841 // ----------------------------------------------------------------------------- |
|
1842 // CAknFepCtrlMultiModeButton::IsGivenRangeSupported |
|
1843 // (other items were commented in a header). |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // |
|
1846 EXPORT_C TBool CAknFepCtrlMultiModeButton::IsGivenRangeSupported(const TInt aRange) |
|
1847 { |
|
1848 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1849 { |
|
1850 // judge if aRange is supported by at least 1 mode |
|
1851 if ((iModesList[i]->iRangeId == aRange) && (iModesList[i]->iPermitted)) |
|
1852 { |
|
1853 return ETrue; |
|
1854 } |
|
1855 } |
|
1856 |
|
1857 return EFalse; |
|
1858 } |
|
1859 |
|
1860 // ----------------------------------------------------------------------------- |
|
1861 // CAknFepCtrlMultiModeButton::SetRange |
|
1862 // (other items were commented in a header). |
|
1863 // ----------------------------------------------------------------------------- |
|
1864 // |
|
1865 EXPORT_C TInt CAknFepCtrlMultiModeButton::SetRange(const TInt aRange) |
|
1866 { |
|
1867 if (CurrentRange() != aRange) |
|
1868 { |
|
1869 for (TInt i = 0; i < iModesList.Count(); i++) |
|
1870 { |
|
1871 if ((iModesList[i]->iRangeId == aRange) && |
|
1872 (iModesList[i]->iPermitted)) |
|
1873 { |
|
1874 TRAP_IGNORE(SetCurrentModeL(EBtnBmpActive, i)); |
|
1875 return KErrNone; |
|
1876 } |
|
1877 } |
|
1878 } |
|
1879 |
|
1880 return KErrNotSupported; |
|
1881 } |
|
1882 |
|
1883 // ----------------------------------------------------------------------------- |
|
1884 // CAknFepCtrlMultiModeButton::CurrentRange |
|
1885 // (other items were commented in a header). |
|
1886 // ----------------------------------------------------------------------------- |
|
1887 // |
|
1888 EXPORT_C TInt CAknFepCtrlMultiModeButton::CurrentRange() const |
|
1889 { |
|
1890 if ((iCurrentMode >= 0) && (iCurrentMode <= (NumberOfModes()-1))) |
|
1891 { |
|
1892 return iModesList[iCurrentMode]->iRangeId; |
|
1893 } |
|
1894 else |
|
1895 { |
|
1896 return KErrNotFound; |
|
1897 } |
|
1898 } |
|
1899 |
|
1900 // ----------------------------------------------------------------------------- |
|
1901 // CAknFepCtrlMultiModeButton::RangeOfGivenMode() |
|
1902 // (other items were commented in a header). |
|
1903 // ----------------------------------------------------------------------------- |
|
1904 // |
|
1905 EXPORT_C TInt CAknFepCtrlMultiModeButton::RangeOfGivenMode(TInt aModeIndex) const |
|
1906 { |
|
1907 if ((aModeIndex >= 0) && (aModeIndex <= NumberOfModes()-1)) |
|
1908 { |
|
1909 return iModesList[aModeIndex]->iRangeId; |
|
1910 } |
|
1911 |
|
1912 return KErrNotSupported; |
|
1913 } |
|
1914 |
|
1915 // ----------------------------------------------------------------------------- |
|
1916 // CAknFepCtrlMultiModeButton::GetRealCaseByMode() |
|
1917 // (other items were commented in a header). |
|
1918 // ----------------------------------------------------------------------------- |
|
1919 // |
|
1920 EXPORT_C TInt CAknFepCtrlMultiModeButton::GetRealCaseByMode(TInt aModeIndex) const |
|
1921 { |
|
1922 if ((aModeIndex >= 0) && (aModeIndex <= NumberOfModes() -1)) |
|
1923 { |
|
1924 return iModesList[aModeIndex]->iModeId; |
|
1925 } |
|
1926 |
|
1927 return KErrNotFound; |
|
1928 } |
|
1929 |
|
1930 // ----------------------------------------------------------------------------- |
|
1931 // CAknFepCtrlMultiModeButton::GetRangeListL() |
|
1932 // (other items were commented in a header). |
|
1933 // ----------------------------------------------------------------------------- |
|
1934 // |
|
1935 void CAknFepCtrlMultiModeButton::GetRangeListL(RArray<TInt>& aList) |
|
1936 { |
|
1937 for (TInt i = 0; i < NumberOfModes(); i++) |
|
1938 { |
|
1939 if (aList.Find(iModesList[i]->iRangeId) == KErrNotFound) |
|
1940 { |
|
1941 aList.AppendL(iModesList[i]->iRangeId); |
|
1942 } |
|
1943 } |
|
1944 } |
|
1945 |
|
1946 // ----------------------------------------------------------------------------- |
|
1947 // CAknFepCtrlMultiModeButton::DuplicateBitmapL |
|
1948 // (other items were commented in a header). |
|
1949 // ----------------------------------------------------------------------------- |
|
1950 // |
|
1951 CFbsBitmap* CAknFepCtrlMultiModeButton::DuplicateBitmapL(CFbsBitmap* aSourceBmp) |
|
1952 { |
|
1953 CFbsBitmap* bmp = new (ELeave) CFbsBitmap; |
|
1954 CleanupStack::PushL( bmp ); |
|
1955 |
|
1956 User::LeaveIfError(bmp->Duplicate(aSourceBmp->Handle())); |
|
1957 |
|
1958 CleanupStack::Pop( bmp ); |
|
1959 //iOwnedBitmaps.InsertInAddressOrder(bmp); |
|
1960 return bmp; |
|
1961 } |
|
1962 |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // CAknFepCtrlMultiModeButton::ResizeBitmaps |
|
1965 // (other items were commented in a header). |
|
1966 // ----------------------------------------------------------------------------- |
|
1967 // |
|
1968 void CAknFepCtrlMultiModeButton::ResizeBitmaps(TSize aSize) |
|
1969 { |
|
1970 if(iForegroundBmpList.Count() >= 1 && iForegroundBmpList[0]->SizeInPixels() != aSize |
|
1971 || iForegroundMaskBmpList.Count() >= 1 && iForegroundMaskBmpList[0]->SizeInPixels() != aSize) |
|
1972 { |
|
1973 for (TInt i=0; i<iForegroundBmpList.Count(); i++) |
|
1974 { |
|
1975 AknIconUtils::SetSize(iForegroundBmpList[i], aSize, EAspectRatioNotPreserved); |
|
1976 } |
|
1977 for (TInt i=0; i<iForegroundMaskBmpList.Count(); i++) |
|
1978 { |
|
1979 AknIconUtils::SetSize(iForegroundMaskBmpList[i], aSize, EAspectRatioNotPreserved); |
|
1980 } |
|
1981 } |
|
1982 } |
|
1983 |
|
1984 // ----------------------------------------------------------------------------- |
|
1985 // CAknFepCtrlMultiModeButton::SizeChanged |
|
1986 // (other items were commented in a header). |
|
1987 // ----------------------------------------------------------------------------- |
|
1988 // |
|
1989 EXPORT_C void CAknFepCtrlMultiModeButton::SizeChanged(TRect aRect, TRect aInnerRect, |
|
1990 TBool aIsReloadImages) |
|
1991 { |
|
1992 if (aRect.Size().iWidth == 0 || aRect.Size().iHeight == 0) |
|
1993 { |
|
1994 return; |
|
1995 } |
|
1996 SetRect(aRect); |
|
1997 |
|
1998 iForgroundBmpRect = aInnerRect; |
|
1999 |
|
2000 if (aIsReloadImages) |
|
2001 { |
|
2002 ResizeBitmaps(aInnerRect.Size()); |
|
2003 } |
|
2004 |
|
2005 TRAP_IGNORE(SetButtonBmpL(iCurrentBmpType, iCurrentMode)); |
|
2006 |
|
2007 CAknFepCtrlCommonButton::SizeChanged(aRect,aInnerRect,aIsReloadImages); |
|
2008 /* |
|
2009 Draw(); |
|
2010 UpdateArea(Rect(), ETrue); |
|
2011 */ |
|
2012 } |
|
2013 |
|
2014 // ----------------------------------------------------------------------------- |
|
2015 // CAknFepCtrlMultiModeButton::TransferOwnership |
|
2016 // (other items were commented in a header). |
|
2017 // ----------------------------------------------------------------------------- |
|
2018 // |
|
2019 void CAknFepCtrlMultiModeButton::TransferOwnership(CFbsBitmap* aRemoved) |
|
2020 { |
|
2021 /* |
|
2022 TInt index = iOwnedBitmaps.FindInAddressOrder(aRemoved); |
|
2023 if( index != KErrNotFound ) |
|
2024 { |
|
2025 iOwnedBitmaps.Remove(index); |
|
2026 } |
|
2027 */ |
|
2028 } |
|
2029 |
|
2030 // ----------------------------------------------------------------------------- |
|
2031 // CAknFepCtrlEventButton::NewL |
|
2032 // (other items were commented in a header). |
|
2033 // ----------------------------------------------------------------------------- |
|
2034 // |
|
2035 EXPORT_C CAknFepCtrlEventButton* CAknFepCtrlEventButton::NewL(CFepUiLayout* aUiLayout, |
|
2036 TInt aControlId, |
|
2037 TInt aEvent, |
|
2038 TInt aUnicode, |
|
2039 TAknsItemID aNormalID, |
|
2040 TAknsItemID aPressedID, |
|
2041 TAknsItemID aInactiveID) |
|
2042 { |
|
2043 CAknFepCtrlEventButton* self = NewLC(aUiLayout, aControlId, aEvent, aUnicode, |
|
2044 aNormalID, aPressedID, aInactiveID); |
|
2045 CleanupStack::Pop(self); |
|
2046 |
|
2047 return self; |
|
2048 } |
|
2049 |
|
2050 // ----------------------------------------------------------------------------- |
|
2051 // CAknFepCtrlEventButton::NewLC |
|
2052 // (other items were commented in a header). |
|
2053 // ----------------------------------------------------------------------------- |
|
2054 // |
|
2055 EXPORT_C CAknFepCtrlEventButton* CAknFepCtrlEventButton::NewLC(CFepUiLayout* aUiLayout, |
|
2056 TInt aControlId, |
|
2057 TInt aEvent, |
|
2058 TInt aUnicode, |
|
2059 TAknsItemID aNormalID, |
|
2060 TAknsItemID aPressedID, |
|
2061 TAknsItemID aInactiveID) |
|
2062 { |
|
2063 CAknFepCtrlEventButton* self = new (ELeave) CAknFepCtrlEventButton(aUiLayout, |
|
2064 aControlId, |
|
2065 aEvent, |
|
2066 aUnicode, |
|
2067 aNormalID, |
|
2068 aPressedID, |
|
2069 aInactiveID); |
|
2070 CleanupStack::PushL(self); |
|
2071 self->BaseConstructL(); |
|
2072 |
|
2073 return self; |
|
2074 } |
|
2075 |
|
2076 // ----------------------------------------------------------------------------- |
|
2077 // CAknFepCtrlEventButton::CAknFepCtrlEventButton |
|
2078 // (other items were commented in a header). |
|
2079 // ----------------------------------------------------------------------------- |
|
2080 // |
|
2081 EXPORT_C CAknFepCtrlEventButton::CAknFepCtrlEventButton(CFepUiLayout* aUiLayout, |
|
2082 TInt aControlId, |
|
2083 TInt aEvent, |
|
2084 TInt aUnicode, |
|
2085 TAknsItemID aNormalID, |
|
2086 TAknsItemID aPressedID, |
|
2087 TAknsItemID aInactiveID) |
|
2088 : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID), |
|
2089 iEvent(aEvent),iUnicode(aUnicode),iText(NULL) |
|
2090 { |
|
2091 } |
|
2092 |
|
2093 // ----------------------------------------------------------------------------- |
|
2094 // CAknFepCtrlEventButton::~CAknFepCtrlEventButton |
|
2095 // (other items were commented in a header). |
|
2096 // ----------------------------------------------------------------------------- |
|
2097 // |
|
2098 EXPORT_C CAknFepCtrlEventButton::~CAknFepCtrlEventButton() |
|
2099 { |
|
2100 delete iText; |
|
2101 } |
|
2102 |
|
2103 // ----------------------------------------------------------------------------- |
|
2104 // CAknFepCtrlEventButton::HandlePointerUpEventL |
|
2105 // (other items were commented in a header). |
|
2106 // ----------------------------------------------------------------------------- |
|
2107 // |
|
2108 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlEventButton::HandlePointerUpEventL(const TPoint& aPoint) |
|
2109 { |
|
2110 if (iEvent == 0xFFFF) |
|
2111 { |
|
2112 return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint); |
|
2113 } |
|
2114 else |
|
2115 { |
|
2116 CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint); |
|
2117 if(IsDimmed()) |
|
2118 { |
|
2119 return NULL; |
|
2120 } |
|
2121 |
|
2122 if(IsActive()) |
|
2123 { |
|
2124 SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse)); |
|
2125 SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue)); |
|
2126 } |
|
2127 else |
|
2128 { |
|
2129 SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse)); |
|
2130 SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue)); |
|
2131 } |
|
2132 |
|
2133 SetActive(ETrue); |
|
2134 Draw(); |
|
2135 UpdateArea(Rect(),EFalse); |
|
2136 |
|
2137 TPtrC ptr = (TUint16*)(&iUnicode); |
|
2138 ReportEvent(iEvent,ptr); |
|
2139 |
|
2140 return this; |
|
2141 } |
|
2142 } |
|
2143 |
|
2144 // ----------------------------------------------------------------------------- |
|
2145 // CAknFepCtrlEventButton::DisplayText |
|
2146 // (other items were commented in a header). |
|
2147 // ----------------------------------------------------------------------------- |
|
2148 // |
|
2149 EXPORT_C void CAknFepCtrlEventButton::DisplayText() |
|
2150 { |
|
2151 if ((iFont) && (iShadowFont)) |
|
2152 { |
|
2153 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
2154 |
|
2155 gc->Activate(BitmapDevice()); |
|
2156 |
|
2157 // draw shadow text |
|
2158 gc->UseFont(iShadowFont); |
|
2159 |
|
2160 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
2161 gc->SetBrushColor( KRgbBlack);//Non transparent at all |
|
2162 gc->SetPenColor(iShadowFontColor); |
|
2163 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
2164 gc->SetPenSize( PenSize()); |
|
2165 |
|
2166 TPoint pointText; |
|
2167 TPoint pointShadowText; |
|
2168 |
|
2169 TInt leftMarginOfText = (Rect().Width() - iFont->TextWidthInPixels(*iText))/2; |
|
2170 |
|
2171 pointText.iX = Rect().iTl.iX + leftMarginOfText; |
|
2172 pointText.iY = Rect().iTl.iY + Rect().Height()*3/4; |
|
2173 |
|
2174 pointShadowText.iX = pointText.iX + 1; |
|
2175 pointShadowText.iY = pointText.iY + 1; |
|
2176 |
|
2177 gc->DrawText(*iText, pointShadowText); |
|
2178 |
|
2179 gc->DiscardFont(); |
|
2180 |
|
2181 // draw text |
|
2182 gc->UseFont(iFont); |
|
2183 |
|
2184 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
2185 gc->SetBrushColor( KRgbBlack);//Non transparent at all |
|
2186 gc->SetPenColor(iFontColor); |
|
2187 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
2188 gc->SetPenSize( PenSize()); |
|
2189 |
|
2190 gc->DrawText(*iText, pointText); |
|
2191 |
|
2192 gc->DiscardFont(); |
|
2193 } |
|
2194 } |
|
2195 |
|
2196 // ----------------------------------------------------------------------------- |
|
2197 // CAknFepCtrlEventButton::SetFontColor |
|
2198 // (other items were commented in a header). |
|
2199 // ----------------------------------------------------------------------------- |
|
2200 // |
|
2201 EXPORT_C void CAknFepCtrlEventButton::SetFontColor(const TRgb aColor) |
|
2202 { |
|
2203 iFontColor = aColor; |
|
2204 } |
|
2205 |
|
2206 // ----------------------------------------------------------------------------- |
|
2207 // CAknFepCtrlEventButton::SetShadowFontColor |
|
2208 // (other items were commented in a header). |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // |
|
2211 EXPORT_C void CAknFepCtrlEventButton::SetShadowFontColor(const TRgb aColor) |
|
2212 { |
|
2213 iShadowFontColor = aColor; |
|
2214 } |
|
2215 |
|
2216 |
|
2217 // ----------------------------------------------------------------------------- |
|
2218 // CAknFepCtrlEventButton::Draw |
|
2219 // (other items were commented in a header). |
|
2220 // ----------------------------------------------------------------------------- |
|
2221 // |
|
2222 EXPORT_C void CAknFepCtrlEventButton::Draw() |
|
2223 { |
|
2224 if(!AbleToDraw()) |
|
2225 return; |
|
2226 |
|
2227 CAknFepCtrlCommonButton::Draw(); |
|
2228 |
|
2229 if ( iText && (iText->Length() > 0 ) ) |
|
2230 { |
|
2231 DisplayText(); |
|
2232 } |
|
2233 } |
|
2234 |
|
2235 // ----------------------------------------------------------------------------- |
|
2236 // CAknFepCtrlEventButton::SetText |
|
2237 // (other items were commented in a header). |
|
2238 // ----------------------------------------------------------------------------- |
|
2239 // |
|
2240 EXPORT_C void CAknFepCtrlEventButton::SetText(const TDesC& aText) |
|
2241 { |
|
2242 if ( iText ) |
|
2243 { |
|
2244 delete iText; |
|
2245 iText = NULL; |
|
2246 } |
|
2247 TRAPD(err, iText = aText.AllocL()); |
|
2248 if (err != KErrNone) |
|
2249 { |
|
2250 iText = NULL; |
|
2251 } |
|
2252 Draw(); |
|
2253 } |
|
2254 |
|
2255 // ----------------------------------------------------------------------------- |
|
2256 // CAknFepCtrlEventButton::SetFont |
|
2257 // (other items were commented in a header). |
|
2258 // ----------------------------------------------------------------------------- |
|
2259 // |
|
2260 EXPORT_C void CAknFepCtrlEventButton::SetFont(const CFont* aFont) |
|
2261 { |
|
2262 iFont = aFont; |
|
2263 } |
|
2264 |
|
2265 // ----------------------------------------------------------------------------- |
|
2266 // CAknFepCtrlEventButton::SetShadowFont |
|
2267 // (other items were commented in a header). |
|
2268 // ----------------------------------------------------------------------------- |
|
2269 // |
|
2270 EXPORT_C void CAknFepCtrlEventButton::SetShadowFont(const CFont* aFont) |
|
2271 { |
|
2272 iShadowFont = aFont; |
|
2273 } |
|
2274 |
|
2275 // ----------------------------------------------------------------------------- |
|
2276 // CAknFepCtrlEventButton::Event |
|
2277 // (other items were commented in a header). |
|
2278 // ----------------------------------------------------------------------------- |
|
2279 // |
|
2280 EXPORT_C TInt CAknFepCtrlEventButton::Event() const |
|
2281 { |
|
2282 return iEvent; |
|
2283 } |
|
2284 |
|
2285 // ----------------------------------------------------------------------------- |
|
2286 // CAknFepCtrlEventButton::Unicode |
|
2287 // (other items were commented in a header). |
|
2288 // ----------------------------------------------------------------------------- |
|
2289 // |
|
2290 EXPORT_C TInt CAknFepCtrlEventButton::Unicode() const |
|
2291 { |
|
2292 return iUnicode; |
|
2293 } |
|
2294 |
|
2295 // ----------------------------------------------------------------------------- |
|
2296 // CAknFepCtrlEventButton::SetEvent |
|
2297 // (other items were commented in a header). |
|
2298 // ----------------------------------------------------------------------------- |
|
2299 // |
|
2300 EXPORT_C void CAknFepCtrlEventButton::SetEvent(TInt aEvent) |
|
2301 { |
|
2302 iEvent = aEvent; |
|
2303 } |
|
2304 |
|
2305 // ----------------------------------------------------------------------------- |
|
2306 // CAknFepCtrlEventButton::SetUnicode |
|
2307 // (other items were commented in a header). |
|
2308 // ----------------------------------------------------------------------------- |
|
2309 // |
|
2310 EXPORT_C void CAknFepCtrlEventButton::SetUnicode(TInt aUnicode) |
|
2311 { |
|
2312 iUnicode = aUnicode; |
|
2313 } |
|
2314 |
|
2315 // --------------------------------------------------------- |
|
2316 // Constructor |
|
2317 // --------------------------------------------------------- |
|
2318 // |
|
2319 EXPORT_C CAknFepCtrlRepeatButton* CAknFepCtrlRepeatButton::NewLC(CFepUiLayout* aUiLayout, |
|
2320 TInt aCtrlId, |
|
2321 TInt aEvent, |
|
2322 TInt aUnicode, |
|
2323 TAknsItemID aNormalID, |
|
2324 TAknsItemID aPressedID, |
|
2325 TAknsItemID aInactiveID) |
|
2326 { |
|
2327 //PRINTF((_L("CAknFepCtrlRepeatButton::NewLC(), aCtrlId = %d\n"), aCtrlId)); |
|
2328 CAknFepCtrlRepeatButton *self = new(ELeave) CAknFepCtrlRepeatButton(aUiLayout, |
|
2329 aCtrlId, |
|
2330 aEvent, |
|
2331 aUnicode, |
|
2332 aNormalID, |
|
2333 aPressedID, |
|
2334 aInactiveID); |
|
2335 |
|
2336 CleanupStack::PushL(self); |
|
2337 self->ConstructL(); |
|
2338 |
|
2339 return self; |
|
2340 } |
|
2341 |
|
2342 // --------------------------------------------------------- |
|
2343 // Constructor |
|
2344 // --------------------------------------------------------- |
|
2345 // |
|
2346 EXPORT_C CAknFepCtrlRepeatButton* CAknFepCtrlRepeatButton::NewL(CFepUiLayout* aUiLayout, |
|
2347 TInt aCtrlId, |
|
2348 TInt aEvent, |
|
2349 TInt aUnicode, |
|
2350 TAknsItemID aNormalID, |
|
2351 TAknsItemID aPressedID, |
|
2352 TAknsItemID aInactiveID) |
|
2353 { |
|
2354 //PRINTF((_L("CAknFepCtrlRepeatButton::NewL(), aCtrlId = %d\n"), aCtrlId)); |
|
2355 CAknFepCtrlRepeatButton *self = NewLC(aUiLayout, aCtrlId, aEvent, aUnicode, |
|
2356 aNormalID, aPressedID, aInactiveID); |
|
2357 CleanupStack::Pop(self); |
|
2358 |
|
2359 return self; |
|
2360 } |
|
2361 |
|
2362 // --------------------------------------------------------- |
|
2363 // Destructor |
|
2364 // --------------------------------------------------------- |
|
2365 // |
|
2366 EXPORT_C CAknFepCtrlRepeatButton::~CAknFepCtrlRepeatButton() |
|
2367 { |
|
2368 //PRINTF((_L("CAknFepCtrlRepeatButton::~CAknFepCtrlRepeatButton()\n"))); |
|
2369 CancelRepeat(); |
|
2370 |
|
2371 delete iLongPressTimer; |
|
2372 delete iRepeatTimer; |
|
2373 } |
|
2374 |
|
2375 // --------------------------------------------------------- |
|
2376 // Constructor |
|
2377 // --------------------------------------------------------- |
|
2378 // |
|
2379 EXPORT_C CAknFepCtrlRepeatButton::CAknFepCtrlRepeatButton(CFepUiLayout* aUiLayout, |
|
2380 TInt aCtrlId, |
|
2381 TInt aEvent, |
|
2382 TInt aUnicode, |
|
2383 TAknsItemID aNormalID, |
|
2384 TAknsItemID aPressedID, |
|
2385 TAknsItemID aInactiveID) |
|
2386 :CAknFepCtrlEventButton(aUiLayout, aCtrlId, aEvent, aUnicode, |
|
2387 aNormalID, |
|
2388 aPressedID, |
|
2389 aInactiveID) |
|
2390 { |
|
2391 iLongPressInterval = KLongPressInterval; |
|
2392 iRepeatInterval = KRepeatInterval; |
|
2393 } |
|
2394 |
|
2395 // --------------------------------------------------------- |
|
2396 // Constructor |
|
2397 // --------------------------------------------------------- |
|
2398 // |
|
2399 EXPORT_C void CAknFepCtrlRepeatButton::ConstructL() |
|
2400 { |
|
2401 //PRINTF((_L("CAknFepCtrlRepeatButton::ConstructL()\n"))); |
|
2402 BaseConstructL(); |
|
2403 |
|
2404 iLongPressTimer = CAknFepTimer::NewL(this); |
|
2405 iRepeatTimer = CAknFepTimer::NewL(this); |
|
2406 } |
|
2407 |
|
2408 // --------------------------------------------------------- |
|
2409 // Time out event handler of both long press timer & repeat timer |
|
2410 // --------------------------------------------------------- |
|
2411 // |
|
2412 EXPORT_C void CAknFepCtrlRepeatButton::HandleTimerOut(const CAknFepTimer* aTimer) |
|
2413 { |
|
2414 //PRINTF((_L("CAknFepCtrlRepeatButton::HandleTimerOut()--"))); |
|
2415 if (aTimer == iLongPressTimer) |
|
2416 { |
|
2417 //PRINTF((_L("long press timer timeout\n"))); |
|
2418 iRepeatTimer->SetTimer(iRepeatInterval); |
|
2419 } |
|
2420 else |
|
2421 { |
|
2422 if (aTimer == iRepeatTimer) |
|
2423 { |
|
2424 //PRINTF((_L("repeat timer timeout: EEventButtonUp reported\n"))); |
|
2425 if ( Unicode() ) |
|
2426 { |
|
2427 TInt unicode = Unicode(); |
|
2428 TPtrC ptr = (TUint16*)(&unicode ) ; |
|
2429 ReportEvent(Event(),ptr); |
|
2430 #ifdef RD_TACTILE_FEEDBACK |
|
2431 if (UiLayout()->SupportTactileFeedback()) |
|
2432 { |
|
2433 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad); |
|
2434 } |
|
2435 #endif //RD_TACTILE_FEEDBACK |
|
2436 } |
|
2437 else |
|
2438 { |
|
2439 ReportEvent(EEventButtonUp); |
|
2440 } |
|
2441 iRepeatTimer->SetTimer(iRepeatInterval); |
|
2442 } |
|
2443 } |
|
2444 } |
|
2445 |
|
2446 // --------------------------------------------------------- |
|
2447 // Handle button down start long press timer |
|
2448 // --------------------------------------------------------- |
|
2449 // |
|
2450 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerDownEventL(const TPoint& aPt) |
|
2451 { |
|
2452 //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonDown()\n"))); |
|
2453 |
|
2454 //PRINTF((_L("Set long press Timer\n"))); |
|
2455 iLongPressTimer->SetTimer(iLongPressInterval); |
|
2456 |
|
2457 return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt); |
|
2458 } |
|
2459 |
|
2460 // --------------------------------------------------------- |
|
2461 // Handle button up cancel timers |
|
2462 // --------------------------------------------------------- |
|
2463 // |
|
2464 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRepeatButton::HandlePointerUpEventL(const TPoint& aPt) |
|
2465 { |
|
2466 //PRINTF((_L("CAknFepCtrlRepeatButton::HandleButtonUp()\n"))); |
|
2467 |
|
2468 CancelRepeat(); |
|
2469 |
|
2470 return CAknFepCtrlEventButton::HandlePointerUpEventL(aPt); |
|
2471 } |
|
2472 |
|
2473 // --------------------------------------------------------- |
|
2474 // Handle pointer levae event cancel timers |
|
2475 // --------------------------------------------------------- |
|
2476 // |
|
2477 EXPORT_C void CAknFepCtrlRepeatButton::HandlePointerLeave(const TPoint& aPoint) |
|
2478 { |
|
2479 CAknFepCtrlCommonButton::HandlePointerLeave(aPoint); |
|
2480 |
|
2481 CancelRepeat(); |
|
2482 } |
|
2483 |
|
2484 // --------------------------------------------------------------------------- |
|
2485 // CAknFepCtrlRepeatButton::CancelPointerDownL |
|
2486 // Cancel pointer down event |
|
2487 // (other items were commented in a header). |
|
2488 // --------------------------------------------------------------------------- |
|
2489 // |
|
2490 EXPORT_C void CAknFepCtrlRepeatButton::CancelPointerDownL() |
|
2491 { |
|
2492 CAknFepCtrlCommonButton::CancelPointerDownL(); |
|
2493 |
|
2494 CancelRepeat(); |
|
2495 } |
|
2496 |
|
2497 // --------------------------------------------------------- |
|
2498 // Set the repeat interval of repeat timer |
|
2499 // --------------------------------------------------------- |
|
2500 // |
|
2501 EXPORT_C void CAknFepCtrlRepeatButton::SetRepeatInterval(const TTimeIntervalMicroSeconds32& aTime) |
|
2502 { |
|
2503 iRepeatInterval = aTime; |
|
2504 } |
|
2505 |
|
2506 // --------------------------------------------------------- |
|
2507 // Cancel timers |
|
2508 // --------------------------------------------------------- |
|
2509 // |
|
2510 EXPORT_C void CAknFepCtrlRepeatButton::CancelRepeat() |
|
2511 { |
|
2512 //PRINTF((_L("CAknFepCtrlRepeatButton::CancelRepeat()\n"))); |
|
2513 iLongPressTimer->Cancel(); |
|
2514 iRepeatTimer->Cancel(); |
|
2515 } |
|
2516 |
|
2517 EXPORT_C CAknFepCtrlRawKeyButton* CAknFepCtrlRawKeyButton::NewL(CFepUiLayout* aUiLayout, |
|
2518 TInt aControlId, |
|
2519 TAknsItemID aNormalID, |
|
2520 TAknsItemID aPressedID, |
|
2521 TAknsItemID aInactiveID, |
|
2522 TInt aDownEvent, |
|
2523 TInt aUpEvent, |
|
2524 TInt aScanCode) |
|
2525 { |
|
2526 CAknFepCtrlRawKeyButton* self = NewLC(aUiLayout, |
|
2527 aControlId, |
|
2528 aNormalID, |
|
2529 aPressedID, |
|
2530 aInactiveID, |
|
2531 aDownEvent, |
|
2532 aUpEvent, |
|
2533 aScanCode); |
|
2534 CleanupStack::Pop(self); |
|
2535 |
|
2536 return self; |
|
2537 } |
|
2538 |
|
2539 EXPORT_C CAknFepCtrlRawKeyButton* CAknFepCtrlRawKeyButton::NewLC(CFepUiLayout* aUiLayout, |
|
2540 TInt aControlId, |
|
2541 TAknsItemID aNormalID, |
|
2542 TAknsItemID aPressedID, |
|
2543 TAknsItemID aInactiveID, |
|
2544 TInt aDownEvent, |
|
2545 TInt aUpEvent, |
|
2546 TInt aScanCode) |
|
2547 { |
|
2548 CAknFepCtrlRawKeyButton* self = new (ELeave) CAknFepCtrlRawKeyButton(aUiLayout, |
|
2549 aControlId, |
|
2550 aNormalID, |
|
2551 aPressedID, |
|
2552 aInactiveID, |
|
2553 aDownEvent, |
|
2554 aUpEvent, |
|
2555 aScanCode); |
|
2556 CleanupStack::PushL(self); |
|
2557 self->BaseConstructL(); |
|
2558 return self; |
|
2559 } |
|
2560 |
|
2561 EXPORT_C CAknFepCtrlRawKeyButton::CAknFepCtrlRawKeyButton(CFepUiLayout* aUiLayout, |
|
2562 TInt aControlId, |
|
2563 TAknsItemID aNormalID, |
|
2564 TAknsItemID aPressedID, |
|
2565 TAknsItemID aInactiveID, |
|
2566 TInt aDownEvent, |
|
2567 TInt aUpEvent, |
|
2568 TInt aScanCode) |
|
2569 : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID), |
|
2570 iDownEvent(aDownEvent), |
|
2571 iUpEvent(aUpEvent), |
|
2572 iScanCode(aScanCode), |
|
2573 iLastPntDownEvent(EFalse) |
|
2574 { |
|
2575 } |
|
2576 |
|
2577 EXPORT_C CAknFepCtrlRawKeyButton::~CAknFepCtrlRawKeyButton() |
|
2578 { |
|
2579 } |
|
2580 |
|
2581 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRawKeyButton::HandlePointerDownEventL(const TPoint& aPoint) |
|
2582 { |
|
2583 /* if (iDownEvent == KInvalidEventId) |
|
2584 { |
|
2585 return CButtonBase::HandlePointerDownEventL(aPoint); |
|
2586 } |
|
2587 |
|
2588 if(IsDimmed()) |
|
2589 { |
|
2590 return NULL; |
|
2591 } |
|
2592 |
|
2593 CAknFepCtrlButton::HandlePointerDownEventL(aPoint); |
|
2594 if(IsActive()) |
|
2595 { |
|
2596 SetBackgroundBmp(iActiveBmpPressed); |
|
2597 SetBackgroundMaskBmp(iActiveMaskBmpPressed); |
|
2598 } |
|
2599 else |
|
2600 { |
|
2601 SetBackgroundBmp(iNonActiveBkBmpPressed); |
|
2602 SetBackgroundMaskBmp(iNonActiveBkMaskBmpPressed); |
|
2603 } |
|
2604 |
|
2605 Draw(); |
|
2606 UpdateArea(Rect(),ETrue); |
|
2607 */ |
|
2608 if(IsDimmed()) |
|
2609 { |
|
2610 return NULL; |
|
2611 } |
|
2612 |
|
2613 CAknFepCtrlCommonButton::HandlePointerDownEventL(aPoint); |
|
2614 TKeyEvent event= {0,0,0,0}; |
|
2615 TPtrC eventDataPtr; |
|
2616 event.iScanCode = iScanCode; |
|
2617 eventDataPtr.Set(reinterpret_cast<TUint16*>(&event),sizeof(event)); |
|
2618 |
|
2619 ReportEvent(iDownEvent,eventDataPtr); |
|
2620 |
|
2621 iLastPntDownEvent = ETrue; |
|
2622 |
|
2623 return this; |
|
2624 } |
|
2625 |
|
2626 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlRawKeyButton::HandlePointerUpEventL(const TPoint& aPoint) |
|
2627 { |
|
2628 if (iUpEvent == KInvalidEventId) |
|
2629 { |
|
2630 return CButtonBase::HandlePointerUpEventL(aPoint); |
|
2631 } |
|
2632 |
|
2633 /* if(IsDimmed()) |
|
2634 { |
|
2635 return NULL; |
|
2636 } |
|
2637 |
|
2638 if(IsActive()) |
|
2639 { |
|
2640 SetBackgroundBmp(Bitmap(EBtnBmpActive,EFalse)); |
|
2641 SetBackgroundMaskBmp(Bitmap(EBtnBmpActive,ETrue)); |
|
2642 } |
|
2643 else |
|
2644 { |
|
2645 SetBackgroundBmp(Bitmap(EBtnBmpNonActive,EFalse)); |
|
2646 SetBackgroundMaskBmp(Bitmap(EBtnBmpNonActive,ETrue)); |
|
2647 } |
|
2648 |
|
2649 SetActive(ETrue); |
|
2650 Draw(); |
|
2651 UpdateArea(Rect(),ETrue); |
|
2652 */ |
|
2653 if(IsDimmed()) |
|
2654 { |
|
2655 return NULL; |
|
2656 } |
|
2657 |
|
2658 CAknFepCtrlCommonButton::HandlePointerUpEventL(aPoint); |
|
2659 if (iLastPntDownEvent) |
|
2660 { |
|
2661 // only when last event is pointer down event, there is need to simulate |
|
2662 // pointer up event |
|
2663 TKeyEvent event= {0,0,0,0}; |
|
2664 TPtrC eventDataPtr; |
|
2665 event.iScanCode = iScanCode; |
|
2666 eventDataPtr.Set(reinterpret_cast<TUint16*>(&event),sizeof(event)); |
|
2667 |
|
2668 ReportEvent(iUpEvent,eventDataPtr); |
|
2669 |
|
2670 iLastPntDownEvent = EFalse; |
|
2671 } |
|
2672 |
|
2673 return this; |
|
2674 } |
|
2675 |
|
2676 EXPORT_C void CAknFepCtrlRawKeyButton::ConstructFromResourceL(TResourceReader& aReader) |
|
2677 { |
|
2678 TInt scancode = aReader.ReadInt16(); |
|
2679 SetScanCode(scancode); |
|
2680 |
|
2681 TInt32 btnimgResId = aReader.ReadInt32(); |
|
2682 TResourceReader imgreader; |
|
2683 CCoeEnv::Static()->CreateResourceReaderLC(imgreader, btnimgResId); |
|
2684 CAknFepCtrlCommonButton::ConstructFromResourceL(imgreader); |
|
2685 CleanupStack::PopAndDestroy(); // imgreader |
|
2686 |
|
2687 //ResizeBitmaps(Rect().Size()); |
|
2688 iFirstTimeConstruct = EFalse; |
|
2689 } |
|
2690 |
|
2691 EXPORT_C void CAknFepCtrlRawKeyButton::ConstructFromResourceL() |
|
2692 { |
|
2693 if (iResourceId == KInvalidResId) |
|
2694 { |
|
2695 return; |
|
2696 } |
|
2697 |
|
2698 TResourceReader reader; |
|
2699 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
2700 |
|
2701 TInt scancode = reader.ReadInt16(); |
|
2702 SetScanCode(scancode); |
|
2703 |
|
2704 TInt32 btnimgResId = reader.ReadInt32(); |
|
2705 TResourceReader imgreader; |
|
2706 CCoeEnv::Static()->CreateResourceReaderLC(imgreader, btnimgResId); |
|
2707 CAknFepCtrlCommonButton::ConstructFromResourceL(imgreader); |
|
2708 CleanupStack::PopAndDestroy(2); // reader, imgreader |
|
2709 |
|
2710 //ResizeBitmaps(Rect().Size()); |
|
2711 iFirstTimeConstruct = EFalse; |
|
2712 } |
|
2713 |
|
2714 EXPORT_C void CAknFepCtrlRawKeyButton::HandlePointerLeave(const TPoint& aPoint) |
|
2715 { |
|
2716 if (!Rect().Contains(aPoint)) |
|
2717 { |
|
2718 TRAP_IGNORE(HandlePointerUpEventL(Rect().Center())); |
|
2719 } |
|
2720 } |
|
2721 |
|
2722 EXPORT_C void CAknFepCtrlRawKeyButton::OnDeActivate() |
|
2723 { |
|
2724 CButtonBase::OnDeActivate(); |
|
2725 |
|
2726 if (iLastPntDownEvent) |
|
2727 { |
|
2728 TRAP_IGNORE(HandlePointerUpEventL(Rect().Center())); |
|
2729 } |
|
2730 } |
|
2731 |
|
2732 // --------------------------------------------------------------------------- |
|
2733 // CAknFepCtrlCommonButton::CAknFepCtrlCommonButton |
|
2734 // C++ default constructor can NOT contain any code, that |
|
2735 // might leave. |
|
2736 // (other items were commented in a header). |
|
2737 // --------------------------------------------------------------------------- |
|
2738 // |
|
2739 EXPORT_C CAknFepCtrlCommonButton::CAknFepCtrlCommonButton(CFepUiLayout* aUiLayout, |
|
2740 TInt aControlId, |
|
2741 TAknsItemID aNormalID, |
|
2742 TAknsItemID aPressedID, |
|
2743 TAknsItemID aInactiveID) |
|
2744 : CButtonBase(TRect(), aUiLayout, aControlId), |
|
2745 iFirstTimeConstruct(ETrue), |
|
2746 iHighlight(EFalse), |
|
2747 iPressed(EFalse), |
|
2748 iTextColorIndex( KInvalidColorGroup ) |
|
2749 { |
|
2750 iNormalImgID = aNormalID; |
|
2751 iPressedImgID = aPressedID; |
|
2752 iInactiveImgID = aInactiveID; |
|
2753 CFepUiBaseCtrl::SetActive( ETrue ); |
|
2754 } |
|
2755 |
|
2756 // --------------------------------------------------------------------------- |
|
2757 // CAknFepCtrlCommonButton::NewL |
|
2758 // Two-phased constructor. |
|
2759 // (other items were commented in a header). |
|
2760 // --------------------------------------------------------------------------- |
|
2761 // |
|
2762 EXPORT_C CAknFepCtrlCommonButton* CAknFepCtrlCommonButton::NewL(CFepUiLayout* aUiLayout, |
|
2763 TInt aControlId, |
|
2764 TAknsItemID aNormalID, |
|
2765 TAknsItemID aPressedID, |
|
2766 TAknsItemID aInactiveID) |
|
2767 { |
|
2768 CAknFepCtrlCommonButton* self = NewLC(aUiLayout, |
|
2769 aControlId, |
|
2770 aNormalID, |
|
2771 aPressedID, |
|
2772 aInactiveID); |
|
2773 CleanupStack::Pop(self); |
|
2774 |
|
2775 return self; |
|
2776 } |
|
2777 // --------------------------------------------------------------------------- |
|
2778 // CAknFepCtrlCommonButton::NewLC |
|
2779 // Two-phased constructor. |
|
2780 // (other items were commented in a header). |
|
2781 // --------------------------------------------------------------------------- |
|
2782 // |
|
2783 EXPORT_C CAknFepCtrlCommonButton* CAknFepCtrlCommonButton::NewLC(CFepUiLayout* aUiLayout, |
|
2784 TInt aControlId, |
|
2785 TAknsItemID aNormalID, |
|
2786 TAknsItemID aPressedID, |
|
2787 TAknsItemID aInactiveID) |
|
2788 { |
|
2789 CAknFepCtrlCommonButton* self = new (ELeave) CAknFepCtrlCommonButton(aUiLayout, |
|
2790 aControlId, |
|
2791 aNormalID, |
|
2792 aPressedID, |
|
2793 aInactiveID); |
|
2794 CleanupStack::PushL(self); |
|
2795 self->BaseConstructL(); |
|
2796 |
|
2797 return self; |
|
2798 } |
|
2799 |
|
2800 // ----------------------------------------------------------------------------- |
|
2801 // Destructor. |
|
2802 // (other items were commented in a header). |
|
2803 // ----------------------------------------------------------------------------- |
|
2804 // |
|
2805 EXPORT_C CAknFepCtrlCommonButton::~CAknFepCtrlCommonButton() |
|
2806 { |
|
2807 DeleteForgroundRes(); |
|
2808 delete iColorIcons; |
|
2809 delete iText; |
|
2810 } |
|
2811 // --------------------------------------------------------------------------- |
|
2812 // CAknFepCtrlCommonButton::ConstructFromResourceL |
|
2813 // The order of the image ids in the CButtonBase class must not be changed |
|
2814 // (other items were commented in a header). |
|
2815 // --------------------------------------------------------------------------- |
|
2816 // |
|
2817 EXPORT_C void CAknFepCtrlCommonButton::ConstructFromResourceL(TResourceReader& aReader) |
|
2818 { |
|
2819 if (!iFirstTimeConstruct) |
|
2820 { |
|
2821 DeleteForgroundRes(); |
|
2822 if( iColorIcons ) |
|
2823 iColorIcons->ReConstructL(); |
|
2824 } |
|
2825 |
|
2826 TPtrC bmpFileName = aReader.ReadTPtrC(); // Read the file name of the bmps |
|
2827 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
2828 TInt colorGroup = aReader.ReadInt16(); |
|
2829 TAknsItemID id; |
|
2830 |
|
2831 // Get the image ids and mask ids from resource |
|
2832 TInt bmpId = aReader.ReadInt16(); |
|
2833 TInt bmpMskId = aReader.ReadInt16(); |
|
2834 |
|
2835 // read skin item id |
|
2836 const TInt skinitemid = aReader.ReadInt16(); |
|
2837 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
2838 |
|
2839 if (bmpId != KInvalidBmp) |
|
2840 { |
|
2841 if (bmpMskId != KInvalidBmp) |
|
2842 { |
|
2843 if( colorGroup == KInvalidColorGroup ) |
|
2844 { |
|
2845 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
2846 id, |
|
2847 iForgroundBmp, |
|
2848 iForgroundBmpMask, |
|
2849 bmpFileName, |
|
2850 bmpId, |
|
2851 bmpMskId); |
|
2852 } |
|
2853 else |
|
2854 { |
|
2855 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
2856 id, |
|
2857 KAknsIIDQsnIconColors, |
|
2858 colorGroup, |
|
2859 iForgroundBmp, |
|
2860 iForgroundBmpMask, |
|
2861 bmpFileName, |
|
2862 bmpId, |
|
2863 bmpMskId, |
|
2864 AKN_LAF_COLOR( 0 ) ); |
|
2865 } |
|
2866 |
|
2867 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
2868 AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), |
|
2869 EAspectRatioNotPreserved); |
|
2870 |
|
2871 /*CreateDimmedMaskL( iForgroundDimBmpMask, iForgroundBmpMask ); |
|
2872 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), |
|
2873 EAspectRatioNotPreserved);*/ |
|
2874 } |
|
2875 else |
|
2876 { |
|
2877 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
2878 id, |
|
2879 iForgroundBmp, |
|
2880 bmpFileName, |
|
2881 bmpId); |
|
2882 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
2883 } |
|
2884 } |
|
2885 |
|
2886 if (!iFirstTimeConstruct) |
|
2887 { |
|
2888 //ResizeBitmaps(iForgroundBmpRect.Size()); |
|
2889 Draw(); |
|
2890 } |
|
2891 |
|
2892 iFirstTimeConstruct = EFalse; |
|
2893 } |
|
2894 |
|
2895 // --------------------------------------------------------------------------- |
|
2896 // CAknFepCtrlCommonButton::ConstructFromResourceL |
|
2897 // (other items were commented in a header). |
|
2898 // --------------------------------------------------------------------------- |
|
2899 // |
|
2900 EXPORT_C void CAknFepCtrlCommonButton::ConstructFromResourceL() |
|
2901 { |
|
2902 if (iResourceId == KInvalidResId) |
|
2903 { |
|
2904 return; |
|
2905 } |
|
2906 |
|
2907 if (!iFirstTimeConstruct) |
|
2908 { |
|
2909 // need to remove original bmp and maskbmp |
|
2910 DeleteForgroundRes(); |
|
2911 if( iColorIcons ) |
|
2912 iColorIcons->ReConstructL(); |
|
2913 } |
|
2914 |
|
2915 TResourceReader reader; |
|
2916 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
2917 |
|
2918 TPtrC bmpFileName = reader.ReadTPtrC(); // Read the file name of the bmps |
|
2919 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
2920 TInt colorGroup = reader.ReadInt16(); |
|
2921 TAknsItemID id; |
|
2922 |
|
2923 // Get the image ids and mask ids from resource |
|
2924 TInt bmpId = reader.ReadInt16(); |
|
2925 TInt bmpMskId = reader.ReadInt16(); |
|
2926 |
|
2927 // Read skin item id |
|
2928 const TInt skinitemid = reader.ReadInt16(); |
|
2929 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
2930 |
|
2931 if (bmpId != KInvalidBmp) |
|
2932 { |
|
2933 if (bmpMskId != KInvalidBmp) |
|
2934 { |
|
2935 if( colorGroup == KInvalidColorGroup ) |
|
2936 { |
|
2937 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
2938 id, |
|
2939 iForgroundBmp, |
|
2940 iForgroundBmpMask, |
|
2941 bmpFileName, |
|
2942 bmpId, |
|
2943 bmpMskId); |
|
2944 } |
|
2945 else |
|
2946 { |
|
2947 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
2948 id, |
|
2949 KAknsIIDQsnIconColors, |
|
2950 colorGroup, |
|
2951 iForgroundBmp, |
|
2952 iForgroundBmpMask, |
|
2953 bmpFileName, |
|
2954 bmpId, |
|
2955 bmpMskId, |
|
2956 AKN_LAF_COLOR( 0 ) ); |
|
2957 } |
|
2958 |
|
2959 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
2960 AknIconUtils::SetSize(iForgroundBmpMask, iForgroundBmpRect.Size(), |
|
2961 EAspectRatioNotPreserved); |
|
2962 |
|
2963 /*CreateDimmedMaskL( iForgroundDimBmpMask, |
|
2964 iForgroundBmpMask ); |
|
2965 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), EAspectRatioNotPreserved);*/ |
|
2966 } |
|
2967 else |
|
2968 { |
|
2969 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
2970 id, |
|
2971 iForgroundBmp, |
|
2972 bmpFileName, |
|
2973 bmpId); |
|
2974 AknIconUtils::SetSize(iForgroundBmp, iForgroundBmpRect.Size(), EAspectRatioNotPreserved); |
|
2975 } |
|
2976 } |
|
2977 |
|
2978 CleanupStack::PopAndDestroy(); // reader |
|
2979 |
|
2980 if (!iFirstTimeConstruct) |
|
2981 { |
|
2982 //ResizeBitmaps(iForgroundBmpRect.Size()); |
|
2983 Draw(); |
|
2984 } |
|
2985 |
|
2986 iFirstTimeConstruct = EFalse; |
|
2987 } |
|
2988 |
|
2989 // --------------------------------------------------------------------------- |
|
2990 // CAknFepCtrlCommonButton::Draw |
|
2991 // Draws UI |
|
2992 // (other items were commented in a header). |
|
2993 // --------------------------------------------------------------------------- |
|
2994 // |
|
2995 EXPORT_C void CAknFepCtrlCommonButton::Draw() |
|
2996 { |
|
2997 if(!AbleToDraw()) |
|
2998 return; |
|
2999 |
|
3000 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
3001 |
|
3002 //mask bitmaps |
|
3003 DrawOpaqueMaskBackground(); |
|
3004 TRect rect = Rect(); |
|
3005 TRect innerRect = rect; |
|
3006 innerRect.Shrink( 10, 10 ); |
|
3007 |
|
3008 // ----- draw bitmaps ----- |
|
3009 gc->Activate( BitmapDevice() ); |
|
3010 // gc->SetClippingRegion( &ValidClipRegion() ); |
|
3011 //gc->Clear(rect); |
|
3012 |
|
3013 CFbsBitmap* bmpMask = NULL; |
|
3014 |
|
3015 // Draw background |
|
3016 if( IsDimmed() ) // Dimmed state |
|
3017 { |
|
3018 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
3019 *gc, |
|
3020 rect, |
|
3021 innerRect, |
|
3022 iInactiveImgID, |
|
3023 KAknsIIDDefault ); |
|
3024 if( iForgroundDimBmpMask ) |
|
3025 { |
|
3026 delete iForgroundDimBmpMask; |
|
3027 iForgroundDimBmpMask = NULL; |
|
3028 } |
|
3029 TRAP_IGNORE(CreateDimmedMaskL( iForgroundDimBmpMask, |
|
3030 iForgroundBmpMask )); |
|
3031 AknIconUtils::SetSize(iForgroundDimBmpMask, iForgroundBmpRect.Size(), |
|
3032 EAspectRatioNotPreserved); |
|
3033 |
|
3034 bmpMask = iForgroundDimBmpMask; |
|
3035 } |
|
3036 else |
|
3037 { |
|
3038 // Normal state or pressed state |
|
3039 TAknsItemID ImgID; |
|
3040 if (iHighlight) |
|
3041 { |
|
3042 ImgID = iPressedImgID; |
|
3043 } |
|
3044 else |
|
3045 { |
|
3046 ImgID = /*iPressed*/PointerDown()? iPressedImgID : iNormalImgID; |
|
3047 } |
|
3048 |
|
3049 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
3050 *gc, |
|
3051 rect, |
|
3052 innerRect, |
|
3053 ImgID, |
|
3054 KAknsIIDDefault ); |
|
3055 bmpMask = iForgroundBmpMask; |
|
3056 } |
|
3057 |
|
3058 // Draw forground |
|
3059 if ( iColorIcons ) // 3-pieces color icon |
|
3060 { |
|
3061 AknPenInputDrawUtils::Draw3PiecesColorIcon( iColorIcons, |
|
3062 *gc, |
|
3063 iForgroundBmpRect, |
|
3064 iDraw3PiecesInfo.iInnerRect ); |
|
3065 } |
|
3066 else if( iForgroundBmp ) |
|
3067 { |
|
3068 TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() ); |
|
3069 if( bmpMask ) |
|
3070 { |
|
3071 gc->BitBltMasked( iForgroundBmpRect.iTl, |
|
3072 iForgroundBmp, |
|
3073 srcRect, |
|
3074 bmpMask, |
|
3075 EFalse); |
|
3076 } |
|
3077 else |
|
3078 { |
|
3079 gc->BitBlt( iForgroundBmpRect.iTl, |
|
3080 iForgroundBmp, |
|
3081 srcRect ); |
|
3082 } |
|
3083 } |
|
3084 |
|
3085 if (iText) |
|
3086 { |
|
3087 //if( IsDimmed() ) |
|
3088 // { |
|
3089 // gc->SetFadingParameters( KFadingParamBlack, KFadingParamWhite ); |
|
3090 // gc->SetFaded( ETrue ); |
|
3091 // } |
|
3092 |
|
3093 TAknLayoutText textLayout; |
|
3094 textLayout.LayoutText(Rect(), iTextFormat); |
|
3095 if( iTextColorIndex == KInvalidColorGroup ) |
|
3096 textLayout.DrawText(*gc, *iText); |
|
3097 else |
|
3098 { |
|
3099 TRgb color( KRgbBlack ); // sane default for nonskinned case |
|
3100 if ( AknsUtils::AvkonSkinEnabled() ) |
|
3101 { |
|
3102 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
3103 color, KAknsIIDQsnTextColors, iTextColorIndex ); |
|
3104 } |
|
3105 if( IsDimmed() ) |
|
3106 { |
|
3107 color = KRgbGray; |
|
3108 } |
|
3109 textLayout.DrawText(*gc, *iText, ETrue, color); |
|
3110 } |
|
3111 //if( IsDimmed() ) |
|
3112 // gc->SetFaded( EFalse ); |
|
3113 } |
|
3114 } |
|
3115 |
|
3116 // --------------------------------------------------------------------------- |
|
3117 // CAknFepCtrlCommonButton::SetActive |
|
3118 // Set active for the button |
|
3119 // (other items were commented in a header). |
|
3120 // --------------------------------------------------------------------------- |
|
3121 // |
|
3122 EXPORT_C void CAknFepCtrlCommonButton::SetActive(TBool aActiveFlag) |
|
3123 { |
|
3124 if( IsDimmed() ) |
|
3125 { |
|
3126 return; |
|
3127 } |
|
3128 |
|
3129 if(IsActive() != aActiveFlag) |
|
3130 { |
|
3131 CFepUiBaseCtrl::SetActive(aActiveFlag); |
|
3132 /* if(BitGc()) |
|
3133 { |
|
3134 Draw(); |
|
3135 UpdateArea(Rect(),EFalse); |
|
3136 }*/ |
|
3137 } |
|
3138 } |
|
3139 |
|
3140 // --------------------------------------------------------------------------- |
|
3141 // CAknFepCtrlCommonButton::SetHighlight |
|
3142 // Set highlight for the button |
|
3143 // (other items were commented in a header). |
|
3144 // --------------------------------------------------------------------------- |
|
3145 // |
|
3146 EXPORT_C void CAknFepCtrlCommonButton::SetHighlight(TBool aIsHighlight) |
|
3147 { |
|
3148 iHighlight = aIsHighlight; |
|
3149 |
|
3150 Draw(); |
|
3151 UpdateArea(Rect(),EFalse); |
|
3152 } |
|
3153 |
|
3154 // --------------------------------------------------------------------------- |
|
3155 // CAknFepCtrlCommonButton::ResizeBitmaps |
|
3156 // This methods shall be called by the container's SizeChanged handler |
|
3157 // (other items were commented in a header). |
|
3158 // --------------------------------------------------------------------------- |
|
3159 // |
|
3160 void CAknFepCtrlCommonButton::ResizeBitmaps(TSize aInnerSize) |
|
3161 { |
|
3162 if( iForgroundBmp && ( iForgroundBmp->SizeInPixels() != aInnerSize ) ) |
|
3163 { |
|
3164 AknIconUtils::SetSize( iForgroundBmp, aInnerSize, EAspectRatioNotPreserved ); |
|
3165 } |
|
3166 if( iForgroundBmpMask && ( iForgroundBmpMask->SizeInPixels() != aInnerSize ) ) |
|
3167 { |
|
3168 AknIconUtils::SetSize( iForgroundBmpMask, aInnerSize, EAspectRatioNotPreserved ); |
|
3169 } |
|
3170 |
|
3171 /*TRAP_IGNORE(CreateDimmedMaskL(iForgroundDimBmpMask, |
|
3172 iForgroundBmpMask));*/ |
|
3173 } |
|
3174 |
|
3175 // --------------------------------------------------------------------------- |
|
3176 // CAknFepCtrlCommonButton::SizeChanged |
|
3177 // This methods shall be called by the container's SizeChanged handler |
|
3178 // (other items were commented in a header). |
|
3179 // --------------------------------------------------------------------------- |
|
3180 // |
|
3181 EXPORT_C void CAknFepCtrlCommonButton::SizeChanged(TRect aNewRect, |
|
3182 TRect aInnerRect, |
|
3183 TBool aIsReloadImages) |
|
3184 { |
|
3185 if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) |
|
3186 { |
|
3187 return; |
|
3188 } |
|
3189 |
|
3190 TRect oriRect = Rect(); |
|
3191 |
|
3192 if( oriRect == aNewRect && iForgroundBmpRect == aInnerRect ) |
|
3193 { |
|
3194 return; |
|
3195 } |
|
3196 |
|
3197 SetRect(aNewRect); |
|
3198 |
|
3199 if (aIsReloadImages) |
|
3200 { |
|
3201 iForgroundBmpRect = aInnerRect; |
|
3202 ResizeBitmaps(aInnerRect.Size() ); |
|
3203 } |
|
3204 RootControl()->ReDrawRect( Rect() ); |
|
3205 UpdateArea(Rect(), EFalse); |
|
3206 Draw(); |
|
3207 UpdateArea(Rect(), EFalse); |
|
3208 } |
|
3209 |
|
3210 // --------------------------------------------------------------------------- |
|
3211 // CAknFepCtrlCommonButton::SetForgroundBmpRect |
|
3212 // This methods shall be called by the container's SizeChanged handler |
|
3213 // (other items were commented in a header). |
|
3214 // --------------------------------------------------------------------------- |
|
3215 // |
|
3216 EXPORT_C void CAknFepCtrlCommonButton::SetForgroundBmpRect(const TRect& aRect) |
|
3217 { |
|
3218 iForgroundBmpRect = aRect; |
|
3219 } |
|
3220 |
|
3221 EXPORT_C void CAknFepCtrlCommonButton::SetDraw3PieceFrameInfo(TDraw3PiecesFrame a3PiecesFrameInfo) |
|
3222 { |
|
3223 iDraw3PiecesInfo = a3PiecesFrameInfo; |
|
3224 } |
|
3225 |
|
3226 // --------------------------------------------------------------------------- |
|
3227 // CAknFepCtrlCommonButton::DeleteForgroundRes |
|
3228 // This methods shall be called by the container's SizeChanged handler |
|
3229 // (other items were commented in a header). |
|
3230 // --------------------------------------------------------------------------- |
|
3231 // |
|
3232 void CAknFepCtrlCommonButton::DeleteForgroundRes() |
|
3233 { |
|
3234 if( iForgroundBmp ) |
|
3235 { |
|
3236 delete iForgroundBmp; |
|
3237 iForgroundBmp = NULL; |
|
3238 } |
|
3239 if( iForgroundBmpMask ) |
|
3240 { |
|
3241 delete iForgroundBmpMask; |
|
3242 iForgroundBmpMask = NULL; |
|
3243 } |
|
3244 if( iForgroundDimBmpMask ) |
|
3245 { |
|
3246 delete iForgroundDimBmpMask; |
|
3247 iForgroundDimBmpMask = NULL; |
|
3248 } |
|
3249 } |
|
3250 |
|
3251 // --------------------------------------------------------------------------- |
|
3252 // CAknFepCtrlCommonButton::CreateDimmedMaskL |
|
3253 // This methods shall be called by the container's SizeChanged handler |
|
3254 // (other items were commented in a header). |
|
3255 // --------------------------------------------------------------------------- |
|
3256 // |
|
3257 void CAknFepCtrlCommonButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask, |
|
3258 const CFbsBitmap* aMask |
|
3259 /*TScaleMode aScaleMode*/ ) |
|
3260 { |
|
3261 if (aMask && aMask->DisplayMode() == EGray256) |
|
3262 { |
|
3263 delete aDimmedMask; |
|
3264 aDimmedMask = NULL; |
|
3265 |
|
3266 aDimmedMask = new (ELeave) CFbsBitmap; |
|
3267 |
|
3268 User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); |
|
3269 CleanupStack::PushL(aDimmedMask); |
|
3270 |
|
3271 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask); |
|
3272 CleanupStack::PushL(bitmapDevice); |
|
3273 |
|
3274 CFbsBitGc* bitGc(NULL); |
|
3275 User::LeaveIfError(bitmapDevice->CreateContext(bitGc)); |
|
3276 CleanupStack::PushL(bitGc); |
|
3277 |
|
3278 bitGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
3279 bitGc->BitBlt(TPoint(0, 0), aMask); |
|
3280 |
|
3281 aDimmedMask->LockHeap(); |
|
3282 TInt w = aMask->SizeInPixels().iWidth; |
|
3283 TInt h = aMask->SizeInPixels().iHeight; |
|
3284 TInt dataStride = aMask->DataStride() - w; |
|
3285 unsigned char* address = (unsigned char *)aDimmedMask->DataAddress(); |
|
3286 |
|
3287 for ( TInt i = 0; i < h; ++i ) |
|
3288 { |
|
3289 for ( TInt j = 0; j < w; ++j ) |
|
3290 { |
|
3291 *address = KTransparency[*address]; |
|
3292 ++address; |
|
3293 } |
|
3294 address += dataStride; |
|
3295 } |
|
3296 |
|
3297 aDimmedMask->UnlockHeap(); |
|
3298 |
|
3299 //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode); |
|
3300 |
|
3301 CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc |
|
3302 CleanupStack::Pop(1); // aDimmedMask |
|
3303 } |
|
3304 |
|
3305 } |
|
3306 |
|
3307 // --------------------------------------------------------------------------- |
|
3308 // CAknFepCtrlCommonButton::HandlePointerDownEventL |
|
3309 // Handle button down event |
|
3310 // (other items were commented in a header). |
|
3311 // --------------------------------------------------------------------------- |
|
3312 // |
|
3313 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlCommonButton::HandlePointerDownEventL(const TPoint& aPt) |
|
3314 { |
|
3315 if( IsDimmed() ) |
|
3316 return NULL; |
|
3317 |
|
3318 CFepUiBaseCtrl::HandlePointerDownEventL(aPt); |
|
3319 iPressed = ETrue; |
|
3320 |
|
3321 Draw(); |
|
3322 UpdateArea(Rect(),EFalse); |
|
3323 ReportEvent(EEventButtonDown); |
|
3324 return this; |
|
3325 } |
|
3326 |
|
3327 // --------------------------------------------------------------------------- |
|
3328 // CAknFepCtrlCommonButton::HandlePointerLeave |
|
3329 // Handle pointer leave event |
|
3330 // --------------------------------------------------------------------------- |
|
3331 // |
|
3332 EXPORT_C void CAknFepCtrlCommonButton::HandlePointerLeave(const TPoint& aPt) |
|
3333 { |
|
3334 if( IsDimmed() ) |
|
3335 return; |
|
3336 |
|
3337 CFepUiBaseCtrl::HandlePointerLeave(aPt); |
|
3338 iPressed = EFalse; |
|
3339 |
|
3340 RootControl()->ReDrawRect( Rect() ); |
|
3341 UpdateArea(Rect(),EFalse); |
|
3342 |
|
3343 return ; |
|
3344 } |
|
3345 |
|
3346 // --------------------------------------------------------------------------- |
|
3347 // CAknFepCtrlCommonButton::HandleButtonUpEventL |
|
3348 // Handle button up event |
|
3349 // (other items were commented in a header). |
|
3350 // --------------------------------------------------------------------------- |
|
3351 // |
|
3352 EXPORT_C CFepUiBaseCtrl* CAknFepCtrlCommonButton::HandlePointerUpEventL(const TPoint& aPt) |
|
3353 { |
|
3354 CFepUiBaseCtrl::HandlePointerUpEventL(aPt); |
|
3355 if( IsDimmed() ) |
|
3356 return NULL; |
|
3357 |
|
3358 iPressed = EFalse; |
|
3359 SetActive(ETrue); |
|
3360 RootControl()->ReDrawRect( Rect() ); |
|
3361 //Draw(); |
|
3362 UpdateArea(Rect(),EFalse); |
|
3363 |
|
3364 ReportEvent(EEventButtonUp); |
|
3365 |
|
3366 #ifdef RD_TACTILE_FEEDBACK |
|
3367 { |
|
3368 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse); |
|
3369 } |
|
3370 #endif // RD_TACTILE_FEEDBACK |
|
3371 |
|
3372 return this; |
|
3373 } |
|
3374 |
|
3375 EXPORT_C void CAknFepCtrlCommonButton::HandlePointerEnter(const TPoint& aPt) |
|
3376 { |
|
3377 if( IsDimmed() ) |
|
3378 return; |
|
3379 |
|
3380 CFepUiBaseCtrl::HandlePointerEnter(aPt); |
|
3381 iPressed = ETrue; |
|
3382 Draw(); |
|
3383 UpdateArea(Rect(),EFalse); |
|
3384 |
|
3385 return ; |
|
3386 } |
|
3387 |
|
3388 // --------------------------------------------------------------------------- |
|
3389 // CAknFepCtrlCommonButton::CancelPointerDownL |
|
3390 // (other items were commented in a header). |
|
3391 // --------------------------------------------------------------------------- |
|
3392 // |
|
3393 EXPORT_C void CAknFepCtrlCommonButton::CancelPointerDownL() |
|
3394 { |
|
3395 CFepUiBaseCtrl::CancelPointerDownL(); |
|
3396 } |
|
3397 |
|
3398 // --------------------------------------------------------------------------- |
|
3399 // CAknFepCtrlCommonButton::SetForegroundBmpL |
|
3400 // (other items were commented in a header). |
|
3401 // --------------------------------------------------------------------------- |
|
3402 // |
|
3403 EXPORT_C void CAknFepCtrlCommonButton::SetForegroundBmpL(CFbsBitmap* aBmp, |
|
3404 CFbsBitmap* aMaskBmp) |
|
3405 { |
|
3406 DeleteForgroundRes(); |
|
3407 |
|
3408 iForgroundBmp = aBmp; |
|
3409 iForgroundBmpMask = aMaskBmp; |
|
3410 |
|
3411 ResizeBitmaps(iForgroundBmpRect.Size()); |
|
3412 } |
|
3413 |
|
3414 EXPORT_C void CAknFepCtrlCommonButton::Move(const TPoint& aOffset) |
|
3415 { |
|
3416 CButtonBase::Move(aOffset); |
|
3417 iForgroundBmpRect.Move( aOffset ); |
|
3418 |
|
3419 if ( iColorIcons ) |
|
3420 { |
|
3421 iDraw3PiecesInfo.iInnerRect.Move( aOffset ); |
|
3422 } |
|
3423 } |
|
3424 |
|
3425 |
|
3426 |
|
3427 // --------------------------------------------------------------------------- |
|
3428 // CAknFepCtrlMultiImageButton::CAknFepCtrlMultiImageButton |
|
3429 // C++ default constructor can NOT contain any code, that |
|
3430 // might leave. |
|
3431 // (other items were commented in a header). |
|
3432 // --------------------------------------------------------------------------- |
|
3433 // |
|
3434 EXPORT_C CAknFepCtrlMultiImageButton::CAknFepCtrlMultiImageButton(CFepUiLayout* aUiLayout, |
|
3435 TInt aControlId, |
|
3436 TAknsItemID aNormalID, |
|
3437 TAknsItemID aPressedID, |
|
3438 TAknsItemID aInactiveID) |
|
3439 : CAknFepCtrlCommonButton(aUiLayout, aControlId, aNormalID, aPressedID, aInactiveID) |
|
3440 { |
|
3441 iNormalImgID = aNormalID; |
|
3442 iPressedImgID = aPressedID; |
|
3443 iInactiveImgID = aInactiveID; |
|
3444 } |
|
3445 |
|
3446 // --------------------------------------------------------------------------- |
|
3447 // CAknFepCtrlMultiImageButton::NewL |
|
3448 // Two-phased constructor. |
|
3449 // (other items were commented in a header). |
|
3450 // --------------------------------------------------------------------------- |
|
3451 // |
|
3452 EXPORT_C CAknFepCtrlMultiImageButton* CAknFepCtrlMultiImageButton::NewL(CFepUiLayout* aUiLayout, |
|
3453 TInt aControlId, |
|
3454 TAknsItemID aNormalID, |
|
3455 TAknsItemID aPressedID, |
|
3456 TAknsItemID aInactiveID) |
|
3457 { |
|
3458 CAknFepCtrlMultiImageButton* self = NewLC(aUiLayout, |
|
3459 aControlId, |
|
3460 aNormalID, |
|
3461 aPressedID, |
|
3462 aInactiveID); |
|
3463 CleanupStack::Pop(self); |
|
3464 |
|
3465 return self; |
|
3466 } |
|
3467 // --------------------------------------------------------------------------- |
|
3468 // CAknFepCtrlMultiImageButton::NewLC |
|
3469 // Two-phased constructor. |
|
3470 // (other items were commented in a header). |
|
3471 // --------------------------------------------------------------------------- |
|
3472 // |
|
3473 EXPORT_C CAknFepCtrlMultiImageButton* CAknFepCtrlMultiImageButton::NewLC(CFepUiLayout* aUiLayout, |
|
3474 TInt aControlId, |
|
3475 TAknsItemID aNormalID, |
|
3476 TAknsItemID aPressedID, |
|
3477 TAknsItemID aInactiveID) |
|
3478 { |
|
3479 CAknFepCtrlMultiImageButton* self = new (ELeave) CAknFepCtrlMultiImageButton(aUiLayout, |
|
3480 aControlId, |
|
3481 aNormalID, |
|
3482 aPressedID, |
|
3483 aInactiveID); |
|
3484 CleanupStack::PushL(self); |
|
3485 self->BaseConstructL(); |
|
3486 |
|
3487 return self; |
|
3488 } |
|
3489 |
|
3490 // ----------------------------------------------------------------------------- |
|
3491 // Destructor. |
|
3492 // (other items were commented in a header). |
|
3493 // ----------------------------------------------------------------------------- |
|
3494 // |
|
3495 EXPORT_C CAknFepCtrlMultiImageButton::~CAknFepCtrlMultiImageButton() |
|
3496 { |
|
3497 DeleteForgroundRes(); |
|
3498 delete iText; |
|
3499 } |
|
3500 // --------------------------------------------------------------------------- |
|
3501 // CAknFepCtrlMultiImageButton::ConstructFromResourceL |
|
3502 // The order of the image ids in the CButtonBase class must not be changed |
|
3503 // (other items were commented in a header). |
|
3504 // --------------------------------------------------------------------------- |
|
3505 // |
|
3506 EXPORT_C void CAknFepCtrlMultiImageButton::ConstructFromResourceL(TResourceReader& aReader) |
|
3507 { |
|
3508 if (!iFirstTimeConstruct) |
|
3509 { |
|
3510 DeleteForgroundRes(); |
|
3511 } |
|
3512 |
|
3513 TPtrC bmpFileName = aReader.ReadTPtrC(); // Read the file name of the bmps |
|
3514 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
3515 TInt colorGroup = aReader.ReadInt16(); |
|
3516 TAknsItemID id; |
|
3517 |
|
3518 // Get the image ids and mask ids from resource |
|
3519 TInt bmpId = aReader.ReadInt16(); |
|
3520 TInt bmpMskId = aReader.ReadInt16(); |
|
3521 |
|
3522 // read skin item id |
|
3523 const TInt skinitemid = aReader.ReadInt16(); |
|
3524 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
3525 |
|
3526 if (bmpId != KInvalidBmp) |
|
3527 { |
|
3528 if (bmpMskId != KInvalidBmp) |
|
3529 { |
|
3530 if( colorGroup == KInvalidColorGroup ) |
|
3531 { |
|
3532 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3533 id, |
|
3534 iForground1Bmp, |
|
3535 iForground1BmpMask, |
|
3536 bmpFileName, |
|
3537 bmpId, |
|
3538 bmpMskId); |
|
3539 } |
|
3540 else |
|
3541 { |
|
3542 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
3543 id, |
|
3544 KAknsIIDQsnIconColors, |
|
3545 colorGroup, |
|
3546 iForground1Bmp, |
|
3547 iForground1BmpMask, |
|
3548 bmpFileName, |
|
3549 bmpId, |
|
3550 bmpMskId, |
|
3551 AKN_LAF_COLOR( 0 ) ); |
|
3552 } |
|
3553 |
|
3554 AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved); |
|
3555 AknIconUtils::SetSize(iForground1BmpMask, iForground1BmpRect.Size(), |
|
3556 EAspectRatioNotPreserved); |
|
3557 |
|
3558 /*CreateDimmedMaskL( iForground1DimBmpMask, iForground1BmpMask ); |
|
3559 AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), |
|
3560 EAspectRatioNotPreserved);*/ |
|
3561 } |
|
3562 else |
|
3563 { |
|
3564 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3565 id, |
|
3566 iForground1Bmp, |
|
3567 bmpFileName, |
|
3568 bmpId); |
|
3569 AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved); |
|
3570 } |
|
3571 } |
|
3572 |
|
3573 |
|
3574 |
|
3575 TAknsItemID id2; |
|
3576 |
|
3577 // Get the image ids and mask ids from resource |
|
3578 TInt bmp2Id = aReader.ReadInt16(); |
|
3579 TInt bmp2MskId = aReader.ReadInt16(); |
|
3580 |
|
3581 // read skin item id |
|
3582 const TInt skinitem2id = aReader.ReadInt16(); |
|
3583 id2.Set(TInt(imgMajorSkinId), skinitem2id); |
|
3584 |
|
3585 if (bmp2Id != KInvalidBmp) |
|
3586 { |
|
3587 if (bmp2MskId != KInvalidBmp) |
|
3588 { |
|
3589 if( colorGroup == KInvalidColorGroup ) |
|
3590 { |
|
3591 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3592 id2, |
|
3593 iForground2Bmp, |
|
3594 iForground2BmpMask, |
|
3595 bmpFileName, |
|
3596 bmp2Id, |
|
3597 bmp2MskId); |
|
3598 } |
|
3599 else |
|
3600 { |
|
3601 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
3602 id2, |
|
3603 KAknsIIDQsnIconColors, |
|
3604 colorGroup, |
|
3605 iForground2Bmp, |
|
3606 iForground2BmpMask, |
|
3607 bmpFileName, |
|
3608 bmp2Id, |
|
3609 bmp2MskId, |
|
3610 AKN_LAF_COLOR( 0 ) ); |
|
3611 } |
|
3612 |
|
3613 AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioNotPreserved); |
|
3614 AknIconUtils::SetSize(iForground2BmpMask, iForground2BmpRect.Size(), |
|
3615 EAspectRatioNotPreserved); |
|
3616 |
|
3617 /*CreateDimmedMaskL( iForground2DimBmpMask, iForground2BmpMask ); |
|
3618 AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), |
|
3619 EAspectRatioNotPreserved);*/ |
|
3620 } |
|
3621 else |
|
3622 { |
|
3623 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3624 id2, |
|
3625 iForground2Bmp, |
|
3626 bmpFileName, |
|
3627 bmp2Id); |
|
3628 AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioNotPreserved); |
|
3629 } |
|
3630 } |
|
3631 |
|
3632 if (!iFirstTimeConstruct) |
|
3633 { |
|
3634 Draw(); |
|
3635 } |
|
3636 |
|
3637 iFirstTimeConstruct = EFalse; |
|
3638 } |
|
3639 |
|
3640 // --------------------------------------------------------------------------- |
|
3641 // CAknFepCtrlMultiImageButton::ConstructFromResourceL |
|
3642 // (other items were commented in a header). |
|
3643 // --------------------------------------------------------------------------- |
|
3644 // |
|
3645 EXPORT_C void CAknFepCtrlMultiImageButton::ConstructFromResourceL() |
|
3646 { |
|
3647 if (iResourceId == KInvalidResId) |
|
3648 { |
|
3649 User::Leave(KErrArgument); |
|
3650 } |
|
3651 |
|
3652 if (!iFirstTimeConstruct) |
|
3653 { |
|
3654 // need to remove original bmp and maskbmp |
|
3655 DeleteForgroundRes(); |
|
3656 } |
|
3657 |
|
3658 TResourceReader reader; |
|
3659 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
3660 |
|
3661 TPtrC bmpFileName = reader.ReadTPtrC(); // Read the file name of the bmps |
|
3662 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
3663 TInt colorGroup = reader.ReadInt16(); |
|
3664 TAknsItemID id; |
|
3665 |
|
3666 // Get the image ids and mask ids from resource |
|
3667 TInt bmpId = reader.ReadInt16(); |
|
3668 TInt bmpMskId = reader.ReadInt16(); |
|
3669 |
|
3670 // Read skin item id |
|
3671 const TInt skinitemid = reader.ReadInt16(); |
|
3672 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
3673 |
|
3674 if (bmpId != KInvalidBmp) |
|
3675 { |
|
3676 if (bmpMskId != KInvalidBmp) |
|
3677 { |
|
3678 if( colorGroup == KInvalidColorGroup ) |
|
3679 { |
|
3680 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3681 id, |
|
3682 iForground1Bmp, |
|
3683 iForground1BmpMask, |
|
3684 bmpFileName, |
|
3685 bmpId, |
|
3686 bmpMskId); |
|
3687 } |
|
3688 else |
|
3689 { |
|
3690 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
3691 id, |
|
3692 KAknsIIDQsnIconColors, |
|
3693 colorGroup, |
|
3694 iForground1Bmp, |
|
3695 iForground1BmpMask, |
|
3696 bmpFileName, |
|
3697 bmpId, |
|
3698 bmpMskId, |
|
3699 AKN_LAF_COLOR( 0 ) ); |
|
3700 } |
|
3701 |
|
3702 AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved); |
|
3703 AknIconUtils::SetSize(iForground1BmpMask, iForground1BmpRect.Size(), EAspectRatioNotPreserved); |
|
3704 |
|
3705 /*CreateDimmedMaskL( iForground1DimBmpMask, |
|
3706 iForground1BmpMask ); |
|
3707 AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), EAspectRatioNotPreserved);*/ |
|
3708 } |
|
3709 else |
|
3710 { |
|
3711 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3712 id, |
|
3713 iForground1Bmp, |
|
3714 bmpFileName, |
|
3715 bmpId); |
|
3716 AknIconUtils::SetSize(iForground1Bmp, iForground1BmpRect.Size(), EAspectRatioNotPreserved); |
|
3717 } |
|
3718 } |
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 |
|
3730 |
|
3731 TAknsItemID id2; |
|
3732 |
|
3733 // Get the image ids and mask ids from resource |
|
3734 TInt bmp2Id = reader.ReadInt16(); |
|
3735 TInt bmp2MskId = reader.ReadInt16(); |
|
3736 |
|
3737 // Read skin item id |
|
3738 const TInt skinitem2id = reader.ReadInt16(); |
|
3739 id2.Set(TInt(imgMajorSkinId), skinitem2id); |
|
3740 |
|
3741 if (bmp2Id != KInvalidBmp) |
|
3742 { |
|
3743 if (bmp2MskId != KInvalidBmp) |
|
3744 { |
|
3745 if( colorGroup == KInvalidColorGroup ) |
|
3746 { |
|
3747 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3748 id2, |
|
3749 iForground2Bmp, |
|
3750 iForground2BmpMask, |
|
3751 bmpFileName, |
|
3752 bmp2Id, |
|
3753 bmp2MskId); |
|
3754 } |
|
3755 else |
|
3756 { |
|
3757 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
3758 id, |
|
3759 KAknsIIDQsnIconColors, |
|
3760 colorGroup, |
|
3761 iForground2Bmp, |
|
3762 iForground2BmpMask, |
|
3763 bmpFileName, |
|
3764 bmp2Id, |
|
3765 bmp2MskId, |
|
3766 AKN_LAF_COLOR( 0 ) ); |
|
3767 } |
|
3768 |
|
3769 AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioPreserved); |
|
3770 AknIconUtils::SetSize(iForground2BmpMask, iForground2BmpRect.Size(), EAspectRatioPreserved); |
|
3771 |
|
3772 /*CreateDimmedMaskL( iForground2DimBmpMask, iForground2BmpMask ); |
|
3773 AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), |
|
3774 EAspectRatioNotPreserved);*/ |
|
3775 } |
|
3776 else |
|
3777 { |
|
3778 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
3779 id, |
|
3780 iForground2Bmp, |
|
3781 bmpFileName, |
|
3782 bmp2Id); |
|
3783 AknIconUtils::SetSize(iForground2Bmp, iForground2BmpRect.Size(), EAspectRatioPreserved); |
|
3784 } |
|
3785 } |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 CleanupStack::PopAndDestroy(); // reader |
|
3793 |
|
3794 if (!iFirstTimeConstruct) |
|
3795 { |
|
3796 //ResizeBitmaps(iForgroundBmpRect.Size()); |
|
3797 Draw(); |
|
3798 } |
|
3799 |
|
3800 iFirstTimeConstruct = EFalse; |
|
3801 } |
|
3802 |
|
3803 // --------------------------------------------------------------------------- |
|
3804 // CAknFepCtrlMultiImageButton::Draw |
|
3805 // Draws UI |
|
3806 // (other items were commented in a header). |
|
3807 // --------------------------------------------------------------------------- |
|
3808 // |
|
3809 EXPORT_C void CAknFepCtrlMultiImageButton::Draw() |
|
3810 { |
|
3811 if(!AbleToDraw()) |
|
3812 return; |
|
3813 |
|
3814 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
3815 |
|
3816 //mask bitmaps |
|
3817 DrawOpaqueMaskBackground(); |
|
3818 TRect rect = Rect(); |
|
3819 TRect innerRect = rect; |
|
3820 innerRect.Shrink( 10, 10 ); |
|
3821 |
|
3822 // ----- draw bitmaps ----- |
|
3823 gc->Activate( BitmapDevice() ); |
|
3824 // gc->SetClippingRegion( &ValidClipRegion() ); |
|
3825 //gc->Clear(rect); |
|
3826 |
|
3827 CFbsBitmap* bmpMask1 = NULL; |
|
3828 CFbsBitmap* bmpMask2 = NULL; |
|
3829 |
|
3830 // Draw background |
|
3831 if( IsDimmed() ) // Dimmed state |
|
3832 { |
|
3833 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
3834 *gc, |
|
3835 rect, |
|
3836 innerRect, |
|
3837 iInactiveImgID, |
|
3838 KAknsIIDDefault ); |
|
3839 if( iForground1DimBmpMask ) |
|
3840 { |
|
3841 delete iForground1DimBmpMask; |
|
3842 iForground1DimBmpMask = NULL; |
|
3843 } |
|
3844 TRAP_IGNORE(CreateDimmedMaskL( iForground1DimBmpMask, |
|
3845 iForground1BmpMask )); |
|
3846 AknIconUtils::SetSize(iForground1DimBmpMask, iForground1BmpRect.Size(), |
|
3847 EAspectRatioNotPreserved); |
|
3848 bmpMask1 = iForground1DimBmpMask; |
|
3849 |
|
3850 if( iForground2DimBmpMask ) |
|
3851 { |
|
3852 delete iForground2DimBmpMask; |
|
3853 iForground2DimBmpMask = NULL; |
|
3854 } |
|
3855 TRAP_IGNORE(CreateDimmedMaskL( iForground2DimBmpMask, |
|
3856 iForground2BmpMask )); |
|
3857 AknIconUtils::SetSize(iForground2DimBmpMask, iForground2BmpRect.Size(), |
|
3858 EAspectRatioNotPreserved); |
|
3859 bmpMask2 = iForground2DimBmpMask; |
|
3860 } |
|
3861 else |
|
3862 { |
|
3863 // Normal state or pressed state |
|
3864 TAknsItemID ImgID; |
|
3865 if (iHighlight) |
|
3866 { |
|
3867 ImgID = iPressedImgID; |
|
3868 } |
|
3869 else |
|
3870 { |
|
3871 ImgID = /*iPressed*/PointerDown()? iPressedImgID : iNormalImgID; |
|
3872 } |
|
3873 |
|
3874 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
3875 *gc, |
|
3876 rect, |
|
3877 innerRect, |
|
3878 ImgID, |
|
3879 KAknsIIDDefault ); |
|
3880 bmpMask1 = iForground1BmpMask; |
|
3881 bmpMask2 = iForground2BmpMask; |
|
3882 } |
|
3883 |
|
3884 // Draw forground |
|
3885 if( iForground1Bmp && iForground2Bmp) |
|
3886 { |
|
3887 TRect srcRect( TPoint( 0, 0 ), iForground1Bmp->SizeInPixels() ); |
|
3888 if( bmpMask1 ) |
|
3889 { |
|
3890 gc->BitBltMasked( iForground1BmpRect.iTl, |
|
3891 iForground1Bmp, |
|
3892 srcRect, |
|
3893 bmpMask1, |
|
3894 EFalse); |
|
3895 } |
|
3896 else |
|
3897 { |
|
3898 gc->BitBlt( iForground1BmpRect.iTl, |
|
3899 iForground1Bmp, |
|
3900 srcRect ); |
|
3901 } |
|
3902 |
|
3903 TRect src2Rect( TPoint( 0, 0 ), iForground2Bmp->SizeInPixels() ); |
|
3904 if( bmpMask2 ) |
|
3905 { |
|
3906 gc->BitBltMasked( rect.iTl, //fix EVWG-7PKC6J. layout of 2nd foreground is determined by image itself, but not hard code. |
|
3907 iForground2Bmp, |
|
3908 src2Rect, |
|
3909 bmpMask2, |
|
3910 EFalse); |
|
3911 } |
|
3912 else |
|
3913 { |
|
3914 gc->BitBlt( rect.iTl, //fix EVWG-7PKC6J. |
|
3915 iForground2Bmp, |
|
3916 src2Rect ); |
|
3917 } |
|
3918 } |
|
3919 |
|
3920 if (iText) |
|
3921 { |
|
3922 TAknLayoutText textLayout; |
|
3923 textLayout.LayoutText(Rect(), iTextFormat); |
|
3924 textLayout.DrawText(*gc, *iText); |
|
3925 } |
|
3926 } |
|
3927 |
|
3928 // --------------------------------------------------------------------------- |
|
3929 // CAknFepCtrlMultiImageButton::ResizeBitmaps |
|
3930 // This methods shall be called by the container's SizeChanged handler |
|
3931 // (other items were commented in a header). |
|
3932 // --------------------------------------------------------------------------- |
|
3933 // |
|
3934 void CAknFepCtrlMultiImageButton::ResizeBitmaps(TSize aInnerSize) |
|
3935 { |
|
3936 if( iForground1Bmp && ( iForground1Bmp->SizeInPixels() != aInnerSize ) ) |
|
3937 { |
|
3938 AknIconUtils::SetSize( iForground1Bmp, aInnerSize, EAspectRatioNotPreserved ); |
|
3939 } |
|
3940 if( iForground1BmpMask && ( iForground1BmpMask->SizeInPixels() != aInnerSize ) ) |
|
3941 { |
|
3942 AknIconUtils::SetSize( iForground1BmpMask, aInnerSize, EAspectRatioNotPreserved ); |
|
3943 } |
|
3944 |
|
3945 //TRAP_IGNORE(CreateDimmedMaskL(iForground1DimBmpMask, iForground1BmpMask)); |
|
3946 |
|
3947 |
|
3948 |
|
3949 |
|
3950 if( iForground2Bmp && ( iForground2Bmp->SizeInPixels() != Rect().Size() ) ) |
|
3951 { |
|
3952 AknIconUtils::SetSize( iForground2Bmp, Rect().Size(), EAspectRatioNotPreserved ); |
|
3953 } |
|
3954 if( iForground2BmpMask && ( iForground2BmpMask->SizeInPixels() != Rect().Size() ) ) |
|
3955 { |
|
3956 AknIconUtils::SetSize( iForground2BmpMask, Rect().Size(), EAspectRatioNotPreserved ); |
|
3957 } |
|
3958 |
|
3959 //TRAP_IGNORE(CreateDimmedMaskL(iForground2DimBmpMask, iForground2BmpMask)); |
|
3960 } |
|
3961 |
|
3962 // --------------------------------------------------------------------------- |
|
3963 // CAknFepCtrlMultiImageButton::SizeChanged |
|
3964 // This methods shall be called by the container's SizeChanged handler |
|
3965 // (other items were commented in a header). |
|
3966 // --------------------------------------------------------------------------- |
|
3967 // |
|
3968 EXPORT_C void CAknFepCtrlMultiImageButton::SizeChanged(TRect aNewRect, |
|
3969 TRect aInnerRect, |
|
3970 TBool aIsReloadImages) |
|
3971 { |
|
3972 if (aNewRect.Size().iWidth == 0 || aNewRect.Size().iHeight == 0) |
|
3973 { |
|
3974 return; |
|
3975 } |
|
3976 |
|
3977 TRect oriRect = Rect(); |
|
3978 SetRect(aNewRect); |
|
3979 iForground1BmpRect = aInnerRect; |
|
3980 iForground2BmpRect = aInnerRect; |
|
3981 |
|
3982 if (aIsReloadImages) |
|
3983 { |
|
3984 ResizeBitmaps(aInnerRect.Size() ); |
|
3985 } |
|
3986 RootControl()->ReDrawRect( oriRect ); |
|
3987 UpdateArea(oriRect, EFalse); |
|
3988 Draw(); |
|
3989 UpdateArea(Rect(), EFalse); |
|
3990 } |
|
3991 |
|
3992 // --------------------------------------------------------------------------- |
|
3993 // CAknFepCtrlMultiImageButton::DeleteForgroundRes |
|
3994 // This methods shall be called by the container's SizeChanged handler |
|
3995 // (other items were commented in a header). |
|
3996 // --------------------------------------------------------------------------- |
|
3997 // |
|
3998 void CAknFepCtrlMultiImageButton::DeleteForgroundRes() |
|
3999 { |
|
4000 if( iForground1Bmp ) |
|
4001 { |
|
4002 delete iForground1Bmp; |
|
4003 iForground1Bmp = NULL; |
|
4004 } |
|
4005 if( iForground1BmpMask ) |
|
4006 { |
|
4007 delete iForground1BmpMask; |
|
4008 iForground1BmpMask = NULL; |
|
4009 } |
|
4010 if( iForground1DimBmpMask ) |
|
4011 { |
|
4012 delete iForground1DimBmpMask; |
|
4013 iForground1DimBmpMask = NULL; |
|
4014 } |
|
4015 |
|
4016 |
|
4017 if( iForground2Bmp ) |
|
4018 { |
|
4019 delete iForground2Bmp; |
|
4020 iForground2Bmp = NULL; |
|
4021 } |
|
4022 if( iForground2BmpMask ) |
|
4023 { |
|
4024 delete iForground2BmpMask; |
|
4025 iForground2BmpMask = NULL; |
|
4026 } |
|
4027 if( iForground2DimBmpMask ) |
|
4028 { |
|
4029 delete iForground2DimBmpMask; |
|
4030 iForground2DimBmpMask = NULL; |
|
4031 } |
|
4032 |
|
4033 } |
|
4034 |
|
4035 // --------------------------------------------------------------------------- |
|
4036 // CAknFepCtrlMultiImageButton::CreateDimmedMaskL |
|
4037 // This methods shall be called by the container's SizeChanged handler |
|
4038 // (other items were commented in a header). |
|
4039 // --------------------------------------------------------------------------- |
|
4040 // |
|
4041 void CAknFepCtrlMultiImageButton::CreateDimmedMaskL( CFbsBitmap*& aDimmedMask, |
|
4042 const CFbsBitmap* aMask |
|
4043 /*TScaleMode aScaleMode*/ ) |
|
4044 { |
|
4045 if (aMask && aMask->DisplayMode() == EGray256) |
|
4046 { |
|
4047 delete aDimmedMask; |
|
4048 aDimmedMask = NULL; |
|
4049 |
|
4050 aDimmedMask = new (ELeave) CFbsBitmap; |
|
4051 |
|
4052 User::LeaveIfError(aDimmedMask->Create(aMask->SizeInPixels(), EGray256)); |
|
4053 CleanupStack::PushL(aDimmedMask); |
|
4054 |
|
4055 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(aDimmedMask); |
|
4056 CleanupStack::PushL(bitmapDevice); |
|
4057 |
|
4058 CFbsBitGc* bitGc(NULL); |
|
4059 User::LeaveIfError(bitmapDevice->CreateContext(bitGc)); |
|
4060 CleanupStack::PushL(bitGc); |
|
4061 |
|
4062 bitGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
4063 bitGc->BitBlt(TPoint(0, 0), aMask); |
|
4064 |
|
4065 aDimmedMask->LockHeap(); |
|
4066 TInt w = aMask->SizeInPixels().iWidth; |
|
4067 TInt h = aMask->SizeInPixels().iHeight; |
|
4068 TInt dataStride = aMask->DataStride() - w; |
|
4069 unsigned char* address = (unsigned char *)aDimmedMask->DataAddress(); |
|
4070 |
|
4071 for ( TInt i = 0; i < h; ++i ) |
|
4072 { |
|
4073 for ( TInt j = 0; j < w; ++j ) |
|
4074 { |
|
4075 *address = KTransparency[*address]; |
|
4076 ++address; |
|
4077 } |
|
4078 address += dataStride; |
|
4079 } |
|
4080 |
|
4081 aDimmedMask->UnlockHeap(); |
|
4082 |
|
4083 //AknIconUtils::SetSize(aDimmedMask, aMask->SizeInPixels(), aScaleMode); |
|
4084 |
|
4085 CleanupStack::PopAndDestroy(2); // bitmapDevice, bitGc |
|
4086 CleanupStack::Pop(1); // aDimmedMask |
|
4087 } |
|
4088 |
|
4089 } |
|
4090 |
|
4091 EXPORT_C void CAknFepCtrlMultiImageButton::Move(const TPoint& aOffset) |
|
4092 { |
|
4093 CButtonBase::Move(aOffset); |
|
4094 iForground1BmpRect.Move( aOffset ); |
|
4095 iForground2BmpRect.Move( aOffset ); |
|
4096 } |
|
4097 |
|
4098 // End Of File |
|