73
|
1 module doodle.gtk.events;
|
|
2
|
|
3 public {
|
|
4 import doodle.tk.events;
|
|
5 }
|
|
6
|
|
7 private {
|
|
8 import doodle.gtk.conversions;
|
|
9
|
|
10 import core.stdc.string : strlen;
|
|
11 }
|
|
12
|
|
13
|
|
14 // Functions for creating the events
|
|
15
|
|
16 /*
|
|
17 public struct GdkEventButton {
|
|
18 GdkEventType type;
|
|
19 GdkWindow *window;
|
|
20 byte sendEvent;
|
|
21 uint time;
|
|
22 double x;
|
|
23 double y;
|
|
24 double *axes;
|
|
25 uint state;
|
|
26 uint button;
|
|
27 GdkDevice *device;
|
|
28 double xRoot, yRoot;
|
|
29 }
|
|
30 */
|
|
31
|
77
|
32 ButtonEvent makeButtonEvent(const GdkEventButton * event, in ScreenModel screenModel) {
|
|
33 Point screenPoint = Point(event.x + 0.5, screenModel.viewBoundsScreen.h - (event.y + 0.5));
|
|
34 Point modelPoint = screenModel.screenToModel(screenPoint);
|
73
|
35 return new ButtonEvent(gtk2tkButtonAction(event.type),
|
|
36 gtk2tkButtonName(event.button),
|
77
|
37 screenPoint, modelPoint, gtk2tkMask(event.state));
|
73
|
38 }
|
|
39
|
|
40 /*
|
|
41 public struct GdkEventMotion {
|
|
42 GdkEventType type;
|
|
43 GdkWindow *window;
|
|
44 byte sendEvent;
|
|
45 uint time;
|
|
46 double x;
|
|
47 double y;
|
|
48 double *axes;
|
|
49 uint state;
|
|
50 short isHint;
|
|
51 GdkDevice *device;
|
|
52 double xRoot, yRoot;
|
|
53 }
|
|
54 */
|
|
55
|
77
|
56 MotionEvent makeMotionEvent(const GdkEventMotion * event, in ScreenModel screenModel) {
|
|
57 Point screenPoint = Point(event.x + 0.5, screenModel.viewBoundsScreen.h - (event.y + 0.5));
|
|
58 Point modelPoint = screenModel.screenToModel(screenPoint);
|
73
|
59
|
77
|
60 return new MotionEvent(screenPoint, modelPoint, gtk2tkMask(event.state));
|
73
|
61 }
|
|
62
|
|
63 /*
|
|
64 public struct GdkEventKey {
|
|
65 GdkEventType type;
|
|
66 GdkWindow *window;
|
|
67 byte sendEvent;
|
|
68 uint time;
|
|
69 uint state;
|
|
70 uint keyval;
|
|
71 int length;
|
|
72 char *string;
|
|
73 ushort hardwareKeycode;
|
|
74 ubyte group;
|
|
75 uint bitfield0;
|
|
76 uint isModifier : 1;
|
|
77 }
|
|
78 */
|
|
79
|
77
|
80 KeyEvent makeKeyEvent(const GdkEventKey * event, in ScreenModel screenModel) {
|
73
|
81 return new KeyEvent(event.string[0..strlen(event.string)].idup,
|
|
82 event.keyval,
|
|
83 gtk2tkMask(event.state));
|
|
84 }
|
|
85
|
|
86 /*
|
|
87 public struct GdkEventScroll {
|
|
88 GdkEventType type;
|
|
89 GdkWindow *window;
|
|
90 byte sendEvent;
|
|
91 uint time;
|
|
92 double x;
|
|
93 double y;
|
|
94 uint state;
|
|
95 GdkScrollDirection direction;
|
|
96 GdkDevice *device;
|
|
97 double xRoot, yRoot;
|
|
98 }
|
|
99 */
|
|
100
|
77
|
101 ScrollEvent makeScrollEvent(const GdkEventScroll * event, in ScreenModel screenModel) {
|
|
102 Point screenPoint = Point(event.x + 0.5, screenModel.viewBoundsScreen.h - (event.y + 0.5));
|
|
103 Point modelPoint = screenModel.screenToModel(screenPoint);
|
73
|
104 return new ScrollEvent(gtk2tkDirection(event.direction),
|
77
|
105 screenPoint,
|
73
|
106 modelPoint,
|
|
107 gtk2tkMask(event.state));
|
|
108 }
|
|
109
|
|
110 /*
|
|
111 public enum GdkCrossingMode {
|
|
112 NORMAL,
|
|
113 GRAB,
|
|
114 UNGRAB,
|
|
115 GTK_GRAB,
|
|
116 GTK_UNGRAB,
|
|
117 STATE_CHANGED
|
|
118 }
|
|
119
|
|
120 public struct GdkEventCrossing {
|
|
121 GdkEventType type;
|
|
122 GdkWindow *window;
|
|
123 byte sendEvent;
|
|
124 GdkWindow *subwindow;
|
|
125 uint time;
|
|
126 double x;
|
|
127 double y;
|
|
128 double xRoot;
|
|
129 double yRoot;
|
|
130 GdkCrossingMode mode;
|
|
131 GdkNotifyType detail;
|
|
132 int focus;
|
|
133 uint state;
|
|
134 }
|
|
135 */
|
|
136
|
77
|
137 CrossingEvent makeCrossingEvent(const GdkEventCrossing * event, in ScreenModel screenModel) {
|
|
138 Point screenPoint = Point(event.x + 0.5, screenModel.viewBoundsScreen.h - (event.y + 0.5));
|
|
139 Point modelPoint = screenModel.screenToModel(screenPoint);
|
73
|
140 return new CrossingEvent(gtk2tkCrossingMode(event.mode),
|
77
|
141 screenPoint,
|
73
|
142 modelPoint,
|
|
143 gtk2tkMask(event.state));
|
|
144 }
|
|
145
|
|
146
|
|
147 /*
|
|
148 public struct GdkEventFocus {
|
|
149 GdkEventType type;
|
|
150 GdkWindow *window;
|
|
151 byte sendEvent;
|
|
152 short inn;
|
|
153 }
|
|
154 */
|
|
155 // In case we implement focus event...
|