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-2013, 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. The initial size allocated to the children 
  33. --  depends on the size they request. However, the user has the possibility to 
  34. --  interactively move a separation bar between the two to enlarge one of the 
  35. --  children, while at the same time shrinking the second one. The bar can be 
  36. --  moved by clicking with the mouse on a small cursor displayed in the bar, 
  37. --  and then dragging the mouse. 
  38. -- 
  39. --  No additional decoration is provided around the children. 
  40. -- 
  41. --  Each child has two parameters, Resize and Shrink. 
  42. -- 
  43. --  If Shrink is True, then the widget can be made smaller than its 
  44. --  requisition size by the user. Set this to False if you want to set a 
  45. --  minimum size. 
  46. -- 
  47. --  if Resize is True, this means that the child accepts to be resized, and 
  48. --  will not require any size. Thus, the size allocated to it will be the total 
  49. --  size allocated to the container minus the size requested by the other 
  50. --  child. If Resize is False, the child should ask for a specific size, which 
  51. --  it will get. The other child will be resized accordingly. If both Child 
  52. --  have the same value for Resize (either True or False), then the size 
  53. --  allocated to each is a ratio between the size requested by both. 
  54. -- 
  55. --  When you use Set_Position with a parameter other than -1, or the user 
  56. --  moves the handle to resize the widgets, the behavior of Resize is canceled. 
  57. -- 
  58. --  </description> 
  59. --  <screenshot>gtk-paned</screenshot> 
  60. --  <group>Layout container</group> 
  61. --  <testgtk>create_paned.adb</testgtk> 
  62.  
  63. pragma Warnings (Off, "*is already use-visible*"); 
  64. with Gdk.Window;      use Gdk.Window; 
  65. with Glib;            use Glib; 
  66. with Glib.Properties; use Glib.Properties; 
  67. with Glib.Types;      use Glib.Types; 
  68. with Gtk.Buildable;   use Gtk.Buildable; 
  69. with Gtk.Container;   use Gtk.Container; 
  70. with Gtk.Enums;       use Gtk.Enums; 
  71. with Gtk.Orientable;  use Gtk.Orientable; 
  72. with Gtk.Widget;      use Gtk.Widget; 
  73.  
  74. package Gtk.Paned is 
  75.  
  76.    type Gtk_Paned_Record is new Gtk_Container_Record with null record; 
  77.    type Gtk_Paned is access all Gtk_Paned_Record'Class; 
  78.  
  79.    subtype Gtk_Hpaned_Record is Gtk_Paned_Record; 
  80.    subtype Gtk_Hpaned is Gtk_Paned; 
  81.  
  82.    subtype Gtk_Vpaned_Record is Gtk_Paned_Record; 
  83.    subtype Gtk_Vpaned is Gtk_Paned; 
  84.  
  85.    ------------------ 
  86.    -- Constructors -- 
  87.    ------------------ 
  88.  
  89.    function Get_Type return Glib.GType; 
  90.    pragma Import (C, Get_Type, "gtk_paned_get_type"); 
  91.  
  92.    procedure Gtk_New_Hpaned (Paned : out Gtk_Hpaned); 
  93.    procedure Initialize_Hpaned (Paned : access Gtk_Hpaned_Record'Class); 
  94.    --  The children will be displayed next to each other 
  95.  
  96.    function Get_Type_Hpaned return Glib.GType; 
  97.    pragma Import (C, Get_Type_Hpaned, "gtk_hpaned_get_type"); 
  98.  
  99.    procedure Gtk_New_Vpaned (Paned : out Gtk_Vpaned); 
  100.    procedure Initialize_Vpaned (Paned : access Gtk_Vpaned_Record'Class); 
  101.    --  The children will be displayed one on top of the other 
  102.  
  103.    function Get_Type_Vpaned return Glib.GType; 
  104.    pragma Import (C, Get_Type_Vpaned, "gtk_vpaned_get_type"); 
  105.  
  106.    ------------- 
  107.    -- Methods -- 
  108.    ------------- 
  109.  
  110.    procedure Add1 
  111.       (Paned : access Gtk_Paned_Record; 
  112.        Child : access Gtk.Widget.Gtk_Widget_Record'Class); 
  113.    --  Add the first child of the container. The child will be displayed 
  114.    --  either in the top or in the left pane, depending on the orientation of 
  115.    --  the container. This is equivalent to using the Pack1 procedure with its 
  116.    --  default parameters. 
  117.  
  118.    procedure Add2 
  119.       (Paned : access Gtk_Paned_Record; 
  120.        Child : access Gtk.Widget.Gtk_Widget_Record'Class); 
  121.    --  Add the second child of the container. It will be displayed in the 
  122.    --  bottom or right pane, depending on the container's orientation. This is 
  123.    --  equivalent to using Pack2 with its default parameters. 
  124.  
  125.    procedure Compute_Position 
  126.       (Paned      : access Gtk_Paned_Record; 
  127.        Allocation : Gint; 
  128.        Child1_Req : Gint; 
  129.        Child2_Req : Gint); 
  130.  
  131.    function Get_Child1 
  132.       (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget; 
  133.    --  Obtains the first child of the paned widget. 
  134.    --  Since: gtk+ 2.4 
  135.  
  136.    function Get_Child2 
  137.       (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget; 
  138.    --  Obtains the second child of the paned widget. 
  139.    --  Since: gtk+ 2.4 
  140.  
  141.    function Get_Handle_Window 
  142.       (Paned : access Gtk_Paned_Record) return Gdk.Window.Gdk_Window; 
  143.    --  Returns the Gdk.Window.Gdk_Window of the handle. This function is 
  144.    --  useful when handling button or motion events because it enables the 
  145.    --  callback to distinguish between the window of the paned, a child and the 
  146.    --  handle. 
  147.    --  Since: gtk+ 2.20 
  148.  
  149.    function Get_Position (Paned : access Gtk_Paned_Record) return Gint; 
  150.    procedure Set_Position (Paned : access Gtk_Paned_Record; Position : Gint); 
  151.    --  Sets the position of the divider between the two panes. 
  152.    --  "position": pixel position of divider, a negative value means that the 
  153.    --  position is unset. 
  154.  
  155.    procedure Pack1 
  156.       (Paned  : access Gtk_Paned_Record; 
  157.        Child  : access Gtk.Widget.Gtk_Widget_Record'Class; 
  158.        Resize : Boolean := False; 
  159.        Shrink : Boolean := True); 
  160.    --  Add a child to the top or left pane. You can not change dynamically the 
  161.    --  attributes Resize and Shrink. Instead, you have to remove the child from 
  162.    --  the container, and put it back with the new value of the attributes. You 
  163.    --  should also first call Glib.Object.Ref on the child so as to be sure it 
  164.    --  is not destroyed when you remove it, and Glib.Object.Unref it at the 
  165.    --  end. See the example in testgtk/ in the GtkAda distribution. 
  166.  
  167.    procedure Pack2 
  168.       (Paned  : access Gtk_Paned_Record; 
  169.        Child  : access Gtk.Widget.Gtk_Widget_Record'Class; 
  170.        Resize : Boolean := False; 
  171.        Shrink : Boolean := False); 
  172.  
  173.    --------------------- 
  174.    -- Interfaces_Impl -- 
  175.    --------------------- 
  176.  
  177.    function Get_Orientation 
  178.       (Self : access Gtk_Paned_Record) return Gtk.Enums.Gtk_Orientation; 
  179.    procedure Set_Orientation 
  180.       (Self        : access Gtk_Paned_Record; 
  181.        Orientation : Gtk.Enums.Gtk_Orientation); 
  182.  
  183.    ---------------- 
  184.    -- Interfaces -- 
  185.    ---------------- 
  186.    --  This class implements several interfaces. See Glib.Types 
  187.    -- 
  188.    --  - "Buildable" 
  189.    -- 
  190.    --  - "Orientable" 
  191.  
  192.    package Implements_Buildable is new Glib.Types.Implements 
  193.      (Gtk.Buildable.Gtk_Buildable, Gtk_Paned_Record, Gtk_Paned); 
  194.    function "+" 
  195.      (Widget : access Gtk_Paned_Record'Class) 
  196.    return Gtk.Buildable.Gtk_Buildable 
  197.    renames Implements_Buildable.To_Interface; 
  198.    function "-" 
  199.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  200.    return Gtk_Paned 
  201.    renames Implements_Buildable.To_Object; 
  202.  
  203.    package Implements_Orientable is new Glib.Types.Implements 
  204.      (Gtk.Orientable.Gtk_Orientable, Gtk_Paned_Record, Gtk_Paned); 
  205.    function "+" 
  206.      (Widget : access Gtk_Paned_Record'Class) 
  207.    return Gtk.Orientable.Gtk_Orientable 
  208.    renames Implements_Orientable.To_Interface; 
  209.    function "-" 
  210.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  211.    return Gtk_Paned 
  212.    renames Implements_Orientable.To_Object; 
  213.  
  214.    ---------------- 
  215.    -- Properties -- 
  216.    ---------------- 
  217.    --  The following properties are defined for this widget. See 
  218.    --  Glib.Properties for more information on properties) 
  219.    -- 
  220.    --  Name: Max_Position_Property 
  221.    --  Type: Gint 
  222.    --  Flags: read-write 
  223.    --  The largest possible value for the position property. This property is 
  224.    --  derived from the size and shrinkability of the widget's children. 
  225.    -- 
  226.    --  Name: Min_Position_Property 
  227.    --  Type: Gint 
  228.    --  Flags: read-write 
  229.    --  The smallest possible value for the position property. This property is 
  230.    --  derived from the size and shrinkability of the widget's children. 
  231.    -- 
  232.    --  Name: Position_Property 
  233.    --  Type: Gint 
  234.    --  Flags: read-write 
  235.    -- 
  236.    --  Name: Position_Set_Property 
  237.    --  Type: Boolean 
  238.    --  Flags: read-write 
  239.    --  The following properties are defined for this widget. See 
  240.    --  Glib.Properties for more information on properties) 
  241.    --  The following properties are defined for this widget. See 
  242.    --  Glib.Properties for more information on properties) 
  243.  
  244.    Max_Position_Property : constant Glib.Properties.Property_Int; 
  245.    Min_Position_Property : constant Glib.Properties.Property_Int; 
  246.    Position_Property : constant Glib.Properties.Property_Int; 
  247.    Position_Set_Property : constant Glib.Properties.Property_Boolean; 
  248.  
  249.    ------------- 
  250.    -- Signals -- 
  251.    ------------- 
  252.    --  The following new signals are defined for this widget: 
  253.    -- 
  254.    --  "accept-position" 
  255.    --     function Handler 
  256.    --       (Self : access Gtk_Paned_Record'Class) return Boolean; 
  257.    --  The ::accept-position signal is a <link 
  258.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  259.    --  to accept the current position of the handle when moving it using key 
  260.    --  bindings. The default binding for this signal is Return or Space. 
  261.    -- 
  262.    --  "cancel-position" 
  263.    --     function Handler 
  264.    --       (Self : access Gtk_Paned_Record'Class) return Boolean; 
  265.    --  The ::cancel-position signal is a <link 
  266.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  267.    --  to cancel moving the position of the handle using key bindings. The 
  268.    --  position of the handle will be reset to the value prior to moving it. 
  269.    --  The default binding for this signal is Escape. 
  270.    -- 
  271.    --  "cycle-child-focus" 
  272.    --     function Handler 
  273.    --       (Self     : access Gtk_Paned_Record'Class; 
  274.    --        Reversed : Boolean) return Boolean; 
  275.    --    --  "reversed": whether cycling backward or forward 
  276.    --  The ::cycle-child-focus signal is a <link 
  277.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  278.    --  to cycle the focus between the children of the paned. The default 
  279.    --  binding is f6. 
  280.    -- 
  281.    --  "cycle-handle-focus" 
  282.    --     function Handler 
  283.    --       (Self     : access Gtk_Paned_Record'Class; 
  284.    --        Reversed : Boolean) return Boolean; 
  285.    --    --  "reversed": whether cycling backward or forward 
  286.    --  The ::cycle-handle-focus signal is a <link 
  287.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  288.    --  to cycle whether the paned should grab focus to allow the user to change 
  289.    --  position of the handle by using key bindings. The default binding for 
  290.    --  this signal is f8. 
  291.    -- 
  292.    --  "move-handle" 
  293.    --     function Handler 
  294.    --       (Self        : access Gtk_Paned_Record'Class; 
  295.    --        Scroll_Type : Gtk.Enums.Gtk_Scroll_Type) return Boolean; 
  296.    --    --  "scroll_type": a Gtk.Enums.Gtk_Scroll_Type 
  297.    --  The ::move-handle signal is a <link 
  298.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  299.    --  to move the handle when the user is using key bindings to move it. 
  300.    -- 
  301.    --  "toggle-handle-focus" 
  302.    --     function Handler 
  303.    --       (Self : access Gtk_Paned_Record'Class) return Boolean; 
  304.    --  The ::toggle-handle-focus is a <link 
  305.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  306.    --  to accept the current position of the handle and then move focus to the 
  307.    --  next widget in the focus chain. The default binding is Tab. 
  308.  
  309.    Signal_Accept_Position : constant Glib.Signal_Name := "accept-position"; 
  310.    Signal_Cancel_Position : constant Glib.Signal_Name := "cancel-position"; 
  311.    Signal_Cycle_Child_Focus : constant Glib.Signal_Name := "cycle-child-focus"; 
  312.    Signal_Cycle_Handle_Focus : constant Glib.Signal_Name := "cycle-handle-focus"; 
  313.    Signal_Move_Handle : constant Glib.Signal_Name := "move-handle"; 
  314.    Signal_Toggle_Handle_Focus : constant Glib.Signal_Name := "toggle-handle-focus"; 
  315.  
  316. private 
  317.    Max_Position_Property : constant Glib.Properties.Property_Int := 
  318.      Glib.Properties.Build ("max-position"); 
  319.    Min_Position_Property : constant Glib.Properties.Property_Int := 
  320.      Glib.Properties.Build ("min-position"); 
  321.    Position_Property : constant Glib.Properties.Property_Int := 
  322.      Glib.Properties.Build ("position"); 
  323.    Position_Set_Property : constant Glib.Properties.Property_Boolean := 
  324.      Glib.Properties.Build ("position-set"); 
  325. end Gtk.Paned;