Mercurial > projects > dwt2
comparison org.eclipse.draw2d/src/org/eclipse/draw2d/Cursors.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.draw2d.Cursors; | |
14 | |
15 import java.lang.all; | |
16 | |
17 import org.eclipse.swt.SWT; | |
18 import org.eclipse.swt.graphics.Cursor; | |
19 import org.eclipse.draw2d.PositionConstants; | |
20 | |
21 /** | |
22 * A collection of cursors. | |
23 */ | |
24 public class Cursors { | |
25 | |
26 /** | |
27 * Returns the cursor corresponding to the given direction, defined in | |
28 * {@link PositionConstants}. Note that {@link #getDirectionalCursor(int, bool)} should | |
29 * be used for applications which want to run properly when running in a mirrored | |
30 * environment. The behavior is the same as calling {@link #getDirectionalCursor(int, | |
31 * bool) getDirectionalCursor(direction, false)}. | |
32 * | |
33 * @param direction the relative direction of the desired cursor | |
34 * @return The appropriate directional cursor | |
35 */ | |
36 public static Cursor getDirectionalCursor(int direction) { | |
37 return getDirectionalCursor(direction, false); | |
38 } | |
39 | |
40 /** | |
41 * Returns the cursor corresponding to the given direction and mirroring. The direction | |
42 * must be one of: | |
43 * <UL> | |
44 * <LI>{@link PositionConstants#NORTH} | |
45 * <LI>{@link PositionConstants#SOUTH} | |
46 * <LI>{@link PositionConstants#EAST} | |
47 * <LI>{@link PositionConstants#WEST} | |
48 * <LI>{@link PositionConstants#NORTH_EAST} | |
49 * <LI>{@link PositionConstants#NORTH_WEST} | |
50 * <LI>{@link PositionConstants#SOUTH_EAST} | |
51 * <LI>{@link PositionConstants#SOUTH_WEST} | |
52 * </UL> | |
53 * <P>The behavior is undefined for other values. If <code>isMirrored</code> is set to | |
54 * <code>true</code>, EAST and WEST will be inverted. | |
55 * @param direction the relative direction of the desired cursor | |
56 * @param isMirrored <code>true</code> if EAST and WEST should be inverted | |
57 * @return The appropriate directional cursor | |
58 */ | |
59 public static Cursor getDirectionalCursor(int direction, bool isMirrored) { | |
60 if (isMirrored && (direction & PositionConstants.EAST_WEST) !is 0) | |
61 direction = direction ^ PositionConstants.EAST_WEST; | |
62 switch (direction) { | |
63 case PositionConstants.NORTH : | |
64 return SIZEN; | |
65 case PositionConstants.SOUTH: | |
66 return SIZES; | |
67 case PositionConstants.EAST : | |
68 return SIZEE; | |
69 case PositionConstants.WEST: | |
70 return SIZEW; | |
71 case PositionConstants.SOUTH_EAST: | |
72 return SIZESE; | |
73 case PositionConstants.SOUTH_WEST: | |
74 return SIZESW; | |
75 case PositionConstants.NORTH_EAST: | |
76 return SIZENE; | |
77 case PositionConstants.NORTH_WEST: | |
78 return SIZENW; | |
79 default: | |
80 break; | |
81 } | |
82 return null; | |
83 } | |
84 | |
85 /** | |
86 * @see SWT#CURSOR_ARROW | |
87 */ | |
88 private static Cursor ARROW_; | |
89 public static Cursor ARROW(){ | |
90 if( !initStaticCtor_done ) initStaticCtor(); | |
91 return ARROW_; | |
92 } | |
93 | |
94 /** | |
95 * @see SWT#CURSOR_SIZEN | |
96 */ | |
97 private static Cursor SIZEN_; | |
98 public static Cursor SIZEN(){ | |
99 if( !initStaticCtor_done ) initStaticCtor(); | |
100 return SIZEN_; | |
101 } | |
102 | |
103 /** | |
104 * @see SWT#CURSOR_SIZENE | |
105 */ | |
106 private static Cursor SIZENE_; | |
107 public static Cursor SIZENE(){ | |
108 if( !initStaticCtor_done ) initStaticCtor(); | |
109 return SIZENE_; | |
110 } | |
111 | |
112 /** | |
113 * @see SWT#CURSOR_SIZEE | |
114 */ | |
115 private static Cursor SIZEE_; | |
116 public static Cursor SIZEE(){ | |
117 if( !initStaticCtor_done ) initStaticCtor(); | |
118 return SIZEE_; | |
119 } | |
120 | |
121 /** | |
122 * @see SWT#CURSOR_SIZESE | |
123 */ | |
124 private static Cursor SIZESE_; | |
125 public static Cursor SIZESE(){ | |
126 if( !initStaticCtor_done ) initStaticCtor(); | |
127 return SIZESE_; | |
128 } | |
129 | |
130 /** | |
131 * @see SWT#CURSOR_SIZES | |
132 */ | |
133 private static Cursor SIZES_; | |
134 public static Cursor SIZES(){ | |
135 if( !initStaticCtor_done ) initStaticCtor(); | |
136 return SIZES_; | |
137 } | |
138 | |
139 /** | |
140 * @see SWT#CURSOR_SIZESW | |
141 */ | |
142 private static Cursor SIZESW_; | |
143 public static Cursor SIZESW(){ | |
144 if( !initStaticCtor_done ) initStaticCtor(); | |
145 return SIZESW_; | |
146 } | |
147 | |
148 /** | |
149 * @see SWT#CURSOR_SIZEW | |
150 */ | |
151 private static Cursor SIZEW_; | |
152 public static Cursor SIZEW(){ | |
153 if( !initStaticCtor_done ) initStaticCtor(); | |
154 return SIZEW_; | |
155 } | |
156 | |
157 /** | |
158 * @see SWT#CURSOR_SIZENW | |
159 */ | |
160 private static Cursor SIZENW_; | |
161 public static Cursor SIZENW(){ | |
162 if( !initStaticCtor_done ) initStaticCtor(); | |
163 return SIZENW_; | |
164 } | |
165 | |
166 /** | |
167 * @see SWT#CURSOR_APPSTARTING | |
168 */ | |
169 private static Cursor APPSTARTING_; | |
170 public static Cursor APPSTARTING(){ | |
171 if( !initStaticCtor_done ) initStaticCtor(); | |
172 return APPSTARTING_; | |
173 } | |
174 | |
175 /** | |
176 * @see SWT#CURSOR_CROSS | |
177 */ | |
178 private static Cursor CROSS_; | |
179 public static Cursor CROSS(){ | |
180 if( !initStaticCtor_done ) initStaticCtor(); | |
181 return CROSS_; | |
182 } | |
183 | |
184 /** | |
185 * @see SWT#CURSOR_HAND | |
186 */ | |
187 private static Cursor HAND_; | |
188 public static Cursor HAND(){ | |
189 if( !initStaticCtor_done ) initStaticCtor(); | |
190 return HAND_; | |
191 } | |
192 | |
193 /** | |
194 * @see SWT#CURSOR_HELP | |
195 */ | |
196 private static Cursor HELP_; | |
197 public static Cursor HELP(){ | |
198 if( !initStaticCtor_done ) initStaticCtor(); | |
199 return HELP_; | |
200 } | |
201 | |
202 /** | |
203 * @see SWT#CURSOR_IBEAM | |
204 */ | |
205 private static Cursor IBEAM_; | |
206 public static Cursor IBEAM(){ | |
207 if( !initStaticCtor_done ) initStaticCtor(); | |
208 return IBEAM_; | |
209 } | |
210 | |
211 /** | |
212 * @see SWT#CURSOR_NO | |
213 */ | |
214 private static Cursor NO_; | |
215 public static Cursor NO(){ | |
216 if( !initStaticCtor_done ) initStaticCtor(); | |
217 return NO_; | |
218 } | |
219 | |
220 /** | |
221 * @see SWT#CURSOR_SIZEALL | |
222 */ | |
223 private static Cursor SIZEALL_; | |
224 public static Cursor SIZEALL(){ | |
225 if( !initStaticCtor_done ) initStaticCtor(); | |
226 return SIZEALL_; | |
227 } | |
228 | |
229 /** | |
230 * @see SWT#CURSOR_SIZENESW | |
231 */ | |
232 private static Cursor SIZENESW_; | |
233 public static Cursor SIZENESW(){ | |
234 if( !initStaticCtor_done ) initStaticCtor(); | |
235 return SIZENESW_; | |
236 } | |
237 | |
238 /** | |
239 * @see SWT#CURSOR_SIZENWSE | |
240 */ | |
241 private static Cursor SIZENWSE_; | |
242 public static Cursor SIZENWSE(){ | |
243 if( !initStaticCtor_done ) initStaticCtor(); | |
244 return SIZENWSE_; | |
245 } | |
246 | |
247 /** | |
248 * @see SWT#CURSOR_SIZEWE | |
249 */ | |
250 private static Cursor SIZEWE_; | |
251 public static Cursor SIZEWE(){ | |
252 if( !initStaticCtor_done ) initStaticCtor(); | |
253 return SIZEWE_; | |
254 } | |
255 | |
256 /** | |
257 * @see SWT#CURSOR_SIZENS | |
258 */ | |
259 private static Cursor SIZENS_; | |
260 public static Cursor SIZENS(){ | |
261 if( !initStaticCtor_done ) initStaticCtor(); | |
262 return SIZENS_; | |
263 } | |
264 | |
265 /** | |
266 * @see SWT#CURSOR_UPARROW | |
267 */ | |
268 private static Cursor UPARROW_; | |
269 public static Cursor UPARROW(){ | |
270 if( !initStaticCtor_done ) initStaticCtor(); | |
271 return UPARROW_; | |
272 } | |
273 | |
274 /** | |
275 * @see SWT#CURSOR_WAIT | |
276 */ | |
277 private static Cursor WAIT_; | |
278 public static Cursor WAIT(){ | |
279 if( !initStaticCtor_done ) initStaticCtor(); | |
280 return WAIT_; | |
281 } | |
282 | |
283 private static bool initStaticCtor_done = false; | |
284 private static void initStaticCtor() { | |
285 synchronized(Cursor.classinfo){ | |
286 if(!initStaticCtor_done){ | |
287 ARROW_ = new Cursor(null, SWT.CURSOR_ARROW); | |
288 SIZEN_ = new Cursor(null, SWT.CURSOR_SIZEN); | |
289 SIZENE_ = new Cursor(null, SWT.CURSOR_SIZENE); | |
290 SIZEE_ = new Cursor(null, SWT.CURSOR_SIZEE); | |
291 SIZESE_ = new Cursor(null, SWT.CURSOR_SIZESE); | |
292 SIZES_ = new Cursor(null, SWT.CURSOR_SIZES); | |
293 SIZESW_ = new Cursor(null, SWT.CURSOR_SIZESW); | |
294 SIZEW_ = new Cursor(null, SWT.CURSOR_SIZEW); | |
295 SIZENW_ = new Cursor(null, SWT.CURSOR_SIZENW); | |
296 SIZENS_ = new Cursor(null, SWT.CURSOR_SIZENS); | |
297 SIZEWE_ = new Cursor(null, SWT.CURSOR_SIZEWE); | |
298 APPSTARTING_ = new Cursor(null, SWT.CURSOR_APPSTARTING); | |
299 CROSS_ = new Cursor(null, SWT.CURSOR_CROSS); | |
300 HAND_ = new Cursor(null, SWT.CURSOR_HAND); | |
301 HELP_ = new Cursor(null, SWT.CURSOR_HELP); | |
302 IBEAM_ = new Cursor(null, SWT.CURSOR_IBEAM); | |
303 NO_ = new Cursor(null, SWT.CURSOR_NO); | |
304 SIZEALL_ = new Cursor(null, SWT.CURSOR_SIZEALL); | |
305 SIZENESW_ = new Cursor(null, SWT.CURSOR_SIZENESW); | |
306 SIZENWSE_ = new Cursor(null, SWT.CURSOR_SIZENWSE); | |
307 UPARROW_ = new Cursor(null, SWT.CURSOR_UPARROW); | |
308 WAIT_ = new Cursor(null, SWT.CURSOR_WAIT); | |
309 initStaticCtor_done = true; | |
310 } | |
311 } | |
312 } | |
313 | |
314 } |