Mercurial > projects > dwt-win
annotate dwt/graphics/GC.d @ 334:c49e17d48b76
Fix problems at GC run at main()'s end.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 18 Feb 2009 16:14:31 +0100 |
parents | b3dbd786541a |
children |
rev | line source |
---|---|
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1 /******************************************************************************* |
246 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * Contributors: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
23 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 *******************************************************************************/ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 module dwt.graphics.GC; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 import dwt.DWT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 import dwt.DWTError; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
17 import dwt.DWTException; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 import dwt.internal.Compatibility; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 import dwt.internal.gdip.Gdip; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 import dwt.internal.win32.OS; |
24 | 21 |
22 import dwt.graphics.Color; | |
23 import dwt.graphics.Drawable; | |
24 import dwt.graphics.Resource; | |
25 import dwt.graphics.Device; | |
26 import dwt.graphics.Font; | |
27 import dwt.graphics.FontMetrics; | |
28 import dwt.graphics.GCData; | |
29 import dwt.graphics.Image; | |
30 import dwt.graphics.ImageData; | |
31 import dwt.graphics.Path; | |
32 import dwt.graphics.Pattern; | |
33 import dwt.graphics.Point; | |
34 import dwt.graphics.RGB; | |
35 import dwt.graphics.Rectangle; | |
36 import dwt.graphics.Region; | |
37 import dwt.graphics.Resource; | |
38 import dwt.graphics.Transform; | |
39 import dwt.graphics.LineAttributes; | |
40 | |
25 | 41 import dwt.dwthelper.utils; |
24 | 42 import tango.text.convert.Format; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 * Class <code>GC</code> is where all of the drawing capabilities that are |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 * supported by DWT are located. Instances are used to draw on either an |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 * <dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 * <dt><b>Styles:</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 * </dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 * The DWT drawing coordinate system is the two-dimensional space with the origin |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 * (0,0) at the top left corner of the drawing area and with (x,y) values increasing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 * to the right and downward respectively. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 * Application code must explicitly invoke the <code>GC.dispose()</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 * method to release the operating system resources managed by each instance |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 * when those instances are no longer required. This is <em>particularly</em> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 * important on Windows95 and Windows98 where the operating system has a limited |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 * number of device contexts available. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 * @see dwt.events.PaintEvent |
246 | 72 * @see <a href="http://www.eclipse.org/swt/snippets/#gc">GC snippets</a> |
73 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Examples: GraphicsExample, PaintExample</a> | |
74 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 |
24 | 77 public final class GC : Resource { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 |
213 | 79 alias Resource.init_ init_; |
80 | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 * the handle to the OS device context |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 * (Warning: This field is platform dependent) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 * public API. It is marked public only so that it can be shared |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 * within the packages provided by DWT. It is not available on all |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 * platforms and should never be accessed from application code. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 */ |
24 | 91 public HDC handle; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 Drawable drawable; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 GCData data; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 |
24 | 96 static const int FOREGROUND = 1 << 0; |
97 static const int BACKGROUND = 1 << 1; | |
98 static const int FONT = 1 << 2; | |
99 static const int LINE_STYLE = 1 << 3; | |
100 static const int LINE_WIDTH = 1 << 4; | |
101 static const int LINE_CAP = 1 << 5; | |
102 static const int LINE_JOIN = 1 << 6; | |
103 static const int LINE_MITERLIMIT = 1 << 7; | |
104 static const int FOREGROUND_TEXT = 1 << 8; | |
105 static const int BACKGROUND_TEXT = 1 << 9; | |
106 static const int BRUSH = 1 << 10; | |
107 static const int PEN = 1 << 11; | |
108 static const int NULL_BRUSH = 1 << 12; | |
109 static const int NULL_PEN = 1 << 13; | |
110 static const int DRAW_OFFSET = 1 << 14; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 |
24 | 112 static const int DRAW = FOREGROUND | LINE_STYLE | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_MITERLIMIT | PEN | NULL_BRUSH | DRAW_OFFSET; |
113 static const int FILL = BACKGROUND | BRUSH | NULL_PEN; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 |
24 | 115 static const float[] LINE_DOT_ZERO = [3, 3]; |
116 static const float[] LINE_DASH_ZERO = [18, 6]; | |
117 static const float[] LINE_DASHDOT_ZERO = [9, 6, 3, 6]; | |
118 static const float[] LINE_DASHDOTDOT_ZERO = [9, 3, 3, 3, 3, 3]; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
119 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
120 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
121 * Prevents uninitialized instances from being created outside the package. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
122 */ |
24 | 123 this() { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
124 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
125 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
126 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
127 * Constructs a new instance of this class which has been |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 * configured to draw on the specified drawable. Sets the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 * foreground color, background color and font in the GC |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 * to match those in the drawable. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 * You must dispose the graphics context when it is no longer required. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 * @param drawable the drawable to draw on |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 * <li>ERROR_NULL_ARGUMENT - if the drawable is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 * <li>ERROR_NULL_ARGUMENT - if there is no current device</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 * <li>ERROR_INVALID_ARGUMENT |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 * - if the drawable is an image that is not a bitmap or an icon |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 * - if the drawable is an image or printer that is already selected |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 * into another graphics context</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 * @exception DWTError <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 * <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 */ |
24 | 148 public this(Drawable drawable) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 this(drawable, DWT.NONE); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 * Constructs a new instance of this class which has been |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 * configured to draw on the specified drawable. Sets the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 * foreground color, background color and font in the GC |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 * to match those in the drawable. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 * You must dispose the graphics context when it is no longer required. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 * @param drawable the drawable to draw on |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 * @param style the style of GC to construct |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 * <li>ERROR_NULL_ARGUMENT - if the drawable is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 * <li>ERROR_NULL_ARGUMENT - if there is no current device</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 * <li>ERROR_INVALID_ARGUMENT |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 * - if the drawable is an image that is not a bitmap or an icon |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 * - if the drawable is an image or printer that is already selected |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 * into another graphics context</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 * @exception DWTError <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 * <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
177 * @since 2.1.2 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
178 */ |
24 | 179 public this(Drawable drawable, int style) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
180 if (drawable is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
181 GCData data = new GCData (); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
182 data.style = checkStyle(style); |
24 | 183 auto hDC = drawable.internal_new_GC(data); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
184 Device device = data.device; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
185 if (device is null) device = Device.getDevice(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
186 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
187 this.device = data.device = device; |
197
184ab53b7785
Changes and fixes for jface
Frank Benoit <benoit@tionex.de>
parents:
194
diff
changeset
|
188 init_ (drawable, data, hDC); |
213 | 189 init_(); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
190 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
191 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
192 static int checkStyle(int style) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
193 if ((style & DWT.LEFT_TO_RIGHT) !is 0) style &= ~DWT.RIGHT_TO_LEFT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
194 return style & (DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
195 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
196 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
197 void checkGC(int mask) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
198 int state = data.state; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
199 if ((state & mask) is mask) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
200 state = (state ^ mask) & mask; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
201 data.state |= mask; |
24 | 202 auto gdipGraphics = data.gdipGraphics; |
203 if (gdipGraphics !is null) { | |
204 auto pen = data.gdipPen; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
205 float width = data.lineWidth; |
24 | 206 if ((state & FOREGROUND) !is 0 || (pen is null && (state & (LINE_WIDTH | LINE_STYLE | LINE_MITERLIMIT | LINE_JOIN | LINE_CAP)) !is 0)) { |
207 if (data.gdipFgBrush !is null) Gdip.SolidBrush_delete(data.gdipFgBrush); | |
208 data.gdipFgBrush = null; | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
209 Gdip.Brush brush; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
210 Pattern pattern = data.foregroundPattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
211 if (pattern !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 brush = pattern.handle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
213 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
214 switch (Gdip.Brush_GetType(brush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
215 case Gdip.BrushTypeTextureFill: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
216 brush = Gdip.Brush_Clone(brush); |
24 | 217 if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
218 Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush) brush, -1, 1, Gdip.MatrixOrderPrepend); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
219 data.gdipFgBrush = cast(Gdip.SolidBrush)brush; |
81 | 220 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
221 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
222 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
223 } else { |
24 | 224 auto foreground = data.foreground; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
225 int rgb = ((foreground >> 16) & 0xFF) | (foreground & 0xFF00) | ((foreground & 0xFF) << 16); |
24 | 226 auto color = Gdip.Color_new(data.alpha << 24 | rgb); |
220
f54496748313
Fix foreground color in GC on non-gdip platforms
Frank Benoit <benoit@tionex.de>
parents:
215
diff
changeset
|
227 if (color is 0) DWT.error(DWT.ERROR_NO_HANDLES); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
228 brush = cast(Gdip.Brush) Gdip.SolidBrush_new(color); |
24 | 229 if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
230 Gdip.Color_delete(color); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
231 data.gdipFgBrush = cast(Gdip.SolidBrush)brush; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
232 } |
24 | 233 if (pen !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
234 Gdip.Pen_SetBrush(pen, brush); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
235 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
236 pen = data.gdipPen = Gdip.Pen_new(brush, width); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
237 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
238 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
239 if ((state & LINE_WIDTH) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
240 Gdip.Pen_SetWidth(pen, width); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
241 switch (data.lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
242 case DWT.LINE_CUSTOM: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
243 state |= LINE_STYLE; |
81 | 244 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
245 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
246 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
247 if ((state & LINE_STYLE) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
248 float[] dashes = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
249 float dashOffset = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
250 int dashStyle = Gdip.DashStyleSolid; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
251 switch (data.lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
252 case DWT.LINE_SOLID: break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
253 case DWT.LINE_DOT: dashStyle = Gdip.DashStyleDot; if (width is 0) dashes = LINE_DOT_ZERO; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
254 case DWT.LINE_DASH: dashStyle = Gdip.DashStyleDash; if (width is 0) dashes = LINE_DASH_ZERO; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
255 case DWT.LINE_DASHDOT: dashStyle = Gdip.DashStyleDashDot; if (width is 0) dashes = LINE_DASHDOT_ZERO; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
256 case DWT.LINE_DASHDOTDOT: dashStyle = Gdip.DashStyleDashDotDot; if (width is 0) dashes = LINE_DASHDOTDOT_ZERO; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
257 case DWT.LINE_CUSTOM: { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
258 if (data.lineDashes !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
259 dashOffset = data.lineDashesOffset / Math.max (1, width); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
260 dashes = new float[data.lineDashes.length * 2]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
261 for (int i = 0; i < data.lineDashes.length; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
262 float dash = data.lineDashes[i] / Math.max (1, width); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
263 dashes[i] = dash; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
264 dashes[i + data.lineDashes.length] = dash; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
265 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
266 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
267 } |
81 | 268 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
269 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
270 if (dashes !is null) { |
213 | 271 Gdip.Pen_SetDashPattern(pen, dashes.ptr, dashes.length); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
272 Gdip.Pen_SetDashStyle(pen, Gdip.DashStyleCustom); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
273 Gdip.Pen_SetDashOffset(pen, dashOffset); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
274 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
275 Gdip.Pen_SetDashStyle(pen, dashStyle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
276 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
277 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
278 if ((state & LINE_MITERLIMIT) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
279 Gdip.Pen_SetMiterLimit(pen, data.lineMiterLimit); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
280 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
281 if ((state & LINE_JOIN) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
282 int joinStyle = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
283 switch (data.lineJoin) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
284 case DWT.JOIN_MITER: joinStyle = Gdip.LineJoinMiter; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
285 case DWT.JOIN_BEVEL: joinStyle = Gdip.LineJoinBevel; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
286 case DWT.JOIN_ROUND: joinStyle = Gdip.LineJoinRound; break; |
81 | 287 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
288 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
289 Gdip.Pen_SetLineJoin(pen, joinStyle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
290 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
291 if ((state & LINE_CAP) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
292 int dashCap = Gdip.DashCapFlat, capStyle = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
293 switch (data.lineCap) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
294 case DWT.CAP_FLAT: capStyle = Gdip.LineCapFlat; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
295 case DWT.CAP_ROUND: capStyle = Gdip.LineCapRound; dashCap = Gdip.DashCapRound; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
296 case DWT.CAP_SQUARE: capStyle = Gdip.LineCapSquare; break; |
81 | 297 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
298 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
299 Gdip.Pen_SetLineCap(pen, capStyle, capStyle, dashCap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
300 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
301 if ((state & BACKGROUND) !is 0) { |
24 | 302 if (data.gdipBgBrush !is null) Gdip.SolidBrush_delete(data.gdipBgBrush); |
303 data.gdipBgBrush = null; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
304 Pattern pattern = data.backgroundPattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
305 if (pattern !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
306 data.gdipBrush = pattern.handle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
307 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
308 switch (Gdip.Brush_GetType(data.gdipBrush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
309 case Gdip.BrushTypeTextureFill: |
24 | 310 auto brush = Gdip.Brush_Clone(data.gdipBrush); |
311 if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
312 Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); |
24 | 313 data.gdipBrush = brush; |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
314 data.gdipBgBrush = cast(Gdip.SolidBrush) brush; |
81 | 315 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
316 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
317 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
318 } else { |
24 | 319 auto background = data.background; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
320 int rgb = ((background >> 16) & 0xFF) | (background & 0xFF00) | ((background & 0xFF) << 16); |
24 | 321 auto color = Gdip.Color_new(data.alpha << 24 | rgb); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
322 // if (color is null) DWT.error(DWT.ERROR_NO_HANDLES); |
24 | 323 auto brush = Gdip.SolidBrush_new(color); |
324 if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
325 Gdip.Color_delete(color); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
326 data.gdipBrush = cast(Gdip.Brush)brush; |
24 | 327 data.gdipBgBrush = brush; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
328 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
329 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
330 if ((state & FONT) !is 0) { |
213 | 331 Font font = data.font; |
332 OS.SelectObject(handle, font.handle); | |
333 auto gdipFont = createGdipFont(handle, font.handle); | |
24 | 334 if (data.gdipFont !is null) Gdip.Font_delete(data.gdipFont); |
213 | 335 data.gdipFont = gdipFont; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
336 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
337 if ((state & DRAW_OFFSET) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
338 data.gdipXOffset = data.gdipYOffset = 0; |
24 | 339 auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); |
213 | 340 float[2] point; point[0]=1.0; point[1]=1.0; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
341 Gdip.Graphics_GetTransform(gdipGraphics, matrix); |
213 | 342 Gdip.Matrix_TransformPoints(matrix, cast(Gdip.PointF*)point.ptr, 1); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
343 Gdip.Matrix_delete(matrix); |
213 | 344 float scaling = point[0]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
345 if (scaling < 0) scaling = -scaling; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
346 float penWidth = data.lineWidth * scaling; |
24 | 347 if (penWidth is 0 || (cast(int)penWidth % 2) is 1) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
348 data.gdipXOffset = 0.5f / scaling; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
349 } |
213 | 350 scaling = point[1]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
351 if (scaling < 0) scaling = -scaling; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
352 penWidth = data.lineWidth * scaling; |
24 | 353 if (penWidth is 0 || (cast(int)penWidth % 2) is 1) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
354 data.gdipYOffset = 0.5f / scaling; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
355 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
356 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
357 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
358 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
359 if ((state & (FOREGROUND | LINE_CAP | LINE_JOIN | LINE_STYLE | LINE_WIDTH)) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
360 int color = data.foreground; |
24 | 361 int width = cast(int)data.lineWidth; |
362 uint[] dashes = null; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
363 int lineStyle = OS.PS_SOLID; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
364 switch (data.lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
365 case DWT.LINE_SOLID: break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
366 case DWT.LINE_DASH: lineStyle = OS.PS_DASH; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
367 case DWT.LINE_DOT: lineStyle = OS.PS_DOT; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
368 case DWT.LINE_DASHDOT: lineStyle = OS.PS_DASHDOT; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
369 case DWT.LINE_DASHDOTDOT: lineStyle = OS.PS_DASHDOTDOT; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
370 case DWT.LINE_CUSTOM: { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
371 if (data.lineDashes !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
372 lineStyle = OS.PS_USERSTYLE; |
24 | 373 dashes = new uint[data.lineDashes.length]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
374 for (int i = 0; i < dashes.length; i++) { |
24 | 375 dashes[i] = cast(int)data.lineDashes[i]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
376 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
377 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
378 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
379 } |
81 | 380 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
381 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
382 if ((state & LINE_STYLE) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
383 OS.SetBkMode(handle, data.lineStyle is DWT.LINE_SOLID ? OS.OPAQUE : OS.TRANSPARENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
384 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
385 int joinStyle = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
386 switch (data.lineJoin) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
387 case DWT.JOIN_MITER: joinStyle = OS.PS_JOIN_MITER; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
388 case DWT.JOIN_ROUND: joinStyle = OS.PS_JOIN_ROUND; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
389 case DWT.JOIN_BEVEL: joinStyle = OS.PS_JOIN_BEVEL; break; |
81 | 390 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
391 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
392 int capStyle = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
393 switch (data.lineCap) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
394 case DWT.CAP_ROUND: capStyle = OS.PS_ENDCAP_ROUND; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
395 case DWT.CAP_FLAT: capStyle = OS.PS_ENDCAP_FLAT; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
396 case DWT.CAP_SQUARE: capStyle = OS.PS_ENDCAP_SQUARE;break; |
81 | 397 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
398 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
399 int style = lineStyle | joinStyle | capStyle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
400 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
401 * Feature in Windows. Windows does not honour line styles other then |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
402 * PS_SOLID for pens wider than 1 pixel created with CreatePen(). The fix |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
403 * is to use ExtCreatePen() instead. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
404 */ |
24 | 405 HPEN newPen; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
406 if (OS.IsWinCE || (width is 0 && lineStyle !is OS.PS_USERSTYLE) || style is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
407 newPen = OS.CreatePen(style & OS.PS_STYLE_MASK, width, color); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
408 } else { |
24 | 409 LOGBRUSH logBrush; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
410 logBrush.lbStyle = OS.BS_SOLID; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
411 logBrush.lbColor = color; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
412 /* Feature in Windows. PS_GEOMETRIC pens cannot have zero width. */ |
24 | 413 newPen = OS.ExtCreatePen (style | OS.PS_GEOMETRIC, Math.max(1, width), &logBrush, dashes !is null ? dashes.length : 0, dashes.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
414 } |
220
f54496748313
Fix foreground color in GC on non-gdip platforms
Frank Benoit <benoit@tionex.de>
parents:
215
diff
changeset
|
415 OS.SelectObject(handle, newPen); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
416 data.state |= PEN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
417 data.state &= ~NULL_PEN; |
24 | 418 if (data.hPen !is null) OS.DeleteObject(data.hPen); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
419 data.hPen = data.hOldPen = newPen; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
420 } else if ((state & PEN) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
421 OS.SelectObject(handle, data.hOldPen); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
422 data.state &= ~NULL_PEN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
423 } else if ((state & NULL_PEN) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
424 data.hOldPen = OS.SelectObject(handle, OS.GetStockObject(OS.NULL_PEN)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
425 data.state &= ~PEN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
426 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
427 if ((state & BACKGROUND) !is 0) { |
24 | 428 auto newBrush = OS.CreateSolidBrush(data.background); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
429 OS.SelectObject(handle, newBrush); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
430 data.state |= BRUSH; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
431 data.state &= ~NULL_BRUSH; |
24 | 432 if (data.hBrush !is null) OS.DeleteObject(data.hBrush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
433 data.hOldBrush = data.hBrush = newBrush; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
434 } else if ((state & BRUSH) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
435 OS.SelectObject(handle, data.hOldBrush); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
436 data.state &= ~NULL_BRUSH; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
437 } else if ((state & NULL_BRUSH) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
438 data.hOldBrush = OS.SelectObject(handle, OS.GetStockObject(OS.NULL_BRUSH)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
439 data.state &= ~BRUSH; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
440 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
441 if ((state & BACKGROUND_TEXT) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
442 OS.SetBkColor(handle, data.background); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
443 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
444 if ((state & FOREGROUND_TEXT) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
445 OS.SetTextColor(handle, data.foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
446 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
447 if ((state & FONT) !is 0) { |
213 | 448 Font font = data.font; |
449 OS.SelectObject(handle, font.handle); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
450 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
451 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
452 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
453 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
454 * Copies a rectangular area of the receiver at the specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
455 * position into the image, which must be of type <code>DWT.BITMAP</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
456 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
457 * @param image the image to copy into |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
458 * @param x the x coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
459 * @param y the y coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
460 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
461 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
462 * <li>ERROR_NULL_ARGUMENT - if the image is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
463 * <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
464 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
465 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
466 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
467 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
468 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
469 public void copyArea(Image image, int x, int y) { |
24 | 470 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
471 if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
472 if (image.type !is DWT.BITMAP || image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
473 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
474 /* Copy the bitmap area */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
475 Rectangle rect = image.getBounds(); |
24 | 476 auto memHdc = OS.CreateCompatibleDC(handle); |
477 auto hOldBitmap = OS.SelectObject(memHdc, image.handle); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
478 OS.BitBlt(memHdc, 0, 0, rect.width, rect.height, handle, x, y, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
479 OS.SelectObject(memHdc, hOldBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
480 OS.DeleteDC(memHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
481 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
482 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
483 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
484 * Copies a rectangular area of the receiver at the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
485 * position onto the receiver at the destination position. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
486 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
487 * @param srcX the x coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
488 * @param srcY the y coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
489 * @param width the width of the area to copy |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
490 * @param height the height of the area to copy |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
491 * @param destX the x coordinate in the receiver of the area to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
492 * @param destY the y coordinate in the receiver of the area to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
493 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
494 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
495 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
496 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
497 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
498 public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
499 copyArea(srcX, srcY, width, height, destX, destY, true); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
500 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
501 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
502 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
503 * Copies a rectangular area of the receiver at the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
504 * position onto the receiver at the destination position. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
505 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
506 * @param srcX the x coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
507 * @param srcY the y coordinate in the receiver of the area to be copied |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
508 * @param width the width of the area to copy |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
509 * @param height the height of the area to copy |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
510 * @param destX the x coordinate in the receiver of the area to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
511 * @param destY the y coordinate in the receiver of the area to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
512 * @param paint if <code>true</code> paint events will be generated for old and obscured areas |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
513 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
514 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
515 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
516 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
517 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
518 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
519 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
520 public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, bool paint) { |
24 | 521 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
522 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
523 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
524 * Feature in WinCE. The function WindowFromDC is not part of the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
525 * WinCE SDK. The fix is to remember the HWND. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
526 */ |
24 | 527 auto hwnd = data.hwnd; |
528 if (hwnd is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
529 OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
530 } else { |
24 | 531 RECT lprcClip; |
532 auto hrgn = OS.CreateRectRgn(0, 0, 0, 0); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
533 if (OS.GetClipRgn(handle, hrgn) is 1) { |
24 | 534 OS.GetRgnBox(hrgn, &lprcClip); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
535 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
536 OS.DeleteObject(hrgn); |
24 | 537 RECT lprcScroll; |
538 OS.SetRect(&lprcScroll, srcX, srcY, srcX + width, srcY + height); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
539 int flags = paint ? OS.SW_INVALIDATE | OS.SW_ERASE : 0; |
24 | 540 int res = OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, &lprcScroll, &lprcClip, null, null, flags); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
541 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
542 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
543 * Feature in WinCE. ScrollWindowEx does not accept combined |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
544 * vertical and horizontal scrolling. The fix is to do a |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
545 * BitBlt and invalidate the appropriate source area. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
546 */ |
117 | 547 static if (OS.IsWinCE) { |
548 if (res is 0) { | |
549 OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY); | |
550 if (paint) { | |
551 int deltaX = destX - srcX, deltaY = destY - srcY; | |
552 bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); | |
553 if (disjoint) { | |
24 | 554 OS.InvalidateRect(hwnd, &lprcScroll, true); |
117 | 555 } else { |
556 if (deltaX !is 0) { | |
557 int newX = destX - deltaX; | |
558 if (deltaX < 0) newX = destX + width; | |
559 OS.SetRect(&lprcScroll, newX, srcY, newX + Math.abs(deltaX), srcY + height); | |
560 OS.InvalidateRect(hwnd, &lprcScroll, true); | |
561 } | |
562 if (deltaY !is 0) { | |
563 int newY = destY - deltaY; | |
564 if (deltaY < 0) newY = destY + height; | |
565 OS.SetRect(&lprcScroll, srcX, newY, srcX + width, newY + Math.abs(deltaY)); | |
566 OS.InvalidateRect(hwnd, &lprcScroll, true); | |
567 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
568 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
569 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
570 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
571 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
572 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
573 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
574 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
575 static Gdip.Font createGdipFont(HDC hDC, HFONT hFont) { |
24 | 576 auto font = Gdip.Font_new(hDC, hFont); |
577 if (font is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
578 if (!Gdip.Font_IsAvailable(font)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
579 Gdip.Font_delete(font); |
24 | 580 LOGFONT logFont; |
581 OS.GetObject(hFont, LOGFONT.sizeof, &logFont); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
582 int size = Math.abs(logFont.lfHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
583 int style = Gdip.FontStyleRegular; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
584 if (logFont.lfWeight is 700) style |= Gdip.FontStyleBold; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
585 if (logFont.lfItalic !is 0) style |= Gdip.FontStyleItalic; |
24 | 586 wchar[] chars; |
587 static if (OS.IsUnicode) { | |
588 chars = logFont.lfFaceName; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
589 } else { |
24 | 590 chars = new wchar[OS.LF_FACESIZE]; |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
591 String bytes = logFont.lfFaceName; |
24 | 592 OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes.ptr, bytes.length, chars, chars.length); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
593 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
594 int index = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
595 while (index < chars.length) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
596 if (chars [index] is 0) break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
597 index++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
598 } |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
599 String name = WCHARsToStr( chars[ 0 .. index ] ); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
600 if (Compatibility.equalsIgnoreCase(name, "Courier")) { //$NON-NLS-1$ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
601 name = "Courier New"; //$NON-NLS-1$ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
602 } |
24 | 603 font = Gdip.Font_new( StrToWCHARz(name), size, style, Gdip.UnitPixel, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
604 } |
24 | 605 if (font is null) DWT.error(DWT.ERROR_NO_HANDLES); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
606 return font; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
607 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
608 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
609 static void destroyGdipBrush(Gdip.Brush brush) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
610 int type = Gdip.Brush_GetType(brush); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
611 switch (type) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
612 case Gdip.BrushTypeSolidColor: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
613 Gdip.SolidBrush_delete( cast(Gdip.SolidBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
614 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
615 case Gdip.BrushTypeHatchFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
616 Gdip.HatchBrush_delete(cast(Gdip.HatchBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
617 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
618 case Gdip.BrushTypeLinearGradient: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
619 Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
620 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
621 case Gdip.BrushTypeTextureFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
622 Gdip.TextureBrush_delete(cast(Gdip.TextureBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
623 break; |
81 | 624 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
625 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
626 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
627 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
628 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
629 * Disposes of the operating system resources associated with |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
630 * the graphics context. Applications must dispose of all GCs |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
631 * which they allocate. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
632 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
633 * @exception DWTError <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
634 * <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
635 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
636 */ |
213 | 637 void destroy() { |
638 bool gdip = data.gdipGraphics !is null; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
639 disposeGdip(); |
213 | 640 if (gdip && (data.style & DWT.MIRRORED) !is 0) { |
641 OS.SetLayout(handle, OS.GetLayout(handle) | OS.LAYOUT_RTL); | |
642 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
643 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
644 /* Select stock pen and brush objects and free resources */ |
24 | 645 if (data.hPen !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
646 OS.SelectObject(handle, OS.GetStockObject(OS.NULL_PEN)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
647 OS.DeleteObject(data.hPen); |
24 | 648 data.hPen = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
649 } |
24 | 650 if (data.hBrush !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
651 OS.SelectObject(handle, OS.GetStockObject(OS.NULL_BRUSH)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
652 OS.DeleteObject(data.hBrush); |
24 | 653 data.hBrush = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
654 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
655 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
656 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
657 * Put back the original bitmap into the device context. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
658 * This will ensure that we have not left a bitmap |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
659 * selected in it when we delete the HDC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
660 */ |
24 | 661 auto hNullBitmap = data.hNullBitmap; |
662 if (hNullBitmap !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
663 OS.SelectObject(handle, hNullBitmap); |
24 | 664 data.hNullBitmap = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
665 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
666 Image image = data.image; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
667 if (image !is null) image.memGC = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
668 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
669 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
670 * Dispose the HDC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
671 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
672 if (drawable !is null) drawable.internal_dispose_GC(handle, data); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
673 drawable = null; |
24 | 674 handle = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
675 data.image = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
676 data.ps = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
677 data = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
678 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
679 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
680 void disposeGdip() { |
24 | 681 if (data.gdipPen !is null) Gdip.Pen_delete(data.gdipPen); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
682 if (data.gdipBgBrush !is null) destroyGdipBrush(cast(Gdip.Brush)data.gdipBgBrush); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
683 if (data.gdipFgBrush !is null) destroyGdipBrush(cast(Gdip.Brush)data.gdipFgBrush); |
24 | 684 if (data.gdipFont !is null) Gdip.Font_delete(data.gdipFont); |
685 if (data.gdipGraphics !is null) Gdip.Graphics_delete(data.gdipGraphics); | |
686 data.gdipGraphics = null; | |
687 data.gdipBrush = null; | |
688 data.gdipBgBrush = null; | |
689 data.gdipFgBrush = null; | |
690 data.gdipFont = null; | |
691 data.gdipPen = null; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
692 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
693 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
694 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
695 * Draws the outline of a circular or elliptical arc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
696 * within the specified rectangular area. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
697 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
698 * The resulting arc begins at <code>startAngle</code> and extends |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
699 * for <code>arcAngle</code> degrees, using the current color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
700 * Angles are interpreted such that 0 degrees is at the 3 o'clock |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
701 * position. A positive value indicates a counter-clockwise rotation |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
702 * while a negative value indicates a clockwise rotation. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
703 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
704 * The center of the arc is the center of the rectangle whose origin |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
705 * is (<code>x</code>, <code>y</code>) and whose size is specified by the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
706 * <code>width</code> and <code>height</code> arguments. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
707 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
708 * The resulting arc covers an area <code>width + 1</code> pixels wide |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
709 * by <code>height + 1</code> pixels tall. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
710 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
711 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
712 * @param x the x coordinate of the upper-left corner of the arc to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
713 * @param y the y coordinate of the upper-left corner of the arc to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
714 * @param width the width of the arc to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
715 * @param height the height of the arc to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
716 * @param startAngle the beginning angle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
717 * @param arcAngle the angular extent of the arc, relative to the start angle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
718 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
719 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
720 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
721 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
722 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
723 public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
24 | 724 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
725 checkGC(DRAW); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
726 if (width < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
727 x = x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
728 width = -width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
729 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
730 if (height < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
731 y = y + height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
732 height = -height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
733 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
734 if (width is 0 || height is 0 || arcAngle is 0) return; |
24 | 735 auto gdipGraphics = data.gdipGraphics; |
736 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
737 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
738 if (width is height) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
739 Gdip.Graphics_DrawArc(gdipGraphics, data.gdipPen, x, y, width, height, -startAngle, -arcAngle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
740 } else { |
24 | 741 auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); |
742 if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
743 auto matrix = Gdip.Matrix_new(width, 0, 0, height, x, y); | |
744 if (matrix is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
745 Gdip.GraphicsPath_AddArc(path, 0, 0, 1, 1, -startAngle, -arcAngle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
746 Gdip.GraphicsPath_Transform(path, matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
747 Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
748 Gdip.Matrix_delete(matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
749 Gdip.GraphicsPath_delete(path); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
750 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
751 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
752 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
753 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
754 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
755 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
756 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
757 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
758 * Feature in WinCE. The function Arc is not present in the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
759 * WinCE SDK. The fix is to emulate arc drawing by using |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
760 * Polyline. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
761 */ |
117 | 762 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
763 /* compute arc with a simple linear interpolation */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
764 if (arcAngle < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
765 startAngle += arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
766 arcAngle = -arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
767 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
768 if (arcAngle > 360) arcAngle = 360; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
769 int[] points = new int[(arcAngle + 1) * 2]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
770 int cteX = 2 * x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
771 int cteY = 2 * y + height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
772 int index = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
773 for (int i = 0; i <= arcAngle; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
774 points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
775 points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
776 } |
24 | 777 OS.Polyline(handle, cast(POINT*)points.ptr, points.length / 2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
778 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
779 int x1, y1, x2, y2,tmp; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
780 bool isNegative; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
781 if (arcAngle >= 360 || arcAngle <= -360) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
782 x1 = x2 = x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
783 y1 = y2 = y + height / 2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
784 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
785 isNegative = arcAngle < 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
786 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
787 arcAngle = arcAngle + startAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
788 if (isNegative) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
789 // swap angles |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
790 tmp = startAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
791 startAngle = arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
792 arcAngle = tmp; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
793 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
794 x1 = Compatibility.cos(startAngle, width) + x + width/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
795 y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
796 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
797 x2 = Compatibility.cos(arcAngle, width) + x + width/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
798 y2 = -1 * Compatibility.sin(arcAngle, height) + y + height/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
799 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
800 OS.Arc(handle, x, y, x + width + 1, y + height + 1, x1, y1, x2, y2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
801 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
802 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
803 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
804 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
805 * Draws a rectangle, based on the specified arguments, which has |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
806 * the appearance of the platform's <em>focus rectangle</em> if the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
807 * platform supports such a notion, and otherwise draws a simple |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
808 * rectangle in the receiver's foreground color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
809 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
810 * @param x the x coordinate of the rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
811 * @param y the y coordinate of the rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
812 * @param width the width of the rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
813 * @param height the height of the rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
814 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
815 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
816 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
817 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
818 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
819 * @see #drawRectangle(int, int, int, int) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
820 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
821 public void drawFocus (int x, int y, int width, int height) { |
24 | 822 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
823 if ((data.uiState & OS.UISF_HIDEFOCUS) !is 0) return; |
213 | 824 data.focusDrawn = true; |
24 | 825 HDC hdc = handle; |
826 int state = 0; | |
827 auto gdipGraphics = data.gdipGraphics; | |
828 if (gdipGraphics !is null) { | |
829 HRGN clipRgn; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
830 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); |
24 | 831 auto rgn = Gdip.Region_new(); |
832 if (rgn is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
833 Gdip.Graphics_GetClip(gdipGraphics, rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
834 if (!Gdip.Region_IsInfinite(rgn, gdipGraphics)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
835 clipRgn = Gdip.Region_GetHRGN(rgn, gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
836 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
837 Gdip.Region_delete(rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
838 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); |
24 | 839 float[6] lpXform; |
840 bool gotElements = false; | |
841 auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); | |
842 if (matrix is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
843 Gdip.Graphics_GetTransform(gdipGraphics, matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
844 if (!Gdip.Matrix_IsIdentity(matrix)) { |
24 | 845 gotElements = true; |
213 | 846 Gdip.Matrix_GetElements(matrix, lpXform.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
847 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
848 Gdip.Matrix_delete(matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
849 hdc = Gdip.Graphics_GetHDC(gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
850 state = OS.SaveDC(hdc); |
24 | 851 if (gotElements) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
852 OS.SetGraphicsMode(hdc, OS.GM_ADVANCED); |
24 | 853 OS.SetWorldTransform(hdc, cast(XFORM*)lpXform.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
854 } |
24 | 855 if (clipRgn !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
856 OS.SelectClipRgn(hdc, clipRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
857 OS.DeleteObject(clipRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
858 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
859 } |
213 | 860 OS.SetBkColor(hdc, 0xFFFFFF); |
861 OS.SetTextColor(hdc, 0x000000); | |
24 | 862 RECT rect; |
863 OS.SetRect(&rect, x, y, x + width, y + height); | |
864 OS.DrawFocusRect(hdc, &rect); | |
865 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
866 OS.RestoreDC(hdc, state); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
867 Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc); |
213 | 868 } else { |
869 data.state &= ~(BACKGROUND_TEXT | FOREGROUND_TEXT); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
870 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
871 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
872 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
873 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
874 * Draws the given image in the receiver at the specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
875 * coordinates. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
876 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
877 * @param image the image to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
878 * @param x the x coordinate of where to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
879 * @param y the y coordinate of where to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
880 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
881 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
882 * <li>ERROR_NULL_ARGUMENT - if the image is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
883 * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
884 * <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
885 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
886 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
887 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
888 * @exception DWTError <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
889 * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
890 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
891 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
892 public void drawImage(Image image, int x, int y) { |
24 | 893 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
894 if (image is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
895 if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
896 drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
897 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
898 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
899 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
900 * Copies a rectangular area from the source image into a (potentially |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
901 * different sized) rectangular area in the receiver. If the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
902 * and destination areas are of differing sizes, then the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
903 * area will be stretched or shrunk to fit the destination area |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
904 * as it is copied. The copy fails if any part of the source rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
905 * lies outside the bounds of the source image, or if any of the width |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
906 * or height arguments are negative. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
907 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
908 * @param image the source image |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
909 * @param srcX the x coordinate in the source image to copy from |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
910 * @param srcY the y coordinate in the source image to copy from |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
911 * @param srcWidth the width in pixels to copy from the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
912 * @param srcHeight the height in pixels to copy from the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
913 * @param destX the x coordinate in the destination to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
914 * @param destY the y coordinate in the destination to copy to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
915 * @param destWidth the width in pixels of the destination rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
916 * @param destHeight the height in pixels of the destination rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
917 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
918 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
919 * <li>ERROR_NULL_ARGUMENT - if the image is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
920 * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
921 * <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
922 * <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
923 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
924 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
925 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
926 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
927 * @exception DWTError <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
928 * <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
929 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
930 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
931 public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) { |
24 | 932 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
933 if (srcWidth is 0 || srcHeight is 0 || destWidth is 0 || destHeight is 0) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
934 if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
935 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
936 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
937 if (image is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
938 if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
939 drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
940 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
941 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
942 void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) { |
24 | 943 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
944 //TODO - cache bitmap |
213 | 945 int /*long*/ [] gdipImage = srcImage.createGdipImage(); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
946 auto img = cast(Gdip.Image) gdipImage[0]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
947 int imgWidth = Gdip.Image_GetWidth(img); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
948 int imgHeight = Gdip.Image_GetHeight(img); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
949 if (simple) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
950 srcWidth = destWidth = imgWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
951 srcHeight = destHeight = imgHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
952 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
953 if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
954 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
955 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
956 simple = srcX is 0 && srcY is 0 && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
957 srcWidth is destWidth && destWidth is imgWidth && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
958 srcHeight is destHeight && destHeight is imgHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
959 } |
24 | 960 Gdip.Rect rect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
961 rect.X = destX; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
962 rect.Y = destY; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
963 rect.Width = destWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
964 rect.Height = destHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
965 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
966 * Note that if the wrap mode is not WrapModeTileFlipXY, the scaled image |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
967 * is translucent around the borders. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
968 */ |
24 | 969 auto attrib = Gdip.ImageAttributes_new(); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
970 Gdip.ImageAttributes_SetWrapMode(attrib, Gdip.WrapModeTileFlipXY); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
971 if (data.alpha != 0xFF) { |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
972 |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
973 Gdip.ColorMatrix matrix = |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
974 { [ [1,0,0,0,0], |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
975 [0,1,0,0,0], |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
976 [0,0,1,0,0], |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
977 [0,0,0,data.alpha / cast(float)0xFF,0,], |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
978 [0,0,0,0,1] ] }; |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
979 /* |
24 | 980 float[] matrix = [ cast(float) |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
981 1,0,0,0,0, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
982 0,1,0,0,0, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
983 0,0,1,0,0, |
24 | 984 0,0,0,data.alpha / cast(float)0xFF,0, |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
985 0,0,0,0,1, |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
986 ];*/ |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
987 Gdip.ImageAttributes_SetColorMatrix(attrib, matrix, Gdip.ColorMatrixFlagsDefault, Gdip.ColorAdjustTypeBitmap); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
988 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
989 int gstate = 0; |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
990 if ((data.style & DWT.MIRRORED) != 0) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
991 gstate = Gdip.Graphics_Save(data.gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
992 Gdip.Graphics_ScaleTransform(data.gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
993 Gdip.Graphics_TranslateTransform(data.gdipGraphics, - 2 * destX - destWidth, 0, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
994 } |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
995 Gdip.Graphics_DrawImage(data.gdipGraphics, img, rect, srcX, srcY, srcWidth, srcHeight, Gdip.UnitPixel, attrib, null, null); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
996 if ((data.style & DWT.MIRRORED) != 0) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
997 Gdip.Graphics_Restore(data.gdipGraphics, gstate); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
998 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
999 Gdip.ImageAttributes_delete(attrib); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
1000 Gdip.Bitmap_delete( cast(Gdip.Bitmap) img); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
1001 if (gdipImage[1] != 0) { |
24 | 1002 auto hHeap = OS.GetProcessHeap (); |
1003 OS.HeapFree(hHeap, 0, cast(void*)gdipImage[1]); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1004 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1005 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1006 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1007 switch (srcImage.type) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1008 case DWT.BITMAP: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1009 drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1010 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1011 case DWT.ICON: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1012 drawIcon(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1013 break; |
81 | 1014 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1015 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1016 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1017 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1018 void drawIcon(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1019 int technology = OS.GetDeviceCaps(handle, OS.TECHNOLOGY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1020 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1021 bool drawIcon = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1022 int flags = OS.DI_NORMAL; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1023 int offsetX = 0, offsetY = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1024 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(5, 1)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1025 if ((OS.GetLayout(handle) & OS.LAYOUT_RTL) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1026 flags |= OS.DI_NOMIRROR; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1027 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1028 * Bug in Windows. For some reason, DrawIconEx() does not take |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1029 * into account the window origin when the DI_NOMIRROR and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1030 * LAYOUT_RTL are set. The fix is to set the window origin to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1031 * (0, 0) and offset the drawing ourselves. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1032 */ |
24 | 1033 POINT pt; |
1034 OS.GetWindowOrgEx(handle, &pt); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1035 offsetX = pt.x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1036 offsetY = pt.y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1037 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1038 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1039 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1040 drawIcon = (OS.GetLayout(handle) & OS.LAYOUT_RTL) is 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1041 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1042 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1043 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1044 /* Simple case: no stretching, entire icon */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1045 if (simple && technology !is OS.DT_RASPRINTER && drawIcon) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1046 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null); |
24 | 1047 OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, null, flags); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1048 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1049 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1050 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1051 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1052 /* Get the icon info */ |
24 | 1053 ICONINFO srcIconInfo; |
117 | 1054 static if (OS.IsWinCE) { |
24 | 1055 Image.GetIconInfo(srcImage, &srcIconInfo); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1056 } else { |
24 | 1057 OS.GetIconInfo(srcImage.handle, &srcIconInfo); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1058 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1059 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1060 /* Get the icon width and height */ |
24 | 1061 auto hBitmap = srcIconInfo.hbmColor; |
1062 if (hBitmap is null) hBitmap = srcIconInfo.hbmMask; | |
1063 BITMAP bm; | |
1064 OS.GetObject(hBitmap, BITMAP.sizeof, &bm); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1065 int iconWidth = bm.bmWidth, iconHeight = bm.bmHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1066 if (hBitmap is srcIconInfo.hbmMask) iconHeight /= 2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1067 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1068 if (simple) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1069 srcWidth = destWidth = iconWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1070 srcHeight = destHeight = iconHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1071 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1072 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1073 /* Draw the icon */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1074 bool failed = srcX + srcWidth > iconWidth || srcY + srcHeight > iconHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1075 if (!failed) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1076 simple = srcX is 0 && srcY is 0 && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1077 srcWidth is destWidth && srcHeight is destHeight && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1078 srcWidth is iconWidth && srcHeight is iconHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1079 if (!drawIcon) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1080 drawBitmapMask(srcImage, srcIconInfo.hbmColor, srcIconInfo.hbmMask, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, iconWidth, iconHeight, false); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1081 } else if (simple && technology !is OS.DT_RASPRINTER) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1082 /* Simple case: no stretching, entire icon */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1083 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null); |
24 | 1084 OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, null, flags); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1085 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1086 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1087 /* Create the icon info and HDC's */ |
24 | 1088 ICONINFO newIconInfo; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1089 newIconInfo.fIcon = true; |
24 | 1090 auto srcHdc = OS.CreateCompatibleDC(handle); |
1091 auto dstHdc = OS.CreateCompatibleDC(handle); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1092 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1093 /* Blt the color bitmap */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1094 int srcColorY = srcY; |
24 | 1095 auto srcColor = srcIconInfo.hbmColor; |
1096 if (srcColor is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1097 srcColor = srcIconInfo.hbmMask; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1098 srcColorY += iconHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1099 } |
24 | 1100 auto oldSrcBitmap = OS.SelectObject(srcHdc, srcColor); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1101 newIconInfo.hbmColor = OS.CreateCompatibleBitmap(srcHdc, destWidth, destHeight); |
24 | 1102 if (newIconInfo.hbmColor is null) DWT.error(DWT.ERROR_NO_HANDLES); |
1103 auto oldDestBitmap = OS.SelectObject(dstHdc, newIconInfo.hbmColor); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1104 bool stretch = !simple && (srcWidth !is destWidth || srcHeight !is destHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1105 if (stretch) { |
117 | 1106 static if (!OS.IsWinCE) OS.SetStretchBltMode(dstHdc, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1107 OS.StretchBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcColorY, srcWidth, srcHeight, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1108 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1109 OS.BitBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcColorY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1110 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1111 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1112 /* Blt the mask bitmap */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1113 OS.SelectObject(srcHdc, srcIconInfo.hbmMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1114 newIconInfo.hbmMask = OS.CreateBitmap(destWidth, destHeight, 1, 1, null); |
24 | 1115 if (newIconInfo.hbmMask is null) DWT.error(DWT.ERROR_NO_HANDLES); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1116 OS.SelectObject(dstHdc, newIconInfo.hbmMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1117 if (stretch) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1118 OS.StretchBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1119 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1120 OS.BitBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1121 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1122 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1123 if (technology is OS.DT_RASPRINTER) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1124 OS.SelectObject(srcHdc, newIconInfo.hbmColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1125 OS.SelectObject(dstHdc, newIconInfo.hbmMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1126 drawBitmapTransparentByClipping(srcHdc, dstHdc, 0, 0, destWidth, destHeight, destX, destY, destWidth, destHeight, true, destWidth, destHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1127 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1128 OS.SelectObject(dstHdc, oldDestBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1129 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1130 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1131 OS.SelectObject(dstHdc, oldDestBitmap); |
24 | 1132 auto hIcon = OS.CreateIconIndirect(&newIconInfo); |
1133 if (hIcon is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1134 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null); |
24 | 1135 OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, hIcon, destWidth, destHeight, 0, null, flags); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1136 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1137 OS.DestroyIcon(hIcon); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1138 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1139 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1140 /* Destroy the new icon src and mask and hdc's*/ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1141 OS.DeleteObject(newIconInfo.hbmMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1142 OS.DeleteObject(newIconInfo.hbmColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1143 OS.DeleteDC(dstHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1144 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1145 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1146 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1147 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1148 /* Free icon info */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1149 OS.DeleteObject(srcIconInfo.hbmMask); |
24 | 1150 if (srcIconInfo.hbmColor !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1151 OS.DeleteObject(srcIconInfo.hbmColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1152 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1153 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1154 if (failed) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1155 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1156 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1157 void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) { |
24 | 1158 BITMAP bm; |
1159 OS.GetObject(srcImage.handle, BITMAP.sizeof, &bm); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1160 int imgWidth = bm.bmWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1161 int imgHeight = bm.bmHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1162 if (simple) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1163 srcWidth = destWidth = imgWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1164 srcHeight = destHeight = imgHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1165 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1166 if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1167 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1168 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1169 simple = srcX is 0 && srcY is 0 && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1170 srcWidth is destWidth && destWidth is imgWidth && |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1171 srcHeight is destHeight && destHeight is imgHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1172 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1173 bool mustRestore = false; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1174 GC memGC = srcImage.memGC; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1175 if (memGC !is null && !memGC.isDisposed()) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1176 memGC.flush(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1177 mustRestore = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1178 GCData data = memGC.data; |
24 | 1179 if (data.hNullBitmap !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1180 OS.SelectObject(memGC.handle, data.hNullBitmap); |
24 | 1181 data.hNullBitmap = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1182 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1183 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1184 if (srcImage.alpha !is -1 || srcImage.alphaData !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1185 drawBitmapAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1186 } else if (srcImage.transparentPixel !is -1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1187 drawBitmapTransparent(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1188 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1189 drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1190 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1191 if (mustRestore) { |
24 | 1192 auto hOldBitmap = OS.SelectObject(memGC.handle, srcImage.handle); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1193 memGC.data.hNullBitmap = hOldBitmap; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1194 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1195 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1196 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1197 void drawBitmapAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, BITMAP bm, int imgWidth, int imgHeight) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1198 /* Simple cases */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1199 if (srcImage.alpha is 0) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1200 if (srcImage.alpha is 255) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1201 drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1202 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1203 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1204 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1205 if (OS.IsWinNT && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { |
24 | 1206 BLENDFUNCTION blend; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1207 blend.BlendOp = OS.AC_SRC_OVER; |
24 | 1208 auto srcHdc = OS.CreateCompatibleDC(handle); |
1209 auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1210 if (srcImage.alpha !is -1) { |
24 | 1211 blend.SourceConstantAlpha = cast(byte)srcImage.alpha; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1212 OS.AlphaBlend(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, blend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1213 } else { |
24 | 1214 auto memDib = Image.createDIB(srcWidth, srcHeight, 32); |
1215 if (memDib is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
1216 auto memHdc = OS.CreateCompatibleDC(handle); | |
1217 auto oldMemBitmap = OS.SelectObject(memHdc, memDib); | |
1218 BITMAP dibBM; | |
1219 OS.GetObject(memDib, BITMAP.sizeof, &dibBM); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1220 OS.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1221 byte[] srcData = new byte[dibBM.bmWidthBytes * dibBM.bmHeight]; |
24 | 1222 srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. srcData.length ]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1223 final int apinc = imgWidth - srcWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1224 int ap = srcY * imgWidth + srcX, sp = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1225 byte[] alphaData = srcImage.alphaData; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1226 for (int y = 0; y < srcHeight; ++y) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1227 for (int x = 0; x < srcWidth; ++x) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1228 int alpha = alphaData[ap++] & 0xff; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1229 int r = ((srcData[sp + 0] & 0xFF) * alpha) + 128; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1230 r = (r + (r >> 8)) >> 8; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1231 int g = ((srcData[sp + 1] & 0xFF) * alpha) + 128; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1232 g = (g + (g >> 8)) >> 8; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1233 int b = ((srcData[sp + 2] & 0xFF) * alpha) + 128; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1234 b = (b + (b >> 8)) >> 8; |
24 | 1235 srcData[sp+0] = cast(byte)r; |
1236 srcData[sp+1] = cast(byte)g; | |
1237 srcData[sp+2] = cast(byte)b; | |
1238 srcData[sp+3] = cast(byte)alpha; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1239 sp += 4; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1240 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1241 ap += apinc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1242 } |
24 | 1243 (cast(byte*)dibBM.bmBits)[ 0 .. srcData.length ] = srcData[]; |
1244 blend.SourceConstantAlpha = 0xff; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1245 blend.AlphaFormat = OS.AC_SRC_ALPHA; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1246 OS.AlphaBlend(handle, destX, destY, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, blend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1247 OS.SelectObject(memHdc, oldMemBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1248 OS.DeleteDC(memHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1249 OS.DeleteObject(memDib); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1250 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1251 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1252 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1253 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1254 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1255 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1256 /* Check clipping */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1257 Rectangle rect = getClipping(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1258 rect = rect.intersection(new Rectangle(destX, destY, destWidth, destHeight)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1259 if (rect.isEmpty()) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1260 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1261 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1262 * Optimization. Recalculate src and dest rectangles so that |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1263 * only the clipping area is drawn. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1264 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1265 int sx1 = srcX + (((rect.x - destX) * srcWidth) / destWidth); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1266 int sx2 = srcX + ((((rect.x + rect.width) - destX) * srcWidth) / destWidth); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1267 int sy1 = srcY + (((rect.y - destY) * srcHeight) / destHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1268 int sy2 = srcY + ((((rect.y + rect.height) - destY) * srcHeight) / destHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1269 destX = rect.x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1270 destY = rect.y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1271 destWidth = rect.width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1272 destHeight = rect.height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1273 srcX = sx1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1274 srcY = sy1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1275 srcWidth = Math.max(1, sx2 - sx1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1276 srcHeight = Math.max(1, sy2 - sy1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1277 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1278 /* Create resources */ |
24 | 1279 auto srcHdc = OS.CreateCompatibleDC(handle); |
1280 auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle); | |
1281 auto memHdc = OS.CreateCompatibleDC(handle); | |
1282 auto memDib = Image.createDIB(Math.max(srcWidth, destWidth), Math.max(srcHeight, destHeight), 32); | |
1283 if (memDib is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
1284 auto oldMemBitmap = OS.SelectObject(memHdc, memDib); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1285 |
24 | 1286 BITMAP dibBM; |
1287 OS.GetObject(memDib, BITMAP.sizeof, &dibBM); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1288 int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1289 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1290 /* Get the background pixels */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1291 OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1292 byte[] destData = new byte[sizeInBytes]; |
24 | 1293 destData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1294 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1295 /* Get the foreground pixels */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1296 OS.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1297 byte[] srcData = new byte[sizeInBytes]; |
24 | 1298 srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1299 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1300 /* Merge the alpha channel in place */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1301 int alpha = srcImage.alpha; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1302 final bool hasAlphaChannel = (srcImage.alpha is -1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1303 if (hasAlphaChannel) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1304 final int apinc = imgWidth - srcWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1305 final int spinc = dibBM.bmWidthBytes - srcWidth * 4; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1306 int ap = srcY * imgWidth + srcX, sp = 3; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1307 byte[] alphaData = srcImage.alphaData; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1308 for (int y = 0; y < srcHeight; ++y) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1309 for (int x = 0; x < srcWidth; ++x) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1310 srcData[sp] = alphaData[ap++]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1311 sp += 4; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1312 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1313 ap += apinc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1314 sp += spinc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1315 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1316 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1317 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1318 /* Scale the foreground pixels with alpha */ |
24 | 1319 (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ] = srcData[]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1320 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1321 * Bug in WinCE and Win98. StretchBlt does not correctly stretch when |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1322 * the source and destination HDCs are the same. The workaround is to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1323 * stretch to a temporary HDC and blit back into the original HDC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1324 * Note that on WinCE StretchBlt correctly compresses the image when the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1325 * source and destination HDCs are the same. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1326 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1327 if ((OS.IsWinCE && (destWidth > srcWidth || destHeight > srcHeight)) || (!OS.IsWinNT && !OS.IsWinCE)) { |
24 | 1328 auto tempHdc = OS.CreateCompatibleDC(handle); |
1329 auto tempDib = Image.createDIB(destWidth, destHeight, 32); | |
1330 if (tempDib is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
1331 auto oldTempBitmap = OS.SelectObject(tempHdc, tempDib); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1332 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
117 | 1333 static if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1334 OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1335 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1336 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1337 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1338 OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1339 OS.SelectObject(tempHdc, oldTempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1340 OS.DeleteObject(tempDib); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1341 OS.DeleteDC(tempHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1342 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1343 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
117 | 1344 static if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1345 OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1346 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1347 OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1348 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1349 } |
24 | 1350 srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1351 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1352 /* Compose the pixels */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1353 final int dpinc = dibBM.bmWidthBytes - destWidth * 4; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1354 int dp = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1355 for (int y = 0; y < destHeight; ++y) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1356 for (int x = 0; x < destWidth; ++x) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1357 if (hasAlphaChannel) alpha = srcData[dp + 3] & 0xff; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1358 destData[dp] += ((srcData[dp] & 0xff) - (destData[dp] & 0xff)) * alpha / 255; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1359 destData[dp + 1] += ((srcData[dp + 1] & 0xff) - (destData[dp + 1] & 0xff)) * alpha / 255; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1360 destData[dp + 2] += ((srcData[dp + 2] & 0xff) - (destData[dp + 2] & 0xff)) * alpha / 255; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1361 dp += 4; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1362 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1363 dp += dpinc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1364 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1365 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1366 /* Draw the composed pixels */ |
24 | 1367 (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ] = destData[]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1368 OS.BitBlt(handle, destX, destY, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1369 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1370 /* Free resources */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1371 OS.SelectObject(memHdc, oldMemBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1372 OS.DeleteDC(memHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1373 OS.DeleteObject(memDib); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1374 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1375 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1376 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1377 |
24 | 1378 void drawBitmapTransparentByClipping(HDC srcHdc, HDC maskHdc, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1379 /* Create a clipping region from the mask */ |
24 | 1380 auto rgn = OS.CreateRectRgn(0, 0, 0, 0); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1381 for (int y=0; y<imgHeight; y++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1382 for (int x=0; x<imgWidth; x++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1383 if (OS.GetPixel(maskHdc, x, y) is 0) { |
24 | 1384 auto tempRgn = OS.CreateRectRgn(x, y, x+1, y+1); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1385 OS.CombineRgn(rgn, rgn, tempRgn, OS.RGN_OR); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1386 OS.DeleteObject(tempRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1387 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1388 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1389 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1390 /* Stretch the clipping mask if needed */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1391 if (destWidth !is srcWidth || destHeight !is srcHeight) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1392 int nBytes = OS.GetRegionData (rgn, 0, null); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1393 int[] lpRgnData = new int[nBytes / 4]; |
24 | 1394 OS.GetRegionData (rgn, nBytes, cast(RGNDATA*)lpRgnData.ptr); |
1395 float[6] lpXform; | |
1396 lpXform[] = 0.0f; | |
1397 lpXform[0] = cast(float)destWidth/srcWidth; | |
1398 lpXform[3] = cast(float)destHeight/srcHeight; | |
1399 auto tmpRgn = OS.ExtCreateRegion(cast(XFORM*)lpXform.ptr, nBytes, cast(RGNDATA*)lpRgnData.ptr); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1400 OS.DeleteObject(rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1401 rgn = tmpRgn; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1402 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1403 OS.OffsetRgn(rgn, destX, destY); |
24 | 1404 auto clip = OS.CreateRectRgn(0, 0, 0, 0); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1405 int result = OS.GetClipRgn(handle, clip); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1406 if (result is 1) OS.CombineRgn(rgn, rgn, clip, OS.RGN_AND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1407 OS.SelectClipRgn(handle, rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1408 int rop2 = 0; |
117 | 1409 static if (!OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1410 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1411 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1412 rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1413 OS.SetROP2 (handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1414 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1415 int dwRop = rop2 is OS.R2_XORPEN ? OS.SRCINVERT : OS.SRCCOPY; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1416 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1417 int mode = 0; |
117 | 1418 static if (!OS.IsWinCE) mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1419 OS.StretchBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, dwRop); |
117 | 1420 static if (!OS.IsWinCE) OS.SetStretchBltMode(handle, mode); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1421 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1422 OS.BitBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, dwRop); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1423 } |
24 | 1424 OS.SelectClipRgn(handle, result is 1 ? clip : null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1425 OS.DeleteObject(clip); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1426 OS.DeleteObject(rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1427 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1428 |
24 | 1429 void drawBitmapMask(Image srcImage, HBITMAP srcColor, HBITMAP srcMask, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight, bool offscreen) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1430 int srcColorY = srcY; |
24 | 1431 if (srcColor is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1432 srcColor = srcMask; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1433 srcColorY += imgHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1434 } |
24 | 1435 auto srcHdc = OS.CreateCompatibleDC(handle); |
1436 auto oldSrcBitmap = OS.SelectObject(srcHdc, srcColor); | |
213 | 1437 auto destHdc = handle; |
1438 int x = destX, y = destY; | |
24 | 1439 HDC tempHdc; |
1440 HBITMAP tempBitmap; | |
1441 HBITMAP oldTempBitmap; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1442 int oldBkColor = 0, oldTextColor = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1443 if (offscreen) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1444 tempHdc = OS.CreateCompatibleDC(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1445 tempBitmap = OS.CreateCompatibleBitmap(handle, destWidth, destHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1446 oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1447 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1448 destHdc = tempHdc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1449 x = y = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1450 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1451 oldBkColor = OS.SetBkColor(handle, 0xFFFFFF); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1452 oldTextColor = OS.SetTextColor(handle, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1453 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1454 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1455 int mode = 0; |
117 | 1456 static if (!OS.IsWinCE) mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1457 OS.StretchBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcColorY, srcWidth, srcHeight, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1458 OS.SelectObject(srcHdc, srcMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1459 OS.StretchBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCAND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1460 OS.SelectObject(srcHdc, srcColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1461 OS.StretchBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcColorY, srcWidth, srcHeight, OS.SRCINVERT); |
117 | 1462 static if (!OS.IsWinCE) OS.SetStretchBltMode(handle, mode); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1463 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1464 OS.BitBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcColorY, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1465 OS.SetTextColor(destHdc, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1466 OS.SelectObject(srcHdc, srcMask); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1467 OS.BitBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcY, OS.SRCAND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1468 OS.SelectObject(srcHdc, srcColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1469 OS.BitBlt(destHdc, x, y, destWidth, destHeight, srcHdc, srcX, srcColorY, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1470 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1471 if (offscreen) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1472 OS.BitBlt(handle, destX, destY, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1473 OS.SelectObject(tempHdc, oldTempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1474 OS.DeleteDC(tempHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1475 OS.DeleteObject(tempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1476 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1477 OS.SetBkColor(handle, oldBkColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1478 OS.SetTextColor(handle, oldTextColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1479 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1480 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1481 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1482 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1483 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1484 void drawBitmapTransparent(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, BITMAP bm, int imgWidth, int imgHeight) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1485 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1486 /* Find the RGB values for the transparent pixel. */ |
249 | 1487 bool isDib = bm.bmBits !is null; |
24 | 1488 auto hBitmap = srcImage.handle; |
1489 auto srcHdc = OS.CreateCompatibleDC(handle); | |
1490 auto oldSrcBitmap = OS.SelectObject(srcHdc, hBitmap); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1491 byte[] originalColors = null; |
246 | 1492 int transparentColor = srcImage.transparentColor; |
1493 if (transparentColor is -1) { | |
1494 int transBlue = 0, transGreen = 0, transRed = 0; | |
1495 bool fixPalette = false; | |
1496 if (bm.bmBitsPixel <= 8) { | |
1497 if (isDib) { | |
1498 /* Palette-based DIBSECTION */ | |
1499 static if (OS.IsWinCE) { | |
1500 byte* pBits = cast(byte*)bm.bmBits; | |
1501 //OS.MoveMemory(pBits, bm.bmBits, 1); | |
1502 byte oldValue = pBits[0]; | |
1503 int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF; | |
1504 pBits[0] = cast(byte)((srcImage.transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask)); | |
1505 //OS.MoveMemory(bm.bmBits, pBits, 1); | |
1506 int color = OS.GetPixel(srcHdc, 0, 0); | |
1507 pBits[0] = oldValue; | |
1508 //OS.MoveMemory(bm.bmBits, pBits, 1); | |
1509 transBlue = (color & 0xFF0000) >> 16; | |
1510 transGreen = (color & 0xFF00) >> 8; | |
1511 transRed = color & 0xFF; | |
1512 } else { | |
1513 int maxColors = 1 << bm.bmBitsPixel; | |
1514 byte[] oldColors = new byte[maxColors * 4]; | |
1515 OS.GetDIBColorTable(srcHdc, 0, maxColors, cast(RGBQUAD*)oldColors.ptr); | |
1516 int offset = srcImage.transparentPixel * 4; | |
1517 for (int i = 0; i < oldColors.length; i += 4) { | |
1518 if (i !is offset) { | |
1519 if (oldColors[offset] is oldColors[i] && oldColors[offset+1] is oldColors[i+1] && oldColors[offset+2] is oldColors[i+2]) { | |
1520 fixPalette = true; | |
1521 break; | |
1522 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1523 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1524 } |
246 | 1525 if (fixPalette) { |
1526 byte[] newColors = new byte[oldColors.length]; | |
1527 transRed = transGreen = transBlue = 0xff; | |
1528 newColors[offset] = cast(byte)transBlue; | |
1529 newColors[offset+1] = cast(byte)transGreen; | |
1530 newColors[offset+2] = cast(byte)transRed; | |
1531 OS.SetDIBColorTable(srcHdc, 0, maxColors, cast(RGBQUAD*)newColors.ptr); | |
1532 originalColors = oldColors; | |
1533 } else { | |
1534 transBlue = oldColors[offset] & 0xFF; | |
1535 transGreen = oldColors[offset+1] & 0xFF; | |
1536 transRed = oldColors[offset+2] & 0xFF; | |
1537 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1538 } |
246 | 1539 } else { |
1540 /* Palette-based bitmap */ | |
1541 int numColors = 1 << bm.bmBitsPixel; | |
1542 /* Set the few fields necessary to get the RGB data out */ | |
1543 BITMAPINFOHEADER bmiHeader; | |
1544 bmiHeader.biSize = BITMAPINFOHEADER.sizeof; | |
1545 bmiHeader.biPlanes = bm.bmPlanes; | |
1546 bmiHeader.biBitCount = bm.bmBitsPixel; | |
1547 byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4]; | |
1548 bmi[] = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof ]; | |
1549 static if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); | |
1550 OS.GetDIBits(srcHdc, srcImage.handle, 0, 0, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); | |
1551 int offset = BITMAPINFOHEADER.sizeof + 4 * srcImage.transparentPixel; | |
1552 transRed = bmi[offset + 2] & 0xFF; | |
1553 transGreen = bmi[offset + 1] & 0xFF; | |
1554 transBlue = bmi[offset] & 0xFF; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1555 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1556 } else { |
246 | 1557 /* Direct color image */ |
1558 int pixel = srcImage.transparentPixel; | |
1559 switch (bm.bmBitsPixel) { | |
1560 case 16: | |
1561 transBlue = (pixel & 0x1F) << 3; | |
1562 transGreen = (pixel & 0x3E0) >> 2; | |
1563 transRed = (pixel & 0x7C00) >> 7; | |
1564 break; | |
1565 case 24: | |
1566 transBlue = (pixel & 0xFF0000) >> 16; | |
1567 transGreen = (pixel & 0xFF00) >> 8; | |
1568 transRed = pixel & 0xFF; | |
1569 break; | |
1570 case 32: | |
1571 transBlue = (pixel & 0xFF000000) >>> 24; | |
1572 transGreen = (pixel & 0xFF0000) >> 16; | |
1573 transRed = (pixel & 0xFF00) >> 8; | |
1574 break; | |
1575 default: | |
1576 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1577 } |
246 | 1578 transparentColor = transBlue << 16 | transGreen << 8 | transRed; |
1579 if (!fixPalette) srcImage.transparentColor = transparentColor; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1580 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1581 |
25 | 1582 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1583 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1584 * Note in WinCE. TransparentImage uses the first entry of a palette |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1585 * based image when there are multiple entries that have the same |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1586 * transparent color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1587 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1588 OS.TransparentImage(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, transparentColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1589 } else if (originalColors is null && OS.IsWinNT && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1590 int mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1591 OS.TransparentBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, transparentColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1592 OS.SetStretchBltMode(handle, mode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1593 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1594 /* Create the mask for the source image */ |
24 | 1595 auto maskHdc = OS.CreateCompatibleDC(handle); |
1596 auto maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null); | |
1597 auto oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1598 OS.SetBkColor(srcHdc, transparentColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1599 OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY); |
25 | 1600 if (originalColors !is null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, cast(RGBQUAD*)originalColors.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1601 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1602 if (OS.GetDeviceCaps(handle, OS.TECHNOLOGY) is OS.DT_RASPRINTER) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1603 /* Most printers do not support BitBlt(), draw the source bitmap transparently using clipping */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1604 drawBitmapTransparentByClipping(srcHdc, maskHdc, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1605 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1606 /* Draw the source bitmap transparently using invert/and mask/invert */ |
24 | 1607 auto tempHdc = OS.CreateCompatibleDC(handle); |
1608 auto tempBitmap = OS.CreateCompatibleBitmap(handle, destWidth, destHeight); | |
1609 auto oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1610 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1611 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
117 | 1612 static if (!OS.IsWinCE) OS.SetStretchBltMode(tempHdc, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1613 OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1614 OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, maskHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCAND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1615 OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1616 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1617 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1618 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, maskHdc, srcX, srcY, OS.SRCAND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1619 OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1620 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1621 OS.BitBlt(handle, destX, destY, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1622 OS.SelectObject(tempHdc, oldTempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1623 OS.DeleteDC(tempHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1624 OS.DeleteObject(tempBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1625 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1626 OS.SelectObject(maskHdc, oldMaskBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1627 OS.DeleteDC(maskHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1628 OS.DeleteObject(maskBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1629 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1630 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1631 if (hBitmap !is srcImage.handle) OS.DeleteObject(hBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1632 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1633 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1634 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1635 void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, BITMAP bm, int imgWidth, int imgHeight) { |
24 | 1636 auto srcHdc = OS.CreateCompatibleDC(handle); |
1637 auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1638 int rop2 = 0; |
117 | 1639 static if (!OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1640 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1641 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1642 rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1643 OS.SetROP2 (handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1644 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1645 int dwRop = rop2 is OS.R2_XORPEN ? OS.SRCINVERT : OS.SRCCOPY; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1646 if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1647 int mode = 0; |
117 | 1648 static if (!OS.IsWinCE) mode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1649 OS.StretchBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, dwRop); |
117 | 1650 static if (!OS.IsWinCE) OS.SetStretchBltMode(handle, mode); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1651 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1652 OS.BitBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, dwRop); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1653 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1654 OS.SelectObject(srcHdc, oldSrcBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1655 OS.DeleteDC(srcHdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1656 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1657 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1658 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1659 * Draws a line, using the foreground color, between the points |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1660 * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1661 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1662 * @param x1 the first point's x coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1663 * @param y1 the first point's y coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1664 * @param x2 the second point's x coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1665 * @param y2 the second point's y coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1666 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1667 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1668 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1669 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1670 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1671 public void drawLine (int x1, int y1, int x2, int y2) { |
24 | 1672 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1673 checkGC(DRAW); |
24 | 1674 auto gdipGraphics = data.gdipGraphics; |
1675 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1676 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1677 Gdip.Graphics_DrawLine(gdipGraphics, data.gdipPen, x1, y1, x2, y2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1678 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1679 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1680 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1681 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1682 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1683 x1--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1684 x2--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1685 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1686 } |
117 | 1687 static if (OS.IsWinCE) { |
220
f54496748313
Fix foreground color in GC on non-gdip platforms
Frank Benoit <benoit@tionex.de>
parents:
215
diff
changeset
|
1688 int [4] points; points[0] = x1; points[1] = y1; points[2] = x2; points[3] = y2; |
25 | 1689 OS.Polyline (handle, cast(POINT*)points.ptr, points.length / 2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1690 } else { |
25 | 1691 OS.MoveToEx (handle, x1, y1, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1692 OS.LineTo (handle, x2, y2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1693 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1694 if (data.lineWidth <= 1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1695 OS.SetPixel (handle, x2, y2, data.foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1696 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1697 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1698 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1699 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1700 * Draws the outline of an oval, using the foreground color, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1701 * within the specified rectangular area. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1702 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1703 * The result is a circle or ellipse that fits within the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1704 * rectangle specified by the <code>x</code>, <code>y</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1705 * <code>width</code>, and <code>height</code> arguments. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1706 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1707 * The oval covers an area that is <code>width + 1</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1708 * pixels wide and <code>height + 1</code> pixels tall. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1709 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1710 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1711 * @param x the x coordinate of the upper left corner of the oval to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1712 * @param y the y coordinate of the upper left corner of the oval to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1713 * @param width the width of the oval to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1714 * @param height the height of the oval to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1715 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1716 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1717 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1718 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1719 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1720 public void drawOval (int x, int y, int width, int height) { |
24 | 1721 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1722 checkGC(DRAW); |
24 | 1723 auto gdipGraphics = data.gdipGraphics; |
1724 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1725 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1726 Gdip.Graphics_DrawEllipse(gdipGraphics, data.gdipPen, x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1727 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1728 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1729 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1730 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1731 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1732 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1733 OS.Ellipse(handle, x, y, x + width + 1, y + height + 1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1734 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1735 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1736 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1737 * Draws the path described by the parameter. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1738 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1739 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1740 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1741 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1742 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1743 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1744 * @param path the path to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1745 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1746 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1747 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1748 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1749 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1750 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1751 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1752 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1753 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1754 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1755 * @see Path |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1756 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1757 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1758 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1759 public void drawPath (Path path) { |
24 | 1760 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1761 if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
24 | 1762 if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1763 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1764 checkGC(DRAW); |
24 | 1765 auto gdipGraphics = data.gdipGraphics; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1766 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1767 Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path.handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1768 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1769 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1770 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1771 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1772 * Draws a pixel, using the foreground color, at the specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1773 * point (<code>x</code>, <code>y</code>). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1774 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1775 * Note that the receiver's line attributes do not affect this |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1776 * operation. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1777 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1778 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1779 * @param x the point's x coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1780 * @param y the point's y coordinate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1781 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1782 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1783 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1784 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1785 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1786 * @since 3.0 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1787 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1788 public void drawPoint (int x, int y) { |
24 | 1789 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
1790 if (data.gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1791 checkGC(DRAW); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1792 Gdip.Graphics_FillRectangle(data.gdipGraphics, getFgBrush(), x, y, 1, 1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1793 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1794 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1795 OS.SetPixel (handle, x, y, data.foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1796 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1797 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1798 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1799 * Draws the closed polygon which is defined by the specified array |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1800 * of integer coordinates, using the receiver's foreground color. The array |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1801 * contains alternating x and y values which are considered to represent |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1802 * points which are the vertices of the polygon. Lines are drawn between |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1803 * each consecutive pair, and between the first pair and last pair in the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1804 * array. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1805 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1806 * @param pointArray an array of alternating x and y values which are the vertices of the polygon |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1807 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1808 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1809 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1810 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1811 */ |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
1812 public void drawPolygon( int[] pointArray) { |
24 | 1813 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
1814 // DWT extension: allow null array |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
1815 //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1816 checkGC(DRAW); |
24 | 1817 auto gdipGraphics = data.gdipGraphics; |
1818 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1819 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
213 | 1820 Gdip.Graphics_DrawPolygon(gdipGraphics, data.gdipPen, cast(Gdip.Point*)pointArray.ptr, pointArray.length/2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1821 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1822 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1823 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1824 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1825 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1826 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1827 pointArray[i]--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1828 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1829 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1830 } |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
1831 OS.Polygon(handle, cast(POINT*)pointArray.ptr, pointArray.length/2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1832 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1833 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1834 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1835 pointArray[i]++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1836 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1837 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1838 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1839 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1840 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1841 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1842 * Draws the polyline which is defined by the specified array |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1843 * of integer coordinates, using the receiver's foreground color. The array |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1844 * contains alternating x and y values which are considered to represent |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1845 * points which are the corners of the polyline. Lines are drawn between |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1846 * each consecutive pair, but not between the first pair and last pair in |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1847 * the array. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1848 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1849 * @param pointArray an array of alternating x and y values which are the corners of the polyline |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1850 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1851 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1852 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1853 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1854 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1855 public void drawPolyline(int[] pointArray) { |
24 | 1856 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
1857 // DWT externsion: allow null array |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
1858 //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1859 checkGC(DRAW); |
24 | 1860 auto gdipGraphics = data.gdipGraphics; |
1861 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1862 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
213 | 1863 Gdip.Graphics_DrawLines(gdipGraphics, data.gdipPen, cast(Gdip.Point*)pointArray.ptr, pointArray.length / 2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1864 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1865 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1866 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1867 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1868 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1869 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1870 pointArray[i]--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1871 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1872 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1873 } |
25 | 1874 OS.Polyline(handle, cast(POINT*)pointArray.ptr, pointArray.length / 2); |
24 | 1875 int length_ = pointArray.length; |
1876 if (length_ >= 2) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1877 if (data.lineWidth <= 1) { |
24 | 1878 OS.SetPixel (handle, pointArray[length_ - 2], pointArray[length_ - 1], data.foreground); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1879 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1880 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1881 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1882 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1883 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1884 pointArray[i]++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1885 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1886 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1887 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1888 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1889 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1890 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1891 * Draws the outline of the rectangle specified by the arguments, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1892 * using the receiver's foreground color. The left and right edges |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1893 * of the rectangle are at <code>x</code> and <code>x + width</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1894 * The top and bottom edges are at <code>y</code> and <code>y + height</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1895 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1896 * @param x the x coordinate of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1897 * @param y the y coordinate of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1898 * @param width the width of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1899 * @param height the height of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1900 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1901 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1902 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1903 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1904 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1905 public void drawRectangle (int x, int y, int width, int height) { |
24 | 1906 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1907 checkGC(DRAW); |
24 | 1908 auto gdipGraphics = data.gdipGraphics; |
1909 if (gdipGraphics !is null) { | |
213 | 1910 if (width < 0) { |
1911 x = x + width; | |
1912 width = -width; | |
1913 } | |
1914 if (height < 0) { | |
1915 y = y + height; | |
1916 height = -height; | |
1917 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1918 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1919 Gdip.Graphics_DrawRectangle(gdipGraphics, data.gdipPen, x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1920 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1921 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1922 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1923 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1924 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1925 * Note that Rectangle() subtracts one pixel in MIRRORED mode when |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1926 * the pen was created with CreatePen() and its width is 0 or 1. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1927 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1928 if (data.lineWidth > 1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1929 if ((data.lineWidth % 2) is 1) x++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1930 } else { |
25 | 1931 if (data.hPen !is null && OS.GetObject(data.hPen, 0, null) !is LOGPEN.sizeof) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1932 x++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1933 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1934 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1935 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1936 OS.Rectangle (handle, x, y, x + width + 1, y + height + 1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1937 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1938 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1939 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1940 * Draws the outline of the specified rectangle, using the receiver's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1941 * foreground color. The left and right edges of the rectangle are at |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1942 * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1943 * and bottom edges are at <code>rect.y</code> and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1944 * <code>rect.y + rect.height</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1945 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1946 * @param rect the rectangle to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1947 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1948 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1949 * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1950 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1951 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1952 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1953 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1954 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1955 public void drawRectangle (Rectangle rect) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1956 if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1957 drawRectangle (rect.x, rect.y, rect.width, rect.height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1958 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1959 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1960 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1961 * Draws the outline of the round-cornered rectangle specified by |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1962 * the arguments, using the receiver's foreground color. The left and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1963 * right edges of the rectangle are at <code>x</code> and <code>x + width</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1964 * The top and bottom edges are at <code>y</code> and <code>y + height</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1965 * The <em>roundness</em> of the corners is specified by the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1966 * <code>arcWidth</code> and <code>arcHeight</code> arguments, which |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1967 * are respectively the width and height of the ellipse used to draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1968 * the corners. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1969 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1970 * @param x the x coordinate of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1971 * @param y the y coordinate of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1972 * @param width the width of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1973 * @param height the height of the rectangle to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1974 * @param arcWidth the width of the arc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1975 * @param arcHeight the height of the arc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1976 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1977 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1978 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1979 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1980 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1981 public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
24 | 1982 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1983 checkGC(DRAW); |
24 | 1984 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1985 drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1986 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1987 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1988 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1989 if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1990 } |
117 | 1991 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1992 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1993 * Bug in WinCE PPC. On certain devices, RoundRect does not draw |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1994 * all the pixels. The workaround is to draw a round rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1995 * using lines and arcs. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1996 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1997 if (width is 0 || height is 0) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1998 if (arcWidth is 0 || arcHeight is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
1999 drawRectangle(x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2000 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2001 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2002 if (width < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2003 x += width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2004 width = -width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2005 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2006 if (height < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2007 y += height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2008 height = -height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2009 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2010 if (arcWidth < 0) arcWidth = -arcWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2011 if (arcHeight < 0) arcHeight = -arcHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2012 if (arcWidth > width) arcWidth = width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2013 if (arcHeight > height) arcHeight = height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2014 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2015 if (arcWidth < width) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2016 drawLine(x+arcWidth/2, y, x+width-arcWidth/2, y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2017 drawLine(x+arcWidth/2, y+height, x+width-arcWidth/2, y+height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2018 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2019 if (arcHeight < height) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2020 drawLine(x, y+arcHeight/2, x, y+height-arcHeight/2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2021 drawLine(x+width, y+arcHeight/2, x+width, y+height-arcHeight/2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2022 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2023 if (arcWidth !is 0 && arcHeight !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2024 drawArc(x, y, arcWidth, arcHeight, 90, 90); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2025 drawArc(x+width-arcWidth, y, arcWidth, arcHeight, 0, 90); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2026 drawArc(x+width-arcWidth, y+height-arcHeight, arcWidth, arcHeight, 0, -90); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2027 drawArc(x, y+height-arcHeight, arcWidth, arcHeight, 180, 90); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2028 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2029 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2030 OS.RoundRect(handle, x,y,x+width+1,y+height+1, arcWidth, arcHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2031 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2032 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2033 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2034 void drawRoundRectangleGdip (Gdip.Graphics gdipGraphics, Gdip.Pen pen, int x, int y, int width, int height, int arcWidth, int arcHeight) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2035 int nx = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2036 int ny = y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2037 int nw = width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2038 int nh = height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2039 int naw = arcWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2040 int nah = arcHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2041 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2042 if (nw < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2043 nw = 0 - nw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2044 nx = nx - nw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2045 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2046 if (nh < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2047 nh = 0 - nh; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2048 ny = ny - nh; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2049 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2050 if (naw < 0) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2051 naw = 0 - naw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2052 if (nah < 0) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2053 nah = 0 - nah; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2054 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2055 Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); |
213 | 2056 if (naw is 0 || nah is 0) { |
2057 Gdip.Graphics_DrawRectangle(gdipGraphics, data.gdipPen, x, y, width, height); | |
2058 } else { | |
2059 auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); | |
2060 if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
2061 if (nw > naw) { | |
2062 if (nh > nah) { | |
2063 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nah, 0, -90); | |
2064 Gdip.GraphicsPath_AddArc(path, nx, ny, naw, nah, -90, -90); | |
2065 Gdip.GraphicsPath_AddArc(path, nx, ny + nh - nah, naw, nah, -180, -90); | |
2066 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny + nh - nah, naw, nah, -270, -90); | |
2067 } else { | |
2068 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nh, -270, -180); | |
2069 Gdip.GraphicsPath_AddArc(path, nx, ny, naw, nh, -90, -180); | |
2070 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2071 } else { |
213 | 2072 if (nh > nah) { |
2073 Gdip.GraphicsPath_AddArc(path, nx, ny, nw, nah, 0, -180); | |
2074 Gdip.GraphicsPath_AddArc(path, nx, ny + nh - nah, nw, nah, -180, -180); | |
2075 } else { | |
2076 Gdip.GraphicsPath_AddArc(path, nx, ny, nw, nh, 0, 360); | |
2077 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2078 } |
213 | 2079 Gdip.GraphicsPath_CloseFigure(path); |
2080 Gdip.Graphics_DrawPath(gdipGraphics, pen, path); | |
2081 Gdip.GraphicsPath_delete(path); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2082 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2083 Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2084 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2085 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2086 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2087 * Draws the given string, using the receiver's current font and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2088 * foreground color. No tab expansion or carriage return processing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2089 * will be performed. The background of the rectangular area where |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2090 * the string is being drawn will be filled with the receiver's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2091 * background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2092 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2093 * @param string the string to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2094 * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2095 * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2096 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2097 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2098 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2099 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2100 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
2101 public void drawString (String string, int x, int y) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2102 drawString(string, x, y, false); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2103 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2104 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2105 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2106 * Draws the given string, using the receiver's current font and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2107 * foreground color. No tab expansion or carriage return processing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2108 * will be performed. If <code>isTransparent</code> is <code>true</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2109 * then the background of the rectangular area where the string is being |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2110 * drawn will not be modified, otherwise it will be filled with the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2111 * receiver's background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2112 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2113 * @param string the string to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2114 * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2115 * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2116 * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2117 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2118 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2119 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2120 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2121 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
2122 public void drawString (String string, int x, int y, bool isTransparent) { |
24 | 2123 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2124 // DWT extension: allow null string |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2125 //if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2126 // TCHAR buffer = new TCHAR (getCodePage(), string, false); |
25 | 2127 wchar[] wstr = StrToWCHARs( string ); |
2128 int length_ = wstr.length; | |
24 | 2129 if (length_ is 0) return; |
25 | 2130 wchar* buffer = wstr.ptr; |
24 | 2131 auto gdipGraphics = data.gdipGraphics; |
2132 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2133 checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND)); |
25 | 2134 Gdip.PointF pt; |
2135 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2136 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2137 if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2138 Gdip.StringFormat_SetFormatFlags(format, formatFlags); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2139 if (!isTransparent) { |
25 | 2140 Gdip.RectF bounds; |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2141 Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); |
25 | 2142 Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.rndint(bounds.Width), Math.rndint(bounds.Height)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2143 } |
25 | 2144 int gstate = 0; |
2145 auto brush = getFgBrush(); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2146 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2147 switch (Gdip.Brush_GetType(brush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2148 case Gdip.BrushTypeLinearGradient: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2149 Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2150 Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2151 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2152 case Gdip.BrushTypeTextureFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2153 Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2154 Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2155 break; |
81 | 2156 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2157 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2158 gstate = Gdip.Graphics_Save(gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2159 Gdip.Graphics_ScaleTransform(gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2160 Gdip.Graphics_TranslateTransform(gdipGraphics, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2161 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2162 pt.X = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2163 pt.Y = y; |
24 | 2164 Gdip.Graphics_DrawString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2165 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2166 switch (Gdip.Brush_GetType(brush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2167 case Gdip.BrushTypeLinearGradient: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2168 Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2169 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2170 case Gdip.BrushTypeTextureFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2171 Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2172 break; |
81 | 2173 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2174 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2175 Gdip.Graphics_Restore(gdipGraphics, gstate); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2176 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2177 Gdip.StringFormat_delete(format); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2178 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2179 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2180 int rop2 = 0; |
117 | 2181 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2182 rop2 = OS.SetROP2(handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2183 OS.SetROP2(handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2184 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2185 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2186 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2187 checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2188 int oldBkMode = OS.SetBkMode(handle, isTransparent ? OS.TRANSPARENT : OS.OPAQUE); |
25 | 2189 RECT rect; |
2190 SIZE size; | |
2191 bool sizeValid = false; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2192 int flags = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2193 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2194 if (!isTransparent) { |
25 | 2195 sizeValid = true; |
2196 OS.GetTextExtentPoint32W(handle, buffer, length_, &size); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2197 rect.left = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2198 rect.right = x + size.cx; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2199 rect.top = y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2200 rect.bottom = y + size.cy; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2201 flags = OS.ETO_CLIPPED; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2202 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2203 x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2204 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2205 if (rop2 !is OS.R2_XORPEN) { |
25 | 2206 OS.ExtTextOutW(handle, x, y, flags, &rect, buffer, length_, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2207 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2208 int foreground = OS.GetTextColor(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2209 if (isTransparent) { |
25 | 2210 if (!sizeValid) { |
2211 OS.GetTextExtentPoint32W(handle, buffer, length_, &size); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2212 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2213 int width = size.cx, height = size.cy; |
25 | 2214 auto hBitmap = OS.CreateCompatibleBitmap(handle, width, height); |
24 | 2215 if (hBitmap is null) DWT.error(DWT.ERROR_NO_HANDLES); |
25 | 2216 auto memDC = OS.CreateCompatibleDC(handle); |
2217 auto hOldBitmap = OS.SelectObject(memDC, hBitmap); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2218 OS.PatBlt(memDC, 0, 0, width, height, OS.BLACKNESS); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2219 OS.SetBkMode(memDC, OS.TRANSPARENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2220 OS.SetTextColor(memDC, foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2221 OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT)); |
24 | 2222 OS.ExtTextOutW(memDC, 0, 0, 0, null, buffer, length_, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2223 OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2224 OS.SelectObject(memDC, hOldBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2225 OS.DeleteDC(memDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2226 OS.DeleteObject(hBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2227 } else { |
25 | 2228 auto background = OS.GetBkColor(handle); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2229 OS.SetTextColor(handle, foreground ^ background); |
25 | 2230 OS.ExtTextOutW(handle, x, y, flags, &rect, buffer, length_, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2231 OS.SetTextColor(handle, foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2232 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2233 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2234 OS.SetBkMode(handle, oldBkMode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2235 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2236 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2237 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2238 * Draws the given string, using the receiver's current font and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2239 * foreground color. Tab expansion and carriage return processing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2240 * are performed. The background of the rectangular area where |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2241 * the text is being drawn will be filled with the receiver's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2242 * background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2243 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2244 * @param string the string to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2245 * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2246 * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2247 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2248 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2249 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2250 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2251 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
2252 public void drawText (String string, int x, int y) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2253 drawText(string, x, y, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2254 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2255 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2256 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2257 * Draws the given string, using the receiver's current font and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2258 * foreground color. Tab expansion and carriage return processing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2259 * are performed. If <code>isTransparent</code> is <code>true</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2260 * then the background of the rectangular area where the text is being |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2261 * drawn will not be modified, otherwise it will be filled with the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2262 * receiver's background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2263 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2264 * @param string the string to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2265 * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2266 * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2267 * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2268 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2269 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2270 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2271 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2272 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
2273 public void drawText (String string, int x, int y, bool isTransparent) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2274 int flags = DWT.DRAW_DELIMITER | DWT.DRAW_TAB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2275 if (isTransparent) flags |= DWT.DRAW_TRANSPARENT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2276 drawText(string, x, y, flags); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2277 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2278 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2279 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2280 * Draws the given string, using the receiver's current font and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2281 * foreground color. Tab expansion, line delimiter and mnemonic |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2282 * processing are performed according to the specified flags. If |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2283 * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2284 * then the background of the rectangular area where the text is being |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2285 * drawn will not be modified, otherwise it will be filled with the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2286 * receiver's background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2287 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2288 * The parameter <code>flags</code> may be a combination of: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2289 * <dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2290 * <dt><b>DRAW_DELIMITER</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2291 * <dd>draw multiple lines</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2292 * <dt><b>DRAW_TAB</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2293 * <dd>expand tabs</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2294 * <dt><b>DRAW_MNEMONIC</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2295 * <dd>underline the mnemonic character</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2296 * <dt><b>DRAW_TRANSPARENT</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2297 * <dd>transparent background</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2298 * </dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2299 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2300 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2301 * @param string the string to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2302 * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2303 * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2304 * @param flags the flags specifying how to process the text |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2305 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2306 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2307 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2308 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2309 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
2310 public void drawText (String string, int x, int y, int flags) { |
24 | 2311 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2312 // DWT extension: allow null string |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2313 //if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
24 | 2314 if (string.length is 0) return; |
2315 auto gdipGraphics = data.gdipGraphics; | |
2316 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2317 checkGC(FONT | FOREGROUND | ((flags & DWT.DRAW_TRANSPARENT) !is 0 ? 0 : BACKGROUND)); |
25 | 2318 wchar[] wstr = StrToWCHARs( string ); |
2319 int length_ = wstr.length; | |
2320 wchar* buffer = wstr.ptr; | |
2321 Gdip.PointF pt; | |
2322 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2323 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2324 if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2325 Gdip.StringFormat_SetFormatFlags(format, formatFlags); |
25 | 2326 float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [ cast(float) measureSpace(data.gdipFont, format) * 8] : new float[1]; |
213 | 2327 Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2328 int hotkeyPrefix = (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2329 if ((flags & DWT.DRAW_MNEMONIC) !is 0 && (data.uiState & OS.UISF_HIDEACCEL) !is 0) hotkeyPrefix = Gdip.HotkeyPrefixHide; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2330 Gdip.StringFormat_SetHotkeyPrefix(format, hotkeyPrefix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2331 if ((flags & DWT.DRAW_TRANSPARENT) is 0) { |
25 | 2332 Gdip.RectF bounds; |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2333 Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); |
25 | 2334 Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.rndint(bounds.Width), Math.rndint(bounds.Height)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2335 } |
25 | 2336 int gstate = 0; |
2337 auto brush = getFgBrush(); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2338 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2339 switch (Gdip.Brush_GetType(brush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2340 case Gdip.BrushTypeLinearGradient: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2341 Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2342 Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2343 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2344 case Gdip.BrushTypeTextureFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2345 Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2346 Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2347 break; |
81 | 2348 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2349 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2350 gstate = Gdip.Graphics_Save(gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2351 Gdip.Graphics_ScaleTransform(gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2352 Gdip.Graphics_TranslateTransform(gdipGraphics, - 2 * x, 0, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2353 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2354 pt.X = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2355 pt.Y = y; |
24 | 2356 Gdip.Graphics_DrawString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2357 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2358 switch (Gdip.Brush_GetType(brush)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2359 case Gdip.BrushTypeLinearGradient: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2360 Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2361 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2362 case Gdip.BrushTypeTextureFill: |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2363 Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush)brush); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2364 break; |
81 | 2365 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2366 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2367 Gdip.Graphics_Restore(gdipGraphics, gstate); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2368 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2369 Gdip.StringFormat_delete(format); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2370 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2371 } |
25 | 2372 TCHAR[] wstr = StrToTCHARs( string ); |
2373 TCHAR* buffer = wstr.ptr; | |
2374 int length_ = wstr.length; | |
24 | 2375 if (length_ is 0) return; |
25 | 2376 RECT rect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2377 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2378 * Feature in Windows. For some reason DrawText(), the maximum |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2379 * value for the bottom and right coordinates for the RECT that |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2380 * is used to position the text is different on between Windows |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2381 * versions. If this value is larger than the maximum, nothing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2382 * is drawn. On Windows 98, the limit is 0x7FFF. On Windows CE, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2383 * NT, and 2000 it is 0x6FFFFFF. And on XP, it is 0x7FFFFFFF. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2384 * The fix is to use the the smaller limit for Windows 98 and the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2385 * larger limit on the other Windows platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2386 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2387 int limit = OS.IsWin95 ? 0x7FFF : 0x6FFFFFF; |
25 | 2388 OS.SetRect(&rect, x, y, limit, limit); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2389 int uFormat = OS.DT_LEFT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2390 if ((flags & DWT.DRAW_DELIMITER) is 0) uFormat |= OS.DT_SINGLELINE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2391 if ((flags & DWT.DRAW_TAB) !is 0) uFormat |= OS.DT_EXPANDTABS; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2392 if ((flags & DWT.DRAW_MNEMONIC) is 0) uFormat |= OS.DT_NOPREFIX; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2393 if ((flags & DWT.DRAW_MNEMONIC) !is 0 && (data.uiState & OS.UISF_HIDEACCEL) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2394 uFormat |= OS.DT_HIDEPREFIX; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2395 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2396 int rop2 = 0; |
117 | 2397 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2398 rop2 = OS.SetROP2(handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2399 OS.SetROP2(handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2400 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2401 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2402 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2403 checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2404 int oldBkMode = OS.SetBkMode(handle, (flags & DWT.DRAW_TRANSPARENT) !is 0 ? OS.TRANSPARENT : OS.OPAQUE); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2405 if (rop2 !is OS.R2_XORPEN) { |
25 | 2406 OS.DrawText(handle, buffer, length_, &rect, uFormat); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2407 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2408 int foreground = OS.GetTextColor(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2409 if ((flags & DWT.DRAW_TRANSPARENT) !is 0) { |
25 | 2410 OS.DrawText(handle, buffer, length_, &rect, uFormat | OS.DT_CALCRECT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2411 int width = rect.right - rect.left; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2412 int height = rect.bottom - rect.top; |
24 | 2413 auto hBitmap = OS.CreateCompatibleBitmap(handle, width, height); |
2414 if (hBitmap is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
25 | 2415 auto memDC = OS.CreateCompatibleDC(handle); |
2416 auto hOldBitmap = OS.SelectObject(memDC, hBitmap); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2417 OS.PatBlt(memDC, 0, 0, width, height, OS.BLACKNESS); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2418 OS.SetBkMode(memDC, OS.TRANSPARENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2419 OS.SetTextColor(memDC, foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2420 OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT)); |
25 | 2421 OS.SetRect(&rect, 0, 0, 0x7FFF, 0x7FFF); |
2422 OS.DrawText(memDC, buffer, length_, &rect, uFormat); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2423 OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2424 OS.SelectObject(memDC, hOldBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2425 OS.DeleteDC(memDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2426 OS.DeleteObject(hBitmap); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2427 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2428 int background = OS.GetBkColor(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2429 OS.SetTextColor(handle, foreground ^ background); |
25 | 2430 OS.DrawText(handle, buffer, length_, &rect, uFormat); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2431 OS.SetTextColor(handle, foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2432 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2433 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2434 OS.SetBkMode(handle, oldBkMode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2435 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2436 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2437 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2438 * Compares the argument to the receiver, and returns true |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2439 * if they represent the <em>same</em> object using a class |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2440 * specific comparison. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2441 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2442 * @param object the object to compare with this object |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2443 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2444 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2445 * @see #hashCode |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2446 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2447 public bool equals (Object object) { |
24 | 2448 return (object is this) || (null !is (cast(GC)object) && (handle is (cast(GC)object).handle)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2449 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2450 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2451 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2452 * Fills the interior of a circular or elliptical arc within |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2453 * the specified rectangular area, with the receiver's background |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2454 * color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2455 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2456 * The resulting arc begins at <code>startAngle</code> and extends |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2457 * for <code>arcAngle</code> degrees, using the current color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2458 * Angles are interpreted such that 0 degrees is at the 3 o'clock |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2459 * position. A positive value indicates a counter-clockwise rotation |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2460 * while a negative value indicates a clockwise rotation. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2461 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2462 * The center of the arc is the center of the rectangle whose origin |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2463 * is (<code>x</code>, <code>y</code>) and whose size is specified by the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2464 * <code>width</code> and <code>height</code> arguments. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2465 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2466 * The resulting arc covers an area <code>width + 1</code> pixels wide |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2467 * by <code>height + 1</code> pixels tall. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2468 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2469 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2470 * @param x the x coordinate of the upper-left corner of the arc to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2471 * @param y the y coordinate of the upper-left corner of the arc to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2472 * @param width the width of the arc to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2473 * @param height the height of the arc to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2474 * @param startAngle the beginning angle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2475 * @param arcAngle the angular extent of the arc, relative to the start angle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2476 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2477 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2478 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2479 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2480 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2481 * @see #drawArc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2482 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2483 public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) { |
24 | 2484 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2485 checkGC(FILL); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2486 if (width < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2487 x = x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2488 width = -width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2489 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2490 if (height < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2491 y = y + height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2492 height = -height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2493 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2494 if (width is 0 || height is 0 || arcAngle is 0) return; |
24 | 2495 auto gdipGraphics = data.gdipGraphics; |
2496 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2497 if (width is height) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2498 Gdip.Graphics_FillPie(gdipGraphics, data.gdipBrush, x, y, width, height, -startAngle, -arcAngle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2499 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2500 int state = Gdip.Graphics_Save(gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2501 Gdip.Graphics_TranslateTransform(gdipGraphics, x, y, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2502 Gdip.Graphics_ScaleTransform(gdipGraphics, width, height, Gdip.MatrixOrderPrepend); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2503 Gdip.Graphics_FillPie(gdipGraphics, data.gdipBrush, 0, 0, 1, 1, -startAngle, -arcAngle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2504 Gdip.Graphics_Restore(gdipGraphics, state); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2505 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2506 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2507 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2508 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2509 if ((data.style & DWT.MIRRORED) !is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2510 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2511 * Feature in WinCE. The function Pie is not present in the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2512 * WinCE SDK. The fix is to emulate it by using Polygon. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2513 */ |
117 | 2514 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2515 /* compute arc with a simple linear interpolation */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2516 if (arcAngle < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2517 startAngle += arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2518 arcAngle = -arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2519 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2520 bool drawSegments = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2521 if (arcAngle >= 360) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2522 arcAngle = 360; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2523 drawSegments = false; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2524 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2525 int[] points = new int[(arcAngle + 1) * 2 + (drawSegments ? 4 : 0)]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2526 int cteX = 2 * x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2527 int cteY = 2 * y + height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2528 int index = (drawSegments ? 2 : 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2529 for (int i = 0; i <= arcAngle; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2530 points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2531 points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2532 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2533 if (drawSegments) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2534 points[0] = points[points.length - 2] = cteX >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2535 points[1] = points[points.length - 1] = cteY >> 1; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2536 } |
25 | 2537 OS.Polygon(handle, cast(POINT*)points.ptr, points.length / 2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2538 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2539 int x1, y1, x2, y2,tmp; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2540 bool isNegative; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2541 if (arcAngle >= 360 || arcAngle <= -360) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2542 x1 = x2 = x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2543 y1 = y2 = y + height / 2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2544 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2545 isNegative = arcAngle < 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2546 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2547 arcAngle = arcAngle + startAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2548 if (isNegative) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2549 // swap angles |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2550 tmp = startAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2551 startAngle = arcAngle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2552 arcAngle = tmp; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2553 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2554 x1 = Compatibility.cos(startAngle, width) + x + width/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2555 y1 = -1 * Compatibility.sin(startAngle, height) + y + height/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2556 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2557 x2 = Compatibility.cos(arcAngle, width) + x + width/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2558 y2 = -1 * Compatibility.sin(arcAngle, height) + y + height/2; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2559 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2560 OS.Pie(handle, x, y, x + width + 1, y + height + 1, x1, y1, x2, y2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2561 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2562 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2563 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2564 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2565 * Fills the interior of the specified rectangle with a gradient |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2566 * sweeping from left to right or top to bottom progressing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2567 * from the receiver's foreground color to its background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2568 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2569 * @param x the x coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2570 * @param y the y coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2571 * @param width the width of the rectangle to be filled, may be negative |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2572 * (inverts direction of gradient if horizontal) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2573 * @param height the height of the rectangle to be filled, may be negative |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2574 * (inverts direction of gradient if vertical) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2575 * @param vertical if true sweeps from top to bottom, else |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2576 * sweeps from left to right |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2577 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2578 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2579 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2580 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2581 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2582 * @see #drawRectangle(int, int, int, int) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2583 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2584 public void fillGradientRectangle(int x, int y, int width, int height, bool vertical) { |
24 | 2585 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2586 if (width is 0 || height is 0) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2587 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2588 RGB backgroundRGB, foregroundRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2589 backgroundRGB = getBackground().getRGB(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2590 foregroundRGB = getForeground().getRGB(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2591 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2592 RGB fromRGB, toRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2593 fromRGB = foregroundRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2594 toRGB = backgroundRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2595 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2596 bool swapColors = false; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2597 if (width < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2598 x += width; width = -width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2599 if (! vertical) swapColors = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2600 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2601 if (height < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2602 y += height; height = -height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2603 if (vertical) swapColors = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2604 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2605 if (swapColors) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2606 fromRGB = backgroundRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2607 toRGB = foregroundRGB; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2608 } |
25 | 2609 if (fromRGB ==/*eq*/ toRGB) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2610 fillRectangle(x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2611 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2612 } |
24 | 2613 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2614 initGdip(); |
25 | 2615 Gdip.PointF p1, p2; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2616 p1.X = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2617 p1.Y = y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2618 if (vertical) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2619 p2.X = p1.X; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2620 p2.Y = p1.Y + height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2621 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2622 p2.X = p1.X + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2623 p2.Y = p1.Y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2624 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2625 int rgb = ((fromRGB.red & 0xFF) << 16) | ((fromRGB.green & 0xFF) << 8) | (fromRGB.blue & 0xFF); |
24 | 2626 auto fromGpColor = Gdip.Color_new(data.alpha << 24 | rgb); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2627 //if (fromGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2628 rgb = ((toRGB.red & 0xFF) << 16) | ((toRGB.green & 0xFF) << 8) | (toRGB.blue & 0xFF); |
24 | 2629 auto toGpColor = Gdip.Color_new(data.alpha << 24 | rgb); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2630 //if (toGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); |
25 | 2631 auto brush = Gdip.LinearGradientBrush_new(p1, p2, fromGpColor, toGpColor); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2632 Gdip.Graphics_FillRectangle(data.gdipGraphics, cast(Gdip.Brush)brush, x, y, width, height); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2633 Gdip.LinearGradientBrush_delete(brush); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2634 Gdip.Color_delete(fromGpColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2635 Gdip.Color_delete(toGpColor); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2636 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2637 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2638 /* Use GradientFill if supported, only on Windows 98, 2000 and newer. */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2639 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2640 * Bug in Windows: On Windows 2000 when the device is a printer, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2641 * GradientFill swaps red and blue color components, causing the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2642 * gradient to be printed in the wrong color. On Windows 98 when |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2643 * the device is a printer, GradientFill does not fill completely |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2644 * to the right edge of the rectangle. The fix is not to use |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2645 * GradientFill for printer devices. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2646 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2647 int rop2 = 0; |
117 | 2648 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2649 rop2 = OS.SetROP2(handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2650 OS.SetROP2(handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2651 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2652 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2653 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2654 if (OS.IsWinNT && rop2 !is OS.R2_XORPEN && OS.GetDeviceCaps(handle, OS.TECHNOLOGY) !is OS.DT_RASPRINTER) { |
24 | 2655 final auto hHeap = OS.GetProcessHeap(); |
2656 final auto pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2); | |
2657 if (pMesh is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
25 | 2658 auto pVertex = cast(TRIVERTEX*)( pMesh + GRADIENT_RECT.sizeof ); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2659 |
25 | 2660 GRADIENT_RECT gradientRect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2661 gradientRect.UpperLeft = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2662 gradientRect.LowerRight = 1; |
25 | 2663 *cast(GRADIENT_RECT*)pMesh = gradientRect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2664 |
25 | 2665 TRIVERTEX* trivertex = pVertex; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2666 trivertex.x = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2667 trivertex.y = y; |
24 | 2668 trivertex.Red = cast(short)((fromRGB.red << 8) | fromRGB.red); |
2669 trivertex.Green = cast(short)((fromRGB.green << 8) | fromRGB.green); | |
2670 trivertex.Blue = cast(short)((fromRGB.blue << 8) | fromRGB.blue); | |
25 | 2671 trivertex.Alpha = ushort.max; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2672 |
25 | 2673 trivertex = pVertex+1; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2674 trivertex.x = x + width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2675 trivertex.y = y + height; |
24 | 2676 trivertex.Red = cast(short)((toRGB.red << 8) | toRGB.red); |
2677 trivertex.Green = cast(short)((toRGB.green << 8) | toRGB.green); | |
2678 trivertex.Blue = cast(short)((toRGB.blue << 8) | toRGB.blue); | |
25 | 2679 trivertex.Alpha = ushort.max; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2680 |
25 | 2681 bool success = cast(bool)OS.GradientFill(handle, pVertex, 2, pMesh, 1, vertical ? OS.GRADIENT_FILL_RECT_V : OS.GRADIENT_FILL_RECT_H); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2682 OS.HeapFree(hHeap, 0, pMesh); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2683 if (success) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2684 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2685 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2686 final int depth = OS.GetDeviceCaps(handle, OS.BITSPIXEL); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2687 final int bitResolution = (depth >= 24) ? 8 : (depth >= 15) ? 5 : 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2688 ImageData.fillGradientRectangle(this, data.device, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2689 x, y, width, height, vertical, fromRGB, toRGB, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2690 bitResolution, bitResolution, bitResolution); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2691 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2692 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2693 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2694 * Fills the interior of an oval, within the specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2695 * rectangular area, with the receiver's background |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2696 * color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2697 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2698 * @param x the x coordinate of the upper left corner of the oval to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2699 * @param y the y coordinate of the upper left corner of the oval to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2700 * @param width the width of the oval to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2701 * @param height the height of the oval to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2702 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2703 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2704 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2705 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2706 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2707 * @see #drawOval |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2708 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2709 public void fillOval (int x, int y, int width, int height) { |
24 | 2710 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2711 checkGC(FILL); |
24 | 2712 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2713 Gdip.Graphics_FillEllipse(data.gdipGraphics, data.gdipBrush, x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2714 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2715 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2716 if ((data.style & DWT.MIRRORED) !is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2717 OS.Ellipse(handle, x, y, x + width + 1, y + height + 1); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2718 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2719 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2720 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2721 * Fills the path described by the parameter. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2722 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2723 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2724 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2725 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2726 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2727 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2728 * @param path the path to fill |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2729 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2730 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2731 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2732 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2733 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2734 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2735 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2736 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2737 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2738 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2739 * @see Path |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2740 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2741 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2742 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2743 public void fillPath (Path path) { |
24 | 2744 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2745 if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
24 | 2746 if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2747 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2748 checkGC(FILL); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2749 int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2750 Gdip.GraphicsPath_SetFillMode(path.handle, mode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2751 Gdip.Graphics_FillPath(data.gdipGraphics, data.gdipBrush, path.handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2752 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2753 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2754 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2755 * Fills the interior of the closed polygon which is defined by the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2756 * specified array of integer coordinates, using the receiver's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2757 * background color. The array contains alternating x and y values |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2758 * which are considered to represent points which are the vertices of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2759 * the polygon. Lines are drawn between each consecutive pair, and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2760 * between the first pair and last pair in the array. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2761 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2762 * @param pointArray an array of alternating x and y values which are the vertices of the polygon |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2763 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2764 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2765 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2766 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2767 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2768 * @see #drawPolygon |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2769 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2770 public void fillPolygon(int[] pointArray) { |
24 | 2771 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2772 // DWT externsion: allow null array |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
2773 //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2774 checkGC(FILL); |
24 | 2775 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2776 int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
213 | 2777 Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, cast(Gdip.Point*)pointArray.ptr, pointArray.length / 2, mode); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2778 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2779 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2780 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2781 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2782 pointArray[i]--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2783 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2784 } |
25 | 2785 OS.Polygon(handle, cast(POINT*)pointArray.ptr, pointArray.length / 2); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2786 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2787 for (int i = 0; i < pointArray.length; i+=2) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2788 pointArray[i]++; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2789 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2790 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2791 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2792 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2793 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2794 * Fills the interior of the rectangle specified by the arguments, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2795 * using the receiver's background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2796 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2797 * @param x the x coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2798 * @param y the y coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2799 * @param width the width of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2800 * @param height the height of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2801 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2802 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2803 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2804 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2805 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2806 * @see #drawRectangle(int, int, int, int) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2807 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2808 public void fillRectangle (int x, int y, int width, int height) { |
24 | 2809 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2810 checkGC(FILL); |
24 | 2811 if (data.gdipGraphics !is null) { |
213 | 2812 if (width < 0) { |
2813 x = x + width; | |
2814 width = -width; | |
2815 } | |
2816 if (height < 0) { | |
2817 y = y + height; | |
2818 height = -height; | |
2819 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2820 Gdip.Graphics_FillRectangle(data.gdipGraphics, data.gdipBrush, x, y, width, height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2821 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2822 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2823 int rop2 = 0; |
117 | 2824 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2825 rop2 = OS.SetROP2(handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2826 OS.SetROP2(handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2827 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2828 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2829 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2830 int dwRop = rop2 is OS.R2_XORPEN ? OS.PATINVERT : OS.PATCOPY; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2831 OS.PatBlt(handle, x, y, width, height, dwRop); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2832 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2833 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2834 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2835 * Fills the interior of the specified rectangle, using the receiver's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2836 * background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2837 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2838 * @param rect the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2839 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2840 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2841 * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2842 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2843 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2844 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2845 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2846 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2847 * @see #drawRectangle(int, int, int, int) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2848 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2849 public void fillRectangle (Rectangle rect) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2850 if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2851 fillRectangle (rect.x, rect.y, rect.width, rect.height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2852 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2853 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2854 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2855 * Fills the interior of the round-cornered rectangle specified by |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2856 * the arguments, using the receiver's background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2857 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2858 * @param x the x coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2859 * @param y the y coordinate of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2860 * @param width the width of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2861 * @param height the height of the rectangle to be filled |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2862 * @param arcWidth the width of the arc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2863 * @param arcHeight the height of the arc |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2864 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2865 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2866 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2867 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2868 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2869 * @see #drawRoundRectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2870 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2871 public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) { |
24 | 2872 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2873 checkGC(FILL); |
24 | 2874 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2875 fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2876 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2877 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2878 if ((data.style & DWT.MIRRORED) !is 0) x--; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2879 OS.RoundRect(handle, x,y,x+width+1,y+height+1,arcWidth, arcHeight); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2880 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2881 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
2882 void fillRoundRectangleGdip (Gdip.Graphics gdipGraphics, Gdip.Brush brush, int x, int y, int width, int height, int arcWidth, int arcHeight) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2883 int nx = x; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2884 int ny = y; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2885 int nw = width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2886 int nh = height; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2887 int naw = arcWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2888 int nah = arcHeight; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2889 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2890 if (nw < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2891 nw = 0 - nw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2892 nx = nx - nw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2893 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2894 if (nh < 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2895 nh = 0 - nh; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2896 ny = ny -nh; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2897 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2898 if (naw < 0) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2899 naw = 0 - naw; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2900 if (nah < 0) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2901 nah = 0 - nah; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2902 |
213 | 2903 if (naw is 0 || nah is 0) { |
2904 Gdip.Graphics_FillRectangle(data.gdipGraphics, data.gdipBrush, x, y, width, height); | |
2905 } else { | |
2906 auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); | |
2907 if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); | |
2908 if (nw > naw) { | |
2909 if (nh > nah) { | |
2910 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nah, 0, -90); | |
2911 Gdip.GraphicsPath_AddArc(path, nx, ny, naw, nah, -90, -90); | |
2912 Gdip.GraphicsPath_AddArc(path, nx, ny + nh - nah, naw, nah, -180, -90); | |
2913 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny + nh - nah, naw, nah, -270, -90); | |
2914 } else { | |
2915 Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nh, -270, -180); | |
2916 Gdip.GraphicsPath_AddArc(path, nx, ny, naw, nh, -90, -180); | |
2917 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2918 } else { |
213 | 2919 if (nh > nah) { |
2920 Gdip.GraphicsPath_AddArc(path, nx, ny, nw, nah, 0, -180); | |
2921 Gdip.GraphicsPath_AddArc(path, nx, ny + nh - nah, nw, nah, -180, -180); | |
2922 } else { | |
2923 Gdip.GraphicsPath_AddArc(path, nx, ny, nw, nh, 0, 360); | |
2924 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2925 } |
213 | 2926 Gdip.GraphicsPath_CloseFigure(path); |
2927 Gdip.Graphics_FillPath(gdipGraphics, brush, path); | |
2928 Gdip.GraphicsPath_delete(path); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2929 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2930 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2931 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2932 void flush () { |
24 | 2933 if (data.gdipGraphics !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2934 Gdip.Graphics_Flush(data.gdipGraphics, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2935 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2936 * Note Flush() does not flush the output to the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2937 * underline HDC. This is done by calling GetHDC() |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2938 * followed by ReleaseHDC(). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2939 */ |
25 | 2940 auto hdc = Gdip.Graphics_GetHDC(data.gdipGraphics); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2941 Gdip.Graphics_ReleaseHDC(data.gdipGraphics, hdc); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2942 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2943 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2944 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2945 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2946 * Returns the <em>advance width</em> of the specified character in |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2947 * the font which is currently selected into the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2948 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2949 * The advance width is defined as the horizontal distance the cursor |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2950 * should move after printing the character in the selected font. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2951 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2952 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2953 * @param ch the character to measure |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2954 * @return the distance in the x direction to move past the character before painting the next |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2955 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2956 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2957 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2958 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2959 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2960 public int getAdvanceWidth(char ch) { |
24 | 2961 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2962 checkGC(FONT); |
25 | 2963 static if (OS.IsWinCE) { |
2964 SIZE size; | |
2965 OS.GetTextExtentPoint32W(handle, [ch], 1, &size); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2966 return size.cx; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2967 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2968 int tch = ch; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2969 if (ch > 0x7F) { |
25 | 2970 char[1] str; |
2971 str[0] = ch; | |
2972 TCHAR[] buffer = StrToTCHARs( str ); | |
2973 tch = buffer[0]; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2974 } |
25 | 2975 int width; |
2976 OS.GetCharWidth(handle, tch, tch, &width); | |
2977 return width; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2978 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2979 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2980 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2981 * Returns <code>true</code> if receiver is using the operating system's |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2982 * advanced graphics subsystem. Otherwise, <code>false</code> is returned |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2983 * to indicate that normal graphics are in use. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2984 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2985 * Advanced graphics may not be installed for the operating system. In this |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2986 * case, <code>false</code> is always returned. Some operating system have |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2987 * only one graphics subsystem. If this subsystem supports advanced graphics, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2988 * then <code>true</code> is always returned. If any graphics operation such |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2989 * as alpha, antialias, patterns, interpolation, paths, clipping or transformation |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2990 * has caused the receiver to switch from regular to advanced graphics mode, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2991 * <code>true</code> is returned. If the receiver has been explicitly switched |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2992 * to advanced mode and this mode is supported, <code>true</code> is returned. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2993 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2994 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2995 * @return the advanced value |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2996 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2997 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2998 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
2999 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3000 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3001 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3002 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3003 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3004 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3005 public bool getAdvanced() { |
24 | 3006 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3007 return data.gdipGraphics !is null; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3008 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3009 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3010 /** |
246 | 3011 * Returns the receiver's alpha value. The alpha value |
3012 * is between 0 (transparent) and 255 (opaque). | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3013 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3014 * @return the alpha value |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3015 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3016 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3017 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3018 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3019 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3020 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3021 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3022 public int getAlpha() { |
24 | 3023 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3024 return data.alpha; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3025 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3026 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3027 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3028 * Returns the receiver's anti-aliasing setting value, which will be |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3029 * one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> or |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3030 * <code>DWT.ON</code>. Note that this controls anti-aliasing for all |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3031 * <em>non-text drawing</em> operations. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3032 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3033 * @return the anti-aliasing setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3034 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3035 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3036 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3037 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3038 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3039 * @see #getTextAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3040 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3041 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3042 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3043 public int getAntialias() { |
24 | 3044 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3045 if (data.gdipGraphics is null) return DWT.DEFAULT; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3046 int mode = Gdip.Graphics_GetSmoothingMode(data.gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3047 switch (mode) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3048 case Gdip.SmoothingModeDefault: return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3049 case Gdip.SmoothingModeHighSpeed: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3050 case Gdip.SmoothingModeNone: return DWT.OFF; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3051 case Gdip.SmoothingModeAntiAlias: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3052 case Gdip.SmoothingModeAntiAlias8x8: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3053 case Gdip.SmoothingModeHighQuality: return DWT.ON; |
81 | 3054 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3055 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3056 return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3057 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3058 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3059 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3060 * Returns the background color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3061 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3062 * @return the receiver's background color |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3063 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3064 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3065 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3066 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3067 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3068 public Color getBackground() { |
24 | 3069 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3070 return Color.win32_new(data.device, data.background); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3071 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3072 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3073 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3074 * Returns the background pattern. The default value is |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3075 * <code>null</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3076 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3077 * @return the receiver's background pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3078 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3079 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3080 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3081 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3082 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3083 * @see Pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3084 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3085 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3086 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3087 public Pattern getBackgroundPattern() { |
24 | 3088 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3089 return data.backgroundPattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3090 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3091 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3092 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3093 * Returns the width of the specified character in the font |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3094 * selected into the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3095 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3096 * The width is defined as the space taken up by the actual |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3097 * character, not including the leading and tailing whitespace |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3098 * or overhang. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3099 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3100 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3101 * @param ch the character to measure |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3102 * @return the width of the character |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3103 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3104 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3105 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3106 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3107 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3108 public int getCharWidth(char ch) { |
24 | 3109 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3110 checkGC(FONT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3111 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3112 /* GetCharABCWidths only succeeds on truetype fonts */ |
25 | 3113 static if (!OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3114 int tch = ch; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3115 if (ch > 0x7F) { |
25 | 3116 char[1] str; |
3117 str[0] = ch; | |
3118 TCHAR[] buffer = StrToTCHARs( str ); | |
3119 tch = buffer[0]; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3120 } |
25 | 3121 ABC abc; |
3122 if (OS.GetCharABCWidths(handle, tch, tch, &abc)) { | |
3123 return abc.abcA; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3124 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3125 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3126 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3127 /* It wasn't a truetype font */ |
24 | 3128 TEXTMETRIC lptm; |
3129 OS.GetTextMetrics(handle, &lptm); | |
3130 SIZE size; | |
25 | 3131 char[1] str; |
3132 str[0] = ch; | |
3133 OS.GetTextExtentPoint32W(handle, StrToWCHARz( str ), 1, &size); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3134 return size.cx - lptm.tmOverhang; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3135 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3136 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3137 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3138 * Returns the bounding rectangle of the receiver's clipping |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3139 * region. If no clipping region is set, the return value |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3140 * will be a rectangle which covers the entire bounds of the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3141 * object the receiver is drawing on. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3142 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3143 * @return the bounding rectangle of the clipping region |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3144 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3145 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3146 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3147 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3148 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3149 public Rectangle getClipping() { |
24 | 3150 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3151 auto gdipGraphics = data.gdipGraphics; | |
3152 if (gdipGraphics !is null) { | |
25 | 3153 Gdip.Rect rect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3154 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3155 Gdip.Graphics_GetVisibleClipBounds(gdipGraphics, rect); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3156 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3157 return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3158 } |
25 | 3159 RECT rect; |
3160 OS.GetClipBox(handle, &rect); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3161 return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3162 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3163 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3164 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3165 * Sets the region managed by the argument to the current |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3166 * clipping region of the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3167 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3168 * @param region the region to fill with the clipping region |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3169 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3170 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3171 * <li>ERROR_NULL_ARGUMENT - if the region is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3172 * <li>ERROR_INVALID_ARGUMENT - if the region is disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3173 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3174 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3175 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3176 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3177 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3178 public void getClipping (Region region) { |
24 | 3179 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3180 if (region is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3181 if (region.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
24 | 3182 auto gdipGraphics = data.gdipGraphics; |
3183 if (gdipGraphics !is null) { | |
25 | 3184 auto rgn = Gdip.Region_new(); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3185 Gdip.Graphics_GetClip(data.gdipGraphics, rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3186 if (Gdip.Region_IsInfinite(rgn, gdipGraphics)) { |
25 | 3187 Gdip.Rect rect; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3188 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3189 Gdip.Graphics_GetVisibleClipBounds(gdipGraphics, rect); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3190 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3191 OS.SetRectRgn(region.handle, rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3192 } else { |
25 | 3193 auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); |
3194 auto identity_ = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3195 Gdip.Graphics_GetTransform(gdipGraphics, matrix); |
25 | 3196 Gdip.Graphics_SetTransform(gdipGraphics, identity_); |
3197 auto hRgn = Gdip.Region_GetHRGN(rgn, data.gdipGraphics); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3198 Gdip.Graphics_SetTransform(gdipGraphics, matrix); |
25 | 3199 Gdip.Matrix_delete(identity_); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3200 Gdip.Matrix_delete(matrix); |
25 | 3201 OS.CombineRgn(region.handle, hRgn, null, OS.RGN_COPY); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3202 OS.DeleteObject(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3203 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3204 Gdip.Region_delete(rgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3205 return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3206 } |
25 | 3207 POINT pt; |
3208 static if (!OS.IsWinCE) OS.GetWindowOrgEx (handle, &pt); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3209 int result = OS.GetClipRgn (handle, region.handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3210 if (result !is 1) { |
25 | 3211 RECT rect; |
3212 OS.GetClipBox(handle, &rect); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3213 OS.SetRectRgn(region.handle, rect.left, rect.top, rect.right, rect.bottom); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3214 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3215 OS.OffsetRgn (region.handle, pt.x, pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3216 } |
25 | 3217 static if (!OS.IsWinCE) { |
3218 auto metaRgn = OS.CreateRectRgn (0, 0, 0, 0); | |
3219 if (OS.GetMetaRgn (handle, metaRgn) !is 0) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3220 OS.OffsetRgn (metaRgn, pt.x, pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3221 OS.CombineRgn (region.handle, metaRgn, region.handle, OS.RGN_AND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3222 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3223 OS.DeleteObject(metaRgn); |
25 | 3224 auto hwnd = data.hwnd; |
24 | 3225 if (hwnd !is null && data.ps !is null) { |
25 | 3226 auto sysRgn = OS.CreateRectRgn (0, 0, 0, 0); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3227 if (OS.GetRandomRgn (handle, sysRgn, OS.SYSRGN) is 1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3228 if (OS.WIN32_VERSION >= OS.VERSION(4, 10)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3229 if ((OS.GetLayout(handle) & OS.LAYOUT_RTL) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3230 int nBytes = OS.GetRegionData (sysRgn, 0, null); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3231 int [] lpRgnData = new int [nBytes / 4]; |
25 | 3232 OS.GetRegionData (sysRgn, nBytes, cast(RGNDATA*)lpRgnData.ptr); |
3233 auto newSysRgn = OS.ExtCreateRegion( cast(XFORM*) [-1, 0, 0, 1, 0, 0].ptr, nBytes, cast(RGNDATA*)lpRgnData.ptr); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3234 OS.DeleteObject(sysRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3235 sysRgn = newSysRgn; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3236 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3237 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3238 if (OS.IsWinNT) { |
25 | 3239 OS.MapWindowPoints(null, hwnd, &pt, 1); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3240 OS.OffsetRgn(sysRgn, pt.x, pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3241 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3242 OS.CombineRgn (region.handle, sysRgn, region.handle, OS.RGN_AND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3243 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3244 OS.DeleteObject(sysRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3245 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3246 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3247 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3248 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3249 int getCodePage () { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3250 if (OS.IsUnicode) return OS.CP_ACP; |
25 | 3251 CHARSETINFO csi; |
3252 auto cs = OS.GetTextCharset(handle); | |
3253 OS.TranslateCharsetInfo( cast(DWORD*)cs, &csi, OS.TCI_SRCCHARSET); | |
3254 return csi.ciACP; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3255 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3256 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
3257 Gdip.Brush getFgBrush() { |
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
3258 return data.foregroundPattern !is null ? data.foregroundPattern.handle : cast(Gdip.Brush)data.gdipFgBrush; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3259 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3260 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3261 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3262 * Returns the receiver's fill rule, which will be one of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3263 * <code>DWT.FILL_EVEN_ODD</code> or <code>DWT.FILL_WINDING</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3264 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3265 * @return the receiver's fill rule |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3266 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3267 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3268 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3269 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3270 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3271 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3272 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3273 public int getFillRule() { |
24 | 3274 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
117 | 3275 static if (OS.IsWinCE) return DWT.FILL_EVEN_ODD; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3276 return OS.GetPolyFillMode(handle) is OS.WINDING ? DWT.FILL_WINDING : DWT.FILL_EVEN_ODD; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3277 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3278 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3279 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3280 * Returns the font currently being used by the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3281 * to draw and measure text. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3282 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3283 * @return the receiver's font |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3284 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3285 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3286 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3287 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3288 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3289 public Font getFont () { |
24 | 3290 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
213 | 3291 return data.font; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3292 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3293 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3294 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3295 * Returns a FontMetrics which contains information |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3296 * about the font currently being used by the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3297 * to draw and measure text. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3298 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3299 * @return font metrics for the receiver's font |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3300 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3301 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3302 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3303 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3304 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3305 public FontMetrics getFontMetrics() { |
24 | 3306 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3307 checkGC(FONT); |
24 | 3308 TEXTMETRIC lptm; |
3309 OS.GetTextMetrics(handle, &lptm); | |
3310 return FontMetrics.win32_new(&lptm); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3311 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3312 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3313 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3314 * Returns the receiver's foreground color. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3315 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3316 * @return the color used for drawing foreground things |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3317 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3318 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3319 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3320 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3321 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3322 public Color getForeground() { |
24 | 3323 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3324 return Color.win32_new(data.device, data.foreground); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3325 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3326 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3327 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3328 * Returns the foreground pattern. The default value is |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3329 * <code>null</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3330 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3331 * @return the receiver's foreground pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3332 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3333 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3334 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3335 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3336 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3337 * @see Pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3338 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3339 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3340 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3341 public Pattern getForegroundPattern() { |
24 | 3342 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3343 return data.foregroundPattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3344 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3345 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3346 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3347 * Returns the GCData. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3348 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3349 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3350 * API for <code>GC</code>. It is marked public only so that it |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3351 * can be shared within the packages provided by DWT. It is not |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3352 * available on all platforms, and should never be called from |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3353 * application code. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3354 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3355 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3356 * @return the receiver's GCData |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3357 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3358 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3359 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3360 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3361 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3362 * @see GCData |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3363 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3364 * @since 3.2 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3365 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3366 public GCData getGCData() { |
24 | 3367 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3368 return data; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3369 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3370 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3371 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3372 * Returns the receiver's interpolation setting, which will be one of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3373 * <code>DWT.DEFAULT</code>, <code>DWT.NONE</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3374 * <code>DWT.LOW</code> or <code>DWT.HIGH</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3375 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3376 * @return the receiver's interpolation setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3377 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3378 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3379 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3380 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3381 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3382 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3383 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3384 public int getInterpolation() { |
24 | 3385 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3386 if (data.gdipGraphics is null) return DWT.DEFAULT; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3387 int mode = Gdip.Graphics_GetInterpolationMode(data.gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3388 switch (mode) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3389 case Gdip.InterpolationModeDefault: return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3390 case Gdip.InterpolationModeNearestNeighbor: return DWT.NONE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3391 case Gdip.InterpolationModeBilinear: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3392 case Gdip.InterpolationModeLowQuality: return DWT.LOW; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3393 case Gdip.InterpolationModeBicubic: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3394 case Gdip.InterpolationModeHighQualityBilinear: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3395 case Gdip.InterpolationModeHighQualityBicubic: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3396 case Gdip.InterpolationModeHighQuality: return DWT.HIGH; |
81 | 3397 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3398 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3399 return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3400 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3401 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3402 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3403 * Returns the receiver's line attributes. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3404 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3405 * @return the line attributes used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3406 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3407 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3408 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3409 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3410 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3411 * @since 3.3 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3412 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3413 public LineAttributes getLineAttributes() { |
24 | 3414 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3415 float[] dashes = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3416 if (data.lineDashes !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3417 dashes = new float[data.lineDashes.length]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3418 System.arraycopy(data.lineDashes, 0, dashes, 0, dashes.length); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3419 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3420 return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, data.lineDashesOffset, data.lineMiterLimit); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3421 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3422 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3423 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3424 * Returns the receiver's line cap style, which will be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3425 * of the constants <code>DWT.CAP_FLAT</code>, <code>DWT.CAP_ROUND</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3426 * or <code>DWT.CAP_SQUARE</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3427 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3428 * @return the cap style used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3429 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3430 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3431 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3432 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3433 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3434 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3435 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3436 public int getLineCap() { |
24 | 3437 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3438 return data.lineCap; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3439 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3440 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3441 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3442 * Returns the receiver's line dash style. The default value is |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3443 * <code>null</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3444 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3445 * @return the line dash style used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3446 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3447 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3448 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3449 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3450 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3451 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3452 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3453 public int[] getLineDash() { |
24 | 3454 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3455 if (data.lineDashes is null) return null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3456 int[] lineDashes = new int[data.lineDashes.length]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3457 for (int i = 0; i < lineDashes.length; i++) { |
24 | 3458 lineDashes[i] = cast(int)data.lineDashes[i]; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3459 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3460 return lineDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3461 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3462 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3463 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3464 * Returns the receiver's line join style, which will be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3465 * of the constants <code>DWT.JOIN_MITER</code>, <code>DWT.JOIN_ROUND</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3466 * or <code>DWT.JOIN_BEVEL</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3467 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3468 * @return the join style used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3469 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3470 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3471 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3472 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3473 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3474 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3475 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3476 public int getLineJoin() { |
24 | 3477 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3478 return data.lineJoin; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3479 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3480 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3481 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3482 * Returns the receiver's line style, which will be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3483 * of the constants <code>DWT.LINE_SOLID</code>, <code>DWT.LINE_DASH</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3484 * <code>DWT.LINE_DOT</code>, <code>DWT.LINE_DASHDOT</code> or |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3485 * <code>DWT.LINE_DASHDOTDOT</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3486 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3487 * @return the style used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3488 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3489 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3490 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3491 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3492 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3493 public int getLineStyle() { |
24 | 3494 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3495 return data.lineStyle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3496 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3497 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3498 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3499 * Returns the width that will be used when drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3500 * for all of the figure drawing operations (that is, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3501 * <code>drawLine</code>, <code>drawRectangle</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3502 * <code>drawPolyline</code>, and so forth. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3503 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3504 * @return the receiver's line width |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3505 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3506 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3507 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3508 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3509 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3510 public int getLineWidth() { |
24 | 3511 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3512 return cast(int)data.lineWidth; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3513 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3514 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3515 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3516 * Returns the receiver's style information. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3517 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3518 * Note that the value which is returned by this method <em>may |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3519 * not match</em> the value which was provided to the constructor |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3520 * when the receiver was created. This can occur when the underlying |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3521 * operating system does not support a particular combination of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3522 * requested styles. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3523 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3524 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3525 * @return the style bits |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3526 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3527 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3528 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3529 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3530 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3531 * @since 2.1.2 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3532 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3533 public int getStyle () { |
24 | 3534 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3535 return data.style; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3536 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3537 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3538 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3539 * Returns the receiver's text drawing anti-aliasing setting value, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3540 * which will be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> or |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3541 * <code>DWT.ON</code>. Note that this controls anti-aliasing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3542 * <em>only</em> for text drawing operations. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3543 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3544 * @return the anti-aliasing setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3545 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3546 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3547 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3548 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3549 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3550 * @see #getAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3551 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3552 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3553 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3554 public int getTextAntialias() { |
24 | 3555 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3556 if (data.gdipGraphics is null) return DWT.DEFAULT; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3557 int mode = Gdip.Graphics_GetTextRenderingHint(data.gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3558 switch (mode) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3559 case Gdip.TextRenderingHintSystemDefault: return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3560 case Gdip.TextRenderingHintSingleBitPerPixel: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3561 case Gdip.TextRenderingHintSingleBitPerPixelGridFit: return DWT.OFF; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3562 case Gdip.TextRenderingHintAntiAlias: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3563 case Gdip.TextRenderingHintAntiAliasGridFit: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3564 case Gdip.TextRenderingHintClearTypeGridFit: return DWT.ON; |
81 | 3565 default: |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3566 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3567 return DWT.DEFAULT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3568 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3569 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3570 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3571 * Sets the parameter to the transform that is currently being |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3572 * used by the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3573 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3574 * @param transform the destination to copy the transform into |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3575 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3576 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3577 * <li>ERROR_NULL_ARGUMENT - if the parameter is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3578 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3579 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3580 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3581 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3582 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3583 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3584 * @see Transform |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3585 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3586 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3587 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3588 public void getTransform(Transform transform) { |
24 | 3589 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3590 if (transform is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3591 if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
24 | 3592 auto gdipGraphics = data.gdipGraphics; |
3593 if (gdipGraphics !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3594 Gdip.Graphics_GetTransform(gdipGraphics, transform.handle); |
25 | 3595 auto identity_ = identity(); |
3596 Gdip.Matrix_Invert(identity_); | |
3597 Gdip.Matrix_Multiply(transform.handle, identity_, Gdip.MatrixOrderAppend); | |
3598 Gdip.Matrix_delete(identity_); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3599 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3600 transform.setElements(1, 0, 0, 1, 0, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3601 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3602 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3603 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3604 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3605 * Returns <code>true</code> if this GC is drawing in the mode |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3606 * where the resulting color in the destination is the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3607 * <em>exclusive or</em> of the color values in the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3608 * and the destination, and <code>false</code> if it is |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3609 * drawing in the mode where the destination color is being |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3610 * replaced with the source color value. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3611 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3612 * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3613 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3614 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3615 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3616 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3617 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3618 public bool getXORMode() { |
24 | 3619 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3620 int rop2 = 0; |
117 | 3621 static if (OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3622 rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3623 OS.SetROP2 (handle, rop2); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3624 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3625 rop2 = OS.GetROP2(handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3626 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3627 return rop2 is OS.R2_XORPEN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3628 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3629 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3630 void initGdip() { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3631 data.device.checkGDIP(); |
24 | 3632 auto gdipGraphics = data.gdipGraphics; |
3633 if (gdipGraphics !is null) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3634 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3635 * Feature in GDI+. The GDI+ clipping set with Graphics->SetClip() |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3636 * is always intersected with the GDI clipping at the time the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3637 * GDI+ graphics is created. This means that the clipping |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3638 * cannot be reset. The fix is to clear the clipping before |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3639 * the GDI+ graphics is created and reset it afterwards. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3640 */ |
25 | 3641 auto hRgn = OS.CreateRectRgn(0, 0, 0, 0); |
3642 auto result = OS.GetClipRgn(handle, hRgn); | |
3643 static if (!OS.IsWinCE) { | |
3644 POINT pt; | |
3645 OS.GetWindowOrgEx (handle, &pt); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3646 OS.OffsetRgn (hRgn, pt.x, pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3647 } |
25 | 3648 OS.SelectClipRgn(handle, null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3649 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3650 /* |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3651 * Bug in GDI+. GDI+ does not work when the HDC layout is RTL. There |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3652 * are many issues like pixel corruption, but the most visible problem |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3653 * is that it does not have an effect when drawing to an bitmap. The |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3654 * fix is to clear the bit before creating the GDI+ graphics and install |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3655 * a mirroring matrix ourselves. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3656 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3657 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3658 OS.SetLayout(handle, OS.GetLayout(handle) & ~OS.LAYOUT_RTL); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3659 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3660 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3661 gdipGraphics = data.gdipGraphics = Gdip.Graphics_new(handle); |
24 | 3662 if (gdipGraphics is null) DWT.error(DWT.ERROR_NO_HANDLES); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3663 Gdip.Graphics_SetPageUnit(gdipGraphics, Gdip.UnitPixel); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3664 Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3665 if ((data.style & DWT.MIRRORED) !is 0) { |
25 | 3666 auto matrix = identity(); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3667 Gdip.Graphics_SetTransform(gdipGraphics, matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3668 Gdip.Matrix_delete(matrix); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3669 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3670 if (result is 1) setClipping(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3671 OS.DeleteObject(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3672 data.state = 0; |
24 | 3673 if (data.hPen !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3674 OS.SelectObject(handle, OS.GetStockObject(OS.NULL_PEN)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3675 OS.DeleteObject(data.hPen); |
24 | 3676 data.hPen = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3677 } |
24 | 3678 if (data.hBrush !is null) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3679 OS.SelectObject(handle, OS.GetStockObject(OS.NULL_BRUSH)); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3680 OS.DeleteObject(data.hBrush); |
24 | 3681 data.hBrush = null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3682 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3683 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3684 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
3685 Gdip.Matrix identity() { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3686 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3687 int width = 0; |
213 | 3688 int technology = OS.GetDeviceCaps(handle, OS.TECHNOLOGY); |
3689 if (technology is OS.DT_RASPRINTER) { | |
3690 width = OS.GetDeviceCaps(handle, OS.PHYSICALWIDTH); | |
3691 } else { | |
3692 Image image = data.image; | |
3693 if (image !is null) { | |
25 | 3694 BITMAP bm; |
3695 OS.GetObject(image.handle, BITMAP.sizeof, &bm); | |
213 | 3696 width = bm.bmWidth; |
3697 } else { | |
3698 HWND hwnd; | |
3699 static if( OS.IsWinCE ){ | |
3700 hwnd = data.hwnd; | |
3701 } | |
3702 else{ | |
3703 hwnd = OS.WindowFromDC(handle); | |
3704 } | |
3705 if (hwnd !is null) { | |
3706 RECT rect; | |
3707 OS.GetClientRect(hwnd, &rect); | |
3708 width = rect.right - rect.left; | |
3709 } else { | |
3710 auto hBitmap = OS.GetCurrentObject(handle, OS.OBJ_BITMAP); | |
3711 BITMAP bm; | |
3712 OS.GetObject(hBitmap, BITMAP.sizeof, &bm); | |
3713 width = bm.bmWidth; | |
3714 } | |
3715 } | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3716 } |
25 | 3717 POINT pt; |
117 | 3718 static if (!OS.IsWinCE) OS.GetWindowOrgEx (handle, &pt); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3719 return Gdip.Matrix_new(-1, 0, 0, 1, width + 2 * pt.x, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3720 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3721 return Gdip.Matrix_new(1, 0, 0, 1, 0, 0); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3722 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3723 |
197
184ab53b7785
Changes and fixes for jface
Frank Benoit <benoit@tionex.de>
parents:
194
diff
changeset
|
3724 void init_(Drawable drawable, GCData data, HDC hDC) { |
25 | 3725 auto foreground = data.foreground; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3726 if (foreground !is -1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3727 data.state &= ~(FOREGROUND | FOREGROUND_TEXT | PEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3728 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3729 data.foreground = OS.GetTextColor(hDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3730 } |
25 | 3731 auto background = data.background; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3732 if (background !is -1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3733 data.state &= ~(BACKGROUND | BACKGROUND_TEXT | BRUSH); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3734 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3735 data.background = OS.GetBkColor(hDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3736 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3737 data.state &= ~(NULL_BRUSH | NULL_PEN); |
213 | 3738 Font font = data.font; |
3739 if (font !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3740 data.state &= ~FONT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3741 } else { |
213 | 3742 data.font = Font.win32_new(device, OS.GetCurrentObject(hDC, OS.OBJ_FONT)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3743 } |
24 | 3744 auto hPalette = data.device.hPalette; |
3745 if (hPalette !is null) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3746 OS.SelectPalette(hDC, hPalette, true); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3747 OS.RealizePalette(hDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3748 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3749 Image image = data.image; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3750 if (image !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3751 data.hNullBitmap = OS.SelectObject(hDC, image.handle); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3752 image.memGC = this; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3753 } |
25 | 3754 auto layout = data.layout; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3755 if (layout !is -1) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3756 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3757 int flags = OS.GetLayout(hDC); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3758 if ((flags & OS.LAYOUT_RTL) !is (layout & OS.LAYOUT_RTL)) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3759 flags &= ~OS.LAYOUT_RTL; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3760 OS.SetLayout(hDC, flags | layout); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3761 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3762 if ((data.style & DWT.RIGHT_TO_LEFT) !is 0) data.style |= DWT.MIRRORED; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3763 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3764 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3765 this.drawable = drawable; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3766 this.data = data; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3767 handle = hDC; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3768 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3769 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3770 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3771 * Returns an integer hash code for the receiver. Any two |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3772 * objects that return <code>true</code> when passed to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3773 * <code>equals</code> must return the same value for this |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3774 * method. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3775 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3776 * @return the receiver's hash |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3777 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3778 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3779 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3780 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3781 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3782 * @see #equals |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3783 */ |
25 | 3784 public override hash_t toHash () { |
3785 return cast(hash_t)handle; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3786 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3787 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3788 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3789 * Returns <code>true</code> if the receiver has a clipping |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3790 * region set into it, and <code>false</code> otherwise. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3791 * If this method returns false, the receiver will draw on all |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3792 * available space in the destination. If it returns true, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3793 * it will draw only in the area that is covered by the region |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3794 * that can be accessed with <code>getClipping(region)</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3795 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3796 * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3797 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3798 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3799 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3800 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3801 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3802 public bool isClipped() { |
24 | 3803 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
213 | 3804 auto gdipGraphics = data.gdipGraphics; |
3805 if (gdipGraphics !is null) { | |
3806 auto rgn = Gdip.Region_new(); | |
3807 Gdip.Graphics_GetClip(data.gdipGraphics, rgn); | |
3808 bool isInfinite = Gdip.Region_IsInfinite(rgn, gdipGraphics) !is 0; | |
3809 Gdip.Region_delete(rgn); | |
3810 return !isInfinite; | |
3811 } | |
25 | 3812 auto region = OS.CreateRectRgn(0, 0, 0, 0); |
213 | 3813 int result = OS.GetClipRgn(handle, region); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3814 OS.DeleteObject(region); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3815 return result > 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3816 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3817 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3818 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3819 * Returns <code>true</code> if the GC has been disposed, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3820 * and <code>false</code> otherwise. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3821 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3822 * This method gets the dispose state for the GC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3823 * When a GC has been disposed, it is an error to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3824 * invoke any other method using the GC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3825 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3826 * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3827 */ |
48
9a64a7781bab
Added override and alias, first chunk. Thanks torhu for doing this patch.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
3828 override public bool isDisposed() { |
24 | 3829 return handle is null; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3830 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3831 |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
3832 float measureSpace(Gdip.Font font, Gdip.StringFormat format) { |
25 | 3833 Gdip.PointF pt; |
3834 Gdip.RectF bounds; | |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
3835 Gdip.Graphics_MeasureString(data.gdipGraphics, (" "w).ptr, 1, font, pt, format, bounds); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3836 return bounds.Width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3837 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3838 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3839 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3840 * Sets the receiver to always use the operating system's advanced graphics |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3841 * subsystem for all graphics operations if the argument is <code>true</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3842 * If the argument is <code>false</code>, the advanced graphics subsystem is |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3843 * no longer used, advanced graphics state is cleared and the normal graphics |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3844 * subsystem is used from now on. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3845 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3846 * Normally, the advanced graphics subsystem is invoked automatically when |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3847 * any one of the alpha, antialias, patterns, interpolation, paths, clipping |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3848 * or transformation operations in the receiver is requested. When the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3849 * is switched into advanced mode, the advanced graphics subsystem performs both |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3850 * advanced and normal graphics operations. Because the two subsystems are |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3851 * different, their output may differ. Switching to advanced graphics before |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3852 * any graphics operations are performed ensures that the output is consistent. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3853 * </p><p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3854 * Advanced graphics may not be installed for the operating system. In this |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3855 * case, this operation does nothing. Some operating system have only one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3856 * graphics subsystem, so switching from normal to advanced graphics does |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3857 * nothing. However, switching from advanced to normal graphics will always |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3858 * clear the advanced graphics state, even for operating systems that have |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3859 * only one graphics subsystem. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3860 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3861 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3862 * @param advanced the new advanced graphics state |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3863 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3864 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3865 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3866 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3867 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3868 * @see #setAlpha |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3869 * @see #setAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3870 * @see #setBackgroundPattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3871 * @see #setClipping(Path) |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3872 * @see #setForegroundPattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3873 * @see #setLineAttributes |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3874 * @see #setInterpolation |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3875 * @see #setTextAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3876 * @see #setTransform |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3877 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3878 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3879 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3880 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3881 public void setAdvanced(bool advanced) { |
24 | 3882 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3883 if (advanced && data.gdipGraphics !is null) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3884 if (advanced) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3885 try { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3886 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3887 } catch (DWTException e) {} |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3888 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3889 disposeGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3890 data.alpha = 0xFF; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3891 data.backgroundPattern = data.foregroundPattern = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3892 data.state = 0; |
25 | 3893 setClipping( cast(HRGN) null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3894 if ((data.style & DWT.MIRRORED) !is 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3895 OS.SetLayout(handle, OS.GetLayout(handle) | OS.LAYOUT_RTL); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3896 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3897 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3898 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3899 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3900 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3901 * Sets the receiver's anti-aliasing value to the parameter, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3902 * which must be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3903 * or <code>DWT.ON</code>. Note that this controls anti-aliasing for all |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3904 * <em>non-text drawing</em> operations. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3905 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3906 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3907 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3908 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3909 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3910 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3911 * @param antialias the anti-aliasing setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3912 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3913 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3914 * <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>DWT.DEFAULT</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3915 * <code>DWT.OFF</code> or <code>DWT.ON</code></li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3916 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3917 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3918 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3919 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3920 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3921 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3922 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3923 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3924 * @see #setTextAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3925 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3926 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3927 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3928 public void setAntialias(int antialias) { |
24 | 3929 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3930 if (data.gdipGraphics is null && antialias is DWT.DEFAULT) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3931 int mode = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3932 switch (antialias) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3933 case DWT.DEFAULT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3934 mode = Gdip.SmoothingModeDefault; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3935 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3936 case DWT.OFF: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3937 mode = Gdip.SmoothingModeNone; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3938 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3939 case DWT.ON: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3940 mode = Gdip.SmoothingModeAntiAlias; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3941 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3942 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3943 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3944 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3945 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3946 Gdip.Graphics_SetSmoothingMode(data.gdipGraphics, mode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3947 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3948 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3949 /** |
246 | 3950 * Sets the receiver's alpha value which must be |
3951 * between 0 (transparent) and 255 (opaque). | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3952 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3953 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3954 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3955 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3956 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3957 * @param alpha the alpha value |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3958 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3959 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3960 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3961 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3962 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3963 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3964 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3965 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3966 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3967 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3968 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3969 public void setAlpha(int alpha) { |
24 | 3970 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
3971 if (data.gdipGraphics is null && (alpha & 0xFF) is 0xFF) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3972 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3973 data.alpha = alpha & 0xFF; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3974 data.state &= ~(BACKGROUND | FOREGROUND); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3975 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3976 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3977 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3978 * Sets the background color. The background color is used |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3979 * for fill operations and as the background color when text |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3980 * is drawn. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3981 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3982 * @param color the new background color for the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3983 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3984 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3985 * <li>ERROR_NULL_ARGUMENT - if the color is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3986 * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3987 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3988 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3989 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3990 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3991 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3992 public void setBackground (Color color) { |
24 | 3993 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3994 if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3995 if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3996 if (data.backgroundPattern is null && data.background is color.handle) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3997 data.backgroundPattern = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3998 data.background = color.handle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3999 data.state &= ~(BACKGROUND | BACKGROUND_TEXT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4000 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4001 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4002 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4003 * Sets the background pattern. The default value is <code>null</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4004 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4005 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4006 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4007 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4008 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4009 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4010 * @param pattern the new background pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4011 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4012 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4013 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4014 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4015 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4016 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4017 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4018 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4019 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4020 * @see Pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4021 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4022 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4023 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4024 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4025 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4026 public void setBackgroundPattern (Pattern pattern) { |
24 | 4027 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4028 if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
24 | 4029 if (data.gdipGraphics is null && pattern is null) return; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4030 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4031 if (data.backgroundPattern is pattern) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4032 data.backgroundPattern = pattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4033 data.state &= ~BACKGROUND; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4034 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4035 |
25 | 4036 void setClipping(HRGN clipRgn) { |
4037 auto hRgn = clipRgn; | |
24 | 4038 auto gdipGraphics = data.gdipGraphics; |
4039 if (gdipGraphics !is null) { | |
4040 if (hRgn !is null) { | |
25 | 4041 auto region = Gdip.Region_new(hRgn); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4042 Gdip.Graphics_SetClip(gdipGraphics, region, Gdip.CombineModeReplace); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4043 Gdip.Region_delete(region); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4044 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4045 Gdip.Graphics_ResetClip(gdipGraphics); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4046 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4047 } else { |
25 | 4048 POINT pt; |
24 | 4049 if (hRgn !is null && !OS.IsWinCE) { |
25 | 4050 OS.GetWindowOrgEx(handle, &pt); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4051 OS.OffsetRgn(hRgn, -pt.x, -pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4052 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4053 OS.SelectClipRgn(handle, hRgn); |
24 | 4054 if (hRgn !is null && !OS.IsWinCE) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4055 OS.OffsetRgn(hRgn, pt.x, pt.y); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4056 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4057 } |
24 | 4058 if (hRgn !is null && hRgn !is clipRgn) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4059 OS.DeleteObject(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4060 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4061 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4062 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4063 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4064 * Sets the area of the receiver which can be changed |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4065 * by drawing operations to the rectangular area specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4066 * by the arguments. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4067 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4068 * @param x the x coordinate of the clipping rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4069 * @param y the y coordinate of the clipping rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4070 * @param width the width of the clipping rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4071 * @param height the height of the clipping rectangle |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4072 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4073 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4074 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4075 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4076 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4077 public void setClipping (int x, int y, int width, int height) { |
24 | 4078 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
25 | 4079 auto hRgn = OS.CreateRectRgn(x, y, x + width, y + height); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4080 setClipping(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4081 OS.DeleteObject(hRgn); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4082 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4083 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4084 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4085 * Sets the area of the receiver which can be changed |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4086 * by drawing operations to the path specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4087 * by the argument. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4088 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4089 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4090 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4091 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4092 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4093 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4094 * @param path the clipping path. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4095 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4096 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4097 * <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4098 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4099 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4100 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4101 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4102 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4103 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4104 * @see Path |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4105 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4106 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4107 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4108 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4109 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4110 public void setClipping (Path path) { |
24 | 4111 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4112 if (path !is null && path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
25 | 4113 setClipping(cast(HRGN)null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4114 if (path !is null) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4115 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4116 int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4117 Gdip.GraphicsPath_SetFillMode(path.handle, mode); |
213 | 4118 Gdip.Graphics_SetClipPath(data.gdipGraphics, path.handle); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4119 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4120 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4121 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4122 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4123 * Sets the area of the receiver which can be changed |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4124 * by drawing operations to the rectangular area specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4125 * by the argument. Specifying <code>null</code> for the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4126 * rectangle reverts the receiver's clipping area to its |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4127 * original value. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4128 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4129 * @param rect the clipping rectangle or <code>null</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4130 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4131 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4132 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4133 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4134 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4135 public void setClipping (Rectangle rect) { |
24 | 4136 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4137 if (rect is null) { |
25 | 4138 setClipping(cast(HRGN)null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4139 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4140 setClipping(rect.x, rect.y, rect.width, rect.height); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4141 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4142 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4143 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4144 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4145 * Sets the area of the receiver which can be changed |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4146 * by drawing operations to the region specified |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4147 * by the argument. Specifying <code>null</code> for the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4148 * region reverts the receiver's clipping area to its |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4149 * original value. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4150 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4151 * @param region the clipping region or <code>null</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4152 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4153 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4154 * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4155 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4156 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4157 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4158 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4159 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4160 public void setClipping (Region region) { |
24 | 4161 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4162 if (region !is null && region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
25 | 4163 setClipping(region !is null ? region.handle : cast(HRGN)null); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4164 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4165 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4166 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4167 * Sets the receiver's fill rule to the parameter, which must be one of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4168 * <code>DWT.FILL_EVEN_ODD</code> or <code>DWT.FILL_WINDING</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4169 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4170 * @param rule the new fill rule |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4171 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4172 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4173 * <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>DWT.FILL_EVEN_ODD</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4174 * or <code>DWT.FILL_WINDING</code></li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4175 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4176 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4177 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4178 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4179 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4180 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4181 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4182 public void setFillRule(int rule) { |
24 | 4183 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
117 | 4184 static if (OS.IsWinCE) return; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4185 int mode = OS.ALTERNATE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4186 switch (rule) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4187 case DWT.FILL_WINDING: mode = OS.WINDING; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4188 case DWT.FILL_EVEN_ODD: mode = OS.ALTERNATE; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4189 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4190 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4191 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4192 OS.SetPolyFillMode(handle, mode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4193 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4194 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4195 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4196 * Sets the font which will be used by the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4197 * to draw and measure text to the argument. If the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4198 * argument is null, then a default font appropriate |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4199 * for the platform will be used instead. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4200 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4201 * @param font the new font for the receiver, or null to indicate a default font |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4202 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4203 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4204 * <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4205 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4206 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4207 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4208 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4209 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4210 public void setFont (Font font) { |
24 | 4211 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4212 if (font !is null && font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
213 | 4213 data.font = font !is null ? font : data.device.systemFont; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4214 data.state &= ~FONT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4215 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4216 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4217 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4218 * Sets the foreground color. The foreground color is used |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4219 * for drawing operations including when text is drawn. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4220 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4221 * @param color the new foreground color for the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4222 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4223 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4224 * <li>ERROR_NULL_ARGUMENT - if the color is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4225 * <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4226 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4227 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4228 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4229 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4230 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4231 public void setForeground (Color color) { |
24 | 4232 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4233 if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4234 if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4235 if (data.foregroundPattern is null && color.handle is data.foreground) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4236 data.foregroundPattern = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4237 data.foreground = color.handle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4238 data.state &= ~(FOREGROUND | FOREGROUND_TEXT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4239 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4240 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4241 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4242 * Sets the foreground pattern. The default value is <code>null</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4243 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4244 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4245 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4246 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4247 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4248 * @param pattern the new foreground pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4249 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4250 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4251 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4252 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4253 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4254 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4255 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4256 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4257 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4258 * @see Pattern |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4259 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4260 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4261 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4262 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4263 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4264 public void setForegroundPattern (Pattern pattern) { |
24 | 4265 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4266 if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
24 | 4267 if (data.gdipGraphics is null && pattern is null) return; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4268 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4269 if (data.foregroundPattern is pattern) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4270 data.foregroundPattern = pattern; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4271 data.state &= ~FOREGROUND; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4272 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4273 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4274 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4275 * Sets the receiver's interpolation setting to the parameter, which |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4276 * must be one of <code>DWT.DEFAULT</code>, <code>DWT.NONE</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4277 * <code>DWT.LOW</code> or <code>DWT.HIGH</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4278 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4279 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4280 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4281 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4282 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4283 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4284 * @param interpolation the new interpolation setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4285 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4286 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4287 * <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>DWT.DEFAULT</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4288 * <code>DWT.NONE</code>, <code>DWT.LOW</code> or <code>DWT.HIGH</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4289 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4290 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4291 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4292 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4293 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4294 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4295 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4296 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4297 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4298 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4299 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4300 public void setInterpolation(int interpolation) { |
24 | 4301 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
4302 if (data.gdipGraphics is null && interpolation is DWT.DEFAULT) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4303 int mode = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4304 switch (interpolation) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4305 case DWT.DEFAULT: mode = Gdip.InterpolationModeDefault; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4306 case DWT.NONE: mode = Gdip.InterpolationModeNearestNeighbor; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4307 case DWT.LOW: mode = Gdip.InterpolationModeLowQuality; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4308 case DWT.HIGH: mode = Gdip.InterpolationModeHighQuality; break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4309 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4310 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4311 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4312 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4313 Gdip.Graphics_SetInterpolationMode(data.gdipGraphics, mode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4314 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4315 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4316 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4317 * Sets the receiver's line attributes. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4318 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4319 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4320 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4321 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4322 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4323 * @param attributes the line attributes |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4324 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4325 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4326 * <li>ERROR_NULL_ARGUMENT - if the attributes is null</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4327 * <li>ERROR_INVALID_ARGUMENT - if any of the line attributes is not valid</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4328 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4329 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4330 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4331 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4332 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4333 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4334 * @see LineAttributes |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4335 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4336 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4337 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4338 * @since 3.3 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4339 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4340 public void setLineAttributes(LineAttributes attributes) { |
24 | 4341 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4342 if (attributes is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4343 int mask = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4344 float lineWidth = attributes.width; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4345 if (lineWidth !is data.lineWidth) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4346 mask |= LINE_WIDTH | DRAW_OFFSET; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4347 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4348 int lineStyle = attributes.style; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4349 if (lineStyle !is data.lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4350 mask |= LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4351 switch (lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4352 case DWT.LINE_SOLID: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4353 case DWT.LINE_DASH: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4354 case DWT.LINE_DOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4355 case DWT.LINE_DASHDOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4356 case DWT.LINE_DASHDOTDOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4357 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4358 case DWT.LINE_CUSTOM: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4359 if (attributes.dash is null) lineStyle = DWT.LINE_SOLID; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4360 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4361 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4362 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4363 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4364 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4365 int join = attributes.join; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4366 if (join !is data.lineJoin) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4367 mask |= LINE_JOIN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4368 switch (join) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4369 case DWT.CAP_ROUND: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4370 case DWT.CAP_FLAT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4371 case DWT.CAP_SQUARE: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4372 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4373 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4374 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4375 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4376 } |
213 | 4377 int cap = attributes.cap; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4378 if (cap !is data.lineCap) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4379 mask |= LINE_CAP; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4380 switch (cap) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4381 case DWT.JOIN_MITER: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4382 case DWT.JOIN_ROUND: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4383 case DWT.JOIN_BEVEL: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4384 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4385 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4386 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4387 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4388 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4389 float[] dashes = attributes.dash; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4390 float[] lineDashes = data.lineDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4391 if (dashes !is null && dashes.length > 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4392 bool changed = lineDashes is null || lineDashes.length !is dashes.length; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4393 for (int i = 0; i < dashes.length; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4394 float dash = dashes[i]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4395 if (dash <= 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4396 if (!changed && lineDashes[i] !is dash) changed = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4397 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4398 if (changed) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4399 float[] newDashes = new float[dashes.length]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4400 System.arraycopy(dashes, 0, newDashes, 0, dashes.length); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4401 dashes = newDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4402 mask |= LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4403 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4404 dashes = lineDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4405 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4406 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4407 if (lineDashes !is null && lineDashes.length > 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4408 mask |= LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4409 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4410 dashes = lineDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4411 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4412 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4413 float dashOffset = attributes.dashOffset; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4414 if (dashOffset !is data.lineDashesOffset) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4415 mask |= LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4416 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4417 float miterLimit = attributes.miterLimit; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4418 if (miterLimit !is data.lineMiterLimit) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4419 mask |= LINE_MITERLIMIT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4420 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4421 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4422 if (mask is 0) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4423 data.lineWidth = lineWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4424 data.lineStyle = lineStyle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4425 data.lineCap = cap; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4426 data.lineJoin = join; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4427 data.lineDashes = dashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4428 data.lineDashesOffset = dashOffset; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4429 data.lineMiterLimit = miterLimit; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4430 data.state &= ~mask; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4431 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4432 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4433 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4434 * Sets the receiver's line cap style to the argument, which must be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4435 * of the constants <code>DWT.CAP_FLAT</code>, <code>DWT.CAP_ROUND</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4436 * or <code>DWT.CAP_SQUARE</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4437 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4438 * @param cap the cap style to be used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4439 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4440 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4441 * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4442 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4443 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4444 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4445 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4446 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4447 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4448 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4449 public void setLineCap(int cap) { |
24 | 4450 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4451 if (data.lineCap is cap) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4452 switch (cap) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4453 case DWT.CAP_ROUND: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4454 case DWT.CAP_FLAT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4455 case DWT.CAP_SQUARE: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4456 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4457 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4458 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4459 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4460 data.lineCap = cap; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4461 data.state &= ~LINE_CAP; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4462 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4463 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4464 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4465 * Sets the receiver's line dash style to the argument. The default |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4466 * value is <code>null</code>. If the argument is not <code>null</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4467 * the receiver's line style is set to <code>DWT.LINE_CUSTOM</code>, otherwise |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4468 * it is set to <code>DWT.LINE_SOLID</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4469 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4470 * @param dashes the dash style to be used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4471 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4472 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4473 * <li>ERROR_INVALID_ARGUMENT - if any of the values in the array is less than or equal 0</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4474 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4475 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4476 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4477 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4478 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4479 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4480 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4481 public void setLineDash(int[] dashes) { |
24 | 4482 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4483 float[] lineDashes = data.lineDashes; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4484 if (dashes !is null && dashes.length > 0) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4485 bool changed = data.lineStyle !is DWT.LINE_CUSTOM || lineDashes is null || lineDashes.length !is dashes.length; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4486 for (int i = 0; i < dashes.length; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4487 int dash = dashes[i]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4488 if (dash <= 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4489 if (!changed && lineDashes[i] !is dash) changed = true; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4490 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4491 if (!changed) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4492 data.lineDashes = new float[dashes.length]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4493 for (int i = 0; i < dashes.length; i++) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4494 data.lineDashes[i] = dashes[i]; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4495 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4496 data.lineStyle = DWT.LINE_CUSTOM; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4497 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4498 if (data.lineStyle is DWT.LINE_SOLID && (lineDashes is null || lineDashes.length is 0)) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4499 data.lineDashes = null; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4500 data.lineStyle = DWT.LINE_SOLID; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4501 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4502 data.state &= ~LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4503 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4504 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4505 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4506 * Sets the receiver's line join style to the argument, which must be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4507 * of the constants <code>DWT.JOIN_MITER</code>, <code>DWT.JOIN_ROUND</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4508 * or <code>DWT.JOIN_BEVEL</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4509 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4510 * @param join the join style to be used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4511 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4512 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4513 * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4514 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4515 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4516 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4517 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4518 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4519 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4520 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4521 public void setLineJoin(int join) { |
24 | 4522 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4523 if (data.lineJoin is join) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4524 switch (join) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4525 case DWT.JOIN_MITER: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4526 case DWT.JOIN_ROUND: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4527 case DWT.JOIN_BEVEL: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4528 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4529 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4530 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4531 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4532 data.lineJoin = join; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4533 data.state &= ~LINE_JOIN; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4534 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4535 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4536 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4537 * Sets the receiver's line style to the argument, which must be one |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4538 * of the constants <code>DWT.LINE_SOLID</code>, <code>DWT.LINE_DASH</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4539 * <code>DWT.LINE_DOT</code>, <code>DWT.LINE_DASHDOT</code> or |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4540 * <code>DWT.LINE_DASHDOTDOT</code>. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4541 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4542 * @param lineStyle the style to be used for drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4543 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4544 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4545 * <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4546 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4547 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4548 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4549 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4550 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4551 public void setLineStyle(int lineStyle) { |
24 | 4552 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4553 if (data.lineStyle is lineStyle) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4554 switch (lineStyle) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4555 case DWT.LINE_SOLID: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4556 case DWT.LINE_DASH: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4557 case DWT.LINE_DOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4558 case DWT.LINE_DASHDOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4559 case DWT.LINE_DASHDOTDOT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4560 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4561 case DWT.LINE_CUSTOM: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4562 if (data.lineDashes is null) lineStyle = DWT.LINE_SOLID; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4563 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4564 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4565 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4566 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4567 data.lineStyle = lineStyle; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4568 data.state &= ~LINE_STYLE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4569 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4570 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4571 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4572 * Sets the width that will be used when drawing lines |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4573 * for all of the figure drawing operations (that is, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4574 * <code>drawLine</code>, <code>drawRectangle</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4575 * <code>drawPolyline</code>, and so forth. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4576 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4577 * Note that line width of zero is used as a hint to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4578 * indicate that the fastest possible line drawing |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4579 * algorithms should be used. This means that the |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4580 * output may be different from line width one. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4581 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4582 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4583 * @param lineWidth the width of a line |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4584 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4585 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4586 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4587 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4588 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4589 public void setLineWidth(int lineWidth) { |
24 | 4590 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4591 if (data.lineWidth is lineWidth) return; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4592 data.lineWidth = lineWidth; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4593 data.state &= ~(LINE_WIDTH | DRAW_OFFSET); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4594 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4595 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4596 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4597 * If the argument is <code>true</code>, puts the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4598 * in a drawing mode where the resulting color in the destination |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4599 * is the <em>exclusive or</em> of the color values in the source |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4600 * and the destination, and if the argument is <code>false</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4601 * puts the receiver in a drawing mode where the destination color |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4602 * is replaced with the source color value. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4603 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4604 * Note that this mode in fundamentally unsupportable on certain |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4605 * platforms, notably Carbon (Mac OS X). Clients that want their |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4606 * code to run on all platforms need to avoid this method. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4607 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4608 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4609 * @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4610 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4611 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4612 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4613 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4614 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4615 * @deprecated this functionality is not supported on some platforms |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4616 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4617 public void setXORMode(bool xor) { |
24 | 4618 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4619 OS.SetROP2(handle, xor ? OS.R2_XORPEN : OS.R2_COPYPEN); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4620 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4621 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4622 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4623 * Sets the receiver's text anti-aliasing value to the parameter, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4624 * which must be one of <code>DWT.DEFAULT</code>, <code>DWT.OFF</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4625 * or <code>DWT.ON</code>. Note that this controls anti-aliasing only |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4626 * for all <em>text drawing</em> operations. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4627 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4628 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4629 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4630 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4631 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4632 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4633 * @param antialias the anti-aliasing setting |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4634 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4635 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4636 * <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>DWT.DEFAULT</code>, |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4637 * <code>DWT.OFF</code> or <code>DWT.ON</code></li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4638 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4639 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4640 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4641 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4642 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4643 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4644 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4645 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4646 * @see #setAntialias |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4647 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4648 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4649 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4650 public void setTextAntialias(int antialias) { |
24 | 4651 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
4652 if (data.gdipGraphics is null && antialias is DWT.DEFAULT) return; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4653 int textMode = 0; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4654 switch (antialias) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4655 case DWT.DEFAULT: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4656 textMode = Gdip.TextRenderingHintSystemDefault; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4657 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4658 case DWT.OFF: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4659 textMode = Gdip.TextRenderingHintSingleBitPerPixelGridFit; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4660 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4661 case DWT.ON: |
25 | 4662 int type; |
4663 OS.SystemParametersInfo(OS.SPI_GETFONTSMOOTHINGTYPE, 0, &type, 0); | |
4664 if (type is OS.FE_FONTSMOOTHINGCLEARTYPE) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4665 textMode = Gdip.TextRenderingHintClearTypeGridFit; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4666 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4667 textMode = Gdip.TextRenderingHintAntiAliasGridFit; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4668 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4669 break; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4670 default: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4671 DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4672 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4673 initGdip(); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4674 Gdip.Graphics_SetTextRenderingHint(data.gdipGraphics, textMode); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4675 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4676 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4677 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4678 * Sets the transform that is currently being used by the receiver. If |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4679 * the argument is <code>null</code>, the current transform is set to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4680 * the identity transform. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4681 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4682 * This operation requires the operating system's advanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4683 * graphics subsystem which may not be available on some |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4684 * platforms. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4685 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4686 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4687 * @param transform the transform to set |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4688 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4689 * @exception IllegalArgumentException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4690 * <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4691 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4692 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4693 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4694 * <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4695 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4696 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4697 * @see Transform |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4698 * @see #getAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4699 * @see #setAdvanced |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4700 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4701 * @since 3.1 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4702 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4703 public void setTransform(Transform transform) { |
24 | 4704 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4705 if (transform !is null && transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
24 | 4706 if (data.gdipGraphics is null && transform is null) return; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4707 initGdip(); |
25 | 4708 auto identity_ = identity(); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4709 if (transform !is null) { |
25 | 4710 Gdip.Matrix_Multiply(identity_, transform.handle, Gdip.MatrixOrderPrepend); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4711 } |
25 | 4712 Gdip.Graphics_SetTransform(data.gdipGraphics, identity_); |
4713 Gdip.Matrix_delete(identity_); | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4714 data.state &= ~DRAW_OFFSET; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4715 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4716 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4717 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4718 * Returns the extent of the given string. No tab |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4719 * expansion or carriage return processing will be performed. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4720 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4721 * The <em>extent</em> of a string is the width and height of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4722 * the rectangular area it would cover if drawn in a particular |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4723 * font (in this case, the current font in the receiver). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4724 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4725 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4726 * @param string the string to measure |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4727 * @return a point containing the extent of the string |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4728 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4729 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4730 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4731 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4732 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
4733 public Point stringExtent(String string) { |
24 | 4734 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
239
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
4735 // DWT externsion: allow null string |
43b41c7fe84a
work on allow null strings and arrays
Frank Benoit <benoit@tionex.de>
parents:
220
diff
changeset
|
4736 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4737 checkGC(FONT); |
24 | 4738 int length_ = string.length; |
4739 if (data.gdipGraphics !is null) { | |
25 | 4740 Gdip.PointF pt; |
4741 Gdip.RectF bounds; | |
4742 wchar* buffer; | |
24 | 4743 if (length_ !is 0) { |
25 | 4744 wchar[] wstr = StrToWCHARs( string ); |
4745 buffer = wstr.ptr; | |
4746 length_ = wstr.length; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4747 } else { |
25 | 4748 buffer = (" "w).ptr; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4749 } |
25 | 4750 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4751 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4752 if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4753 Gdip.StringFormat_SetFormatFlags(format, formatFlags); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
4754 Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4755 Gdip.StringFormat_delete(format); |
25 | 4756 return new Point(length_ is 0 ? 0 : Math.rndint(bounds.Width), Math.rndint(bounds.Height)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4757 } |
24 | 4758 SIZE size; |
4759 if (length_ is 0) { | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4760 // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size); |
24 | 4761 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4762 return new Point(0, size.cy); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4763 } else { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4764 // TCHAR buffer = new TCHAR (getCodePage(), string, false); |
25 | 4765 wchar[] wstr = StrToWCHARs( string ); |
4766 wchar* buffer = wstr.ptr; | |
4767 length_ = wstr.length; | |
24 | 4768 OS.GetTextExtentPoint32W(handle, buffer, length_, &size); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4769 return new Point(size.cx, size.cy); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4770 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4771 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4772 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4773 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4774 * Returns the extent of the given string. Tab expansion and |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4775 * carriage return processing are performed. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4776 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4777 * The <em>extent</em> of a string is the width and height of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4778 * the rectangular area it would cover if drawn in a particular |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4779 * font (in this case, the current font in the receiver). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4780 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4781 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4782 * @param string the string to measure |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4783 * @return a point containing the extent of the string |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4784 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4785 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4786 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4787 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4788 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
4789 public Point textExtent(String string) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4790 return textExtent(string, DWT.DRAW_DELIMITER | DWT.DRAW_TAB); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4791 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4792 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4793 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4794 * Returns the extent of the given string. Tab expansion, line |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4795 * delimiter and mnemonic processing are performed according to |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4796 * the specified flags, which can be a combination of: |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4797 * <dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4798 * <dt><b>DRAW_DELIMITER</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4799 * <dd>draw multiple lines</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4800 * <dt><b>DRAW_TAB</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4801 * <dd>expand tabs</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4802 * <dt><b>DRAW_MNEMONIC</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4803 * <dd>underline the mnemonic character</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4804 * <dt><b>DRAW_TRANSPARENT</b></dt> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4805 * <dd>transparent background</dd> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4806 * </dl> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4807 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4808 * The <em>extent</em> of a string is the width and height of |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4809 * the rectangular area it would cover if drawn in a particular |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4810 * font (in this case, the current font in the receiver). |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4811 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4812 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4813 * @param string the string to measure |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4814 * @param flags the flags specifying how to process the text |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4815 * @return a point containing the extent of the string |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4816 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4817 * @exception DWTException <ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4818 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4819 * </ul> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4820 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
4821 public Point textExtent(String string, int flags) { |
24 | 4822 if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
215
4436505b216f
Change behaviour of dwt.graphics.GC textExtend(): allow null for string argument
Frank Benoit <benoit@tionex.de>
parents:
213
diff
changeset
|
4823 //DWT_CHANGE: allow null string |
4436505b216f
Change behaviour of dwt.graphics.GC textExtend(): allow null for string argument
Frank Benoit <benoit@tionex.de>
parents:
213
diff
changeset
|
4824 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4825 checkGC(FONT); |
24 | 4826 if (data.gdipGraphics !is null) { |
25 | 4827 Gdip.PointF pt; |
4828 Gdip.RectF bounds; | |
4829 wchar* buffer; | |
24 | 4830 int length_ = string.length; |
4831 if (length_ !is 0) { | |
25 | 4832 wchar[] wstr = StrToWCHARs( string ); |
4833 buffer = wstr.ptr; | |
4834 length_ = wstr.length; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4835 } else { |
24 | 4836 buffer = (" "w).ptr; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4837 } |
25 | 4838 auto format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic()); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4839 int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4840 if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4841 Gdip.StringFormat_SetFormatFlags(format, formatFlags); |
24 | 4842 float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [measureSpace(data.gdipFont, format) * 8] : new float[1]; |
213 | 4843 Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs.ptr); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4844 Gdip.StringFormat_SetHotkeyPrefix(format, (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone); |
53
0405e18fec7f
Gdiplus implemented - test build of dwt.lib successful; updated graphics package as necessary
John Reimer <terminal.node@gmail.com
parents:
48
diff
changeset
|
4845 Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4846 Gdip.StringFormat_delete(format); |
25 | 4847 return new Point(length_ is 0 ? 0 : Math.rndint(bounds.Width), Math.rndint(bounds.Height)); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4848 } |
24 | 4849 if (string.length is 0) { |
25 | 4850 SIZE size; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4851 // OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size); |
25 | 4852 OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4853 return new Point(0, size.cy); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4854 } |
25 | 4855 RECT rect; |
4856 auto wstr = StrToTCHARs( string ); | |
4857 TCHAR* buffer = wstr.ptr; | |
4858 int length_ = wstr.length; | |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4859 int uFormat = OS.DT_LEFT | OS.DT_CALCRECT; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4860 if ((flags & DWT.DRAW_DELIMITER) is 0) uFormat |= OS.DT_SINGLELINE; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4861 if ((flags & DWT.DRAW_TAB) !is 0) uFormat |= OS.DT_EXPANDTABS; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4862 if ((flags & DWT.DRAW_MNEMONIC) is 0) uFormat |= OS.DT_NOPREFIX; |
25 | 4863 OS.DrawText(handle, buffer, length_, &rect, uFormat); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4864 return new Point(rect.right, rect.bottom); |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4865 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4866 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4867 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4868 * Returns a string containing a concise, human-readable |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4869 * description of the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4870 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4871 * @return a string representation of the receiver |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4872 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
4873 override public String toString () { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4874 if (isDisposed()) return "GC {*DISPOSED*}"; |
24 | 4875 return Format( "GC {{{}}", handle ); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4876 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4877 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4878 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4879 * Invokes platform specific functionality to allocate a new graphics context. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4880 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4881 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4882 * API for <code>GC</code>. It is marked public only so that it |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4883 * can be shared within the packages provided by DWT. It is not |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4884 * available on all platforms, and should never be called from |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4885 * application code. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4886 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4887 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4888 * @param drawable the Drawable for the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4889 * @param data the data for the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4890 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4891 * @return a new <code>GC</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4892 */ |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4893 public static GC win32_new(Drawable drawable, GCData data) { |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4894 GC gc = new GC(); |
24 | 4895 auto hDC = drawable.internal_new_GC(data); |
334
c49e17d48b76
Fix problems at GC run at main()'s end.
Frank Benoit <benoit@tionex.de>
parents:
249
diff
changeset
|
4896 gc.disposeChecking = false; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4897 gc.device = data.device; |
197
184ab53b7785
Changes and fixes for jface
Frank Benoit <benoit@tionex.de>
parents:
194
diff
changeset
|
4898 gc.init_(drawable, data, hDC); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4899 return gc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4900 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4901 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4902 /** |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4903 * Invokes platform specific functionality to wrap a graphics context. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4904 * <p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4905 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4906 * API for <code>GC</code>. It is marked public only so that it |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4907 * can be shared within the packages provided by DWT. It is not |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4908 * available on all platforms, and should never be called from |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4909 * application code. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4910 * </p> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4911 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4912 * @param hDC the Windows HDC. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4913 * @param data the data for the receiver. |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4914 * |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4915 * @return a new <code>GC</code> |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4916 */ |
24 | 4917 public static GC win32_new(HDC hDC, GCData data) { |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4918 GC gc = new GC(); |
334
c49e17d48b76
Fix problems at GC run at main()'s end.
Frank Benoit <benoit@tionex.de>
parents:
249
diff
changeset
|
4919 gc.disposeChecking = false; |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4920 gc.device = data.device; |
213 | 4921 data.style |= DWT.LEFT_TO_RIGHT; |
4922 if (OS.WIN32_VERSION >= OS.VERSION (4, 10)) { | |
4923 int flags = OS.GetLayout (hDC); | |
4924 if ((flags & OS.LAYOUT_RTL) !is 0) { | |
4925 data.style |= DWT.RIGHT_TO_LEFT | DWT.MIRRORED; | |
4926 } | |
4927 } | |
197
184ab53b7785
Changes and fixes for jface
Frank Benoit <benoit@tionex.de>
parents:
194
diff
changeset
|
4928 gc.init_(null, data, hDC); |
22
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4929 return gc; |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4930 } |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4931 |
5f2e72114476
Image in work, this revision does not compile
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4932 } |