Toc Gallery Index Tree Gtk.Paned

Screenshot

No screeshot

Hierarchy

Description

A Gtk_Paned is a container that organizes its two children either horizontally or vertically. The initial size allocated to the children depends on the size they request. However, the user has the possibility to interactively move a separation bar between the two to enlarge one of the children, while at the same time shrinking the second one. The bar can be moved by clicking with the mouse on a small cursor displayed in the bar, and then dragging the mouse.

No additional decoration is provided around the children.

Each child has two parameters, Resize and Shrink.

If Shrink is True, then the widget can be made smaller than its requisition size by the user. Set this to False if you want to set a minimum size.

if Resize is True, this means that the child accepts to be resized, and will not require any size. Thus, the size allocated to it will be the total size allocated to the container minus the size requested by the other child. If Resize is False, the child should ask for a specific size, which it will get. The other child will be resized accordingly. If both Child have the same value for Resize (either True or False), then the size allocated to each is a ratio between the size requested by both.

When you use Set_Position with a parameter other than -1, or the user moves the handle to resize the widgets, the behavior of Resize is canceled.

Types

  • type Gtk_Hpaned is Gtk_Paned;
  • type Gtk_Hpaned_Record is Gtk_Paned_Record;
  • type Gtk_Paned is access all Gtk_Paned_Record'Class;
  • type Gtk_Paned_Record is new Gtk.Container.Gtk_Container_Record with private;
  • type Gtk_Vpaned is Gtk_Paned;
  • type Gtk_Vpaned_Record is Gtk_Paned_Record;

Subprograms

  • procedure Gtk_New_Vpaned (Widget : out Gtk_Paned);
    Create a new vertical container. The children will be displayed one on top of the other.
  • procedure Gtk_New_Hpaned (Widget : out Gtk_Paned);
    Create a new horizontal container. The children will be displayed one besides the other.
  • procedure Initialize_Vpaned (Widget : access Gtk_Paned_Record'Class);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • procedure Initialize_Hpaned (Widget : access Gtk_Paned_Record'Class);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • function Get_Type return Glib.GType;
    function Get_Type_Vpaned return Glib.GType;
    function Get_Type_Hpaned return Glib.GType;
    Return the internal value associated with a Gtk_Paned.
  • procedure Add1 (Paned : access Gtk_Paned_Record; Child : access Gtk_Widget_Record'Class);
    Add the first child of the container. The child will be displayed either in the top or in the left pane, depending on the orientation of the container. This is equivalent to using the Pack1 procedure with its default parameters.
  • procedure Pack1 (Paned : access Gtk_Paned_Record; Child : access Gtk_Widget_Record'Class; Resize : Boolean := False; Shrink : Boolean := True);
    Add a child to the top or left pane. You can not change dynamically the attributes Resize and Shrink. Instead, you have to remove the child from the container, and put it back with the new value of the attributes. You should also first call Gtk.Object.Ref on the child so as to be sure it is not destroyed when you remove it, and Gtk.Object.Unref it at the end. See the example in testgtk/ in the GtkAda distribution.
  • procedure Add2 (Paned : access Gtk_Paned_Record; Child : access Gtk_Widget_Record'Class);
    Add the second child of the container. It will be displayed in the bottom or right pane, depending on the container's orientation. This is equivalent to using Pack2 with its default parameters.
  • procedure Pack2 (Paned : access Gtk_Paned_Record; Child : access Gtk_Widget_Record'Class; Resize : Boolean := False; Shrink : Boolean := False);
    Add a child to the bottom or right pane.
  • procedure Set_Position (Paned : access Gtk_Paned_Record; Position : Gint);
    function Get_Position (Paned : access Gtk_Paned_Record) return Gint;
    Change or get the position of the separator. If position is negative, the remembered position is forgotten, and the division is recomputed from the requisitions of the children. Position is in fact the size (either vertically or horizontally, depending on the container) set for the first child.
  • function Get_Child1 (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget;
    Return the child displayed in the top or left pane.
  • function Get_Child2 (Paned : access Gtk_Paned_Record) return Gtk.Widget.Gtk_Widget;
    Return the child displayed in the bottom or right pane.
  • function Get_Child1_Resize (Paned : access Gtk_Paned_Record) return Boolean;
    Get the value of the resize attribute for the first child.
  • function Get_Child2_Resize (Paned : access Gtk_Paned_Record) return Boolean;
    Get the value of the resize attribute for the second child.
  • function Get_Child1_Shrink (Paned : access Gtk_Paned_Record) return Boolean;
    Get the value of the shrink attribute for the first child.
  • function Get_Child2_Shrink (Paned : access Gtk_Paned_Record) return Boolean;
    Get the value of the shrink attribute for the second child.

Signals

  • accept_position
    procedure Handler (Paned : access Gtk_Paned_Record'Class);
    You should emit this signal to request that the current handle position be considered as valid, and the focus moved out of the handle. By default, this is bound to the key , so that after resizing through the keyboard (see cycle_handle_focus), the user can validate the new position
  • cancel_position
    procedure Handler (Paned : access Gtk_Paned_Record'Class);
    Similar to accept_position, but cancel the last resizing operation. This is bound to by default.
  • cycle_child_focus
    procedure Handler (Paned : access Gtk_Paned_Record'Class; To_Next : Boolean);
    You should emit this signal to request that the child be moved to the next child of paned. After the last child, the focus is moved to the parent of Paned (if it is a Gtk_Paned_Record itself),... This signal is mostly intended to be used from a keybinding (by default, gtk+ attaches it to F6 and shift-F6).
  • cycle_handle_focus
    procedure Handler (Paned : access Gtk_Paned_Record'Class; To_Next : Boolean);
    You should emit this signal to request that the focus be given to the handle, so that the user can then resize the children through the keyboard. It it mostly intended to be used from a keybinding. By default, gtk+ attaches it to F8. The children can then be resized with the arrow keys, PageUp, PageDown, Home and End.
  • move_handle
    procedure Handler (Paned : access Gtk_Paned_Record'Class; Typ : Gtk_Scroll_Type);
    You should emit this signal to request a resizing of the children. This is mostly useful when bound to keys, so that when the handle has the focus (cycle_handle_focus), the children can be resized with the arrow keys, PageUp, PageDown, Home and End
  • toggle_handle_focus
    procedure Handler (Paned : access Gtk_Paned_Record'Class);
    Mostly intended to be bound to a keybinding. When called, this removes the keyboard focus from the handle (if it was given through cycle_handle_focus above).

Properties

  • Max_Position_Property
    Int
    Largest possible value for the "position" property
  • Min_Position_Property
    Int
    Smallest possible value for the "position" property. This is
  • Position_Property
    Int
    Position of paned separator in pixels (0 means all the way to the
  • Position_Set_Property
    Boolean
    TRUE if the Position property should be used

Child Properties

  • Resize_Property
    Boolean
    If TRUE, the child expands and shrinks along with the paned
  • Shrink_Property
    Boolean
    If TRUE, the child can be made smaller than its requisition

Style Properties

  • Handle_Size_Property
    Int
    Width of handle

Testgtk source code

This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
----------------------------------------------------------------------- -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 1998-1999 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- ----------------------------------------------------------------------- with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Check_Button; use Gtk.Check_Button; with Gtk.Enums; use Gtk.Enums; with Gtk.Frame; use Gtk.Frame; with Gtk.Label; use Gtk.Label; with Gtk.Paned; use Gtk.Paned; with Gtk.Table; use Gtk.Table; with Gtk.Widget; use Gtk.Widget; with Gtk; use Gtk; with Common; use Common; package body Create_Paned is ---------- -- Help -- ---------- function Help return String is begin return "A @bGtk_Paned@B splits a container in two parts, that can be" & " resized by the user." & ASCII.LF & "They have two children, one for each side." & ASCII.LF & "If @bShrink@B is set to True for one of the children, then the user" & " can resize it to any size. If it is set to False, then the" & " minimum size set for the child by a call to @bSet_Usize@B is" & " enforced, and the child can never be shrinked more than that." & ASCII.LF & "If @bResize@B is set to True for one of the children only, then" & " that child gets the exact size it requested, the other gets the" & " remaining space. In the example, the two buttons have required" & " the same size, and you can see the effect of the resize buttons" & " by clicking on them." & ASCII.LF & "If both children have the same value for resize, their allocated" & " size is a ratio between their respective sizes." & ASCII.LF & "Note that moving the handle to manually resize the widgets" & " cancels the effect of the resize buttons, so you should click on" & " them before playing with the handles..."; end Help; ------------------- -- Toggle_Resize -- ------------------- procedure Toggle_Resize (Child : access Gtk_Widget_Record'Class) is Paned : constant Gtk_Paned := Gtk_Paned (Get_Parent (Child)); Is_Child1 : constant Boolean := Gtk_Widget (Child) = Get_Child1 (Paned); Resize : Boolean; Shrink : Boolean; begin if Is_Child1 then Resize := Get_Child1_Resize (Paned); Shrink := Get_Child1_Shrink (Paned); else Resize := Get_Child2_Resize (Paned); Shrink := Get_Child2_Shrink (Paned); end if; Ref (Child); -- Since we are going to remove it, we do not want -- to delete it. Remove (Paned, Child); if Is_Child1 then Pack1 (Paned, Child, not Resize, Shrink); else Pack2 (Paned, Child, not Resize, Shrink); end if; Unref (Child); end Toggle_Resize; ------------------- -- Toggle_Shrink -- ------------------- procedure Toggle_Shrink (Child : access Gtk_Widget_Record'Class) is Paned : constant Gtk_Paned := Gtk_Paned (Get_Parent (Child)); Is_Child1 : constant Boolean := Gtk_Widget (Child) = Get_Child1 (Paned); Resize : Boolean; Shrink : Boolean; begin if Is_Child1 then Resize := Get_Child1_Resize (Paned); Shrink := Get_Child1_Shrink (Paned); else Resize := Get_Child2_Resize (Paned); Shrink := Get_Child2_Shrink (Paned); end if; Ref (Child); -- Since we are going to remove it, we do not want -- to delete it. Remove (Paned, Child); if Is_Child1 then Pack1 (Paned, Child, Resize, not Shrink); else Pack2 (Paned, Child, Resize, not Shrink); end if; Unref (Child); end Toggle_Shrink; ------------------------- -- Create_Pane_Options -- ------------------------- function Create_Pane_Options (Paned : access Gtk_Paned_Record'Class; Frame_Label : String; Label1 : String; Label2 : String) return Gtk_Frame is Frame : Gtk_Frame; Table : Gtk_Table; Label : Gtk_Label; Check : Gtk_Check_Button; begin Gtk_New (Frame, Frame_Label); Set_Border_Width (Frame, 4); Gtk_New (Table, 3, 2, False); Add (Frame, Table); Gtk_New (Label, Label1); Attach_Defaults (Table, Label, 0, 1, 0, 1); Gtk_New (Check, "Resize"); Attach_Defaults (Table, Check, 0, 1, 1, 2); Set_Active (Check, Get_Child1_Resize (Paned)); Widget_Handler.Object_Connect (Check, "toggled", Widget_Handler.To_Marshaller (Toggle_Resize'Access), Slot_Object => Get_Child1 (Paned)); Gtk_New (Check, "Shrink"); Attach_Defaults (Table, Check, 0, 1, 2, 3); Set_Active (Check, Get_Child1_Shrink (Paned)); Widget_Handler.Object_Connect (Check, "toggled", Widget_Handler.To_Marshaller (Toggle_Shrink'Access), Slot_Object => Get_Child1 (Paned)); Gtk_New (Label, Label2); Attach_Defaults (Table, Label, 1, 2, 0, 1); Gtk_New (Check, "Resize"); Attach_Defaults (Table, Check, 1, 2, 1, 2); Set_Active (Check, Get_Child2_Resize (Paned)); Widget_Handler.Object_Connect (Check, "toggled", Widget_Handler.To_Marshaller (Toggle_Resize'Access), Slot_Object => Get_Child2 (Paned)); Gtk_New (Check, "Shrink"); Attach_Defaults (Table, Check, 1, 2, 2, 3); Set_Active (Check, Get_Child2_Shrink (Paned)); Widget_Handler.Object_Connect (Check, "toggled", Widget_Handler.To_Marshaller (Toggle_Shrink'Access), Slot_Object => Get_Child2 (Paned)); return Frame; end Create_Pane_Options; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is VPaned : Gtk_Paned; HPaned : Gtk_Paned; Frame2 : Gtk_Frame; Button : Gtk_Button; Vbox : Gtk_Box; begin Set_Label (Frame, "Panes"); Gtk_New_Vbox (Vbox, False, 0); Add (Frame, Vbox); Gtk_New_Vpaned (VPaned); Pack_Start (Vbox, VPaned, True, True, 0); Set_Border_Width (VPaned, 5); Gtk_New_Hpaned (HPaned); Add1 (VPaned, HPaned); Gtk_New (Frame2); Gtk_New (Button, "Hi There"); Add (Frame2, Button); Set_Shadow_Type (Frame2, Shadow_In); Set_USize (Frame2, 60, 60); Pack1 (HPaned, Frame2, False, False); Gtk_New (Frame2); Gtk_New (Button, "erehT iH"); Add (Frame2, Button); Set_Shadow_Type (Frame2, Shadow_In); Set_USize (Frame2, 80, 60); Add2 (HPaned, Frame2); Gtk_New (Frame2); Set_Shadow_Type (Frame2, Shadow_In); Set_USize (Frame2, 60, 280); Add2 (VPaned, Frame2); Pack_Start (Vbox, Create_Pane_Options (HPaned, "Horizontal", "Left", "Right"), False, False, 0); Pack_Start (Vbox, Create_Pane_Options (VPaned, "Vertical", "Top", "Bottom"), False, False, 0); Show_All (Frame); end Run; end Create_Paned;

Alphabetical Index