1 /* |
|
2 * Copyright (c) 2002-2004 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: Predictive candidate list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 #include <eikdef.h> |
|
31 #include <aknViewAppUi.h> |
|
32 #include <avkon.hrh> |
|
33 #include <aknPopup.h> |
|
34 #include <aknlists.h> |
|
35 |
|
36 #include "AknFepUiInterfacePanic.h" |
|
37 #include "AknFepUIAvkonCtrlJapanesePredictiveListBoxModel.h" |
|
38 #include "AknFepUIAvkonCtrlJapanesePredictiveListboxItemDrawer.h" |
|
39 #include "AknFepUIAvkonCtrlJapanesePredictiveListboxView.h" |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CAknFepUICtrlJapanesePredictiveListboxView::CurrentCandidateNo |
|
45 // Return the selected candidate number currently |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TInt CAknFepUICtrlJapanesePredictiveListboxView::CurrentCandidateNo() const |
|
49 { |
|
50 return iCurrentCandidateNo; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CAknFepUICtrlJapanesePredictiveListboxView::SetCurrentCandidateNo |
|
55 // Set current candidate number |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 TInt CAknFepUICtrlJapanesePredictiveListboxView::SetCurrentCandidateNo( |
|
59 TInt aCandidateNo) |
|
60 { |
|
61 iOldCandidateNo = iCurrentCandidateNo; |
|
62 iCurrentCandidateNo = aCandidateNo; |
|
63 |
|
64 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
65 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
66 |
|
67 const TInt itemIndex = model->SearchItemIndexFromCandidateNo(aCandidateNo); |
|
68 |
|
69 return itemIndex; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CPeninputJapanesePredictiveListBoxView::SetCurrentCandidateNo |
|
74 // Set current candidate number |
|
75 // ----------------------------------------------------------------------------- |
|
76 TInt CAknFepUICtrlJapanesePredictiveListboxView::SetCurrentCandidateNo( |
|
77 TInt aLineNo, const TPoint& aPoint) |
|
78 { |
|
79 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
80 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
81 |
|
82 iCurrentCandidateNo = model->SearchCandidateNoFromPosition(aLineNo, aPoint); |
|
83 |
|
84 return aLineNo; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CAknFepUICtrlJapanesePredictiveListboxView::PreviousItem |
|
89 // Return previous candidate number |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 TInt CAknFepUICtrlJapanesePredictiveListboxView::PreviousItem() |
|
93 { |
|
94 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
95 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
96 const TInt maximumItems = model->MaximumItems(); |
|
97 |
|
98 TInt itemindex = iCurrentCandidateNo - 1; |
|
99 if (itemindex < 0) |
|
100 { |
|
101 itemindex = maximumItems - 1; |
|
102 } |
|
103 |
|
104 return itemindex; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CAknFepUICtrlJapanesePredictiveListboxView::NextItem |
|
109 // Return next candidate number |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CAknFepUICtrlJapanesePredictiveListboxView::NextItem() |
|
113 { |
|
114 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
115 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
116 const TInt maximumItems = model->MaximumItems(); |
|
117 |
|
118 TInt itemindex = iCurrentCandidateNo +1; |
|
119 if (itemindex >= maximumItems) |
|
120 { |
|
121 itemindex = 0; |
|
122 } |
|
123 |
|
124 return itemindex; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CAknFepUICtrlJapanesePredictiveListboxView::PreviousLineItem |
|
129 // Return candidate number of previous line |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CAknFepUICtrlJapanesePredictiveListboxView::PreviousLineItem() |
|
133 { |
|
134 TInt currentItemIndex = CurrentItemIndex(); |
|
135 TPredictivePopupElement currentElement; |
|
136 |
|
137 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
138 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
139 CPredictivePopupLineInfoArray* lineInfoArray = model->LineInfoArray(); |
|
140 const TInt lineInfoArrayCount = lineInfoArray->Count(); |
|
141 |
|
142 TInt previousItemIndex = currentItemIndex; |
|
143 TInt previousCandidateNo = -1; |
|
144 |
|
145 if (model->SearchElement( |
|
146 currentItemIndex, iCurrentCandidateNo, currentElement)) |
|
147 { |
|
148 do |
|
149 { |
|
150 previousItemIndex--; |
|
151 if (previousItemIndex < 0) |
|
152 { |
|
153 previousItemIndex = lineInfoArrayCount - 1; |
|
154 } |
|
155 |
|
156 if (previousItemIndex == currentItemIndex) |
|
157 { |
|
158 break; // in case one loop |
|
159 } |
|
160 |
|
161 CPredictivePopupLineInfo* lineInfo = |
|
162 lineInfoArray->At(previousItemIndex); |
|
163 |
|
164 CPredictivePopupElementArray* elementArray = |
|
165 lineInfo->iElementsOnLine; |
|
166 |
|
167 const TInt numberOfElement = elementArray->Count(); |
|
168 TInt lastCandidateNo = -1; |
|
169 TInt i; |
|
170 for (i = 0; i < numberOfElement; i++) |
|
171 { |
|
172 TPredictivePopupElement element = elementArray->At(i); |
|
173 if (currentElement.iStartXPos >= element.iStartXPos |
|
174 && currentElement.iStartXPos < element.iEndXPos) |
|
175 { |
|
176 previousCandidateNo = element.iCandidateNo; |
|
177 break; |
|
178 } |
|
179 else if (currentElement.iStartXPos < element.iStartXPos) |
|
180 { |
|
181 previousCandidateNo = element.iCandidateNo; |
|
182 break; |
|
183 } |
|
184 |
|
185 lastCandidateNo = element.iCandidateNo; |
|
186 } |
|
187 |
|
188 if (previousCandidateNo == -1) |
|
189 { |
|
190 previousCandidateNo = lastCandidateNo; |
|
191 } |
|
192 } |
|
193 while (previousCandidateNo == iCurrentCandidateNo); |
|
194 } |
|
195 |
|
196 if (previousCandidateNo == -1) |
|
197 { |
|
198 previousCandidateNo = iCurrentCandidateNo; |
|
199 } |
|
200 |
|
201 return previousCandidateNo; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CAknFepUICtrlJapanesePredictiveListboxView::NextLineItem |
|
206 // Return candidate number of next line |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 TInt CAknFepUICtrlJapanesePredictiveListboxView::NextLineItem() |
|
210 { |
|
211 TInt currentItemIndex = CurrentItemIndex(); |
|
212 TPredictivePopupElement currentElement; |
|
213 |
|
214 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
215 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
216 |
|
217 CPredictivePopupLineInfoArray* lineInfoArray = model->LineInfoArray(); |
|
218 TInt nextCandidateNo = -1; |
|
219 |
|
220 if (lineInfoArray) |
|
221 { |
|
222 const TInt lineInfoArrayCount = lineInfoArray->Count(); |
|
223 |
|
224 TInt nextItemIndex = currentItemIndex; |
|
225 |
|
226 if (model->SearchElement( |
|
227 currentItemIndex, iCurrentCandidateNo, currentElement)) |
|
228 { |
|
229 do |
|
230 { |
|
231 nextItemIndex++; |
|
232 if (nextItemIndex >= lineInfoArrayCount) |
|
233 { |
|
234 nextItemIndex = 0; |
|
235 } |
|
236 |
|
237 if (nextItemIndex == currentItemIndex) |
|
238 { |
|
239 break; // in case one loop |
|
240 } |
|
241 |
|
242 CPredictivePopupLineInfo* lineInfo = |
|
243 lineInfoArray->At(nextItemIndex); |
|
244 |
|
245 CPredictivePopupElementArray* elementArray = |
|
246 lineInfo->iElementsOnLine; |
|
247 |
|
248 const TInt numberOfElement = elementArray->Count(); |
|
249 TInt lastCandidateNo = -1; |
|
250 TInt i; |
|
251 for (i = 0; i < numberOfElement; i++) |
|
252 { |
|
253 TPredictivePopupElement element = elementArray->At(i); |
|
254 if (currentElement.iStartXPos >= element.iStartXPos |
|
255 && currentElement.iStartXPos < element.iEndXPos) |
|
256 { |
|
257 nextCandidateNo = element.iCandidateNo; |
|
258 break; |
|
259 } |
|
260 else if (currentElement.iStartXPos < element.iStartXPos) |
|
261 { |
|
262 nextCandidateNo = element.iCandidateNo; |
|
263 break; |
|
264 } |
|
265 |
|
266 lastCandidateNo = element.iCandidateNo; |
|
267 } |
|
268 |
|
269 if (nextCandidateNo == -1) |
|
270 { |
|
271 nextCandidateNo = lastCandidateNo; |
|
272 } |
|
273 } |
|
274 while (nextCandidateNo == iCurrentCandidateNo); |
|
275 } |
|
276 } |
|
277 if (nextCandidateNo == -1) |
|
278 { |
|
279 nextCandidateNo = iCurrentCandidateNo; |
|
280 } |
|
281 return nextCandidateNo; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CAknFepUICtrlJapanesePredictiveListboxView::DrawItem |
|
286 // Drawing item |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 void CAknFepUICtrlJapanesePredictiveListboxView::DrawItem(TInt aItemIndex) const |
|
290 { |
|
291 if (RedrawDisabled() || !IsVisible()) |
|
292 return; |
|
293 |
|
294 if (((aItemIndex > -1) && (aItemIndex < iModel->NumberOfItems())) |
|
295 && ItemIsVisible(aItemIndex)) |
|
296 { |
|
297 TInt highlightStartXPos = 0; |
|
298 TInt highlightEndXPos = 0; |
|
299 |
|
300 TPredictivePopupElement currentElement; |
|
301 CAknFepUICtrlJapanesePredictiveListBoxModel* model = |
|
302 static_cast<CAknFepUICtrlJapanesePredictiveListBoxModel*>(iModel); |
|
303 |
|
304 if (model->SearchElement(aItemIndex, |
|
305 iCurrentCandidateNo, currentElement)) |
|
306 { |
|
307 highlightStartXPos = currentElement.iStartXPos; |
|
308 highlightEndXPos = currentElement.iEndXPos; |
|
309 } |
|
310 |
|
311 CAknFepUICtrlJapanesePredictiveListboxItemDrawer* itemDrawer = |
|
312 static_cast<CAknFepUICtrlJapanesePredictiveListboxItemDrawer*>(iItemDrawer); |
|
313 |
|
314 itemDrawer->DrawItem( |
|
315 aItemIndex, |
|
316 ItemPos(aItemIndex), |
|
317 ItemIsSelected(aItemIndex), |
|
318 (aItemIndex == iCurrentItemIndex), |
|
319 (iFlags & EEmphasized) > 0, (iFlags & EDimmed) > 0, |
|
320 highlightStartXPos, highlightEndXPos); |
|
321 } |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CAknFepUICtrlJapanesePredictiveListboxView::OldCandidateNo |
|
326 // Return the selected candidate number previously |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 TInt CAknFepUICtrlJapanesePredictiveListboxView::OldCandidateNo() const |
|
330 { |
|
331 return iOldCandidateNo; |
|
332 } |
|
333 |
|
334 // End of File |
|