|
1 /* |
|
2 * Copyright (c) 2006-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: Implementation for CHuiCurvePathLayout. Combines a layout |
|
15 * visual and a curve path. The path is rescaled as the layout's |
|
16 * size changes. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include "uiacceltk/HuiCurvePathLayout.h" // Class definition |
|
23 #include "uiacceltk/HuiControl.h" |
|
24 #include "uiacceltk/HuiCurvePath.h" |
|
25 #include "uiacceltk/HuiPanic.h" |
|
26 |
|
27 |
|
28 const TReal32 KPathLogicalCoordsMax = 1000.0; |
|
29 |
|
30 |
|
31 EXPORT_C CHuiCurvePathLayout* CHuiCurvePathLayout::AddNewL(CHuiControl& aOwnerControl, |
|
32 CHuiLayout* aParentLayout) |
|
33 { |
|
34 CHuiCurvePathLayout* layout = new (ELeave) CHuiCurvePathLayout(aOwnerControl); |
|
35 CleanupStack::PushL(layout); |
|
36 layout->ConstructL(); |
|
37 aOwnerControl.AppendL(layout, aParentLayout); |
|
38 CleanupStack::Pop(layout); |
|
39 return layout; |
|
40 } |
|
41 |
|
42 |
|
43 CHuiCurvePathLayout::CHuiCurvePathLayout(MHuiVisualOwner& aOwner) |
|
44 : CHuiLayout(aOwner) |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 void CHuiCurvePathLayout::ConstructL() |
|
50 { |
|
51 CHuiLayout::ConstructL(); |
|
52 iPath = CHuiCurvePath::NewL(); |
|
53 } |
|
54 |
|
55 |
|
56 CHuiCurvePathLayout::~CHuiCurvePathLayout() |
|
57 { |
|
58 delete iPath; |
|
59 } |
|
60 |
|
61 |
|
62 EXPORT_C CHuiCurvePath& CHuiCurvePathLayout::CurvePath() |
|
63 { |
|
64 return *iPath; |
|
65 } |
|
66 |
|
67 |
|
68 TReal32 CHuiCurvePathLayout::MapValue(TReal32 aValue, TInt aMode) const __SOFTFP |
|
69 { |
|
70 TReal32 value = iPath->MapValue(aValue, aMode); |
|
71 |
|
72 if (iPath->IsLegacyApiUsed()) |
|
73 { |
|
74 // The path defines points in range (0, 1000). |
|
75 value /= KPathLogicalCoordsMax; |
|
76 if(aMode == 0) // Horizontal. |
|
77 { |
|
78 value *= Size().RealNow().iX; |
|
79 } |
|
80 else // Vertical. |
|
81 { |
|
82 value *= Size().RealNow().iY; |
|
83 } |
|
84 } |
|
85 |
|
86 return value; |
|
87 } |
|
88 |
|
89 TBool CHuiCurvePathLayout::MappingFunctionChanged() const |
|
90 { |
|
91 return iPath->MappingFunctionChanged() || Size().Changed(); |
|
92 } |
|
93 |
|
94 |
|
95 void CHuiCurvePathLayout::MappingFunctionClearChanged() |
|
96 { |
|
97 iPath->MappingFunctionClearChanged(); |
|
98 } |
|
99 |
|
100 void CHuiCurvePathLayout::SetSize(const THuiRealSize& aSize, TInt aTransitionTime) |
|
101 { |
|
102 CHuiLayout::SetSize(aSize, aTransitionTime); |
|
103 UpdateChildrenLayout(aTransitionTime); |
|
104 } |
|
105 |
|
106 |
|
107 TBool CHuiCurvePathLayout::ChildSize(TInt /*aOrdinal*/, TSize& /*aSize*/) |
|
108 { |
|
109 return EFalse; |
|
110 } |
|
111 |
|
112 TBool CHuiCurvePathLayout::ChildPos(TInt /*aOrdinal*/, TPoint& /*aPos*/) |
|
113 { |
|
114 return EFalse; |
|
115 } |
|
116 |
|
117 EXPORT_C TInt CHuiCurvePathLayout::ChildRect(TInt /*aOrdinal*/, THuiRealRect& /*aPos*/) |
|
118 { |
|
119 return THuiLayoutChildRectUpdateNotNeeded; |
|
120 } |