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