|
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: vkb number keymapping manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikon.hrh> |
|
20 |
|
21 #include "peninputvkbnumerickeymappingmgr.h" |
|
22 |
|
23 _LIT(KNumberString,"0123456789"); |
|
24 const TInt KMaxNumericString = 32; |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // ------------------------------------------------------------------------ |
|
29 // Constructor |
|
30 // ------------------------------------------------------------------------ |
|
31 // |
|
32 CAknFepVkbNumericKepMappingMgr* CAknFepVkbNumericKepMappingMgr::NewL(TResourceReader aReader) |
|
33 { |
|
34 CAknFepVkbNumericKepMappingMgr* self = NewLC(aReader); |
|
35 CleanupStack::Pop(self); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ------------------------------------------------------------------------ |
|
41 // Constructor |
|
42 // ------------------------------------------------------------------------ |
|
43 // |
|
44 CAknFepVkbNumericKepMappingMgr* CAknFepVkbNumericKepMappingMgr::NewLC(TResourceReader aReader) |
|
45 { |
|
46 CAknFepVkbNumericKepMappingMgr* self = new (ELeave) CAknFepVkbNumericKepMappingMgr(); |
|
47 |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(aReader); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ------------------------------------------------------------------------ |
|
55 // Constructor |
|
56 // ------------------------------------------------------------------------ |
|
57 // |
|
58 void CAknFepVkbNumericKepMappingMgr::ConstructL(TResourceReader aReader) |
|
59 { |
|
60 const TInt count = aReader.ReadInt16(); |
|
61 |
|
62 |
|
63 for (TInt i = 0; i < count; i++) |
|
64 { |
|
65 iKeyMappingIdList.Append(aReader.ReadInt16()); |
|
66 TPtrC ptr = aReader.ReadTPtrC(); |
|
67 iKeyMappingStringList.Append(ptr.Alloc()); |
|
68 } |
|
69 } |
|
70 |
|
71 // ------------------------------------------------------------------------ |
|
72 // Destructor |
|
73 // ------------------------------------------------------------------------ |
|
74 // |
|
75 CAknFepVkbNumericKepMappingMgr::~CAknFepVkbNumericKepMappingMgr() |
|
76 { |
|
77 iKeyMappingIdList.Reset(); |
|
78 iKeyMappingIdList.Close(); |
|
79 |
|
80 iKeyMappingStringList.ResetAndDestroy(); |
|
81 iKeyMappingStringList.Close(); |
|
82 } |
|
83 |
|
84 // ------------------------------------------------------------------------ |
|
85 // Get number keymapping string |
|
86 // ------------------------------------------------------------------------ |
|
87 // |
|
88 HBufC* CAknFepVkbNumericKepMappingMgr::KeyMappingStringL(const TInt aKeyMappingId) const |
|
89 { |
|
90 TLocale locale; |
|
91 TBuf<KMaxNumericString> rs = KNumberString(); |
|
92 const TInt index = iKeyMappingIdList.Find(aKeyMappingId); |
|
93 |
|
94 if (index != KErrNotFound) |
|
95 { |
|
96 HBufC* buf = iKeyMappingStringList[index]; |
|
97 |
|
98 rs.Append(*buf); |
|
99 |
|
100 if ((aKeyMappingId== EAknEditorCalculatorNumberModeKeymap) || |
|
101 (aKeyMappingId== EAknEditorConverterNumberModeKeymap)) |
|
102 { |
|
103 rs.Append(locale.DecimalSeparator()); |
|
104 } |
|
105 } |
|
106 |
|
107 return rs.AllocL(); |
|
108 } |
|
109 |
|
110 // ------------------------------------------------------------------------ |
|
111 // Get Keymapping id array item count |
|
112 // ------------------------------------------------------------------------ |
|
113 // |
|
114 TInt CAknFepVkbNumericKepMappingMgr::Count() const |
|
115 { |
|
116 return iKeyMappingIdList.Count(); |
|
117 } |
|
118 |
|
119 // ------------------------------------------------------------------------ |
|
120 // Remove all keymapping id and pointer in array |
|
121 // ------------------------------------------------------------------------ |
|
122 // |
|
123 void CAknFepVkbNumericKepMappingMgr::Reset() |
|
124 { |
|
125 iKeyMappingIdList.Reset(); |
|
126 iKeyMappingStringList.ResetAndDestroy(); |
|
127 } |
|
128 |
|
129 // End Of File |