0
|
1 module tk.gtk_support;
|
|
2
|
|
3 import tk.types;
|
|
4
|
|
5 static import gdk.Event;
|
|
6
|
7
|
7 ButtonAction gtk2tk_button_action(gdk.Event.EventType event_type) {
|
0
|
8 switch (event_type) {
|
|
9 case gdk.Event.EventType.BUTTON_PRESS:
|
8
|
10 return ButtonAction.SINGLE_PRESS;
|
0
|
11 case gdk.Event.EventType.DOUBLE_BUTTON_PRESS:
|
8
|
12 return ButtonAction.DOUBLE_PRESS;
|
0
|
13 case gdk.Event.EventType.TRIPLE_BUTTON_PRESS:
|
8
|
14 return ButtonAction.TRIPLE_PRESS;
|
0
|
15 case gdk.Event.EventType.BUTTON_RELEASE:
|
7
|
16 return ButtonAction.RELEASE;
|
0
|
17 default:
|
|
18 assert(false);
|
|
19 }
|
|
20 }
|
|
21
|
7
|
22 ButtonName gtk2tk_button_name(gdk.Event.guint button) {
|
0
|
23 switch (button) {
|
|
24 case 1:
|
7
|
25 return ButtonName.LEFT;
|
0
|
26 case 2:
|
7
|
27 return ButtonName.MIDDLE;
|
0
|
28 case 3:
|
7
|
29 return ButtonName.RIGHT;
|
|
30 case 4:
|
|
31 return ButtonName.FOUR;
|
|
32 case 5:
|
|
33 return ButtonName.FIVE;
|
0
|
34 default:
|
|
35 assert(false);
|
|
36 }
|
|
37 }
|
|
38
|
6
|
39 Mask gtk2tk_mask(gdk.Event.guint state) {
|
|
40 Modifier[] modifiers;
|
|
41
|
|
42 if (state & gdk.Event.GdkModifierType.SHIFT_MASK) modifiers ~= Modifier.SHIFT;
|
|
43 if (state & gdk.Event.GdkModifierType.CONTROL_MASK) modifiers ~= Modifier.CONTROL;
|
|
44 if (state & gdk.Event.GdkModifierType.MOD1_MASK) modifiers ~= Modifier.ALT;
|
|
45 if (state & gdk.Event.GdkModifierType.MOD2_MASK) modifiers ~= Modifier.META;
|
7
|
46 if (state & gdk.Event.GdkModifierType.BUTTON1_MASK) modifiers ~= Modifier.BUTTON_LEFT;
|
|
47 if (state & gdk.Event.GdkModifierType.BUTTON2_MASK) modifiers ~= Modifier.BUTTON_MIDDLE;
|
|
48 if (state & gdk.Event.GdkModifierType.BUTTON3_MASK) modifiers ~= Modifier.BUTTON_RIGHT;
|
|
49 if (state & gdk.Event.GdkModifierType.BUTTON4_MASK) modifiers ~= Modifier.BUTTON_FOUR;
|
|
50 if (state & gdk.Event.GdkModifierType.BUTTON5_MASK) modifiers ~= Modifier.BUTTON_FIVE;
|
6
|
51
|
|
52 return new Mask(modifiers);
|
|
53 }
|
0
|
54
|
|
55 ScrollDirection gtk2tk_direction(gdk.Event.ScrollDirection direction) {
|
|
56 switch (direction) {
|
|
57 case gdk.Event.ScrollDirection.UP:
|
|
58 return ScrollDirection.UP;
|
|
59 case gdk.Event.ScrollDirection.DOWN:
|
|
60 return ScrollDirection.DOWN;
|
|
61 case gdk.Event.ScrollDirection.LEFT:
|
|
62 return ScrollDirection.LEFT;
|
|
63 case gdk.Event.ScrollDirection.RIGHT:
|
|
64 return ScrollDirection.RIGHT;
|
|
65 default:
|
|
66 assert(false);
|
|
67 }
|
|
68 }
|