|
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: drop-down list control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknFepGlobalEnums.h> |
|
20 #include <peninputgeneralitutnew.rsg> |
|
21 #include <peninputlayoutvkb.h> |
|
22 #include <peninputlayoutmultilineicf.h> |
|
23 #include <peninputcmdparam.h> |
|
24 #include <peninputlayoutbutton.h> |
|
25 |
|
26 #include "peninputitutwesternuistatecusotmization.h" |
|
27 #include "peninputgenericitutlayoutcontext.h" |
|
28 #include "peninputgenericitutuimgrbase.h" |
|
29 #include "peninputgenericitutdatamgr.h" |
|
30 #include "peninputitutcustomizationresourcemgr.h" |
|
31 #include "peninputgenericitutcustomization.h" |
|
32 #include "peninputgenericitutconverter.h" |
|
33 |
|
34 CWesternItutUiStateCustomization* CWesternItutUiStateCustomization::NewL( |
|
35 CGenericItutUiMgrBase* aOwner) |
|
36 { |
|
37 CWesternItutUiStateCustomization* self = |
|
38 new (ELeave) CWesternItutUiStateCustomization(aOwner); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CWesternItutUiStateCustomization::~CWesternItutUiStateCustomization() |
|
46 { |
|
47 if (iRscMgr) |
|
48 { |
|
49 iRscMgr->RemoveAddedCtrls(); |
|
50 delete iRscMgr; |
|
51 } |
|
52 } |
|
53 |
|
54 CWesternItutUiStateCustomization::CWesternItutUiStateCustomization( |
|
55 CGenericItutUiMgrBase* aOwner):CGenericItutUiStateBase(aOwner) |
|
56 { |
|
57 } |
|
58 |
|
59 void CWesternItutUiStateCustomization::ConstructL() |
|
60 { |
|
61 CGenericItutUiStateBase::ConstructL(); |
|
62 iRscMgr = CItutCustomizedRscMgr::NewL(iOwner->LayoutContext()->UiLayout(), |
|
63 iOwner->LayoutContext()); |
|
64 } |
|
65 |
|
66 void CWesternItutUiStateCustomization::OnEntryL() |
|
67 { |
|
68 } |
|
69 |
|
70 void CWesternItutUiStateCustomization::OnExit() |
|
71 { |
|
72 iRscMgr->Restore(); |
|
73 } |
|
74 |
|
75 TInt CWesternItutUiStateCustomization::HandleCommandL(TInt aCmd, TUint8* aData) |
|
76 { |
|
77 switch (aCmd) |
|
78 { |
|
79 case EItutExtCmdSetLayout: |
|
80 { |
|
81 TInt layouttype = *(reinterpret_cast<TInt*>(aData)); |
|
82 switch (layouttype) |
|
83 { |
|
84 case EItutLayoutNumeric: |
|
85 { |
|
86 iOwner->DataMgr()->NotifyChangeControlLayout( |
|
87 MItutPropertySubscriber::EItutPropertyKeypadResourceId, |
|
88 R_FINGER_INPUT_KEYPAD_NUMBER); |
|
89 break; |
|
90 } |
|
91 case EItutLayoutAlphabetic: |
|
92 { |
|
93 // should consider: if pin code need to support change keypad when case changed |
|
94 // should also consider: if pin code need to consider different keypad res id used for different |
|
95 // language script |
|
96 iOwner->DataMgr()->NotifyChangeControlLayout( |
|
97 MItutPropertySubscriber::EItutPropertyKeypadResourceId, |
|
98 iOwner->DataMgr()->KeypadResourceId()); |
|
99 break; |
|
100 } |
|
101 default: |
|
102 return KErrNotSupported; |
|
103 } |
|
104 |
|
105 return KErrNone; |
|
106 } |
|
107 case EItutExtCmdDimKey: |
|
108 { |
|
109 TInt keyidx = *(reinterpret_cast<TInt*>(aData)); |
|
110 |
|
111 if (IsKeyIdxValid(keyidx)) |
|
112 { |
|
113 DimKey(keyidx); |
|
114 } |
|
115 |
|
116 return KErrNone; |
|
117 } |
|
118 case EItutExtCmdHideKey: |
|
119 { |
|
120 TInt keyidx = *(reinterpret_cast<TInt*>(aData)); |
|
121 |
|
122 if (IsKeyIdxValid(keyidx)) |
|
123 { |
|
124 HideKey(keyidx); |
|
125 } |
|
126 |
|
127 return KErrNone; |
|
128 } |
|
129 case EItutExtCmdAddKey: |
|
130 { |
|
131 TItutKey itutkey = *(reinterpret_cast<TItutKey*>(aData)); |
|
132 |
|
133 if (iRscMgr->FindRawKeyBtn(itutkey.iScanCode) == KErrNotFound) |
|
134 { |
|
135 iRscMgr->CreateCustomizedRawKeyButtonL(itutkey); |
|
136 } |
|
137 else |
|
138 { |
|
139 iRscMgr->ShowRawKeyBtn(itutkey.iScanCode); |
|
140 } |
|
141 |
|
142 return KErrNone; |
|
143 } |
|
144 case EItutExtCmdSetIcfData: |
|
145 { |
|
146 TFepInputContextFieldData icfdata = |
|
147 *(reinterpret_cast<TFepInputContextFieldData*>(aData)); |
|
148 CFepLayoutMultiLineIcf* icffield = |
|
149 static_cast<CFepLayoutMultiLineIcf*>(iOwner->LayoutContext()->Control(ECtrlIdICF)); |
|
150 icffield->SetTextL(icfdata); |
|
151 } |
|
152 break; |
|
153 case EItutExtCmdSizeChanged: |
|
154 { |
|
155 iRscMgr->ResizeAddedCtrls(); |
|
156 } |
|
157 default: |
|
158 break; |
|
159 } |
|
160 |
|
161 return KErrNotSupported; |
|
162 } |
|
163 |
|
164 CGenericItutUiMgrBase::TUiState CWesternItutUiStateCustomization::StateType() |
|
165 { |
|
166 return CGenericItutUiMgrBase::EStateCustomization; |
|
167 } |
|
168 |
|
169 void CWesternItutUiStateCustomization::DimKey(TInt aKeyIndex) |
|
170 { |
|
171 TInt keyscancode = ItutKeymap[aKeyIndex].iScanCode; |
|
172 TInt ctrlid = ItutKeymap[aKeyIndex].iCtrlId; |
|
173 |
|
174 if (keyscancode != KInvalidScanCode) |
|
175 { |
|
176 CVirtualKeyboard* keypad = |
|
177 static_cast<CVirtualKeyboard*>(iOwner->LayoutContext()->Control(ECtrlIdStdItut)); |
|
178 CVirtualKey* dimkey = FindKeyByScanCode(keyscancode); |
|
179 keypad->DimKey(dimkey, ETrue); |
|
180 iRscMgr->AddDimmedVKey(dimkey); |
|
181 } |
|
182 else if (ctrlid != KInvalidCtrlId) |
|
183 { |
|
184 CButtonBase* btn = static_cast<CButtonBase*>(iOwner->LayoutContext()->Control(ctrlid)); |
|
185 btn->SetDimmed(ETrue); |
|
186 iRscMgr->AddDimmedCtrl(btn); |
|
187 } |
|
188 } |
|
189 |
|
190 void CWesternItutUiStateCustomization::HideKey(TInt aKeyIndex) |
|
191 { |
|
192 // cannot hide virtual key, only can hide button |
|
193 TInt ctrlid = ItutKeymap[aKeyIndex].iCtrlId; |
|
194 |
|
195 if (ctrlid != KInvalidCtrlId) |
|
196 { |
|
197 iRscMgr->AddHidedCtrl(iOwner->LayoutContext()->Control(ctrlid)); |
|
198 } |
|
199 } |
|
200 |
|
201 CVirtualKey* CWesternItutUiStateCustomization::FindKeyByScanCode(TInt aScanCode) |
|
202 { |
|
203 CVirtualKeyboard* keypad = |
|
204 static_cast<CVirtualKeyboard*>(iOwner->LayoutContext()->Control(ECtrlIdStdItut)); |
|
205 const RPointerArray<CVirtualKey>& keys = keypad->KeyArray(); |
|
206 |
|
207 for (TInt i = 0; i < keys.Count(); i++) |
|
208 { |
|
209 if (keys[i]->ScanCode() == aScanCode) |
|
210 { |
|
211 return keys[i]; |
|
212 } |
|
213 } |
|
214 |
|
215 return NULL; |
|
216 } |
|
217 |
|
218 TBool CWesternItutUiStateCustomization::IsKeyIdxValid(TInt aKeyIndex) |
|
219 { |
|
220 return (aKeyIndex >= 0 && aKeyIndex < sizeof(ItutKeymap)/sizeof(ItutKeymap[0])); |
|
221 } |
|
222 |
|
223 // End Of File |