420 // Load virtual keys image |
417 // Load virtual keys image |
421 // --------------------------------------------------------------------------- |
418 // --------------------------------------------------------------------------- |
422 // |
419 // |
423 void CPeninputArabicFingerHwrSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize) |
420 void CPeninputArabicFingerHwrSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize) |
424 { |
421 { |
425 TResourceReader reader; |
422 PeninputFingerHwrArVkbUtility::LoadVkbKeyImageL(*iMutiPageKeypad,aResId,aKeySize); |
426 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId ); |
|
427 |
|
428 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
429 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
430 TAknsItemID id; |
|
431 |
|
432 TSize keySize = aKeySize; |
|
433 |
|
434 for ( TInt index = 0; index <= EKeyBmpLastType ; index += 2 ) |
|
435 { |
|
436 // Get the image ids and mask ids from resource |
|
437 TInt bmpId = reader.ReadInt16(); |
|
438 TInt bmpMskId = reader.ReadInt16(); |
|
439 |
|
440 // read skin item id |
|
441 const TInt skinitemid = reader.ReadInt16(); |
|
442 id.Set( TInt( imgMajorSkinId ), skinitemid ); |
|
443 |
|
444 if ( bmpId != KInvalidImg ) |
|
445 { |
|
446 CFbsBitmap* bmp = NULL; |
|
447 CFbsBitmap* maskbmp = NULL; |
|
448 |
|
449 if ( bmpMskId != KInvalidImg ) |
|
450 { |
|
451 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
452 id, bmp, maskbmp, bmpFileName, bmpId, bmpMskId ); |
|
453 |
|
454 // set maskbmp and size |
|
455 AknIconUtils::SetSize( maskbmp, keySize, EAspectRatioNotPreserved ); |
|
456 iMutiPageKeypad->SetNonIrregularKeyBitmapL( |
|
457 TVirtualKeyBmpType( EKeyBmpNormal + index + 1 ), maskbmp ); |
|
458 } |
|
459 else |
|
460 { |
|
461 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), id, |
|
462 bmp, bmpFileName, bmpId ); |
|
463 } |
|
464 // set bmp and size |
|
465 AknIconUtils::SetSize( bmp, keySize, EAspectRatioNotPreserved ); |
|
466 iMutiPageKeypad->SetNonIrregularKeyBitmapL( |
|
467 TVirtualKeyBmpType( EKeyBmpNormal + index ), bmp ); |
|
468 } |
|
469 } |
|
470 // Pop and destroy reader |
|
471 CleanupStack::PopAndDestroy( 1 ); |
|
472 } |
423 } |
473 |
424 |
474 // --------------------------------------------------------------------------- |
425 // --------------------------------------------------------------------------- |
475 // Load virtual keys |
426 // Load virtual keys |
476 // --------------------------------------------------------------------------- |
427 // --------------------------------------------------------------------------- |
477 // |
428 // |
478 void CPeninputArabicFingerHwrSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects) |
429 void CPeninputArabicFingerHwrSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects) |
479 { |
430 { |
480 iMutiPageKeypad->SetResourceId(aResId); |
431 PeninputFingerHwrArVkbUtility::LoadVirtualKeypadKeyL(*iMutiPageKeypad,aResId,aCellRects); |
481 |
432 } |
482 TResourceReader reader; |
|
483 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId ); |
|
484 |
|
485 // construct keys |
|
486 TInt resKeyCount = reader.ReadInt16(); |
|
487 TInt existsKeyCount = iMutiPageKeypad->KeyArray().Count(); |
|
488 TInt rectCount = aCellRects.Count(); |
|
489 |
|
490 for ( TInt i = 0; i < resKeyCount; i++ ) |
|
491 { |
|
492 if ( i < existsKeyCount ) |
|
493 { |
|
494 CVirtualKey* vk = iMutiPageKeypad->KeyArray()[i]; |
|
495 UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] ); |
|
496 } |
|
497 else |
|
498 { |
|
499 CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] ); |
|
500 CleanupStack::PushL( vk ); |
|
501 iMutiPageKeypad->AddKeyL( vk ); |
|
502 |
|
503 CleanupStack::Pop( vk ); |
|
504 } |
|
505 } |
|
506 |
|
507 CleanupStack::PopAndDestroy( 1 ); // reader |
|
508 |
|
509 iMutiPageKeypad->Draw(); |
|
510 iMutiPageKeypad->UpdateArea( iMutiPageKeypad->Rect() ); |
|
511 } |
|
512 |
|
513 // --------------------------------------------------------------------------- |
|
514 // create virtual key. |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 CVirtualKey* CPeninputArabicFingerHwrSymbolTable::CreateVkbKeyL( TResourceReader& aReader, |
|
518 const TRect aKeyRect ) |
|
519 { |
|
520 CHBufCArray* keytexts = CHBufCArray::NewL(); |
|
521 CleanupStack::PushL( keytexts ); |
|
522 |
|
523 for ( TInt i = 0; i <= EPosLast; i++ ) |
|
524 { |
|
525 HBufC* unicode = aReader.ReadHBufCL(); |
|
526 keytexts->Array().AppendL( unicode ); |
|
527 } |
|
528 |
|
529 TInt keyscancode = aReader.ReadInt16(); |
|
530 |
|
531 HBufC* text = keytexts->Array()[0]; |
|
532 |
|
533 CVirtualKey* vk = NULL; |
|
534 if ( text ) |
|
535 { |
|
536 vk = CVirtualKey::NewL( *text, keyscancode, aKeyRect, aKeyRect, 0 ); |
|
537 } |
|
538 else |
|
539 { |
|
540 vk = CVirtualKey::NewL( KNullDesC, keyscancode, aKeyRect, aKeyRect, 0 ); |
|
541 } |
|
542 |
|
543 CleanupStack::PopAndDestroy( keytexts ); //keytexts |
|
544 |
|
545 |
|
546 TRect innerrect = aKeyRect; |
|
547 innerrect.Shrink( TSize(2, 2) ); |
|
548 vk->SetInnerRect( innerrect ); |
|
549 |
|
550 return vk; |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 // update virtual key info. |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 void CPeninputArabicFingerHwrSymbolTable::UpdateVkbKeyL( CVirtualKey* aVirtualKey, |
|
558 TResourceReader& aReader, const TRect aKeyRect ) |
|
559 { |
|
560 CHBufCArray* keytexts = CHBufCArray::NewL(); |
|
561 CleanupStack::PushL( keytexts ); |
|
562 |
|
563 for ( TInt i = 0; i <= EPosLast; i++ ) |
|
564 { |
|
565 HBufC* unicode = aReader.ReadHBufCL(); |
|
566 keytexts->Array().AppendL( unicode ); |
|
567 } |
|
568 |
|
569 TInt keyscancode = aReader.ReadInt16(); |
|
570 |
|
571 HBufC* text = keytexts->Array()[0]; |
|
572 if ( text ) |
|
573 { |
|
574 aVirtualKey->SetKeyData( *text ); |
|
575 } |
|
576 else |
|
577 { |
|
578 aVirtualKey->SetKeyData( KNullDesC ); |
|
579 } |
|
580 |
|
581 aVirtualKey->SetKeyScancode( keyscancode ); |
|
582 |
|
583 CleanupStack::PopAndDestroy( keytexts ); //keytexts |
|
584 |
|
585 aVirtualKey->SetRect(aKeyRect); |
|
586 TRect innerrect = aKeyRect; |
|
587 innerrect.Shrink( TSize(2,2) ); |
|
588 aVirtualKey->SetInnerRect( innerrect ); |
|
589 } |
|
590 |
433 |
591 // --------------------------------------------------------------------------- |
434 // --------------------------------------------------------------------------- |
592 // Navigate the symbol page |
435 // Navigate the symbol page |
593 // --------------------------------------------------------------------------- |
436 // --------------------------------------------------------------------------- |
594 // |
437 // |