Mercurial > projects > dynamin
annotate dynamin/gui/x_cursor.d @ 113:4636a64afabc default tip
Add reverse() function.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 19 Jan 2013 21:08:52 -0600 |
parents | 73060bc3f004 |
children |
rev | line source |
---|---|
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
1 |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
2 /* |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
3 * Copyright Jordan Miner |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
4 * |
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/. |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
8 * |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
23
diff
changeset
|
9 */ |
0 | 10 |
11 module dynamin.gui.x_cursor; | |
12 | |
13 public import tango.io.Stdout; | |
14 public import dynamin.gui.control; | |
15 | |
16 template CursorBackend() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
17 XCursor _handle; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
18 this(XCursor h) { |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
19 _handle = h; |
0 | 20 } |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
21 public XCursor handle() { return _handle; } |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
22 static: |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
23 Cursor getCursor(uint shape) { |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
24 return new Cursor(XCreateFontCursor(display, shape)); |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
25 } |
0 | 26 Cursor backend_None() { |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
27 auto p = XCreateBitmapFromData(display, msgWin, |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
28 "\0\0\0\0\0\0\0\0", 1, 1); |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
29 XColor color; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
30 return new Cursor(XCreatePixmapCursor(display, p, p, &color, &color, |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
31 1, 1)); |
0 | 32 } |
33 Cursor backend_Arrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
34 return getCursor(XC_left_ptr); |
0 | 35 } |
36 Cursor backend_WaitArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
37 return getCursor(XC_watch); |
0 | 38 } |
39 Cursor backend_Wait() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
40 return getCursor(XC_watch); |
0 | 41 } |
42 Cursor backend_Text() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
43 return getCursor(XC_xterm); |
0 | 44 } |
45 Cursor backend_Hand() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
46 return getCursor(XC_hand2); |
0 | 47 } |
48 Cursor backend_Move() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
49 return getCursor(XC_fleur); |
0 | 50 } |
51 Cursor backend_ResizeHoriz() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
52 return getCursor(XC_left_side); |
0 | 53 } |
54 Cursor backend_ResizeVert() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
55 return getCursor(XC_top_side); |
0 | 56 } |
57 Cursor backend_ResizeBackslash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
58 return getCursor(XC_top_left_corner); |
0 | 59 } |
60 Cursor backend_ResizeSlash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
61 return getCursor(XC_top_right_corner); |
0 | 62 } |
63 Cursor backend_Drag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
64 return getCursor(XC_fleur); // not the best |
0 | 65 } |
66 Cursor backend_InvalidDrag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
67 return getCursor(XC_fleur); // bad, but what Linux does |
0 | 68 } |
69 Cursor backend_ReversedArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
70 return getCursor(XC_right_ptr); |
0 | 71 } |
72 Cursor backend_Crosshair() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
73 return getCursor(XC_crosshair); |
0 | 74 } |
75 } | |
76 |