]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/gen/terminal_interface-curses-mouse.ads.m4
ncurses 6.2 - patch 20210905
[ncurses.git] / Ada95 / gen / terminal_interface-curses-mouse.ads.m4
1 --  -*- ada -*-
2 define(`HTMLNAME',`terminal_interface-curses-mouse__ads.htm')dnl
3 include(M4MACRO)dnl
4 ------------------------------------------------------------------------------
5 --                                                                          --
6 --                           GNAT ncurses Binding                           --
7 --                                                                          --
8 --                      Terminal_Interface.Curses.Mouse                     --
9 --                                                                          --
10 --                                 S P E C                                  --
11 --                                                                          --
12 ------------------------------------------------------------------------------
13 -- Copyright 2020 Thomas E. Dickey                                          --
14 -- Copyright 1998-2014,2015 Free Software Foundation, Inc.                  --
15 --                                                                          --
16 -- Permission is hereby granted, free of charge, to any person obtaining a  --
17 -- copy of this software and associated documentation files (the            --
18 -- "Software"), to deal in the Software without restriction, including      --
19 -- without limitation the rights to use, copy, modify, merge, publish,      --
20 -- distribute, distribute with modifications, sublicense, and/or sell       --
21 -- copies of the Software, and to permit persons to whom the Software is    --
22 -- furnished to do so, subject to the following conditions:                 --
23 --                                                                          --
24 -- The above copyright notice and this permission notice shall be included  --
25 -- in all copies or substantial portions of the Software.                   --
26 --                                                                          --
27 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
28 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
29 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
30 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
31 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
32 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
33 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
34 --                                                                          --
35 -- Except as contained in this notice, the name(s) of the above copyright   --
36 -- holders shall not be used in advertising or otherwise to promote the     --
37 -- sale, use or other dealings in this Software without prior written       --
38 -- authorization.                                                           --
39 ------------------------------------------------------------------------------
40 --  Author:  Juergen Pfeifer, 1996
41 --  Version Control:
42 --  $Revision: 1.33 $
43 --  $Date: 2020/02/02 23:34:34 $
44 --  Binding Version 01.00
45 ------------------------------------------------------------------------------
46 with System;
47
48 package Terminal_Interface.Curses.Mouse is
49    pragma Preelaborate (Terminal_Interface.Curses.Mouse);
50
51    --  MANPAGE(`curs_mouse.3x')
52    --  mouse_trafo, wmouse_trafo are implemented as Transform_Coordinates
53    --  in the parent package.
54    --
55    --  Not implemented:
56    --  REPORT_MOUSE_POSITION (i.e. as a parameter to Register_Reportable_Event
57    --  or Start_Mouse)
58    type Event_Mask is private;
59    No_Events  : constant Event_Mask;
60    All_Events : constant Event_Mask;
61
62    type Mouse_Button is (Left,     -- aka: Button 1
63                          Middle,   -- aka: Button 2
64                          Right,    -- aka: Button 3
65                          Button4,  -- aka: Button 4
66                          Control,  -- Control Key
67                          Shift,    -- Shift Key
68                          Alt);     -- ALT Key
69
70    subtype Real_Buttons  is Mouse_Button range Left .. Button4;
71    subtype Modifier_Keys is Mouse_Button range Control .. Alt;
72
73    type Button_State is (Released,
74                          Pressed,
75                          Clicked,
76                          Double_Clicked,
77                          Triple_Clicked);
78
79    type Button_States is array (Button_State) of Boolean;
80    pragma Pack (Button_States);
81
82    All_Clicks : constant Button_States := (Clicked .. Triple_Clicked => True,
83                                            others => False);
84    All_States : constant Button_States := (others => True);
85
86    type Mouse_Event is private;
87
88    --  MANPAGE(`curs_mouse.3x')
89
90    function Has_Mouse return Boolean;
91    --  Return true if a mouse device is supported, false otherwise.
92
93    procedure Register_Reportable_Event
94      (Button : Mouse_Button;
95       State  : Button_State;
96       Mask   : in out Event_Mask);
97    --  Stores the event described by the button and the state in the mask.
98    --  Before you call this the first time, you should initialize the mask
99    --  with the Empty_Mask constant
100    pragma Inline (Register_Reportable_Event);
101
102    procedure Register_Reportable_Events
103      (Button : Mouse_Button;
104       State  : Button_States;
105       Mask   : in out Event_Mask);
106    --  Register all events described by the Button and the State bitmap.
107    --  Before you call this the first time, you should initialize the mask
108    --  with the Empty_Mask constant
109
110    --  ANCHOR(`mousemask()',`Start_Mouse')
111    --  There is one difference to mousmask(): we return the value of the
112    --  old mask, that means the event mask value before this call.
113    --  Not Implemented: The library version
114    --  returns a Mouse_Mask that tells which events are reported.
115    function Start_Mouse (Mask : Event_Mask := All_Events)
116                          return Event_Mask;
117    --  AKA
118    pragma Inline (Start_Mouse);
119
120    procedure End_Mouse (Mask : Event_Mask := No_Events);
121    --  Terminates the mouse, restores the specified event mask
122    pragma Inline (End_Mouse);
123
124    --  ANCHOR(`getmouse()',`Get_Mouse')
125    function Get_Mouse return Mouse_Event;
126    --  AKA
127    pragma Inline (Get_Mouse);
128
129    procedure Get_Event (Event  : Mouse_Event;
130                         Y      : out Line_Position;
131                         X      : out Column_Position;
132                         Button : out Mouse_Button;
133                         State  : out Button_State);
134    --  !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
135    --  may not be identical to window coordinates.
136    --  Not Implemented: Get_Event only reports one event, the C library
137    --  version supports multiple events, e.g. {click-1, click-3}
138    pragma Inline (Get_Event);
139
140    --  ANCHOR(`ungetmouse()',`Unget_Mouse')
141    procedure Unget_Mouse (Event : Mouse_Event);
142    --  AKA
143    pragma Inline (Unget_Mouse);
144
145    --  ANCHOR(`wenclose()',`Enclosed_In_Window')
146    function Enclosed_In_Window (Win    : Window := Standard_Window;
147                                 Event  : Mouse_Event) return Boolean;
148    --  AKA
149    --  But : use event instead of screen coordinates.
150    pragma Inline (Enclosed_In_Window);
151
152    --  ANCHOR(`mouseinterval()',`Mouse_Interval')
153    function Mouse_Interval (Msec : Natural := 200) return Natural;
154    --  AKA
155    pragma Inline (Mouse_Interval);
156
157 private
158    --  This can be as little as 32 bits (unsigned), or as long as the system's
159    --  unsigned long.  Declare it as the minimum size to handle all valid
160    --  sizes.
161    type Event_Mask is mod 4294967296;
162
163    type Mouse_Event is
164       record
165          Id      : Integer range Integer (Interfaces.C.short'First) ..
166                                  Integer (Interfaces.C.short'Last);
167          X, Y, Z : Integer range Integer (Interfaces.C.int'First) ..
168                                  Integer (Interfaces.C.int'Last);
169          Bstate  : Event_Mask;
170       end record;
171    pragma Convention (C, Mouse_Event);
172
173    for Mouse_Event use
174       record
175          Id     at 0 range Curses_Constants.MEVENT_id_First
176            .. Curses_Constants.MEVENT_id_Last;
177          X      at 0 range Curses_Constants.MEVENT_x_First
178            .. Curses_Constants.MEVENT_x_Last;
179          Y      at 0 range Curses_Constants.MEVENT_y_First
180            .. Curses_Constants.MEVENT_y_Last;
181          Z      at 0 range Curses_Constants.MEVENT_z_First
182            .. Curses_Constants.MEVENT_z_Last;
183          Bstate at 0 range Curses_Constants.MEVENT_bstate_First
184            .. Curses_Constants.MEVENT_bstate_Last;
185       end record;
186    for Mouse_Event'Size use Curses_Constants.MEVENT_Size;
187    Generation_Bit_Order : System.Bit_Order renames Curses_Constants.Bit_Order;
188
189    BUTTON_CTRL      : constant Event_Mask := Curses_Constants.BUTTON_CTRL;
190    BUTTON_SHIFT     : constant Event_Mask := Curses_Constants.BUTTON_SHIFT;
191    BUTTON_ALT       : constant Event_Mask := Curses_Constants.BUTTON_ALT;
192    BUTTON1_EVENTS   : constant Event_Mask
193      := Curses_Constants.all_events_button_1;
194    BUTTON2_EVENTS   : constant Event_Mask
195      := Curses_Constants.all_events_button_2;
196    BUTTON3_EVENTS   : constant Event_Mask
197      := Curses_Constants.all_events_button_3;
198    BUTTON4_EVENTS   : constant Event_Mask
199      := Curses_Constants.all_events_button_4;
200    ALL_MOUSE_EVENTS : constant Event_Mask := Curses_Constants.ALL_MOUSE_EVENTS;
201    No_Events        : constant Event_Mask := 0;
202    All_Events       : constant Event_Mask := ALL_MOUSE_EVENTS;
203
204 end Terminal_Interface.Curses.Mouse;