Mercurial > projects > dynamin
annotate dynamin/gui/cursor.d @ 103:73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Tue, 15 May 2012 22:06:02 -0500 |
parents | d55b5b998412 |
children |
rev | line source |
---|---|
0 | 1 |
2 /* | |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
3 * Copyright Jordan Miner |
0 | 4 * |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
5 * This Source Code Form is subject to the terms of the Mozilla Public |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
6 * License, v. 2.0. If a copy of the MPL was not distributed with this |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
0 | 8 * |
9 */ | |
10 | |
11 module dynamin.gui.cursor; | |
12 | |
13 import tango.io.Stdout; | |
14 import dynamin.gui_backend; | |
15 | |
16 /// | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
17 final class Cursor { |
0 | 18 private: |
19 mixin CursorBackend; | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
20 static: |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
21 Cursor _none = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
22 Cursor _arrow = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
23 Cursor _waitArrow = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
24 Cursor _wait = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
25 Cursor _text = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
26 Cursor _hand = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
27 Cursor _move = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
28 Cursor _resizeHoriz = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
29 Cursor _resizeVert = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
30 Cursor _resizeBackslash = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
31 Cursor _resizeSlash = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
32 Cursor _drag = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
33 Cursor _invalidDrag = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
34 Cursor _reversedArrow = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
35 Cursor _crosshair = null; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
36 // handles caching for backends |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
37 Cursor maybeLoad(Cursor function() loadCursor, ref Cursor cache) { |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
38 if(cache is null) |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
39 cache = loadCursor(); |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
40 return cache; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
41 } |
0 | 42 public: |
43 /** | |
44 * Gets a blank cursor used for an activity, such as typing, with which | |
45 * the cursor may interfere. | |
46 */ | |
47 Cursor None() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
48 return maybeLoad(&backend_None, _none); |
0 | 49 } |
50 /** | |
51 * Gets the cursor used normally. | |
52 * | |
53 * The appearance with Windows XP: | |
54 * | |
55 * $(IMAGE ../web/example_arrow_cursor.png) | |
56 */ | |
57 Cursor Arrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
58 return maybeLoad(&backend_Arrow, _arrow); |
0 | 59 } |
60 /** | |
61 * Gets the cursor used when the computer is accomplishing some | |
62 * task that does not prevent the user from continuing work. | |
63 * | |
64 * The appearance with Windows XP: | |
65 * | |
66 * $(IMAGE ../web/example_wait_arrow_cursor.png) | |
67 */ | |
68 Cursor WaitArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
69 return maybeLoad(&backend_WaitArrow, _waitArrow); |
0 | 70 } |
71 /** | |
72 * Gets the cursor used when the computer is accomplishing some | |
73 * task that prevents the user from continuing work. | |
74 * | |
75 * The appearance with Windows XP: | |
76 * | |
77 * $(IMAGE ../web/example_wait_cursor.png) | |
78 */ | |
79 Cursor Wait() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
80 return maybeLoad(&backend_Wait, _wait); |
0 | 81 } |
82 /** | |
83 * Gets the cursor used when the mouse is over selectable text. | |
84 * In text that supports dragging, this should not be used when the | |
85 * mouse is over already selected text, as the text is not then | |
86 * selectable, but draggable. | |
87 * | |
88 * The appearance with Windows XP: | |
89 * | |
90 * $(IMAGE ../web/example_text_cursor.png) | |
91 */ | |
92 Cursor Text() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
93 return maybeLoad(&backend_Text, _text); |
0 | 94 } |
95 /** | |
96 * Gets the cursor used when the mouse is over a link. | |
97 * | |
98 * The appearance with Windows XP: | |
99 * | |
100 * $(IMAGE ../web/example_hand_cursor.png) | |
101 */ | |
102 Cursor Hand() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
103 return maybeLoad(&backend_Hand, _hand); |
0 | 104 } |
105 /** | |
106 * Gets the cursor used when moving something. | |
107 * | |
108 * The appearance with Windows XP: | |
109 * | |
110 * $(IMAGE ../web/example_move_cursor.png) | |
111 */ | |
112 Cursor Move() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
113 return maybeLoad(&backend_Move, _move); |
0 | 114 } |
115 /** | |
116 * Gets the cursor used when resizing the left or right | |
117 * sides of something. | |
118 * | |
119 * The appearance with Windows XP: | |
120 * | |
121 * $(IMAGE ../web/example_resize_horiz_cursor.png) | |
122 */ | |
123 Cursor ResizeHoriz() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
124 return maybeLoad(&backend_ResizeHoriz, _resizeHoriz); |
0 | 125 } |
126 /** | |
127 * Gets the cursor used when resizing the top or bottom | |
128 * sides of something. | |
129 * | |
130 * The appearance with Windows XP: | |
131 * | |
132 * $(IMAGE ../web/example_resize_vert_cursor.png) | |
133 */ | |
134 Cursor ResizeVert() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
135 return maybeLoad(&backend_ResizeVert, _resizeVert); |
0 | 136 } |
137 /** | |
138 * Gets the cursor used when resizing the top-left or bottom-right | |
139 * corners of something. | |
140 * | |
141 * The appearance with Windows XP: | |
142 * | |
143 * $(IMAGE ../web/example_resize_backslash_cursor.png) | |
144 */ | |
145 Cursor ResizeBackslash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
146 return maybeLoad(&backend_ResizeBackslash, _resizeBackslash); |
0 | 147 } |
148 /** | |
149 * Gets the cursor used when resizing the bottom-left or top-right | |
150 * corners of something. | |
151 * | |
152 * The appearance with Windows XP: | |
153 * | |
154 * $(IMAGE ../web/example_resize_slash_cursor.png) | |
155 */ | |
156 Cursor ResizeSlash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
157 return maybeLoad(&backend_ResizeSlash, _resizeSlash); |
0 | 158 } |
159 /** | |
160 * Gets the cursor used when the mouse is over something that | |
161 * will accept what has been dragged. | |
162 * | |
163 * The appearance with Windows XP: | |
164 * | |
165 * $(IMAGE ../web/example_drag_cursor.png) | |
166 */ | |
167 Cursor Drag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
168 return maybeLoad(&backend_Drag, _drag); |
0 | 169 } |
170 /** | |
171 * Gets the cursor used when the mouse is over something that | |
172 * will not accept what has been dragged. | |
173 * | |
174 * The appearance with Windows XP: | |
175 * | |
176 * $(IMAGE ../web/example_invalid_drag_cursor.png) | |
177 */ | |
178 Cursor InvalidDrag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
179 return maybeLoad(&backend_InvalidDrag, _invalidDrag); |
0 | 180 } |
181 /** | |
182 * Gets the cursor used when the mouse is over a gutter that | |
183 * will select a line of text when clicked. | |
184 * | |
185 * The appearance with Windows XP: | |
186 * | |
187 * $(IMAGE ../web/example_reversed_arrow_cursor.png) | |
188 */ | |
189 Cursor ReversedArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
190 return maybeLoad(&backend_ReversedArrow, _reversedArrow); |
0 | 191 } |
192 /** | |
193 * Gets the cursor that is sometimes used for selecting. | |
194 * | |
195 * The appearance with Windows XP: | |
196 * | |
197 * $(IMAGE ../web/example_crosshair_cursor.png) | |
198 */ | |
199 Cursor Crosshair() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
200 return maybeLoad(&backend_Crosshair, _crosshair); |
0 | 201 } |
202 } | |
203 |