|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 #include <fbs.h> |
|
18 #include <AknsUtils.h> |
|
19 #include <AknLayoutDef.h> |
|
20 #include <peninputdropdownlistcontext.h> |
|
21 |
|
22 #include "peninputdropdownlist.h" |
|
23 #include "peninputlayout.h" |
|
24 #include "peninputlistmultirowrollwithicon.h" |
|
25 |
|
26 // added by txin |
|
27 const TInt KInvalidCandIndex = -1; |
|
28 // end adding |
|
29 |
|
30 CListMultiRowRollWithIcon* CListMultiRowRollWithIcon::NewL(CListManager* aManager, |
|
31 MFepCtrlDropdownListContext* aOwner) |
|
32 { |
|
33 CListMultiRowRollWithIcon* self = new (ELeave) CListMultiRowRollWithIcon(aManager, aOwner); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CListMultiRowRollWithIcon::~CListMultiRowRollWithIcon() |
|
41 { |
|
42 iLines.Reset(); |
|
43 iLines.Close(); |
|
44 } |
|
45 |
|
46 void CListMultiRowRollWithIcon::HandlePointerDownL(const TPoint& aPoint) |
|
47 { |
|
48 CList::HandlePointerDownL(aPoint); |
|
49 |
|
50 // if press outside of expanded list, close it |
|
51 // also consider fuzzy boundary |
|
52 TRect fuzzyrect = iRect; |
|
53 fuzzyrect.Grow(iOwner->FuzzyBoundry(), iOwner->FuzzyBoundry()); |
|
54 |
|
55 if (!fuzzyrect.Contains(aPoint)) |
|
56 { |
|
57 iOwner->SetCapture(EFalse); |
|
58 |
|
59 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
60 { |
|
61 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
62 } |
|
63 else |
|
64 { |
|
65 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
66 } |
|
67 |
|
68 return; |
|
69 } |
|
70 |
|
71 // If click in navigation rect and NextButton is not disable, then do |
|
72 if ( iNavigationRect.Contains(aPoint) ) |
|
73 { |
|
74 if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable ) |
|
75 { |
|
76 #ifdef RD_TACTILE_FEEDBACK |
|
77 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
78 DoTactileFeedback(ETouchFeedbackBasic); |
|
79 #endif //RD_TACTILE_FEEDBACK |
|
80 iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr); |
|
81 iIndicateButtonClicked = ETrue; |
|
82 DrawSelection(iClickedRect, ETrue); |
|
83 } |
|
84 else if (!iOwner->PageCtrlShown()) |
|
85 { |
|
86 iClickedRect = KDummyRect; |
|
87 return; |
|
88 } |
|
89 else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable ) |
|
90 { |
|
91 #ifdef RD_TACTILE_FEEDBACK |
|
92 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
93 DoTactileFeedback(ETouchFeedbackBasic); |
|
94 #endif //RD_TACTILE_FEEDBACK |
|
95 iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr); |
|
96 iIndicateButtonClicked = ETrue; |
|
97 DrawSelection(iClickedRect, ETrue); |
|
98 } |
|
99 else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable ) |
|
100 { |
|
101 #ifdef RD_TACTILE_FEEDBACK |
|
102 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
103 DoTactileFeedback(ETouchFeedbackBasic); |
|
104 #endif //RD_TACTILE_FEEDBACK |
|
105 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
106 iIndicateButtonClicked = ETrue; |
|
107 DrawSelection(iClickedRect, ETrue); |
|
108 } |
|
109 else |
|
110 { |
|
111 iClickedRect = KDummyRect; |
|
112 } |
|
113 } |
|
114 } |
|
115 |
|
116 void CListMultiRowRollWithIcon::HandlePointerUpL(const TPoint& aPoint) |
|
117 { |
|
118 // Reset the button clicked flag to EFalse |
|
119 iIndicateButtonClicked = EFalse; |
|
120 |
|
121 #ifdef __WINS__ |
|
122 // in emulator, double click will be treated as: |
|
123 // 1 pointer down and 2 pointer up, which will cause error |
|
124 if (iClickedRect.IsEmpty() && ((CFepUiBaseCtrl*)iOwner)->PointerDown()) |
|
125 #else |
|
126 if (iClickedRect.IsEmpty()) |
|
127 #endif // __WINS__ |
|
128 { |
|
129 iOwner->SetCapture(EFalse); |
|
130 // Change active list object ie. close the dd-list |
|
131 |
|
132 // txin modify |
|
133 //iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
134 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
135 { |
|
136 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
137 } |
|
138 else |
|
139 { |
|
140 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
141 } |
|
142 // end |
|
143 } |
|
144 else |
|
145 { |
|
146 if ( iContentRect.Contains(aPoint) ) |
|
147 { |
|
148 if ( iClickedRect.Contains(aPoint) ) |
|
149 { |
|
150 // Redraw the selected aread |
|
151 DrawSelection(iClickedRect, EFalse); |
|
152 |
|
153 iOwner->SetCapture(EFalse); |
|
154 |
|
155 // We have selected a candidate and iClickedCandidateIndex is the selected Index. |
|
156 // Send the candidate to others |
|
157 if (iClickedCandidateIndex != KErrNotFound) |
|
158 { |
|
159 CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex); |
|
160 |
|
161 if (candidate) |
|
162 { |
|
163 iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(), |
|
164 iClickedCandidateIndex); |
|
165 } |
|
166 |
|
167 TInt lastIdxOfLine = StartCandIdxOfLine(iClickedCandidateIndex); |
|
168 |
|
169 TInt originalFirstCandIdx = iOwner->GetFirstCandidateIndex(); |
|
170 TInt originalLastCandIdx = iOwner->GetLastCandidateIndex(); |
|
171 |
|
172 if (lastIdxOfLine == KInvalidCandIndex) |
|
173 { |
|
174 lastIdxOfLine = iOwner->GetFirstCandidateIndex(); |
|
175 } |
|
176 |
|
177 iOwner->SetOneRowStartCandIdx(lastIdxOfLine); |
|
178 |
|
179 iOwner->AutoChangeActiveList(lastIdxOfLine); |
|
180 |
|
181 iOwner->SetOriginalFirstCandIdx(originalFirstCandIdx); |
|
182 } |
|
183 } |
|
184 } |
|
185 else if ( iNavigationCloseRect.Contains(aPoint) ) |
|
186 { |
|
187 if ( iNavigationCloseRect == iClickedRect ) |
|
188 { |
|
189 iOwner->SetCapture(EFalse); |
|
190 |
|
191 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
192 { |
|
193 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
194 } |
|
195 else |
|
196 { |
|
197 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
198 } |
|
199 } |
|
200 } |
|
201 else if (!iOwner->PageCtrlShown()) |
|
202 { |
|
203 iClickedRect = KEmptyRect; |
|
204 return; |
|
205 } |
|
206 else if ( iNavigationNextRect.Contains(aPoint) ) |
|
207 { |
|
208 if ( iNavigationNextRect == iClickedRect ) |
|
209 { |
|
210 iOwner->NotifyGetNextPage(); |
|
211 UpdateListL(); |
|
212 } |
|
213 } |
|
214 else if ( iNavigationPreviousRect.Contains(aPoint) ) |
|
215 { |
|
216 if ( iNavigationPreviousRect == iClickedRect ) |
|
217 { |
|
218 // Change page to previous |
|
219 iOwner->NotifyGetPreviousPage(); // do nothing, just to avoid clear candidate |
|
220 |
|
221 TInt firstIndex = 0; |
|
222 TInt lastIndex = 0; |
|
223 |
|
224 if (iOwner->GetPages()->GetPreviousIndex(iOwner->GetLastCandidateIndex(), |
|
225 firstIndex,lastIndex)) |
|
226 { |
|
227 iOwner->SetFirstCandidateIndex(firstIndex); |
|
228 iOwner->SetLastCandidateIndex(lastIndex); |
|
229 } |
|
230 |
|
231 UpdateListL(ETrue, EFalse); |
|
232 } |
|
233 } |
|
234 |
|
235 iClickedRect = KEmptyRect; |
|
236 } |
|
237 } |
|
238 |
|
239 void CListMultiRowRollWithIcon::SetNextPageHighlightCellAfterOnePageL(const TInt aCellIndex) |
|
240 { |
|
241 while (aCellIndex >= iOwner->GetLastCandidateIndex()) |
|
242 { |
|
243 UpdateListL(); |
|
244 } |
|
245 |
|
246 TInt lastIdxOfLine = StartCandIdxOfLine(aCellIndex); |
|
247 |
|
248 TInt originalFirstCandIdx = iOwner->GetFirstCandidateIndex(); |
|
249 TInt originalLastCandIdx = iOwner->GetLastCandidateIndex(); |
|
250 |
|
251 if (lastIdxOfLine == KInvalidCandIndex) |
|
252 { |
|
253 lastIdxOfLine = iOwner->GetFirstCandidateIndex(); |
|
254 } |
|
255 |
|
256 iOwner->SetOneRowStartCandIdx(lastIdxOfLine); |
|
257 |
|
258 iOwner->AutoChangeActiveList(lastIdxOfLine); |
|
259 |
|
260 iOwner->SetOriginalFirstCandIdx(originalFirstCandIdx); |
|
261 } |
|
262 |
|
263 CListMultiRowRollWithIcon::CListMultiRowRollWithIcon(CListManager* aManager, |
|
264 MFepCtrlDropdownListContext* aOwner): |
|
265 CListMultiRowWithIcon(aManager, aOwner) |
|
266 { |
|
267 iIsMultiRows = ETrue; |
|
268 } |
|
269 |
|
270 TInt CListMultiRowRollWithIcon::StartCandIdxOfLine(TInt aCandIndex) |
|
271 { |
|
272 TInt lineCnt = iLines.Count(); |
|
273 |
|
274 for (TInt i = 0; i < lineCnt; i++) |
|
275 { |
|
276 if ((aCandIndex >= iLines[i].iStartIdx) && (aCandIndex <= iLines[i].iEndIdx)) |
|
277 { |
|
278 return iLines[i].iStartIdx; |
|
279 } |
|
280 } |
|
281 |
|
282 return KInvalidCandIndex; |
|
283 } |
|
284 |
|
285 void CListMultiRowRollWithIcon::ResetStatus() |
|
286 { |
|
287 CList::ResetStatus(); |
|
288 iLines.Reset(); |
|
289 } |
|
290 |
|
291 TInt CListMultiRowRollWithIcon::CalculatePositionsL() |
|
292 { |
|
293 TLineCandidate lineCand; |
|
294 |
|
295 TInt t = 0; |
|
296 TPoint setpoints; |
|
297 TInt count = iOwner->CandidateCount(); |
|
298 CCandidate* candidate = NULL; |
|
299 |
|
300 if ( count > 0 ) |
|
301 { |
|
302 // modified by txin |
|
303 // original |
|
304 /* |
|
305 setpoints.iX = iContentRect.iTl.iX; |
|
306 setpoints.iY = iContentRect.iTl.iY; |
|
307 */ |
|
308 |
|
309 TBool candHLToR = (iOwner->CandHDirection() == CFepCtrlDropdownList::ECandFromLToR); // horizontal direction |
|
310 candHLToR ? setpoints.SetXY(iContentRect.iTl.iX, iContentRect.iTl.iY) : |
|
311 setpoints.SetXY(iContentRect.iBr.iX, iContentRect.iTl.iY); |
|
312 // end modify |
|
313 |
|
314 TInt currentCellIndex = 0; |
|
315 TInt lastUsedCellCount = 0; |
|
316 TInt lastusedRow = 0; |
|
317 iOwner->SetFirstCandidateIndex (iOwner->GetLastCandidateIndex()); |
|
318 count = Min(count, iOwner->GetLastCandidateIndex() + |
|
319 iOwner->GetColNum() * iOwner->GetRowNum() ); |
|
320 |
|
321 lineCand.iStartIdx = iOwner->GetLastCandidateIndex(); |
|
322 |
|
323 for(t = iOwner->GetLastCandidateIndex(); t < count ; t++) |
|
324 { |
|
325 candidate = iOwner->GetCandidate(t); |
|
326 |
|
327 if (!candidate) |
|
328 { |
|
329 continue; |
|
330 } |
|
331 |
|
332 lastUsedCellCount = candidate->SetPositionL(setpoints, |
|
333 iOwner->GetCellWidth(), |
|
334 iOwner->GetCellHeight(), |
|
335 iOwner->GetFont(), |
|
336 iOwner->GetCellHorizontalMargin()); |
|
337 currentCellIndex += lastUsedCellCount; |
|
338 if ( currentCellIndex > iOwner->GetColNum() ) |
|
339 { |
|
340 lastusedRow++; |
|
341 if ( lastusedRow >= iOwner->GetRowNum() ) |
|
342 { |
|
343 break; |
|
344 } |
|
345 |
|
346 currentCellIndex = 0; |
|
347 setpoints.iY = setpoints.iY + |
|
348 iOwner->GetCellHeight() + |
|
349 iOwner->GetCellVerticalMargin(); |
|
350 |
|
351 candHLToR ? (setpoints.iX = iContentRect.iTl.iX) : (setpoints.iX = iContentRect.iBr.iX); |
|
352 |
|
353 lastUsedCellCount = candidate->SetPositionL(setpoints, |
|
354 iOwner->GetCellWidth(), |
|
355 iOwner->GetCellHeight(), |
|
356 iOwner->GetFont(), |
|
357 iOwner->GetCellHorizontalMargin()); |
|
358 currentCellIndex += lastUsedCellCount; |
|
359 |
|
360 lineCand.iEndIdx = t - 1; |
|
361 iLines.Append(lineCand); |
|
362 |
|
363 lineCand.iStartIdx = t; |
|
364 |
|
365 candHLToR ? (setpoints.iX += lastUsedCellCount * (iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())) : |
|
366 (setpoints.iX -= lastUsedCellCount * (iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())); |
|
367 } |
|
368 else |
|
369 { |
|
370 candHLToR ? (setpoints.iX += lastUsedCellCount * (iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())) : |
|
371 (setpoints.iX -= lastUsedCellCount * (iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())); |
|
372 } |
|
373 } // for-loop |
|
374 } // if candidate exist |
|
375 |
|
376 lineCand.iEndIdx = t-1; |
|
377 iLines.Append(lineCand); |
|
378 |
|
379 return t; // as lastCandidateIndex |
|
380 } |
|
381 |
|
382 void CListMultiRowRollWithIcon::UpdateListL(TBool aDrawFlag, TBool aRecalculate) |
|
383 { |
|
384 RefreshListL(aRecalculate); |
|
385 |
|
386 if (iOwner->GetUpdateListRedrawFlag() && aDrawFlag ) |
|
387 { |
|
388 Draw(); |
|
389 iOwner->Invalidate(iRect); |
|
390 } |
|
391 } |
|
392 |
|
393 // End Of File |