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