98 // |
97 // |
99 void CPeninputArabicFingerHwrNumSymbolTable::OpenSymbolTable() |
98 void CPeninputArabicFingerHwrNumSymbolTable::OpenSymbolTable() |
100 { |
99 { |
101 CapturePointer( ETrue ); |
100 CapturePointer( ETrue ); |
102 iPopupVisible = ETrue; |
101 iPopupVisible = ETrue; |
103 UiLayout()->LockArea(UiLayout()->Rect(),this); |
102 iCurrentNumSCTType = ENumSCTLatin; |
104 // signal server to add the pop area |
103 UiLayout()->LockArea(UiLayout()->Rect(),this); |
105 if(UiLayout()->NotDrawToLayoutDevice()) |
104 UpdateNumSymbolTable(ENumSCTLatin); |
106 { |
|
107 struct SData |
|
108 { |
|
109 TRect rr; |
|
110 TBool flag; |
|
111 } data; |
|
112 |
|
113 data.rr = iNumKeypad->Rect(); |
|
114 data.flag = ETrue; |
|
115 TPtrC ptrForAdd; |
|
116 ptrForAdd.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
117 |
|
118 UiLayout()->SignalOwner(ESignalPopupArea,ptrForAdd); |
|
119 } |
|
120 |
|
121 RefreshNumSymbolTable();; |
|
122 } |
105 } |
123 |
106 |
124 // --------------------------------------------------------------------------- |
107 // --------------------------------------------------------------------------- |
125 // cancel the popup. |
108 // cancel the popup. |
126 // --------------------------------------------------------------------------- |
109 // --------------------------------------------------------------------------- |
127 // |
110 // |
128 void CPeninputArabicFingerHwrNumSymbolTable::CloseSymbolTable() |
111 void CPeninputArabicFingerHwrNumSymbolTable::CloseSymbolTable() |
129 { |
112 { |
130 CapturePointer( EFalse ); |
113 CapturePointer( EFalse ); |
131 iPopupVisible = EFalse; |
114 iPopupVisible = EFalse; |
132 // signal server to remove the pop area |
|
133 if(UiLayout()->NotDrawToLayoutDevice()) |
|
134 { |
|
135 struct SData |
|
136 { |
|
137 TRect rr; |
|
138 TBool flag; |
|
139 } data; |
|
140 |
|
141 data.rr = iNumKeypad->Rect(); |
|
142 data.flag = EFalse; |
|
143 TPtrC ptrForRemove; |
|
144 ptrForRemove.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
145 |
|
146 UiLayout()->SignalOwner(ESignalPopupArea,ptrForRemove); |
|
147 } |
|
148 UiLayout()->UnLockArea(UiLayout()->Rect(),this); |
115 UiLayout()->UnLockArea(UiLayout()->Rect(),this); |
149 } |
116 } |
150 |
117 |
151 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
152 // get visibility of popup. |
119 // get visibility of popup. |
360 // Load virtual keys image |
337 // Load virtual keys image |
361 // --------------------------------------------------------------------------- |
338 // --------------------------------------------------------------------------- |
362 // |
339 // |
363 void CPeninputArabicFingerHwrNumSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize) |
340 void CPeninputArabicFingerHwrNumSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize) |
364 { |
341 { |
365 PeninputFingerHwrArVkbUtility::LoadVkbKeyImageL(*iNumKeypad,aResId,aKeySize); |
342 TResourceReader reader; |
|
343 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId ); |
|
344 |
|
345 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
346 TInt32 imgMajorSkinId = reader.ReadInt32(); |
|
347 TAknsItemID id; |
|
348 |
|
349 TSize keySize = aKeySize; |
|
350 |
|
351 for ( TInt index = 0; index <= EKeyBmpLastType ; index += 2 ) |
|
352 { |
|
353 // Get the image ids and mask ids from resource |
|
354 TInt bmpId = reader.ReadInt16(); |
|
355 TInt bmpMskId = reader.ReadInt16(); |
|
356 |
|
357 // read skin item id |
|
358 const TInt skinitemid = reader.ReadInt16(); |
|
359 id.Set( TInt( imgMajorSkinId ), skinitemid ); |
|
360 |
|
361 if ( bmpId != KInvalidImg ) |
|
362 { |
|
363 CFbsBitmap* bmp = NULL; |
|
364 CFbsBitmap* maskbmp = NULL; |
|
365 |
|
366 if ( bmpMskId != KInvalidImg ) |
|
367 { |
|
368 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
369 id, bmp, maskbmp, bmpFileName, bmpId, bmpMskId ); |
|
370 |
|
371 // set maskbmp and size |
|
372 AknIconUtils::SetSize( maskbmp, keySize, EAspectRatioNotPreserved ); |
|
373 iNumKeypad->SetNonIrregularKeyBitmapL( |
|
374 TVirtualKeyBmpType( EKeyBmpNormal + index + 1 ), maskbmp ); |
|
375 } |
|
376 else |
|
377 { |
|
378 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), id, |
|
379 bmp, bmpFileName, bmpId ); |
|
380 } |
|
381 // set bmp and size |
|
382 AknIconUtils::SetSize( bmp, keySize, EAspectRatioNotPreserved ); |
|
383 iNumKeypad->SetNonIrregularKeyBitmapL( |
|
384 TVirtualKeyBmpType( EKeyBmpNormal + index ), bmp ); |
|
385 } |
|
386 } |
|
387 // Pop and destroy reader |
|
388 CleanupStack::PopAndDestroy( 1 ); |
366 } |
389 } |
367 |
390 |
368 // --------------------------------------------------------------------------- |
391 // --------------------------------------------------------------------------- |
369 // Load virtual keys |
392 // Load virtual keys |
370 // --------------------------------------------------------------------------- |
393 // --------------------------------------------------------------------------- |
371 // |
394 // |
372 void CPeninputArabicFingerHwrNumSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects) |
395 void CPeninputArabicFingerHwrNumSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects) |
373 { |
396 { |
374 PeninputFingerHwrArVkbUtility::LoadVirtualKeypadKeyL(*iNumKeypad,aResId,aCellRects); |
397 iNumKeypad->SetResourceId(aResId); |
|
398 |
|
399 TResourceReader reader; |
|
400 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId ); |
|
401 |
|
402 // construct keys |
|
403 TInt resKeyCount = reader.ReadInt16(); |
|
404 TInt existsKeyCount = iNumKeypad->KeyArray().Count(); |
|
405 TInt rectCount = aCellRects.Count(); |
|
406 |
|
407 for ( TInt i = 0; i < resKeyCount; i++ ) |
|
408 { |
|
409 if ( i < existsKeyCount ) |
|
410 { |
|
411 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
|
412 UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] ); |
|
413 } |
|
414 else |
|
415 { |
|
416 CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] ); |
|
417 CleanupStack::PushL( vk ); |
|
418 iNumKeypad->AddKeyL( vk ); |
|
419 |
|
420 CleanupStack::Pop( vk ); |
|
421 } |
|
422 } |
|
423 |
|
424 CleanupStack::PopAndDestroy( 1 ); // reader |
|
425 |
|
426 iNumKeypad->Draw(); |
|
427 iNumKeypad->UpdateArea( iNumKeypad->Rect() ); |
375 } |
428 } |
376 |
429 |
377 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
|
431 // create virtual key. |
|
432 // --------------------------------------------------------------------------- |
|
433 // |
|
434 CVirtualKey* CPeninputArabicFingerHwrNumSymbolTable::CreateVkbKeyL( TResourceReader& aReader, |
|
435 const TRect aKeyRect ) |
|
436 { |
|
437 CHBufCArray* keytexts = CHBufCArray::NewL(); |
|
438 CleanupStack::PushL( keytexts ); |
|
439 |
|
440 for ( TInt i = 0; i <= EPosLast; i++ ) |
|
441 { |
|
442 HBufC* unicode = aReader.ReadHBufCL(); |
|
443 keytexts->Array().AppendL( unicode ); |
|
444 } |
|
445 |
|
446 TInt keyscancode = aReader.ReadInt16(); |
|
447 |
|
448 HBufC* text = keytexts->Array()[0]; |
|
449 |
|
450 CVirtualKey* vk = NULL; |
|
451 if ( text ) |
|
452 { |
|
453 vk = CVirtualKey::NewL( *text, keyscancode, aKeyRect, aKeyRect, 0 ); |
|
454 } |
|
455 else |
|
456 { |
|
457 vk = CVirtualKey::NewL( KNullDesC, keyscancode, aKeyRect, aKeyRect, 0 ); |
|
458 } |
|
459 |
|
460 CleanupStack::PopAndDestroy( keytexts ); //keytexts |
|
461 |
|
462 |
|
463 TRect innerrect = aKeyRect; |
|
464 innerrect.Shrink( TSize(10, 10) ); |
|
465 vk->SetInnerRect( innerrect ); |
|
466 |
|
467 return vk; |
|
468 } |
|
469 |
|
470 // --------------------------------------------------------------------------- |
|
471 // update virtual key info. |
|
472 // --------------------------------------------------------------------------- |
|
473 // |
|
474 void CPeninputArabicFingerHwrNumSymbolTable::UpdateVkbKeyL( CVirtualKey* aVirtualKey, |
|
475 TResourceReader& aReader, const TRect aKeyRect ) |
|
476 { |
|
477 CHBufCArray* keytexts = CHBufCArray::NewL(); |
|
478 CleanupStack::PushL( keytexts ); |
|
479 |
|
480 for ( TInt i = 0; i <= EPosLast; i++ ) |
|
481 { |
|
482 HBufC* unicode = aReader.ReadHBufCL(); |
|
483 keytexts->Array().AppendL( unicode ); |
|
484 } |
|
485 |
|
486 TInt keyscancode = aReader.ReadInt16(); |
|
487 |
|
488 HBufC* text = keytexts->Array()[0]; |
|
489 if ( text ) |
|
490 { |
|
491 aVirtualKey->SetKeyData( *text ); |
|
492 } |
|
493 else |
|
494 { |
|
495 aVirtualKey->SetKeyData( KNullDesC ); |
|
496 } |
|
497 |
|
498 aVirtualKey->SetKeyScancode( keyscancode ); |
|
499 |
|
500 CleanupStack::PopAndDestroy( keytexts ); //keytexts |
|
501 |
|
502 aVirtualKey->SetRect(aKeyRect); |
|
503 TRect innerrect = aKeyRect; |
|
504 innerrect.Shrink( TSize(10,10) ); |
|
505 aVirtualKey->SetInnerRect( innerrect ); |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
378 // accept editor's number mapping restriction. |
509 // accept editor's number mapping restriction. |
379 // --------------------------------------------------------------------------- |
510 // --------------------------------------------------------------------------- |
380 // |
511 // |
381 void CPeninputArabicFingerHwrNumSymbolTable::UpdateTableSymbol( const TDesC& aNumMapping ) |
512 void CPeninputArabicFingerHwrNumSymbolTable::SetNumericMapping( const TDesC& aNumMapping ) |
382 { |
513 { |
383 HBufC* charTable = GenerateCharTable(aNumMapping); |
514 //format of aNumMapping is "0123456789******" |
384 if(charTable) |
|
385 { |
|
386 TInt charTalbeCount = charTable->Length(); |
|
387 |
|
388 //numberpad |
|
389 TInt keyCount = iNumKeypad->KeyArray().Count(); |
|
390 for ( TInt i = 0; i < keyCount; i++ ) |
|
391 { |
|
392 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
|
393 |
|
394 if(i < charTalbeCount && (*charTable)[i] != KInvalidChar) |
|
395 { |
|
396 TBuf<1> keydata; |
|
397 TUint16 keyCode = (*charTable)[i]; |
|
398 keydata.Append(keyCode); |
|
399 vk->SetKeyData(keydata); |
|
400 vk->SetKeyScancode(keyCode); |
|
401 vk->SetDimmed( EFalse ); |
|
402 } |
|
403 else |
|
404 { |
|
405 vk->SetKeyData( KNullDesC ); |
|
406 vk->SetKeyScancode( KInvalidChar ); |
|
407 vk->SetDimmed( EFalse ); |
|
408 } |
|
409 } |
|
410 |
|
411 delete charTable; |
|
412 |
|
413 //sync feedback |
|
414 UpdateAllVirtualKeysFeedback(); |
|
415 } |
|
416 } |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // Get reordered char table for key pad to render them |
|
420 // --------------------------------------------------------------------------- |
|
421 // |
|
422 HBufC* CPeninputArabicFingerHwrNumSymbolTable::GenerateCharTable(const TDesC& aNumMapping) |
|
423 { |
|
424 //format of aNumMapping is "0123456789******" |
|
425 |
515 |
426 //char offset in aNumMapping |
516 //char offset in aNumMapping |
427 //cell 0 using aNumMapping[KNumOffsets[0]] |
517 //cell 0 using aNumMapping[KNumOffsets[0]] |
428 //cell 1 using aNumMapping[KNumOffsets[1]] |
518 //cell 1 using aNumMapping[KNumOffsets[1]] |
429 const TInt KNumOffsets[] = |
519 const TInt KNumOffsets[] = |
431 12, 1, 2, 3, |
521 12, 1, 2, 3, |
432 13, 4, 5, 6, |
522 13, 4, 5, 6, |
433 14, 7, 8, 9, |
523 14, 7, 8, 9, |
434 15, 10, 0, 11 |
524 15, 10, 0, 11 |
435 }; |
525 }; |
436 TInt tableSize = sizeof(KNumOffsets)/sizeof(TInt); |
526 |
|
527 TInt maxMappingItemCount = sizeof(KNumOffsets)/sizeof(TInt); |
437 TInt mappingItemCount = aNumMapping.Length(); |
528 TInt mappingItemCount = aNumMapping.Length(); |
438 |
529 |
439 HBufC* reorderedCharTable = HBufC::New(mappingItemCount +1); |
530 //numberpad |
440 if(reorderedCharTable) |
531 TInt keyCount = iNumKeypad->KeyArray().Count(); |
441 { |
532 for ( TInt i = 0; i < keyCount; i++ ) |
442 for(TInt i = 0; i < tableSize; i++) |
533 { |
443 { |
534 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
444 if(KNumOffsets[i] < mappingItemCount) |
535 |
445 { |
536 TInt offset = ( i < maxMappingItemCount ) ? KNumOffsets[i] : -1; |
446 TUint16 unicode = aNumMapping[KNumOffsets[i]]; |
537 |
447 TUint16 mappedCode = MapLatinNumAccordingToNumMode(unicode); |
538 if ( offset > -1 && offset < mappingItemCount ) |
448 reorderedCharTable->Des().Append(mappedCode); |
539 { |
449 } |
540 TUint16 unicode = aNumMapping[offset]; |
450 else |
541 TUint16 mappedCode = MapLatinNumAccordingToNumMode(unicode); |
451 { |
542 TBuf<1> keydata; |
452 reorderedCharTable->Des().Append(KInvalidChar); |
543 keydata.Append(mappedCode); |
453 } |
544 vk->SetKeyData(keydata); |
454 } |
545 vk->SetKeyScancode( mappedCode); |
455 } |
546 vk->SetDimmed( EFalse ); |
456 |
547 } |
457 return reorderedCharTable; |
548 else |
458 } |
549 { |
459 |
550 vk->SetKeyData( KNullDesC ); |
|
551 vk->SetKeyScancode( 0xFFFF ); |
|
552 vk->SetDimmed( EFalse ); |
|
553 } |
|
554 } |
|
555 |
|
556 |
|
557 //sync feedback |
|
558 UpdateAllVirtualKeysFeedback(); |
|
559 } |
|
560 |
460 // --------------------------------------------------------------------------- |
561 // --------------------------------------------------------------------------- |
461 // Navigate the symbol page |
562 // Navigate the symbol page |
462 // --------------------------------------------------------------------------- |
563 // --------------------------------------------------------------------------- |
463 // |
564 // |
464 void CPeninputArabicFingerHwrNumSymbolTable::RefreshNumSymbolTable() |
565 void CPeninputArabicFingerHwrNumSymbolTable::UpdateNumSymbolTable( TInt aNumSctType) |
465 { |
566 { |
|
567 |
|
568 iCurrentNumSCTType = aNumSctType; |
466 // Draw the symbol table |
569 // Draw the symbol table |
467 Draw(); |
570 Draw(); |
468 |
571 |
469 // Update the feedback for the virtual key |
572 // Update the feedback for the virtual key |
470 UpdateAllVirtualKeysFeedback(); |
573 UpdateAllVirtualKeysFeedback(); |
477 // update feedback state of all virtual keys. |
580 // update feedback state of all virtual keys. |
478 // --------------------------------------------------------------------------- |
581 // --------------------------------------------------------------------------- |
479 // |
582 // |
480 void CPeninputArabicFingerHwrNumSymbolTable::UpdateAllVirtualKeysFeedback() |
583 void CPeninputArabicFingerHwrNumSymbolTable::UpdateAllVirtualKeysFeedback() |
481 { |
584 { |
482 //update numpad keys |
585 //update sctpad keys |
483 TInt keyCount = iNumKeypad->KeyArray().Count(); |
586 TInt keyCount = iNumKeypad->KeyArray().Count(); |
484 for ( TInt i = 0; i < keyCount; i++ ) |
587 for ( TInt i = 0; i < keyCount; i++ ) |
485 { |
588 { |
486 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
589 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
487 TBool enable = !vk->Dimmed(); |
590 TBool enable = !vk->Dimmed(); |
488 iNumKeypad->EnableKeyFeedback( vk, enable ); |
591 iNumKeypad->EnableKeyFeedback( vk, enable ); |
489 } |
592 } |
490 } |
|
491 |
|
492 // --------------------------------------------------------------------------- |
|
493 // update rect of all virtual keys. |
|
494 // --------------------------------------------------------------------------- |
|
495 // |
|
496 void CPeninputArabicFingerHwrNumSymbolTable::UpdateAllVirtualKeysRect(const RArray<TRect> & aCellRects) |
|
497 { |
|
498 //update numpad keys rect |
|
499 TInt keyCount = iNumKeypad->KeyArray().Count(); |
|
500 TInt rectCount = aCellRects.Count(); |
|
501 if(keyCount != rectCount) |
|
502 { |
|
503 return; |
|
504 } |
|
505 for ( TInt i = 0; i < keyCount; i++ ) |
|
506 { |
|
507 CVirtualKey* vk = iNumKeypad->KeyArray()[i]; |
|
508 TRect rect = aCellRects[i%rectCount]; |
|
509 vk->SetRect(aCellRects[i%rectCount]); |
|
510 TRect innerrect = rect; |
|
511 innerrect.Shrink( TSize(10,10) ); |
|
512 vk->SetInnerRect( innerrect ); |
|
513 } |
|
514 } |
593 } |
515 |
594 |
516 // --------------------------------------------------------------------------- |
595 // --------------------------------------------------------------------------- |
517 // Draw new content to the screen |
596 // Draw new content to the screen |
518 // --------------------------------------------------------------------------- |
597 // --------------------------------------------------------------------------- |