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