]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/gen/terminal_interface-curses-mouse.ads.m4
ncurses 5.1
[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 (c) 1998 Free Software Foundation, Inc.                        --
14 --                                                                          --
15 -- Permission is hereby granted, free of charge, to any person obtaining a  --
16 -- copy of this software and associated documentation files (the            --
17 -- "Software"), to deal in the Software without restriction, including      --
18 -- without limitation the rights to use, copy, modify, merge, publish,      --
19 -- distribute, distribute with modifications, sublicense, and/or sell       --
20 -- copies of the Software, and to permit persons to whom the Software is    --
21 -- furnished to do so, subject to the following conditions:                 --
22 --                                                                          --
23 -- The above copyright notice and this permission notice shall be included  --
24 -- in all copies or substantial portions of the Software.                   --
25 --                                                                          --
26 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  --
27 -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               --
28 -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   --
29 -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   --
30 -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    --
31 -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    --
32 -- THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               --
33 --                                                                          --
34 -- Except as contained in this notice, the name(s) of the above copyright   --
35 -- holders shall not be used in advertising or otherwise to promote the     --
36 -- sale, use or other dealings in this Software without prior written       --
37 -- authorization.                                                           --
38 ------------------------------------------------------------------------------
39 --  Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1996
40 --  Version Control:
41 --  $Revision: 1.19 $
42 --  Binding Version 01.00
43 ------------------------------------------------------------------------------
44 include(`Mouse_Base_Defs')
45 with System;
46
47 package Terminal_Interface.Curses.Mouse is
48    pragma Preelaborate (Terminal_Interface.Curses.Mouse);
49
50    --  MANPAGE(`curs_mouse.3x')
51    --  Please note, that in ncurses-1.9.9e documentation mouse support
52    --  is still marked as experimental. So also this binding will change
53    --  if the ncurses methods change.
54    --
55    type Event_Mask is private;
56    No_Events  : constant Event_Mask;
57    All_Events : constant Event_Mask;
58
59    type Mouse_Button is (Left,     -- aka: Button 1
60                          Middle,   -- aka: Button 2
61                          Right,    -- aka: Button 3
62                          Button4,  -- aka: Button 4
63                          Control,  -- Control Key
64                          Shift,    -- Shift Key
65                          Alt);     -- ALT Key
66
67    subtype Real_Buttons  is Mouse_Button range Left .. Button4;
68    subtype Modifier_Keys is Mouse_Button range Control .. Alt;
69
70    type Button_State is (Released,
71                          Pressed,
72                          Clicked,
73                          Double_Clicked,
74                          Triple_Clicked);
75
76    type Button_States is array (Button_State) of Boolean;
77    pragma Pack (Button_States);
78
79    All_Clicks : constant Button_States := (Clicked .. Triple_Clicked => True,
80                                            others => False);
81    All_States : constant Button_States := (others => True);
82
83    type Mouse_Event is private;
84
85    --  MANPAGE(`curs_mouse.3x')
86
87    function Has_Mouse return Boolean;
88    --  Return true if a mouse device is supported, false otherwise.
89
90    procedure Register_Reportable_Event
91      (Button : in Mouse_Button;
92       State  : in Button_State;
93       Mask   : in out Event_Mask);
94    --  Stores the event described by the button and the state in the mask.
95    --  Before you call this the first time, you should init the mask
96    --  with the Empty_Mask constant
97    pragma Inline (Register_Reportable_Event);
98
99    procedure Register_Reportable_Events
100      (Button : in Mouse_Button;
101       State  : in Button_States;
102       Mask   : in out Event_Mask);
103    --  Register all events described by the Button and the State bitmap.
104    --  Before you call this the first time, you should init the mask
105    --  with the Empty_Mask constant
106
107    --  ANCHOR(`mousemask()',`Start_Mouse')
108    --  There is one difference to mousmask(): we return the value of the
109    --  old mask, that means the event mask value before this call.
110    function Start_Mouse (Mask : Event_Mask := All_Events)
111                          return Event_Mask;
112    --  AKA
113    pragma Inline (Start_Mouse);
114
115    procedure End_Mouse (Mask : in Event_Mask := No_Events);
116    --  Terminates the mouse, restores the specified event mask
117    pragma Inline (End_Mouse);
118
119    --  ANCHOR(`getmouse()',`Get_Mouse')
120    function Get_Mouse return Mouse_Event;
121    --  AKA
122    pragma Inline (Get_Mouse);
123
124    procedure Get_Event (Event  : in  Mouse_Event;
125                         Y      : out Line_Position;
126                         X      : out Column_Position;
127                         Button : out Mouse_Button;
128                         State  : out Button_State);
129    --  !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
130    --  may not be identical to window coordinates.
131    pragma Inline (Get_Event);
132
133    --  ANCHOR(`ungetmouse()',`Unget_Mouse')
134    procedure Unget_Mouse (Event : in Mouse_Event);
135    --  AKA
136    pragma Inline (Unget_Mouse);
137
138    --  ANCHOR(`wenclose()',`Enclosed_In_Window')
139    function Enclosed_In_Window (Win    : Window := Standard_Window;
140                                 Event  : Mouse_Event) return Boolean;
141    --  AKA
142    --  But : use event instead of screen coordinates.
143    pragma Inline (Enclosed_In_Window);
144
145    --  ANCHOR(`mouseinterval()',`Mouse_Interval')
146    function Mouse_Interval (Msec : Natural := 200) return Natural;
147    --  AKA
148    pragma Inline (Mouse_Interval);
149
150 private
151    type Event_Mask is new Interfaces.C.unsigned_long;
152
153    type Mouse_Event is
154       record
155          Id      : Integer range Integer (Interfaces.C.short'First) ..
156                                  Integer (Interfaces.C.short'Last);
157          X, Y, Z : Integer range Integer (Interfaces.C.int'First) ..
158                                  Integer (Interfaces.C.int'Last);
159          Bstate  : Event_Mask;
160       end record;
161    pragma Convention (C, Mouse_Event);
162    pragma Pack (Mouse_Event);
163
164 include(`Mouse_Event_Rep')
165    Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
166    --  This constant may be different on your system.
167
168 include(`Mouse_Events')
169
170    No_Events  : constant Event_Mask := 0;
171    All_Events : constant Event_Mask := ALL_MOUSE_EVENTS;
172
173 end Terminal_Interface.Curses.Mouse;