|
1 /* |
|
2 * Copyright (c) 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: Line visual |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_ALFLINEVISUAL_H |
|
22 #define C_ALFLINEVISUAL_H |
|
23 |
|
24 #include <alf/alfvisual.h> |
|
25 #include <alf/alfownership.h> |
|
26 |
|
27 class CAlfControl; |
|
28 class CAlfLayout; |
|
29 class CAlfCurvePath; |
|
30 class MAlfMappingFunction; |
|
31 class TAlfImage; |
|
32 class TRgb; |
|
33 |
|
34 |
|
35 /** |
|
36 * Line visual draws a line along a curve path. |
|
37 * |
|
38 * A line visual will draw a bendy line that follows a specified |
|
39 * curve path. Width and alpha functions can be set to change the |
|
40 * opacity and thickness of the line along its length. |
|
41 * |
|
42 * Note that the Bitgdi renderer contains only a minimal implementation |
|
43 * of line drawing. There is no aliasing or shading on the line, and |
|
44 * thickness and alpha functions have no effect. The entire thickness of a Bitgdi |
|
45 * line is set by the initial thickness at point 0. |
|
46 * Usage: |
|
47 * |
|
48 * @code |
|
49 * |
|
50 * //Create curvepath, which can be used as a path for linevisual |
|
51 * CAlfCurvePath* path = CAlfCurvePath::NewL( &iEnv ); |
|
52 * path->AppendArcL( TPoint(120, 120), TSize(60, 60), 180, 180 + 270, 0.5 ); |
|
53 * path->AppendLineL( TPoint(120, 180), TPoint(20, 180), 0.5 ); |
|
54 * |
|
55 * //Create linevisual |
|
56 * CAlfLineVisual* line = CAlfLineVisual::AddNewL( control ); |
|
57 * //set curvepath instance, with ownership transfered to visual |
|
58 * line->SetPath( path, EAlfHasOwnership ); |
|
59 * |
|
60 * //Line opacity function. Line visuals can use a mapping function to determine the opacity |
|
61 * //of the line along the path. |
|
62 * //member variable : LinearMappingFunction linearFunc; |
|
63 * linearFunc.SetFactor( 1 ); |
|
64 * //setlinevisual alpha function |
|
65 * line->SetAlphaFunction( &linearFunc ); |
|
66 * |
|
67 * //Similerly, line visuals can use a mapping function to determine the width of the |
|
68 * //line along the path. |
|
69 * linearFunc.SetFactor( 60 ); |
|
70 * line->SetWidthFunction( &linearFunc ); * |
|
71 * |
|
72 * @endcode |
|
73 * |
|
74 * @lib alfclient.lib |
|
75 * @since S60 v3.2 |
|
76 * @see CAlfCurvePath |
|
77 */ |
|
78 |
|
79 class CAlfLineVisual : public CAlfVisual |
|
80 { |
|
81 |
|
82 public: |
|
83 |
|
84 /** |
|
85 * Constructor, which gives ownership to the control. |
|
86 * |
|
87 * @param aOwnerControl The control |
|
88 * @param aParentLayout If given, the parent layout. |
|
89 * @return New instance. Ownership NOT transreffed (owned by control) |
|
90 */ |
|
91 IMPORT_C static CAlfLineVisual* AddNewL(CAlfControl& aOwnerControl, |
|
92 CAlfLayout* aParentLayout = 0); |
|
93 |
|
94 /** |
|
95 * Constructor. |
|
96 */ |
|
97 IMPORT_C CAlfLineVisual(); |
|
98 |
|
99 /** |
|
100 * Second-phase constructor. |
|
101 */ |
|
102 IMPORT_C void ConstructL(CAlfControl& aOwner); |
|
103 |
|
104 /** |
|
105 * Destructor. |
|
106 */ |
|
107 IMPORT_C virtual ~CAlfLineVisual(); |
|
108 |
|
109 /** |
|
110 * Sets the path instance of the visual. |
|
111 * |
|
112 * @param aPath |
|
113 * @param aOwnership |
|
114 */ |
|
115 IMPORT_C void SetPath(CAlfCurvePath* aPath, TAlfOwnership aOwnership); |
|
116 |
|
117 /** |
|
118 * Returns the path of the visual. The path can be modified via this |
|
119 * reference. |
|
120 * |
|
121 * @return Path. NULL if not set. |
|
122 */ |
|
123 IMPORT_C CAlfCurvePath* Path(); |
|
124 |
|
125 /** |
|
126 * Sets the image used by the line. |
|
127 */ |
|
128 IMPORT_C void SetImage(const TAlfImage& aImage); |
|
129 |
|
130 /** |
|
131 * Returns the image used by the line. |
|
132 */ |
|
133 IMPORT_C const TAlfImage& Image() const; |
|
134 |
|
135 /** |
|
136 * Sets the alpha mapping function that generates alpha values for the |
|
137 * path. |
|
138 */ |
|
139 IMPORT_C void SetAlphaFunction(MAlfMappingFunction* aFunction); |
|
140 |
|
141 /** |
|
142 * Sets the width mapping function that generates width values for the |
|
143 * path. |
|
144 */ |
|
145 IMPORT_C void SetWidthFunction(MAlfMappingFunction* aFunction); |
|
146 |
|
147 /** |
|
148 * Thickness of the line. |
|
149 */ |
|
150 IMPORT_C const TAlfTimedValue& Thickness() const; |
|
151 IMPORT_C void SetThickness( const TAlfTimedValue& aThickness ); |
|
152 |
|
153 /** |
|
154 * Thickness of the shadow around the line. |
|
155 */ |
|
156 IMPORT_C const TAlfTimedValue& ShadowThickness() const; |
|
157 IMPORT_C void SetShadowThickness( const TAlfTimedValue& aShadowThickness ); |
|
158 |
|
159 /** |
|
160 * Current start position on the path. |
|
161 */ |
|
162 IMPORT_C const TAlfTimedValue& StartPos() const; |
|
163 IMPORT_C void SetStartPos( const TAlfTimedValue& aStartPos ); |
|
164 |
|
165 /** |
|
166 * Current end position on the path. |
|
167 */ |
|
168 IMPORT_C const TAlfTimedValue& EndPos() const; |
|
169 IMPORT_C void SetEndPos( const TAlfTimedValue& aEndPos ); |
|
170 |
|
171 /** |
|
172 * Sets the color of the line. |
|
173 */ |
|
174 IMPORT_C void SetColor(const TRgb& aColor); |
|
175 |
|
176 /** |
|
177 * From CAlfVisual |
|
178 * @see CAlfVisual |
|
179 */ |
|
180 IMPORT_C void RemoveAndDestroyAllD(); |
|
181 IMPORT_C void UpdateChildrenLayout(TInt aTransitionTime = 0); |
|
182 IMPORT_C CAlfVisual* FindTag(const TDesC8& aTag); |
|
183 |
|
184 |
|
185 protected: |
|
186 /** |
|
187 * From CAlfVisual |
|
188 * @see CAlfVisual |
|
189 */ |
|
190 IMPORT_C void DoRemoveAndDestroyAllD(); |
|
191 IMPORT_C void PropertyOwnerExtension(const TUid& aExtensionUid, TAny** aExtensionParams); |
|
192 |
|
193 |
|
194 private: // data |
|
195 |
|
196 struct TLineVisualPrivateData; |
|
197 TLineVisualPrivateData* iLineVisualData; |
|
198 |
|
199 }; |
|
200 |
|
201 #endif // C_ALFLINEVISUAL_H |