|
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: A visualizer for data items with plain text. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
20 //#include <fsconfig.h> |
|
21 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
22 |
|
23 #include "emailtrace.h" |
|
24 #include "fstreeplainonelineitemvisualizer.h" |
|
25 #include "fstreeplainonelineitemdata.h" |
|
26 #include "fstreelist.h" |
|
27 #include "fslayoutmanager.h" |
|
28 #include "fstextstylemanager.h" |
|
29 #include "fsalftextstylemanager.h" |
|
30 #include "fsmarqueeclet.h" |
|
31 #include <touchlogicalfeedback.h> |
|
32 |
|
33 // <cmail> SF |
|
34 #include <alf/alfanchorlayout.h> |
|
35 #include <alf/alfimagevisual.h> |
|
36 #include <alf/alfviewportlayout.h> |
|
37 #include <alf/alftextvisual.h> |
|
38 #include <alf/alfimage.h> |
|
39 #include <alf/alfenv.h> |
|
40 #include <alf/alftextstyle.h> |
|
41 |
|
42 #include <alf/alfevent.h> |
|
43 #include <alf/alfmappingfunctions.h> |
|
44 // </cmail> |
|
45 |
|
46 // ======== MEMBER FUNCTIONS ======== |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Two-phased constructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C CFsTreePlainOneLineItemVisualizer* |
|
53 CFsTreePlainOneLineItemVisualizer::NewL( CAlfControl& aOwnerControl ) |
|
54 { |
|
55 CFsTreePlainOneLineItemVisualizer* self = |
|
56 new( ELeave ) CFsTreePlainOneLineItemVisualizer( aOwnerControl ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL( ); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // C++ destructor. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CFsTreePlainOneLineItemVisualizer::~CFsTreePlainOneLineItemVisualizer() |
|
68 { |
|
69 FUNC_LOG; |
|
70 delete iTextMarquee; |
|
71 } |
|
72 |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Returns visualizer's type. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 TFsTreeItemVisualizerType CFsTreePlainOneLineItemVisualizer::Type() const |
|
79 { |
|
80 FUNC_LOG; |
|
81 return EFsTreePlainOneLineItemVisualizer; |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // From class MFsTreeItemVisualizer. |
|
87 // Sets the size of the item visualization when item is not in expanded |
|
88 // state. The value is taken from layout manager. |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 void CFsTreePlainOneLineItemVisualizer::UpdateLayout( |
|
92 const CFsTreePlainOneLineItemData* aData, |
|
93 const TInt aIndentation ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 TRect rect; |
|
97 |
|
98 TAlfTimedPoint tpMainIconTl, tpMainIconBr; |
|
99 TAlfTimedPoint tpTextTl, tpTextBr; |
|
100 TAlfTimedPoint tpMarkIconTl, tpMarkIconBr; |
|
101 TAlfTimedPoint tpMenuIconTl, tpMenuIconBr; |
|
102 |
|
103 CFsLayoutManager::TFsLayoutMetrics mainIconMetrics = |
|
104 CFsLayoutManager::EFsLmListSingleDycRowPaneG1; |
|
105 CFsLayoutManager::TFsLayoutMetrics markIconMetrics = |
|
106 CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
107 CFsLayoutManager::TFsLayoutMetrics menuIconMetrics = |
|
108 CFsLayoutManager::EFsLmListSingleDycRowPaneG3; |
|
109 CFsLayoutManager::TFsLayoutMetrics textMetrics = |
|
110 CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1; |
|
111 |
|
112 TInt mainIconVariety( 0 ); |
|
113 TInt markIconVariety( 0 ); |
|
114 TInt menuIconVariety( 0 ); |
|
115 TInt textPaneVariety( 0 ); |
|
116 |
|
117 if (aData->IsIconSet() || IsLayoutHintSet( CFsTreeItemVisualizerBase::EPopupLayout )) |
|
118 { |
|
119 if (iFlags & KFsTreeListItemMarked) |
|
120 { |
|
121 if (iMenu && (iFlags & KFsTreeListItemFocused)) |
|
122 { |
|
123 //mainIcon + markIcon + menuIcon |
|
124 //the metrics defined when declared |
|
125 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1; |
|
126 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3; |
|
127 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
128 mainIconVariety = 3; |
|
129 textPaneVariety = 3; |
|
130 menuIconVariety = 1; |
|
131 markIconVariety = 2; |
|
132 } |
|
133 else |
|
134 { |
|
135 //mainIcon + markIcon |
|
136 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1; |
|
137 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
138 mainIconVariety = 4; |
|
139 textPaneVariety = 4; |
|
140 markIconVariety = 3; |
|
141 } |
|
142 } |
|
143 else |
|
144 { |
|
145 if ((iFlags & KFsTreeListItemHasMenu) |
|
146 && (iFlags & KFsTreeListItemFocused)) |
|
147 { |
|
148 //mainIcon + menuIcon |
|
149 mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1; |
|
150 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
151 mainIconVariety = 4; |
|
152 textPaneVariety = 4; |
|
153 menuIconVariety = 3; |
|
154 } |
|
155 else |
|
156 { |
|
157 if ( IsLayoutHintSet( EFolderLayout ) ) |
|
158 { |
|
159 //mainIcon |
|
160 mainIconMetrics = CFsLayoutManager::EFsLmFolderListMediumLineG1; |
|
161 textMetrics = CFsLayoutManager::EFsLmFolderListMediumLineT1; |
|
162 } |
|
163 else |
|
164 { |
|
165 //mainIcon |
|
166 textMetrics = CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneT1; |
|
167 mainIconMetrics = CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneG2; |
|
168 mainIconVariety = 0; |
|
169 textPaneVariety = 2; |
|
170 } |
|
171 } |
|
172 } |
|
173 } |
|
174 else // !aData->IsIconSet() |
|
175 { |
|
176 if (iFlags & KFsTreeListItemMarked) |
|
177 { |
|
178 if (iMenu && (iFlags & KFsTreeListItemFocused)) |
|
179 { |
|
180 //markIcon + menuIcon |
|
181 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3; |
|
182 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
183 menuIconVariety = 2; |
|
184 markIconVariety = 4; |
|
185 textPaneVariety = 6; |
|
186 } |
|
187 else |
|
188 { |
|
189 //markIcon |
|
190 markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
191 markIconVariety = 5; |
|
192 textPaneVariety = 7; |
|
193 } |
|
194 } |
|
195 else |
|
196 { |
|
197 if ((iFlags & KFsTreeListItemHasMenu) |
|
198 && (iFlags & KFsTreeListItemFocused)) |
|
199 { |
|
200 //menuIcon |
|
201 menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4; |
|
202 menuIconVariety = 5; |
|
203 textPaneVariety = 7; |
|
204 } |
|
205 else |
|
206 { |
|
207 //plain item |
|
208 textPaneVariety = 8; |
|
209 } |
|
210 } |
|
211 } |
|
212 //layout manager is queried for medium values - LM returnes rects based on phone's global text settings |
|
213 |
|
214 TRect parentLayoutRect = TRect(iParentLayout->Size().Target().AsSize()); |
|
215 parentLayoutRect.Resize(-(iParentLayout->HorizontalPadding()*2), 0); |
|
216 |
|
217 if (iFlags & KFsTreeListItemManagedLayout) |
|
218 { |
|
219 CFsLayoutManager::LayoutMetricsSize( |
|
220 parentLayoutRect, |
|
221 CFsLayoutManager::EFsLmListSingleDycRowPane, |
|
222 iSize ); |
|
223 } |
|
224 |
|
225 TRect currentSize = iSize; |
|
226 if ( !IsLayoutHintSet( EFolderLayout ) ) |
|
227 { |
|
228 CFsLayoutManager::LayoutMetricsRect(currentSize, CFsLayoutManager::EFsLmListSingleDycRowPane, currentSize); |
|
229 } |
|
230 if (CFsLayoutManager::IsMirrored()) |
|
231 { |
|
232 currentSize.iBr = currentSize.iBr - TPoint(aIndentation, 0); |
|
233 } |
|
234 else |
|
235 { |
|
236 currentSize.iTl = currentSize.iTl + TPoint(aIndentation, 0); |
|
237 } |
|
238 |
|
239 CFsLayoutManager::LayoutMetricsRect( |
|
240 currentSize, |
|
241 mainIconMetrics, |
|
242 rect, |
|
243 mainIconVariety ); |
|
244 tpMainIconTl.SetTarget(TAlfRealPoint(rect.iTl)); |
|
245 tpMainIconBr.SetTarget(TAlfRealPoint(rect.iBr)); |
|
246 |
|
247 CFsLayoutManager::LayoutMetricsRect( |
|
248 currentSize, |
|
249 markIconMetrics, |
|
250 rect, |
|
251 markIconVariety ); |
|
252 tpMarkIconTl.SetTarget(TAlfRealPoint(rect.iTl)); |
|
253 tpMarkIconBr.SetTarget(TAlfRealPoint(rect.iBr)); |
|
254 |
|
255 CFsLayoutManager::LayoutMetricsRect( |
|
256 currentSize, |
|
257 menuIconMetrics, |
|
258 rect, |
|
259 menuIconVariety ); |
|
260 tpMenuIconTl.SetTarget(TAlfRealPoint(rect.iTl)); |
|
261 tpMenuIconBr.SetTarget(TAlfRealPoint(rect.iBr)); |
|
262 |
|
263 TRect textRect( currentSize ); |
|
264 if (textMetrics == CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1) |
|
265 { |
|
266 CFsLayoutManager::LayoutMetricsRect( |
|
267 currentSize, |
|
268 CFsLayoutManager::EFsLmListSingleDycRowTextPane, |
|
269 textRect, |
|
270 textPaneVariety ); |
|
271 } |
|
272 CFsLayoutManager::TFsText textInfo; |
|
273 /*CFsLayoutManager::LayoutMetricsText(currentSize, textMetrics, textInfo);*/ |
|
274 |
|
275 CFsLayoutManager::LayoutMetricsText(textRect, |
|
276 textMetrics, |
|
277 textInfo, textPaneVariety); |
|
278 tpTextTl.SetTarget(TAlfRealPoint(textInfo.iTextRect.iTl)); |
|
279 tpTextBr.SetTarget(TAlfRealPoint(textInfo.iTextRect.iBr)); |
|
280 |
|
281 TInt visualIconIndex = iLayout->FindVisual(iIconVisual); |
|
282 if ( visualIconIndex != KErrNotFound ) |
|
283 { |
|
284 iLayout->SetAnchor( EAlfAnchorTopLeft, |
|
285 visualIconIndex, |
|
286 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
287 EAlfAnchorMetricAbsolute, |
|
288 EAlfAnchorMetricAbsolute, |
|
289 tpMainIconTl ); |
|
290 iLayout->SetAnchor( EAlfAnchorBottomRight, |
|
291 visualIconIndex, |
|
292 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
293 EAlfAnchorMetricAbsolute, |
|
294 EAlfAnchorMetricAbsolute, |
|
295 tpMainIconBr ); |
|
296 } |
|
297 |
|
298 if ((iFlags & KFsTreeListItemHasMenu) |
|
299 && (iFlags & KFsTreeListItemFocused)) |
|
300 { |
|
301 TInt iconMenuVisIndex = iLayout->FindVisual(iIconMenu); |
|
302 if ( iconMenuVisIndex != KErrNotFound ) |
|
303 { |
|
304 iLayout->SetAnchor(EAlfAnchorTopLeft, |
|
305 iconMenuVisIndex, |
|
306 EAlfAnchorOriginLeft,EAlfAnchorOriginTop, |
|
307 EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute, |
|
308 tpMenuIconTl ); |
|
309 iLayout->SetAnchor(EAlfAnchorBottomRight, |
|
310 iconMenuVisIndex, |
|
311 EAlfAnchorOriginLeft,EAlfAnchorOriginTop, |
|
312 EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute, |
|
313 tpMenuIconBr ); |
|
314 |
|
315 TAlfTimedValue opacity; |
|
316 opacity.SetValueNow(1.0f); |
|
317 iIconMenu->SetOpacity(opacity); |
|
318 } |
|
319 } |
|
320 else |
|
321 { |
|
322 TAlfTimedValue opacity; |
|
323 opacity.SetValueNow(0.0f); |
|
324 iIconMenu->SetOpacity(opacity); |
|
325 } |
|
326 |
|
327 if (iViewportLayout) |
|
328 { |
|
329 TInt textVisIndex = iLayout->FindVisual(iViewportLayout); |
|
330 if ( textVisIndex != KErrNotFound ) |
|
331 { |
|
332 iLayout->SetAnchor(EAlfAnchorTopLeft, |
|
333 textVisIndex, |
|
334 EAlfAnchorOriginLeft,EAlfAnchorOriginTop, |
|
335 EAlfAnchorMetricAbsolute, |
|
336 EAlfAnchorMetricAbsolute, |
|
337 tpTextTl ); |
|
338 iLayout->SetAnchor(EAlfAnchorBottomRight, |
|
339 textVisIndex, |
|
340 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
341 EAlfAnchorMetricAbsolute, |
|
342 EAlfAnchorMetricAbsolute, |
|
343 tpTextBr ); |
|
344 } |
|
345 } |
|
346 |
|
347 if ( iFlags & KFsTreeListItemMarked ) |
|
348 { |
|
349 TInt iconMarkedVisIndex = |
|
350 iLayout->FindVisual(iIconMarked); |
|
351 if ( iconMarkedVisIndex != KErrNotFound ) |
|
352 { |
|
353 iLayout->SetAnchor(EAlfAnchorTopLeft, |
|
354 iconMarkedVisIndex, |
|
355 EAlfAnchorOriginLeft,EAlfAnchorOriginTop, |
|
356 EAlfAnchorMetricAbsolute, |
|
357 EAlfAnchorMetricAbsolute, |
|
358 tpMarkIconTl ); |
|
359 iLayout->SetAnchor(EAlfAnchorBottomRight, |
|
360 iconMarkedVisIndex, |
|
361 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, |
|
362 EAlfAnchorMetricAbsolute, |
|
363 EAlfAnchorMetricAbsolute, |
|
364 tpMarkIconBr ); |
|
365 |
|
366 TAlfTimedValue opacity; |
|
367 opacity.SetValueNow(1.0f); |
|
368 iIconMarked->SetOpacity(opacity); |
|
369 } |
|
370 } |
|
371 else |
|
372 { |
|
373 if (iIconMarked) |
|
374 { |
|
375 TAlfTimedValue opacity; |
|
376 opacity.SetValueNow(0.0f); |
|
377 iIconMarked->SetOpacity(opacity); |
|
378 } |
|
379 } |
|
380 iLayout->UpdateChildrenLayout(); |
|
381 |
|
382 } |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // From class MFsTreeItemVisualizer. |
|
390 // A call to this function means that the item is requested to draw itself |
|
391 // within specified parent layout. |
|
392 // --------------------------------------------------------------------------- |
|
393 // |
|
394 void CFsTreePlainOneLineItemVisualizer::ShowL( CAlfLayout& aParentLayout, |
|
395 const TUint aTimeout ) |
|
396 { |
|
397 FUNC_LOG; |
|
398 if (!iLayout) |
|
399 { |
|
400 iParentLayout = &aParentLayout; |
|
401 iLayout = CAlfAnchorLayout::AddNewL(iOwnerControl,iParentLayout); |
|
402 iLayout->SetTactileFeedbackL( ETouchEventStylusDown, ETouchFeedbackBasic ); |
|
403 iLayout->EnableBrushesL(); |
|
404 iLayout->SetClipping(ETrue); |
|
405 |
|
406 if (!iIconVisual) |
|
407 { |
|
408 iIconVisual = |
|
409 CAlfImageVisual::AddNewL(iOwnerControl, iLayout); |
|
410 // <cmail> aspect ratio preserved |
|
411 iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside); |
|
412 iIconVisual->SetFlag( EAlfVisualFlagIgnorePointer ); |
|
413 } |
|
414 |
|
415 if (!iViewportLayout) |
|
416 { |
|
417 iViewportLayout = |
|
418 CAlfViewportLayout::AddNewL(iOwnerControl, iLayout); |
|
419 iViewportLayout->SetFlag( EAlfVisualFlagIgnorePointer ); |
|
420 } |
|
421 |
|
422 if (!iTextVisual) |
|
423 { |
|
424 iTextVisual = |
|
425 CAlfTextVisual::AddNewL(iOwnerControl, iViewportLayout); |
|
426 iTextVisual->SetFlag( EAlfVisualFlagIgnorePointer ); |
|
427 } |
|
428 |
|
429 if (!iIconMarked) |
|
430 { |
|
431 iIconMarked = CAlfImageVisual::AddNewL(iOwnerControl, iLayout); |
|
432 iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside); |
|
433 iIconMarked->SetFlag( EAlfVisualFlagIgnorePointer ); |
|
434 } |
|
435 |
|
436 if (!iIconMenu) |
|
437 { |
|
438 iIconMenu = CAlfImageVisual::AddNewL(iOwnerControl, iLayout); |
|
439 iIconMenu->SetScaleMode(CAlfImageVisual::EScaleFitInside); |
|
440 iIconMenu->SetFlag( EAlfVisualFlagIgnorePointer ); |
|
441 } |
|
442 |
|
443 iTextMarquee = new (ELeave) TFsMarqueeClet(iOwnerControl, *iViewportLayout, TFsMarqueeClet::EScrollFromRight, TFsMarqueeClet::EScrollForth); |
|
444 } |
|
445 else |
|
446 { |
|
447 //visuals are already created but not attached to the list layout |
|
448 if (!iLayout->Layout()) |
|
449 { |
|
450 aParentLayout.Append(iLayout, aTimeout); |
|
451 iParentLayout = &aParentLayout; |
|
452 } |
|
453 } |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // A call to this function means that the item is requested to update its |
|
458 // visual content. |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CFsTreePlainOneLineItemVisualizer::UpdateL( const MFsTreeItemData& aData, |
|
462 TBool aFocused, |
|
463 const TUint aLevel, |
|
464 CAlfTexture*& aMarkIcon, |
|
465 CAlfTexture*& aMenuIcon, |
|
466 const TUint /*aTimeout*/, |
|
467 TBool aUpdateData) |
|
468 { |
|
469 FUNC_LOG; |
|
470 if (iLayout) |
|
471 { |
|
472 iSize.iWidth = iParentLayout->Size().Target().iX; |
|
473 iExtendedSize.iWidth = iSize.iWidth; |
|
474 |
|
475 TSize layoutSize(iLayout->Size().Target().iX, iLayout->Size().Target().iY); |
|
476 layoutSize.iWidth = iSize.iWidth; |
|
477 iLayout->SetSize(layoutSize); |
|
478 |
|
479 if (aFocused) |
|
480 { |
|
481 if (IsFocusable()) |
|
482 { |
|
483 iFlags |= KFsTreeListItemFocused; |
|
484 } |
|
485 } |
|
486 else |
|
487 { |
|
488 iFlags &= ~KFsTreeListItemFocused; |
|
489 } |
|
490 |
|
491 if ( aData.Type() == KFsTreePlainOneLineItemDataType ) |
|
492 { |
|
493 const CFsTreePlainOneLineItemData* data = |
|
494 static_cast<const CFsTreePlainOneLineItemData*>(&aData); |
|
495 |
|
496 //update the ancors for current item settings |
|
497 const TInt indent( iTextIndentation * ( aLevel - 1 ) ); |
|
498 UpdateLayout(data, indent); |
|
499 |
|
500 if (iIconVisual && data->IsIconSet()) |
|
501 { |
|
502 // <cmail> aspect ratio preserved |
|
503 iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside ); |
|
504 // </cmail> |
|
505 iIconVisual->SetImage( TAlfImage( data->Icon() ) ); |
|
506 } |
|
507 |
|
508 if ( iTextVisual && aUpdateData ) |
|
509 { |
|
510 //get text color |
|
511 TRgb textColor; |
|
512 if ( aFocused ) |
|
513 { |
|
514 if (!iIsCustomTextFocusedColor) |
|
515 {//custom color not set, use color from skin - load it in case theme has changed |
|
516 iFocusedTextColor = FocusedStateTextSkinColor(); |
|
517 } |
|
518 textColor = iFocusedTextColor; |
|
519 iFlags |= KFsTreeListItemFocused; |
|
520 } |
|
521 else |
|
522 { |
|
523 if (!iIsCustomTextNormalColor) |
|
524 {//custom color not set, use color from skin - load it in case theme has changed |
|
525 iNormalTextColor = NormalStateTextSkinColor( ); |
|
526 } |
|
527 textColor = iNormalTextColor; |
|
528 iFlags &= ~KFsTreeListItemFocused; |
|
529 } |
|
530 //get text style |
|
531 TInt styleId = ModifiedStyleIdL( ); |
|
532 iTextVisual->Env().CancelCustomCommands(this); |
|
533 |
|
534 TAlfTimedPoint tp(0,0); |
|
535 tp.SetStyle(EAlfTimedValueStyleLinear); |
|
536 iTextVisual->SetPos(tp); |
|
537 iTextVisual->SetTextL(data->Data( )); |
|
538 |
|
539 iTextVisual->EnableShadow(iFlags & KFsTreeListItemTextShadow); |
|
540 iTextVisual->SetColor( textColor ); |
|
541 iTextVisual->SetTextStyle( styleId ); |
|
542 |
|
543 if ( iManualWrapper ) |
|
544 { |
|
545 iTextVisual->SetWrapping( CAlfTextVisual::ELineWrapManual ); |
|
546 } |
|
547 else |
|
548 { |
|
549 iTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
550 } |
|
551 |
|
552 TAlfAlignHorizontal currTextAlign( EAlfAlignHLocale ); |
|
553 currTextAlign = CurrentTextAlignmentL( iTextAlign, &data->Data(), iTextVisual ); |
|
554 iTextVisual->SetAlign( currTextAlign, EAlfAlignVCenter ); |
|
555 |
|
556 if ( currTextAlign == EAlfAlignHRight ) |
|
557 { |
|
558 iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromLeft ); |
|
559 } |
|
560 else |
|
561 { |
|
562 iTextMarquee->SetScrollDirection( TFsMarqueeClet::EScrollFromRight ); |
|
563 } |
|
564 } |
|
565 |
|
566 if ( IsMarked() ) |
|
567 { |
|
568 // <cmail> aspect ratio preserved |
|
569 iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside); |
|
570 // </cmail> |
|
571 iIconMarked->SetImage( *aMarkIcon ); |
|
572 } |
|
573 |
|
574 if ((iFlags & KFsTreeListItemHasMenu) |
|
575 && (iFlags & KFsTreeListItemFocused)) |
|
576 { |
|
577 if ( iIconMenu && aMenuIcon ) |
|
578 { |
|
579 iIconMenu->SetScaleMode( CAlfImageVisual::EScaleFit ); |
|
580 iIconMenu->SetImage( *aMenuIcon ); |
|
581 } |
|
582 } |
|
583 |
|
584 iTextMarquee->StopScrolling(); |
|
585 |
|
586 if ( iTextVisual ) |
|
587 { |
|
588 if ( iManualWrapper ) |
|
589 { |
|
590 iTextVisual->SetWrapping( CAlfTextVisual::ELineWrapManual ); |
|
591 } |
|
592 else |
|
593 { |
|
594 iTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
595 } |
|
596 } |
|
597 } |
|
598 } |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------------------------- |
|
602 // From MFsTreeItemVisualizer. |
|
603 // This method sets flag disable wrapping the text item. |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CFsTreePlainOneLineItemVisualizer::OffWrapping() |
|
607 { |
|
608 iManualWrapper = ETrue; |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------------------------- |
|
612 // From class MFsTreeItemVisualizer. |
|
613 // A call to this function means that the item goes out of the visible items |
|
614 // scope. |
|
615 // --------------------------------------------------------------------------- |
|
616 // |
|
617 void CFsTreePlainOneLineItemVisualizer::Hide( const TInt aTimeout ) |
|
618 { |
|
619 FUNC_LOG; |
|
620 if ( iLayout ) |
|
621 { |
|
622 //if marquee command was sent |
|
623 iTextVisual->Env().CancelCustomCommands(this); |
|
624 |
|
625 delete iTextMarquee; |
|
626 iTextMarquee = NULL; //it has to be here |
|
627 |
|
628 iParentLayout->Remove(iLayout, aTimeout); |
|
629 iLayout->RemoveAndDestroyAllD(); |
|
630 iLayout = NULL; |
|
631 iTextVisual = NULL; |
|
632 iIconVisual = NULL; |
|
633 iIconMarked = NULL; |
|
634 iIconMenu = NULL; |
|
635 iParentLayout = NULL; |
|
636 iViewportLayout = NULL; |
|
637 } |
|
638 } |
|
639 |
|
640 // --------------------------------------------------------------------------- |
|
641 // From MFsTreeItemVisualizer. |
|
642 // Method to marquee the text when it's too long. |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void CFsTreePlainOneLineItemVisualizer::MarqueeL(const TFsTextMarqueeType aMarqueeType, |
|
646 const TUint aMarqueeSpeed, |
|
647 const TInt aMarqueeStartDelay, |
|
648 const TInt aMarqueeCycleStartDelay, |
|
649 const TInt aMarqueeRepetitions) |
|
650 { |
|
651 FUNC_LOG; |
|
652 TInt marqueeSize(0), textWidth(0); |
|
653 |
|
654 if ( aMarqueeType == EFsTextMarqueeNone || !iTextVisual ) |
|
655 { |
|
656 return; |
|
657 } |
|
658 |
|
659 iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapManual); |
|
660 |
|
661 textWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width(); |
|
662 marqueeSize = textWidth - iViewportLayout->Size().iX.Target(); |
|
663 |
|
664 if ( iTextVisual && ( marqueeSize>0 ) ) |
|
665 { |
|
666 TSize size(textWidth,iViewportLayout->Size().iY.Target()); |
|
667 if ( aMarqueeType == EFsTextMarqueeForth ) |
|
668 { |
|
669 iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollForth ); |
|
670 } |
|
671 else if ( aMarqueeType == EFsTextMarqueeForthBack ) |
|
672 { |
|
673 iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollBounce ); |
|
674 } |
|
675 else if ( aMarqueeType == EFsTextMarqueeLoop ) |
|
676 { |
|
677 iTextMarquee->SetScrollType( TFsMarqueeClet::EScrollWrap ); |
|
678 //duplicate text |
|
679 TBufC <1> separator(_L(" ")); |
|
680 HBufC* textHeap = HBufC::NewLC( (iTextVisual->Text().Length()+1)*2+1); |
|
681 TPtr doubleString(textHeap->Des()); |
|
682 doubleString = iTextVisual->Text(); |
|
683 doubleString.Append(_L(" ")); |
|
684 doubleString.Append(iTextVisual->Text()); |
|
685 doubleString.Append(_L(" ")); |
|
686 iTextVisual->SetTextL( doubleString ); |
|
687 CleanupStack::PopAndDestroy(textHeap); |
|
688 size.iWidth = iTextVisual->SubstringExtents(0, iTextVisual->Text().Length()).Width(); |
|
689 } |
|
690 |
|
691 iTextMarquee->SetScrollRepetitions( aMarqueeRepetitions ); |
|
692 TInt time(0); |
|
693 if ( aMarqueeType == EFsTextMarqueeLoop ) |
|
694 { |
|
695 time = textWidth * 1000 / aMarqueeSpeed; |
|
696 } |
|
697 else |
|
698 { |
|
699 time = marqueeSize * 1000 / aMarqueeSpeed; |
|
700 } |
|
701 iTextMarquee->SetScrollSpeed( time ); |
|
702 iTextMarquee->SetScrollableArea( size ); |
|
703 iTextMarquee->SetScrollCycleDelay( aMarqueeCycleStartDelay ); |
|
704 |
|
705 TAlfCustomEventCommand cmd( aMarqueeType, this, 0 ); |
|
706 iTextVisual->Env().CancelCustomCommands( this, aMarqueeType ); |
|
707 iTextVisual->Env().Send( cmd, aMarqueeStartDelay ); |
|
708 } |
|
709 } |
|
710 |
|
711 |
|
712 |
|
713 // --------------------------------------------------------------------------- |
|
714 // Handles custom Alf event. Used with text marquee. |
|
715 // --------------------------------------------------------------------------- |
|
716 // |
|
717 TBool CFsTreePlainOneLineItemVisualizer::OfferEventL(const TAlfEvent& aEvent) |
|
718 { |
|
719 FUNC_LOG; |
|
720 TBool ret( EFalse ); |
|
721 if ( aEvent.IsCustomEvent() ) |
|
722 { |
|
723 TInt param = aEvent.CustomParameter(); |
|
724 if ( param == EFsTextMarqueeForth || |
|
725 param == EFsTextMarqueeForthBack || |
|
726 param == EFsTextMarqueeLoop ) |
|
727 { |
|
728 ret = ETrue; |
|
729 iTextMarquee->StartScrolling( ); |
|
730 } |
|
731 } |
|
732 return ret; |
|
733 } |
|
734 |
|
735 // --------------------------------------------------------------------------- |
|
736 // C++ constructor. |
|
737 // --------------------------------------------------------------------------- |
|
738 // |
|
739 CFsTreePlainOneLineItemVisualizer::CFsTreePlainOneLineItemVisualizer |
|
740 ( CAlfControl& aOwnerControl ) |
|
741 : CFsTreeItemVisualizerBase( aOwnerControl ) |
|
742 { |
|
743 FUNC_LOG; |
|
744 |
|
745 iManualWrapper = EFalse; |
|
746 |
|
747 } |
|
748 |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // Second phase constructor. |
|
752 // --------------------------------------------------------------------------- |
|
753 // |
|
754 void CFsTreePlainOneLineItemVisualizer::ConstructL( ) |
|
755 { |
|
756 FUNC_LOG; |
|
757 CFsTreeItemVisualizerBase::ConstructL(); |
|
758 |
|
759 //get default skin values |
|
760 iNormalTextColor = NormalStateTextSkinColor(); |
|
761 iFocusedTextColor = FocusedStateTextSkinColor(); |
|
762 } |
|
763 |