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