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