|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alf/alflinevisual.h" |
|
21 #include "alf/alfcontrol.h" |
|
22 #include "alf/alfimage.h" |
|
23 #include "alf/alftexture.h" |
|
24 #include "alf/alfcurvepath.h" |
|
25 #include "alf/alfgencomponent.h" |
|
26 #include "alf/alfmappingfunctions.h" |
|
27 #include "alflogger.h" |
|
28 #include "alf/alfconstants.h" |
|
29 #include "alfskinnableimage.h" |
|
30 #include "alf/alfenv.h" |
|
31 |
|
32 #include <uiacceltk/HuiUtil.h> |
|
33 |
|
34 struct CAlfLineVisual::TLineVisualPrivateData |
|
35 { |
|
36 TAlfTimedValue iThickness; |
|
37 TAlfTimedValue iShadowThickness; |
|
38 TAlfTimedValue iStartPos; |
|
39 TAlfTimedValue iEndPos; |
|
40 CAlfCurvePath* iPath; |
|
41 TAlfOwnership iOwnership; |
|
42 CAlfSkinnableImage* iImage; |
|
43 }; |
|
44 |
|
45 // ======== MEMBER FUNCTIONS ======== |
|
46 |
|
47 EXPORT_C CAlfLineVisual* CAlfLineVisual::AddNewL( |
|
48 CAlfControl& aOwnerControl, |
|
49 CAlfLayout* aParentLayout ) |
|
50 { |
|
51 CAlfLineVisual* text = STATIC_CAST(CAlfLineVisual*, |
|
52 aOwnerControl.AppendVisualL(EAlfVisualTypeLine, aParentLayout)); |
|
53 return text; |
|
54 } |
|
55 |
|
56 EXPORT_C CAlfLineVisual::CAlfLineVisual() |
|
57 { |
|
58 } |
|
59 |
|
60 EXPORT_C void CAlfLineVisual::ConstructL(CAlfControl& aOwner) |
|
61 { |
|
62 CAlfVisual::ConstructL(aOwner); |
|
63 |
|
64 iLineVisualData = new (ELeave) TLineVisualPrivateData; |
|
65 |
|
66 iLineVisualData->iPath = NULL; |
|
67 iLineVisualData->iImage = NULL; |
|
68 |
|
69 iLineVisualData->iImage = new (ELeave) CAlfSkinnableImage(&aOwner.Env()); |
|
70 } |
|
71 |
|
72 EXPORT_C CAlfLineVisual::~CAlfLineVisual() |
|
73 { |
|
74 if ( iLineVisualData ) |
|
75 { |
|
76 delete iLineVisualData->iImage; |
|
77 iLineVisualData->iImage = NULL; |
|
78 |
|
79 if ( iLineVisualData->iOwnership == EAlfHasOwnership ) |
|
80 { |
|
81 delete iLineVisualData->iPath; |
|
82 } |
|
83 iLineVisualData->iPath = NULL; |
|
84 } |
|
85 delete iLineVisualData; |
|
86 iLineVisualData = NULL; |
|
87 } |
|
88 |
|
89 EXPORT_C void CAlfLineVisual::SetPath(CAlfCurvePath* aPath, |
|
90 TAlfOwnership aOwnership) |
|
91 { |
|
92 TInt curvePathHandle = 0; |
|
93 if ( aPath ) |
|
94 { |
|
95 MAlfMappingFunction* mappingFunction = aPath; |
|
96 curvePathHandle = mappingFunction->MappingFunctionIdentifier(); |
|
97 } |
|
98 |
|
99 |
|
100 TInt2 params( curvePathHandle, aOwnership ); |
|
101 TPckgC<TInt2> inBuf( params ); |
|
102 |
|
103 TInt err = Comms()->DoCmdNoReply(EAlfLineVisualSetPath, inBuf ); |
|
104 |
|
105 if ( err ) |
|
106 { |
|
107 __ALFLOGSTRING1( "CAlfLineVisual::SetPath panic error %d", err ) |
|
108 USER_INVARIANT(); |
|
109 } |
|
110 |
|
111 // Destroy the old one if owned. |
|
112 if ( iLineVisualData->iOwnership == EAlfHasOwnership ) |
|
113 { |
|
114 delete iLineVisualData->iPath; |
|
115 } |
|
116 |
|
117 iLineVisualData->iPath = aPath; |
|
118 iLineVisualData->iOwnership = aOwnership; |
|
119 } |
|
120 |
|
121 EXPORT_C CAlfCurvePath* CAlfLineVisual::Path() |
|
122 { |
|
123 return iLineVisualData->iPath; |
|
124 } |
|
125 |
|
126 EXPORT_C void CAlfLineVisual::SetImage(const TAlfImage& aImage) |
|
127 { |
|
128 iLineVisualData->iImage->SetImage(aImage);// This texturizes skin graphics if needed |
|
129 |
|
130 TAlfImageParams params(iLineVisualData->iImage->Image()); |
|
131 |
|
132 TPckgC<TAlfImageParams> buf(params); |
|
133 |
|
134 TInt err = Comms()->DoCmdNoReply(EAlfLineVisualSetImage, buf ); |
|
135 |
|
136 if ( err ) |
|
137 { |
|
138 __ALFLOGSTRING1( "CAlfLineVisual::SetImage ignore error %d", err ) |
|
139 } |
|
140 } |
|
141 |
|
142 EXPORT_C const TAlfImage& CAlfLineVisual::Image() const |
|
143 { |
|
144 return iLineVisualData->iImage->Image(); |
|
145 } |
|
146 |
|
147 EXPORT_C void CAlfLineVisual::SetAlphaFunction(MAlfMappingFunction* aFunction) |
|
148 { |
|
149 TInt mappingFunctionHandle = 0; |
|
150 if ( aFunction ) |
|
151 { |
|
152 mappingFunctionHandle = aFunction->MappingFunctionIdentifier(); |
|
153 } |
|
154 |
|
155 TPckgC<TInt> inBuf( mappingFunctionHandle ); |
|
156 |
|
157 TInt err = Comms()->DoCmdNoReply(EAlfLineVisualSetAlphaFunction, inBuf ); |
|
158 |
|
159 if ( err ) |
|
160 { |
|
161 __ALFLOGSTRING1( "CAlfLineVisual::SetAlphaFunction panic error %d", err ) |
|
162 USER_INVARIANT(); |
|
163 } |
|
164 } |
|
165 |
|
166 EXPORT_C void CAlfLineVisual::SetWidthFunction(MAlfMappingFunction* aFunction) |
|
167 { |
|
168 TInt mappingFunctionHandle = 0; |
|
169 if ( aFunction ) |
|
170 { |
|
171 mappingFunctionHandle = aFunction->MappingFunctionIdentifier(); |
|
172 } |
|
173 TPckgC<TInt> inBuf( mappingFunctionHandle ); |
|
174 |
|
175 TInt err =Comms()->DoCmdNoReply(EAlfLineVisualSetWidthFunction, inBuf ); |
|
176 if ( err ) |
|
177 { |
|
178 __ALFLOGSTRING1( "CAlfLineVisual::SetWidthFunction panic error %d", err ) |
|
179 USER_INVARIANT(); |
|
180 } |
|
181 } |
|
182 |
|
183 EXPORT_C const TAlfTimedValue& CAlfLineVisual::Thickness() const |
|
184 { |
|
185 TPckg<TAlfTimedValue> buf(iLineVisualData->iThickness); |
|
186 TInt err = Comms()->DoSynchronousCmd( EAlfLineVisualGetThickness, buf, buf); |
|
187 |
|
188 if ( err != KErrNone ) |
|
189 { |
|
190 __ALFLOGSTRING1( "CAlfLineVisual::Thickness panic error %d", err ) |
|
191 USER_INVARIANT(); |
|
192 } |
|
193 |
|
194 return iLineVisualData->iThickness; |
|
195 } |
|
196 |
|
197 EXPORT_C void CAlfLineVisual::SetThickness( const TAlfTimedValue& aThickness ) |
|
198 { |
|
199 TPckgC<TAlfTimedValue> buf(aThickness); |
|
200 |
|
201 TInt err = Comms()->DoCmdNoReply( EAlfLineVisualSetThickness, buf ); |
|
202 |
|
203 if ( err == KErrNone ) |
|
204 { |
|
205 iLineVisualData->iThickness = aThickness; |
|
206 } |
|
207 else |
|
208 { |
|
209 __ALFLOGSTRING1( "CAlfLineVisual::SetThickness panic error %d", err ) |
|
210 USER_INVARIANT(); |
|
211 } |
|
212 } |
|
213 |
|
214 EXPORT_C const TAlfTimedValue& CAlfLineVisual::ShadowThickness() const |
|
215 { |
|
216 TPckg<TAlfTimedValue> buf(iLineVisualData->iShadowThickness); |
|
217 TInt err = Comms()->DoSynchronousCmd( EAlfLineVisualGetShadowThickness, buf, buf); |
|
218 |
|
219 if ( err != KErrNone ) |
|
220 { |
|
221 __ALFLOGSTRING1( "CAlfLineVisual::ShadowThickness panic error %d", err ) |
|
222 USER_INVARIANT(); |
|
223 } |
|
224 |
|
225 return iLineVisualData->iShadowThickness; |
|
226 } |
|
227 |
|
228 EXPORT_C void CAlfLineVisual::SetShadowThickness( const TAlfTimedValue& aShadowThickness ) |
|
229 { |
|
230 TPckgC<TAlfTimedValue> buf(aShadowThickness); |
|
231 |
|
232 TInt err = Comms()->DoCmdNoReply( EAlfLineVisualSetShadowThickness, buf ); |
|
233 |
|
234 if ( err == KErrNone ) |
|
235 { |
|
236 iLineVisualData->iShadowThickness = aShadowThickness; |
|
237 } |
|
238 else |
|
239 { |
|
240 __ALFLOGSTRING1( "CAlfLineVisual::SetShadowThickness panic error %d", err ) |
|
241 USER_INVARIANT(); |
|
242 } |
|
243 } |
|
244 |
|
245 EXPORT_C const TAlfTimedValue& CAlfLineVisual::StartPos() const |
|
246 { |
|
247 TPckg<TAlfTimedValue> buf(iLineVisualData->iStartPos); |
|
248 TInt err = Comms()->DoSynchronousCmd( EAlfLineVisualGetStartPos, buf, buf); |
|
249 |
|
250 if ( err != KErrNone ) |
|
251 { |
|
252 __ALFLOGSTRING1( "CAlfLineVisual::StartPos panic error %d", err ) |
|
253 USER_INVARIANT(); |
|
254 } |
|
255 |
|
256 return iLineVisualData->iStartPos; |
|
257 } |
|
258 |
|
259 EXPORT_C void CAlfLineVisual::SetStartPos( const TAlfTimedValue& aStartPos ) |
|
260 { |
|
261 TPckgC<TAlfTimedValue> buf(aStartPos); |
|
262 |
|
263 TInt err = Comms()->DoCmdNoReply( EAlfLineVisualSetStartPos, buf ); |
|
264 |
|
265 if ( err == KErrNone ) |
|
266 { |
|
267 iLineVisualData->iStartPos = aStartPos; |
|
268 } |
|
269 else |
|
270 { |
|
271 __ALFLOGSTRING1( "CAlfLineVisual::SetStartPos panic error %d", err ) |
|
272 USER_INVARIANT(); |
|
273 } |
|
274 } |
|
275 |
|
276 EXPORT_C const TAlfTimedValue& CAlfLineVisual::EndPos() const |
|
277 { |
|
278 TPckg<TAlfTimedValue> buf(iLineVisualData->iEndPos); |
|
279 TInt err = Comms()->DoSynchronousCmd( EAlfLineVisualGetEndPos, buf, buf); |
|
280 |
|
281 if ( err != KErrNone ) |
|
282 { |
|
283 __ALFLOGSTRING1( "CAlfLineVisual::EndPos panic error %d", err ) |
|
284 USER_INVARIANT(); |
|
285 } |
|
286 |
|
287 return iLineVisualData->iEndPos; |
|
288 } |
|
289 |
|
290 EXPORT_C void CAlfLineVisual::SetEndPos( const TAlfTimedValue& aEndPos ) |
|
291 { |
|
292 TPckgC<TAlfTimedValue> buf(aEndPos); |
|
293 |
|
294 TInt err = Comms()->DoCmdNoReply( EAlfLineVisualSetEndPos, buf ); |
|
295 |
|
296 if ( err == KErrNone ) |
|
297 { |
|
298 iLineVisualData->iEndPos = aEndPos; |
|
299 } |
|
300 else |
|
301 { |
|
302 __ALFLOGSTRING1( "CAlfLineVisual::SetEndPos panic error %d", err ) |
|
303 USER_INVARIANT(); |
|
304 } |
|
305 } |
|
306 |
|
307 EXPORT_C void CAlfLineVisual::SetColor(const TRgb& aColor) |
|
308 { |
|
309 TPckgC<TRgb> buf(aColor); |
|
310 |
|
311 TInt err = Comms()->DoCmdNoReply(EAlfLineVisualSetColor, buf ); |
|
312 |
|
313 if ( err ) |
|
314 { |
|
315 __ALFLOGSTRING1( "CAlfLineVisual::SetColor ignore error %d", err ) |
|
316 } |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // Place holder from CAlfVisual |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 EXPORT_C void CAlfLineVisual::RemoveAndDestroyAllD() |
|
324 { |
|
325 CAlfVisual::RemoveAndDestroyAllD(); |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // Place holder from CAlfVisual |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 EXPORT_C void CAlfLineVisual::UpdateChildrenLayout(TInt aTransitionTime ) |
|
333 { |
|
334 CAlfVisual::UpdateChildrenLayout( aTransitionTime ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // Place holder from CAlfVisual |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 EXPORT_C CAlfVisual* CAlfLineVisual::FindTag(const TDesC8& aTag) |
|
342 { |
|
343 return CAlfVisual::FindTag( aTag ); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // Place holder from CAlfVisual |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 EXPORT_C void CAlfLineVisual::DoRemoveAndDestroyAllD() |
|
351 { |
|
352 CAlfVisual::DoRemoveAndDestroyAllD(); |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // future proofing |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 EXPORT_C void CAlfLineVisual::PropertyOwnerExtension(const TUid& aExtensionUid, TAny** aExtensionParams) |
|
360 { |
|
361 CAlfVisual::PropertyOwnerExtension(aExtensionUid,aExtensionParams); |
|
362 } |
|
363 |
|
364 |
|
365 |