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