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