Mercurial > projects > doodle
comparison doodle/gtk/events.d @ 73:6f2525e170f2
Cairo/OpenGL checkpoint
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Sun, 15 Aug 2010 01:02:15 +0930 |
parents | |
children | 15ca7d5cd1ed |
comparison
equal
deleted
inserted
replaced
72:5cc2de64f6d0 | 73:6f2525e170f2 |
---|---|
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 | |
32 ButtonEvent makeButtonEvent(const GdkEventButton * event, in PixelModel pixelModel) { | |
33 Point pixelPoint = Point(event.x + 0.5, pixelModel.viewBounds.h - (event.y + 0.5)); | |
34 Point modelPoint = pixelModel.pixelToModel(pixelPoint); | |
35 return new ButtonEvent(gtk2tkButtonAction(event.type), | |
36 gtk2tkButtonName(event.button), | |
37 pixelPoint, modelPoint, gtk2tkMask(event.state)); | |
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 | |
56 MotionEvent makeMotionEvent(const GdkEventMotion * event, in PixelModel pixelModel) { | |
57 Point pixelPoint = Point(event.x + 0.5, pixelModel.viewBounds.h - (event.y + 0.5)); | |
58 Point modelPoint = pixelModel.pixelToModel(pixelPoint); | |
59 | |
60 return new MotionEvent(pixelPoint, modelPoint, gtk2tkMask(event.state)); | |
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 | |
80 KeyEvent makeKeyEvent(const GdkEventKey * event, in PixelModel pixelModel) { | |
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 | |
101 ScrollEvent makeScrollEvent(const GdkEventScroll * event, in PixelModel pixelModel) { | |
102 Point pixelPoint = Point(event.x + 0.5, pixelModel.viewBounds.h - (event.y + 0.5)); | |
103 Point modelPoint = pixelModel.pixelToModel(pixelPoint); | |
104 return new ScrollEvent(gtk2tkDirection(event.direction), | |
105 pixelPoint, | |
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 | |
137 CrossingEvent makeCrossingEvent(const GdkEventCrossing * event, in PixelModel pixelModel) { | |
138 Point pixelPoint = Point(event.x + 0.5, pixelModel.viewBounds.h - (event.y + 0.5)); | |
139 Point modelPoint = pixelModel.pixelToModel(pixelPoint); | |
140 return new CrossingEvent(gtk2tkCrossingMode(event.mode), | |
141 pixelPoint, | |
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... |