--- a/textinput/peninputfingerhwrar/src/peninputfingerhwrarnumsymboltable.cpp Wed Sep 15 12:34:44 2010 +0300
+++ b/textinput/peninputfingerhwrar/src/peninputfingerhwrarnumsymboltable.cpp Wed Oct 13 14:55:58 2010 +0300
@@ -28,7 +28,7 @@
#include <AknLayoutDef.h>
#include <AknUtils.h>
#include <AknsUtils.h>
-#include <AknIconUtils.h>
+#include <akniconutils.h>
#include <aknfeppeninputenums.h>
#include <AknFepGlobalEnums.h>
@@ -41,9 +41,8 @@
#include "peninputfingerhwrarstoreconstants.h"
#include "peninputlayoutvkb.h"
#include "peninputfingerhwrarnumsymboltable.h"
-#include "peninputfingerhwarvkbutility.h"
-const TUint16 KInvalidChar = 0xFFFF;
+
// ---------------------------------------------------------------------------
// Symbian Constructor
// ---------------------------------------------------------------------------
@@ -100,25 +99,9 @@
{
CapturePointer( ETrue );
iPopupVisible = ETrue;
- UiLayout()->LockArea(UiLayout()->Rect(),this);
- // signal server to add the pop area
- if(UiLayout()->NotDrawToLayoutDevice())
- {
- struct SData
- {
- TRect rr;
- TBool flag;
- } data;
-
- data.rr = iNumKeypad->Rect();
- data.flag = ETrue;
- TPtrC ptrForAdd;
- ptrForAdd.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
-
- UiLayout()->SignalOwner(ESignalPopupArea,ptrForAdd);
- }
-
- RefreshNumSymbolTable();;
+ iCurrentNumSCTType = ENumSCTLatin;
+ UiLayout()->LockArea(UiLayout()->Rect(),this);
+ UpdateNumSymbolTable(ENumSCTLatin);
}
// ---------------------------------------------------------------------------
@@ -129,22 +112,6 @@
{
CapturePointer( EFalse );
iPopupVisible = EFalse;
- // signal server to remove the pop area
- if(UiLayout()->NotDrawToLayoutDevice())
- {
- struct SData
- {
- TRect rr;
- TBool flag;
- } data;
-
- data.rr = iNumKeypad->Rect();
- data.flag = EFalse;
- TPtrC ptrForRemove;
- ptrForRemove.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
-
- UiLayout()->SignalOwner(ESignalPopupArea,ptrForRemove);
- }
UiLayout()->UnLockArea(UiLayout()->Rect(),this);
}
@@ -243,10 +210,15 @@
// SizeChanged
// ---------------------------------------------------------------------------
//
-void CPeninputArabicFingerHwrNumSymbolTable::SizeChanged(const TRect& aVirtualKeypadRect)
+void CPeninputArabicFingerHwrNumSymbolTable::SizeChanged(
+ const TRect aVirtualKeypadRect, const RArray<TRect> /*aBtnRects*/,
+ const TInt /*aKeypadRow*/, const TInt /*aKeypadCol*/, TBool aIsLandscape)
{
+ iIsLandscape = aIsLandscape;
+
// relayout the virtual key pad
iNumKeypad->SetRect(aVirtualKeypadRect);
+
}
// ---------------------------------------------------------------------------
@@ -275,6 +247,11 @@
iNumKeypad->SetDrawOpaqueBackground( EFalse );
}
+void CPeninputArabicFingerHwrNumSymbolTable::OnActivate()
+ {
+ CControlGroup::OnActivate();
+ }
+
// ---------------------------------------------------------------------------
// Read control's background info.
// ---------------------------------------------------------------------------
@@ -362,7 +339,53 @@
//
void CPeninputArabicFingerHwrNumSymbolTable::LoadVkbKeyImageL(TInt aResId, const TSize& aKeySize)
{
- PeninputFingerHwrArVkbUtility::LoadVkbKeyImageL(*iNumKeypad,aResId,aKeySize);
+ TResourceReader reader;
+ CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
+
+ TPtrC bmpFileName = reader.ReadTPtrC();
+ TInt32 imgMajorSkinId = reader.ReadInt32();
+ TAknsItemID id;
+
+ TSize keySize = aKeySize;
+
+ for ( TInt index = 0; index <= EKeyBmpLastType ; index += 2 )
+ {
+ // Get the image ids and mask ids from resource
+ TInt bmpId = reader.ReadInt16();
+ TInt bmpMskId = reader.ReadInt16();
+
+ // read skin item id
+ const TInt skinitemid = reader.ReadInt16();
+ id.Set( TInt( imgMajorSkinId ), skinitemid );
+
+ if ( bmpId != KInvalidImg )
+ {
+ CFbsBitmap* bmp = NULL;
+ CFbsBitmap* maskbmp = NULL;
+
+ if ( bmpMskId != KInvalidImg )
+ {
+ AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
+ id, bmp, maskbmp, bmpFileName, bmpId, bmpMskId );
+
+ // set maskbmp and size
+ AknIconUtils::SetSize( maskbmp, keySize, EAspectRatioNotPreserved );
+ iNumKeypad->SetNonIrregularKeyBitmapL(
+ TVirtualKeyBmpType( EKeyBmpNormal + index + 1 ), maskbmp );
+ }
+ else
+ {
+ AknsUtils::CreateIconL( AknsUtils::SkinInstance(), id,
+ bmp, bmpFileName, bmpId );
+ }
+ // set bmp and size
+ AknIconUtils::SetSize( bmp, keySize, EAspectRatioNotPreserved );
+ iNumKeypad->SetNonIrregularKeyBitmapL(
+ TVirtualKeyBmpType( EKeyBmpNormal + index ), bmp );
+ }
+ }
+ // Pop and destroy reader
+ CleanupStack::PopAndDestroy( 1 );
}
// ---------------------------------------------------------------------------
@@ -371,57 +394,124 @@
//
void CPeninputArabicFingerHwrNumSymbolTable::LoadVirtualKeypadKeyL(const TInt aResId, const RArray<TRect>& aCellRects)
{
- PeninputFingerHwrArVkbUtility::LoadVirtualKeypadKeyL(*iNumKeypad,aResId,aCellRects);
+ iNumKeypad->SetResourceId(aResId);
+
+ TResourceReader reader;
+ CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
+
+ // construct keys
+ TInt resKeyCount = reader.ReadInt16();
+ TInt existsKeyCount = iNumKeypad->KeyArray().Count();
+ TInt rectCount = aCellRects.Count();
+
+ for ( TInt i = 0; i < resKeyCount; i++ )
+ {
+ if ( i < existsKeyCount )
+ {
+ CVirtualKey* vk = iNumKeypad->KeyArray()[i];
+ UpdateVkbKeyL( vk, reader, aCellRects[i%rectCount] );
+ }
+ else
+ {
+ CVirtualKey* vk = CreateVkbKeyL( reader, aCellRects[i%rectCount] );
+ CleanupStack::PushL( vk );
+ iNumKeypad->AddKeyL( vk );
+
+ CleanupStack::Pop( vk );
+ }
+ }
+
+ CleanupStack::PopAndDestroy( 1 ); // reader
+
+ iNumKeypad->Draw();
+ iNumKeypad->UpdateArea( iNumKeypad->Rect() );
}
// ---------------------------------------------------------------------------
+// create virtual key.
+// ---------------------------------------------------------------------------
+//
+CVirtualKey* CPeninputArabicFingerHwrNumSymbolTable::CreateVkbKeyL( TResourceReader& aReader,
+ const TRect aKeyRect )
+ {
+ CHBufCArray* keytexts = CHBufCArray::NewL();
+ CleanupStack::PushL( keytexts );
+
+ for ( TInt i = 0; i <= EPosLast; i++ )
+ {
+ HBufC* unicode = aReader.ReadHBufCL();
+ keytexts->Array().AppendL( unicode );
+ }
+
+ TInt keyscancode = aReader.ReadInt16();
+
+ HBufC* text = keytexts->Array()[0];
+
+ CVirtualKey* vk = NULL;
+ if ( text )
+ {
+ vk = CVirtualKey::NewL( *text, keyscancode, aKeyRect, aKeyRect, 0 );
+ }
+ else
+ {
+ vk = CVirtualKey::NewL( KNullDesC, keyscancode, aKeyRect, aKeyRect, 0 );
+ }
+
+ CleanupStack::PopAndDestroy( keytexts ); //keytexts
+
+
+ TRect innerrect = aKeyRect;
+ innerrect.Shrink( TSize(10, 10) );
+ vk->SetInnerRect( innerrect );
+
+ return vk;
+ }
+
+// ---------------------------------------------------------------------------
+// update virtual key info.
+// ---------------------------------------------------------------------------
+//
+void CPeninputArabicFingerHwrNumSymbolTable::UpdateVkbKeyL( CVirtualKey* aVirtualKey,
+ TResourceReader& aReader, const TRect aKeyRect )
+ {
+ CHBufCArray* keytexts = CHBufCArray::NewL();
+ CleanupStack::PushL( keytexts );
+
+ for ( TInt i = 0; i <= EPosLast; i++ )
+ {
+ HBufC* unicode = aReader.ReadHBufCL();
+ keytexts->Array().AppendL( unicode );
+ }
+
+ TInt keyscancode = aReader.ReadInt16();
+
+ HBufC* text = keytexts->Array()[0];
+ if ( text )
+ {
+ aVirtualKey->SetKeyData( *text );
+ }
+ else
+ {
+ aVirtualKey->SetKeyData( KNullDesC );
+ }
+
+ aVirtualKey->SetKeyScancode( keyscancode );
+
+ CleanupStack::PopAndDestroy( keytexts ); //keytexts
+
+ aVirtualKey->SetRect(aKeyRect);
+ TRect innerrect = aKeyRect;
+ innerrect.Shrink( TSize(10,10) );
+ aVirtualKey->SetInnerRect( innerrect );
+ }
+
+// ---------------------------------------------------------------------------
// accept editor's number mapping restriction.
// ---------------------------------------------------------------------------
//
-void CPeninputArabicFingerHwrNumSymbolTable::UpdateTableSymbol( const TDesC& aNumMapping )
+void CPeninputArabicFingerHwrNumSymbolTable::SetNumericMapping( const TDesC& aNumMapping )
{
- HBufC* charTable = GenerateCharTable(aNumMapping);
- if(charTable)
- {
- TInt charTalbeCount = charTable->Length();
-
- //numberpad
- TInt keyCount = iNumKeypad->KeyArray().Count();
- for ( TInt i = 0; i < keyCount; i++ )
- {
- CVirtualKey* vk = iNumKeypad->KeyArray()[i];
-
- if(i < charTalbeCount && (*charTable)[i] != KInvalidChar)
- {
- TBuf<1> keydata;
- TUint16 keyCode = (*charTable)[i];
- keydata.Append(keyCode);
- vk->SetKeyData(keydata);
- vk->SetKeyScancode(keyCode);
- vk->SetDimmed( EFalse );
- }
- else
- {
- vk->SetKeyData( KNullDesC );
- vk->SetKeyScancode( KInvalidChar );
- vk->SetDimmed( EFalse );
- }
- }
-
- delete charTable;
-
- //sync feedback
- UpdateAllVirtualKeysFeedback();
- }
- }
-
-// ---------------------------------------------------------------------------
-// Get reordered char table for key pad to render them
-// ---------------------------------------------------------------------------
-//
-HBufC* CPeninputArabicFingerHwrNumSymbolTable::GenerateCharTable(const TDesC& aNumMapping)
- {
- //format of aNumMapping is "0123456789******"
+ //format of aNumMapping is "0123456789******"
//char offset in aNumMapping
//cell 0 using aNumMapping[KNumOffsets[0]]
@@ -433,36 +523,49 @@
14, 7, 8, 9,
15, 10, 0, 11
};
- TInt tableSize = sizeof(KNumOffsets)/sizeof(TInt);
+
+ TInt maxMappingItemCount = sizeof(KNumOffsets)/sizeof(TInt);
TInt mappingItemCount = aNumMapping.Length();
- HBufC* reorderedCharTable = HBufC::New(mappingItemCount +1);
- if(reorderedCharTable)
- {
- for(TInt i = 0; i < tableSize; i++)
- {
- if(KNumOffsets[i] < mappingItemCount)
- {
- TUint16 unicode = aNumMapping[KNumOffsets[i]];
- TUint16 mappedCode = MapLatinNumAccordingToNumMode(unicode);
- reorderedCharTable->Des().Append(mappedCode);
- }
- else
- {
- reorderedCharTable->Des().Append(KInvalidChar);
- }
- }
- }
+ //numberpad
+ TInt keyCount = iNumKeypad->KeyArray().Count();
+ for ( TInt i = 0; i < keyCount; i++ )
+ {
+ CVirtualKey* vk = iNumKeypad->KeyArray()[i];
+
+ TInt offset = ( i < maxMappingItemCount ) ? KNumOffsets[i] : -1;
+
+ if ( offset > -1 && offset < mappingItemCount )
+ {
+ TUint16 unicode = aNumMapping[offset];
+ TUint16 mappedCode = MapLatinNumAccordingToNumMode(unicode);
+ TBuf<1> keydata;
+ keydata.Append(mappedCode);
+ vk->SetKeyData(keydata);
+ vk->SetKeyScancode( mappedCode);
+ vk->SetDimmed( EFalse );
+ }
+ else
+ {
+ vk->SetKeyData( KNullDesC );
+ vk->SetKeyScancode( 0xFFFF );
+ vk->SetDimmed( EFalse );
+ }
+ }
- return reorderedCharTable;
- }
-
+
+ //sync feedback
+ UpdateAllVirtualKeysFeedback();
+ }
+
// ---------------------------------------------------------------------------
// Navigate the symbol page
// ---------------------------------------------------------------------------
//
-void CPeninputArabicFingerHwrNumSymbolTable::RefreshNumSymbolTable()
- {
+void CPeninputArabicFingerHwrNumSymbolTable::UpdateNumSymbolTable( TInt aNumSctType)
+ {
+
+ iCurrentNumSCTType = aNumSctType;
// Draw the symbol table
Draw();
@@ -479,7 +582,7 @@
//
void CPeninputArabicFingerHwrNumSymbolTable::UpdateAllVirtualKeysFeedback()
{
- //update numpad keys
+ //update sctpad keys
TInt keyCount = iNumKeypad->KeyArray().Count();
for ( TInt i = 0; i < keyCount; i++ )
{
@@ -490,30 +593,6 @@
}
// ---------------------------------------------------------------------------
-// update rect of all virtual keys.
-// ---------------------------------------------------------------------------
-//
-void CPeninputArabicFingerHwrNumSymbolTable::UpdateAllVirtualKeysRect(const RArray<TRect> & aCellRects)
- {
- //update numpad keys rect
- TInt keyCount = iNumKeypad->KeyArray().Count();
- TInt rectCount = aCellRects.Count();
- if(keyCount != rectCount)
- {
- return;
- }
- for ( TInt i = 0; i < keyCount; i++ )
- {
- CVirtualKey* vk = iNumKeypad->KeyArray()[i];
- TRect rect = aCellRects[i%rectCount];
- vk->SetRect(aCellRects[i%rectCount]);
- TRect innerrect = rect;
- innerrect.Shrink( TSize(10,10) );
- vk->SetInnerRect( innerrect );
- }
- }
-
-// ---------------------------------------------------------------------------
// Draw new content to the screen
// ---------------------------------------------------------------------------
//