|
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 <AknIconUtils.h> |
|
22 #include <coemain.h> |
|
23 #include <AknsUtils.h> |
|
24 |
|
25 // user includes |
|
26 #include "peninputvkbctrllayout.h" |
|
27 #include "peninputvkbctrlext.h" |
|
28 |
|
29 // constants |
|
30 const TInt KInvalidBmp = -1 ; |
|
31 |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CAknFepCtrlVkbLayout::CAknFepCtrlVkbLayout |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // (other items were commented in a header). |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 |
|
43 |
|
44 CAknFepCtrlVkbLayout::CAknFepCtrlVkbLayout() |
|
45 : iFirstTimeConstruct(ETrue), iResourceId( -1 ), iVkbLayoutId( -1 ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CAknFepCtrlVkbLayout::NewL |
|
51 // Two-phased constructor. |
|
52 // (other items were commented in a header). |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CAknFepCtrlVkbLayout* CAknFepCtrlVkbLayout::NewL() |
|
56 { |
|
57 CAknFepCtrlVkbLayout* self = NewLC(); |
|
58 CleanupStack::Pop(self); |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CAknFepCtrlVkbLayout::NewLC |
|
65 // Two-phased constructor. |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CAknFepCtrlVkbLayout* CAknFepCtrlVkbLayout::NewLC() |
|
70 { |
|
71 CAknFepCtrlVkbLayout* self = new (ELeave) CAknFepCtrlVkbLayout(); |
|
72 CleanupStack::PushL(self); |
|
73 self->ConstructL(); |
|
74 |
|
75 return self; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CAknFepCtrlVkbLayout::Reset |
|
80 // (other items were commented in a header). |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C void CAknFepCtrlVkbLayout::Reset() |
|
84 { |
|
85 iVkbLayoutId = -1; |
|
86 iFirstTimeConstruct = ETrue; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAknFepCtrlVkbLayout::ConstructL |
|
91 // Two-phased constructor. |
|
92 // (other items were commented in a header). |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CAknFepCtrlVkbLayout::ConstructL() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // Destructor. |
|
102 // (other items were commented in a header). |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C CAknFepCtrlVkbLayout::~CAknFepCtrlVkbLayout() |
|
106 { |
|
107 iVkbLayoutInfoList.ResetAndDestroy(); |
|
108 iVkbLayoutInfoList.Close(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CAknFepCtrlVkbLayout::SetVkbKeyboard |
|
113 // Two-phased constructor. |
|
114 // (other items were commented in a header). |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C void CAknFepCtrlVkbLayout::SetVkbKeyboard( |
|
118 CPeninputVkbCtrlExt* aVkbCtrl ) |
|
119 { |
|
120 iVkbCtrl = aVkbCtrl; |
|
121 } |
|
122 |
|
123 EXPORT_C void CAknFepCtrlVkbLayout::SetIrregularResourceId(TInt32 aResId) |
|
124 { |
|
125 iIrregularResId = aResId; |
|
126 } |
|
127 |
|
128 EXPORT_C void CAknFepCtrlVkbLayout::SetNonIrregularResourceId(TInt32 aResId) |
|
129 { |
|
130 iNonIrregularResId = aResId; |
|
131 } |
|
132 |
|
133 |
|
134 EXPORT_C void CAknFepCtrlVkbLayout::ConstructFromIrregularResourceL() |
|
135 { |
|
136 if ( iIrregularResId < 0 ) |
|
137 { |
|
138 return; |
|
139 } |
|
140 |
|
141 TResourceReader reader; |
|
142 |
|
143 CCoeEnv::Static()->CreateResourceReaderLC( reader, iIrregularResId ); |
|
144 |
|
145 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
146 |
|
147 for (TInt index = 0; index <= EKeyRightUp; index ++) |
|
148 { |
|
149 CreateIrregularKeyBitmapsL(reader, bmpFileName, (TVirtualKeyIrregularKeyType) index); |
|
150 } |
|
151 |
|
152 // Pop and destroy reader |
|
153 CleanupStack::PopAndDestroy( 1 ); |
|
154 for( TInt i = 0; i < iVkbLayoutInfoList.Count(); i++ ) |
|
155 { |
|
156 iVkbLayoutInfoList[i]->iIrregular = ETrue; |
|
157 } |
|
158 |
|
159 } |
|
160 |
|
161 EXPORT_C void CAknFepCtrlVkbLayout::ConstructFromNonIrregularResourceL() |
|
162 { |
|
163 if ( iNonIrregularResId < 0 ) |
|
164 { |
|
165 return; |
|
166 } |
|
167 |
|
168 TResourceReader reader; |
|
169 |
|
170 CCoeEnv::Static()->CreateResourceReaderLC( reader, iNonIrregularResId ); |
|
171 |
|
172 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
173 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
174 TAknsItemID id; |
|
175 |
|
176 for (TInt index = 0; index <= EKeyBmpLastType ; index += 2) |
|
177 { |
|
178 // Get the image ids and mask ids from resource |
|
179 TInt bmpId = reader.ReadInt16(); |
|
180 TInt bmpMskId = reader.ReadInt16(); |
|
181 |
|
182 // read skin item id |
|
183 const TInt skinitemid = reader.ReadInt16(); |
|
184 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
185 |
|
186 if (bmpId != KInvalidBmp) |
|
187 { |
|
188 CFbsBitmap* bmp = NULL; |
|
189 CFbsBitmap* maskbmp = NULL; |
|
190 |
|
191 if (bmpMskId != KInvalidBmp) |
|
192 { |
|
193 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
194 id, |
|
195 bmp, |
|
196 maskbmp, |
|
197 bmpFileName, |
|
198 bmpId, |
|
199 bmpMskId); |
|
200 |
|
201 // set maskbmp and size |
|
202 iVkbCtrl->SetNonIrregularKeyBitmapL(TVirtualKeyBmpType(EKeyBmpNormal + index + 1), |
|
203 maskbmp ); |
|
204 } |
|
205 else |
|
206 { |
|
207 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
208 id, |
|
209 bmp, |
|
210 bmpFileName, |
|
211 bmpId); |
|
212 } |
|
213 |
|
214 // set bmp and size |
|
215 iVkbCtrl->SetNonIrregularKeyBitmapL( TVirtualKeyBmpType(EKeyBmpNormal + index), bmp ); |
|
216 } |
|
217 } |
|
218 |
|
219 // Pop and destroy reader |
|
220 CleanupStack::PopAndDestroy( 1 ); |
|
221 for( TInt i = 0; i < iVkbLayoutInfoList.Count(); i++ ) |
|
222 { |
|
223 iVkbLayoutInfoList[i]->iIrregular = EFalse; |
|
224 } |
|
225 |
|
226 } |
|
227 void CAknFepCtrlVkbLayout::CreateIrregularKeyBitmapsL(TResourceReader& reader, TPtrC& bmpFileName, |
|
228 TVirtualKeyIrregularKeyType aKeyType) |
|
229 { |
|
230 int maskid = 0; |
|
231 for(TInt index = 0; index <= EKeyStateDimmedMask; index += 2) |
|
232 { |
|
233 maskid = index + 1; |
|
234 CreateIrregularKeyBitmapL(reader, bmpFileName, aKeyType , |
|
235 (TVirtualKeyIrregularKeyState)index, |
|
236 (TVirtualKeyIrregularKeyState)maskid); |
|
237 } |
|
238 } |
|
239 |
|
240 void CAknFepCtrlVkbLayout::CreateIrregularKeyBitmapL(TResourceReader& reader, TPtrC& bmpFileName, |
|
241 TVirtualKeyIrregularKeyType aKeyType , |
|
242 TVirtualKeyIrregularKeyState aKeyState, |
|
243 TVirtualKeyIrregularKeyState aKeyStateMask) |
|
244 { |
|
245 CFbsBitmap* bitmap = NULL; |
|
246 CFbsBitmap* bitmapmaks = NULL; |
|
247 TAknsItemID id; |
|
248 MAknsSkinInstance* skininstance = AknsUtils::SkinInstance(); |
|
249 |
|
250 TInt bmpID = reader.ReadInt16(); |
|
251 TInt bmpmaskID = reader.ReadInt16(); |
|
252 TInt minorskinID = reader.ReadInt16(); |
|
253 id.Set(TInt(EAknsMajorGeneric), minorskinID); |
|
254 |
|
255 if (bmpID > 0) |
|
256 { |
|
257 |
|
258 AknsUtils::CreateIconL( skininstance, |
|
259 id, |
|
260 bitmap, |
|
261 bitmapmaks, |
|
262 bmpFileName, |
|
263 bmpID, |
|
264 bmpmaskID ); |
|
265 |
|
266 if (bitmapmaks) |
|
267 { |
|
268 AknIconUtils::DisableCompression(bitmapmaks); |
|
269 } |
|
270 |
|
271 if (bitmap && iVkbCtrl) |
|
272 { |
|
273 iVkbCtrl->AddIrregularKeyBitmapL(aKeyType, aKeyState, bitmap); |
|
274 } |
|
275 |
|
276 if (bitmapmaks && iVkbCtrl) |
|
277 { |
|
278 iVkbCtrl->AddIrregularKeyBitmapL(aKeyType, aKeyStateMask, bitmapmaks); |
|
279 } |
|
280 } |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // CAknFepCtrlVkbLayout::SetResourceId |
|
285 // Set resurce Id |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 EXPORT_C void CAknFepCtrlVkbLayout::SetResourceId(TInt32 aResId) |
|
289 { |
|
290 iResourceId = aResId; |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CAknFepCtrlVkbLayout::ConstructFromResourceL |
|
295 // (other items were commented in a header). |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C void CAknFepCtrlVkbLayout::ConstructFromResourceL() |
|
299 { |
|
300 if ( iResourceId < 0 ) |
|
301 { |
|
302 return; |
|
303 } |
|
304 |
|
305 TResourceReader reader; |
|
306 |
|
307 CCoeEnv::Static()->CreateResourceReaderLC( reader, iResourceId ); |
|
308 |
|
309 TInt count = reader.ReadInt16(); |
|
310 |
|
311 if( iFirstTimeConstruct ) |
|
312 { |
|
313 iVkbLayoutInfoList.ResetAndDestroy(); |
|
314 for ( TInt i = 0; i < count; i++ ) |
|
315 { |
|
316 CPeninputVkbLayoutInfo* vkbLayoutInfo = |
|
317 CPeninputVkbLayoutInfo::NewL( reader ); |
|
318 |
|
319 if (iVkbCtrl) |
|
320 { |
|
321 vkbLayoutInfo->iIrregular = iVkbCtrl->IsIrregularKeyBoard(); |
|
322 } |
|
323 iVkbLayoutInfoList.Append( vkbLayoutInfo ); |
|
324 } |
|
325 } |
|
326 else |
|
327 { |
|
328 // vkb keyboard must reset first, because iKeyInfoList will reset and destroy later |
|
329 iVkbCtrl->Reset(); |
|
330 |
|
331 for ( TInt i = 0; i < count; i++ ) |
|
332 { |
|
333 iVkbLayoutInfoList[i]->ConstructFromResourceL( reader, iVkbCtrl, iVkbLayoutId ); |
|
334 iVkbLayoutInfoList[i]->ResetSize( |
|
335 iVkbLayoutInfoList[i]->UnitWidth(), |
|
336 iVkbLayoutInfoList[i]->UnitHeight(), |
|
337 iVkbLayoutInfoList[i]->UnitCharWidth(), |
|
338 iVkbLayoutInfoList[i]->UnitCharHeight(), |
|
339 iVkbLayoutInfoList[i]->CharLeftTopPoint(), |
|
340 iVkbLayoutInfoList[i]->CharFont() ); |
|
341 |
|
342 if (iVkbCtrl) |
|
343 { |
|
344 iVkbLayoutInfoList[i]->iIrregular = iVkbCtrl->IsIrregularKeyBoard(); |
|
345 } |
|
346 } |
|
347 } |
|
348 |
|
349 // Pop and destroy reader |
|
350 CleanupStack::PopAndDestroy( 1 ); |
|
351 |
|
352 iFirstTimeConstruct = EFalse; |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CAknFepCtrlVkbLayout::VkbLayoutInfoList |
|
357 // (other items were commented in a header). |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 EXPORT_C RPointerArray<CPeninputVkbLayoutInfo> CAknFepCtrlVkbLayout::VkbLayoutInfoList() |
|
361 { |
|
362 return iVkbLayoutInfoList; |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // CAknFepCtrlVkbLayout::ChangeVkbLayout |
|
367 // (other items were commented in a header). |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 EXPORT_C void CAknFepCtrlVkbLayout::ChangeVkbLayout( TInt aVkbLayoutId ) |
|
371 { |
|
372 if( iVkbLayoutId == aVkbLayoutId ) |
|
373 { |
|
374 return; |
|
375 } |
|
376 iVkbLayoutId = aVkbLayoutId; |
|
377 for( TInt i = 0; i < iVkbLayoutInfoList.Count(); i++ ) |
|
378 { |
|
379 if( aVkbLayoutId == iVkbLayoutInfoList[i]->LayoutID() ) |
|
380 { |
|
381 iVkbCtrl->ReorganizeVkbKeys( iVkbLayoutInfoList[i] ); |
|
382 |
|
383 return; |
|
384 } |
|
385 } |
|
386 } |
|
387 |
|
388 // ------------------------------------------------------------------------ |
|
389 // CPeninputVkbKeyInfo::NewL |
|
390 // (other items were commented in a header) |
|
391 // ------------------------------------------------------------------------ |
|
392 // |
|
393 EXPORT_C CPeninputVkbKeyInfo* CPeninputVkbKeyInfo::NewL( |
|
394 TResourceReader& aReader ) |
|
395 { |
|
396 CPeninputVkbKeyInfo* self = new ( ELeave ) CPeninputVkbKeyInfo(); |
|
397 |
|
398 CleanupStack::PushL( self ); |
|
399 self->ConstructL( aReader ); |
|
400 CleanupStack::Pop( self ); |
|
401 |
|
402 return self; |
|
403 } |
|
404 |
|
405 // ------------------------------------------------------------------------ |
|
406 // CPeninputVkbKeyInfo::~CPeninputVkbKeyInfo |
|
407 // (other items were commented in a header) |
|
408 // ------------------------------------------------------------------------ |
|
409 // |
|
410 EXPORT_C CPeninputVkbKeyInfo::~CPeninputVkbKeyInfo() |
|
411 { |
|
412 delete iKey; |
|
413 iKey = NULL; |
|
414 delete iUnicode; |
|
415 iUnicode = NULL; |
|
416 } |
|
417 |
|
418 // ------------------------------------------------------------------------ |
|
419 // CPeninputVkbKeyInfo::ConstructL |
|
420 // (other items were commented in a header) |
|
421 // ------------------------------------------------------------------------ |
|
422 // |
|
423 void CPeninputVkbKeyInfo::ConstructL( TResourceReader& aReader ) |
|
424 { |
|
425 ConstructFromResourceL( aReader ); |
|
426 } |
|
427 |
|
428 // ------------------------------------------------------------------------ |
|
429 // CPeninputVkbKeyInfo::ConstructFromResourceL |
|
430 // (other items were commented in a header) |
|
431 // ------------------------------------------------------------------------ |
|
432 // |
|
433 void CPeninputVkbKeyInfo::ConstructFromResourceL( TResourceReader& aReader ) |
|
434 { |
|
435 iUnicode = aReader.ReadHBufCL(); |
|
436 iScanCode = aReader.ReadInt16(); |
|
437 iBeginRow = aReader.ReadInt16(); |
|
438 iBeginColumn = aReader.ReadInt16(); |
|
439 iEndRow = aReader.ReadInt16(); |
|
440 iEndColumn = aReader.ReadInt16(); |
|
441 iHighlightBmpIndex = aReader.ReadInt16(); |
|
442 iHighlightMaskBmpIndex = aReader.ReadInt16(); |
|
443 TPtrC displayUnicode = aReader.ReadTPtrC(); |
|
444 |
|
445 TInt baseLine = 0; |
|
446 iKey = CVirtualKey::NewL( *iUnicode, iScanCode, TRect(), |
|
447 TRect(), baseLine, iHighlightBmpIndex, iHighlightMaskBmpIndex ); |
|
448 if( displayUnicode.Length() != 0 ) |
|
449 { |
|
450 iKey->SetDisplayUnicodeL( displayUnicode ); |
|
451 } |
|
452 } |
|
453 |
|
454 TVirtualKeyIrregularKeyType CPeninputVkbKeyInfo::KeyTypeFromColumn(TInt aColumns) |
|
455 { |
|
456 if (iBeginColumn == 0) |
|
457 { |
|
458 return EKeyLeftDown; |
|
459 } |
|
460 |
|
461 if ((iBeginColumn == aColumns - 1) && (aColumns % 2 == 0)) |
|
462 { |
|
463 return EKeyRightUp; |
|
464 } |
|
465 |
|
466 if ((iBeginColumn == aColumns - 1) && (aColumns % 2 == 1)) |
|
467 { |
|
468 return EKeyRightDown; |
|
469 } |
|
470 |
|
471 if (iBeginColumn % 2 == 0) |
|
472 { |
|
473 return EKeyMiddleDown; |
|
474 } |
|
475 |
|
476 return EKeyMiddleUp; |
|
477 } |
|
478 |
|
479 void CPeninputVkbKeyInfo::SetIrregularKeyType(TInt aColumns) |
|
480 { |
|
481 if (iKey) |
|
482 { |
|
483 iKey->SetIrregualrKeyType(KeyTypeFromColumn(aColumns)); |
|
484 } |
|
485 } |
|
486 // ------------------------------------------------------------------------ |
|
487 // CPeninputVkbKeyInfo::CreateKeyL |
|
488 // (other items were commented in a header) |
|
489 // ------------------------------------------------------------------------ |
|
490 // |
|
491 void CPeninputVkbKeyInfo::CreateKeyL() |
|
492 { |
|
493 TInt baseLine = 0; |
|
494 iKey = CVirtualKey::NewL( *iUnicode, iScanCode, TRect(), |
|
495 TRect(), baseLine, iHighlightBmpIndex, iHighlightMaskBmpIndex ); |
|
496 } |
|
497 |
|
498 // ------------------------------------------------------------------------ |
|
499 // CPeninputVkbLayoutInfo::NewL |
|
500 // (other items were commented in a header) |
|
501 // ------------------------------------------------------------------------ |
|
502 // |
|
503 EXPORT_C CPeninputVkbLayoutInfo* CPeninputVkbLayoutInfo::NewL( |
|
504 TResourceReader& aReader ) |
|
505 { |
|
506 CPeninputVkbLayoutInfo* self = NewLC( aReader ); |
|
507 CleanupStack::Pop( self ); |
|
508 |
|
509 return self; |
|
510 } |
|
511 |
|
512 // ------------------------------------------------------------------------ |
|
513 // CPeninputVkbLayoutInfo::NewLC |
|
514 // (other items were commented in a header) |
|
515 // ------------------------------------------------------------------------ |
|
516 // |
|
517 EXPORT_C CPeninputVkbLayoutInfo* CPeninputVkbLayoutInfo::NewLC( |
|
518 TResourceReader& aReader ) |
|
519 { |
|
520 CPeninputVkbLayoutInfo* self = new ( ELeave ) CPeninputVkbLayoutInfo(); |
|
521 CleanupStack::PushL( self ); |
|
522 self->ConstructL( aReader ); |
|
523 |
|
524 return self; |
|
525 } |
|
526 |
|
527 // ------------------------------------------------------------------------ |
|
528 // CPeninputVkbLayoutInfo::GetRealSize |
|
529 // (other items were commented in a header) |
|
530 // ------------------------------------------------------------------------ |
|
531 // |
|
532 EXPORT_C const TSize CPeninputVkbLayoutInfo::GetRealSize( |
|
533 const TInt aUnitWidth, const TInt aUnitHeight ) const |
|
534 { |
|
535 return TSize( aUnitWidth * iColumns, aUnitHeight * iRows ); |
|
536 } |
|
537 |
|
538 EXPORT_C void CPeninputVkbLayoutInfo::ResetLayoutInfo(const TSize& aSize) |
|
539 { |
|
540 AknIconUtils::SetSize( iBgBmp, aSize, EAspectRatioNotPreserved ); |
|
541 AknIconUtils::SetSize( iBgMaskBmp, aSize, EAspectRatioNotPreserved ); |
|
542 |
|
543 } |
|
544 |
|
545 EXPORT_C void CPeninputVkbLayoutInfo::SetKeyInfo(const TInt aRow, |
|
546 const TInt aColumn, |
|
547 const TRect& aKeyRect, |
|
548 const TRect& aCharRect, |
|
549 const CFont* aFont) |
|
550 { |
|
551 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
552 TInt count = keyInfoList.Count(); |
|
553 |
|
554 for (TInt i = 0; i < count; i++ ) |
|
555 { |
|
556 if (keyInfoList[i] && |
|
557 keyInfoList[i]->BeginColumn() == aColumn && |
|
558 keyInfoList[i]->BeginRow() == aRow) |
|
559 { |
|
560 keyInfoList[i]->Key()->SetRect( aKeyRect ); |
|
561 |
|
562 return; |
|
563 } |
|
564 } |
|
565 } |
|
566 |
|
567 |
|
568 // ------------------------------------------------------------------------ |
|
569 // CPeninputVkbLayoutInfo::ResetSize |
|
570 // (other items were commented in a header) |
|
571 // ------------------------------------------------------------------------ |
|
572 // |
|
573 EXPORT_C void CPeninputVkbLayoutInfo::ResetSize( |
|
574 const TInt aUnitWidth, |
|
575 const TInt aUnitHeight, |
|
576 const TInt aUnitCharWidth, |
|
577 const TInt aUnitCharHeight, |
|
578 const TPoint& aCharLeftTopPoint, |
|
579 const CFont* aFont ) |
|
580 { |
|
581 iUnitWidth = aUnitWidth; |
|
582 iUnitHeight = aUnitHeight; |
|
583 iUnitCharWidth = aUnitCharWidth; |
|
584 iUnitCharHeight = aUnitCharHeight; |
|
585 iCharLeftTopPoint = aCharLeftTopPoint; |
|
586 iFont = aFont; |
|
587 |
|
588 iLastTopLeft = TPoint( 0, 0 ); |
|
589 |
|
590 // 1.Resize bk bmp and mask bmp |
|
591 AknIconUtils::SetSize( iBgBmp, |
|
592 TSize( aUnitWidth * iColumns, aUnitHeight * iRows ), |
|
593 EAspectRatioNotPreserved ); |
|
594 AknIconUtils::SetSize( iBgMaskBmp, |
|
595 TSize( aUnitWidth * iColumns, aUnitHeight * iRows ), |
|
596 EAspectRatioNotPreserved ); |
|
597 |
|
598 // 2.Resize dim bmp and mask bmp |
|
599 AknIconUtils::SetSize( iDimBmp, TSize( aUnitWidth, aUnitHeight ), |
|
600 EAspectRatioNotPreserved ); |
|
601 AknIconUtils::SetSize( iDimMaskBmp, TSize( aUnitWidth, aUnitHeight ), |
|
602 EAspectRatioNotPreserved ); |
|
603 |
|
604 // 3.Resize all highlight bmp and mask bmp |
|
605 TInt count = iHighlightBmps.Count(); |
|
606 TInt i = 0; |
|
607 |
|
608 for ( i = 0; i < count; i++ ) |
|
609 { |
|
610 AknIconUtils::SetSize( iHighlightBmps[i], |
|
611 TSize( aUnitWidth, aUnitHeight ), EAspectRatioNotPreserved ); |
|
612 } |
|
613 |
|
614 count = iHighlightMaskBmps.Count(); |
|
615 for ( i = 0; i < count; i++ ) |
|
616 { |
|
617 AknIconUtils::SetSize( iHighlightMaskBmps[i], |
|
618 TSize( aUnitWidth, aUnitHeight ), EAspectRatioNotPreserved ); |
|
619 } |
|
620 |
|
621 // 4.For every key, reset the key rect and char rect |
|
622 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
623 count = keyInfoList.Count(); |
|
624 TPoint keyLeftTop; |
|
625 TInt rows; |
|
626 TInt columns; |
|
627 TRect rect; |
|
628 |
|
629 for ( i = 0; i < count; i++ ) |
|
630 { |
|
631 if ( keyInfoList[i]->Key() ) |
|
632 { |
|
633 if (keyInfoList[i]->BeginColumn() == 0) |
|
634 { |
|
635 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth, |
|
636 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
637 } |
|
638 else |
|
639 { |
|
640 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth - |
|
641 6 * keyInfoList[i]->BeginColumn(), |
|
642 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
643 } |
|
644 |
|
645 if (!iIrregular) |
|
646 { |
|
647 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth, |
|
648 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
649 } |
|
650 |
|
651 |
|
652 rows = keyInfoList[i]->EndRow() - keyInfoList[i]->BeginRow(); |
|
653 columns = keyInfoList[i]->EndColumn() |
|
654 - keyInfoList[i]->BeginColumn(); |
|
655 |
|
656 //Set key rect |
|
657 rect = TRect( keyLeftTop, TSize( columns * aUnitWidth, |
|
658 rows * aUnitHeight ) ); |
|
659 keyInfoList[i]->Key()->SetRect( rect ); |
|
660 } |
|
661 } |
|
662 } |
|
663 |
|
664 // ------------------------------------------------------------------------ |
|
665 // CPeninputVkbLayoutInfo::~CPeninputVkbLayoutInfo |
|
666 // (other items were commented in a header) |
|
667 // ------------------------------------------------------------------------ |
|
668 // |
|
669 EXPORT_C CPeninputVkbLayoutInfo::~CPeninputVkbLayoutInfo() |
|
670 { |
|
671 delete iBgBmp; |
|
672 iBgBmp = NULL; |
|
673 delete iBgMaskBmp; |
|
674 iBgMaskBmp = NULL; |
|
675 delete iDimBmp; |
|
676 iDimBmp = NULL; |
|
677 delete iDimMaskBmp; |
|
678 iDimMaskBmp = NULL; |
|
679 |
|
680 iHighlightBmps.ResetAndDestroy(); |
|
681 iHighlightBmps.Close(); |
|
682 |
|
683 iHighlightMaskBmps.ResetAndDestroy(); |
|
684 iHighlightMaskBmps.Close(); |
|
685 |
|
686 iKeyInfoList.ResetAndDestroy(); |
|
687 iKeyInfoList.Close(); |
|
688 } |
|
689 |
|
690 // ------------------------------------------------------------------------ |
|
691 // CPeninputVkbLayoutInfo::FindKey |
|
692 // (other items were commented in a header) |
|
693 // ------------------------------------------------------------------------ |
|
694 // |
|
695 EXPORT_C CPeninputVkbKeyInfo* CPeninputVkbLayoutInfo::FindKey( |
|
696 const TInt aUnicode ) const |
|
697 { |
|
698 const TInt count = iKeyInfoList.Count(); |
|
699 |
|
700 for ( TInt i = 0; i < count; i++ ) |
|
701 { |
|
702 if ( (*iKeyInfoList[i]->Unicode())[0] == aUnicode ) |
|
703 { |
|
704 return iKeyInfoList[i]; |
|
705 } |
|
706 } |
|
707 |
|
708 return NULL; |
|
709 } |
|
710 |
|
711 // ------------------------------------------------------------------------ |
|
712 // CPeninputVkbLayoutInfo::MoveKeys |
|
713 // (other items were commented in a header) |
|
714 // ------------------------------------------------------------------------ |
|
715 // |
|
716 EXPORT_C void CPeninputVkbLayoutInfo::MoveKeys( const TPoint& aTopLeft ) |
|
717 { |
|
718 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
719 const TInt count = keyInfoList.Count(); |
|
720 const TPoint difference = aTopLeft - iLastTopLeft; |
|
721 TRect rect; |
|
722 |
|
723 for ( TInt i = 0; i < count; i++ ) |
|
724 { |
|
725 if ( keyInfoList[i]->Key() ) |
|
726 { |
|
727 //Set key rect |
|
728 rect = keyInfoList[i]->Key()->Rect(); |
|
729 rect.SetRect( rect.iTl + difference, rect.Size() ); |
|
730 keyInfoList[i]->Key()->SetRect( rect ); |
|
731 } |
|
732 } |
|
733 |
|
734 iLastTopLeft = aTopLeft; |
|
735 } |
|
736 |
|
737 // ------------------------------------------------------------------------ |
|
738 // CPeninputVkbLayoutInfo::CPeninputVkbLayoutInfo |
|
739 // (other items were commented in a header) |
|
740 // ------------------------------------------------------------------------ |
|
741 // |
|
742 CPeninputVkbLayoutInfo::CPeninputVkbLayoutInfo() |
|
743 : iCharLeftTopPoint( TPoint(0,0) ) |
|
744 { |
|
745 iLastTopLeft = TPoint( 0, 0 ); |
|
746 } |
|
747 |
|
748 // ------------------------------------------------------------------------ |
|
749 // CPeninputVkbLayoutInfo::ConstructL |
|
750 // (other items were commented in a header) |
|
751 // ------------------------------------------------------------------------ |
|
752 // |
|
753 void CPeninputVkbLayoutInfo::ConstructL( TResourceReader& aReader ) |
|
754 { |
|
755 |
|
756 ConstructFromResourceL( aReader ); |
|
757 } |
|
758 |
|
759 // ------------------------------------------------------------------------ |
|
760 // CPeninputVkbLayoutInfo::ConstructFromResourceL |
|
761 // (other items were commented in a header) |
|
762 // ------------------------------------------------------------------------ |
|
763 // |
|
764 void CPeninputVkbLayoutInfo::ConstructFromResourceL( TResourceReader& aReader, |
|
765 CPeninputVkbCtrlExt* aVkbCtrl, |
|
766 TInt aVkbLayoutId ) |
|
767 { |
|
768 delete iBgBmp; |
|
769 iBgBmp = NULL; |
|
770 delete iBgMaskBmp; |
|
771 iBgMaskBmp = NULL; |
|
772 delete iDimBmp; |
|
773 iDimBmp = NULL; |
|
774 delete iDimMaskBmp; |
|
775 iDimMaskBmp = NULL; |
|
776 |
|
777 iHighlightBmps.ResetAndDestroy(); |
|
778 iHighlightBmps.Close(); |
|
779 |
|
780 iHighlightMaskBmps.ResetAndDestroy(); |
|
781 iHighlightMaskBmps.Close(); |
|
782 |
|
783 iKeyInfoList.ResetAndDestroy(); |
|
784 iKeyInfoList.Close(); |
|
785 |
|
786 iLayoutID = aReader.ReadInt16(); |
|
787 |
|
788 // Read the file name of the bmps |
|
789 TPtrC bmpFileName = aReader.ReadTPtrC(); |
|
790 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
791 |
|
792 TInt layoutBmpId = aReader.ReadInt16(); |
|
793 TInt layoutBmpMaskId = aReader.ReadInt16(); |
|
794 TInt layoutBmpSkinId = aReader.ReadInt16(); |
|
795 |
|
796 TAknsItemID id; |
|
797 MAknsSkinInstance* skininstance = AknsUtils::SkinInstance(); |
|
798 |
|
799 id.Set(TInt( imgMajorSkinId ), layoutBmpSkinId); |
|
800 |
|
801 if ( layoutBmpId != KInvalidBmp) |
|
802 { |
|
803 if ( layoutBmpMaskId != KInvalidBmp) |
|
804 { |
|
805 AknsUtils::CreateIconL( skininstance, |
|
806 id, |
|
807 iBgBmp, |
|
808 iBgMaskBmp, |
|
809 bmpFileName, |
|
810 layoutBmpId, |
|
811 layoutBmpMaskId ); |
|
812 } |
|
813 else |
|
814 { |
|
815 AknsUtils::CreateIconL( skininstance, |
|
816 id, |
|
817 iBgBmp, |
|
818 bmpFileName, |
|
819 layoutBmpId ); |
|
820 } |
|
821 } |
|
822 |
|
823 TInt dimBmpId = aReader.ReadInt16(); |
|
824 TInt dimMaskBmpId = aReader.ReadInt16(); |
|
825 TInt dimBmpSkinId = aReader.ReadInt16(); |
|
826 |
|
827 id.Set( TInt( imgMajorSkinId ), dimBmpSkinId ); |
|
828 |
|
829 if ( dimBmpId != KInvalidBmp ) |
|
830 { |
|
831 if ( dimMaskBmpId != KInvalidBmp ) |
|
832 { |
|
833 AknsUtils::CreateIconL( skininstance, |
|
834 id, |
|
835 iDimBmp, |
|
836 iDimMaskBmp, |
|
837 bmpFileName, |
|
838 dimBmpId, |
|
839 dimMaskBmpId ); |
|
840 } |
|
841 else |
|
842 { |
|
843 AknsUtils::CreateIconL( skininstance, |
|
844 id, |
|
845 iDimBmp, |
|
846 bmpFileName, |
|
847 dimBmpId ); |
|
848 } |
|
849 } |
|
850 |
|
851 iColumns = aReader.ReadInt16(); |
|
852 iRows = aReader.ReadInt16(); |
|
853 |
|
854 TInt i; |
|
855 TInt count = aReader.ReadInt16(); |
|
856 TInt bmpId; |
|
857 |
|
858 for ( i = 0; i < count; i++ ) |
|
859 { |
|
860 bmpId = aReader.ReadInt16(); |
|
861 if ( bmpId != KInvalidBmp ) |
|
862 { |
|
863 CFbsBitmap* bmp = AknIconUtils::CreateIconL( bmpFileName, |
|
864 bmpId ); |
|
865 CleanupStack::PushL( bmp ); |
|
866 iHighlightBmps.Append( bmp ); |
|
867 CleanupStack::Pop( bmp ); |
|
868 } |
|
869 } |
|
870 |
|
871 count = aReader.ReadInt16(); |
|
872 for ( i = 0; i < count; i++ ) |
|
873 { |
|
874 bmpId = aReader.ReadInt16(); |
|
875 if ( bmpId != KInvalidBmp ) |
|
876 { |
|
877 CFbsBitmap* bmp = AknIconUtils::CreateIconL( bmpFileName, bmpId ); |
|
878 CleanupStack::PushL( bmp ); |
|
879 iHighlightMaskBmps.Append( bmp ); |
|
880 CleanupStack::Pop( bmp ); |
|
881 } |
|
882 } |
|
883 |
|
884 count = aReader.ReadInt16(); |
|
885 |
|
886 for ( i = 0; i < count; i++ ) |
|
887 { |
|
888 CPeninputVkbKeyInfo* keyInfo = CPeninputVkbKeyInfo::NewL( aReader ); |
|
889 keyInfo->SetIrregularKeyType(iColumns); |
|
890 iKeyInfoList.Append( keyInfo ); |
|
891 } |
|
892 |
|
893 if ( ( iLayoutID == aVkbLayoutId ) && ( aVkbCtrl ) ) |
|
894 { |
|
895 aVkbCtrl->ReorganizeVkbKeys( this ); |
|
896 } |
|
897 } |
|
898 // End Of File |