|
1 /* |
|
2 * Copyright (c) 2007 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: Definition of the class CPbkxRclSearchResultListBox. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <AknsUtils.h> |
|
21 #include <eikclbd.h> |
|
22 |
|
23 #include <skinlayout.cdl.h> |
|
24 #include <aknlayoutscalable_apps.cdl.h> |
|
25 // --------------------- |
|
26 |
|
27 #include "cpbkxrclsearchresultlistbox.h" |
|
28 |
|
29 //////////////////////////////////////////////////////////////////////////// |
|
30 // CPbkxRclSearchResultListBox |
|
31 //////////////////////////////////////////////////////////////////////////// |
|
32 |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CPbkxRclSearchResultListBox::CPbkxRclSearchResultListBox |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CPbkxRclSearchResultListBox::CPbkxRclSearchResultListBox() : |
|
41 CAknSingleStyleListBox() |
|
42 { |
|
43 FUNC_LOG; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CPbkxRclSearchResultListBox::~CPbkxRclSearchResultListBox |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CPbkxRclSearchResultListBox::~CPbkxRclSearchResultListBox() |
|
51 { |
|
52 FUNC_LOG; |
|
53 } |
|
54 |
|
55 // -------------------------------------------------------------------------- |
|
56 // CPbkxRclSearchResultListBox::HandleScrollEventL |
|
57 // -------------------------------------------------------------------------- |
|
58 // |
|
59 void CPbkxRclSearchResultListBox::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
60 { |
|
61 // Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
62 TBool prevState = iShowPopupChar; |
|
63 iShowPopupChar = (aEventType == EEikScrollThumbDragHoriz || aEventType == EEikScrollThumbDragVert); |
|
64 if( prevState != iShowPopupChar ) |
|
65 { |
|
66 DrawDeferred(); |
|
67 } |
|
68 |
|
69 CAknSingleStyleListBox::HandleScrollEventL( aScrollBar, aEventType ); |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CPbkxRclSearchResultListBox::Draw |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 void CPbkxRclSearchResultListBox::Draw(const TRect& aRect ) const |
|
77 { |
|
78 CAknSingleStyleListBox::Draw(aRect); |
|
79 |
|
80 // Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
81 if( iShowPopupChar ) |
|
82 { |
|
83 CWindowGc& gc = SystemGc(); |
|
84 |
|
85 TRgb normal; |
|
86 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
87 normal, |
|
88 KAknsIIDQsnTextColors, |
|
89 EAknsCIQsnTextColorsCG6 ); |
|
90 |
|
91 TAknLayoutRect layout; |
|
92 layout.LayoutRect(Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane(0)); |
|
93 |
|
94 TAknLayoutRect cornerRect; |
|
95 // skinned draw uses submenu popup window skin (skinned border) |
|
96 cornerRect.LayoutRect( |
|
97 layout.Rect(), |
|
98 SkinLayout::Submenu_skin_placing_Line_2() ); |
|
99 |
|
100 TRect innerRect( layout.Rect() ); |
|
101 innerRect.Shrink( cornerRect.Rect().Width(), cornerRect.Rect().Height() ); |
|
102 |
|
103 if ( !AknsDrawUtils::DrawFrame( |
|
104 AknsUtils::SkinInstance(), |
|
105 gc, |
|
106 layout.Rect(), |
|
107 innerRect, |
|
108 KAknsIIDQsnFrPopupSub, |
|
109 KAknsIIDQsnFrPopupCenterSubmenu ) ) |
|
110 { |
|
111 // skinned border failed -> black border |
|
112 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
113 gc.SetBrushColor( KRgbBlack ); |
|
114 gc.DrawRect( layout.Rect() ); |
|
115 } |
|
116 |
|
117 TAknLayoutText textLayout; |
|
118 textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine()); |
|
119 |
|
120 TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex())); |
|
121 textLayout.DrawText(gc, desc.Mid(desc.Find(_L("\t")) + 1, 1), ETrue, normal ); |
|
122 } |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CPbkxRclSearchResultListBox::CreateItemDrawerL |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CPbkxRclSearchResultListBox::CreateItemDrawerL() |
|
130 { |
|
131 FUNC_LOG; |
|
132 CColumnListBoxData* data = CColumnListBoxData::NewL(); |
|
133 CleanupStack::PushL( data ); |
|
134 iItemDrawer = new ( ELeave ) CPbkxRclSearchResultItemDrawer( |
|
135 Model(), |
|
136 iEikonEnv->NormalFont(), |
|
137 data ); |
|
138 data->SetSkinEnabledL( ETrue ); |
|
139 CleanupStack::Pop( data ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CPbkxRclSearchResultListBox::MakeViewClassInstanceL |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 CListBoxView* CPbkxRclSearchResultListBox::MakeViewClassInstanceL() |
|
147 { |
|
148 return ( new (ELeave) CPbkxRclSearchResultListView() ); |
|
149 } |
|
150 |
|
151 //////////////////////////////////////////////////////////////////////////// |
|
152 // CPbkxRclSearchResultItemDrawer |
|
153 //////////////////////////////////////////////////////////////////////////// |
|
154 |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CPbkxRclSearchResultItemDrawer::CPbkxRclSearchResultItemDrawer |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 CPbkxRclSearchResultItemDrawer::CPbkxRclSearchResultItemDrawer( |
|
161 MTextListBoxModel* aTextListBoxModel, |
|
162 const CFont* aFont, |
|
163 CColumnListBoxData* aColumnData ) : |
|
164 CColumnListBoxItemDrawer( aTextListBoxModel, aFont, aColumnData ) |
|
165 { |
|
166 FUNC_LOG; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CPbkxRclSearchResultItemDrawer::~CPbkxRclSearchResultItemDrawer |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 CPbkxRclSearchResultItemDrawer::~CPbkxRclSearchResultItemDrawer() |
|
174 { |
|
175 FUNC_LOG; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CPbkxRclSearchResultItemDrawer::SetHighlightColor |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CPbkxRclSearchResultItemDrawer::SetHighlightColor( TRgb aColor ) |
|
183 { |
|
184 FUNC_LOG; |
|
185 iHighlightColor = aColor; |
|
186 iColorsSet = iColorsSet | EHighlighColorSet; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CPbkxRclSearchResultItemDrawer::SetColor |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CPbkxRclSearchResultItemDrawer::SetColor( TRgb aColor ) |
|
194 { |
|
195 FUNC_LOG; |
|
196 iColor = aColor; |
|
197 iColorsSet = iColorsSet | EColorSet; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CPbkxRclSearchResultItemDrawer::ResetColors |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CPbkxRclSearchResultItemDrawer::ResetColors( TBool aHighlightColor ) |
|
205 { |
|
206 FUNC_LOG; |
|
207 if ( aHighlightColor ) |
|
208 { |
|
209 iColorsSet = iColorsSet & ( ~EHighlighColorSet ); |
|
210 } |
|
211 else |
|
212 { |
|
213 iColorsSet = iColorsSet & ( ~EColorSet ); |
|
214 } |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CPbkxRclSearchResultItemDrawer::DrawItemText |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CPbkxRclSearchResultItemDrawer::DrawItemText( |
|
222 TInt aItemIndex, |
|
223 const TRect& aItemTextRect, |
|
224 TBool aItemIsCurrent, |
|
225 TBool aViewIsEmphasized, |
|
226 TBool aItemIsSelected ) const |
|
227 { |
|
228 FUNC_LOG; |
|
229 |
|
230 // force our own text colors to item drawer |
|
231 CPbkxRclSearchResultItemDrawer* ptr = |
|
232 const_cast<CPbkxRclSearchResultItemDrawer*>( this ); |
|
233 if ( iColorsSet & EColorSet ) |
|
234 { |
|
235 ptr->iTextColor = iColor; |
|
236 } |
|
237 |
|
238 if ( iColorsSet & EHighlighColorSet ) |
|
239 { |
|
240 ptr->iHighlightedTextColor = iHighlightColor; |
|
241 } |
|
242 |
|
243 // Disable AVKON skinning so that our own color definitions apply |
|
244 TBool skinEnabled = AknsUtils::AvkonSkinEnabled(); |
|
245 // Safe to ignore error |
|
246 TRAP_IGNORE( AknsUtils::SetAvkonSkinEnabledL( EFalse ) ); |
|
247 CColumnListBoxItemDrawer::DrawItemText( |
|
248 aItemIndex, |
|
249 aItemTextRect, |
|
250 aItemIsCurrent, |
|
251 aViewIsEmphasized, |
|
252 aItemIsSelected ); |
|
253 // Safe to ignore error |
|
254 TRAP_IGNORE( AknsUtils::SetAvkonSkinEnabledL( skinEnabled ) ); |
|
255 } |
|
256 |
|
257 //////////////////////////////////////////////////////////////////////////// |
|
258 // CPbkxRclSearchResultListView |
|
259 //////////////////////////////////////////////////////////////////////////// |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CPbkxRclSearchResultListView::DrawEmptyList |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void CPbkxRclSearchResultListView::DrawEmptyList(const TRect &aClientRect) const |
|
266 { |
|
267 // Disable AVKON skinning so that our own color definitions apply |
|
268 TBool skinEnabled = AknsUtils::AvkonSkinEnabled(); |
|
269 // Safe to ignore error |
|
270 TRAP_IGNORE( AknsUtils::SetAvkonSkinEnabledL( EFalse ) ); |
|
271 CAknColumnListBoxView::DrawEmptyList( aClientRect ); |
|
272 // Safe to ignore error |
|
273 TRAP_IGNORE( AknsUtils::SetAvkonSkinEnabledL( skinEnabled ) ); |
|
274 } |
|
275 |