summaryrefslogtreecommitdiff
path: root/src/fltk-event.ads
blob: 17f5a1c7a2397fbc31b516ba1ef08692365e8741 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263


with

    FLTK.Widgets.Groups.Windows;

private with

    Ada.Containers.Vectors,
    System.Address_To_Access_Conversions;


package FLTK.Event is


    type Event_Handler is access function
           (Event : in Event_Kind)
        return Event_Outcome;

    type Event_Dispatch is access function
           (Event : in     Event_Kind;
            Win   : in out FLTK.Widgets.Groups.Windows.Window'Class)
        return Event_Outcome;




    procedure Add_Handler
           (Func : in Event_Handler);

    procedure Remove_Handler
           (Func : in Event_Handler);

    function Get_Dispatch
        return Event_Dispatch;

    procedure Set_Dispatch
           (Func : in Event_Dispatch);

    function Default_Dispatch
           (Event : in     Event_Kind;
            Win   : in out FLTK.Widgets.Groups.Windows.Window'Class)
        return Event_Outcome;




    function Get_Grab
        return access FLTK.Widgets.Groups.Windows.Window'Class;

    procedure Set_Grab
           (To : in FLTK.Widgets.Groups.Windows.Window'Class);

    procedure Release_Grab;

    function Get_Pushed
        return access FLTK.Widgets.Widget'Class;

    procedure Set_Pushed
           (To : in FLTK.Widgets.Widget'Class);

    function Get_Below_Mouse
        return access FLTK.Widgets.Widget'Class;

    procedure Set_Below_Mouse
           (To : in FLTK.Widgets.Widget'Class);

    function Get_Focus
        return access FLTK.Widgets.Widget'Class;

    procedure Set_Focus
           (To : in FLTK.Widgets.Widget'Class);




    function Compose
           (Del : out Natural)
        return Boolean;

    procedure Compose_Reset;

    function Text
        return String;

    function Text_Length
        return Natural;




    function Last
        return Event_Kind;

    function Last_Modifier
        return Modifier;

    function Last_Modifier
           (Had : in Modifier)
        return Boolean;




    function Mouse_X
        return Integer;

    function Mouse_X_Root
        return Integer;

    function Mouse_Y
        return Integer;

    function Mouse_Y_Root
        return Integer;

    function Mouse_DX
        return Integer;

    function Mouse_DY
        return Integer;

    procedure Get_Mouse
           (X, Y : out Integer);

    function Is_Click
        return Boolean;

    function Is_Multi_Click
        return Boolean;

    procedure Set_Clicks
           (To : in Natural);

    function Last_Button
        return Mouse_Button;

    function Mouse_Left
        return Boolean;

    function Mouse_Middle
        return Boolean;

    function Mouse_Right
        return Boolean;

    function Is_Inside
           (X, Y, W, H : in Integer)
        return Boolean;




    function Last_Key
        return Keypress;

    function Original_Last_Key
        return Keypress;

    function Pressed_During
           (Key : in Keypress)
        return Boolean;

    function Key_Now
           (Key : in Keypress)
        return Boolean;

    function Key_Ctrl
        return Boolean;

    function Key_Alt
        return Boolean;

    function Key_Command
        return Boolean;

    function Key_Shift
        return Boolean;


private


    package Widget_Convert is new System.Address_To_Access_Conversions
        (FLTK.Widgets.Widget'Class);
    package Window_Convert is new System.Address_To_Access_Conversions
        (FLTK.Widgets.Groups.Windows.Window'Class);


    package Handler_Vectors is new Ada.Containers.Vectors
        (Index_Type => Positive, Element_Type => Event_Handler);


    Handlers : Handler_Vectors.Vector := Handler_Vectors.Empty_Vector;
    Current_Dispatch : Event_Dispatch := null;


    function fl_widget_get_user_data
           (W : in System.Address)
        return System.Address;
    pragma Import (C, fl_widget_get_user_data, "fl_widget_get_user_data");
    pragma Inline (fl_widget_get_user_data);




    pragma Inline (Add_Handler);
    pragma Inline (Remove_Handler);
    pragma Inline (Get_Dispatch);
    pragma Inline (Set_Dispatch);
    pragma Inline (Default_Dispatch);


    pragma Inline (Get_Grab);
    pragma Inline (Set_Grab);
    pragma Inline (Release_Grab);
    pragma Inline (Get_Pushed);
    pragma Inline (Set_Pushed);
    pragma Inline (Get_Below_Mouse);
    pragma Inline (Set_Below_Mouse);
    pragma Inline (Get_Focus);
    pragma Inline (Set_Focus);


    pragma Inline (Compose);
    pragma Inline (Compose_Reset);
    pragma Inline (Text);
    pragma Inline (Text_Length);


    pragma Inline (Last);
    pragma Inline (Last_Modifier);


    pragma Inline (Mouse_X);
    pragma Inline (Mouse_X_Root);
    pragma Inline (Mouse_Y);
    pragma Inline (Mouse_Y_Root);
    pragma Inline (Mouse_DX);
    pragma Inline (Mouse_DY);
    pragma Inline (Get_Mouse);
    pragma Inline (Is_Click);
    pragma Inline (Is_Multi_Click);
    pragma Inline (Set_Clicks);
    pragma Inline (Last_Button);
    pragma Inline (Mouse_Left);
    pragma Inline (Mouse_Middle);
    pragma Inline (Mouse_Right);
    pragma Inline (Is_Inside);


    pragma Inline (Last_Key);
    pragma Inline (Original_Last_Key);
    pragma Inline (Pressed_During);
    pragma Inline (Key_Now);
    pragma Inline (Key_Ctrl);
    pragma Inline (Key_Alt);
    pragma Inline (Key_Command);
    pragma Inline (Key_Shift);


end FLTK.Event;