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-2007 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. --  A Gtk_Paned is a container that organizes its two children either 
  32. --  horizontally or vertically. 
  33. --  The initial size allocated to the children depends on the size 
  34. --  they request. However, the user has the possibility to interactively 
  35. --  move a separation bar between the two to enlarge one of the children, 
  36. --  while at the same time shrinking the second one. 
  37. --  The bar can be moved by clicking with the mouse on a small cursor 
  38. --  displayed in the bar, and then dragging the mouse. 
  39. -- 
  40. --  No additional decoration is provided around the children. 
  41. -- 
  42. --  Each child has two parameters, Resize and Shrink. 
  43. -- 
  44. --  If Shrink is True, then the widget can be made smaller than its 
  45. --  requisition size by the user. Set this to False if you want to 
  46. --  set a minimum size. 
  47. -- 
  48. --  if Resize is True, this means that the child accepts to be resized, and 
  49. --  will not require any size. Thus, the size allocated to it will be 
  50. --  the total size allocated to the container minus the size requested by 
  51. --  the other child. 
  52. --  If Resize is False, the child should ask for a specific size, which it 
  53. --  will get. The other child will be resized accordingly. 
  54. --  If both Child have the same value for Resize (either True or False), then 
  55. --  the size allocated to each is a ratio between the size requested by both. 
  56. -- 
  57. --  When you use Set_Position with a parameter other than -1, or the user 
  58. --  moves the handle to resize the widgets, the behavior of Resize is 
  59. --  canceled. 
  60. -- 
  61. --  </description> 
  62. --  <c_version>2.8.17</c_version> 
  63. --  <group>Layout containers</group> 
  64. --  <testgtk>create_paned.adb</testgtk> 
  65. --  <screenshot>gtk-paned</screenshot> 
  66.  
  67. with Glib.Properties; 
  68. with Gtk.Container; 
  69. with Gtk.Widget; use Gtk.Widget; 
  70.  
  71. package Gtk.Paned is 
  72.  
  73.    type Gtk_Paned_Record is new 
  74.      Gtk.Container.Gtk_Container_Record with private; 
  75.    subtype Gtk_Hpaned_Record is Gtk_Paned_Record; 
  76.    subtype Gtk_Vpaned_Record is Gtk_Paned_Record; 
  77.  
  78.    type Gtk_Paned is access all Gtk_Paned_Record'Class; 
  79.    subtype Gtk_Hpaned is Gtk_Paned; 
  80.    subtype Gtk_Vpaned is Gtk_Paned; 
  81.  
  82.    procedure Gtk_New_Vpaned (Widget : out Gtk_Paned); 
  83.    --  Create a new vertical container. 
  84.    --  The children will be displayed one on top of the other. 
  85.  
  86.    procedure Gtk_New_Hpaned (Widget : out Gtk_Paned); 
  87.    --  Create a new horizontal container. 
  88.    --  The children will be displayed one besides the other. 
  89.  
  90.    procedure Initialize_Vpaned (Widget : access Gtk_Paned_Record'Class); 
  91.    --  Internal initialization function. 
  92.    --  See the section "Creating your own widgets" in the documentation. 
  93.  
  94.    procedure Initialize_Hpaned (Widget : access Gtk_Paned_Record'Class); 
  95.    --  Internal initialization function. 
  96.    --  See the section "Creating your own widgets" in the documentation. 
  97.  
  98.    function Get_Type return Glib.GType; 
  99.    function Get_Type_Vpaned return Glib.GType; 
  100.    function Get_Type_Hpaned return Glib.GType; 
  101.    --  Return the internal value associated with a Gtk_Paned. 
  102.  
  103.    procedure Add1 
  104.      (Paned : access Gtk_Paned_Record; 
  105.       Child : access Gtk_Widget_Record'Class); 
  106.    --  Add the first child of the container. 
  107.    --  The child will be displayed either in the top or in the left pane, 
  108.    --  depending on the orientation of the container. 
  109.    --  This is equivalent to using the Pack1 procedure with its default 
  110.    --  parameters. 
  111.  
  112.    procedure Pack1 
  113.      (Paned  : access Gtk_Paned_Record; 
  114.       Child  : access Gtk_Widget_Record'Class; 
  115.       Resize : Boolean := False; 
  116.       Shrink : Boolean := True); 
  117.    --  Add a child to the top or left pane. 
  118.    --  You can not change dynamically the attributes Resize and Shrink. 
  119.    --  Instead, you have to remove the child from the container, and put it 
  120.    --  back with the new value of the attributes. You should also first 
  121.    --  call Gtk.Object.Ref on the child so as to be sure it is not destroyed 
  122.    --  when you remove it, and Gtk.Object.Unref it at the end. See the 
  123.    --  example in testgtk/ in the GtkAda distribution. 
  124.  
  125.    procedure Add2 
  126.      (Paned : access Gtk_Paned_Record; 
  127.       Child : access Gtk_Widget_Record'Class); 
  128.    --  Add the second child of the container. 
  129.    --  It will be displayed in the bottom or right pane, depending on the 
  130.    --  container's orientation. 
  131.    --  This is equivalent to using Pack2 with its default parameters. 
  132.  
  133.    procedure Pack2 
  134.      (Paned  : access Gtk_Paned_Record; 
  135.       Child  : access Gtk_Widget_Record'Class; 
  136.       Resize : Boolean := False; 
  137.       Shrink : Boolean := False); 
  138.    --  Add a child to the bottom or right pane. 
  139.  
  140.    procedure Set_Position (Paned : access Gtk_Paned_Record; Position : Gint); 
  141.    function  Get_Position (Paned : access Gtk_Paned_Record) return Gint; 
  142.    --  Change or get the position of the separator. 
  143.    --  If position is negative, the remembered position is forgotten, 
  144.    --  and the division is recomputed from the requisitions of the 
  145.    --  children. 
  146.    --  Position is in fact the size (either vertically or horizontally, 
  147.    --  depending on the container) set for the first child. 
  148.  
  149.    function Get_Child1 
  150.      (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget; 
  151.    --  Return the child displayed in the top or left pane. 
  152.  
  153.    function Get_Child2 
  154.      (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget; 
  155.    --  Return the child displayed in the bottom or right pane. 
  156.  
  157.    function Get_Child1_Resize 
  158.      (Paned : access Gtk_Paned_Record) return Boolean; 
  159.    --  Get the value of the resize attribute for the first child. 
  160.  
  161.    function Get_Child2_Resize (Paned : access Gtk_Paned_Record) return Boolean; 
  162.    --  Get the value of the resize attribute for the second child. 
  163.  
  164.    function Get_Child1_Shrink (Paned : access Gtk_Paned_Record) return Boolean; 
  165.    --  Get the value of the shrink attribute for the first child. 
  166.  
  167.    function Get_Child2_Shrink (Paned : access Gtk_Paned_Record) return Boolean; 
  168.    --  Get the value of the shrink attribute for the second child. 
  169.  
  170.    ----------------- 
  171.    -- Obsolescent -- 
  172.    ----------------- 
  173.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  174.    --  from future versions of gtk+ (and therefore GtkAda). 
  175.    --  To find out whether your code uses any of these, we recommend compiling 
  176.    --  with the -gnatwj switch 
  177.    --  <doc_ignore> 
  178.  
  179.    procedure Set_Handle_Size (Paned : access Gtk_Paned_Record; Size : Guint16); 
  180.    pragma Obsolescent; 
  181.    --  Do nothing. 
  182.    --  Only provided for compatibility. 
  183.  
  184.    function Get_Handle_Size (Paned : access Gtk_Paned_Record) return Guint16; 
  185.    pragma Obsolescent; 
  186.    --  Return 0. 
  187.    --  Only provided for compatibility. 
  188.  
  189.    procedure Set_Gutter_Size (Paned : access Gtk_Paned_Record; Size : Guint16); 
  190.    pragma Obsolescent; 
  191.    --  Do nothing. 
  192.    --  Only provided for compatibility. 
  193.  
  194.    function Get_Gutter_Size (Paned : access Gtk_Paned_Record) return Guint16; 
  195.    pragma Obsolescent; 
  196.    --  Return 0. 
  197.    --  Only provided for compatibility. 
  198.  
  199.    --  </doc_ignore> 
  200.  
  201.    ---------------- 
  202.    -- Properties -- 
  203.    ---------------- 
  204.    --  The following properties are defined for this widget. See 
  205.    --  Glib.Properties for more information on properties. 
  206.  
  207.    --  <properties> 
  208.    --  Name:  Max_Position_Property 
  209.    --  Type:  Int 
  210.    --  Descr: Largest possible value for the "position" property 
  211.    -- 
  212.    --  Name:  Min_Position_Property 
  213.    --  Type:  Int 
  214.    --  Descr: Smallest possible value for the "position" property. This is 
  215.    --         derived from the size and shrinkability of the widget 
  216.    -- 
  217.    --  Name:  Position_Property 
  218.    --  Type:  Int 
  219.    --  Descr: Position of paned separator in pixels (0 means all the way to the 
  220.    --         left/top) 
  221.    -- 
  222.    --  Name:  Position_Set_Property 
  223.    --  Type:  Boolean 
  224.    --  Descr: TRUE if the Position property should be used 
  225.    --  </properties> 
  226.  
  227.    Max_Position_Property : constant Glib.Properties.Property_Int; 
  228.    Min_Position_Property : constant Glib.Properties.Property_Int; 
  229.    Position_Property     : constant Glib.Properties.Property_Int; 
  230.    Position_Set_Property : constant Glib.Properties.Property_Boolean; 
  231.  
  232.    ---------------------- 
  233.    -- Child Properties -- 
  234.    ---------------------- 
  235.    --  The following properties can be set on children of this widget. See 
  236.    --  in particular Gtk.Containers.Child_Set_Property. 
  237.  
  238.    --  <child_properties> 
  239.    --  Name:  Resize_Property 
  240.    --  Type:  Boolean 
  241.    --  Descr: If TRUE, the child expands and shrinks along with the paned 
  242.    --         widget 
  243.    -- 
  244.    --  Name:  Shrink_Property 
  245.    --  Type:  Boolean 
  246.    --  Descr: If TRUE, the child can be made smaller than its requisition 
  247.    --  </child_properties> 
  248.  
  249.    Resize_Property : constant Glib.Properties.Property_Boolean; 
  250.    Shrink_Property : constant Glib.Properties.Property_Boolean; 
  251.  
  252.    ---------------------- 
  253.    -- Style Properties -- 
  254.    ---------------------- 
  255.    --  The following properties can be changed through the gtk theme and 
  256.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  257.  
  258.    --  <style_properties> 
  259.    --  Name:  Handle_Size_Property 
  260.    --  Type:  Int 
  261.    --  Descr: Width of handle 
  262.    --  </style_properties> 
  263.  
  264.    Handle_Size_Property : constant Glib.Properties.Property_Int; 
  265.  
  266.    ------------- 
  267.    -- Signals -- 
  268.    ------------- 
  269.  
  270.    --  <signals> 
  271.    --  The following new signals are defined for this widget: 
  272.    -- 
  273.    --  - "accept_position" 
  274.    --    procedure Handler (Paned : access Gtk_Paned_Record'Class); 
  275.    --    You should emit this signal to request that the current handle 
  276.    --    position be considered as valid, and the focus moved out of the 
  277.    --    handle. By default, this is bound to the key <enter>, so that after 
  278.    --    resizing through the keyboard (see cycle_handle_focus), the user can 
  279.    --    validate the new position 
  280.    -- 
  281.    --  - "cancel_position" 
  282.    --    procedure Handler (Paned : access Gtk_Paned_Record'Class); 
  283.    --    Similar to accept_position, but cancel the last resizing operation. 
  284.    --    This is bound to <esc> by default. 
  285.    -- 
  286.    --  - "cycle_child_focus" 
  287.    --    procedure Handler 
  288.    --       (Paned   : access Gtk_Paned_Record'Class; 
  289.    --        To_Next : Boolean); 
  290.    --    You should emit this signal to request that the child be moved to the 
  291.    --    next child of paned. After the last child, the focus is moved to the 
  292.    --    parent of Paned (if it is a Gtk_Paned_Record itself),... 
  293.    --    This signal is mostly intended to be used from a keybinding (by 
  294.    --    default, gtk+ attaches it to F6 and shift-F6). 
  295.    -- 
  296.    --  - "cycle_handle_focus" 
  297.    --    procedure Handler 
  298.    --       (Paned   : access Gtk_Paned_Record'Class; 
  299.    --        To_Next : Boolean); 
  300.    --    You should emit this signal to request that the focus be given to the 
  301.    --    handle, so that the user can then resize the children through the 
  302.    --    keyboard. It it mostly intended to be used from a keybinding. By 
  303.    --    default, gtk+ attaches it to F8. The children can then be resized 
  304.    --    with the arrow keys, PageUp, PageDown, Home and End. 
  305.    -- 
  306.    --  - "move_handle" 
  307.    --    procedure Handler 
  308.    --       (Paned : access Gtk_Paned_Record'Class; 
  309.    --        Typ   : Gtk_Scroll_Type); 
  310.    --    You should emit this signal to request a resizing of the children. 
  311.    --    This is mostly useful when bound to keys, so that when the handle has 
  312.    --    the focus (cycle_handle_focus), the children can be resized with the 
  313.    --    arrow keys, PageUp, PageDown, Home and End 
  314.    -- 
  315.    --  - "toggle_handle_focus" 
  316.    --    procedure Handler (Paned : access Gtk_Paned_Record'Class); 
  317.    --    Mostly intended to be bound to a keybinding. When called, this removes 
  318.    --    the keyboard focus from the handle (if it was given through 
  319.    --    cycle_handle_focus above). 
  320.    -- 
  321.    --  </signals> 
  322.  
  323.    Signal_Accept_Position     : constant Glib.Signal_Name := 
  324.                                   "accept_position"; 
  325.    Signal_Cancel_Position     : constant Glib.Signal_Name := 
  326.                                   "cancel_position"; 
  327.    Signal_Cycle_Child_Focus   : constant Glib.Signal_Name := 
  328.                                   "cycle_child_focus"; 
  329.    Signal_Cycle_Handle_Focus  : constant Glib.Signal_Name := 
  330.                                   "cycle_handle_focus"; 
  331.    Signal_Move_Handle         : constant Glib.Signal_Name := 
  332.                                   "move_handle"; 
  333.    Signal_Toggle_Handle_Focus : constant Glib.Signal_Name := 
  334.                                   "toggle_handle_focus"; 
  335.  
  336. private 
  337.    type Gtk_Paned_Record is new Gtk.Container.Gtk_Container_Record 
  338.    with null record; 
  339.  
  340.    Max_Position_Property : constant Glib.Properties.Property_Int := 
  341.      Glib.Properties.Build ("max-position"); 
  342.    Min_Position_Property : constant Glib.Properties.Property_Int := 
  343.      Glib.Properties.Build ("min-position"); 
  344.    Position_Property : constant Glib.Properties.Property_Int := 
  345.      Glib.Properties.Build ("position"); 
  346.    Position_Set_Property : constant Glib.Properties.Property_Boolean := 
  347.      Glib.Properties.Build ("position-set"); 
  348.  
  349.    Resize_Property : constant Glib.Properties.Property_Boolean := 
  350.      Glib.Properties.Build ("resize"); 
  351.    Shrink_Property : constant Glib.Properties.Property_Boolean := 
  352.      Glib.Properties.Build ("shrink"); 
  353.  
  354.    Handle_Size_Property : constant Glib.Properties.Property_Int := 
  355.      Glib.Properties.Build ("handle-size"); 
  356.  
  357.    pragma Import (C, Get_Type, "gtk_paned_get_type"); 
  358.    pragma Import (C, Get_Type_Vpaned, "gtk_vpaned_get_type"); 
  359.    pragma Import (C, Get_Type_Hpaned, "gtk_hpaned_get_type"); 
  360. end Gtk.Paned; 
  361.  
  362. --  Was never implemented, and is now obsolescent anyway: 
  363. --  No binding: gtk_paned_compute_position