terminal_interface-curses-mouse.ads.m4 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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-2004,2006 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, 1996
  40. -- Version Control:
  41. -- $Revision: 1.27 $
  42. -- $Date: 2006/06/25 14:30:22 $
  43. -- Binding Version 01.00
  44. ------------------------------------------------------------------------------
  45. include(`Mouse_Base_Defs')
  46. with System;
  47. package Terminal_Interface.Curses.Mouse is
  48. pragma Preelaborate (Terminal_Interface.Curses.Mouse);
  49. -- MANPAGE(`curs_mouse.3x')
  50. -- Please note, that in ncurses-1.9.9e documentation mouse support
  51. -- is still marked as experimental. So also this binding will change
  52. -- if the ncurses methods change.
  53. --
  54. -- mouse_trafo, wmouse_trafo are implemented as Transform_Coordinates
  55. -- in the parent package.
  56. --
  57. -- Not implemented:
  58. -- REPORT_MOUSE_POSITION (i.e. as a parameter to Register_Reportable_Event
  59. -- or Start_Mouse)
  60. type Event_Mask is private;
  61. No_Events : constant Event_Mask;
  62. All_Events : constant Event_Mask;
  63. type Mouse_Button is (Left, -- aka: Button 1
  64. Middle, -- aka: Button 2
  65. Right, -- aka: Button 3
  66. Button4, -- aka: Button 4
  67. Control, -- Control Key
  68. Shift, -- Shift Key
  69. Alt); -- ALT Key
  70. subtype Real_Buttons is Mouse_Button range Left .. Button4;
  71. subtype Modifier_Keys is Mouse_Button range Control .. Alt;
  72. type Button_State is (Released,
  73. Pressed,
  74. Clicked,
  75. Double_Clicked,
  76. Triple_Clicked);
  77. type Button_States is array (Button_State) of Boolean;
  78. pragma Pack (Button_States);
  79. All_Clicks : constant Button_States := (Clicked .. Triple_Clicked => True,
  80. others => False);
  81. All_States : constant Button_States := (others => True);
  82. type Mouse_Event is private;
  83. -- MANPAGE(`curs_mouse.3x')
  84. function Has_Mouse return Boolean;
  85. -- Return true if a mouse device is supported, false otherwise.
  86. procedure Register_Reportable_Event
  87. (Button : in Mouse_Button;
  88. State : in Button_State;
  89. Mask : in out Event_Mask);
  90. -- Stores the event described by the button and the state in the mask.
  91. -- Before you call this the first time, you should init the mask
  92. -- with the Empty_Mask constant
  93. pragma Inline (Register_Reportable_Event);
  94. procedure Register_Reportable_Events
  95. (Button : in Mouse_Button;
  96. State : in Button_States;
  97. Mask : in out Event_Mask);
  98. -- Register all events described by the Button and the State bitmap.
  99. -- Before you call this the first time, you should init the mask
  100. -- with the Empty_Mask constant
  101. -- ANCHOR(`mousemask()',`Start_Mouse')
  102. -- There is one difference to mousmask(): we return the value of the
  103. -- old mask, that means the event mask value before this call.
  104. -- Not Implemented: The library version
  105. -- returns a Mouse_Mask that tells which events are reported.
  106. function Start_Mouse (Mask : Event_Mask := All_Events)
  107. return Event_Mask;
  108. -- AKA
  109. pragma Inline (Start_Mouse);
  110. procedure End_Mouse (Mask : in Event_Mask := No_Events);
  111. -- Terminates the mouse, restores the specified event mask
  112. pragma Inline (End_Mouse);
  113. -- ANCHOR(`getmouse()',`Get_Mouse')
  114. function Get_Mouse return Mouse_Event;
  115. -- AKA
  116. pragma Inline (Get_Mouse);
  117. procedure Get_Event (Event : in Mouse_Event;
  118. Y : out Line_Position;
  119. X : out Column_Position;
  120. Button : out Mouse_Button;
  121. State : out Button_State);
  122. -- !!! Warning: X and Y are screen coordinates. Due to ripped of lines they
  123. -- may not be identical to window coordinates.
  124. -- Not Implemented: Get_Event only reports one event, the C library
  125. -- version supports multiple events, e.g. {click-1, click-3}
  126. pragma Inline (Get_Event);
  127. -- ANCHOR(`ungetmouse()',`Unget_Mouse')
  128. procedure Unget_Mouse (Event : in Mouse_Event);
  129. -- AKA
  130. pragma Inline (Unget_Mouse);
  131. -- ANCHOR(`wenclose()',`Enclosed_In_Window')
  132. function Enclosed_In_Window (Win : Window := Standard_Window;
  133. Event : Mouse_Event) return Boolean;
  134. -- AKA
  135. -- But : use event instead of screen coordinates.
  136. pragma Inline (Enclosed_In_Window);
  137. -- ANCHOR(`mouseinterval()',`Mouse_Interval')
  138. function Mouse_Interval (Msec : Natural := 200) return Natural;
  139. -- AKA
  140. pragma Inline (Mouse_Interval);
  141. private
  142. type Event_Mask is new Interfaces.C.unsigned_long;
  143. type Mouse_Event is
  144. record
  145. Id : Integer range Integer (Interfaces.C.short'First) ..
  146. Integer (Interfaces.C.short'Last);
  147. X, Y, Z : Integer range Integer (Interfaces.C.int'First) ..
  148. Integer (Interfaces.C.int'Last);
  149. Bstate : Event_Mask;
  150. end record;
  151. pragma Convention (C, Mouse_Event);
  152. include(`Mouse_Event_Rep')
  153. Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
  154. -- This constant may be different on your system.
  155. include(`Mouse_Events')
  156. No_Events : constant Event_Mask := 0;
  157. All_Events : constant Event_Mask := ALL_MOUSE_EVENTS;
  158. end Terminal_Interface.Curses.Mouse;