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