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 |
|
18 |
|
19 #include <fbs.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <AknLayoutDef.h> |
|
22 #include <peninputdropdownlistcontext.h> |
|
23 |
|
24 #include "peninputdropdownlist.h" |
|
25 #include "peninputlayout.h" |
|
26 #include "peninputlistmultirowrollwithiconwithbubble.h" |
|
27 |
|
28 |
|
29 const TInt KInvalidCandIndex = -1; |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // Implementation of Class CListMultiRowRollWithIconWithBubble |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CListMultiRowRollWithIconWithBubble::NewL |
|
37 // factory function |
|
38 // (other items were commented in a header). |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CListMultiRowRollWithIconWithBubble* CListMultiRowRollWithIconWithBubble::NewL(CListManager* aManager, |
|
42 MFepCtrlDropdownListContext* aOwner) |
|
43 { |
|
44 CListMultiRowRollWithIconWithBubble* self = new (ELeave) CListMultiRowRollWithIconWithBubble(aManager, aOwner); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CListMultiRowRollWithIconWithBubble::CListMultiRowRollWithIconWithBubble |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave |
|
55 // (other items were commented in a header). |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CListMultiRowRollWithIconWithBubble::CListMultiRowRollWithIconWithBubble(CListManager* aManager, |
|
59 MFepCtrlDropdownListContext* aOwner): |
|
60 CListMultiRowRollWithIcon(aManager, aOwner) |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CListMultiRowRollWithIconWithBubble::~CListMultiRowRollWithIconWithBubble |
|
66 // desstrutor function |
|
67 // (other items were commented in a header). |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CListMultiRowRollWithIconWithBubble::~CListMultiRowRollWithIconWithBubble() |
|
71 { |
|
72 |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CListMultiRowRollWithIconWithBubble::HandlePointerDownL |
|
77 // handle pointer down |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CListMultiRowRollWithIconWithBubble::HandlePointerDownL(const TPoint& aPoint) |
|
82 { |
|
83 CList::HandlePointerDownL(aPoint); |
|
84 |
|
85 // if press outside of expanded list, close it |
|
86 // also consider fuzzy boundary |
|
87 TRect fuzzyrect = iRect; |
|
88 fuzzyrect.Grow(iOwner->FuzzyBoundry(), iOwner->FuzzyBoundry()); |
|
89 |
|
90 if (!fuzzyrect.Contains(aPoint)) |
|
91 { |
|
92 iOwner->SetCapture(EFalse); |
|
93 |
|
94 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
95 { |
|
96 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
97 } |
|
98 else |
|
99 { |
|
100 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
101 } |
|
102 iOwner->ClearBubble(); |
|
103 return; |
|
104 } |
|
105 |
|
106 // If click in navigation rect and NextButton is not disable, then do |
|
107 if ( iNavigationRect.Contains(aPoint) ) |
|
108 { |
|
109 if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable ) |
|
110 { |
|
111 #ifdef RD_TACTILE_FEEDBACK |
|
112 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
113 DoTactileFeedback(ETouchFeedbackBasic); |
|
114 #endif |
|
115 iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr); |
|
116 iIndicateButtonClicked = ETrue; |
|
117 DrawSelection(iClickedRect, ETrue); |
|
118 } |
|
119 else if (!iOwner->PageCtrlShown()) |
|
120 { |
|
121 iClickedRect = KDummyRect; |
|
122 return; |
|
123 } |
|
124 else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable ) |
|
125 { |
|
126 #ifdef RD_TACTILE_FEEDBACK |
|
127 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
128 DoTactileFeedback(ETouchFeedbackBasic); |
|
129 #endif |
|
130 iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr); |
|
131 iIndicateButtonClicked = ETrue; |
|
132 DrawSelection(iClickedRect, ETrue); |
|
133 } |
|
134 else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable ) |
|
135 { |
|
136 #ifdef RD_TACTILE_FEEDBACK |
|
137 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
138 DoTactileFeedback(ETouchFeedbackBasic); |
|
139 #endif |
|
140 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
141 iIndicateButtonClicked = ETrue; |
|
142 DrawSelection(iClickedRect, ETrue); |
|
143 } |
|
144 else |
|
145 { |
|
146 iClickedRect = KDummyRect; |
|
147 } |
|
148 } |
|
149 else |
|
150 { |
|
151 TInt index = -1; |
|
152 CCandidate* candidate = FindCandidate(aPoint, index); |
|
153 if(candidate) |
|
154 { |
|
155 iOwner->DrawBubble(iClickedRect, candidate->GetCandidate()); |
|
156 } |
|
157 } |
|
158 } |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CListMultiRowRollWithIconWithBubble::HandlePointerDragL |
|
163 // handle pointer drag function |
|
164 // (other items were commented in a header). |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CListMultiRowRollWithIconWithBubble::HandlePointerDragL(const TPoint& aPoint) |
|
168 { |
|
169 // Pass the event first to the base |
|
170 CList::HandlePointerDragL(aPoint); |
|
171 |
|
172 CCandidate* candidate = FindCandidate(aPoint, iClickedCandidateIndex); |
|
173 |
|
174 TBool isUpdateBubble = EFalse; |
|
175 if ( candidate ) |
|
176 { |
|
177 if (iClickedRect != candidate->GetRect()) |
|
178 {// move to the other candidate |
|
179 // set update prview bubble flag |
|
180 isUpdateBubble = ETrue; |
|
181 // remenber the previous cell rect |
|
182 iMoveLatestRect = iClickedRect; |
|
183 // get the new cell rect |
|
184 iClickedRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size()); |
|
185 } |
|
186 } |
|
187 else if ( iNavigationRect.Contains(aPoint) ) |
|
188 { |
|
189 iOwner->ClearBubble(); |
|
190 if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable && |
|
191 iClickedRect != iNavigationCloseRect) |
|
192 { |
|
193 iMoveLatestRect = iClickedRect; |
|
194 iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr); |
|
195 CompareRect(iMoveLatestRect, iClickedRect); |
|
196 } |
|
197 else if (!iOwner->PageCtrlShown()) |
|
198 { |
|
199 return; |
|
200 } |
|
201 else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable && |
|
202 iClickedRect != iNavigationPreviousRect ) |
|
203 { |
|
204 iMoveLatestRect = iClickedRect; |
|
205 iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr); |
|
206 CompareRect(iMoveLatestRect, iClickedRect); |
|
207 } |
|
208 else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable && |
|
209 iClickedRect != iNavigationNextRect ) |
|
210 { |
|
211 iMoveLatestRect = iClickedRect; |
|
212 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
213 CompareRect(iMoveLatestRect, iClickedRect); |
|
214 } |
|
215 else if(!((iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable) || |
|
216 (iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable) || |
|
217 (iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable))) |
|
218 { |
|
219 // Move to navigation area but not valid navigation button |
|
220 TRect dummyrect = KDummyRect; |
|
221 if(iClickedRect != dummyrect) |
|
222 { |
|
223 iMoveLatestRect = iClickedRect; |
|
224 iClickedRect = KDummyRect; |
|
225 CompareRect(iMoveLatestRect, iClickedRect); |
|
226 } |
|
227 } |
|
228 } |
|
229 else |
|
230 {// outside the list |
|
231 // remember the previous cell |
|
232 iMoveLatestRect = iClickedRect; |
|
233 // set the new cell to empty |
|
234 iClickedRect = KDummyRect; |
|
235 // redraw the cell only when drag outside at the first time |
|
236 if(iMoveLatestRect != iClickedRect) |
|
237 { |
|
238 iOwner->ClearBubble(); |
|
239 DrawSelection(iMoveLatestRect, EFalse); |
|
240 DrawHighightCell(iMoveLatestRect, ETrue); |
|
241 } |
|
242 } |
|
243 |
|
244 if(candidate && isUpdateBubble) |
|
245 { |
|
246 iOwner->ClearBubble(); |
|
247 CompareRect(iMoveLatestRect, iClickedRect); |
|
248 // Show preview bubble when drag into a candidate cell |
|
249 // Make sure show the bubble after redraw clicked cell |
|
250 iOwner->DrawBubble(iClickedRect, candidate->GetCandidate()); |
|
251 } |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CListMultiRowRollWithIconWithBubble::HandlePointerUpL |
|
256 // handle pointer up |
|
257 // (other items were commented in a header). |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CListMultiRowRollWithIconWithBubble::HandlePointerUpL(const TPoint& aPoint) |
|
261 { |
|
262 // Reset the button clicked flag to EFalse |
|
263 iIndicateButtonClicked = EFalse; |
|
264 |
|
265 iOwner->ClearBubble(); |
|
266 #ifdef __WINS__ |
|
267 // in emulator, double click will be treated as: |
|
268 // 1 pointer down and 2 pointer up, which will cause error |
|
269 if (iClickedRect.IsEmpty() && ((CFepUiBaseCtrl*)iOwner)->PointerDown()) |
|
270 #else |
|
271 if (iClickedRect.IsEmpty()) |
|
272 #endif // __WINS__ |
|
273 { |
|
274 iOwner->SetCapture(EFalse); |
|
275 // Change active list object ie. close the dd-list |
|
276 |
|
277 // txin modify |
|
278 //iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
279 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
280 { |
|
281 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
282 } |
|
283 else |
|
284 { |
|
285 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
286 } |
|
287 // end |
|
288 } |
|
289 else |
|
290 { |
|
291 if ( iContentRect.Contains(aPoint) ) |
|
292 { |
|
293 if ( iClickedRect.Contains(aPoint) ) |
|
294 { |
|
295 // Redraw the selected aread |
|
296 DrawSelection(iClickedRect, EFalse); |
|
297 |
|
298 iOwner->SetCapture(EFalse); |
|
299 |
|
300 // We have selected a candidate and iClickedCandidateIndex is the selected Index. |
|
301 // Send the candidate to others |
|
302 if (iClickedCandidateIndex != KErrNotFound) |
|
303 { |
|
304 CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex); |
|
305 |
|
306 if (candidate) |
|
307 { |
|
308 iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(), |
|
309 iClickedCandidateIndex); |
|
310 } |
|
311 |
|
312 TInt lastIdxOfLine = StartCandIdxOfLine(iClickedCandidateIndex); |
|
313 |
|
314 TInt originalFirstCandIdx = iOwner->GetFirstCandidateIndex(); |
|
315 TInt originalLastCandIdx = iOwner->GetLastCandidateIndex(); |
|
316 |
|
317 if (lastIdxOfLine == KInvalidCandIndex) |
|
318 { |
|
319 lastIdxOfLine = iOwner->GetFirstCandidateIndex(); |
|
320 } |
|
321 |
|
322 iOwner->SetOneRowStartCandIdx(lastIdxOfLine); |
|
323 |
|
324 iOwner->AutoChangeActiveList(lastIdxOfLine); |
|
325 |
|
326 iOwner->SetOriginalFirstCandIdx(originalFirstCandIdx); |
|
327 } |
|
328 } |
|
329 } |
|
330 else if ( iNavigationCloseRect.Contains(aPoint) ) |
|
331 { |
|
332 if ( iNavigationCloseRect == iClickedRect ) |
|
333 { |
|
334 iOwner->SetCapture(EFalse); |
|
335 |
|
336 if (iOwner->OneRowStartCandIdx() != KInvalidCandIndex) |
|
337 { |
|
338 iOwner->AutoChangeActiveList(iOwner->OneRowStartCandIdx()); |
|
339 } |
|
340 else |
|
341 { |
|
342 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
343 } |
|
344 } |
|
345 } |
|
346 else if (!iOwner->PageCtrlShown()) |
|
347 { |
|
348 iClickedRect = KEmptyRect; |
|
349 return; |
|
350 } |
|
351 else if ( iNavigationNextRect.Contains(aPoint) ) |
|
352 { |
|
353 if ( iNavigationNextRect == iClickedRect ) |
|
354 { |
|
355 iOwner->NotifyGetNextPage(); |
|
356 UpdateListL(); |
|
357 } |
|
358 } |
|
359 else if ( iNavigationPreviousRect.Contains(aPoint) ) |
|
360 { |
|
361 if ( iNavigationPreviousRect == iClickedRect ) |
|
362 { |
|
363 // Change page to previous |
|
364 iOwner->NotifyGetPreviousPage(); // do nothing, just to avoid clear candidate |
|
365 |
|
366 TInt firstIndex = 0; |
|
367 TInt lastIndex = 0; |
|
368 |
|
369 if (iOwner->GetPages()->GetPreviousIndex(iOwner->GetLastCandidateIndex(), |
|
370 firstIndex,lastIndex)) |
|
371 { |
|
372 iOwner->SetFirstCandidateIndex(firstIndex); |
|
373 iOwner->SetLastCandidateIndex(lastIndex); |
|
374 } |
|
375 |
|
376 UpdateListL(ETrue, EFalse); |
|
377 } |
|
378 } |
|
379 |
|
380 iClickedRect = KEmptyRect; |
|
381 } |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CListMultiRowRollWithIconWithBubble::CompareRect |
|
386 // Compare src and des rect |
|
387 // (other items were commented in a header). |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 TBool CListMultiRowRollWithIconWithBubble::CompareRect(const TRect& aSrcRect, const TRect& aDesRect) |
|
391 { |
|
392 if(aSrcRect != aDesRect) |
|
393 { |
|
394 DrawSelection(aDesRect, ETrue); |
|
395 DrawSelection(aSrcRect, EFalse); |
|
396 DrawHighightCell(aSrcRect, ETrue); |
|
397 } |
|
398 |
|
399 return EFalse; |
|
400 } |
|
401 |
|
402 // End Of File |
|