Mercurial > projects > dynamin
annotate dynamin/gui/x_cursor.d @ 55:c138461bf845
Add focusing and other changes that are related
like descendantAdded/Removed events, Window.activated event, and updating List.
Window.state was also added, even though focusing does not depend on it.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 08 Aug 2009 15:42:27 -0500 |
parents | d55b5b998412 |
children | 73060bc3f004 |
rev | line source |
---|---|
0 | 1 // Written in the D programming language |
2 // www.digitalmars.com/d/ | |
3 | |
4 module dynamin.gui.x_cursor; | |
5 | |
6 public import tango.io.Stdout; | |
7 public import dynamin.gui.control; | |
8 | |
9 template CursorBackend() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
10 XCursor _handle; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
11 this(XCursor h) { |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
12 _handle = h; |
0 | 13 } |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
14 public XCursor handle() { return _handle; } |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
15 static: |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
16 Cursor getCursor(uint shape) { |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
17 return new Cursor(XCreateFontCursor(display, shape)); |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
18 } |
0 | 19 Cursor backend_None() { |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
20 auto p = XCreateBitmapFromData(display, msgWin, |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
21 "\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
|
22 XColor color; |
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
23 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
|
24 1, 1)); |
0 | 25 } |
26 Cursor backend_Arrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
27 return getCursor(XC_left_ptr); |
0 | 28 } |
29 Cursor backend_WaitArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
30 return getCursor(XC_watch); |
0 | 31 } |
32 Cursor backend_Wait() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
33 return getCursor(XC_watch); |
0 | 34 } |
35 Cursor backend_Text() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
36 return getCursor(XC_xterm); |
0 | 37 } |
38 Cursor backend_Hand() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
39 return getCursor(XC_hand2); |
0 | 40 } |
41 Cursor backend_Move() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
42 return getCursor(XC_fleur); |
0 | 43 } |
44 Cursor backend_ResizeHoriz() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
45 return getCursor(XC_left_side); |
0 | 46 } |
47 Cursor backend_ResizeVert() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
48 return getCursor(XC_top_side); |
0 | 49 } |
50 Cursor backend_ResizeBackslash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
51 return getCursor(XC_top_left_corner); |
0 | 52 } |
53 Cursor backend_ResizeSlash() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
54 return getCursor(XC_top_right_corner); |
0 | 55 } |
56 Cursor backend_Drag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
57 return getCursor(XC_fleur); // not the best |
0 | 58 } |
59 Cursor backend_InvalidDrag() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
60 return getCursor(XC_fleur); // bad, but what Linux does |
0 | 61 } |
62 Cursor backend_ReversedArrow() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
63 return getCursor(XC_right_ptr); |
0 | 64 } |
65 Cursor backend_Crosshair() { | |
23
d55b5b998412
Implement built-in mouse cursors with X.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
66 return getCursor(XC_crosshair); |
0 | 67 } |
68 } | |
69 |