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-2010 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. --  The Gtk_Handle_Box widget allows a portion of a window to be "torn off". 
  32. --  It is a bin widget which displays its child and a handle that the user can 
  33. --  drag to tear off a separate window (the float window) containing the child 
  34. --  widget. A thin ghost is drawn in the original location of the handlebox. By 
  35. --  dragging the separate window back to its original location, it can be 
  36. --  reattached. 
  37. -- 
  38. --  When reattaching, the ghost and float window, must be aligned along one of 
  39. --  the edges, the snap edge. This either can be specified by the application 
  40. --  programmer explicitely, or GtkAda will pick a reasonable default based on 
  41. --  the handle position. 
  42. -- 
  43. --  To make detaching and reattaching the handlebox as minimally confusing as 
  44. --  possible to the user, it is important to set the snap edge so that the snap 
  45. --  edge does not move when the handlebox is detached. For instance, if the 
  46. --  handlebox is packed at the bottom of a Vbox, then when the handlebox is 
  47. --  detached, the bottom edge of the handlebox's allocation will remain fixed 
  48. --  as the height of the handlebox shrinks, so the snap edge should be set to 
  49. --  Pos_Bottom. 
  50. --  </description> 
  51. --  <c_version>2.16.6</c_version> 
  52. --  <group>Menus and Toolbars</group> 
  53. --  <testgtk>create_handle_box.adb</testgtk> 
  54. --  <screenshot>gtk-handle_box</screenshot> 
  55.  
  56. with Glib.Properties; 
  57. with Gtk.Bin; 
  58. with Gtk.Enums; 
  59.  
  60. package Gtk.Handle_Box is 
  61.  
  62.    type Gtk_Handle_Box_Record is new Gtk.Bin.Gtk_Bin_Record with private; 
  63.    type Gtk_Handle_Box is access all Gtk_Handle_Box_Record'Class; 
  64.  
  65.    procedure Gtk_New (Handle_Box : out Gtk_Handle_Box); 
  66.    --  Create a new Handle_Box. 
  67.  
  68.    procedure Initialize (Handle_Box : access Gtk_Handle_Box_Record'Class); 
  69.    --  Internal initialization function. 
  70.    --  See the section "Creating your own widgets" in the documentation. 
  71.  
  72.    function Get_Type return Gtk.Gtk_Type; 
  73.    --  Return the internal value associated with a Gtk_Dialog. 
  74.  
  75.    procedure Set_Shadow_Type 
  76.      (Handle_Box : access Gtk_Handle_Box_Record; 
  77.       Typ        : Enums.Gtk_Shadow_Type); 
  78.    function Get_Shadow_Type 
  79.      (Handle_Box : access Gtk_Handle_Box_Record) return Enums.Gtk_Shadow_Type; 
  80.    --  Sets or gets the type of shadow to be drawn around the border of the 
  81.    --  Handle_Box. 
  82.  
  83.    procedure Set_Handle_Position 
  84.      (Handle_Box : access  Gtk_Handle_Box_Record; 
  85.       Position   : Enums.Gtk_Position_Type); 
  86.    function Get_Handle_Position 
  87.      (Handle_Box : access  Gtk_Handle_Box_Record) 
  88.       return Enums.Gtk_Position_Type; 
  89.    --  Sets or gets the side of the Handle_Box where the handle is drawn. 
  90.  
  91.    procedure Set_Snap_Edge 
  92.      (Handle_Box : access  Gtk_Handle_Box_Record; 
  93.       Edge       : Enums.Gtk_Position_Type); 
  94.    function Get_Snap_Edge 
  95.      (Handle_Box : access  Gtk_Handle_Box_Record) 
  96.       return Enums.Gtk_Position_Type; 
  97.    --  Sets or gets the snap edge of a Handle_Box. 
  98.    --  The snap edge is the edge of the detached child that must be aligned 
  99.    --  with the corresponding edge of the "ghost" left behind when the child 
  100.    --  was detached to reattach the torn-off window. Usually, the snap edge 
  101.    --  should be chosen so that it stays in the same place on the screen when 
  102.    --  the Handle_Box is torn off. 
  103.    -- 
  104.    --  If the snap edge is not set, then an appropriate value will be guessed 
  105.    --  from the handle position. If the handle position is Pos_Right or 
  106.    --  Pos_Left, then the snap edge will be Pos_Top, otherwise it will be 
  107.    --  Pos_Left. 
  108.  
  109.    function Get_Child_Detached 
  110.      (Handle_Box : access Gtk_Handle_Box_Record) 
  111.       return Boolean; 
  112.    --  Returns whether the handlebox's child is currently detached. 
  113.  
  114.    ---------------- 
  115.    -- Properties -- 
  116.    ---------------- 
  117.  
  118.    --  <properties> 
  119.    --  The following properties are defined for this widget. See 
  120.    --  Glib.Properties for more information on properties. 
  121.    -- 
  122.    --  - Name:  Child_Detached_Property 
  123.    --    Type:  Boolean 
  124.    --    Descr: A boolean value indicating whether the handlebox's child is 
  125.    --           attached or detached. 
  126.    -- 
  127.    --  - Name:  Shadow_Property and Shadow_Type_Property 
  128.    --    Type:  Gtk_Shadow_Type 
  129.    --    Flags: read-write 
  130.    --    Descr: Appearance of the shadow that surrounds the container. 
  131.    --    See also: Set_Shadow_Type 
  132.    -- 
  133.    --  - Name:  Handle_Position_Property 
  134.    --    Type:  Gtk_Position_Type 
  135.    --    Flags: read-write 
  136.    --    Descr: Position of the handle relative to the child widget. 
  137.    --    See also: Set_Handle_Position 
  138.    -- 
  139.    --  - Name:  Snap_Edge_Property 
  140.    --    Type:  Gtk_Position_Type 
  141.    --    Flags: read-write 
  142.    --    Descr: Side of the handlebox that's lined up with the docking point 
  143.    --           to dock the handlebox. 
  144.    --    See also: Set_Snap_Edge 
  145.    -- 
  146.    --  - Name:  Snap_Edge_Set_Property 
  147.    --    Type:  Boolean 
  148.    --    Descr: Whether to use the value from the Snap_Edge_Property, or a 
  149.    --           value derived from Handle_Position 
  150.    -- 
  151.    --  </properties> 
  152.  
  153.    Child_Detached_Property  : constant Glib.Properties.Property_Boolean; 
  154.    Shadow_Property          : constant Gtk.Enums.Property_Gtk_Shadow_Type; 
  155.    Shadow_Type_Property     : constant Gtk.Enums.Property_Gtk_Shadow_Type; 
  156.    Handle_Position_Property : constant Gtk.Enums.Property_Gtk_Position_Type; 
  157.    Snap_Edge_Property       : constant Gtk.Enums.Property_Gtk_Position_Type; 
  158.    Snap_Edge_Set_Property   : constant Glib.Properties.Property_Boolean; 
  159.  
  160.    ------------- 
  161.    -- Signals -- 
  162.    ------------- 
  163.  
  164.    --  <signals> 
  165.    --  The following new signals are defined for this widget: 
  166.    -- 
  167.    --  - "child_attached" 
  168.    --    procedure Handler 
  169.    --      (Handle_Box : access Gtk_Handle_Box_Record'Class; 
  170.    --       Widget     : access Gtk_Widget_Record'Class); 
  171.    --    Emitted when the contents of the Handle_Box are reattached to the main 
  172.    --    window. 
  173.    --    Widget is the child widget of the Handle_Box. (this argument provides 
  174.    --    no extra information and is here only for backwards-compatibility) 
  175.    -- 
  176.    --  - "child_detached" 
  177.    --    procedure Handler 
  178.    --      (Handle_Box : access Gtk_Handle_Box_Record'Class; 
  179.    --       Widget     : access Gtk_Widget_Record'Class); 
  180.    --    Emitted when the contents of the Handle_Box are detached from the main 
  181.    --    window. See "child-attached" for drtails on the parameters. 
  182.    -- 
  183.    --  </signals> 
  184.  
  185.    Signal_Child_Attached : constant Glib.Signal_Name := "child_attached"; 
  186.    Signal_Child_Detached : constant Glib.Signal_Name := "child_detached"; 
  187.  
  188. private 
  189.    type Gtk_Handle_Box_Record is new Gtk.Bin.Gtk_Bin_Record with null record; 
  190.  
  191.    Child_Detached_Property  : constant Glib.Properties.Property_Boolean := 
  192.      Glib.Properties.Build ("child-detached"); 
  193.    Shadow_Property          : constant Gtk.Enums.Property_Gtk_Shadow_Type := 
  194.      Gtk.Enums.Build ("shadow-type");  --  Same as Shadow_Type ! 
  195.    Shadow_Type_Property     : constant Gtk.Enums.Property_Gtk_Shadow_Type := 
  196.      Gtk.Enums.Build ("shadow-type"); 
  197.    Handle_Position_Property : constant Gtk.Enums.Property_Gtk_Position_Type := 
  198.      Gtk.Enums.Build ("handle_position"); 
  199.    Snap_Edge_Property       : constant Gtk.Enums.Property_Gtk_Position_Type := 
  200.      Gtk.Enums.Build ("snap_edge"); 
  201.    Snap_Edge_Set_Property   : constant Glib.Properties.Property_Boolean := 
  202.      Glib.Properties.Build ("snap-edge-set"); 
  203.  
  204.    pragma Import (C, Get_Type, "gtk_handle_box_get_type"); 
  205. end Gtk.Handle_Box;