|
1 /* |
|
2 * Copyright (c) 2010 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: Easy dialing listbox list item drawer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "easydialinglistboxitemdrawer.h" |
|
22 #include "easydialinglistboxdata.h" |
|
23 #include "easydialinglistbox.h" |
|
24 #include "easydialinglistboxview.h" |
|
25 |
|
26 #include <aknlistloadertfx.h> |
|
27 #include <aknlistboxtfxinternal.h> |
|
28 #include <aknlistboxtfx.h> |
|
29 |
|
30 #include <akntransitionutils.h> |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 |
|
34 // EXTERNAL FUNCTION PROTOTYPES |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 const TInt KTextColorFallBack = 215; |
|
39 const TInt KMatchingTextColorFallBack = 0; |
|
40 const TInt KMatchingTextBackgroundFallBack = 243; |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 |
|
44 /* |
|
45 * ============================================================================== |
|
46 * |
|
47 * |
|
48 * class CEasyDialingListBoxItemDrawer |
|
49 * |
|
50 * |
|
51 * ============================================================================== |
|
52 */ |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CEasyDialingListBoxItemDrawer |
|
56 // Constructor |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CEasyDialingListBoxItemDrawer::CEasyDialingListBoxItemDrawer( |
|
60 MTextListBoxModel* aTextListBoxModel, |
|
61 const CFont* aFont, |
|
62 CFormattedCellListBoxData* aFormattedCellData) : |
|
63 CFormattedCellListBoxItemDrawer( aTextListBoxModel, aFont, aFormattedCellData) |
|
64 { |
|
65 |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // EasyDialingCellData |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CEasyDialingListBoxData* CEasyDialingListBoxItemDrawer::EasyDialingCellData() const |
|
75 { |
|
76 return STATIC_CAST( CEasyDialingListBoxData*, iData ); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // DrawItem |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CEasyDialingListBoxItemDrawer::DrawItem( |
|
86 TInt aItemIndex, |
|
87 TPoint aItemRectPos, |
|
88 TBool aItemIsSelected, |
|
89 TBool aItemIsCurrent, |
|
90 TBool aViewIsEmphasized, |
|
91 TBool aViewIsDimmed) const |
|
92 { |
|
93 CFormattedCellListBoxItemDrawer::DrawItem( aItemIndex, aItemRectPos, aItemIsSelected, aItemIsCurrent, aViewIsEmphasized, aViewIsDimmed); |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // DrawItemText |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CEasyDialingListBoxItemDrawer::DrawItemText( |
|
103 TInt aItemIndex, |
|
104 const TRect& aItemTextRect, |
|
105 TBool aItemIsCurrent, |
|
106 TBool aViewIsEmphasized, |
|
107 TBool /* aItemIsSelected */) const |
|
108 { |
|
109 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc ); |
|
110 if ( transApi ) |
|
111 { |
|
112 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
|
113 } |
|
114 |
|
115 iGc->SetPenColor(iTextColor); |
|
116 iGc->SetBrushColor(iBackColor); |
|
117 |
|
118 TPtrC temp=iModel->ItemText(aItemIndex); |
|
119 |
|
120 SetupGc(aItemIndex); |
|
121 if ( transApi ) |
|
122 { |
|
123 transApi->StopDrawing(); |
|
124 } |
|
125 |
|
126 // TBool removeicon = (!aItemIsSelected && !ItemMarkReverse()) || (aItemIsSelected && ItemMarkReverse()); |
|
127 |
|
128 CEasyDialingListBoxData::TExtendedColors colors; |
|
129 colors.iText=iTextColor; |
|
130 colors.iBack=iBackColor; |
|
131 colors.iHighlightedText = iHighlightedTextColor; |
|
132 colors.iHighlightedBack = iHighlightedBackColor; |
|
133 colors.iMatchingText = iMatchingText; |
|
134 colors.iMatchingBack = iMatchingBack; |
|
135 |
|
136 DrawBackgroundAndSeparatorLines( aItemTextRect ); |
|
137 |
|
138 TBool highlightShown = ETrue; |
|
139 if ( ( FormattedCellData()->RespectFocus() && !aViewIsEmphasized ) ) |
|
140 { |
|
141 if ( transApi ) |
|
142 { |
|
143 transApi->Remove( MAknListBoxTfxInternal::EListHighlight ); |
|
144 } |
|
145 |
|
146 highlightShown = EFalse; |
|
147 } |
|
148 |
|
149 // normal drawing without mark icon |
|
150 EasyDialingCellData()->DrawData( |
|
151 Properties(aItemIndex), |
|
152 *iGc, |
|
153 &temp, |
|
154 aItemTextRect, |
|
155 aItemIsCurrent && highlightShown, |
|
156 colors ); |
|
157 |
|
158 //currently few themes doesnt support IsListSeperatorLines method therefore it is commented out |
|
159 // for the time being in the below if loop |
|
160 |
|
161 if ( /*AknsDrawUtils::IsListSeperatorLines( AknsUtils::SkinInstance() ) &&*/ aItemTextRect.iTl.iY > iViewRect.iTl.iY ) |
|
162 { |
|
163 if ( transApi ) |
|
164 { |
|
165 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
|
166 } |
|
167 |
|
168 TRgb lineColor; |
|
169 TInt retVal = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), lineColor, KAknsIIDFsLineColors, |
|
170 EAknsCIFsLineColorsCG1); |
|
171 // we are fetching lineColor from the skin.Incase, if there isn't any lineColor then we are using |
|
172 //iMatchingBack as a backup line Color |
|
173 if( retVal == KErrNone) |
|
174 { |
|
175 iGc->SetPenColor(lineColor); |
|
176 } |
|
177 else |
|
178 { |
|
179 iGc->SetPenColor(iMatchingBack); |
|
180 } |
|
181 iGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
182 iGc->DrawLine( aItemTextRect.iTl, TPoint( aItemTextRect.iBr.iX, aItemTextRect.iTl.iY) ); |
|
183 |
|
184 if ( transApi ) |
|
185 { |
|
186 transApi->StopDrawing(); |
|
187 } |
|
188 } |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // SetColors |
|
194 // |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CEasyDialingListBoxItemDrawer::SetColors() |
|
198 { |
|
199 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
200 |
|
201 if ( !skin ) |
|
202 { |
|
203 // These values are copied from "aknlist.cpp". |
|
204 // This branch should be never take, and can be considered protective programming. |
|
205 iTextColor = AKN_LAF_COLOR_STATIC( KTextColorFallBack); |
|
206 iHighlightedTextColor = AKN_LAF_COLOR_STATIC( KTextColorFallBack ); |
|
207 iMatchingText = AKN_LAF_COLOR_STATIC( KMatchingTextColorFallBack ); |
|
208 iMatchingBack = AKN_LAF_COLOR_STATIC( KMatchingTextBackgroundFallBack ); |
|
209 } |
|
210 |
|
211 else |
|
212 { |
|
213 AknsUtils::GetCachedColor( skin, |
|
214 iTextColor, |
|
215 KAknsIIDQsnTextColors, |
|
216 EAknsCIQsnTextColorsCG7 ); |
|
217 |
|
218 AknsUtils::GetCachedColor( skin, |
|
219 iHighlightedTextColor, |
|
220 KAknsIIDQsnTextColors, |
|
221 EAknsCIQsnTextColorsCG10 ); |
|
222 |
|
223 AknsUtils::GetCachedColor( skin, |
|
224 iMatchingText, |
|
225 KAknsIIDQsnTextColors, |
|
226 EAknsCIQsnTextColorsCG24 ); |
|
227 |
|
228 AknsUtils::GetCachedColor( skin, |
|
229 iMatchingBack, |
|
230 KAknsIIDQsnHighlightColors, |
|
231 EAknsCIQsnHighlightColorsCG2 ); |
|
232 } |
|
233 } |
|
234 |
|
235 |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // DrawBackgroundAndSeparatorLines |
|
239 // |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 void CEasyDialingListBoxItemDrawer::DrawBackgroundAndSeparatorLines( const TRect& aItemTextRect ) const |
|
243 { |
|
244 CCoeControl* control = FormattedCellData()->Control(); |
|
245 |
|
246 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc ); |
|
247 |
|
248 if ( transApi && !transApi->EffectsDisabled() ) |
|
249 { |
|
250 MAknListBoxTfx* tfxApi = CAknListLoader::TfxApi( iGc ); |
|
251 |
|
252 if ( tfxApi ) |
|
253 { |
|
254 tfxApi->EnableEffects( ETrue ); |
|
255 } |
|
256 } |
|
257 |
|
258 if ( transApi ) |
|
259 { |
|
260 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
|
261 } |
|
262 TBool bgDrawn( EFalse ); |
|
263 |
|
264 if ( control ) |
|
265 { |
|
266 MAknsControlContext *cc = AknsDrawUtils::ControlContext( control ); |
|
267 |
|
268 bgDrawn = AknsDrawUtils::DrawBackground( |
|
269 AknsUtils::SkinInstance(), |
|
270 cc, |
|
271 control, |
|
272 *Gc(), |
|
273 aItemTextRect.iTl, |
|
274 aItemTextRect, |
|
275 KAknsDrawParamDefault ); |
|
276 } |
|
277 |
|
278 if ( !bgDrawn ) |
|
279 { |
|
280 iGc->Clear( aItemTextRect ); |
|
281 } |
|
282 if ( transApi ) |
|
283 { |
|
284 transApi->StopDrawing(); |
|
285 } |
|
286 } |
|
287 |
|
288 // end of file |