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