1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Gtk.Paned.Gtk_Paned has two panes, arranged either horizontally or 
  26. --  vertically. The division between the two panes is adjustable by the user by 
  27. --  dragging a handle. 
  28. -- 
  29. --  Child widgets are added to the panes of the widget with Gtk.Paned.Pack1 
  30. --  and Gtk.Paned.Pack2. The division between the two children is set by 
  31. --  default from the size requests of the children, but it can be adjusted by 
  32. --  the user. 
  33. -- 
  34. --  A paned widget draws a separator between the two child widgets and a small 
  35. --  handle that the user can drag to adjust the division. It does not draw any 
  36. --  relief around the children or around the separator. (The space in which the 
  37. --  separator is called the gutter.) Often, it is useful to put each child 
  38. --  inside a Gtk.Frame.Gtk_Frame with the shadow type set to 
  39. --  Gtk.Enums.Shadow_In so that the gutter appears as a ridge. No separator is 
  40. --  drawn if one of the children is missing. 
  41. -- 
  42. --  Each child has two options that can be set, Resize and Shrink. If Resize 
  43. --  is true, then when the Gtk.Paned.Gtk_Paned is resized, that child will 
  44. --  expand or shrink along with the paned widget. If Shrink is true, then that 
  45. --  child can be made smaller than its requisition by the user. Setting Shrink 
  46. --  to False allows the application to set a minimum size. If Resize is false 
  47. --  for both children, then this is treated as if Resize is true for both 
  48. --  children. 
  49. -- 
  50. --  The application can set the position of the slider as if it were set by 
  51. --  the user, by calling Gtk.Paned.Set_Position. 
  52. -- 
  53. --  == Creating a paned widget with minimum sizes. == 
  54. -- 
  55. --    GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); 
  56. --    GtkWidget *frame1 = gtk_frame_new (NULL); 
  57. --    GtkWidget *frame2 = gtk_frame_new (NULL); 
  58. --    gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_IN); 
  59. --    gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_IN); 
  60. --    gtk_widget_set_size_request (hpaned, 200, -1); 
  61. --    gtk_paned_pack1 (GTK_PANED (hpaned), frame1, TRUE, FALSE); 
  62. --    gtk_widget_set_size_request (frame1, 50, -1); 
  63. --    gtk_paned_pack2 (GTK_PANED (hpaned), frame2, FALSE, FALSE); 
  64. --    gtk_widget_set_size_request (frame2, 50, -1); 
  65. -- 
  66. -- 
  67. --  </description> 
  68. --  <screenshot>gtk-paned</screenshot> 
  69. --  <group>Layout container</group> 
  70. --  <testgtk>create_paned.adb</testgtk> 
  71. pragma Ada_2005; 
  72.  
  73. pragma Warnings (Off, "*is already use-visible*"); 
  74. with Gdk;             use Gdk; 
  75. with Glib;            use Glib; 
  76. with Glib.Object;     use Glib.Object; 
  77. with Glib.Properties; use Glib.Properties; 
  78. with Glib.Types;      use Glib.Types; 
  79. with Gtk.Buildable;   use Gtk.Buildable; 
  80. with Gtk.Container;   use Gtk.Container; 
  81. with Gtk.Enums;       use Gtk.Enums; 
  82. with Gtk.Orientable;  use Gtk.Orientable; 
  83. with Gtk.Widget;      use Gtk.Widget; 
  84.  
  85. package Gtk.Paned is 
  86.  
  87.    type Gtk_Paned_Record is new Gtk_Container_Record with null record; 
  88.    type Gtk_Paned is access all Gtk_Paned_Record'Class; 
  89.  
  90.    subtype Gtk_Hpaned_Record is Gtk_Paned_Record; 
  91.    subtype Gtk_Hpaned is Gtk_Paned; 
  92.  
  93.    subtype Gtk_Vpaned_Record is Gtk_Paned_Record; 
  94.    subtype Gtk_Vpaned is Gtk_Paned; 
  95.  
  96.    ------------------ 
  97.    -- Constructors -- 
  98.    ------------------ 
  99.  
  100.    procedure Gtk_New 
  101.       (Paned       : out Gtk_Paned; 
  102.        Orientation : Gtk.Enums.Gtk_Orientation); 
  103.    procedure Initialize 
  104.       (Paned       : not null access Gtk_Paned_Record'Class; 
  105.        Orientation : Gtk.Enums.Gtk_Orientation); 
  106.    --  Creates a new Gtk.Paned.Gtk_Paned widget. 
  107.    --  Since: gtk+ 3.0 
  108.    --  "orientation": the paned's orientation. 
  109.  
  110.    function Gtk_Paned_New 
  111.       (Orientation : Gtk.Enums.Gtk_Orientation) return Gtk_Paned; 
  112.    --  Creates a new Gtk.Paned.Gtk_Paned widget. 
  113.    --  Since: gtk+ 3.0 
  114.    --  "orientation": the paned's orientation. 
  115.  
  116.    function Get_Type return Glib.GType; 
  117.    pragma Import (C, Get_Type, "gtk_paned_get_type"); 
  118.  
  119.    procedure Gtk_New_Hpaned (Paned : out Gtk_Hpaned); 
  120.    procedure Initialize_Hpaned 
  121.       (Paned : not null access Gtk_Hpaned_Record'Class); 
  122.    --  The children will be displayed next to each other 
  123.  
  124.    function Gtk_Hpaned_New return Gtk_Hpaned; 
  125.    --  The children will be displayed next to each other 
  126.  
  127.    function Get_Type_Hpaned return Glib.GType; 
  128.    pragma Import (C, Get_Type_Hpaned, "gtk_hpaned_get_type"); 
  129.  
  130.    procedure Gtk_New_Vpaned (Paned : out Gtk_Vpaned); 
  131.    procedure Initialize_Vpaned 
  132.       (Paned : not null access Gtk_Vpaned_Record'Class); 
  133.    --  The children will be displayed one on top of the other 
  134.  
  135.    function Gtk_Vpaned_New return Gtk_Vpaned; 
  136.    --  The children will be displayed one on top of the other 
  137.  
  138.    function Get_Type_Vpaned return Glib.GType; 
  139.    pragma Import (C, Get_Type_Vpaned, "gtk_vpaned_get_type"); 
  140.  
  141.    ------------- 
  142.    -- Methods -- 
  143.    ------------- 
  144.  
  145.    procedure Add1 
  146.       (Paned : not null access Gtk_Paned_Record; 
  147.        Child : not null access Gtk.Widget.Gtk_Widget_Record'Class); 
  148.    --  Add the first child of the container. The child will be displayed 
  149.    --  either in the top or in the left pane, depending on the orientation of 
  150.    --  the container. This is equivalent to using the Pack1 procedure with its 
  151.    --  default parameters. 
  152.    --  "child": the child to add 
  153.  
  154.    procedure Add2 
  155.       (Paned : not null access Gtk_Paned_Record; 
  156.        Child : not null access Gtk.Widget.Gtk_Widget_Record'Class); 
  157.    --  Add the second child of the container. It will be displayed in the 
  158.    --  bottom or right pane, depending on the container's orientation. This is 
  159.    --  equivalent to using Pack2 with its default parameters. 
  160.    --  "child": the child to add 
  161.  
  162.    function Get_Child1 
  163.       (Paned : not null access Gtk_Paned_Record) 
  164.        return Gtk.Widget.Gtk_Widget; 
  165.    --  Obtains the first child of the paned widget. 
  166.    --  Since: gtk+ 2.4 
  167.  
  168.    function Get_Child2 
  169.       (Paned : not null access Gtk_Paned_Record) 
  170.        return Gtk.Widget.Gtk_Widget; 
  171.    --  Obtains the second child of the paned widget. 
  172.    --  Since: gtk+ 2.4 
  173.  
  174.    function Get_Handle_Window 
  175.       (Paned : not null access Gtk_Paned_Record) return Gdk.Gdk_Window; 
  176.    --  Returns the Gdk.Gdk_Window of the handle. This function is useful when 
  177.    --  handling button or motion events because it enables the callback to 
  178.    --  distinguish between the window of the paned, a child and the handle. 
  179.    --  Since: gtk+ 2.20 
  180.  
  181.    function Get_Position 
  182.       (Paned : not null access Gtk_Paned_Record) return Gint; 
  183.    --  Obtains the position of the divider between the two panes. 
  184.  
  185.    procedure Set_Position 
  186.       (Paned    : not null access Gtk_Paned_Record; 
  187.        Position : Gint); 
  188.    --  Sets the position of the divider between the two panes. 
  189.    --  "position": pixel position of divider, a negative value means that the 
  190.    --  position is unset. 
  191.  
  192.    procedure Pack1 
  193.       (Paned  : not null access Gtk_Paned_Record; 
  194.        Child  : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  195.        Resize : Boolean := False; 
  196.        Shrink : Boolean := True); 
  197.    --  Add a child to the top or left pane. You can not change dynamically the 
  198.    --  attributes Resize and Shrink. Instead, you have to remove the child from 
  199.    --  the container, and put it back with the new value of the attributes. You 
  200.    --  should also first call Glib.Object.Ref on the child so as to be sure it 
  201.    --  is not destroyed when you remove it, and Glib.Object.Unref it at the 
  202.    --  end. See the example in testgtk/ in the GtkAda distribution. 
  203.    --  "child": the child to add 
  204.    --  "resize": should this child expand when the paned widget is resized. 
  205.    --  "shrink": can this child be made smaller than its requisition. 
  206.  
  207.    procedure Pack2 
  208.       (Paned  : not null access Gtk_Paned_Record; 
  209.        Child  : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  210.        Resize : Boolean := False; 
  211.        Shrink : Boolean := False); 
  212.    --  Adds a child to the bottom or right pane. 
  213.    --  "child": the child to add 
  214.    --  "resize": should this child expand when the paned widget is resized. 
  215.    --  "shrink": can this child be made smaller than its requisition. 
  216.  
  217.    --------------------------------------------- 
  218.    -- Inherited subprograms (from interfaces) -- 
  219.    --------------------------------------------- 
  220.    --  Methods inherited from the Buildable interface are not duplicated here 
  221.    --  since they are meant to be used by tools, mostly. If you need to call 
  222.    --  them, use an explicit cast through the "-" operator below. 
  223.  
  224.    function Get_Orientation 
  225.       (Self : not null access Gtk_Paned_Record) 
  226.        return Gtk.Enums.Gtk_Orientation; 
  227.  
  228.    procedure Set_Orientation 
  229.       (Self        : not null access Gtk_Paned_Record; 
  230.        Orientation : Gtk.Enums.Gtk_Orientation); 
  231.  
  232.    ---------------- 
  233.    -- Properties -- 
  234.    ---------------- 
  235.    --  The following properties are defined for this widget. See 
  236.    --  Glib.Properties for more information on properties) 
  237.  
  238.    Max_Position_Property : constant Glib.Properties.Property_Int; 
  239.    --  The largest possible value for the position property. This property is 
  240.    --  derived from the size and shrinkability of the widget's children. 
  241.  
  242.    Min_Position_Property : constant Glib.Properties.Property_Int; 
  243.    --  The smallest possible value for the position property. This property is 
  244.    --  derived from the size and shrinkability of the widget's children. 
  245.  
  246.    Position_Property : constant Glib.Properties.Property_Int; 
  247.  
  248.    Position_Set_Property : constant Glib.Properties.Property_Boolean; 
  249.  
  250.    ------------- 
  251.    -- Signals -- 
  252.    ------------- 
  253.  
  254.    type Cb_Gtk_Paned_Boolean is not null access function 
  255.      (Self : access Gtk_Paned_Record'Class) return Boolean; 
  256.  
  257.    type Cb_GObject_Boolean is not null access function 
  258.      (Self : access Glib.Object.GObject_Record'Class) 
  259.    return Boolean; 
  260.  
  261.    Signal_Accept_Position : constant Glib.Signal_Name := "accept-position"; 
  262.    procedure On_Accept_Position 
  263.       (Self  : not null access Gtk_Paned_Record; 
  264.        Call  : Cb_Gtk_Paned_Boolean; 
  265.        After : Boolean := False); 
  266.    procedure On_Accept_Position 
  267.       (Self  : not null access Gtk_Paned_Record; 
  268.        Call  : Cb_GObject_Boolean; 
  269.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  270.        After : Boolean := False); 
  271.    --  The ::accept-position signal is a <link 
  272.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  273.    --  to accept the current position of the handle when moving it using key 
  274.    --  bindings. 
  275.    -- 
  276.    --  The default binding for this signal is Return or Space. 
  277.  
  278.    Signal_Cancel_Position : constant Glib.Signal_Name := "cancel-position"; 
  279.    procedure On_Cancel_Position 
  280.       (Self  : not null access Gtk_Paned_Record; 
  281.        Call  : Cb_Gtk_Paned_Boolean; 
  282.        After : Boolean := False); 
  283.    procedure On_Cancel_Position 
  284.       (Self  : not null access Gtk_Paned_Record; 
  285.        Call  : Cb_GObject_Boolean; 
  286.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  287.        After : Boolean := False); 
  288.    --  The ::cancel-position signal is a <link 
  289.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  290.    --  to cancel moving the position of the handle using key bindings. The 
  291.    --  position of the handle will be reset to the value prior to moving it. 
  292.    -- 
  293.    --  The default binding for this signal is Escape. 
  294.  
  295.    type Cb_Gtk_Paned_Boolean_Boolean is not null access function 
  296.      (Self     : access Gtk_Paned_Record'Class; 
  297.       Reversed : Boolean) return Boolean; 
  298.  
  299.    type Cb_GObject_Boolean_Boolean is not null access function 
  300.      (Self     : access Glib.Object.GObject_Record'Class; 
  301.       Reversed : Boolean) return Boolean; 
  302.  
  303.    Signal_Cycle_Child_Focus : constant Glib.Signal_Name := "cycle-child-focus"; 
  304.    procedure On_Cycle_Child_Focus 
  305.       (Self  : not null access Gtk_Paned_Record; 
  306.        Call  : Cb_Gtk_Paned_Boolean_Boolean; 
  307.        After : Boolean := False); 
  308.    procedure On_Cycle_Child_Focus 
  309.       (Self  : not null access Gtk_Paned_Record; 
  310.        Call  : Cb_GObject_Boolean_Boolean; 
  311.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  312.        After : Boolean := False); 
  313.    --  The ::cycle-child-focus signal is a <link 
  314.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  315.    --  to cycle the focus between the children of the paned. 
  316.    -- 
  317.    --  The default binding is f6. 
  318.  
  319.    Signal_Cycle_Handle_Focus : constant Glib.Signal_Name := "cycle-handle-focus"; 
  320.    procedure On_Cycle_Handle_Focus 
  321.       (Self  : not null access Gtk_Paned_Record; 
  322.        Call  : Cb_Gtk_Paned_Boolean_Boolean; 
  323.        After : Boolean := False); 
  324.    procedure On_Cycle_Handle_Focus 
  325.       (Self  : not null access Gtk_Paned_Record; 
  326.        Call  : Cb_GObject_Boolean_Boolean; 
  327.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  328.        After : Boolean := False); 
  329.    --  The ::cycle-handle-focus signal is a <link 
  330.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  331.    --  to cycle whether the paned should grab focus to allow the user to change 
  332.    --  position of the handle by using key bindings. 
  333.    -- 
  334.    --  The default binding for this signal is f8. 
  335.  
  336.    type Cb_Gtk_Paned_Gtk_Scroll_Type_Boolean is not null access function 
  337.      (Self        : access Gtk_Paned_Record'Class; 
  338.       Scroll_Type : Gtk.Enums.Gtk_Scroll_Type) return Boolean; 
  339.  
  340.    type Cb_GObject_Gtk_Scroll_Type_Boolean is not null access function 
  341.      (Self        : access Glib.Object.GObject_Record'Class; 
  342.       Scroll_Type : Gtk.Enums.Gtk_Scroll_Type) return Boolean; 
  343.  
  344.    Signal_Move_Handle : constant Glib.Signal_Name := "move-handle"; 
  345.    procedure On_Move_Handle 
  346.       (Self  : not null access Gtk_Paned_Record; 
  347.        Call  : Cb_Gtk_Paned_Gtk_Scroll_Type_Boolean; 
  348.        After : Boolean := False); 
  349.    procedure On_Move_Handle 
  350.       (Self  : not null access Gtk_Paned_Record; 
  351.        Call  : Cb_GObject_Gtk_Scroll_Type_Boolean; 
  352.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  353.        After : Boolean := False); 
  354.    --  The ::move-handle signal is a <link 
  355.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  356.    --  to move the handle when the user is using key bindings to move it. 
  357.  
  358.    Signal_Toggle_Handle_Focus : constant Glib.Signal_Name := "toggle-handle-focus"; 
  359.    procedure On_Toggle_Handle_Focus 
  360.       (Self  : not null access Gtk_Paned_Record; 
  361.        Call  : Cb_Gtk_Paned_Boolean; 
  362.        After : Boolean := False); 
  363.    procedure On_Toggle_Handle_Focus 
  364.       (Self  : not null access Gtk_Paned_Record; 
  365.        Call  : Cb_GObject_Boolean; 
  366.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  367.        After : Boolean := False); 
  368.    --  The ::toggle-handle-focus is a <link 
  369.    --  linkend="keybinding-signals">keybinding signal</link> which gets emitted 
  370.    --  to accept the current position of the handle and then move focus to the 
  371.    --  next widget in the focus chain. 
  372.    -- 
  373.    --  The default binding is Tab. 
  374.  
  375.    ---------------- 
  376.    -- Interfaces -- 
  377.    ---------------- 
  378.    --  This class implements several interfaces. See Glib.Types 
  379.    -- 
  380.    --  - "Buildable" 
  381.    -- 
  382.    --  - "Orientable" 
  383.  
  384.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  385.      (Gtk.Buildable.Gtk_Buildable, Gtk_Paned_Record, Gtk_Paned); 
  386.    function "+" 
  387.      (Widget : access Gtk_Paned_Record'Class) 
  388.    return Gtk.Buildable.Gtk_Buildable 
  389.    renames Implements_Gtk_Buildable.To_Interface; 
  390.    function "-" 
  391.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  392.    return Gtk_Paned 
  393.    renames Implements_Gtk_Buildable.To_Object; 
  394.  
  395.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  396.      (Gtk.Orientable.Gtk_Orientable, Gtk_Paned_Record, Gtk_Paned); 
  397.    function "+" 
  398.      (Widget : access Gtk_Paned_Record'Class) 
  399.    return Gtk.Orientable.Gtk_Orientable 
  400.    renames Implements_Gtk_Orientable.To_Interface; 
  401.    function "-" 
  402.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  403.    return Gtk_Paned 
  404.    renames Implements_Gtk_Orientable.To_Object; 
  405.  
  406. private 
  407.    Position_Set_Property : constant Glib.Properties.Property_Boolean := 
  408.      Glib.Properties.Build ("position-set"); 
  409.    Position_Property : constant Glib.Properties.Property_Int := 
  410.      Glib.Properties.Build ("position"); 
  411.    Min_Position_Property : constant Glib.Properties.Property_Int := 
  412.      Glib.Properties.Build ("min-position"); 
  413.    Max_Position_Property : constant Glib.Properties.Property_Int := 
  414.      Glib.Properties.Build ("max-position"); 
  415. end Gtk.Paned;