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 <ganes/HgSingleLargeList.h> |
|
20 #include <ganes/HgItem.h> |
|
21 #include "HgMarquee.h" |
|
22 #include "HgLayoutData.h" |
|
23 #include "HgIndicatorManager.h" |
|
24 #include "HgDrawUtils.h" |
|
25 #include "HgConstants.h" |
|
26 |
|
27 #include <AknsUtils.h> |
|
28 #include <AknUtils.h> |
|
29 #include <AknsDrawUtils.h> |
|
30 |
|
31 #include <layoutmetadata.cdl.h> |
|
32 #include <aknlayoutscalable_avkon.cdl.h> |
|
33 #include <gulicon.h> |
|
34 |
|
35 using namespace AknLayoutScalable_Avkon; |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CHgSingleLargeList::NewL() |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CHgSingleLargeList* CHgSingleLargeList::NewL( |
|
42 const TRect& aRect, |
|
43 TInt aItemCount, |
|
44 CGulIcon* aDefaultIcon, |
|
45 RWsSession* aSession) |
|
46 { |
|
47 CHgSingleLargeList* self = new ( ELeave ) CHgSingleLargeList( |
|
48 aItemCount, |
|
49 aDefaultIcon ); |
|
50 |
|
51 CleanupStack::PushL (self ); |
|
52 self->ConstructL( aRect, aSession ); |
|
53 CleanupStack::Pop (self ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CHgSingleLargeList::~CHgSingleLargeList() |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CHgSingleLargeList::~CHgSingleLargeList( ) |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CHgSingleLargeList::PreferredImageSize() |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 EXPORT_C TSize CHgSingleLargeList::PreferredImageSize() |
|
71 { |
|
72 TAknLayoutRect image; |
|
73 image.LayoutRect(TRect(), list_single_large_graphic_pane_g1( 0 )); |
|
74 return image.Rect().Size(); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CHgSingleLargeList::HandleSizeChanged() |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CHgSingleLargeList::HandleSizeChanged() |
|
82 { |
|
83 CHgList::HandleSizeChanged(); |
|
84 |
|
85 iLayoutData->SetItemLayout(list_single_large_graphic_pane( 0, 0 )); |
|
86 iLayoutData->SetIconLayout(list_single_large_graphic_pane_g1( 2 )); |
|
87 for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i) |
|
88 iLayoutData->SetTitleLayout( i, list_single_large_graphic_pane_t1( i )); |
|
89 iLayoutData->SetFirstIndicatorLayout(list_single_large_graphic_pane_g3(0)); |
|
90 iLayoutData->SetSecondIndicatorLayout(list_single_large_graphic_pane_g2(1)); |
|
91 |
|
92 // Get the Row rect. |
|
93 TAknLayoutRect layout; |
|
94 layout.LayoutRect(ListRect(), iLayoutData->ItemLayout()); |
|
95 iRowHeight = layout.Rect().Height(); |
|
96 |
|
97 // Icon rect. |
|
98 TAknLayoutRect image; |
|
99 image.LayoutRect(layout.Rect(), iLayoutData->IconLayout()); |
|
100 iImageSize = image.Rect().Size(); |
|
101 |
|
102 // Indicator Rect. |
|
103 TAknLayoutRect indicator; |
|
104 indicator.LayoutRect(layout.Rect(), iLayoutData->FirstIndicatorLayout()); |
|
105 iIndicatorSize = indicator.Rect().Size(); |
|
106 |
|
107 iItemsOnScreen = iHeight / iRowHeight; |
|
108 iHeight = iItemsOnScreen * iRowHeight; |
|
109 |
|
110 if( iCurrentRow != KErrNotFound ) |
|
111 FitTopItemToView( iCurrentRow ); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CHgDoubleGraphicList::DrawItem() |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CHgSingleLargeList::DrawItem( TInt aIndex, const TRect& aRect ) const |
|
119 { |
|
120 // Get the Icon |
|
121 CHgItem* item = iItems[aIndex]; |
|
122 CGulIcon* icon = item->Icon() ? item->Icon() : iDefaultIcon; |
|
123 |
|
124 TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags()); |
|
125 |
|
126 CWindowGc& gc = SystemGc(); |
|
127 |
|
128 // Highlight the row if it's selected |
|
129 TRgb color = iColor; |
|
130 if( aIndex == iSelectedIndex ) |
|
131 { |
|
132 DrawHighlight( aRect, color ); |
|
133 |
|
134 // Draw first line text |
|
135 iDrawUtils->DrawTextMarquee( |
|
136 gc, |
|
137 aRect, |
|
138 iLayoutData->TitleLayout(indicators), |
|
139 item->Title(), |
|
140 color, 0); |
|
141 |
|
142 ResetClippingRect( gc ); |
|
143 } |
|
144 else |
|
145 { |
|
146 // Draw first line text |
|
147 iDrawUtils->DrawText( |
|
148 gc, |
|
149 aRect, |
|
150 iLayoutData->TitleLayout(indicators), |
|
151 item->Title(), |
|
152 color); |
|
153 } |
|
154 |
|
155 // Draw the icon |
|
156 iDrawUtils->DrawImage(gc, aRect, iLayoutData->IconLayout(), *icon); |
|
157 |
|
158 // Draw the indicators. |
|
159 iIndicatorManager->DrawIndicators( |
|
160 gc, |
|
161 aRect, |
|
162 item->Flags(), |
|
163 iLayoutData->FirstIndicatorLayout(), |
|
164 iLayoutData->SecondIndicatorLayout() ); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CHgSingleLargeList::CHgSingleLargeList() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 CHgSingleLargeList::CHgSingleLargeList( TInt aItemCount, |
|
172 CGulIcon* aDefaultIcon ) |
|
173 : CHgList( aItemCount, aDefaultIcon ) |
|
174 { |
|
175 |
|
176 } |
|
177 |
|
178 |
|
179 |
|
180 // End of file |
|