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