|
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 <peninputlayout.h> |
|
20 #include <peninputlayoutbutton.h> |
|
21 #include <peninputlayoutvkb.h> |
|
22 #include <peninputrawkeybutton.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <fbs.h> |
|
25 |
|
26 #include "peninputitutcustomizationresourcemgr.h" |
|
27 #include "peninputgenericitutlayoutcontext.h" |
|
28 #include "peninputgenericitutdata.h" |
|
29 #include "peninputgenericitutdatamgr.h" |
|
30 #include "peninputgenericitutconverter.h" |
|
31 |
|
32 CItutCustomizedRscMgr* CItutCustomizedRscMgr::NewL(CFepUiLayout* aUiLayout, |
|
33 MItutLayoutContext* aLayoutContext) |
|
34 { |
|
35 CItutCustomizedRscMgr* self = new (ELeave) CItutCustomizedRscMgr(aUiLayout, aLayoutContext); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CItutCustomizedRscMgr::~CItutCustomizedRscMgr() |
|
43 { |
|
44 iAddedCtrls.Reset(); |
|
45 iAddedCtrls.Close(); |
|
46 |
|
47 iDimmedCtrls.Reset(); |
|
48 iDimmedCtrls.Close(); |
|
49 |
|
50 iHidedCtrls.Reset(); |
|
51 iHidedCtrls.Close(); |
|
52 |
|
53 iDimmedVKeys.Reset(); |
|
54 iDimmedVKeys.Close(); |
|
55 } |
|
56 |
|
57 void CItutCustomizedRscMgr::Restore() |
|
58 { |
|
59 // in customized case, only keypad's key and button can be dimmed |
|
60 for (TInt i = 0; i < iDimmedCtrls.Count(); i++) |
|
61 { |
|
62 static_cast<CButtonBase*>(iDimmedCtrls[i])->SetDimmed(EFalse); |
|
63 } |
|
64 iDimmedCtrls.Reset(); |
|
65 |
|
66 for (TInt i = 0; i < iHidedCtrls.Count(); i++) |
|
67 { |
|
68 iHidedCtrls[i]->Hide(EFalse); |
|
69 } |
|
70 iHidedCtrls.Reset(); |
|
71 |
|
72 for (TInt i = 0; i < iDimmedVKeys.Count(); i++) |
|
73 { |
|
74 iDimmedVKeys[i]->SetDimmed(EFalse); |
|
75 } |
|
76 iDimmedVKeys.Reset(); |
|
77 |
|
78 // hide all new created ctrl |
|
79 for (TInt i = 0; i < iAddedCtrls.Count(); i++) |
|
80 { |
|
81 iAddedCtrls[i].iCtrl->Hide(ETrue); |
|
82 } |
|
83 } |
|
84 |
|
85 void CItutCustomizedRscMgr::RemoveAddedCtrls() |
|
86 { |
|
87 for (TInt i = 0; i < iAddedCtrls.Count(); i++) |
|
88 { |
|
89 iUiLayout->RemoveControl(iAddedCtrls[i].iCtrl); |
|
90 } |
|
91 iAddedCtrls.Reset(); |
|
92 |
|
93 iNewCtrlId = ECtrlIdLastStdCtrl; |
|
94 } |
|
95 |
|
96 void CItutCustomizedRscMgr::CreateCustomizedRawKeyButtonL(TItutKey aKeyInfo) |
|
97 { |
|
98 CAknFepCtrlRawKeyButton* rawkeybtn = NULL; |
|
99 |
|
100 rawkeybtn = CAknFepCtrlRawKeyButton::NewL(iUiLayout, |
|
101 iNewCtrlId, |
|
102 KAknsIIDQsnFrFunctionButtonNormal, |
|
103 KAknsIIDQsnFrFunctionButtonPressed, |
|
104 KAknsIIDQsnFrFunctionButtonInactive, |
|
105 EEventRawKeyDownEvent, |
|
106 EEventRawKeyUpEvent); |
|
107 rawkeybtn->SetRect(TItutDataConverter::AnyToRect( |
|
108 iLayoutContext->DataMgr()->RequestData(aKeyInfo.iPos))); |
|
109 rawkeybtn->SetForgroundBmpRect(TItutDataConverter::AnyToRect( |
|
110 iLayoutContext->DataMgr()->RequestData(aKeyInfo.iInnerPos))); |
|
111 rawkeybtn->SetScanCode(aKeyInfo.iScanCode); |
|
112 |
|
113 TItutBmp itutbmp = aKeyInfo.iForgroundBmp; |
|
114 |
|
115 if (IsBmpValid(itutbmp)) |
|
116 { |
|
117 CFbsBitmap* bmp = new (ELeave) CFbsBitmap; |
|
118 CleanupStack::PushL(bmp); |
|
119 bmp->Duplicate(itutbmp.iBmpHandle); |
|
120 CleanupStack::Pop(bmp); |
|
121 |
|
122 if (IsMaskBmpValid(itutbmp)) |
|
123 { |
|
124 CFbsBitmap* maskbmp = new (ELeave) CFbsBitmap; |
|
125 CleanupStack::PushL(maskbmp); |
|
126 maskbmp->Duplicate(itutbmp.iMaskBmpHandle); |
|
127 CleanupStack::Pop(maskbmp); |
|
128 |
|
129 rawkeybtn->SetForegroundBmpL(bmp, maskbmp); |
|
130 } |
|
131 else |
|
132 { |
|
133 rawkeybtn->SetForegroundBmpL(bmp, NULL); |
|
134 } |
|
135 } |
|
136 |
|
137 rawkeybtn->SetTextL(aKeyInfo.iText); |
|
138 rawkeybtn->SetTextFormat(aKeyInfo.iTextFormat); |
|
139 |
|
140 TAddedRawKeyCtrl newctrl = {aKeyInfo.iPos, aKeyInfo.iInnerPos, |
|
141 aKeyInfo.iTextFormat, rawkeybtn}; |
|
142 |
|
143 iUiLayout->AddControlL(rawkeybtn); |
|
144 iAddedCtrls.AppendL(newctrl); |
|
145 rawkeybtn->Draw(); |
|
146 iUiLayout->UpdateArea(rawkeybtn, rawkeybtn->Rect(), EFalse); |
|
147 iNewCtrlId++; |
|
148 } |
|
149 |
|
150 void CItutCustomizedRscMgr::ResizeAddedCtrls() |
|
151 { |
|
152 for (TInt i = 0; i < iAddedCtrls.Count(); i++) |
|
153 { |
|
154 iAddedCtrls[i].iCtrl->SetTextFormat(iAddedCtrls[i].iTextFormat); |
|
155 iAddedCtrls[i].iCtrl->SizeChanged( |
|
156 TItutDataConverter::AnyToRect( |
|
157 iLayoutContext->DataMgr()->RequestData(iAddedCtrls[i].iPos)), |
|
158 TItutDataConverter::AnyToRect( |
|
159 iLayoutContext->DataMgr()->RequestData(iAddedCtrls[i].iInnerPos)), |
|
160 ETrue); |
|
161 } |
|
162 } |
|
163 |
|
164 TInt CItutCustomizedRscMgr::AddDimmedCtrl(CFepUiBaseCtrl* aCtrl) |
|
165 { |
|
166 if (!aCtrl) |
|
167 { |
|
168 return KErrNone; |
|
169 } |
|
170 |
|
171 if (iDimmedCtrls.Find(aCtrl) == KErrNotFound) |
|
172 { |
|
173 return iDimmedCtrls.Append(aCtrl); |
|
174 } |
|
175 |
|
176 return KErrNone; |
|
177 } |
|
178 |
|
179 TInt CItutCustomizedRscMgr::AddDimmedVKey(CVirtualKey* aKey) |
|
180 { |
|
181 if (!aKey) |
|
182 { |
|
183 return KErrNone; |
|
184 } |
|
185 |
|
186 if (iDimmedVKeys.Find(aKey) == KErrNotFound) |
|
187 { |
|
188 return iDimmedVKeys.Append(aKey); |
|
189 } |
|
190 |
|
191 return KErrNone; |
|
192 } |
|
193 |
|
194 TInt CItutCustomizedRscMgr::AddHidedCtrl(CFepUiBaseCtrl* aCtrl) |
|
195 { |
|
196 if (!aCtrl) |
|
197 { |
|
198 return KErrNone; |
|
199 } |
|
200 |
|
201 if (iHidedCtrls.Find(aCtrl) == KErrNotFound) |
|
202 { |
|
203 aCtrl->Hide(ETrue); |
|
204 return iHidedCtrls.Append(aCtrl); |
|
205 } |
|
206 |
|
207 return KErrNone; |
|
208 } |
|
209 |
|
210 CItutCustomizedRscMgr::CItutCustomizedRscMgr( |
|
211 CFepUiLayout* aUiLayout, MItutLayoutContext* aLayoutContext) |
|
212 :iUiLayout(aUiLayout), |
|
213 iLayoutContext(aLayoutContext), |
|
214 iNewCtrlId(ECtrlIdLastStdCtrl) |
|
215 { |
|
216 } |
|
217 |
|
218 void CItutCustomizedRscMgr::ConstructL() |
|
219 { |
|
220 } |
|
221 |
|
222 TBool CItutCustomizedRscMgr::IsBmpValid(const TItutBmp& aBmp) |
|
223 { |
|
224 return aBmp.iBmpHandle != KInvalidBmp; |
|
225 } |
|
226 |
|
227 TBool CItutCustomizedRscMgr::IsMaskBmpValid(const TItutBmp& aMaskBmp) |
|
228 { |
|
229 return aMaskBmp.iMaskBmpHandle != KInvalidBmp; |
|
230 } |
|
231 |
|
232 TInt CItutCustomizedRscMgr::FindRawKeyBtn(TInt aScanCode) |
|
233 { |
|
234 for (TInt i = 0; i < iAddedCtrls.Count(); i++) |
|
235 { |
|
236 CAknFepCtrlRawKeyButton* rawkeybtn = |
|
237 static_cast<CAknFepCtrlRawKeyButton*>(iAddedCtrls[i].iCtrl); |
|
238 if (rawkeybtn->ScanCode() == aScanCode) |
|
239 { |
|
240 return i; |
|
241 } |
|
242 } |
|
243 |
|
244 return KErrNotFound; |
|
245 } |
|
246 |
|
247 void CItutCustomizedRscMgr::ShowRawKeyBtn(TInt aScanCode, TBool aShow) |
|
248 { |
|
249 for (TInt i = 0; i < iAddedCtrls.Count(); i++) |
|
250 { |
|
251 CAknFepCtrlRawKeyButton* rawkeybtn = |
|
252 static_cast<CAknFepCtrlRawKeyButton*>(iAddedCtrls[i].iCtrl); |
|
253 if (rawkeybtn->ScanCode() == aScanCode) |
|
254 { |
|
255 rawkeybtn->Hide(!aShow); |
|
256 return; |
|
257 } |
|
258 } |
|
259 } |
|
260 |
|
261 // End Of File |