|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Implementation for button base and dragbar |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <coemain.h> |
|
19 #include <barsread.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <AknIconUtils.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include <AknUtils.h> |
|
24 #include <peninputlayout.h> |
|
25 #include <AknBidiTextUtils.h> |
|
26 #include <peninputcommonbutton.h> |
|
27 #include <StringLoader.h> |
|
28 |
|
29 #include "peninputscrollablelist.h" |
|
30 |
|
31 const TInt KCtrlIdPageUp = 1; |
|
32 const TInt KCtrlIdPageDown = 2; |
|
33 |
|
34 const TInt KInvalidResId = -1; |
|
35 const TInt KInvalidBmp = -1; |
|
36 |
|
37 |
|
38 const TInt KDisplayTextLen = KMaxItemTextLength + KAknBidiExtraSpacePerLine; |
|
39 |
|
40 const TInt KTextRectMargin = 4; |
|
41 |
|
42 EXPORT_C CFepLayoutScrollableList* CFepLayoutScrollableList::NewL(CFepUiLayout* aUiLayout, |
|
43 TInt aControlId, |
|
44 TSize aItemSize, |
|
45 TInt aHorizontalMargin, |
|
46 TInt aVerticalMargin, |
|
47 TSize aNaviSize, |
|
48 TSize aNaviInnerSize) |
|
49 { |
|
50 CFepLayoutScrollableList* self = NewLC(aUiLayout, |
|
51 aControlId, |
|
52 aItemSize, |
|
53 aHorizontalMargin, |
|
54 aVerticalMargin, |
|
55 aNaviSize, |
|
56 aNaviInnerSize); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 EXPORT_C CFepLayoutScrollableList* CFepLayoutScrollableList::NewLC(CFepUiLayout* aUiLayout, |
|
62 TInt aControlId, |
|
63 TSize aItemSize, |
|
64 TInt aHorizontalMargin, |
|
65 TInt aVerticalMargin, |
|
66 TSize aNaviSize, |
|
67 TSize aNaviInnerSize) |
|
68 { |
|
69 CFepLayoutScrollableList* self = new(ELeave) CFepLayoutScrollableList(aUiLayout, |
|
70 aControlId, |
|
71 aItemSize, |
|
72 aHorizontalMargin, |
|
73 aVerticalMargin, |
|
74 aNaviSize, |
|
75 aNaviInnerSize); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 return self; |
|
79 } |
|
80 |
|
81 EXPORT_C CFepLayoutScrollableList::~CFepLayoutScrollableList() |
|
82 { |
|
83 //iBmpList.ResetAndDestroy(); |
|
84 //iBmpList.Close(); |
|
85 |
|
86 //delete iPageInfoFormat; |
|
87 delete iPageInfo; |
|
88 iItemRects.Close(); |
|
89 delete iSeperationBmp; |
|
90 delete iSeperationMaskBmp; |
|
91 } |
|
92 |
|
93 EXPORT_C void CFepLayoutScrollableList::ConstructFromResourceL() |
|
94 { |
|
95 if (iResourceId == KInvalidResId) |
|
96 { |
|
97 User::Leave(KErrArgument); |
|
98 } |
|
99 //delete the old bmp res |
|
100 delete iSeperationBmp; |
|
101 delete iSeperationMaskBmp; |
|
102 iSeperationBmp = NULL; |
|
103 iSeperationMaskBmp = NULL; |
|
104 |
|
105 TResourceReader reader; |
|
106 CCoeEnv::Static()->CreateResourceReaderLC(reader, iResourceId); |
|
107 |
|
108 TPtrC bmpFileName = reader.ReadTPtrC(); |
|
109 TInt imgMajorSkinId = reader.ReadInt32(); |
|
110 |
|
111 TInt32 pageUpId = reader.ReadInt32(); |
|
112 TInt32 pageDownId = reader.ReadInt32(); |
|
113 TAknsItemID id; |
|
114 |
|
115 //read seperation line res |
|
116 const TInt16 bmpId = reader.ReadInt16(); |
|
117 const TInt16 bmpMskId = reader.ReadInt16(); |
|
118 // read skin item id |
|
119 const TInt skinitemid = reader.ReadInt16(); |
|
120 id.Set(TInt(imgMajorSkinId), skinitemid); |
|
121 |
|
122 if (bmpId != KInvalidBmp) |
|
123 { |
|
124 if (bmpMskId != KInvalidBmp) |
|
125 { |
|
126 AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(), |
|
127 id, |
|
128 KAknsIIDQsnIconColors, |
|
129 EAknsCIQsnIconColorsCG30, |
|
130 iSeperationBmp, |
|
131 iSeperationMaskBmp, |
|
132 bmpFileName, |
|
133 bmpId, |
|
134 bmpMskId, |
|
135 AKN_LAF_COLOR( 0 ) ); |
|
136 } |
|
137 else |
|
138 { |
|
139 AknsUtils::CreateIconL(UiLayout()->SkinInstance(), |
|
140 id, |
|
141 iSeperationBmp, |
|
142 bmpFileName, |
|
143 bmpId); |
|
144 } |
|
145 } |
|
146 CleanupStack::PopAndDestroy(1); // reader |
|
147 |
|
148 TResourceReader pageUpReader; |
|
149 CCoeEnv::Static()->CreateResourceReaderLC(pageUpReader, pageUpId); |
|
150 iPageUp->ConstructFromResourceL(pageUpReader); |
|
151 CleanupStack::PopAndDestroy(1); // pageUpReader, imgreader |
|
152 |
|
153 TResourceReader pageDownReader; |
|
154 CCoeEnv::Static()->CreateResourceReaderLC(pageDownReader, pageDownId); |
|
155 iPageDown->ConstructFromResourceL(pageDownReader); |
|
156 CleanupStack::PopAndDestroy(1); // pageDownReader, imgreader |
|
157 } |
|
158 |
|
159 EXPORT_C void CFepLayoutScrollableList::SizeChanged(TSize aItemSize, |
|
160 TInt aHorizontalMargin, |
|
161 TInt aVerticalMargin, |
|
162 TSize aNaviSize, |
|
163 TSize aNaviInnerSize) |
|
164 { |
|
165 iItemSize = aItemSize; |
|
166 iHorizontalMargin = aHorizontalMargin; |
|
167 iVerticalMargin = aVerticalMargin; |
|
168 iNaviSize = aNaviSize; |
|
169 iNaviInnerSize = aNaviInnerSize; |
|
170 |
|
171 } |
|
172 |
|
173 EXPORT_C void CFepLayoutScrollableList::SetTextProperty(const CFont* aFont, |
|
174 TRgb aFontColor) |
|
175 { |
|
176 iFont = aFont; |
|
177 iFontColor = aFontColor; |
|
178 |
|
179 iBaselineOffset = iItemSize.iHeight/2 + aFont->AscentInPixels()/2; |
|
180 } |
|
181 |
|
182 EXPORT_C void CFepLayoutScrollableList::Draw() |
|
183 { |
|
184 if (Hiden() || !Ready() || Rect().Size() == TSize(0,0)) |
|
185 { |
|
186 return; |
|
187 } |
|
188 |
|
189 // draw background of whole control |
|
190 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
191 |
|
192 //mask bitmaps |
|
193 TRect rect = Rect(); |
|
194 |
|
195 DrawOpaqueMaskBackground(); |
|
196 |
|
197 TRect innerRect = rect; |
|
198 innerRect.Shrink(4, 4); |
|
199 |
|
200 // ----- draw bitmaps ----- |
|
201 gc->Activate(BitmapDevice()); |
|
202 gc->Clear(rect); |
|
203 |
|
204 AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), |
|
205 *gc, |
|
206 rect, |
|
207 innerRect, |
|
208 iBgFrId, |
|
209 KAknsIIDDefault); |
|
210 |
|
211 // draw item |
|
212 for (TInt i = iCurrentPage * iOnePageItemCnt; |
|
213 i < (iCurrentPage + 1) * iOnePageItemCnt && i < ItemArray().Count(); |
|
214 i++) |
|
215 { |
|
216 DrawItem(i); |
|
217 } |
|
218 |
|
219 // draw scroll area |
|
220 if (iNaviBtnShown) |
|
221 { |
|
222 iPageUp->Draw(); |
|
223 iPageDown->Draw(); |
|
224 DrawPageInfo(); |
|
225 } |
|
226 } |
|
227 |
|
228 EXPORT_C void CFepLayoutScrollableList::DrawPageInfo() |
|
229 { |
|
230 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
231 //TPtr ptr = iPageInfo->Des(); |
|
232 //FORMATPAGEINFO(ptr, *iPageInfoFormat, iCurrentPage + 1, iTotalPages); |
|
233 TRAP_IGNORE(UpdatePageInfoL( iCurrentPage + 1, iTotalPages )); |
|
234 |
|
235 if( iPageInfoLineSet ) |
|
236 { |
|
237 TRgb color( KRgbBlack ); // sane default for nonskinned case |
|
238 |
|
239 TAknLayoutText textLayout; |
|
240 textLayout.LayoutText(iScrollRect, iPageInfoTextLine ); |
|
241 TAknsQsnTextColorsIndex clrIndex; |
|
242 clrIndex = EAknsCIQsnTextColorsCG20; |
|
243 |
|
244 if ( AknsUtils::AvkonSkinEnabled() ) |
|
245 { |
|
246 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
|
247 color, KAknsIIDQsnTextColors, clrIndex ); |
|
248 } |
|
249 |
|
250 textLayout.DrawText(*gc, iPageInfo->Des(), EFalse, color); |
|
251 } |
|
252 else |
|
253 { |
|
254 gc->UseFont(iFont); |
|
255 |
|
256 gc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
257 gc->SetBrushColor(KRgbBlack); |
|
258 gc->SetPenColor(iFontColor); |
|
259 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
260 gc->SetPenSize(PenSize()); |
|
261 |
|
262 |
|
263 gc->DrawText(iPageInfo->Des(), |
|
264 iPageInfoRect, |
|
265 iBaselineOffset, |
|
266 CGraphicsContext::ECenter); |
|
267 |
|
268 gc->DiscardFont(); |
|
269 } |
|
270 } |
|
271 |
|
272 EXPORT_C TInt CFepLayoutScrollableList::HitTest(const TPoint& aPoint) |
|
273 { |
|
274 if( !Contains( aPoint ) ) |
|
275 { |
|
276 return EListOutside; |
|
277 } |
|
278 for (TInt i = 0; i < iItemRects.Count(); i++) |
|
279 { |
|
280 if (iItemRects[i].Contains(aPoint)) |
|
281 { |
|
282 if ((iCurrentPage * iOnePageItemCnt + i) < ItemArray().Count()) |
|
283 return (iCurrentPage * iOnePageItemCnt + i); |
|
284 else |
|
285 break; |
|
286 } |
|
287 } |
|
288 |
|
289 return EListInsideNoneListItem; |
|
290 } |
|
291 |
|
292 void CFepLayoutScrollableList::ScrollPageUp() |
|
293 { |
|
294 if (iCurrentPage >= 0 && iCurrentPage <= (iTotalPages - 1)) |
|
295 { |
|
296 if (iCurrentPage == 0) |
|
297 { |
|
298 iCurrentPage = iTotalPages - 1; |
|
299 } |
|
300 else |
|
301 { |
|
302 iCurrentPage--; |
|
303 } |
|
304 UpdateNaviButtonStates(); |
|
305 Draw(); |
|
306 UpdateArea( Rect(), EFalse); |
|
307 } |
|
308 |
|
309 #ifdef RD_TACTILE_FEEDBACK |
|
310 UpdateFeedbackArea(); |
|
311 #endif // RD_TACTILE_FEEDBACK |
|
312 } |
|
313 |
|
314 void CFepLayoutScrollableList::ScrollPageDown() |
|
315 { |
|
316 if (iCurrentPage >= 0 && iCurrentPage <= (iTotalPages - 1)) |
|
317 { |
|
318 if (iCurrentPage == iTotalPages - 1) |
|
319 { |
|
320 iCurrentPage = 0; |
|
321 } |
|
322 else |
|
323 { |
|
324 iCurrentPage++; |
|
325 } |
|
326 UpdateNaviButtonStates(); |
|
327 Draw(); |
|
328 UpdateArea( Rect(), EFalse); |
|
329 } |
|
330 |
|
331 #ifdef RD_TACTILE_FEEDBACK |
|
332 UpdateFeedbackArea(); |
|
333 #endif // RD_TACTILE_FEEDBACK |
|
334 } |
|
335 |
|
336 EXPORT_C void CFepLayoutScrollableList::UpdateNaviButtonStates() |
|
337 { |
|
338 iPageUp->SetDimmed( iTotalPages == 1 ); |
|
339 iPageDown->SetDimmed(iTotalPages == 1 ); |
|
340 } |
|
341 |
|
342 EXPORT_C void CFepLayoutScrollableList::CalcPageInfo() |
|
343 { |
|
344 iCurrentPage = 0; |
|
345 iTotalPages = (ItemArray().Count() + iOnePageItemCnt - 1) / iOnePageItemCnt; |
|
346 UpdateNaviButtonStates(); |
|
347 } |
|
348 |
|
349 EXPORT_C void CFepLayoutScrollableList::CalculateItemWidth() |
|
350 { |
|
351 TBuf<KDisplayTextLen> buf; |
|
352 CFont::TMeasureTextInput::TFlags flg = CFont::TMeasureTextInput::EFVisualOrder; |
|
353 if(iAlign == CGraphicsContext::ERight) |
|
354 flg = CFont::TMeasureTextInput::EFVisualOrderRightToLeft; |
|
355 |
|
356 const CFont* font = iFont; |
|
357 if(iTextLineSet) |
|
358 { |
|
359 TAknLayoutText textLayout; |
|
360 textLayout.LayoutText(TRect(0, 0, 1, 1), iTextLine); |
|
361 font = textLayout.Font(); |
|
362 } |
|
363 ASSERT(font); |
|
364 |
|
365 iItemSize.iWidth = iInitItemWidth; |
|
366 const RPointerArray<SItem>& allItems = ItemArray(); |
|
367 for(TInt i = 0; i < allItems.Count(); ++i) |
|
368 { |
|
369 TInt itemWidth = AknBidiTextUtils::MeasureTextBoundsWidth( |
|
370 *font, allItems[i]->iText, flg); |
|
371 if(itemWidth > iItemSize.iWidth) |
|
372 iItemSize.iWidth = itemWidth; |
|
373 } |
|
374 |
|
375 TPixelsTwipsAndRotation ptScreenSize; |
|
376 CCoeEnv::Static()->ScreenDevice()-> |
|
377 GetDefaultScreenSizeAndRotation(ptScreenSize); |
|
378 // calculate the length exclude the item |
|
379 TInt naviWidth = iNaviBtnShown? iNaviSize.iWidth : 0; |
|
380 TInt len = 4*iHorizontalMargin + naviWidth; |
|
381 if( iItemSize.iWidth + len > ptScreenSize.iPixelSize.iWidth) |
|
382 { |
|
383 iItemSize.iWidth = ptScreenSize.iPixelSize.iWidth - len; |
|
384 } |
|
385 } |
|
386 |
|
387 EXPORT_C void CFepLayoutScrollableList::DrawItem(TInt aItemIndex, TBool aItemActive) |
|
388 { |
|
389 // aItemIndex is relative to whole item array |
|
390 TBool isSpecial = ((aItemIndex == ItemArray().Count() - 1) && iSpecialItemOn); |
|
391 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
392 TRect itemRect = iItemRects[aItemIndex % iOnePageItemCnt]; |
|
393 TBool isFocus = aItemIndex == iCurFocusItem; |
|
394 |
|
395 if ( isSpecial ) |
|
396 { |
|
397 //mask bitmaps |
|
398 gc->Activate(MaskBitmapDevice()); |
|
399 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
400 gc->SetBrushColor(TRgb(KOpaqueColor));//Non transparent at all |
|
401 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
402 gc->SetPenSize(PenSize()); |
|
403 gc->SetPenColor(TRgb(KOpaqueColor)); |
|
404 gc->DrawRect(itemRect); |
|
405 // ----- draw bitmaps ----- |
|
406 gc->Activate(BitmapDevice()); |
|
407 |
|
408 TRect sepRect = itemRect; |
|
409 sepRect.iBr.iY = sepRect.iTl.iY + 2; |
|
410 sepRect.Move( 0, -4 ); |
|
411 SetListSeperationRect( sepRect ); |
|
412 // draw background frame of special item |
|
413 if( iSeperationBmp ) |
|
414 { |
|
415 TRect srcRect( TPoint( 0, 0 ), iSeperationBmp->SizeInPixels() ); |
|
416 |
|
417 if( iSeperationMaskBmp ) |
|
418 { |
|
419 gc->BitBltMasked( iSeperationRect.iTl, |
|
420 iSeperationBmp, |
|
421 srcRect, |
|
422 iSeperationMaskBmp, |
|
423 ETrue); |
|
424 |
|
425 } |
|
426 else |
|
427 { |
|
428 gc->BitBlt( iSeperationRect.iTl, |
|
429 iSeperationBmp, |
|
430 srcRect ); |
|
431 } |
|
432 } |
|
433 } |
|
434 if( isFocus ) |
|
435 { |
|
436 //mask bitmaps |
|
437 gc->Activate(MaskBitmapDevice()); |
|
438 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
439 gc->SetBrushColor(TRgb(KOpaqueColor));//Non transparent at all |
|
440 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
441 gc->SetPenSize(PenSize()); |
|
442 gc->SetPenColor(TRgb(KOpaqueColor)); |
|
443 gc->DrawRect(itemRect); |
|
444 |
|
445 // ----- draw bitmaps ----- |
|
446 gc->Activate(BitmapDevice()); |
|
447 |
|
448 // draw frame |
|
449 MAknsSkinInstance* skin = UiLayout()->SkinInstance(); |
|
450 TRect innerRect = itemRect; |
|
451 innerRect.Shrink(7, 7); |
|
452 AknsDrawUtils::DrawFrame(skin, |
|
453 *gc, |
|
454 itemRect, |
|
455 innerRect, |
|
456 aItemActive ? iItemActiveFrId : iItemFrId, |
|
457 KAknsIIDDefault); |
|
458 } |
|
459 |
|
460 CFepLayoutChoiceList::SItem* item = ItemArray()[aItemIndex]; |
|
461 const CFont* font = iFont; |
|
462 TRgb color = iFontColor; |
|
463 TInt baseLine = iBaselineOffset; |
|
464 |
|
465 // draw text |
|
466 if (iTextLineSet) |
|
467 { |
|
468 TAknLayoutText textLayout; |
|
469 textLayout.LayoutText(itemRect, iTextLine); |
|
470 |
|
471 TAknsQsnTextColorsIndex clrIndex; |
|
472 clrIndex = isFocus ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG20; |
|
473 |
|
474 color = KRgbBlack; |
|
475 if (AknsUtils::AvkonSkinEnabled()) |
|
476 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
|
477 color, KAknsIIDQsnTextColors, clrIndex ); |
|
478 font = textLayout.Font(); |
|
479 itemRect = textLayout.TextRect(); |
|
480 baseLine = itemRect.Height() / 2 + font->AscentInPixels() / 2; |
|
481 } |
|
482 |
|
483 if(font == NULL) |
|
484 return; |
|
485 |
|
486 gc->UseFont(font); |
|
487 gc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
488 gc->SetBrushColor(KRgbBlack); |
|
489 gc->SetPenColor(color); |
|
490 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
491 gc->SetPenSize(PenSize()); |
|
492 |
|
493 TBuf<KDisplayTextLen> buf; |
|
494 if ( iAlign == CGraphicsContext::ERight ) |
|
495 { |
|
496 AknBidiTextUtils::ConvertToVisualAndClip(item->iText, buf, *iFont, |
|
497 itemRect.Width(), itemRect.Width(), |
|
498 AknBidiTextUtils::ERightToLeft ); |
|
499 } |
|
500 else |
|
501 { |
|
502 AknBidiTextUtils::ConvertToVisualAndClip(item->iText, buf, *iFont, |
|
503 itemRect.Width(), itemRect.Width()); |
|
504 } |
|
505 |
|
506 if ( itemRect.Height() - font->FontMaxHeight() < KTextRectMargin ) |
|
507 { |
|
508 // Make sure the height of the area for drawing text is larger than |
|
509 // the max height of font by 4 pixels at least. |
|
510 // The piece of code is used to avoid clipping some characters, like 'g'. |
|
511 itemRect.SetHeight( font->FontMaxHeight() + KTextRectMargin ); |
|
512 } |
|
513 gc->DrawText(buf, itemRect, baseLine, iAlign); |
|
514 gc->DiscardFont(); |
|
515 } |
|
516 |
|
517 EXPORT_C void CFepLayoutScrollableList::ConstructL() |
|
518 { |
|
519 CFepLayoutPopupWnd::ConstructL(); |
|
520 |
|
521 //create page up/down buttons |
|
522 iPageUp = CAknFepCtrlCommonButton::NewL( |
|
523 UiLayout(), |
|
524 KCtrlIdPageUp, |
|
525 KAknsIIDQsnFrButtonNormal, |
|
526 KAknsIIDQsnFrButtonPressed, |
|
527 KAknsIIDQsnFrButtonInactive); |
|
528 iPageUp->AddEventObserver( this ); |
|
529 iPageDown = CAknFepCtrlCommonButton::NewL( |
|
530 UiLayout(), |
|
531 KCtrlIdPageDown, |
|
532 KAknsIIDQsnFrButtonNormal, |
|
533 KAknsIIDQsnFrButtonPressed, |
|
534 KAknsIIDQsnFrButtonInactive); |
|
535 iPageDown->AddEventObserver( this ); |
|
536 AddControlL( iPageUp ); |
|
537 AddControlL( iPageDown ); |
|
538 } |
|
539 |
|
540 EXPORT_C CFepLayoutScrollableList::CFepLayoutScrollableList(CFepUiLayout* aUiLayout, |
|
541 TInt aControlId, |
|
542 TSize aItemSize, |
|
543 TInt aHorizontalMargin, |
|
544 TInt aVerticalMargin, |
|
545 TSize aNaviSize, |
|
546 TSize aNaviInnerSize) |
|
547 :CFepLayoutChoiceList(aUiLayout, aControlId), |
|
548 iItemSize(aItemSize), |
|
549 iNaviSize(aNaviSize), |
|
550 iNaviInnerSize(aNaviInnerSize), |
|
551 iHorizontalMargin(aHorizontalMargin), |
|
552 iVerticalMargin(aVerticalMargin), |
|
553 iSpecialItemOn(ETrue), |
|
554 iNaviBtnShown( ETrue ), |
|
555 iOnePageItemCnt(4) |
|
556 { |
|
557 iCurFocusItem = -1; |
|
558 iInitItemWidth = aItemSize.iWidth; |
|
559 } |
|
560 |
|
561 EXPORT_C void CFepLayoutScrollableList::ReCalcLayout() |
|
562 { |
|
563 CalculateItemWidth(); |
|
564 CalcPageInfo(); |
|
565 iContentRect = TRect(TPoint(), TSize(2*iHorizontalMargin + iItemSize.iWidth, |
|
566 (iOnePageItemCnt + 1)*iVerticalMargin + iOnePageItemCnt*iItemSize.iHeight)); |
|
567 |
|
568 if (iNaviBtnShown) |
|
569 { |
|
570 TInt nWidthPager = 2 * iHorizontalMargin + iNaviSize.iWidth; |
|
571 TInt nXposPager = iContentRect.Width(); |
|
572 if (iAlign == CGraphicsContext::ERight) |
|
573 { |
|
574 iContentRect.Move(nWidthPager, 0); |
|
575 nXposPager = 0; |
|
576 } |
|
577 iScrollRect = TRect(TPoint(nXposPager, 0), TSize(nWidthPager, iContentRect.Height())); |
|
578 iPageUpRect = TRect(TPoint(iScrollRect.iTl.iX + iHorizontalMargin, |
|
579 iScrollRect.iTl.iY + iVerticalMargin), |
|
580 iNaviSize); |
|
581 |
|
582 TPoint innerTl ( iPageUpRect.iTl.iX + ( iNaviSize.iWidth - iNaviInnerSize.iWidth ) /2, |
|
583 iPageUpRect.iTl.iY + ( iNaviSize.iHeight - iNaviInnerSize.iHeight ) /2 ); |
|
584 iPageUp->SizeChanged( iPageUpRect, TRect( innerTl, iNaviInnerSize), ETrue ); |
|
585 |
|
586 iPageDownRect = TRect(TPoint(iPageUpRect.iTl.iX, |
|
587 iScrollRect.iBr.iY - iVerticalMargin - iNaviSize.iHeight), |
|
588 iNaviSize); |
|
589 |
|
590 innerTl = TPoint(iPageDownRect.iTl.iX + ( iNaviSize.iWidth - iNaviInnerSize.iWidth ) /2, |
|
591 iPageDownRect.iTl.iY + ( iNaviSize.iHeight - iNaviInnerSize.iHeight ) /2 ); |
|
592 iPageDown->SizeChanged( iPageDownRect, TRect(innerTl, iNaviInnerSize), ETrue ); |
|
593 |
|
594 iPageInfoRect = TRect(TPoint(iScrollRect.iTl.iX, |
|
595 iScrollRect.iTl.iY + iScrollRect.Height()/2 - iNaviSize.iHeight/2), |
|
596 iNaviSize); |
|
597 } |
|
598 else |
|
599 { |
|
600 iScrollRect = TRect(0, 0, 0, 0); |
|
601 } |
|
602 |
|
603 iItemRects.Reset(); |
|
604 for (TInt i = 0; i < iOnePageItemCnt; i++) |
|
605 { |
|
606 iItemRects.Append(TRect(TPoint(iContentRect.iTl.iX + iHorizontalMargin, |
|
607 iContentRect.iTl.iY + (i + 1)* iVerticalMargin + |
|
608 i * iItemSize.iHeight) , |
|
609 iItemSize)); |
|
610 } |
|
611 |
|
612 TRect ctrlRect = iContentRect; |
|
613 if (!iScrollRect.IsEmpty()) |
|
614 ctrlRect.BoundingRect(iScrollRect); |
|
615 SetRect(ctrlRect); |
|
616 UpdateNaviButtonStates(); |
|
617 } |
|
618 |
|
619 EXPORT_C void CFepLayoutScrollableList::HandleControlEvent(TInt aEventType, |
|
620 CFepUiBaseCtrl* aCtrl, |
|
621 const TDesC& /*aEventData*/) |
|
622 { |
|
623 if( aEventType == EEventButtonUp ) |
|
624 { |
|
625 if( aCtrl == iPageUp ) |
|
626 { |
|
627 ScrollPageUp(); |
|
628 } |
|
629 else if( aCtrl == iPageDown ) |
|
630 { |
|
631 ScrollPageDown(); |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 EXPORT_C void CFepLayoutScrollableList::UpdatePageInfoL( TInt aCurrentPage, TInt aTotalPage ) |
|
637 { |
|
638 if( iPageInfoResID == 0 ) |
|
639 return; |
|
640 |
|
641 if (iPageInfo) |
|
642 { |
|
643 delete iPageInfo; |
|
644 iPageInfo = NULL; |
|
645 } |
|
646 CArrayFix< TInt >* aInts = new( ELeave ) CArrayFixFlat< TInt >(2); |
|
647 CleanupStack::PushL(aInts); |
|
648 |
|
649 aInts->AppendL( aCurrentPage ); |
|
650 aInts->AppendL( aTotalPage ); |
|
651 iPageInfo = StringLoader::LoadL( iPageInfoResID, *aInts ); |
|
652 |
|
653 CleanupStack::PopAndDestroy(aInts); |
|
654 } |
|
655 |
|
656 EXPORT_C void CFepLayoutScrollableList::SetImgFrId(TAknsItemID aBgFrId, |
|
657 TAknsItemID aNaviFrId, |
|
658 TAknsItemID aNaviActiveFrId, |
|
659 TAknsItemID aNaviDimFrId, |
|
660 TAknsItemID aItemFrId, |
|
661 TAknsItemID aItemActiveFrId) |
|
662 { |
|
663 iBgFrId = aBgFrId; |
|
664 iItemFrId = aItemFrId; |
|
665 iItemActiveFrId = aItemActiveFrId; |
|
666 iPageUp->SetImageFrameId( aNaviFrId, aNaviActiveFrId, aNaviDimFrId ); |
|
667 iPageDown->SetImageFrameId( aNaviFrId, aNaviActiveFrId, aNaviDimFrId ); |
|
668 } |
|
669 |
|
670 EXPORT_C void CFepLayoutScrollableList::Move(const TPoint& aOffset) |
|
671 { |
|
672 CFepLayoutChoiceList::Move(aOffset); |
|
673 iContentRect.Move( aOffset ); |
|
674 for (TInt i = 0; i < iOnePageItemCnt && i < iItemRects.Count(); i++) |
|
675 { |
|
676 iItemRects[i].Move( aOffset ); |
|
677 } |
|
678 iScrollRect.Move( aOffset ); |
|
679 iPageInfoRect.Move( aOffset ); |
|
680 iSeperationRect.Move( aOffset ); |
|
681 } |
|
682 EXPORT_C void CFepLayoutScrollableList::SetListSeperationRect( const TRect& aRect ) |
|
683 { |
|
684 iSeperationRect = aRect; |
|
685 if( iSeperationBmp ) |
|
686 { |
|
687 AknIconUtils::SetSize(iSeperationBmp, aRect.Size(), EAspectRatioNotPreserved ); |
|
688 } |
|
689 if( iSeperationMaskBmp ) |
|
690 { |
|
691 AknIconUtils::SetSize(iSeperationMaskBmp, aRect.Size(), EAspectRatioNotPreserved ); |
|
692 } |
|
693 } |
|
694 |
|
695 |
|
696 |
|
697 EXPORT_C void CFepLayoutScrollableList::Hide(TBool aFlag) |
|
698 { |
|
699 CFepLayoutPopupWnd::Hide(aFlag); |
|
700 |
|
701 #ifdef RD_TACTILE_FEEDBACK |
|
702 if (!aFlag) |
|
703 { |
|
704 iLastPageItemRect = iRect; |
|
705 |
|
706 UpdateFeedbackArea(); |
|
707 |
|
708 if (!iPageUp->IsDimmed()) |
|
709 { |
|
710 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(iPageUp),iPageUp->Rect(),iPageUp->TactileFeedbackType()); |
|
711 } |
|
712 |
|
713 if (!iPageDown->IsDimmed()) |
|
714 { |
|
715 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(iPageDown),iPageDown->Rect(),iPageDown->TactileFeedbackType()); |
|
716 } |
|
717 } |
|
718 else |
|
719 { |
|
720 if (!iPageUp->IsDimmed()) |
|
721 { |
|
722 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(iPageUp),iPageUp->Rect()); |
|
723 } |
|
724 |
|
725 if (!iPageDown->IsDimmed()) |
|
726 { |
|
727 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(iPageDown), |
|
728 iPageDown->Rect()); |
|
729 } |
|
730 } |
|
731 #endif // RD_TACTILE_FEEDBACK |
|
732 } |
|
733 |
|
734 #ifdef RD_TACTILE_FEEDBACK |
|
735 void CFepLayoutScrollableList::UpdateFeedbackArea() |
|
736 { |
|
737 // calculate total height of all aviliable items in current page |
|
738 TInt curPageItemCount = 0; |
|
739 for (TInt i = iCurrentPage * iOnePageItemCnt; |
|
740 i < (iCurrentPage + 1) * iOnePageItemCnt && i < ItemArray().Count(); |
|
741 i++) |
|
742 { |
|
743 curPageItemCount++; |
|
744 } |
|
745 |
|
746 TRect itemRect(TPoint(iItemRects[0].iTl), |
|
747 TSize(iItemRects[0].Width(), iItemRects[0].Height() * curPageItemCount)); |
|
748 |
|
749 UiLayout()->ChangeFeedbackArea(reinterpret_cast<TInt>(this),itemRect,iLastPageItemRect); |
|
750 iLastPageItemRect = itemRect; |
|
751 } |
|
752 #endif // RD_TACTILE_FEEDBACK |
|
753 // End Of File |