Mercurial > projects > dwt-linux
annotate dwt/graphics/Transform.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | ce446666f5a2 |
children |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
259 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
23 | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
23 | 12 *******************************************************************************/ |
13 module dwt.graphics.Transform; | |
14 | |
238 | 15 import dwt.dwthelper.utils; |
16 | |
71 | 17 import dwt.DWT; |
23 | 18 import dwt.internal.Compatibility; |
19 import dwt.internal.cairo.Cairo; | |
20 import dwt.graphics.Resource; | |
21 import dwt.graphics.Device; | |
22 | |
23 import tango.text.convert.Format; | |
24 | |
25 /** | |
26 * Instances of this class represent transformation matrices for | |
27 * points expressed as (x, y) pairs of floating point numbers. | |
28 * <p> | |
29 * Application code must explicitly invoke the <code>Transform.dispose()</code> | |
30 * method to release the operating system resources managed by each instance | |
31 * when those instances are no longer required. | |
32 * </p> | |
33 * <p> | |
34 * This class requires the operating system's advanced graphics subsystem | |
35 * which may not be available on some platforms. | |
36 * </p> | |
37 * | |
259 | 38 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: GraphicsExample</a> |
39 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
40 * | |
23 | 41 * @since 3.1 |
42 */ | |
43 public class Transform : Resource { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
44 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
45 * the OS resource for the Transform |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
46 * (Warning: This field is platform dependent) |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
47 * <p> |
71 | 48 * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
49 * public API. It is marked public only so that it can be shared |
71 | 50 * within the packages provided by DWT. It is not available on all |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
51 * platforms and should never be accessed from application code. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
52 * </p> |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
53 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
54 public double[] handle; |
23 | 55 |
56 /** | |
57 * Constructs a new identity Transform. | |
58 * <p> | |
59 * This operation requires the operating system's advanced | |
60 * graphics subsystem which may not be available on some | |
61 * platforms. | |
62 * </p> | |
63 * | |
64 * @param device the device on which to allocate the Transform | |
65 * | |
66 * @exception IllegalArgumentException <ul> | |
67 * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> | |
68 * </ul> | |
71 | 69 * @exception DWTException <ul> |
23 | 70 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
71 * </ul> | |
71 | 72 * @exception DWTError <ul> |
23 | 73 * <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li> |
74 * </ul> | |
75 * | |
76 * @see #dispose() | |
77 */ | |
78 public this (Device device) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
79 this(device, 1, 0, 0, 1, 0, 0); |
23 | 80 } |
81 | |
82 /** | |
83 * Constructs a new Transform given an array of elements that represent the | |
84 * matrix that describes the transformation. | |
85 * <p> | |
86 * This operation requires the operating system's advanced | |
87 * graphics subsystem which may not be available on some | |
88 * platforms. | |
89 * </p> | |
90 * | |
91 * @param device the device on which to allocate the Transform | |
92 * @param elements an array of floats that describe the transformation matrix | |
93 * | |
94 * @exception IllegalArgumentException <ul> | |
95 * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device, or the elements array is null</li> | |
96 * <li>ERROR_INVALID_ARGUMENT - if the elements array is too small to hold the matrix values</li> | |
97 * </ul> | |
71 | 98 * @exception DWTException <ul> |
23 | 99 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
100 * </ul> | |
71 | 101 * @exception DWTError <ul> |
23 | 102 * <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li> |
103 * </ul> | |
104 * | |
105 * @see #dispose() | |
106 */ | |
107 public this(Device device, float[] elements) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
108 this (device, checkTransform(elements)[0], elements[1], elements[2], elements[3], elements[4], elements[5]); |
23 | 109 } |
110 | |
111 /** | |
112 * Constructs a new Transform given all of the elements that represent the | |
113 * matrix that describes the transformation. | |
114 * <p> | |
115 * This operation requires the operating system's advanced | |
116 * graphics subsystem which may not be available on some | |
117 * platforms. | |
118 * </p> | |
119 * | |
120 * @param device the device on which to allocate the Transform | |
121 * @param m11 the first element of the first row of the matrix | |
122 * @param m12 the second element of the first row of the matrix | |
123 * @param m21 the first element of the second row of the matrix | |
124 * @param m22 the second element of the second row of the matrix | |
125 * @param dx the third element of the first row of the matrix | |
126 * @param dy the third element of the second row of the matrix | |
127 * | |
128 * @exception IllegalArgumentException <ul> | |
129 * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> | |
130 * </ul> | |
71 | 131 * @exception DWTException <ul> |
23 | 132 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
133 * </ul> | |
71 | 134 * @exception DWTError <ul> |
23 | 135 * <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li> |
136 * </ul> | |
137 * | |
138 * @see #dispose() | |
139 */ | |
140 public this (Device device, float m11, float m12, float m21, float m22, float dx, float dy) { | |
240 | 141 super(device); |
142 this.device.checkCairo(); | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
143 handle = new double[6]; |
71 | 144 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
145 Cairo.cairo_matrix_init( cast(cairo_matrix_t*)handle.ptr, m11, m12, m21, m22, dx, dy); |
240 | 146 init_(); |
23 | 147 } |
148 | |
149 static float[] checkTransform(float[] elements) { | |
194 | 150 if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
71 | 151 if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
152 return elements; |
23 | 153 } |
154 | |
240 | 155 void destroy() { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
156 handle = null; |
23 | 157 } |
158 | |
159 /** | |
160 * Fills the parameter with the values of the transformation matrix | |
161 * that the receiver represents, in the order {m11, m12, m21, m22, dx, dy}. | |
162 * | |
163 * @param elements array to hold the matrix values | |
164 * | |
71 | 165 * @exception DWTException <ul> |
23 | 166 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
167 * </ul> | |
168 * @exception IllegalArgumentException <ul> | |
169 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> | |
170 * <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the matrix values</li> | |
171 * </ul> | |
172 */ | |
173 public void getElements(float[] elements) { | |
71 | 174 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
175 if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
176 if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
177 elements[0] = cast(float)handle[0]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
178 elements[1] = cast(float)handle[1]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
179 elements[2] = cast(float)handle[2]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
180 elements[3] = cast(float)handle[3]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
181 elements[4] = cast(float)handle[4]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
182 elements[5] = cast(float)handle[5]; |
23 | 183 } |
184 | |
259 | 185 /** |
186 * Modifies the receiver such that the matrix it represents becomes the | |
187 * identity matrix. | |
188 * | |
189 * @exception DWTException <ul> | |
190 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
191 * </ul> | |
192 * | |
193 * @since 3.4 | |
194 */ | |
240 | 195 public void identity() { |
196 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
197 Cairo.cairo_matrix_init(cast(cairo_matrix_t*)handle.ptr, 1, 0, 0, 1, 0, 0); | |
198 } | |
199 | |
23 | 200 /** |
259 | 201 * Modifies the receiver such that the matrix it represents becomes |
23 | 202 * the mathematical inverse of the matrix it previously represented. |
203 * | |
71 | 204 * @exception DWTException <ul> |
23 | 205 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
206 * <li>ERROR_CANNOT_INVERT_MATRIX - if the matrix is not invertible</li> | |
207 * </ul> | |
208 */ | |
209 public void invert() { | |
71 | 210 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
194 | 211 if (Cairo.cairo_matrix_invert(cast(cairo_matrix_t*)handle.ptr) !is 0) { |
71 | 212 DWT.error(DWT.ERROR_CANNOT_INVERT_MATRIX); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
213 } |
23 | 214 } |
215 | |
216 /** | |
217 * Returns <code>true</code> if the Transform has been disposed, | |
218 * and <code>false</code> otherwise. | |
219 * <p> | |
220 * This method gets the dispose state for the Transform. | |
221 * When a Transform has been disposed, it is an error to | |
222 * invoke any other method using the Transform. | |
223 * | |
224 * @return <code>true</code> when the Transform is disposed, and <code>false</code> otherwise | |
225 */ | |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
226 public override bool isDisposed() { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
227 return handle is null; |
23 | 228 } |
229 | |
230 /** | |
231 * Returns <code>true</code> if the Transform represents the identity matrix | |
232 * and false otherwise. | |
233 * | |
234 * @return <code>true</code> if the receiver is an identity Transform, and <code>false</code> otherwise | |
235 */ | |
236 public bool isIdentity() { | |
71 | 237 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
238 float[] m = new float[6]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
239 getElements(m); |
194 | 240 return m[0] is 1 && m[1] is 0 && m[2] is 0 && m[3] is 1 && m[4] is 0 && m[5] is 0; |
23 | 241 } |
242 | |
243 /** | |
244 * Modifies the receiver such that the matrix it represents becomes the | |
245 * the result of multiplying the matrix it previously represented by the | |
246 * argument. | |
247 * | |
248 * @param matrix the matrix to multiply the receiver by | |
249 * | |
71 | 250 * @exception DWTException <ul> |
23 | 251 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
252 * </ul> | |
253 * @exception IllegalArgumentException <ul> | |
254 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> | |
255 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> | |
256 * </ul> | |
257 */ | |
258 public void multiply(Transform matrix) { | |
71 | 259 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
194 | 260 if (matrix is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
71 | 261 if (matrix.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
262 Cairo.cairo_matrix_multiply(cast(cairo_matrix_t*)handle.ptr,cast(cairo_matrix_t*)matrix.handle.ptr, cast(cairo_matrix_t*)handle.ptr); |
23 | 263 } |
264 | |
265 /** | |
266 * Modifies the receiver so that it represents a transformation that is | |
267 * equivalent to its previous transformation rotated by the specified angle. | |
268 * The angle is specified in degrees and for the identity transform 0 degrees | |
269 * is at the 3 o'clock position. A positive value indicates a clockwise rotation | |
270 * while a negative value indicates a counter-clockwise rotation. | |
271 * | |
272 * @param angle the angle to rotate the transformation by | |
273 * | |
71 | 274 * @exception DWTException <ul> |
23 | 275 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
276 * </ul> | |
277 */ | |
278 public void rotate(float angle) { | |
71 | 279 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
280 Cairo.cairo_matrix_rotate(cast(cairo_matrix_t*)handle.ptr, angle * cast(float)Compatibility.PI / 180); |
23 | 281 } |
282 | |
283 /** | |
284 * Modifies the receiver so that it represents a transformation that is | |
285 * equivalent to its previous transformation scaled by (scaleX, scaleY). | |
286 * | |
287 * @param scaleX the amount to scale in the X direction | |
288 * @param scaleY the amount to scale in the Y direction | |
289 * | |
71 | 290 * @exception DWTException <ul> |
23 | 291 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
292 * </ul> | |
293 */ | |
294 public void scale(float scaleX, float scaleY) { | |
71 | 295 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
296 Cairo.cairo_matrix_scale(cast(cairo_matrix_t*)handle.ptr, scaleX, scaleY); |
23 | 297 } |
298 | |
299 /** | |
300 * Modifies the receiver to represent a new transformation given all of | |
301 * the elements that represent the matrix that describes that transformation. | |
302 * | |
303 * @param m11 the first element of the first row of the matrix | |
304 * @param m12 the second element of the first row of the matrix | |
305 * @param m21 the first element of the second row of the matrix | |
306 * @param m22 the second element of the second row of the matrix | |
307 * @param dx the third element of the first row of the matrix | |
308 * @param dy the third element of the second row of the matrix | |
309 * | |
71 | 310 * @exception DWTException <ul> |
23 | 311 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
312 * </ul> | |
313 */ | |
314 public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) { | |
71 | 315 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
316 Cairo.cairo_matrix_init(cast(cairo_matrix_t*)handle.ptr, m11, m12, m21, m22, dx, dy); |
23 | 317 } |
318 | |
259 | 319 /** |
320 * Modifies the receiver so that it represents a transformation that is | |
321 * equivalent to its previous transformation sheared by (shearX, shearY). | |
322 * | |
323 * @param shearX the shear factor in the X direction | |
324 * @param shearY the shear factor in the Y direction | |
325 * | |
326 * @exception DWTException <ul> | |
327 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> | |
328 * </ul> | |
329 * | |
330 * @since 3.4 | |
331 */ | |
240 | 332 public void shear(float shearX, float shearY) { |
333 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | |
334 double[] matrix = [ 1.0, shearX, shearY, 1, 0, 0]; | |
335 Cairo.cairo_matrix_multiply(cast(cairo_matrix_t*)handle.ptr, cast(cairo_matrix_t*)matrix.ptr, cast(cairo_matrix_t*)handle.ptr); | |
336 } | |
337 | |
23 | 338 /** |
339 * Given an array containing points described by alternating x and y values, | |
340 * modify that array such that each point has been replaced with the result of | |
341 * applying the transformation represented by the receiver to that point. | |
342 * | |
343 * @param pointArray an array of alternating x and y values to be transformed | |
344 * | |
345 * @exception IllegalArgumentException <ul> | |
346 * <li>ERROR_NULL_ARGUMENT - if the point array is null</li> | |
347 * </ul> | |
71 | 348 * @exception DWTException <ul> |
23 | 349 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
350 * </ul> | |
351 */ | |
352 public void transform(float[] pointArray) { | |
71 | 353 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
194 | 354 if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
355 double dx, dy; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
356 int length = pointArray.length / 2; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
357 for (int i = 0, j = 0; i < length; i++, j += 2) { |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
358 dx = pointArray[j]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
359 dy = pointArray[j + 1]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
360 Cairo.cairo_matrix_transform_point(cast(cairo_matrix_t*)handle.ptr, &dx, &dy); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
361 pointArray[j] = cast(float)dx; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
362 pointArray[j + 1] = cast(float)dy; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
363 } |
23 | 364 } |
365 | |
366 /** | |
367 * Modifies the receiver so that it represents a transformation that is | |
368 * equivalent to its previous transformation translated by (offsetX, offsetY). | |
369 * | |
370 * @param offsetX the distance to translate in the X direction | |
371 * @param offsetY the distance to translate in the Y direction | |
372 * | |
71 | 373 * @exception DWTException <ul> |
23 | 374 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
375 * </ul> | |
376 */ | |
377 public void translate(float offsetX, float offsetY) { | |
71 | 378 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
379 Cairo.cairo_matrix_translate(cast(cairo_matrix_t*)handle.ptr, offsetX, offsetY); |
23 | 380 } |
381 | |
382 /** | |
383 * Returns a string containing a concise, human-readable | |
384 * description of the receiver. | |
385 * | |
386 * @return a string representation of the receiver | |
387 */ | |
238 | 388 public override String toString() { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
389 if (isDisposed()) return "Transform {*DISPOSED*}"; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
390 float[] elements = new float[6]; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
391 getElements(elements); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
392 return Format( "Transform {{{}}", elements ); |
23 | 393 } |
394 | |
395 } |