|
1 /* |
|
2 * Copyright (c) 2002 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 <eikslb.h> |
|
20 #include <eikfrlb.h> |
|
21 #include <eikslbd.h> |
|
22 #include <AknUtils.h> |
|
23 #include <featmgr.h> |
|
24 #include "eikslbProt.h" |
|
25 #include "eikslbProtFactory.h" |
|
26 #include <layoutmetadata.cdl.h> |
|
27 #include <aknlayoutscalable_avkon.cdl.h> |
|
28 |
|
29 #include <AknTasHook.h> |
|
30 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
31 #include <aknlistloadertfx.h> |
|
32 #include <aknlistboxtfxinternal.h> |
|
33 #endif |
|
34 |
|
35 #include "akntrace.h" |
|
36 // |
|
37 // settings itemdrawer |
|
38 // |
|
39 |
|
40 EXPORT_C CSettingsListBoxItemDrawer::CSettingsListBoxItemDrawer( MTextListBoxModel* aTextListBoxModel, |
|
41 const CFont* aFont, |
|
42 CSettingsListBoxData* aSettingsData) |
|
43 : CFormattedCellListBoxItemDrawer( aTextListBoxModel, aFont, aSettingsData ) |
|
44 { |
|
45 } |
|
46 |
|
47 EXPORT_C CSettingsListBoxItemDrawer::~CSettingsListBoxItemDrawer() |
|
48 { |
|
49 } |
|
50 |
|
51 EXPORT_C CSettingsListBoxData* CSettingsListBoxItemDrawer::SettingsData() const |
|
52 { |
|
53 return STATIC_CAST(CSettingsListBoxData*,iData); |
|
54 } |
|
55 |
|
56 EXPORT_C void CSettingsListBoxItemDrawer::DrawItemText( TInt aItemIndex, |
|
57 const TRect& aItemTextRect, |
|
58 TBool aItemIsCurrent, |
|
59 TBool /*aViewIsEmphasized*/, |
|
60 TBool /*aItemIsSelected*/) const |
|
61 { |
|
62 _AKNTRACE_FUNC_ENTER; |
|
63 _AKNTRACE("DrawItemText: aItemIndex=%d, aItemTextRect=(%d,%d,%d,%d), aItemIsCurrent=%d", |
|
64 aItemIndex, aItemTextRect.iTl.iX, aItemTextRect.iTl.iY, aItemTextRect.iBr.iX, |
|
65 aItemTextRect.iBr.iY, aItemIsCurrent); |
|
66 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
67 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc ); |
|
68 if ( transApi ) |
|
69 { |
|
70 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
|
71 } |
|
72 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
73 iGc->SetBrushColor( AKN_LAF_COLOR( 0 ) ); |
|
74 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
75 if ( transApi ) |
|
76 { |
|
77 transApi->StopDrawing(); |
|
78 } |
|
79 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
80 |
|
81 DrawBackgroundAndSeparatorLines( aItemTextRect ); |
|
82 |
|
83 if ( aItemIsCurrent ) |
|
84 { |
|
85 FormattedCellData()->SetCurrentItemIndex( aItemIndex ); |
|
86 } |
|
87 |
|
88 FormattedCellData()->SetCurrentlyDrawnItemIndex( aItemIndex ); |
|
89 |
|
90 FormattedCellData()->DrawSettingHighlight( *iGc, aItemTextRect, aItemIsCurrent ); |
|
91 |
|
92 TBool drawBackground = ETrue; |
|
93 TPtrC temp = iModel->ItemText( aItemIndex ); |
|
94 TPtrC columnText; |
|
95 |
|
96 TextUtils::ColumnText( columnText, 3, &temp ); |
|
97 |
|
98 if ( columnText == KNullDesC ) |
|
99 { |
|
100 drawBackground = EFalse; |
|
101 } |
|
102 |
|
103 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
104 if ( transApi ) |
|
105 { |
|
106 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
|
107 iGc->SetClippingRect( iViewRect ); |
|
108 } |
|
109 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
110 |
|
111 // draw setting item's background |
|
112 if ( drawBackground ) |
|
113 { |
|
114 TAknLayoutRect outerRect; |
|
115 TAknWindowComponentLayout valuePane; |
|
116 #ifdef RD_LIST_STRETCH |
|
117 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
118 Layout_Meta_Data::IsListStretchingEnabled() && |
|
119 FormattedCellData()->StretchingEnabled() ) |
|
120 { |
|
121 valuePane = AknLayoutScalable_Avkon::set_value_pane_cp_vc( 0 ); |
|
122 } |
|
123 else |
|
124 #endif // RD_LIST_STRETCH |
|
125 { |
|
126 valuePane = AknLayoutScalable_Avkon::set_value_pane_cp( 0 ); |
|
127 } |
|
128 |
|
129 outerRect.LayoutRect( aItemTextRect, TAknWindowComponentLayout::Compose( |
|
130 valuePane, |
|
131 AknLayoutScalable_Avkon::bg_set_opt_pane( 0 ) ).LayoutLine() ); |
|
132 |
|
133 TBool frameDrawn = EFalse; |
|
134 MAknsControlContext *cc = AknsDrawUtils::ControlContext( FormattedCellData()->Control() ); |
|
135 |
|
136 if ( !cc ) |
|
137 { |
|
138 cc = FormattedCellData()->SkinBackgroundContext(); |
|
139 } |
|
140 |
|
141 if ( cc ) |
|
142 { |
|
143 TAknLayoutRect innerRect; |
|
144 innerRect.LayoutRect( aItemTextRect, TAknWindowComponentLayout::Compose( |
|
145 valuePane, |
|
146 AknLayoutScalable_Avkon::bg_set_opt_pane_g1() ).LayoutLine() ); |
|
147 |
|
148 frameDrawn = AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), |
|
149 *iGc, |
|
150 outerRect.Rect(), |
|
151 innerRect.Rect(), |
|
152 KAknsIIDQsnFrSetOptFoc, |
|
153 KAknsIIDQsnFrSetOptFocCenter ); |
|
154 } |
|
155 |
|
156 if ( !frameDrawn ) |
|
157 { |
|
158 iGc->SetBrushColor( AKN_LAF_COLOR( 243 ) ); |
|
159 iGc->Clear( outerRect.Rect() ); |
|
160 } |
|
161 } |
|
162 |
|
163 SetupGc( aItemIndex ); |
|
164 |
|
165 CFormattedCellListBoxData::TColors colors; |
|
166 |
|
167 TBufC<KMaxTotalDataLength> target; |
|
168 |
|
169 // Try to allocate buffer dynamically. If out of memory, use the fixed size stack buffer. |
|
170 // This size should be sufficient. |
|
171 TInt size = temp.Length() * 2; |
|
172 HBufC* buffer = NULL; |
|
173 |
|
174 if ( size > KMaxTotalDataLength ) |
|
175 { |
|
176 buffer = HBufC::New( size ); |
|
177 } |
|
178 |
|
179 TPtr des = ( buffer ? buffer->Des() : target.Des() ); |
|
180 TDesC* targetptr = &temp; |
|
181 |
|
182 if ( columnText == KNullDesC ) |
|
183 { |
|
184 #ifdef RD_LIST_STRETCH |
|
185 // If list stretching is used and the device is in landscape orientation |
|
186 // there is only one text cell available. Therefore, word wrapping |
|
187 // cannot be done. Instead the first text cell must be omitted and the |
|
188 // possible text moved to the second cell. If both text cells contain |
|
189 // data they are combined and the data is moved to the second cell (i.e. |
|
190 // the first cell is never drawn in landscape if list stretching is |
|
191 // turned on). |
|
192 if ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
193 Layout_Meta_Data::IsListStretchingEnabled() && |
|
194 FormattedCellData()->StretchingEnabled() ) |
|
195 { |
|
196 TBool swapCells = ETrue; |
|
197 TPtrC itemText; |
|
198 |
|
199 // check if cell swapping should be done at all |
|
200 for ( TInt i = 2; i <= 4; ++i ) |
|
201 { |
|
202 if ( TextUtils::ColumnText( itemText, i, targetptr ) == KErrNotFound ) |
|
203 { |
|
204 break; |
|
205 } |
|
206 |
|
207 if ( itemText != KNullDesC ) |
|
208 { |
|
209 swapCells = EFalse; |
|
210 break; |
|
211 } |
|
212 } |
|
213 |
|
214 TextUtils::ColumnText( itemText, 1, targetptr ); |
|
215 |
|
216 if ( swapCells && itemText.Length() > 0 ) |
|
217 { |
|
218 TPtrC secondaryText; |
|
219 TextUtils::ColumnText( secondaryText, 5, targetptr ); |
|
220 |
|
221 // remove text from the first text cell |
|
222 AknLAFUtils::ReplaceColumn( des, targetptr, (TDesC16*)&KNullDesC, KColumnListSeparator, 1 ); |
|
223 |
|
224 // ReplaceColumn does not update descriptor's length :( |
|
225 des.Set( buffer ? buffer->Des() : target.Des() ); |
|
226 |
|
227 TInt secondaryPos = 0; |
|
228 TPtrC temp; |
|
229 temp.Set( des ); |
|
230 |
|
231 // add separators if needed |
|
232 for ( TInt i = 0; i < 5; ++i ) |
|
233 { |
|
234 TInt position = temp.Locate( KColumnListSeparator ); |
|
235 |
|
236 if ( position != KErrNotFound ) |
|
237 { |
|
238 if ( position < temp.Length() ) |
|
239 { |
|
240 ++position; |
|
241 } |
|
242 |
|
243 secondaryPos += position; |
|
244 } |
|
245 else |
|
246 { |
|
247 des.Append( KColumnListSeparator ); |
|
248 secondaryPos = des.Length(); |
|
249 } |
|
250 |
|
251 temp.Set( des.Mid( secondaryPos ) ); |
|
252 } |
|
253 |
|
254 des.Insert( secondaryPos, itemText ); |
|
255 |
|
256 if ( secondaryText != KNullDesC ) |
|
257 { |
|
258 _LIT( KEmptySpace, " " ); |
|
259 des.Insert( secondaryPos + itemText.Length(), KEmptySpace ); |
|
260 } |
|
261 |
|
262 targetptr = &des; |
|
263 } |
|
264 } |
|
265 else |
|
266 { |
|
267 WordWrapListItem( des, *targetptr, 1, 5, aItemIndex ); |
|
268 // Set again because ReplaceColumn in WordWrapListItem does not update the length to 'des' ! |
|
269 des.Set( buffer ? buffer->Des() : target.Des() ); |
|
270 targetptr = &des; |
|
271 } |
|
272 #else |
|
273 WordWrapListItem( des, temp, 1, 5, aItemIndex ); |
|
274 // Set again because ReplaceColumn in WordWrapListItem does not update the length to 'des' ! |
|
275 des.Set( buffer ? buffer->Des() : target.Des() ); |
|
276 targetptr = &des; |
|
277 #endif // RD_LIST_STRETCH |
|
278 } |
|
279 |
|
280 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
281 if ( transApi ) |
|
282 { |
|
283 iGc->CancelClippingRect(); |
|
284 transApi->StopDrawing(); |
|
285 } |
|
286 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
287 |
|
288 if (FormattedCellData()->IsMarqueeOn() && |
|
289 FormattedCellData()->CurrentMarqueeItemIndex() != aItemIndex && |
|
290 aItemIsCurrent) |
|
291 { |
|
292 FormattedCellData()->ResetMarquee(); |
|
293 FormattedCellData()->SetCurrentMarqueeItemIndex(aItemIndex); |
|
294 } |
|
295 |
|
296 SettingsData()->Draw( Properties( aItemIndex ), |
|
297 *iGc, |
|
298 targetptr, |
|
299 aItemTextRect, |
|
300 aItemIsCurrent, |
|
301 colors ); |
|
302 |
|
303 delete buffer; |
|
304 _AKNTRACE_FUNC_EXIT; |
|
305 } |
|
306 |
|
307 EXPORT_C void CSettingsListBoxItemDrawer::CFormattedCellListBoxItemDrawer_Reserved() |
|
308 { |
|
309 } |
|
310 |
|
311 // |
|
312 // Settings listbox |
|
313 // |
|
314 EXPORT_C CEikSettingsListBox::CEikSettingsListBox() |
|
315 { |
|
316 _AKNTRACE_FUNC_ENTER; |
|
317 AKNTASHOOK_ADD( this, "CEikSettingsListBox" ); |
|
318 _AKNTRACE_FUNC_EXIT; |
|
319 } |
|
320 |
|
321 EXPORT_C CSettingsListBoxItemDrawer* CEikSettingsListBox::ItemDrawer() const |
|
322 { |
|
323 return(CSettingsListBoxItemDrawer*)iItemDrawer; |
|
324 } |
|
325 |
|
326 EXPORT_C void CEikSettingsListBox::CreateItemDrawerL() |
|
327 { |
|
328 _AKNTRACE_FUNC_ENTER; |
|
329 CSettingsListBoxData* cellData=CSettingsListBoxData::NewL(); |
|
330 CleanupStack::PushL( cellData ); |
|
331 |
|
332 if ( FeatureManager::FeatureSupported( KFeatureIdSettingsProtection ) ) |
|
333 { |
|
334 iItemDrawer = SettingsProtListBoxItemDrawerFactory:: |
|
335 CreateSettingsProtListBoxItemDrawerL( |
|
336 Model(), |
|
337 CEikonEnv::Static()->NormalFont(), |
|
338 cellData, |
|
339 this ); |
|
340 } |
|
341 else |
|
342 { |
|
343 iItemDrawer = new ( ELeave ) CSettingsListBoxItemDrawer( |
|
344 Model(), CEikonEnv::Static()->NormalFont(), cellData ); |
|
345 } |
|
346 |
|
347 CleanupStack::Pop(); |
|
348 _AKNTRACE_FUNC_EXIT; |
|
349 } |
|
350 |
|
351 EXPORT_C CListBoxView* CEikSettingsListBox::MakeViewClassInstanceL() |
|
352 { |
|
353 return new ( ELeave )CSettingsListBoxView; |
|
354 } |
|
355 |
|
356 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems())) |
|
357 |
|
358 EXPORT_C void CEikSettingsListBox::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
359 { |
|
360 _AKNTRACE_FUNC_ENTER; |
|
361 CEikFormattedCellListBox::HandlePointerEventL(aPointerEvent); |
|
362 _AKNTRACE_FUNC_EXIT; |
|
363 } |
|
364 |
|
365 EXPORT_C void* CEikSettingsListBox::ExtensionInterface( TUid /*aInterface*/ ) |
|
366 { |
|
367 return NULL; |
|
368 } |
|
369 |
|
370 EXPORT_C void CEikSettingsListBox::CEikListBox_Reserved() |
|
371 { |
|
372 } |
|
373 |
|
374 EXPORT_C void CSettingsListBoxView::Draw(const TRect* clipRect) const |
|
375 { |
|
376 _AKNTRACE_FUNC_ENTER; |
|
377 CFormattedCellListBoxView::Draw( clipRect ); |
|
378 _AKNTRACE_FUNC_EXIT; |
|
379 } |
|
380 |
|
381 EXPORT_C void CSettingsListBoxView::DrawItem( TInt aItemIndex ) const |
|
382 { |
|
383 _AKNTRACE_FUNC_ENTER; |
|
384 _AKNTRACE("DrawItem: aItemIndex=%d",aItemIndex); |
|
385 CListBoxView::DrawItem( aItemIndex ); |
|
386 _AKNTRACE_FUNC_EXIT; |
|
387 } |
|
388 |
|
389 EXPORT_C TAny* CSettingsListBoxView::Reserved_1() |
|
390 { |
|
391 return NULL; |
|
392 } |
|
393 |
|
394 // End of File |