1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                  Copyright (C) 2001-2013, AdaCore                 -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <group>Gdk, the low-level API</group> 
  30. with Glib; use Glib; 
  31. with Gdk.Types; use Gdk.Types; 
  32. with Gdk.Window; 
  33. with Gtk; 
  34. with Gtk.Selection; use Gtk.Selection; 
  35.  
  36. package Gdk.Dnd is 
  37.  
  38.    ----------------- 
  39.    -- Drag_Action -- 
  40.    ----------------- 
  41.  
  42.    type Drag_Action is mod 2 ** 32; 
  43.    --  Possible actions for a drop onto a widget, during a drag-and-drop. 
  44.    --  The drag widgets (ie the ones from which the user can start a 
  45.    --  drag-and-drop operation) should set a mask, indicating which actions 
  46.    --  it wants to do. The first action in the list below has the highest 
  47.    --  priority, the last one the lowest. The actual action chosen for the 
  48.    --  drag-and-drop will be the highest-priority one that is also accepted 
  49.    --  by the drop site. 
  50.    -- 
  51.    --  Note that in the case where the drag source supports multiple actions, 
  52.    --  the user can select the one he wants. As explained above, the default 
  53.    --  one is the highest priority one. But if the user pressed Shift at the 
  54.    --  same time, Action_Move will be used if present. Ctrl-Shift selects 
  55.    --  an Action_Link, and Ctrl selects an Action_Copy. 
  56.  
  57.    Action_Any : constant Drag_Action; 
  58.    --  Any of the default action is accepted. 
  59.  
  60.    Action_Default : constant Drag_Action; 
  61.    --  ??? 
  62.  
  63.    Action_Copy    : constant Drag_Action; 
  64.    --  Copy the data to the drop site. 
  65.  
  66.    Action_Move    : constant Drag_Action; 
  67.    --  Copy the data to the drop site, and delete it from the drag source. 
  68.    --  The delete command is invoked automatically by GtkAda. 
  69.  
  70.    Action_Link    : constant Drag_Action; 
  71.    --  Allow the drop site to access the data, without copying it. 
  72.  
  73.    Action_Private : constant Drag_Action; 
  74.    --  Any action you want to implement. No automatic behavior is provided 
  75.    --  by GtkAda. 
  76.  
  77.    Action_Ask     : constant Drag_Action; 
  78.    --  ??? 
  79.  
  80.    ------------------- 
  81.    -- Drag_Protocol -- 
  82.    ------------------- 
  83.  
  84.    type Drag_Protocol is 
  85.      (Drag_Proto_Motif, 
  86.       Drag_Proto_Xdnd, 
  87.       Drag_Proto_Rootwin, 
  88.       Drag_Proto_None, 
  89.       Drag_Proto_Win32_Dropfiles, 
  90.       Drag_Proto_Ole2, 
  91.       Drag_Proto_Local); 
  92.    --  The various dnd protocols recognized by a window. 
  93.    --  Note that not every window recognizes every protocol, and you should 
  94.    --  be careful as to which one you use. The function Gdk.Drag_Get_Protocol 
  95.    --  returns which one is recognized by a window. 
  96.  
  97.    ------------------ 
  98.    -- Drag_Context -- 
  99.    ------------------ 
  100.  
  101.    type Drag_Context is new Gdk.C_Proxy; 
  102.    --  Structure that holds information about a drag in progress. 
  103.    --  This is used on both source and destination sides. 
  104.  
  105.    ------------------ 
  106.    -- Drag_Context -- 
  107.    ------------------ 
  108.  
  109.    function Get_Actions (Context : Drag_Context) return Drag_Action; 
  110.    --  Return the possible actions associated with the context. 
  111.    --  This is the list of actions defined by the source of the drag-and-drop 
  112.    --  operation, in Source_Set. 
  113.    --  (for instance, if Source_Set was used with Action_Copy + Action_Move, 
  114.    --  the result will be exactly this sum, whatever was used for Dest_Set). 
  115.  
  116.    function Get_Suggested_Action (Context : Drag_Context) return Drag_Action; 
  117.    --  Return the suggested action for that context. 
  118.    --  This is the highest priority action that was set by the source of the 
  119.    --  drag-and-drop, ie the one it would rather use. The action that is 
  120.    --  actually used is the one returned by Get_Action, and depends on the 
  121.    --  mask set by the target. 
  122.  
  123.    function Get_Selected_Action (Context : Drag_Context) return Drag_Action; 
  124.    --  Return the action selected for the drag-and-drop operation. 
  125.    --  This is the highest priority action common between the drag site and the 
  126.    --  drop widget (for instance, if Source_Set was used with Action_Copy + 
  127.    --  Action_Move and Dest_Set was used with only Action_Move, this will 
  128.    --  be Action_Move). 
  129.  
  130.    function Get_Action (Context : Drag_Context) return Drag_Action 
  131.                         renames Get_Selected_Action; 
  132.    --  For backwards compatibility. 
  133.  
  134.    type Gdk_Atom_Array is array (Natural range <>) of Gdk.Types.Gdk_Atom; 
  135.    function Get_Targets (Context : Drag_Context) return Gdk_Atom_Array; 
  136.    --  Return the list of targets supported by this context. 
  137.  
  138.    procedure Drag_Context_Ref (Context : Drag_Context); 
  139.  
  140.    procedure Drag_Context_Unref (Context : Drag_Context); 
  141.  
  142.    procedure Drag_Status 
  143.      (Context : Drag_Context; 
  144.       Action  : Drag_Action; 
  145.       Time    : Guint32); 
  146.  
  147.    procedure Drop_Reply 
  148.      (Context : Drag_Context; 
  149.       Ok      : Boolean; 
  150.       Time    : Guint32); 
  151.  
  152.    procedure Drop_Finish 
  153.      (Context : Drag_Context; 
  154.       Success : Boolean; 
  155.       Time    : Guint32); 
  156.    --  Clean up from the drag, and display snapback, if necessary. 
  157.  
  158.    function Drag_Get_Selection (Context : Drag_Context) return Gdk_Atom; 
  159.  
  160.    function Drag_Begin 
  161.      (Window  : Gdk.Window.Gdk_Window; 
  162.       Targets : Target_List) return Drag_Context; 
  163.  
  164.    function Drag_Get_Protocol 
  165.      (Xid      : Guint32; 
  166.       Protocol : Drag_Protocol) return Guint32; 
  167.    --  Return which drag protocol is recognized by a given low level window. 
  168.  
  169.    procedure Drag_Find_Window 
  170.      (Context     : Drag_Context; 
  171.       Drag_Window : Gdk.Window.Gdk_Window; 
  172.       X_Root      : Gint; 
  173.       Y_Root      : Gint; 
  174.       Dest_Window : Gdk.Window.Gdk_Window; 
  175.       Protocol    : Drag_Protocol); 
  176.  
  177.    function Drag_Motion 
  178.      (Context          : Drag_Context; 
  179.       Dest_Window      : Gdk.Window.Gdk_Window; 
  180.       Protocol         : Drag_Protocol; 
  181.       X_Root           : Gint; 
  182.       Y_Root           : Gint; 
  183.       Suggested_Action : Drag_Action; 
  184.       Possible_Actions : Drag_Action; 
  185.       Time             : Guint32) return Boolean; 
  186.  
  187.    procedure Drag_Drop (Context : Drag_Context; Time : Guint32); 
  188.  
  189.    procedure Drag_Abort (Context : Drag_Context; Time : Guint32); 
  190.  
  191. private 
  192.  
  193.    pragma Import (C, Get_Actions, "gdk_drag_context_get_actions"); 
  194.    pragma Import 
  195.      (C, Get_Suggested_Action, 
  196.      "gdk_drag_context_get_suggested_action"); 
  197.    pragma Import (C, Get_Action, "gdk_drag_context_get_selected_action"); 
  198.  
  199.    Action_Default : constant Drag_Action := 2 ** 0; 
  200.    Action_Copy    : constant Drag_Action := 2 ** 1; 
  201.    Action_Move    : constant Drag_Action := 2 ** 2; 
  202.    Action_Link    : constant Drag_Action := 2 ** 3; 
  203.    Action_Private : constant Drag_Action := 2 ** 4; 
  204.    Action_Ask     : constant Drag_Action := 2 ** 5; 
  205.    Action_Any     : constant Drag_Action := 2 ** 8 - 1; 
  206.  
  207. end Gdk.Dnd;