1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                  Copyright (C) 2001-2005                          -- 
  5. --                         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. --  <group>Gdk, the low-level API</group> 
  26. with Glib; use Glib; 
  27. with Gdk.Types; use Gdk.Types; 
  28. with Gdk.Window; 
  29. with Gtk; 
  30. with Gtk.Selection; use Gtk.Selection; 
  31.  
  32. package Gdk.Dnd is 
  33.  
  34.    ----------------- 
  35.    -- Drag_Action -- 
  36.    ----------------- 
  37.  
  38.    type Drag_Action is mod 2 ** 32; 
  39.    --  Possible actions for a drop onto a widget, during a drag-and-drop. 
  40.    --  The drag widgets (ie the ones from which the user can start a 
  41.    --  drag-and-drop operation) should set a mask, indicating which actions 
  42.    --  it wants to do. The first action in the list below has the highest 
  43.    --  priority, the last one the lowest. The actual action chosen for the 
  44.    --  drag-and-drop will be the highest-priority one that is also accepted 
  45.    --  by the drop site. 
  46.    -- 
  47.    --  Note that in the case where the drag source supports multiple actions, 
  48.    --  the user can select the one he wants. As explained above, the default 
  49.    --  one is the highest priority one. But if the user pressed Shift at the 
  50.    --  same time, Action_Move will be used if present. Ctrl-Shift selects 
  51.    --  an Action_Link, and Ctrl selects an Action_Copy. 
  52.  
  53.    Action_Any : constant Drag_Action; 
  54.    --  Any of the default action is accepted. 
  55.  
  56.    Action_Default : constant Drag_Action; 
  57.    --  ??? 
  58.  
  59.    Action_Copy    : constant Drag_Action; 
  60.    --  Copy the data to the drop site. 
  61.  
  62.    Action_Move    : constant Drag_Action; 
  63.    --  Copy the data to the drop site, and delete it from the drag source. 
  64.    --  The delete command is invoked automatically by GtkAda. 
  65.  
  66.    Action_Link    : constant Drag_Action; 
  67.    --  Allow the drop site to access the data, without copying it. 
  68.  
  69.    Action_Private : constant Drag_Action; 
  70.    --  Any action you want to implement. No automatic behavior is provided 
  71.    --  by GtkAda. 
  72.  
  73.    Action_Ask     : constant Drag_Action; 
  74.    --  ??? 
  75.  
  76.    ------------------- 
  77.    -- Drag_Protocol -- 
  78.    ------------------- 
  79.  
  80.    type Drag_Protocol is 
  81.      (Drag_Proto_Motif, 
  82.       Drag_Proto_Xdnd, 
  83.       Drag_Proto_Rootwin, 
  84.       Drag_Proto_None, 
  85.       Drag_Proto_Win32_Dropfiles, 
  86.       Drag_Proto_Ole2, 
  87.       Drag_Proto_Local); 
  88.    --  The various dnd protocols recognized by a window. 
  89.    --  Note that not every window recognizes every protocol, and you should 
  90.    --  be careful as to which one you use. The function Gdk.Drag_Get_Protocol 
  91.    --  returns which one is recognized by a window. 
  92.  
  93.    ------------------ 
  94.    -- Drag_Context -- 
  95.    ------------------ 
  96.  
  97.    type Drag_Context is new Gdk.C_Proxy; 
  98.    --  Structure that holds information about a drag in progress. 
  99.    --  This is used on both source and destination sides. 
  100.  
  101.    ------------------ 
  102.    -- Drag_Context -- 
  103.    ------------------ 
  104.  
  105.    function Get_Actions (Context : Drag_Context) return Drag_Action; 
  106.    --  Return the possible actions associated with the context. 
  107.    --  This is the list of actions defined by the source of the drag-and-drop 
  108.    --  operation, in Source_Set. 
  109.    --  (for instance, if Source_Set was used with Action_Copy + Action_Move, 
  110.    --  the result will be exactly this sum, whatever was used for Dest_Set). 
  111.  
  112.    function Get_Suggested_Action (Context : Drag_Context) return Drag_Action; 
  113.    --  Return the suggested action for that context. 
  114.    --  This is the highest priority action that was set by the source of the 
  115.    --  drag-and-drop, ie the one it would rather use. The action that is 
  116.    --  actually used is the one returned by Get_Action, and depends on the 
  117.    --  mask set by the target. 
  118.  
  119.    function Get_Action (Context : Drag_Context) return Drag_Action; 
  120.    --  Return the action selected for the drag-and-drop operation. 
  121.    --  This is the highest priority action common between the drag site and the 
  122.    --  drop widget (for instance, if Source_Set was used with Action_Copy + 
  123.    --  Action_Move and Dest_Set was used with only Action_Move, this will 
  124.    --  be Action_Move). 
  125.  
  126.    type Gdk_Atom_Array is array (Natural range <>) of Gdk.Types.Gdk_Atom; 
  127.    function Get_Targets (Context : Drag_Context) return Gdk_Atom_Array; 
  128.    --  Return the list of targets supported by this context. 
  129.  
  130.    procedure Drag_Context_Ref (Context : Drag_Context); 
  131.  
  132.    procedure Drag_Context_Unref (Context : Drag_Context); 
  133.  
  134.    procedure Drag_Status 
  135.      (Context : Drag_Context; 
  136.       Action  : Drag_Action; 
  137.       Time    : Guint32); 
  138.  
  139.    procedure Drop_Reply 
  140.      (Context : Drag_Context; 
  141.       Ok      : Boolean; 
  142.       Time    : Guint32); 
  143.  
  144.    procedure Drop_Finish 
  145.      (Context : Drag_Context; 
  146.       Success : Boolean; 
  147.       Time    : Guint32); 
  148.    --  Clean up from the drag, and display snapback, if necessary. 
  149.  
  150.    function Drag_Get_Selection (Context : Drag_Context) return Gdk_Atom; 
  151.  
  152.    function Drag_Begin 
  153.      (Window  : Gdk.Window.Gdk_Window; 
  154.       Targets : Target_List) return Drag_Context; 
  155.  
  156.    function Drag_Get_Protocol 
  157.      (Xid      : Guint32; 
  158.       Protocol : Drag_Protocol) return Guint32; 
  159.    --  Return which drag protocol is recognized by a given low level window. 
  160.  
  161.    procedure Drag_Find_Window 
  162.      (Context     : Drag_Context; 
  163.       Drag_Window : Gdk.Window.Gdk_Window; 
  164.       X_Root      : Gint; 
  165.       Y_Root      : Gint; 
  166.       Dest_Window : Gdk.Window.Gdk_Window; 
  167.       Protocol    : Drag_Protocol); 
  168.  
  169.    function Drag_Motion 
  170.      (Context          : Drag_Context; 
  171.       Dest_Window      : Gdk.Window.Gdk_Window; 
  172.       Protocol         : Drag_Protocol; 
  173.       X_Root           : Gint; 
  174.       Y_Root           : Gint; 
  175.       Suggested_Action : Drag_Action; 
  176.       Possible_Actions : Drag_Action; 
  177.       Time             : Guint32) return Boolean; 
  178.  
  179.    procedure Drag_Drop (Context : Drag_Context; Time : Guint32); 
  180.  
  181.    procedure Drag_Abort (Context : Drag_Context; Time : Guint32); 
  182.  
  183. private 
  184.  
  185.    pragma Import (C, Get_Actions, "ada_gtk_dnd_context_get_actions"); 
  186.    pragma Import 
  187.      (C, Get_Suggested_Action, 
  188.      "ada_gtk_dnd_context_get_suggested_action"); 
  189.    pragma Import (C, Get_Action, "ada_gtk_dnd_context_get_action"); 
  190.  
  191.    Action_Default : constant Drag_Action := 2 ** 0; 
  192.    Action_Copy    : constant Drag_Action := 2 ** 1; 
  193.    Action_Move    : constant Drag_Action := 2 ** 2; 
  194.    Action_Link    : constant Drag_Action := 2 ** 3; 
  195.    Action_Private : constant Drag_Action := 2 ** 4; 
  196.    Action_Ask     : constant Drag_Action := 2 ** 5; 
  197.    Action_Any     : constant Drag_Action := 2 ** 8 - 1; 
  198.  
  199. end Gdk.Dnd;