|
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: Multi rows list with icon for drop-down list objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Include |
|
20 #include <fbs.h> |
|
21 #include <AknsUtils.h> |
|
22 #include <AknLayoutDef.h> |
|
23 #include <peninputdropdownlistcontext.h> |
|
24 #include <peninputdropdownlist.h> |
|
25 #include <AknsDrawUtils.h> |
|
26 #include "peninputlistmultirowwithicon.h" |
|
27 #include "peninputlayout.h" |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // Implementation of Class CListMultiRowWithIcon |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CListMultiRowWithIcon::CListMultiRowWithIcon |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave |
|
37 // (other items were commented in a header). |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CListMultiRowWithIcon::CListMultiRowWithIcon(CListManager* aManager, |
|
41 MFepCtrlDropdownListContext *aOwner) |
|
42 : CList(aManager, aOwner) |
|
43 { |
|
44 iIsMultiRows = ETrue; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CListMultiRowWithIcon::NewL |
|
49 // factory function |
|
50 // (other items were commented in a header). |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CListMultiRowWithIcon* CListMultiRowWithIcon::NewL(CListManager* aManager, |
|
54 MFepCtrlDropdownListContext *aOwner) |
|
55 { |
|
56 CListMultiRowWithIcon* self = new (ELeave) CListMultiRowWithIcon(aManager, aOwner); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CListMultiRowWithIcon::~CListMultiRowWithIcon |
|
65 // desstrutor function |
|
66 // (other items were commented in a header). |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CListMultiRowWithIcon::~CListMultiRowWithIcon() |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CListMultiRowWithIcon::HandlePointerDownL |
|
75 // handle pointer down |
|
76 // (other items were commented in a header). |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CListMultiRowWithIcon::HandlePointerDownL(const TPoint& aPoint) |
|
80 { |
|
81 CList::HandlePointerDownL(aPoint); |
|
82 |
|
83 // also consider fuzzy boundry of drop down list |
|
84 TRect fuzzyrect = iRect; |
|
85 fuzzyrect.Grow(iOwner->FuzzyBoundry(), iOwner->FuzzyBoundry()); |
|
86 |
|
87 if (!fuzzyrect.Contains(aPoint)) |
|
88 { |
|
89 iOwner->SetCapture(EFalse); |
|
90 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
91 return; |
|
92 } |
|
93 |
|
94 // If click in navigation rect and NextButton is not disable, then do |
|
95 if ( iNavigationRect.Contains(aPoint) ) |
|
96 { |
|
97 if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable ) |
|
98 { |
|
99 #ifdef RD_TACTILE_FEEDBACK |
|
100 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
101 DoTactileFeedback(ETouchFeedbackBasic); |
|
102 #endif //RD_TACTILE_FEEDBACK |
|
103 |
|
104 iClickedRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr); |
|
105 iIndicateButtonClicked = ETrue; |
|
106 DrawSelection(iClickedRect, ETrue); |
|
107 } |
|
108 else if (!iOwner->PageCtrlShown()) |
|
109 { |
|
110 iClickedRect = KDummyRect; |
|
111 return; |
|
112 } |
|
113 else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable ) |
|
114 { |
|
115 #ifdef RD_TACTILE_FEEDBACK |
|
116 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
117 DoTactileFeedback(ETouchFeedbackBasic); |
|
118 #endif //RD_TACTILE_FEEDBACK |
|
119 |
|
120 iClickedRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr); |
|
121 iIndicateButtonClicked = ETrue; |
|
122 DrawSelection(iClickedRect, ETrue); |
|
123 } |
|
124 else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable ) |
|
125 { |
|
126 #ifdef RD_TACTILE_FEEDBACK |
|
127 static_cast<CFepCtrlDropdownList*>(iOwner)->UiLayout()-> |
|
128 DoTactileFeedback(ETouchFeedbackBasic); |
|
129 #endif //RD_TACTILE_FEEDBACK |
|
130 |
|
131 |
|
132 iClickedRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
133 iIndicateButtonClicked = ETrue; |
|
134 DrawSelection(iClickedRect, ETrue); |
|
135 } |
|
136 else |
|
137 { |
|
138 iClickedRect = KDummyRect; |
|
139 } |
|
140 } |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CListMultiRowWithIcon::HandlePointerDragL |
|
145 // handle pointer drag function |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CListMultiRowWithIcon::HandlePointerDragL(const TPoint& aPoint) |
|
150 { |
|
151 // Pass the event first to the base |
|
152 CList::HandlePointerDragL(aPoint); |
|
153 |
|
154 if ( !iClickedRect.IsEmpty() ) // clicked rect is not outside the whole DDL |
|
155 { |
|
156 TInt index = -1; |
|
157 CCandidate* candidate = FindCandidate(aPoint, index); |
|
158 |
|
159 iMoveLatestRect = KEmptyRect; |
|
160 |
|
161 if ( candidate ) |
|
162 { |
|
163 iMoveLatestRect.SetRect(candidate->GetRect().iTl, candidate->GetRect().Size()); |
|
164 } |
|
165 else if ( iNavigationRect.Contains(aPoint) ) |
|
166 { |
|
167 if ( iNavigationCloseRect.Contains(aPoint) && !iCloseButtonDisable ) |
|
168 { |
|
169 iMoveLatestRect.SetRect(iNavigationCloseRect.iTl, iNavigationCloseRect.iBr); |
|
170 } |
|
171 else if (!iOwner->PageCtrlShown()) |
|
172 { |
|
173 return; |
|
174 } |
|
175 else if ( iNavigationPreviousRect.Contains(aPoint) && !iPreviousButtonDisable ) |
|
176 { |
|
177 iMoveLatestRect.SetRect(iNavigationPreviousRect.iTl, iNavigationPreviousRect.iBr); |
|
178 } |
|
179 else if ( iNavigationNextRect.Contains(aPoint) && !iNextButtonDisable ) |
|
180 { |
|
181 iMoveLatestRect.SetRect(iNavigationNextRect.iTl, iNavigationNextRect.iBr); |
|
182 } |
|
183 } |
|
184 |
|
185 CompareRect(iMoveLatestRect, iClickedRect); |
|
186 } |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CListMultiRowWithIcon::HandlePointerUpL |
|
191 // handle pointer up function |
|
192 // (other items were commented in a header). |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CListMultiRowWithIcon::HandlePointerUpL(const TPoint& aPoint) |
|
196 { |
|
197 // Reset the button clicked flag to EFalse |
|
198 iIndicateButtonClicked = EFalse; |
|
199 |
|
200 #ifdef __WINS__ |
|
201 // in emulator, double click will be treated as: |
|
202 // 1 pointer down and 2 pointer up, which will cause error |
|
203 if (iClickedRect.IsEmpty() && ((CFepUiBaseCtrl*)iOwner)->PointerDown()) |
|
204 #else |
|
205 if (iClickedRect.IsEmpty()) |
|
206 #endif // __WINS__ |
|
207 { |
|
208 iOwner->SetCapture(EFalse); |
|
209 // Change active list object ie. close the dd-list |
|
210 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() ); |
|
211 } |
|
212 else |
|
213 { |
|
214 if ( iContentRect.Contains(aPoint) ) |
|
215 { |
|
216 if ( iClickedRect.Contains(aPoint) ) |
|
217 { |
|
218 // Redraw the selected aread |
|
219 DrawSelection(iClickedRect, EFalse); |
|
220 |
|
221 iOwner->SetCapture(EFalse); |
|
222 |
|
223 // We have selected a candidate and iClickedCandidateIndex is the selected Index. |
|
224 // Send the candidate to others |
|
225 if (iClickedCandidateIndex != KErrNotFound) |
|
226 { |
|
227 iOwner->AutoChangeActiveList( iOwner->GetFirstCandidateIndex() ); |
|
228 CCandidate* candidate = iOwner->GetCandidate(iClickedCandidateIndex); |
|
229 if ( candidate ) |
|
230 { |
|
231 iOwner->ReportCandidateSelectEventL(candidate->GetCandidate(), |
|
232 iClickedCandidateIndex); |
|
233 } |
|
234 } |
|
235 } |
|
236 } |
|
237 else if ( iNavigationCloseRect.Contains(aPoint) ) |
|
238 { |
|
239 if ( iNavigationCloseRect == iClickedRect ) |
|
240 { |
|
241 iOwner->SetCapture(EFalse); |
|
242 iOwner->AutoChangeActiveList(iOwner->GetFirstCandidateIndex()); |
|
243 } |
|
244 } |
|
245 else if (!iOwner->PageCtrlShown()) |
|
246 { |
|
247 iClickedRect = KEmptyRect; |
|
248 return; |
|
249 } |
|
250 else if ( iNavigationNextRect.Contains(aPoint) ) |
|
251 { |
|
252 if ( iNavigationNextRect == iClickedRect ) |
|
253 { |
|
254 iOwner->NotifyGetNextPage(); |
|
255 UpdateListL(); |
|
256 } |
|
257 } |
|
258 else if ( iNavigationPreviousRect.Contains(aPoint) ) |
|
259 { |
|
260 if ( iNavigationPreviousRect == iClickedRect ) |
|
261 { |
|
262 // Change page to previous |
|
263 iOwner->NotifyGetPreviousPage(); // do nothing, just to avoid clear candidate |
|
264 |
|
265 TInt firstIndex = 0; |
|
266 TInt lastIndex = 0; |
|
267 |
|
268 if (iOwner->GetPages()->GetPreviousIndex(iOwner->GetLastCandidateIndex(), |
|
269 firstIndex,lastIndex)) |
|
270 { |
|
271 iOwner->SetFirstCandidateIndex(firstIndex); |
|
272 iOwner->SetLastCandidateIndex(lastIndex); |
|
273 } |
|
274 |
|
275 UpdateListL(ETrue, EFalse); |
|
276 } |
|
277 } |
|
278 |
|
279 iClickedRect = KEmptyRect; |
|
280 } |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CListMultiRowWithIcon::Draw |
|
285 // draw the list |
|
286 // (other items were commented in a header). |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 void CListMultiRowWithIcon::Draw() |
|
290 { |
|
291 // Call draw in base class; |
|
292 CList::Draw(); |
|
293 |
|
294 DrawCandidates(); |
|
295 |
|
296 const CFbsBitmap* bitmapBg = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapListBg); |
|
297 const CFbsBitmap* bitmapBgMask = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapListBgMask); |
|
298 |
|
299 if (!bitmapBg || !bitmapBgMask) |
|
300 { |
|
301 iOwner->Gc()->SetPenSize(iOwner->GetPenSize()); |
|
302 if ((iOwner->GetCellHorizontalMargin() == 0) && (iOwner->GetCellVerticalMargin() == 0)) |
|
303 { |
|
304 iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
305 } |
|
306 else |
|
307 { |
|
308 iOwner->Gc()->SetPenStyle(CGraphicsContext::ENullPen); |
|
309 } |
|
310 |
|
311 iOwner->Gc()->SetPenColor(iOwner->GetBorderColor()); |
|
312 iOwner->Gc()->SetBrushColor(iOwner->GetBgColor()); |
|
313 iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
314 |
|
315 // Draw the rect for navi |
|
316 iOwner->Gc()->DrawRect(iNavigationRect); |
|
317 } |
|
318 else |
|
319 { |
|
320 iOwner->Gc()->DrawBitmapMasked(iNavigationRect, bitmapBg, |
|
321 bitmapBg->SizeInPixels(), bitmapBgMask, ETrue); |
|
322 |
|
323 } |
|
324 |
|
325 iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
326 |
|
327 // First draw down button |
|
328 if ( iBButtonClose ) |
|
329 { |
|
330 //mask bitmaps |
|
331 TRect rect = iNavigationCloseRect; |
|
332 |
|
333 if (iDropdownListDrawInfo.iSupportSkin) |
|
334 { |
|
335 TRect innerRect = rect; |
|
336 innerRect.Shrink( 4, 4 ); |
|
337 |
|
338 // ----- draw bitmaps ----- |
|
339 |
|
340 |
|
341 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
342 *iOwner->Gc(), |
|
343 rect, |
|
344 innerRect, |
|
345 iDropdownListDrawInfo.iNormalBtnImgID, |
|
346 KAknsIIDDefault ); |
|
347 |
|
348 |
|
349 iBButtonMaskClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapCloseMask); |
|
350 |
|
351 TRect srcRect( TPoint( 0, 0 ), iBButtonClose->SizeInPixels() ); |
|
352 |
|
353 iOwner->Gc()->BitBltMasked( iNavigationCloseRect.iTl, |
|
354 iBButtonClose, |
|
355 srcRect, |
|
356 iBButtonMaskClose, |
|
357 EFalse); |
|
358 } |
|
359 else |
|
360 { |
|
361 // Draw the rect for navi next |
|
362 iOwner->Gc()->DrawLine(TPoint(iNavigationCloseRect.iTl.iX, iNavigationCloseRect.iBr.iY), |
|
363 iNavigationCloseRect.iBr); |
|
364 |
|
365 if (iOwner->GetCellHorizontalMargin() != 0) |
|
366 { |
|
367 iOwner->Gc()->DrawLine(iNavigationCloseRect.iTl, |
|
368 TPoint(iNavigationCloseRect.iTl.iX, |
|
369 iNavigationCloseRect.iBr.iY)); |
|
370 iOwner->Gc()->DrawLine(TPoint(iNavigationCloseRect.iBr.iX, |
|
371 iNavigationCloseRect.iTl.iY), |
|
372 iNavigationCloseRect.iBr); |
|
373 } |
|
374 |
|
375 if (iOwner->GetCellVerticalMargin() != 0) |
|
376 { |
|
377 iOwner->Gc()->DrawLine(iNavigationCloseRect.iTl, |
|
378 TPoint(iNavigationCloseRect.iBr.iX, |
|
379 iNavigationCloseRect.iTl.iY)); |
|
380 } |
|
381 |
|
382 |
|
383 rect.Shrink(TSize(1,1)); |
|
384 rect.iBr.iY = rect.iBr.iY + 1; |
|
385 |
|
386 if (iOwner->GetCellHorizontalMargin() != 0) |
|
387 { |
|
388 rect.iBr.iX = rect.iBr.iX + 1; |
|
389 } |
|
390 |
|
391 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonClose, |
|
392 iBButtonClose->SizeInPixels(), iBButtonMaskClose, ETrue); |
|
393 } |
|
394 } |
|
395 |
|
396 if (!iOwner->PageCtrlShown()) |
|
397 { |
|
398 iOwner->Invalidate(iRect); |
|
399 return; |
|
400 } |
|
401 |
|
402 // First draw down button |
|
403 if ( iBButtonDown ) |
|
404 { |
|
405 //mask bitmaps |
|
406 TRect rect = iNavigationNextRect; |
|
407 |
|
408 if (iDropdownListDrawInfo.iSupportSkin) |
|
409 { |
|
410 TRect innerRect = rect; |
|
411 innerRect.Shrink( 4, 4 ); |
|
412 |
|
413 // ----- draw bitmaps ----- |
|
414 |
|
415 |
|
416 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
417 *iOwner->Gc(), |
|
418 rect, |
|
419 innerRect, |
|
420 iDropdownListDrawInfo.iNormalBtnImgID, |
|
421 KAknsIIDDefault ); |
|
422 |
|
423 |
|
424 iBButtonMaskDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNextMask); |
|
425 |
|
426 TRect srcRect( TPoint( 0, 0 ), iBButtonDown->SizeInPixels() ); |
|
427 |
|
428 iOwner->Gc()->BitBltMasked( iNavigationNextRect.iTl, |
|
429 iBButtonDown, |
|
430 srcRect, |
|
431 iBButtonMaskDown, |
|
432 EFalse); |
|
433 } |
|
434 else |
|
435 { |
|
436 // Draw the rect for navi next |
|
437 iOwner->Gc()->DrawLine(iNavigationNextRect.iTl, |
|
438 TPoint(iNavigationNextRect.iBr.iX, iNavigationNextRect.iTl.iY)); |
|
439 |
|
440 if (iOwner->GetCellHorizontalMargin() != 0) |
|
441 { |
|
442 iOwner->Gc()->DrawLine(iNavigationNextRect.iTl, |
|
443 TPoint(iNavigationNextRect.iTl.iX, iNavigationNextRect.iBr.iY)); |
|
444 iOwner->Gc()->DrawLine(TPoint(iNavigationNextRect.iBr.iX, iNavigationNextRect.iTl.iY), |
|
445 iNavigationNextRect.iBr); |
|
446 } |
|
447 |
|
448 if (iOwner->GetCellVerticalMargin() != 0) |
|
449 { |
|
450 iOwner->Gc()->DrawLine(TPoint(iNavigationNextRect.iTl.iX, iNavigationNextRect.iBr.iY), |
|
451 iNavigationNextRect.iBr); |
|
452 } |
|
453 |
|
454 rect.Shrink(TSize(1,1)); |
|
455 |
|
456 if (iOwner->GetCellHorizontalMargin() != 0) |
|
457 { |
|
458 rect.iBr.iX = rect.iBr.iX + 1; |
|
459 } |
|
460 |
|
461 if (iOwner->GetCellVerticalMargin() != 0) |
|
462 { |
|
463 rect.iBr.iY = rect.iBr.iY + 1; |
|
464 } |
|
465 |
|
466 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonDown, |
|
467 iBButtonDown->SizeInPixels(), iBButtonMaskDown, ETrue); |
|
468 } |
|
469 } |
|
470 |
|
471 // Second draw up button |
|
472 if ( iBButtonUp ) |
|
473 { |
|
474 //mask bitmaps |
|
475 TRect rect = iNavigationPreviousRect; |
|
476 |
|
477 if (iDropdownListDrawInfo.iSupportSkin) |
|
478 { |
|
479 TRect innerRect = rect; |
|
480 innerRect.Shrink( 4, 4 ); |
|
481 |
|
482 // ----- draw bitmaps ----- |
|
483 |
|
484 |
|
485 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
486 *iOwner->Gc(), |
|
487 rect, |
|
488 innerRect, |
|
489 iDropdownListDrawInfo.iNormalBtnImgID, |
|
490 KAknsIIDDefault ); |
|
491 |
|
492 |
|
493 iBButtonMaskUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPreviousMask); |
|
494 |
|
495 TRect srcRect( TPoint( 0, 0 ), iBButtonMaskUp->SizeInPixels() ); |
|
496 |
|
497 iOwner->Gc()->BitBltMasked( iNavigationPreviousRect.iTl, |
|
498 iBButtonUp, |
|
499 srcRect, |
|
500 iBButtonMaskUp, |
|
501 EFalse); |
|
502 } |
|
503 |
|
504 else |
|
505 { |
|
506 // Draw the rect for navi next |
|
507 iOwner->Gc()->DrawLine(TPoint(iNavigationPreviousRect.iTl.iX, |
|
508 iNavigationPreviousRect.iBr.iY), |
|
509 iNavigationPreviousRect.iBr ); |
|
510 |
|
511 if (iOwner->GetCellHorizontalMargin() != 0) |
|
512 { |
|
513 iOwner->Gc()->DrawLine(iNavigationPreviousRect.iTl, |
|
514 TPoint(iNavigationPreviousRect.iTl.iX, iNavigationPreviousRect.iBr.iY)); |
|
515 iOwner->Gc()->DrawLine( |
|
516 TPoint(iNavigationPreviousRect.iBr.iX, iNavigationPreviousRect.iTl.iY), |
|
517 iNavigationPreviousRect.iBr); |
|
518 } |
|
519 |
|
520 if (iOwner->GetCellVerticalMargin() != 0) |
|
521 { |
|
522 iOwner->Gc()->DrawLine(iNavigationPreviousRect.iTl, |
|
523 TPoint(iNavigationPreviousRect.iBr.iX, iNavigationPreviousRect.iTl.iY)); |
|
524 } |
|
525 |
|
526 rect.Shrink(TSize(1,1)); |
|
527 |
|
528 if (iOwner->GetCellHorizontalMargin() != 0) |
|
529 { |
|
530 rect.iBr.iX = rect.iBr.iX + 1; |
|
531 } |
|
532 |
|
533 if (iOwner->GetCellVerticalMargin() != 0) |
|
534 { |
|
535 rect.iBr.iY = rect.iBr.iY + 1; |
|
536 } |
|
537 |
|
538 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonUp, |
|
539 iBButtonUp->SizeInPixels(), iBButtonMaskUp, ETrue); |
|
540 } |
|
541 } |
|
542 |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CListMultiRowWithIcon::UpdateList |
|
547 // update the liset |
|
548 // (other items were commented in a header). |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void CListMultiRowWithIcon::UpdateListL(TBool aDrawFlag,TBool aRecalculate) |
|
552 { |
|
553 RefreshListL(aRecalculate); |
|
554 if(aDrawFlag) |
|
555 { |
|
556 Draw(); |
|
557 iOwner->Invalidate(iRect); |
|
558 } |
|
559 } |
|
560 |
|
561 void CListMultiRowWithIcon::RefreshListL(TBool aRecalculate) |
|
562 { |
|
563 // Recalculate the pos for the candidates |
|
564 if ( aRecalculate ) |
|
565 { |
|
566 iOwner->SetLastCandidateIndex(CalculatePositionsL()); |
|
567 } |
|
568 |
|
569 iOwner->GetPages()->AddPage(iOwner->GetFirstCandidateIndex(), iOwner->GetLastCandidateIndex()); |
|
570 |
|
571 iCloseButtonDisable = EFalse; |
|
572 iBButtonClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapClose); |
|
573 iBButtonMaskClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapCloseMask); |
|
574 |
|
575 if (iOwner->GetFirstCandidateIndex() == 0) // First page, previous button can't be seen |
|
576 { |
|
577 iPreviousButtonDisable = ETrue; |
|
578 iBButtonUp = NULL; |
|
579 iBButtonMaskUp = NULL; |
|
580 } |
|
581 else |
|
582 { |
|
583 iPreviousButtonDisable = EFalse; |
|
584 iBButtonUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrevious); |
|
585 iBButtonMaskUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPreviousMask); |
|
586 } |
|
587 |
|
588 if ((iOwner->GetLastCandidateIndex() < iOwner->CandidateCount()) || |
|
589 iOwner->NextCandidateExist()) |
|
590 { |
|
591 iNextButtonDisable = EFalse; |
|
592 iBButtonDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNext); |
|
593 iBButtonMaskDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNextMask); |
|
594 } |
|
595 else |
|
596 { |
|
597 iNextButtonDisable = ETrue; |
|
598 iBButtonDown = NULL; |
|
599 iBButtonMaskDown = NULL; |
|
600 } |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CListMultiRowWithIcon::CalculateAreas |
|
605 // Calculate all kinds of rectangles |
|
606 // (other items were commented in a header). |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 void CListMultiRowWithIcon::CalculateAreas() |
|
610 { |
|
611 iRect.iTl = iOwner->GetTopLeftPoint(); |
|
612 TInt width = iOwner->GetCellWidth() * iOwner->GetColNum() + |
|
613 iOwner->GetNaviWidth() + |
|
614 (iOwner->GetColNum() + 2) * iOwner->GetCellHorizontalMargin(); |
|
615 |
|
616 TInt height = iOwner->GetCellHeight() * iOwner->GetRowNum() + |
|
617 (iOwner->GetRowNum() + 1) * iOwner->GetCellVerticalMargin(); |
|
618 |
|
619 iRect.SetSize(TSize(width, height)); |
|
620 |
|
621 if (iOwner->CandExpandType() == CFepCtrlDropdownList::ECandExpandUpward) |
|
622 { |
|
623 TInt onerowheight = iOwner->GetCellHeight() + 2 * iOwner->GetCellVerticalMargin(); |
|
624 iRect.Move(0, -(height - onerowheight)); |
|
625 } |
|
626 |
|
627 TBool candHLToR = (iOwner->CandHDirection() == CFepCtrlDropdownList::ECandFromLToR); |
|
628 TInt xPos = iRect.iTl.iX + iOwner->GetCellHorizontalMargin(); |
|
629 TInt yPos = iRect.iTl.iY + iOwner->GetCellVerticalMargin(); |
|
630 |
|
631 // width of content rect |
|
632 TInt widthC = iOwner->GetCellWidth() * iOwner->GetColNum() + |
|
633 (iOwner->GetColNum() - 1) * iOwner->GetCellHorizontalMargin(); |
|
634 height = iOwner->GetCellHeight() * iOwner->GetRowNum() + |
|
635 (iOwner->GetRowNum() - 1) * iOwner->GetCellVerticalMargin(); |
|
636 // width of navi rect |
|
637 TInt widthN = iOwner->GetNaviWidth(); |
|
638 |
|
639 if (candHLToR) |
|
640 { |
|
641 iContentRect.iTl.SetXY(xPos, yPos); |
|
642 iNavigationRect.iTl.SetXY(xPos + widthC + iOwner->GetCellHorizontalMargin(), |
|
643 yPos); |
|
644 } |
|
645 else |
|
646 { |
|
647 iNavigationRect.iTl.SetXY(xPos, yPos); |
|
648 iContentRect.iTl.SetXY(xPos + widthN + iOwner->GetCellHorizontalMargin(), |
|
649 yPos); |
|
650 } |
|
651 |
|
652 iContentRect.SetSize(TSize(widthC, height)); |
|
653 iNavigationRect.SetSize(TSize(widthN, height)); |
|
654 |
|
655 iNavigationCloseRect.iTl = iNavigationRect.iTl; |
|
656 iNavigationCloseRect.SetSize(TSize(iOwner->GetNaviWidth(), iOwner->GetCellHeight())); |
|
657 |
|
658 if (!iOwner->PageCtrlShown()) |
|
659 { |
|
660 iNavigationPreviousRect = TRect(0, 0, 0, 0); |
|
661 iNavigationNextRect = TRect(0, 0, 0, 0); |
|
662 return; |
|
663 } |
|
664 else |
|
665 { |
|
666 iNavigationPreviousRect.iTl.SetXY(iNavigationCloseRect.iTl.iX, |
|
667 iNavigationCloseRect.iBr.iY + iOwner->GetCellVerticalMargin()); |
|
668 iNavigationPreviousRect.SetSize(TSize(iOwner->GetNaviWidth(), iOwner->GetSpinBtnHeight())); |
|
669 iNavigationNextRect.iTl.SetXY(iNavigationRect.iTl.iX, |
|
670 iNavigationRect.iBr.iY - iOwner->GetSpinBtnHeight()); |
|
671 iNavigationNextRect.SetSize(TSize(iOwner->GetNaviWidth(), iOwner->GetSpinBtnHeight())); |
|
672 } |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CListMultiRowWithIcon::CalculatePositionsL |
|
677 // calculate the position of all visible cells in the list |
|
678 // (other items were commented in a header). |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 TInt CListMultiRowWithIcon::CalculatePositionsL() |
|
682 { |
|
683 TInt t = 0; |
|
684 TPoint setpoints; |
|
685 TInt count = iOwner->CandidateCount(); |
|
686 CCandidate* candidate = NULL; |
|
687 if ( count > 0 ) |
|
688 { |
|
689 TBool candHLToR = (iOwner->CandHDirection() == CFepCtrlDropdownList::ECandFromLToR); |
|
690 candHLToR ? setpoints.SetXY(iContentRect.iTl.iX, iContentRect.iTl.iY) : |
|
691 setpoints.SetXY(iContentRect.iBr.iX, iContentRect.iTl.iY); |
|
692 |
|
693 TInt currentCellIndex = 0; |
|
694 TInt lastUsedCellCount = 0; |
|
695 TInt lastusedRow = 0; |
|
696 iOwner->SetFirstCandidateIndex (iOwner->GetLastCandidateIndex()); |
|
697 count = Min(count, iOwner->GetLastCandidateIndex() + iOwner->GetColNum() * iOwner->GetRowNum() ); |
|
698 |
|
699 for(t = iOwner->GetLastCandidateIndex(); t < count ; t++) |
|
700 { |
|
701 candidate = iOwner->GetCandidate(t); |
|
702 |
|
703 if (!candidate) |
|
704 { |
|
705 continue; |
|
706 } |
|
707 |
|
708 lastUsedCellCount = candidate->SetPositionL(setpoints, |
|
709 iOwner->GetCellWidth(), |
|
710 iOwner->GetCellHeight(), |
|
711 iOwner->GetFont(), |
|
712 iOwner->GetCellHorizontalMargin()); |
|
713 currentCellIndex += lastUsedCellCount; |
|
714 if ( currentCellIndex > iOwner->GetColNum() ) |
|
715 { |
|
716 lastusedRow++; |
|
717 if ( lastusedRow >= iOwner->GetRowNum() ) |
|
718 { |
|
719 break; |
|
720 } |
|
721 |
|
722 currentCellIndex = 0; |
|
723 |
|
724 setpoints.iY = setpoints.iY + |
|
725 iOwner->GetCellHeight() + |
|
726 iOwner->GetCellVerticalMargin(); |
|
727 candHLToR ? (setpoints.iX = iContentRect.iTl.iX) : (setpoints.iX = iContentRect.iBr.iX); |
|
728 lastUsedCellCount = candidate->SetPositionL(setpoints, |
|
729 iOwner->GetCellWidth(), |
|
730 iOwner->GetCellHeight(), |
|
731 iOwner->GetFont(), |
|
732 iOwner->GetCellHorizontalMargin()); |
|
733 currentCellIndex += lastUsedCellCount; |
|
734 |
|
735 candHLToR ? (setpoints.iX += lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())) : |
|
736 (setpoints.iX -= lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())); |
|
737 } |
|
738 else |
|
739 { |
|
740 candHLToR ? (setpoints.iX += lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())) : |
|
741 (setpoints.iX -= lastUsedCellCount*(iOwner->GetCellWidth() + iOwner->GetCellHorizontalMargin())); |
|
742 } |
|
743 } // for-loop |
|
744 } // if candidate exist |
|
745 |
|
746 return t; // as lastCandidateIndex |
|
747 } |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // CListMultiRowWithIcon::DrawNavigationPress |
|
751 // draw navigation button when pressed or un-pressed |
|
752 // (other items were commented in a header). |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 TBool CListMultiRowWithIcon::DrawNavigationPress(const TRect& aRect,TBool aIndicate) |
|
756 { |
|
757 TBool retval = EFalse; |
|
758 |
|
759 if ( aRect == iNavigationCloseRect ) |
|
760 { |
|
761 retval = ETrue; |
|
762 |
|
763 // Activeate bitmap context |
|
764 iOwner->ActivateBitmapContext(); |
|
765 |
|
766 if (iDropdownListDrawInfo.iSupportSkin) |
|
767 { |
|
768 TRect rect = iNavigationCloseRect; |
|
769 TRect innerRect = rect; |
|
770 innerRect.Shrink( 4, 4 ); |
|
771 |
|
772 if ( aIndicate ) |
|
773 { |
|
774 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
775 *iOwner->Gc(), |
|
776 rect, |
|
777 innerRect, |
|
778 iDropdownListDrawInfo.iPressedBtnImgID, |
|
779 KAknsIIDDefault ); |
|
780 } |
|
781 else |
|
782 { |
|
783 |
|
784 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
785 *iOwner->Gc(), |
|
786 rect, |
|
787 innerRect, |
|
788 iDropdownListDrawInfo.iNormalBtnImgID, |
|
789 KAknsIIDDefault ); |
|
790 |
|
791 } |
|
792 |
|
793 iBButtonMaskClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapCloseMask); |
|
794 |
|
795 TRect srcRect( TPoint( 0, 0 ), iBButtonClose->SizeInPixels() ); |
|
796 |
|
797 iOwner->Gc()->BitBltMasked( iNavigationCloseRect.iTl, |
|
798 iBButtonClose, |
|
799 srcRect, |
|
800 iBButtonMaskClose, |
|
801 EFalse); |
|
802 } |
|
803 else |
|
804 { |
|
805 if ( aIndicate ) // Pressed the button |
|
806 { |
|
807 iBButtonClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapClosePress); |
|
808 iBButtonMaskClose = iOwner->GetBitmapDb()->GetBitMap( |
|
809 CBitmapDb::EBitmapClosePressMask); |
|
810 } |
|
811 else // Release the button |
|
812 { |
|
813 iBButtonClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapClose); |
|
814 iBButtonMaskClose = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapCloseMask); |
|
815 } |
|
816 |
|
817 // Begin draw navigation next button |
|
818 iOwner->DrawMask(iNavigationCloseRect); |
|
819 // Activeate bitmap context |
|
820 iOwner->ActivateBitmapContext(); |
|
821 // Draw bitmap |
|
822 TRect rect = iNavigationCloseRect; |
|
823 rect.Shrink(TSize(1,1)); |
|
824 rect.iBr.iY += 1; |
|
825 |
|
826 if (iOwner->GetCellHorizontalMargin() != 0) |
|
827 { |
|
828 rect.iBr.iX = rect.iBr.iX + 1; |
|
829 } |
|
830 |
|
831 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonClose, |
|
832 iBButtonClose->SizeInPixels(), iBButtonMaskClose, ETrue); |
|
833 } |
|
834 iOwner->Invalidate(aRect); |
|
835 } |
|
836 else if (!iOwner->PageCtrlShown()) |
|
837 { |
|
838 return retval; |
|
839 } |
|
840 else if ( aRect == iNavigationPreviousRect ) |
|
841 { |
|
842 retval = ETrue; |
|
843 |
|
844 // Activeate bitmap context |
|
845 iOwner->ActivateBitmapContext(); |
|
846 |
|
847 if (iDropdownListDrawInfo.iSupportSkin) |
|
848 { |
|
849 TRect rect = iNavigationPreviousRect; |
|
850 TRect innerRect = rect; |
|
851 innerRect.Shrink( 4, 4 ); |
|
852 |
|
853 if ( aIndicate ) |
|
854 { |
|
855 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
856 *iOwner->Gc(), |
|
857 rect, |
|
858 innerRect, |
|
859 iDropdownListDrawInfo.iPressedBtnImgID, |
|
860 KAknsIIDDefault ); |
|
861 } |
|
862 else |
|
863 { |
|
864 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
865 *iOwner->Gc(), |
|
866 rect, |
|
867 innerRect, |
|
868 iDropdownListDrawInfo.iNormalBtnImgID, |
|
869 KAknsIIDDefault ); |
|
870 } |
|
871 |
|
872 iBButtonMaskUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPreviousMask); |
|
873 |
|
874 TRect srcRect( TPoint( 0, 0 ), iBButtonUp->SizeInPixels() ); |
|
875 |
|
876 iOwner->Gc()->BitBltMasked( iNavigationPreviousRect.iTl, |
|
877 iBButtonUp, |
|
878 srcRect, |
|
879 iBButtonMaskUp, |
|
880 EFalse); |
|
881 } |
|
882 else |
|
883 { |
|
884 if ( aIndicate ) // Pressed the button |
|
885 { |
|
886 if ( iBButtonUp ) |
|
887 { |
|
888 iBButtonUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPreviousPress); |
|
889 iBButtonMaskUp = iOwner->GetBitmapDb()->GetBitMap( |
|
890 CBitmapDb::EBitmapPreviousPressMask); |
|
891 } |
|
892 } |
|
893 else // Release the button |
|
894 { |
|
895 if ( iBButtonUp ) |
|
896 { |
|
897 iBButtonUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPrevious); |
|
898 iBButtonMaskUp = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapPreviousMask); |
|
899 } |
|
900 } |
|
901 |
|
902 // Begin draw navigation next button |
|
903 iOwner->DrawMask(iNavigationPreviousRect); |
|
904 |
|
905 // Activeate bitmap context |
|
906 iOwner->ActivateBitmapContext(); |
|
907 |
|
908 // Clear rect |
|
909 iOwner->Gc()->SetPenSize(iOwner->GetPenSize()); |
|
910 iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
911 iOwner->Gc()->SetPenColor(iOwner->GetBorderColor()); |
|
912 iOwner->Gc()->SetBrushColor(iOwner->GetBgColor()); |
|
913 iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
914 iOwner->Gc()->DrawRect( iNavigationPreviousRect ); |
|
915 |
|
916 // Draw bitmap |
|
917 TRect rect = iNavigationPreviousRect; |
|
918 rect.Shrink(TSize(1,1)); |
|
919 |
|
920 if (iOwner->GetCellHorizontalMargin() != 0) |
|
921 { |
|
922 rect.iBr.iX = rect.iBr.iX + 1; |
|
923 } |
|
924 |
|
925 if (iOwner->GetCellVerticalMargin() != 0) |
|
926 { |
|
927 rect.iBr.iY = rect.iBr.iY + 1; |
|
928 } |
|
929 |
|
930 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonUp, |
|
931 iBButtonUp->SizeInPixels(), iBButtonMaskUp, ETrue); |
|
932 } |
|
933 |
|
934 iOwner->Invalidate(aRect); |
|
935 |
|
936 } |
|
937 else if ( aRect == iNavigationNextRect ) |
|
938 { |
|
939 retval = ETrue; |
|
940 |
|
941 // Activeate bitmap context |
|
942 iOwner->ActivateBitmapContext(); |
|
943 |
|
944 |
|
945 if (iDropdownListDrawInfo.iSupportSkin) |
|
946 { |
|
947 TRect rect = iNavigationNextRect; |
|
948 TRect innerRect = rect; |
|
949 innerRect.Shrink( 4, 4 ); |
|
950 |
|
951 if ( aIndicate ) |
|
952 { |
|
953 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
954 *iOwner->Gc(), |
|
955 rect, |
|
956 innerRect, |
|
957 iDropdownListDrawInfo.iPressedBtnImgID, |
|
958 KAknsIIDDefault ); |
|
959 } |
|
960 else |
|
961 { |
|
962 AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
963 *iOwner->Gc(), |
|
964 rect, |
|
965 innerRect, |
|
966 iDropdownListDrawInfo.iNormalBtnImgID, |
|
967 KAknsIIDDefault ); |
|
968 } |
|
969 |
|
970 iBButtonMaskDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNextMask); |
|
971 |
|
972 TRect srcRect( TPoint( 0, 0 ), iBButtonDown->SizeInPixels() ); |
|
973 |
|
974 iOwner->Gc()->BitBltMasked( iNavigationNextRect.iTl, |
|
975 iBButtonDown, |
|
976 srcRect, |
|
977 iBButtonMaskDown, |
|
978 EFalse); |
|
979 } |
|
980 else |
|
981 { |
|
982 if ( aIndicate ) // Pressed the button |
|
983 { |
|
984 if ( iBButtonDown ) |
|
985 { |
|
986 iBButtonDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNextPress); |
|
987 iBButtonMaskDown = iOwner->GetBitmapDb()->GetBitMap( |
|
988 CBitmapDb::EBitmapNextPressMask); |
|
989 } |
|
990 } |
|
991 else // Release the button |
|
992 { |
|
993 if ( iBButtonDown ) |
|
994 { |
|
995 iBButtonDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNext); |
|
996 iBButtonMaskDown = iOwner->GetBitmapDb()->GetBitMap(CBitmapDb::EBitmapNextMask); |
|
997 } |
|
998 } |
|
999 |
|
1000 // Begin draw navigation next button |
|
1001 iOwner->DrawMask(iNavigationNextRect); |
|
1002 |
|
1003 // Activeate bitmap context |
|
1004 iOwner->ActivateBitmapContext(); |
|
1005 |
|
1006 // Clear rect |
|
1007 iOwner->Gc()->SetPenSize(iOwner->GetPenSize()); |
|
1008 iOwner->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1009 iOwner->Gc()->SetPenColor(iOwner->GetBorderColor()); |
|
1010 iOwner->Gc()->SetBrushColor(iOwner->GetBgColor()); |
|
1011 iOwner->Gc()->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
1012 iOwner->Gc()->DrawRect( iNavigationNextRect ); |
|
1013 |
|
1014 // Draw bitmap |
|
1015 TRect rect = iNavigationNextRect; |
|
1016 rect.Shrink(TSize(1,1)); |
|
1017 |
|
1018 if (iOwner->GetCellHorizontalMargin() != 0) |
|
1019 { |
|
1020 rect.iBr.iX = rect.iBr.iX + 1; |
|
1021 } |
|
1022 |
|
1023 if (iOwner->GetCellVerticalMargin() != 0) |
|
1024 { |
|
1025 rect.iBr.iY = rect.iBr.iY + 1; |
|
1026 } |
|
1027 |
|
1028 iOwner->Gc()->DrawBitmapMasked(rect, iBButtonDown, |
|
1029 iBButtonDown->SizeInPixels(), iBButtonMaskDown, ETrue); |
|
1030 } |
|
1031 |
|
1032 iOwner->Invalidate(aRect); |
|
1033 } |
|
1034 |
|
1035 return retval; |
|
1036 } |
|
1037 |
|
1038 // End Of File |