1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2013, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  This package provides functions dealing with events from the window system. 
  32. --  In GtkAda applications, the events are handled automatically in 
  33. --  Gtk.Main.Do_Event, and passed on to the appropriate widgets, so these 
  34. --  functions are rarely needed. 
  35. -- 
  36. --  !! Warning !! This is one of the only package that requires manual 
  37. --  memory management in some cases. If you use the function Allocate, 
  38. --  you have to use the function Free too... 
  39. --  </description> 
  40. --  <c_version>1.3.6</c_version> 
  41. --  <group>Gdk, the low-level API</group> 
  42.  
  43. with System; 
  44. with Glib; use Glib; 
  45. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  46. pragma Elaborate_All (Glib.Generic_Properties); 
  47. with Glib.Values; 
  48. with Gdk.Rectangle; 
  49. with Gdk.Region; 
  50. with Gdk.Types; 
  51.  
  52. package Gdk.Event is 
  53.  
  54.    ----------------------------- 
  55.    -- Definition of the types -- 
  56.    ----------------------------- 
  57.  
  58.    type Gdk_Event_Type is 
  59.      (Nothing, 
  60.       --  No event occurred. 
  61.  
  62.       Delete, 
  63.       --  A window delete event was sent by the window manager. The specified 
  64.       --  window should be deleted. 
  65.  
  66.       Destroy, 
  67.       --  A window has been destroyed. 
  68.  
  69.       Expose, 
  70.       --  Part of a window has been uncovered. 
  71.  
  72.       Motion_Notify, 
  73.       Button_Press, 
  74.       --  A mouse button was pressed. 
  75.  
  76.       Gdk_2button_Press, 
  77.       --  Double-click 
  78.  
  79.       Gdk_3button_Press, 
  80.       --  Triple-click 
  81.  
  82.       Button_Release, 
  83.       --  A mouse button was released. 
  84.  
  85.       Key_Press, 
  86.       --  A key was pressed. 
  87.  
  88.       Key_Release, 
  89.       --  A key was released. 
  90.  
  91.       Enter_Notify, 
  92.       --  A window was entered. 
  93.  
  94.       Leave_Notify, 
  95.       --  A window was exited. 
  96.  
  97.       Focus_Change, 
  98.       --  The focus window has changed. (The focus window gets keyboard events) 
  99.  
  100.       Configure, 
  101.       Map, 
  102.       --  A window has been mapped. (It is now visible on the screen). 
  103.  
  104.       Unmap, 
  105.       --  A window has been unmapped. (It is no longer visible on the screen). 
  106.  
  107.       Property_Notify, 
  108.       Selection_Clear, 
  109.       Selection_Request, 
  110.       Selection_Notify, 
  111.       Proximity_In, 
  112.       Proximity_Out, 
  113.       Drag_Enter, 
  114.       Drag_Leave, 
  115.       Drag_Motion, 
  116.       Drag_Status, 
  117.       Drop_Start, 
  118.       Drop_Finished, 
  119.       Client_Event, 
  120.       Visibility_Notify, 
  121.       No_Expose, 
  122.       Scroll, 
  123.       --  A mouse wheel was scrolled either up or down. 
  124.  
  125.       Window_State, 
  126.       Setting, 
  127.  
  128.       Owner_Change, 
  129.       --  Emitted when the owner of a selection has changed 
  130.       --  Added in gtk+ 2.6 
  131.       --  See Gdk.Display.Supports_Selection_Notification 
  132.  
  133.       Grab_Broken 
  134.       --  A pointer or keyboard grab was broken 
  135.       --  Added in gtk+ 2.8 
  136.       ); 
  137.    pragma Convention (C, Gdk_Event_Type); 
  138.  
  139.    type Gdk_Event_Mask is mod 2 ** 32; 
  140.    --  Note that you need to change the event mask of a widget if you want 
  141.    --  to be able to get some events. To change this mask, the widget 
  142.    --  must first be Unrealized. 
  143.  
  144.    Exposure_Mask            : constant Gdk_Event_Mask := 2 ** 1; 
  145.  
  146.    Pointer_Motion_Mask      : constant Gdk_Event_Mask := 2 ** 2; 
  147.    --  Every time the mouse moves, GtkAda will send a Motion_Notify event. 
  148.    --  These events will be sent as fast as possible, and your application 
  149.    --  needs to be able to respond as fast as possible (generally about 
  150.    --  200 events per second). 
  151.  
  152.    Pointer_Motion_Hint_Mask : constant Gdk_Event_Mask := 2 ** 3; 
  153.    --  GtkAda will only send one Motion_Notify event when the mouse moves. 
  154.    --  The handler should call Gdk.Window.Get_Pointer, to get the current 
  155.    --  position and signals GtkAda that it is ready to get another 
  156.    --  Motion_Notify signal. No new Motion_Notify will be sent until 
  157.    --  Get_Pointer has been called. 
  158.  
  159.    Button_Motion_Mask       : constant Gdk_Event_Mask := 2 ** 4; 
  160.    Button1_Motion_Mask      : constant Gdk_Event_Mask := 2 ** 5; 
  161.    Button2_Motion_Mask      : constant Gdk_Event_Mask := 2 ** 6; 
  162.    Button3_Motion_Mask      : constant Gdk_Event_Mask := 2 ** 7; 
  163.    Button_Press_Mask        : constant Gdk_Event_Mask := 2 ** 8; 
  164.    Button_Release_Mask      : constant Gdk_Event_Mask := 2 ** 9; 
  165.    Key_Press_Mask           : constant Gdk_Event_Mask := 2 ** 10; 
  166.    Key_Release_Mask         : constant Gdk_Event_Mask := 2 ** 11; 
  167.    Enter_Notify_Mask        : constant Gdk_Event_Mask := 2 ** 12; 
  168.    Leave_Notify_Mask        : constant Gdk_Event_Mask := 2 ** 13; 
  169.    Focus_Change_Mask        : constant Gdk_Event_Mask := 2 ** 14; 
  170.    Structure_Mask           : constant Gdk_Event_Mask := 2 ** 15; 
  171.    Property_Change_Mask     : constant Gdk_Event_Mask := 2 ** 16; 
  172.    Visibility_Notify_Mask   : constant Gdk_Event_Mask := 2 ** 17; 
  173.    Proximity_In_Mask        : constant Gdk_Event_Mask := 2 ** 18; 
  174.    Proximity_Out_Mask       : constant Gdk_Event_Mask := 2 ** 19; 
  175.    Substructure_Mask        : constant Gdk_Event_Mask := 2 ** 20; 
  176.    Scroll_Mask              : constant Gdk_Event_Mask := 2 ** 21; 
  177.    All_Events_Mask          : constant Gdk_Event_Mask := 16#3FFFFE#; 
  178.  
  179.    type Gdk_Visibility_State is 
  180.      (Visibility_Unobscured, 
  181.       Visibility_Partial, 
  182.       Visibility_Fully_Obscured); 
  183.    pragma Convention (C, Gdk_Visibility_State); 
  184.  
  185.    type Gdk_Scroll_Direction is 
  186.      (Scroll_Up, 
  187.       Scroll_Down, 
  188.       Scroll_Left, 
  189.       Scroll_Right); 
  190.    pragma Convention (C, Gdk_Scroll_Direction); 
  191.  
  192.    type Gdk_Notify_Type is 
  193.      (Notify_Ancestor, 
  194.       Notify_Virtual, 
  195.       Notify_Inferior, 
  196.       Notify_Non_Linear, 
  197.       Notify_Non_Linear_Virtual, 
  198.       Notify_Unknown); 
  199.    pragma Convention (C, Gdk_Notify_Type); 
  200.  
  201.    type Gdk_Crossing_Mode is (Crossing_Normal, Crossing_Grab, Crossing_Ungrab); 
  202.    pragma Convention (C, Gdk_Crossing_Mode); 
  203.  
  204.    type Gdk_Property_State is (Property_New_Value, Property_Delete); 
  205.    pragma Convention (C, Gdk_Property_State); 
  206.  
  207.    type Gdk_Window_State is mod 2 ** 32; 
  208.    --  State of a Window. Default is 0. 
  209.  
  210.    Window_State_Withdraw  : constant Gdk_Window_State := 2 ** 0; 
  211.  
  212.    Window_State_Iconified : constant Gdk_Window_State := 2 ** 1; 
  213.    --  Window is iconified on the desktop 
  214.  
  215.    Window_State_Maximized : constant Gdk_Window_State := 2 ** 2; 
  216.    --  Window is maximized on the desktop 
  217.  
  218.    Window_State_Sticky    : constant Gdk_Window_State := 2 ** 3; 
  219.  
  220.    type Gdk_Setting_Action is 
  221.      (Setting_Action_New, 
  222.       Setting_Action_Changed, 
  223.       Setting_Action_Deleted); 
  224.    pragma Convention (C, Gdk_Setting_Action); 
  225.  
  226.    type Gdk_Device_Id is new Guint32; 
  227.    --  This type is specific to GtkAda. In Gdk, guint32 is used instead. 
  228.  
  229.    type Gdk_Event is new Gdk.C_Proxy; 
  230.  
  231.    subtype Gdk_Event_Any is Gdk_Event; 
  232.    --  Change from GtkAda1.2.3: There is no longer a tagged type 
  233.    --  hierarchy, only one type. 
  234.    --  However there are now a few runtime tests for each of the 
  235.    --  function, to check whether a given field is available or not. 
  236.    -- 
  237.    --  Fields common to all events: Window, Send_Event, Event_Type 
  238.  
  239.    subtype Gdk_Event_Expose is Gdk_Event; 
  240.    --  The window needs to be redrawn. For efficiency, gtk gives you the 
  241.    --  smallest area that you need to redraw. 
  242.    --  Relevant fields: Area, Region, Count 
  243.    --  Type: Expose 
  244.  
  245.    subtype Gdk_Event_No_Expose is Gdk_Event; 
  246.    --  Indicate that the source region was completely available when parts of 
  247.    --  a drawable were copied. 
  248.    --  This is also emitted when a gc whose "exposures" attribute is set to 
  249.    --  False in a call to Copy_Area or Draw_Pixmap. See the documentation for 
  250.    --  Gdk.GC.Set_Exposures. 
  251.    --  No Relevent fields except the common ones 
  252.    --  Type: No_Expose 
  253.  
  254.    subtype Gdk_Event_Visibility is Gdk_Event; 
  255.    --  The visibility state of the window (partially visibly, fully visible, 
  256.    --  hidden). This event almost never need to be used, since other events 
  257.    --  are generated at the same time, like expose_events 
  258.    --  Relevant fields: Visibility_State 
  259.    --  type: Visibility_Notify 
  260.  
  261.    subtype Gdk_Event_Motion is Gdk_Event; 
  262.    --  The mouse has moved 
  263.    --  Relevant fields: Time, X, Y, Axes, State, Is_Hint, Device_Id, 
  264.    --  X_Root, Y_Root 
  265.    --  Type: Motion_Notify 
  266.  
  267.    subtype Gdk_Event_Button is Gdk_Event; 
  268.    --  A button was pressed or released. 
  269.    --  Relevant fields: Time, X, Y, Axes, State, Button, Device_Id, 
  270.    --  X_Root, Y_Root, Window. 
  271.    --  Type: Button_Press, Gdk_2Button_Press, Gdk_3Button_Press or 
  272.    --  Button_Release. 
  273.  
  274.    subtype Gdk_Event_Scroll is Gdk_Event; 
  275.    --  A button was pressed or released. 
  276.    --  Relevant fields: Time, X, Y, State, Direction, Device_Id, X_Root, Y_Root 
  277.    --  Type: Scroll 
  278.  
  279.    subtype Gdk_Event_Key is Gdk_Event; 
  280.    --  A keyboard key was pressed 
  281.    --  Relevant fields: Time, State, Key_Val, String, Hardware_Keycode, Group 
  282.    --  Type: Key_Press, Key_Release 
  283.  
  284.    subtype Gdk_Event_Crossing is Gdk_Event; 
  285.    --  The mouse has been moved in or out of the window 
  286.    --  Relevant fields: SubWindow, Time, X, Y, X_Root, Y_Root, Mode, 
  287.    --  Detail, Focus, State 
  288.    --  Type: Enter_Notify, Leave_Notify 
  289.  
  290.    subtype Gdk_Event_Focus is Gdk_Event; 
  291.    --  The focus has changed for a window. 
  292.    --  Relevant fields: in 
  293.    --  Type: Focus_Change 
  294.  
  295.    subtype Gdk_Event_Configure is Gdk_Event; 
  296.    --  The window configuration has changed: either it was remapped, 
  297.    --  resized, moved, ... 
  298.    --  Note that you usually don't have to redraw your window when you 
  299.    --  receive such an event, since it is followed by an Gdk_Event_Expose. 
  300.    --  Relevant fields: X, Y, Width, Height 
  301.    --  Type: Configure 
  302.  
  303.    subtype Gdk_Event_Property is Gdk_Event; 
  304.    --  Some property of the window was modified. GtkAda provides a higher 
  305.    --  level interface, and you almost never need to use this event. 
  306.    --  Relevent fields: Atom, Time, Property_State 
  307.    --  Type: Property_Notify 
  308.  
  309.    subtype Gdk_Event_Selection is Gdk_Event; 
  310.    --  This is how X11 implements a simple cut-and-paste mechanism. However, 
  311.    --  GtkAda provides a higher level interface to the selection mechanism, 
  312.    --  so this event will almost never be used. 
  313.    --  Relevant fields: Selection, Target, Property, Time, Requestor 
  314.    --  Type: Selection_Clear, Selection_Request, Selection_Notify 
  315.  
  316.    subtype Gdk_Event_Proximity is Gdk_Event; 
  317.    --  This event type will be used pretty rarely. It only is 
  318.    --  important for XInput aware programs that are drawing their own 
  319.    --  cursor. This is only used with non standard input devices, like 
  320.    --  graphic tablets. 
  321.    --  Relevant fields: Time, Device_Id 
  322.    --  Type: Proximity_In, Proximity_Out 
  323.  
  324.    subtype Gdk_Event_Client is Gdk_Event; 
  325.    --  This is an event used to send arbitrary data from one X application 
  326.    --  to another. This event too is almost never used, and is not documented 
  327.    --  here. Please consult an X11 documentation for more information. 
  328.    --  Relevant fields: Message_Type, Data 
  329.    --  Type: Client_Event 
  330.  
  331.    subtype Gdk_Event_Setting is Gdk_Event; 
  332.    --  ??? 
  333.    --  Relevant fields: Action, Name. 
  334.    --  Type: ??? 
  335.  
  336.    subtype Gdk_Event_Window_State is Gdk_Event; 
  337.    --  ??? 
  338.    --  Relevant fields: Changed_Mask, New_Window_State. 
  339.    --  Type: Delete, Destroy, Map, Unmap ??? 
  340.  
  341.    subtype Gdk_Event_DND is Gdk_Event; 
  342.    --  ??? 
  343.    --  Relevant fields: Context, Time, X_Root, Y_Root 
  344.    --  Type: Drag_Enter, Drag_Leave, Drag_Motion, Drag_Status, Drop_Start, 
  345.    --  Drop_Finished 
  346.  
  347.    ---------------------------------------- 
  348.    -- Specific definition for the fields -- 
  349.    ---------------------------------------- 
  350.  
  351.    type Gdk_Event_Client_Data_Format is 
  352.      (Char_Array, Short_Array, Long_Array); 
  353.    for Gdk_Event_Client_Data_Format use 
  354.      (Char_Array  => 8, Short_Array => 16, Long_Array  => 32); 
  355.    --  Values extracted from the XClientMessageEvent man page. 
  356.  
  357.    Number_Of_Characters : constant := 20; 
  358.    Number_Of_Shorts     : constant := 10; 
  359.    Number_Of_Longs      : constant := 5; 
  360.  
  361.    type Gdk_Event_Client_Data 
  362.      (Format : Gdk_Event_Client_Data_Format) is 
  363.    record 
  364.       case Format is 
  365.          when Char_Array => 
  366.             B : String (1 .. Number_Of_Characters); 
  367.          when Short_Array => 
  368.             S : Gshort_Array (1 .. Number_Of_Shorts); 
  369.          when Long_Array => 
  370.             L : Glong_Array (1 .. Number_Of_Longs); 
  371.       end case; 
  372.    end record; 
  373.  
  374.    ----------------------------------- 
  375.    -- Access to fields of the event -- 
  376.    ----------------------------------- 
  377.    --  The following functions can be used to retrieve some specific fields 
  378.    --  from an event. Some of these fields do not exist for all the types of 
  379.    --  events (see the description of each event for a list of the relevant 
  380.    --  fields). 
  381.    --  Note also that you can not pass a null event to them. The parameter must 
  382.    --  be a correct event, or the result is undefined. 
  383.  
  384.    Invalid_Field : exception; 
  385.    --  If a field does not exist for the event you gave, an exception 
  386.    --  Invalid_Field is raised 
  387.  
  388.    function Get_Event_Type (Event : Gdk_Event) return Gdk_Event_Type; 
  389.    --  The type of the event. 
  390.  
  391.    function Get_Send_Event (Event : Gdk_Event) return Boolean; 
  392.    --  Set to true if the event was generated by the application, False 
  393.    --  if generated by the X server/Win32. 
  394.  
  395.    function Get_Window    (Event : Gdk_Event) return Gdk.Gdk_Window; 
  396.    --  The window the event occured on. 
  397.    --  See the function Gdk.Window.Get_User_Data to get the actual widget. 
  398.  
  399.    function Get_Time      (Event : Gdk_Event) return Guint32; 
  400.    --  Time when the event occured. 
  401.  
  402.    function Get_X         (Event : Gdk_Event) return Gdouble; 
  403.    --  Horizontal coordinate of the mouse when the event occured. 
  404.    --  The coordinates are relative to the parent window. 
  405.  
  406.    function Get_Y         (Event : Gdk_Event) return Gdouble; 
  407.    --  Vertical coordinate of the mouse when the event occured. 
  408.    --  The coordinates are relative to the parent window. 
  409.  
  410.    function Get_X_Root    (Event : Gdk_Event) return Gdouble; 
  411.    --  Horizontal coordinate of the mouse when the event occured. 
  412.    --  Relative to the root window. 
  413.  
  414.    function Get_Y_Root    (Event : Gdk_Event) return Gdouble; 
  415.    --  Vertical coordinate of the mouse when the event occured. 
  416.    --  Relative to the root window. 
  417.  
  418.    function Get_Button    (Event : Gdk_Event) return Guint; 
  419.    --  Number of the button that was pressed. 
  420.  
  421.    function Get_State (Event : Gdk_Event) return Gdk.Types.Gdk_Modifier_Type; 
  422.    --  State of the mouse buttons and keyboard keys just prior to the event. 
  423.  
  424.    function Get_Subwindow (Event : Gdk_Event) return Gdk.Gdk_Window; 
  425.    --  Child window for the event. 
  426.    --  For an Enter_Notify_Event, this is set to the initial window for the 
  427.    --  pointer; for an Leave_Notify_Event this is set to the window occupied 
  428.    --  by the pointer in its last position. 
  429.  
  430.    function Get_Mode (Event : Gdk_Event) return Gdk_Crossing_Mode; 
  431.    --  Return the mode of an Event. 
  432.    --  Set to indicate whether the events are normal events, pseudo-motion 
  433.    --  events when a grab activates or pseudo-motion events when a grab 
  434.    --  deativates. 
  435.  
  436.    function Get_Detail (Event : Gdk_Event) return Gdk_Notify_Type; 
  437.    --  Set to indicate the notify details. 
  438.    --  Most applications can ignore events with a Notify Virtual or a 
  439.    --  Notify_Non_Linear_Virtual detail. 
  440.  
  441.    function Get_Focus (Event : Gdk_Event) return Boolean; 
  442.    --  Set to true if the window for the event is the focus window. 
  443.  
  444.    function Get_Width (Event : Gdk_Event) return Gint; 
  445.    --  Get the width in a configure event. 
  446.  
  447.    function Get_Height (Event : Gdk_Event) return Gint; 
  448.    --  Get the height in a configure event. 
  449.  
  450.    function Get_Direction (Event : Gdk_Event) return Gdk_Scroll_Direction; 
  451.    --  Get the direction in a scroll event. 
  452.  
  453.    function Get_Device_Id (Event : Gdk_Event) return Gdk_Device_Id; 
  454.    --  Set to a constant for now in the gtk+ source... Probably useless. 
  455.    --  Since multiple input devices can be used at the same time, like a mouse 
  456.    --  and a graphic tablet, this indicates which one generated the event. 
  457.  
  458.    function Get_Area (Event : Gdk_Event) return Rectangle.Gdk_Rectangle; 
  459.    --  The minimal area on which the event applies. 
  460.    --  For Expose_Events, this is the minimal area to redraw. 
  461.  
  462.    function Get_Region (Event : Gdk_Event) return Gdk.Region.Gdk_Region; 
  463.    --  Return the region to which the event applies. 
  464.    --  Do not free the returned value 
  465.  
  466.    function Get_Count (Event : Gdk_Event) return Gint; 
  467.    --  Number of Expose_Events that are to follow this one. 
  468.    --  Most applications can ignore the event if Count is not 0, which also 
  469.    --  allows for optimizations. 
  470.  
  471.    function Get_In (Event : Gdk_Event) return Boolean; 
  472.    --  True if the window has gained the focus, False otherwise. 
  473.  
  474.    function Get_Is_Hint (Event : Gdk_Event) return Boolean; 
  475.    --  ??? 
  476.  
  477.    function Get_Key_Val (Event : Gdk_Event) return Gdk.Types.Gdk_Key_Type; 
  478.    --  Code of the key that was pressed (and that generated the event). 
  479.  
  480.    function Get_Group (Event : Gdk_Event) return Guint8; 
  481.    --  Group of the key that was pressed; 
  482.  
  483.    function Get_Hardware_Keycode (Event : Gdk_Event) return Guint16; 
  484.    --  Hardware key code of the key that was pressed. 
  485.  
  486.    function Get_String  (Event : Gdk_Event) return String; 
  487.    --  Symbol of the key that was pressed, as a string. 
  488.  
  489.    function Get_Atom (Event : Gdk_Event) return Gdk.Types.Gdk_Atom; 
  490.    --  Indicate which property has changed. 
  491.    --  ??? Atom should not be a Guint 
  492.  
  493.    function Get_Property_State (Event : Gdk_Event) return Guint; 
  494.    --  ??? The return type should be changed. 
  495.  
  496.    function Get_Visibility_State 
  497.      (Event : Gdk_Event) return Gdk_Visibility_State; 
  498.    --  Return the new visibility state for the window. 
  499.  
  500.    function Get_Selection (Event : Gdk_Event) return Gdk.Types.Gdk_Atom; 
  501.    --  What was selected in the window... 
  502.  
  503.    function Get_Target (Event : Gdk_Event) return Gdk.Types.Gdk_Atom; 
  504.    --  ??? 
  505.  
  506.    function Get_Property (Event : Gdk_Event) return Gdk.Types.Gdk_Atom; 
  507.    --  ??? 
  508.  
  509.    function Get_Requestor (Event : Gdk_Event) return Guint32; 
  510.    --  ??? 
  511.  
  512.    function Get_Message_Type (Event : Gdk_Event) return Gdk.Types.Gdk_Atom; 
  513.    --  ??? 
  514.  
  515.    function Get_Data (Event : Gdk_Event) return Gdk_Event_Client_Data; 
  516.    --  ??? 
  517.  
  518.    -------------------------------------- 
  519.    -- Modifying the fields of an event -- 
  520.    -------------------------------------- 
  521.  
  522.    procedure Set_Window (Event : Gdk_Event; Win : Gdk.Gdk_Window); 
  523.    --  Set the Window field of an event. 
  524.  
  525.    procedure Set_X      (Event : Gdk_Event; X : Gdouble); 
  526.    --  Set the X field of an event. 
  527.  
  528.    procedure Set_Y      (Event : Gdk_Event; Y : Gdouble); 
  529.    --  Set the Y field of an event. 
  530.  
  531.    procedure Set_Xroot  (Event : Gdk_Event; Xroot : Gdouble); 
  532.    --  Set the Xroot field of an event. 
  533.  
  534.    procedure Set_Yroot  (Event : Gdk_Event; Yroot : Gdouble); 
  535.    --  Set the Yroot field of an event. 
  536.  
  537.    procedure Set_Width  (Event : Gdk_Event; Width : Gint); 
  538.    --  Set the Width field of an event. 
  539.  
  540.    procedure Set_Height (Event : Gdk_Event; Height : Gint); 
  541.    --  Set the Height field of an event. 
  542.  
  543.    procedure Set_Button (Event : Gdk_Event; Button : Guint); 
  544.    --  Set the Button field of an event. 
  545.  
  546.    procedure Set_Time (Event : Gdk_Event; Time : Guint32); 
  547.    --  Set the time for the event. 
  548.    --  If Time is 0, then it is set to the current time. 
  549.  
  550.    procedure Set_State 
  551.      (Event : Gdk_Event; State : Gdk.Types.Gdk_Modifier_Type); 
  552.    --  Set the State field of an event. 
  553.  
  554.    procedure Set_Subwindow (Event : Gdk_Event; Window : Gdk.Gdk_Window); 
  555.    --  Set the Subwindow field of an event. 
  556.  
  557.    procedure Set_Mode (Event : Gdk_Event; Mode : Gdk_Crossing_Mode); 
  558.    --  Set the Mode field of an event. 
  559.  
  560.    procedure Set_Detail (Event : Gdk_Event; Detail : Gdk_Notify_Type); 
  561.    --  Set the Detail field of an event. 
  562.  
  563.    procedure Set_Focus (Event : Gdk_Event; Has_Focus : Boolean); 
  564.    --  Set the Focus field of an event. 
  565.  
  566.    procedure Set_Area  (Event : Gdk_Event; Area : Rectangle.Gdk_Rectangle); 
  567.    --  Set the Area field of an event. 
  568.  
  569.    procedure Set_In    (Event : Gdk_Event; Focus_In : Boolean); 
  570.    --  Set the In field of an event. 
  571.  
  572.    procedure Set_Is_Hint (Event : Gdk_Event; Is_Hint : Boolean); 
  573.    --  Set the Is_Hint field of an event. 
  574.  
  575.    procedure Set_Key_Val (Event : Gdk_Event; Key : Gdk.Types.Gdk_Key_Type); 
  576.    --  Set the Key_Val field of an event. 
  577.  
  578.    procedure Set_Group (Event : Gdk_Event; Group : Guint8); 
  579.    --  Set the group field of a key event. 
  580.  
  581.    procedure Set_Hardware_Keycode (Event : Gdk_Event; Keycode : Guint16); 
  582.    --  Set the hardware key code field of a key event. 
  583.  
  584.    procedure Set_Direction 
  585.      (Event : Gdk_Event; Direction : Gdk_Scroll_Direction); 
  586.    --  Set the direction field of a scroll event. 
  587.  
  588.    procedure Set_Atom (Event : Gdk_Event; Atom : Gdk.Types.Gdk_Atom); 
  589.    --  Set the Atom field of an event. 
  590.  
  591.    procedure Set_Property_State (Event : Gdk_Event; State : Guint); 
  592.    --  Set the Property_State field of an event. 
  593.  
  594.    procedure Set_Visibility_State 
  595.      (Event : Gdk_Event; State : Gdk_Visibility_State); 
  596.    --  Set the Visibility_State field of an event. 
  597.  
  598.    procedure Set_Selection (Event : Gdk_Event; Selection : Gdk.Types.Gdk_Atom); 
  599.    --  Set the Selection field of an event. 
  600.  
  601.    procedure Set_Target (Event : Gdk_Event; Target : Gdk.Types.Gdk_Atom); 
  602.    --  Set the Target field of an event. 
  603.  
  604.    procedure Set_Property (Event : Gdk_Event; Property : Gdk.Types.Gdk_Atom); 
  605.    --  Set the Property field of an event. 
  606.  
  607.    procedure Set_Requestor (Event : Gdk_Event; Requestor : Guint32); 
  608.    --  Set the Requestor field of an event. 
  609.  
  610.    procedure Set_Message_Type (Event : Gdk_Event; Typ : Gdk.Types.Gdk_Atom); 
  611.    --  Set the Message_Type field of an event. 
  612.  
  613.    procedure Set_String (Event : Gdk_Event; Str : String); 
  614.    --  Set the string associated with an event. 
  615.  
  616.    ----------------------- 
  617.    -- General functions -- 
  618.    ----------------------- 
  619.  
  620.    function Get_Type return GType; 
  621.    --  Return the type corresponding to a Gdk_Event. 
  622.  
  623.    procedure Deep_Copy (From : Gdk_Event; To : out Gdk_Event); 
  624.    --  Deep copy for an event. The C structure is itself duplicated. 
  625.    --  You need to deallocated it yourself with a call to Free below. 
  626.  
  627.    procedure Get_Graphics_Expose 
  628.      (Event  : out Gdk_Event_Expose; 
  629.       Window : Gdk.Gdk_Window); 
  630.    --  Waits for a GraphicsExpose or NoExpose event 
  631.    --  If it gets a GraphicsExpose event, it returns a pointer to it, 
  632.    --  otherwise it returns an event for which Is_Created is False. 
  633.    -- 
  634.    --  This function can be used to implement scrolling: you must call 
  635.    --  Gdk.GC.Set_Exposures with True on the GC you are using for the 
  636.    --  drawing, so that a events are generated for obscured areas and every 
  637.    --  time a new part of the widget is drawn. However, there is a race 
  638.    --  condition if multiple scrolls happen before you have finished 
  639.    --  processing the first one. A workaround is to call Get_Graphics_Expose 
  640.    --  after every scroll until it returns a null event. 
  641.  
  642.    function Events_Pending return Boolean; 
  643.    --  Is there any event pending on the queue ? 
  644.  
  645.    procedure Get (Event : out Gdk_Event); 
  646.    --  Get the next event on the queue. 
  647.  
  648.    procedure Peek (Event : out Gdk_Event); 
  649.    --  Look at the next event on the queue, but leave if there. 
  650.  
  651.    procedure Put (Event : Gdk_Event); 
  652.    --  Add an event on the queue - Better to use Gtk.Signal.Emit_By_Name 
  653.  
  654.    procedure Set_Show_Events (Show_Events : Boolean := True); 
  655.    --  For debug purposes, you can choose whether you want to see the events 
  656.    --  GtkAda receives. 
  657.  
  658.    function Get_Show_Events return Boolean; 
  659.    --  Return the current state of Show_Events. 
  660.  
  661.    procedure Send_Client_Message_To_All (Event : Gdk_Event); 
  662.    --  Low level routine to send an Event to every window. 
  663.  
  664.    function Send_Client_Message 
  665.      (Event : Gdk_Event; 
  666.       Xid   : Guint32) return Boolean; 
  667.    --  Low level routine to send an Event to a specified X window. 
  668.  
  669.    procedure Allocate 
  670.      (Event      : out Gdk_Event; 
  671.       Event_Type : Gdk_Event_Type; 
  672.       Window     : Gdk.Gdk_Window); 
  673.    --  Create an event, whose fields are uninitialized. 
  674.    --  You need to use the function Set_* above to modify them, before you can 
  675.    --  send the event with Emit_By_Name. 
  676.    --  !!Note!!: The event has to be freed if you have called this function. 
  677.    --  Use the function Free below. 
  678.  
  679.    procedure Free (Event : in out Gdk_Event); 
  680.    --  Free the memory (and C structure) associated with an event. 
  681.    --  You need to call this function only if the event was created through 
  682.    --  Allocate, not if it was created by GtkAda itself (or you would get 
  683.    --  a segmentation fault). 
  684.  
  685.    type Event_Handler_Func is access procedure 
  686.      (Event : Gdk_Event; Data : System.Address); 
  687.    pragma Convention (C, Event_Handler_Func); 
  688.    --  Function that can be used as a new event handler. 
  689.    --  This function should dispatch all the events properly, since it replaces 
  690.    --  completly the default event handler. However, it can call 
  691.    --  Gtk.Main.Do_Event to take care of the events it does not know how to 
  692.    --  handle. 
  693.    --  See also Gtk.Main.Get_Event_Widget to get the widget from the event. 
  694.  
  695.    procedure Event_Handler_Set 
  696.      (Func : Event_Handler_Func; Data : System.Address); 
  697.    --  Set up a new event handler. 
  698.    --  This handler replaces the default GtkAda event handler, and thus should 
  699.    --  make sure that all events are correctly handled. 
  700.    -- 
  701.    --  Note that managing the memory for Data is your responsability, and 
  702.    --  Data is passed as is to Func. 
  703.  
  704.    function From_Address (C : System.Address) return Gdk_Event; 
  705.    --  Convert a C handler to the matching Event structure. 
  706.  
  707.    function To_Address (C : Gdk_Event) return System.Address; 
  708.    --  Convert an event to the underlying C handler. 
  709.  
  710.    function Is_Created (E : Gdk_Event) return Boolean; 
  711.    --  Return True if the underlying C event has been created. 
  712.  
  713.    -------------------- 
  714.    -- GValue support -- 
  715.    -------------------- 
  716.  
  717.    function Get_Event (Value : Glib.Values.GValue) return Gdk_Event; 
  718.    --  Convert a value into a Gdk_Event. 
  719.  
  720.    ---------------- 
  721.    -- Properties -- 
  722.    ---------------- 
  723.    --  The following packages and types are used to represent properties of 
  724.    --  the given type. They are used in the packages that use these properties 
  725.  
  726.    package Event_Mask_Properties is new Generic_Internal_Discrete_Property 
  727.      (Gdk_Event_Mask); 
  728.  
  729.    type Property_Gdk_Event_Mask is new Event_Mask_Properties.Property; 
  730.  
  731.    ------------------- 
  732.    -- Design issues -- 
  733.    ------------------- 
  734.    --  See gdk-event.adb for some of the design issues behing that package. 
  735.  
  736.    --------------------- 
  737.    -- Event Recording -- 
  738.    --------------------- 
  739.  
  740.    procedure Set_Follow_Events (Follow_Events : Boolean := True); 
  741.    --  Set whether windows should follow events that they normally don't 
  742.    --  (such as motion events) for event recording purposes. 
  743.    --  This function is used in cunjonction with GtkAda.Macro 
  744.  
  745.    function Get_Follow_Events return Boolean; 
  746.    --  Return follow_events value. 
  747.    --  See Set_Follow_Events for more details. 
  748.  
  749. private 
  750.  
  751.    for Gdk_Event_Type use 
  752.      (Nothing => -1, 
  753.       Delete => 0, 
  754.       Destroy => 1, 
  755.       Expose => 2, 
  756.       Motion_Notify => 3, 
  757.       Button_Press => 4, 
  758.       Gdk_2button_Press => 5, 
  759.       Gdk_3button_Press => 6, 
  760.       Button_Release => 7, 
  761.       Key_Press => 8, 
  762.       Key_Release => 9, 
  763.       Enter_Notify => 10, 
  764.       Leave_Notify => 11, 
  765.       Focus_Change => 12, 
  766.       Configure => 13, 
  767.       Map => 14, 
  768.       Unmap => 15, 
  769.       Property_Notify => 16, 
  770.       Selection_Clear => 17, 
  771.       Selection_Request => 18, 
  772.       Selection_Notify => 19, 
  773.       Proximity_In => 20, 
  774.       Proximity_Out => 21, 
  775.       Drag_Enter => 22, 
  776.       Drag_Leave => 23, 
  777.       Drag_Motion => 24, 
  778.       Drag_Status => 25, 
  779.       Drop_Start => 26, 
  780.       Drop_Finished => 27, 
  781.       Client_Event => 28, 
  782.       Visibility_Notify => 29, 
  783.       No_Expose => 30, 
  784.       Scroll => 31, 
  785.       Window_State => 32, 
  786.       Setting => 33, 
  787.       Owner_Change => 34, 
  788.       Grab_Broken => 35); 
  789.  
  790.    pragma Import (C, Get_Type, "gdk_event_get_type"); 
  791.    pragma Import (C, Get_Event_Type, "ada_gdk_event_get_type"); 
  792.    pragma Import (C, Get_Window, "ada_gdk_event_get_window"); 
  793.    pragma Import (C, Get_Time, "gdk_event_get_time"); 
  794.    pragma Import (C, Put, "gdk_event_put"); 
  795.    pragma Import (C, Get_Region, "ada_gdk_event_get_region"); 
  796.    pragma Import 
  797.      (C, Send_Client_Message_To_All, "gdk_event_send_clientmessage_toall"); 
  798.    pragma Import (C, Set_Window, "ada_gdk_event_set_window"); 
  799.  
  800. end Gdk.Event;