|
1 /* |
|
2 * Copyright (c) 2006 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: Border brush |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alf/alfborderbrush.h" |
|
21 #include "alf/alfenv.h" |
|
22 #include "alf/alfgencomponent.h" |
|
23 #include "alf/alfimage.h" |
|
24 #include "alf/alftexture.h" |
|
25 #include "alflogger.h" |
|
26 #include "alfskinnableimage.h" |
|
27 #include "alf/alfconstants.h" |
|
28 |
|
29 #include <uiacceltk/HuiUtil.h> |
|
30 |
|
31 struct CAlfBorderBrush::TBorderBrushPrivateData |
|
32 { |
|
33 TAlfTimedPoint iThickness; |
|
34 TAlfTimedPoint iEdgeOffset; |
|
35 TAlfTimedPoint iImageOffset; |
|
36 CAlfSkinnableImage* iImage; |
|
37 }; |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // Constructor |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CAlfBorderBrush::CAlfBorderBrush() |
|
46 : CAlfBrush() |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // ConstructL |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CAlfBorderBrush::ConstructL( |
|
55 CAlfEnv& aEnv, |
|
56 const TAlfXYMetric& aThickness, |
|
57 const TAlfXYMetric& aEdgeOffset) |
|
58 { |
|
59 |
|
60 TAlfCreateBorderBrushMetricParams params; |
|
61 params.iThickness = aThickness; |
|
62 params.iEdgeOffset = aEdgeOffset; |
|
63 TPckgC<TAlfCreateBorderBrushMetricParams> paramsPckg(params); |
|
64 |
|
65 |
|
66 CAlfBrush::ConstructL( |
|
67 aEnv, |
|
68 EAlfBorderBrushCreateMetric, |
|
69 0, |
|
70 paramsPckg |
|
71 ); |
|
72 |
|
73 iBorderBrushData = new (ELeave) TBorderBrushPrivateData; |
|
74 iBorderBrushData->iImage = NULL; |
|
75 iBorderBrushData->iImage = new (ELeave) CAlfSkinnableImage(&aEnv); |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // ConstructL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CAlfBorderBrush::ConstructL( |
|
84 CAlfEnv& aEnv, |
|
85 TInt aThicknessWidth, |
|
86 TInt aThicknessHeight, |
|
87 TInt aEdgeOffsetX, |
|
88 TInt aEdgeOffsetY ) |
|
89 { |
|
90 |
|
91 TAlfCreateBorderBrushParams params; |
|
92 params.iThicknessWidth = aThicknessWidth; |
|
93 params.iThicknessHeight = aThicknessHeight; |
|
94 params.iEdgeOffsetX = aEdgeOffsetX; |
|
95 params.iEdgeOffsetY = aEdgeOffsetY; |
|
96 TPckgC<TAlfCreateBorderBrushParams> paramsPckg(params); |
|
97 |
|
98 |
|
99 CAlfBrush::ConstructL( |
|
100 aEnv, |
|
101 EAlfBorderBrushCreate, |
|
102 0, |
|
103 paramsPckg |
|
104 ); |
|
105 |
|
106 iBorderBrushData = new (ELeave) TBorderBrushPrivateData; |
|
107 iBorderBrushData->iImage = NULL; |
|
108 iBorderBrushData->iImage = new (ELeave) CAlfSkinnableImage(&aEnv); |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Constructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CAlfBorderBrush* CAlfBorderBrush::NewL( |
|
117 CAlfEnv& aEnv, |
|
118 const TAlfXYMetric& aThickness, |
|
119 const TAlfXYMetric& aEdgeOffset) |
|
120 { |
|
121 CAlfBorderBrush* self = CAlfBorderBrush::NewLC( |
|
122 aEnv, |
|
123 aThickness, |
|
124 aEdgeOffset); |
|
125 CleanupStack::Pop( self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Constructor |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 EXPORT_C CAlfBorderBrush* CAlfBorderBrush::NewLC( |
|
135 CAlfEnv& aEnv, |
|
136 const TAlfXYMetric& aThickness, |
|
137 const TAlfXYMetric& aEdgeOffset) |
|
138 { |
|
139 CAlfBorderBrush* self = new( ELeave ) CAlfBorderBrush; |
|
140 CleanupStack::PushL( self ); |
|
141 self->ConstructL( |
|
142 aEnv, |
|
143 aThickness, |
|
144 aEdgeOffset); |
|
145 return self; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Constructor |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C CAlfBorderBrush* CAlfBorderBrush::NewL( |
|
153 CAlfEnv& aEnv, |
|
154 TInt aThicknessWidth, |
|
155 TInt aThicknessHeight, |
|
156 TInt aEdgeOffsetX, |
|
157 TInt aEdgeOffsetY ) |
|
158 { |
|
159 CAlfBorderBrush* self = CAlfBorderBrush::NewLC( |
|
160 aEnv, |
|
161 aThicknessWidth, |
|
162 aThicknessHeight, |
|
163 aEdgeOffsetX, |
|
164 aEdgeOffsetY ); |
|
165 CleanupStack::Pop( self ); |
|
166 return self; |
|
167 } |
|
168 |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // Constructor |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C CAlfBorderBrush* CAlfBorderBrush::NewLC( |
|
175 CAlfEnv& aEnv, |
|
176 TInt aThicknessWidth, |
|
177 TInt aThicknessHeight, |
|
178 TInt aEdgeOffsetX, |
|
179 TInt aEdgeOffsetY) |
|
180 { |
|
181 CAlfBorderBrush* self = new( ELeave ) CAlfBorderBrush; |
|
182 CleanupStack::PushL( self ); |
|
183 self->ConstructL( |
|
184 aEnv, |
|
185 aThicknessWidth, |
|
186 aThicknessHeight, |
|
187 aEdgeOffsetX, |
|
188 aEdgeOffsetY ); |
|
189 return self; |
|
190 } |
|
191 |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // Destructor. |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 CAlfBorderBrush::~CAlfBorderBrush() |
|
198 { |
|
199 if (iBorderBrushData) |
|
200 { |
|
201 delete iBorderBrushData->iImage; |
|
202 iBorderBrushData->iImage = NULL; |
|
203 } |
|
204 |
|
205 delete iBorderBrushData; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // Set image |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C void CAlfBorderBrush::SetImage(const TAlfImage& aImage) |
|
213 { |
|
214 iBorderBrushData->iImage->SetImage(aImage); // This texturizes skin graphics if needed |
|
215 |
|
216 TAlfImageParams params(iBorderBrushData->iImage->Image()); |
|
217 |
|
218 TPckgC<TAlfImageParams> buf(params); |
|
219 TInt err = Comms()->DoCmdNoReply(EAlfBorderBrushSetImage, buf ); |
|
220 |
|
221 if ( err ) |
|
222 { |
|
223 __ALFLOGSTRING1( "CAlfBorderBrush::SetImage ignore error %d", err ) |
|
224 } |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // Get image |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 EXPORT_C const TAlfImage& CAlfBorderBrush::Image() const |
|
232 { |
|
233 return iBorderBrushData->iImage->Image(); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Set color |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C void CAlfBorderBrush::SetColor(const TRgb& aColor) |
|
241 { |
|
242 // Just send to server |
|
243 TPckgC<TRgb> inBuf(aColor); |
|
244 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetColor, inBuf ); |
|
245 if ( err ) |
|
246 { |
|
247 __ALFLOGSTRING1( "CAlfBorderBrush::SetColor ignore error %d", err ) |
|
248 } |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // Thickness |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 EXPORT_C const TAlfTimedPoint& CAlfBorderBrush::Thickness() const |
|
256 { |
|
257 TPckg<TAlfTimedPoint> buf(iBorderBrushData->iThickness); |
|
258 TInt err = Comms()->DoSynchronousCmd( EAlfBorderBrushGetThickness, buf, buf); |
|
259 |
|
260 if ( err != KErrNone ) |
|
261 { |
|
262 __ALFLOGSTRING1( "CAlfBorderBrush::Thickness panic error %d", err ) |
|
263 USER_INVARIANT(); |
|
264 } |
|
265 |
|
266 return iBorderBrushData->iThickness; |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // Sets thickness |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void CAlfBorderBrush::SetThickness(const TAlfTimedPoint& aThickness) |
|
274 { |
|
275 TPckgC<TAlfTimedPoint> buf(aThickness); |
|
276 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetThickness, buf); |
|
277 |
|
278 if ( err == KErrNone ) |
|
279 { |
|
280 iBorderBrushData->iThickness = aThickness; |
|
281 } |
|
282 else |
|
283 { |
|
284 __ALFLOGSTRING1( "CAlfBorderBrush::SetThickness panic error %d", err ) |
|
285 USER_INVARIANT(); |
|
286 } |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // Edge offset |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C const TAlfTimedPoint& CAlfBorderBrush::EdgeOffset() const |
|
294 { |
|
295 TPckg<TAlfTimedPoint> buf(iBorderBrushData->iEdgeOffset); |
|
296 TInt err = Comms()->DoSynchronousCmd( EAlfBorderBrushGetEdgeOffset, buf, buf); |
|
297 |
|
298 if ( err != KErrNone ) |
|
299 { |
|
300 __ALFLOGSTRING1( "CAlfBorderBrush::EdgeOffset panic error %d", err ) |
|
301 USER_INVARIANT(); |
|
302 } |
|
303 |
|
304 return iBorderBrushData->iEdgeOffset; |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // Set edge offset |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 EXPORT_C void CAlfBorderBrush::SetEdgeOffset(const TAlfTimedPoint& aEdgeOffset) |
|
312 { |
|
313 TPckgC<TAlfTimedPoint> buf(aEdgeOffset); |
|
314 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetEdgeOffset, buf ); |
|
315 |
|
316 if ( err == KErrNone ) |
|
317 { |
|
318 iBorderBrushData->iEdgeOffset = aEdgeOffset; |
|
319 } |
|
320 else |
|
321 { |
|
322 __ALFLOGSTRING1( "CAlfBorderBrush::SetEdgeOffset panic error %d", err ) |
|
323 USER_INVARIANT(); |
|
324 } |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // Image offset |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 EXPORT_C const TAlfTimedPoint& CAlfBorderBrush::ImageOffset() const |
|
332 { |
|
333 TPckg<TAlfTimedPoint> buf(iBorderBrushData->iImageOffset); |
|
334 TInt err = Comms()->DoSynchronousCmd( EAlfBorderBrushGetImageOffset, buf, buf); |
|
335 |
|
336 if ( err != KErrNone ) |
|
337 { |
|
338 __ALFLOGSTRING1( "CAlfBorderBrush::ImageOffset panic error %d", err ) |
|
339 USER_INVARIANT(); |
|
340 } |
|
341 |
|
342 return iBorderBrushData->iImageOffset; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // Sets image offset |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 EXPORT_C void CAlfBorderBrush::SetImageOffset(const TAlfTimedPoint& aImageOffset) |
|
350 { |
|
351 TPckgC<TAlfTimedPoint> buf(aImageOffset); |
|
352 |
|
353 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetImageOffset, buf ); |
|
354 |
|
355 if ( err == KErrNone ) |
|
356 { |
|
357 iBorderBrushData->iImageOffset = aImageOffset; |
|
358 } |
|
359 else |
|
360 { |
|
361 __ALFLOGSTRING1( "CAlfBorderBrush::SetImageOffset panic error %d", err ) |
|
362 USER_INVARIANT(); |
|
363 } |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // Sets image offset |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 EXPORT_C void CAlfBorderBrush::SetImageOffset(const TAlfXYMetric& aImageOffset) |
|
371 { |
|
372 TPckgC<TAlfXYMetric> buf(aImageOffset); |
|
373 |
|
374 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetImageOffsetMetric, buf ); |
|
375 |
|
376 if ( err != KErrNone ) |
|
377 { |
|
378 __ALFLOGSTRING1( "CAlfBorderBrush::SetImageOffset panic error %d", err ) |
|
379 USER_INVARIANT(); |
|
380 } |
|
381 } |
|
382 // --------------------------------------------------------------------------- |
|
383 // Sets edge offset |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 EXPORT_C void CAlfBorderBrush::SetEdgeOffset(const TAlfXYMetric& aEdgeOffset) |
|
387 { |
|
388 TPckgC<TAlfXYMetric> buf(aEdgeOffset); |
|
389 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetEdgeOffsetMetric, buf); |
|
390 |
|
391 if ( err != KErrNone ) |
|
392 { |
|
393 __ALFLOGSTRING1( "CAlfBorderBrush::SetEdgeOffset panic error %d", err ) |
|
394 USER_INVARIANT(); |
|
395 } |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // Sets thickness |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 EXPORT_C void CAlfBorderBrush::SetThickness(const TAlfXYMetric& aThickness) |
|
403 { |
|
404 TPckgC<TAlfXYMetric> buf(aThickness); |
|
405 TInt err = Comms()->DoCmdNoReply( EAlfBorderBrushSetThicknessMetric, buf); |
|
406 |
|
407 if ( err != KErrNone ) |
|
408 { |
|
409 __ALFLOGSTRING1( "CAlfBorderBrush::SetThickness panic error %d", err ) |
|
410 USER_INVARIANT(); |
|
411 } |
|
412 } |