Mercurial > projects > dwt-addons
comparison dwtx/draw2d/Cursors.d @ 98:95307ad235d9
Added Draw2d code, still work in progress
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 00:52:14 +0200 |
parents | |
children | 2d6540440fe6 |
comparison
equal
deleted
inserted
replaced
96:b492ba44e44d | 98:95307ad235d9 |
---|---|
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 dwtx.draw2d.Cursors; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import dwt.DWT; | |
18 import dwt.graphics.Cursor; | |
19 import dwtx.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 DWT#CURSOR_ARROW | |
87 */ | |
88 public static const Cursor ARROW; | |
89 /** | |
90 * @see DWT#CURSOR_SIZEN | |
91 */ | |
92 public static const Cursor SIZEN; | |
93 /** | |
94 * @see DWT#CURSOR_SIZENE | |
95 */ | |
96 public static const Cursor SIZENE; | |
97 /** | |
98 * @see DWT#CURSOR_SIZEE | |
99 */ | |
100 public static const Cursor SIZEE; | |
101 /** | |
102 * @see DWT#CURSOR_SIZESE | |
103 */ | |
104 public static const Cursor SIZESE; | |
105 /** | |
106 * @see DWT#CURSOR_SIZES | |
107 */ | |
108 public static const Cursor SIZES; | |
109 /** | |
110 * @see DWT#CURSOR_SIZESW | |
111 */ | |
112 public static const Cursor SIZESW; | |
113 /** | |
114 * @see DWT#CURSOR_SIZEW | |
115 */ | |
116 public static const Cursor SIZEW; | |
117 /** | |
118 * @see DWT#CURSOR_SIZENW | |
119 */ | |
120 public static const Cursor SIZENW; | |
121 /** | |
122 * @see DWT#CURSOR_APPSTARTING | |
123 */ | |
124 public static const Cursor APPSTARTING; | |
125 /** | |
126 * @see DWT#CURSOR_CROSS | |
127 */ | |
128 public static const Cursor CROSS; | |
129 /** | |
130 * @see DWT#CURSOR_HAND | |
131 */ | |
132 public static const Cursor HAND; | |
133 /** | |
134 * @see DWT#CURSOR_HELP | |
135 */ | |
136 public static const Cursor HELP; | |
137 /** | |
138 * @see DWT#CURSOR_IBEAM | |
139 */ | |
140 public static const Cursor IBEAM; | |
141 /** | |
142 * @see DWT#CURSOR_NO | |
143 */ | |
144 public static const Cursor NO; | |
145 /** | |
146 * @see DWT#CURSOR_SIZEALL | |
147 */ | |
148 public static const Cursor SIZEALL; | |
149 /** | |
150 * @see DWT#CURSOR_SIZENESW | |
151 */ | |
152 public static const Cursor SIZENESW; | |
153 /** | |
154 * @see DWT#CURSOR_SIZENWSE | |
155 */ | |
156 public static const Cursor SIZENWSE; | |
157 /** | |
158 * @see DWT#CURSOR_SIZEWE | |
159 */ | |
160 public static const Cursor SIZEWE; | |
161 /** | |
162 * @see DWT#CURSOR_SIZENS | |
163 */ | |
164 public static const Cursor SIZENS; | |
165 /** | |
166 * @see DWT#CURSOR_UPARROW | |
167 */ | |
168 public static const Cursor UPARROW; | |
169 /** | |
170 * @see DWT#CURSOR_WAIT | |
171 */ | |
172 public static const Cursor WAIT; | |
173 | |
174 static this() { | |
175 ARROW = new Cursor(null, DWT.CURSOR_ARROW); | |
176 SIZEN = new Cursor(null, DWT.CURSOR_SIZEN); | |
177 SIZENE = new Cursor(null, DWT.CURSOR_SIZENE); | |
178 SIZEE = new Cursor(null, DWT.CURSOR_SIZEE); | |
179 SIZESE = new Cursor(null, DWT.CURSOR_SIZESE); | |
180 SIZES = new Cursor(null, DWT.CURSOR_SIZES); | |
181 SIZESW = new Cursor(null, DWT.CURSOR_SIZESW); | |
182 SIZEW = new Cursor(null, DWT.CURSOR_SIZEW); | |
183 SIZENW = new Cursor(null, DWT.CURSOR_SIZENW); | |
184 SIZENS = new Cursor(null, DWT.CURSOR_SIZENS); | |
185 SIZEWE = new Cursor(null, DWT.CURSOR_SIZEWE); | |
186 APPSTARTING = new Cursor(null, DWT.CURSOR_APPSTARTING); | |
187 CROSS = new Cursor(null, DWT.CURSOR_CROSS); | |
188 HAND = new Cursor(null, DWT.CURSOR_HAND); | |
189 HELP = new Cursor(null, DWT.CURSOR_HELP); | |
190 IBEAM = new Cursor(null, DWT.CURSOR_IBEAM); | |
191 NO = new Cursor(null, DWT.CURSOR_NO); | |
192 SIZEALL = new Cursor(null, DWT.CURSOR_SIZEALL); | |
193 SIZENESW = new Cursor(null, DWT.CURSOR_SIZENESW); | |
194 SIZENWSE = new Cursor(null, DWT.CURSOR_SIZENWSE); | |
195 UPARROW = new Cursor(null, DWT.CURSOR_UPARROW); | |
196 WAIT = new Cursor(null, DWT.CURSOR_WAIT); | |
197 } | |
198 | |
199 } |