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