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 |
|
330 if( iVkbCtrl != NULL ) |
|
331 { |
|
332 iVkbCtrl->Reset(); |
|
333 } |
|
334 |
|
335 for ( TInt i = 0; i < count; i++ ) |
|
336 { |
|
337 iVkbLayoutInfoList[i]->ConstructFromResourceL( reader, iVkbCtrl, iVkbLayoutId ); |
|
338 iVkbLayoutInfoList[i]->ResetSize( |
|
339 iVkbLayoutInfoList[i]->UnitWidth(), |
|
340 iVkbLayoutInfoList[i]->UnitHeight(), |
|
341 iVkbLayoutInfoList[i]->UnitCharWidth(), |
|
342 iVkbLayoutInfoList[i]->UnitCharHeight(), |
|
343 iVkbLayoutInfoList[i]->CharLeftTopPoint(), |
|
344 iVkbLayoutInfoList[i]->CharFont() ); |
|
345 |
|
346 if (iVkbCtrl) |
|
347 { |
|
348 iVkbLayoutInfoList[i]->iIrregular = iVkbCtrl->IsIrregularKeyBoard(); |
|
349 } |
|
350 } |
|
351 } |
|
352 |
|
353 // Pop and destroy reader |
|
354 CleanupStack::PopAndDestroy( 1 ); |
|
355 |
|
356 iFirstTimeConstruct = EFalse; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // CAknFepCtrlVkbLayout::VkbLayoutInfoList |
|
361 // (other items were commented in a header). |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 EXPORT_C RPointerArray<CPeninputVkbLayoutInfo> CAknFepCtrlVkbLayout::VkbLayoutInfoList() |
|
365 { |
|
366 return iVkbLayoutInfoList; |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // CAknFepCtrlVkbLayout::ChangeVkbLayout |
|
371 // (other items were commented in a header). |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 EXPORT_C void CAknFepCtrlVkbLayout::ChangeVkbLayout( TInt aVkbLayoutId ) |
|
375 { |
|
376 if( iVkbLayoutId == aVkbLayoutId ) |
|
377 { |
|
378 return; |
|
379 } |
|
380 iVkbLayoutId = aVkbLayoutId; |
|
381 for( TInt i = 0; i < iVkbLayoutInfoList.Count(); i++ ) |
|
382 { |
|
383 if( aVkbLayoutId == iVkbLayoutInfoList[i]->LayoutID() ) |
|
384 { |
|
385 iVkbCtrl->ReorganizeVkbKeys( iVkbLayoutInfoList[i] ); |
|
386 |
|
387 return; |
|
388 } |
|
389 } |
|
390 } |
|
391 |
|
392 // ------------------------------------------------------------------------ |
|
393 // CPeninputVkbKeyInfo::NewL |
|
394 // (other items were commented in a header) |
|
395 // ------------------------------------------------------------------------ |
|
396 // |
|
397 EXPORT_C CPeninputVkbKeyInfo* CPeninputVkbKeyInfo::NewL( |
|
398 TResourceReader& aReader ) |
|
399 { |
|
400 CPeninputVkbKeyInfo* self = new ( ELeave ) CPeninputVkbKeyInfo(); |
|
401 |
|
402 CleanupStack::PushL( self ); |
|
403 self->ConstructL( aReader ); |
|
404 CleanupStack::Pop( self ); |
|
405 |
|
406 return self; |
|
407 } |
|
408 |
|
409 // ------------------------------------------------------------------------ |
|
410 // CPeninputVkbKeyInfo::~CPeninputVkbKeyInfo |
|
411 // (other items were commented in a header) |
|
412 // ------------------------------------------------------------------------ |
|
413 // |
|
414 EXPORT_C CPeninputVkbKeyInfo::~CPeninputVkbKeyInfo() |
|
415 { |
|
416 delete iKey; |
|
417 iKey = NULL; |
|
418 delete iUnicode; |
|
419 iUnicode = NULL; |
|
420 } |
|
421 |
|
422 // ------------------------------------------------------------------------ |
|
423 // CPeninputVkbKeyInfo::ConstructL |
|
424 // (other items were commented in a header) |
|
425 // ------------------------------------------------------------------------ |
|
426 // |
|
427 void CPeninputVkbKeyInfo::ConstructL( TResourceReader& aReader ) |
|
428 { |
|
429 ConstructFromResourceL( aReader ); |
|
430 } |
|
431 |
|
432 // ------------------------------------------------------------------------ |
|
433 // CPeninputVkbKeyInfo::ConstructFromResourceL |
|
434 // (other items were commented in a header) |
|
435 // ------------------------------------------------------------------------ |
|
436 // |
|
437 void CPeninputVkbKeyInfo::ConstructFromResourceL( TResourceReader& aReader ) |
|
438 { |
|
439 iUnicode = aReader.ReadHBufCL(); |
|
440 iScanCode = aReader.ReadInt16(); |
|
441 iBeginRow = aReader.ReadInt16(); |
|
442 iBeginColumn = aReader.ReadInt16(); |
|
443 iEndRow = aReader.ReadInt16(); |
|
444 iEndColumn = aReader.ReadInt16(); |
|
445 iHighlightBmpIndex = aReader.ReadInt16(); |
|
446 iHighlightMaskBmpIndex = aReader.ReadInt16(); |
|
447 TPtrC displayUnicode = aReader.ReadTPtrC(); |
|
448 |
|
449 TInt baseLine = 0; |
|
450 iKey = CVirtualKey::NewL( *iUnicode, iScanCode, TRect(), |
|
451 TRect(), baseLine, iHighlightBmpIndex, iHighlightMaskBmpIndex ); |
|
452 if( displayUnicode.Length() != 0 ) |
|
453 { |
|
454 iKey->SetDisplayUnicodeL( displayUnicode ); |
|
455 } |
|
456 } |
|
457 |
|
458 TVirtualKeyIrregularKeyType CPeninputVkbKeyInfo::KeyTypeFromColumn(TInt aColumns) |
|
459 { |
|
460 if (iBeginColumn == 0) |
|
461 { |
|
462 return EKeyLeftDown; |
|
463 } |
|
464 |
|
465 if ((iBeginColumn == aColumns - 1) && (aColumns % 2 == 0)) |
|
466 { |
|
467 return EKeyRightUp; |
|
468 } |
|
469 |
|
470 if ((iBeginColumn == aColumns - 1) && (aColumns % 2 == 1)) |
|
471 { |
|
472 return EKeyRightDown; |
|
473 } |
|
474 |
|
475 if (iBeginColumn % 2 == 0) |
|
476 { |
|
477 return EKeyMiddleDown; |
|
478 } |
|
479 |
|
480 return EKeyMiddleUp; |
|
481 } |
|
482 |
|
483 void CPeninputVkbKeyInfo::SetIrregularKeyType(TInt aColumns) |
|
484 { |
|
485 if (iKey) |
|
486 { |
|
487 iKey->SetIrregualrKeyType(KeyTypeFromColumn(aColumns)); |
|
488 } |
|
489 } |
|
490 // ------------------------------------------------------------------------ |
|
491 // CPeninputVkbKeyInfo::CreateKeyL |
|
492 // (other items were commented in a header) |
|
493 // ------------------------------------------------------------------------ |
|
494 // |
|
495 void CPeninputVkbKeyInfo::CreateKeyL() |
|
496 { |
|
497 TInt baseLine = 0; |
|
498 iKey = CVirtualKey::NewL( *iUnicode, iScanCode, TRect(), |
|
499 TRect(), baseLine, iHighlightBmpIndex, iHighlightMaskBmpIndex ); |
|
500 } |
|
501 |
|
502 // ------------------------------------------------------------------------ |
|
503 // CPeninputVkbLayoutInfo::NewL |
|
504 // (other items were commented in a header) |
|
505 // ------------------------------------------------------------------------ |
|
506 // |
|
507 EXPORT_C CPeninputVkbLayoutInfo* CPeninputVkbLayoutInfo::NewL( |
|
508 TResourceReader& aReader ) |
|
509 { |
|
510 CPeninputVkbLayoutInfo* self = NewLC( aReader ); |
|
511 CleanupStack::Pop( self ); |
|
512 |
|
513 return self; |
|
514 } |
|
515 |
|
516 // ------------------------------------------------------------------------ |
|
517 // CPeninputVkbLayoutInfo::NewLC |
|
518 // (other items were commented in a header) |
|
519 // ------------------------------------------------------------------------ |
|
520 // |
|
521 EXPORT_C CPeninputVkbLayoutInfo* CPeninputVkbLayoutInfo::NewLC( |
|
522 TResourceReader& aReader ) |
|
523 { |
|
524 CPeninputVkbLayoutInfo* self = new ( ELeave ) CPeninputVkbLayoutInfo(); |
|
525 CleanupStack::PushL( self ); |
|
526 self->ConstructL( aReader ); |
|
527 |
|
528 return self; |
|
529 } |
|
530 |
|
531 // ------------------------------------------------------------------------ |
|
532 // CPeninputVkbLayoutInfo::GetRealSize |
|
533 // (other items were commented in a header) |
|
534 // ------------------------------------------------------------------------ |
|
535 // |
|
536 EXPORT_C const TSize CPeninputVkbLayoutInfo::GetRealSize( |
|
537 const TInt aUnitWidth, const TInt aUnitHeight ) const |
|
538 { |
|
539 return TSize( aUnitWidth * iColumns, aUnitHeight * iRows ); |
|
540 } |
|
541 |
|
542 EXPORT_C void CPeninputVkbLayoutInfo::ResetLayoutInfo(const TSize& aSize) |
|
543 { |
|
544 AknIconUtils::SetSize( iBgBmp, aSize, EAspectRatioNotPreserved ); |
|
545 AknIconUtils::SetSize( iBgMaskBmp, aSize, EAspectRatioNotPreserved ); |
|
546 |
|
547 } |
|
548 |
|
549 EXPORT_C void CPeninputVkbLayoutInfo::SetKeyInfo(const TInt aRow, |
|
550 const TInt aColumn, |
|
551 const TRect& aKeyRect, |
|
552 const TRect& aCharRect, |
|
553 const CFont* aFont) |
|
554 { |
|
555 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
556 TInt count = keyInfoList.Count(); |
|
557 |
|
558 for (TInt i = 0; i < count; i++ ) |
|
559 { |
|
560 if (keyInfoList[i] && |
|
561 keyInfoList[i]->BeginColumn() == aColumn && |
|
562 keyInfoList[i]->BeginRow() == aRow) |
|
563 { |
|
564 keyInfoList[i]->Key()->SetRect( aKeyRect ); |
|
565 |
|
566 return; |
|
567 } |
|
568 } |
|
569 } |
|
570 |
|
571 |
|
572 // ------------------------------------------------------------------------ |
|
573 // CPeninputVkbLayoutInfo::ResetSize |
|
574 // (other items were commented in a header) |
|
575 // ------------------------------------------------------------------------ |
|
576 // |
|
577 EXPORT_C void CPeninputVkbLayoutInfo::ResetSize( |
|
578 const TInt aUnitWidth, |
|
579 const TInt aUnitHeight, |
|
580 const TInt aUnitCharWidth, |
|
581 const TInt aUnitCharHeight, |
|
582 const TPoint& aCharLeftTopPoint, |
|
583 const CFont* aFont ) |
|
584 { |
|
585 iUnitWidth = aUnitWidth; |
|
586 iUnitHeight = aUnitHeight; |
|
587 iUnitCharWidth = aUnitCharWidth; |
|
588 iUnitCharHeight = aUnitCharHeight; |
|
589 iCharLeftTopPoint = aCharLeftTopPoint; |
|
590 iFont = aFont; |
|
591 |
|
592 iLastTopLeft = TPoint( 0, 0 ); |
|
593 |
|
594 // 1.Resize bk bmp and mask bmp |
|
595 AknIconUtils::SetSize( iBgBmp, |
|
596 TSize( aUnitWidth * iColumns, aUnitHeight * iRows ), |
|
597 EAspectRatioNotPreserved ); |
|
598 AknIconUtils::SetSize( iBgMaskBmp, |
|
599 TSize( aUnitWidth * iColumns, aUnitHeight * iRows ), |
|
600 EAspectRatioNotPreserved ); |
|
601 |
|
602 // 2.Resize dim bmp and mask bmp |
|
603 AknIconUtils::SetSize( iDimBmp, TSize( aUnitWidth, aUnitHeight ), |
|
604 EAspectRatioNotPreserved ); |
|
605 AknIconUtils::SetSize( iDimMaskBmp, TSize( aUnitWidth, aUnitHeight ), |
|
606 EAspectRatioNotPreserved ); |
|
607 |
|
608 // 3.Resize all highlight bmp and mask bmp |
|
609 TInt count = iHighlightBmps.Count(); |
|
610 TInt i = 0; |
|
611 |
|
612 for ( i = 0; i < count; i++ ) |
|
613 { |
|
614 AknIconUtils::SetSize( iHighlightBmps[i], |
|
615 TSize( aUnitWidth, aUnitHeight ), EAspectRatioNotPreserved ); |
|
616 } |
|
617 |
|
618 count = iHighlightMaskBmps.Count(); |
|
619 for ( i = 0; i < count; i++ ) |
|
620 { |
|
621 AknIconUtils::SetSize( iHighlightMaskBmps[i], |
|
622 TSize( aUnitWidth, aUnitHeight ), EAspectRatioNotPreserved ); |
|
623 } |
|
624 |
|
625 // 4.For every key, reset the key rect and char rect |
|
626 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
627 count = keyInfoList.Count(); |
|
628 TPoint keyLeftTop; |
|
629 TInt rows; |
|
630 TInt columns; |
|
631 TRect rect; |
|
632 |
|
633 for ( i = 0; i < count; i++ ) |
|
634 { |
|
635 if ( keyInfoList[i]->Key() ) |
|
636 { |
|
637 if (keyInfoList[i]->BeginColumn() == 0) |
|
638 { |
|
639 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth, |
|
640 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
641 } |
|
642 else |
|
643 { |
|
644 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth - |
|
645 6 * keyInfoList[i]->BeginColumn(), |
|
646 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
647 } |
|
648 |
|
649 if (!iIrregular) |
|
650 { |
|
651 keyLeftTop = TPoint( keyInfoList[i]->BeginColumn() * aUnitWidth, |
|
652 keyInfoList[i]->BeginRow() * aUnitHeight ); |
|
653 } |
|
654 |
|
655 |
|
656 rows = keyInfoList[i]->EndRow() - keyInfoList[i]->BeginRow(); |
|
657 columns = keyInfoList[i]->EndColumn() |
|
658 - keyInfoList[i]->BeginColumn(); |
|
659 |
|
660 //Set key rect |
|
661 rect = TRect( keyLeftTop, TSize( columns * aUnitWidth, |
|
662 rows * aUnitHeight ) ); |
|
663 keyInfoList[i]->Key()->SetRect( rect ); |
|
664 } |
|
665 } |
|
666 } |
|
667 |
|
668 // ------------------------------------------------------------------------ |
|
669 // CPeninputVkbLayoutInfo::~CPeninputVkbLayoutInfo |
|
670 // (other items were commented in a header) |
|
671 // ------------------------------------------------------------------------ |
|
672 // |
|
673 EXPORT_C CPeninputVkbLayoutInfo::~CPeninputVkbLayoutInfo() |
|
674 { |
|
675 delete iBgBmp; |
|
676 iBgBmp = NULL; |
|
677 delete iBgMaskBmp; |
|
678 iBgMaskBmp = NULL; |
|
679 delete iDimBmp; |
|
680 iDimBmp = NULL; |
|
681 delete iDimMaskBmp; |
|
682 iDimMaskBmp = NULL; |
|
683 |
|
684 iHighlightBmps.ResetAndDestroy(); |
|
685 iHighlightBmps.Close(); |
|
686 |
|
687 iHighlightMaskBmps.ResetAndDestroy(); |
|
688 iHighlightMaskBmps.Close(); |
|
689 |
|
690 iKeyInfoList.ResetAndDestroy(); |
|
691 iKeyInfoList.Close(); |
|
692 } |
|
693 |
|
694 // ------------------------------------------------------------------------ |
|
695 // CPeninputVkbLayoutInfo::FindKey |
|
696 // (other items were commented in a header) |
|
697 // ------------------------------------------------------------------------ |
|
698 // |
|
699 EXPORT_C CPeninputVkbKeyInfo* CPeninputVkbLayoutInfo::FindKey( |
|
700 const TInt aUnicode ) const |
|
701 { |
|
702 const TInt count = iKeyInfoList.Count(); |
|
703 |
|
704 for ( TInt i = 0; i < count; i++ ) |
|
705 { |
|
706 if ( (*iKeyInfoList[i]->Unicode())[0] == aUnicode ) |
|
707 { |
|
708 return iKeyInfoList[i]; |
|
709 } |
|
710 } |
|
711 |
|
712 return NULL; |
|
713 } |
|
714 |
|
715 // ------------------------------------------------------------------------ |
|
716 // CPeninputVkbLayoutInfo::MoveKeys |
|
717 // (other items were commented in a header) |
|
718 // ------------------------------------------------------------------------ |
|
719 // |
|
720 EXPORT_C void CPeninputVkbLayoutInfo::MoveKeys( const TPoint& aTopLeft ) |
|
721 { |
|
722 RPointerArray<CPeninputVkbKeyInfo> keyInfoList = KeyInfoList(); |
|
723 const TInt count = keyInfoList.Count(); |
|
724 const TPoint difference = aTopLeft - iLastTopLeft; |
|
725 TRect rect; |
|
726 |
|
727 for ( TInt i = 0; i < count; i++ ) |
|
728 { |
|
729 if ( keyInfoList[i]->Key() ) |
|
730 { |
|
731 //Set key rect |
|
732 rect = keyInfoList[i]->Key()->Rect(); |
|
733 rect.SetRect( rect.iTl + difference, rect.Size() ); |
|
734 keyInfoList[i]->Key()->SetRect( rect ); |
|
735 } |
|
736 } |
|
737 |
|
738 iLastTopLeft = aTopLeft; |
|
739 } |
|
740 |
|
741 // ------------------------------------------------------------------------ |
|
742 // CPeninputVkbLayoutInfo::CPeninputVkbLayoutInfo |
|
743 // (other items were commented in a header) |
|
744 // ------------------------------------------------------------------------ |
|
745 // |
|
746 CPeninputVkbLayoutInfo::CPeninputVkbLayoutInfo() |
|
747 : iCharLeftTopPoint( TPoint(0,0) ) |
|
748 { |
|
749 iLastTopLeft = TPoint( 0, 0 ); |
|
750 } |
|
751 |
|
752 // ------------------------------------------------------------------------ |
|
753 // CPeninputVkbLayoutInfo::ConstructL |
|
754 // (other items were commented in a header) |
|
755 // ------------------------------------------------------------------------ |
|
756 // |
|
757 void CPeninputVkbLayoutInfo::ConstructL( TResourceReader& aReader ) |
|
758 { |
|
759 |
|
760 ConstructFromResourceL( aReader ); |
|
761 } |
|
762 |
|
763 // ------------------------------------------------------------------------ |
|
764 // CPeninputVkbLayoutInfo::ConstructFromResourceL |
|
765 // (other items were commented in a header) |
|
766 // ------------------------------------------------------------------------ |
|
767 // |
|
768 void CPeninputVkbLayoutInfo::ConstructFromResourceL( TResourceReader& aReader, |
|
769 CPeninputVkbCtrlExt* aVkbCtrl, |
|
770 TInt aVkbLayoutId ) |
|
771 { |
|
772 delete iBgBmp; |
|
773 iBgBmp = NULL; |
|
774 delete iBgMaskBmp; |
|
775 iBgMaskBmp = NULL; |
|
776 delete iDimBmp; |
|
777 iDimBmp = NULL; |
|
778 delete iDimMaskBmp; |
|
779 iDimMaskBmp = NULL; |
|
780 |
|
781 iHighlightBmps.ResetAndDestroy(); |
|
782 iHighlightBmps.Close(); |
|
783 |
|
784 iHighlightMaskBmps.ResetAndDestroy(); |
|
785 iHighlightMaskBmps.Close(); |
|
786 |
|
787 iKeyInfoList.ResetAndDestroy(); |
|
788 iKeyInfoList.Close(); |
|
789 |
|
790 iLayoutID = aReader.ReadInt16(); |
|
791 |
|
792 // Read the file name of the bmps |
|
793 TPtrC bmpFileName = aReader.ReadTPtrC(); |
|
794 TInt32 imgMajorSkinId = aReader.ReadInt32(); |
|
795 |
|
796 TInt layoutBmpId = aReader.ReadInt16(); |
|
797 TInt layoutBmpMaskId = aReader.ReadInt16(); |
|
798 TInt layoutBmpSkinId = aReader.ReadInt16(); |
|
799 |
|
800 TAknsItemID id; |
|
801 MAknsSkinInstance* skininstance = AknsUtils::SkinInstance(); |
|
802 |
|
803 id.Set(TInt( imgMajorSkinId ), layoutBmpSkinId); |
|
804 |
|
805 if ( layoutBmpId != KInvalidBmp) |
|
806 { |
|
807 if ( layoutBmpMaskId != KInvalidBmp) |
|
808 { |
|
809 AknsUtils::CreateIconL( skininstance, |
|
810 id, |
|
811 iBgBmp, |
|
812 iBgMaskBmp, |
|
813 bmpFileName, |
|
814 layoutBmpId, |
|
815 layoutBmpMaskId ); |
|
816 } |
|
817 else |
|
818 { |
|
819 AknsUtils::CreateIconL( skininstance, |
|
820 id, |
|
821 iBgBmp, |
|
822 bmpFileName, |
|
823 layoutBmpId ); |
|
824 } |
|
825 } |
|
826 |
|
827 TInt dimBmpId = aReader.ReadInt16(); |
|
828 TInt dimMaskBmpId = aReader.ReadInt16(); |
|
829 TInt dimBmpSkinId = aReader.ReadInt16(); |
|
830 |
|
831 id.Set( TInt( imgMajorSkinId ), dimBmpSkinId ); |
|
832 |
|
833 if ( dimBmpId != KInvalidBmp ) |
|
834 { |
|
835 if ( dimMaskBmpId != KInvalidBmp ) |
|
836 { |
|
837 AknsUtils::CreateIconL( skininstance, |
|
838 id, |
|
839 iDimBmp, |
|
840 iDimMaskBmp, |
|
841 bmpFileName, |
|
842 dimBmpId, |
|
843 dimMaskBmpId ); |
|
844 } |
|
845 else |
|
846 { |
|
847 AknsUtils::CreateIconL( skininstance, |
|
848 id, |
|
849 iDimBmp, |
|
850 bmpFileName, |
|
851 dimBmpId ); |
|
852 } |
|
853 } |
|
854 |
|
855 iColumns = aReader.ReadInt16(); |
|
856 iRows = aReader.ReadInt16(); |
|
857 |
|
858 TInt i; |
|
859 TInt count = aReader.ReadInt16(); |
|
860 TInt bmpId; |
|
861 |
|
862 for ( i = 0; i < count; i++ ) |
|
863 { |
|
864 bmpId = aReader.ReadInt16(); |
|
865 if ( bmpId != KInvalidBmp ) |
|
866 { |
|
867 CFbsBitmap* bmp = AknIconUtils::CreateIconL( bmpFileName, |
|
868 bmpId ); |
|
869 CleanupStack::PushL( bmp ); |
|
870 iHighlightBmps.Append( bmp ); |
|
871 CleanupStack::Pop( bmp ); |
|
872 } |
|
873 } |
|
874 |
|
875 count = aReader.ReadInt16(); |
|
876 for ( i = 0; i < count; i++ ) |
|
877 { |
|
878 bmpId = aReader.ReadInt16(); |
|
879 if ( bmpId != KInvalidBmp ) |
|
880 { |
|
881 CFbsBitmap* bmp = AknIconUtils::CreateIconL( bmpFileName, bmpId ); |
|
882 CleanupStack::PushL( bmp ); |
|
883 iHighlightMaskBmps.Append( bmp ); |
|
884 CleanupStack::Pop( bmp ); |
|
885 } |
|
886 } |
|
887 |
|
888 count = aReader.ReadInt16(); |
|
889 |
|
890 for ( i = 0; i < count; i++ ) |
|
891 { |
|
892 CPeninputVkbKeyInfo* keyInfo = CPeninputVkbKeyInfo::NewL( aReader ); |
|
893 keyInfo->SetIrregularKeyType(iColumns); |
|
894 iKeyInfoList.Append( keyInfo ); |
|
895 } |
|
896 |
|
897 if ( ( iLayoutID == aVkbLayoutId ) && ( aVkbCtrl ) ) |
|
898 { |
|
899 aVkbCtrl->ReorganizeVkbKeys( this ); |
|
900 } |
|
901 } |
|
902 // End Of File |
|