Toc Gallery Index Tree Gtkada.Multi_Paned

Hierarchy

Description

This widget implements a multi-paned widget, similar to the standard Gtk_Paned widget, but which can contain several children side to side. This widget can mix vertical and horizontal splits

Types

  • type Child_Iterator is private;
  • type Gtkada_Multi_Paned is access all Gtkada_Multi_Paned_Record'Class;
  • type Gtkada_Multi_Paned_Record is new Gtk.Fixed.Gtk_Fixed_Record with private;
  • type Pane is private;
    An area of the window, which can is splitted either horizontally or vertically. It can contain one or several children, next to each other, or on top of one another.

Subprograms

  • procedure Gtk_New (Win : out Gtkada_Multi_Paned);
    procedure Initialize (Win : access Gtkada_Multi_Paned_Record'Class);
    Create a new paned window.
  • procedure Set_Opaque_Resizing (Win : access Gtkada_Multi_Paned_Record; Opaque : Boolean);
    Whether resizing of the widgets should be opaque or not. The default is not to do opaque resizing for efficiency reasons
  • procedure Add_Child (Win : access Gtkada_Multi_Paned_Record; New_Child : access Gtk.Widget.Gtk_Widget_Record'Class; Orientation : Gtk.Enums.Gtk_Orientation := Gtk.Enums.Orientation_Horizontal; Fixed_Size : Boolean := False; Width, Height : Glib.Gint := 0; After : Boolean := True);
    Add new child, splitting as needed. This should be used when there is no child yet The window is splitted in two by default. However, if Width and Height are specified (or left to -1 for automatic computation), the window is splitted so that amount of screen space is left to the widget (leaving some minimum amount of space to other children as needed). If Fixed_Size is true, then the size of the dock will not change when Win is resized. Otherwise, it will keep its relative size (x% of the total size of Win). This Fixed_Size setting will be reset to False as soon as the user has resized a pane with the mouse.
  • procedure Split (Win : access Gtkada_Multi_Paned_Record; Ref_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; New_Child : access Gtk.Widget.Gtk_Widget_Record'Class; Orientation : Gtk.Enums.Gtk_Orientation; Fixed_Size : Boolean := False; Width, Height : Glib.Gint := 0; After : Boolean := True);
    Split the pane containing Ref_Widget, and add New_Child in the new pane (on the right or at the bottom if After is True, on the left or at the top if After is False).
  • procedure Set_Size (Win : access Gtkada_Multi_Paned_Record; Widget : access Gtk.Widget.Gtk_Widget_Record'Class; Width, Height : Glib.Gint := -1; Fixed_Size : Boolean := False);
    Force a specific size for Widget
  • function Splitted_Area (Win : access Gtkada_Multi_Paned_Record; Ref_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; Orientation : Gtk.Enums.Gtk_Orientation; After : Boolean := True) return Gtk.Widget.Gtk_Widget;
    Return the widget in the splitted area next to Ref_Widget if any exist. Orientation and After define which splitted area we are looking at. null is returned if there are no such splitted area.
  • function Get_Pane (Win : access Gtkada_Multi_Paned_Record; Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return Pane;
    function Get_Pane (Current_Pane : Pane) return Pane;
    Return the pane that contains the widget. See comment for Split below.
  • procedure Split (Win : access Gtkada_Multi_Paned_Record; Ref_Pane : Pane; New_Child : access Gtk.Widget.Gtk_Widget_Record'Class; Orientation : Gtk.Enums.Gtk_Orientation; Fixed_Size : Boolean := False; Width, Height : Glib.Gint := 0; After : Boolean := True);
    Split Ref_Pane to display New_Child to one of its sides. See the comments for Root_Pane above. The examples below assume that you are using one of the two split procedures, either with a Ref_Pane or a Ref_Widget. In the former case, the pane is obtained with a call to Get_Pane(Ref_Widget). As you will see, the results are different (although they might appear similar sometimes on this simple example. In all these examples, we split either vertically or horizontally, and add a new widget "4".

    Given the following setup: +---+---+ | 1 | | +---+ 3 | | 2 | | +---+---+

    Ref_Pane = Get_Pane ("1") Ref_Widget = "1" Split vertically After=True After=False After=True After=False +---+---+ +---+---+ +---+---+ +---+---+ | 1 | 3 | | 4 | 3 | | 1 | 3 | | 4 | 3 | +---+ | +---+ | +---+ | +---+ | | 2 | | | 1 | | | 4 | | | 1 | | +---+ | +---+ | +---+ | +---+ | | 4 | | | 2 | | | 2 | | | 2 | | +---+---+ +---+---+ +---+---+ +---+---+

    Split horizontally After=True After=False After=True After=False +---+---+---+ +---+---+---+ +---+---+---+ +---+---+---+ | 1 | 4 | 3 | | 4 | 1 | 3 | | 1 | 4 | 3 | | 4 | 1 | 3 | +---+ | | | +---+ | +---+---+ | +---+---+ | | 2 | | | | | 2 | | | 2 | | | 2 | | +---+---+---+ +---+---+---+ +-------+---+ +-------+---+

    Ref_Pane = Get_Pane ("3") Ref_Widget = "3" Split vertically After=True After=False After=True After=False +---+---+ +-------+ +---+---+ +---+---+ | 1 | 3 | | 4 | | 1 | 3 | | 1 | 4 | +---+ | +---+---+ +---+---+ +---+---+ | 2 | | | 1 | 3 | | 2 | 4 | | 2 | 3 | +---+---+ +---+ | +---+---+ +---+---+ | 4 | | 2 | | +-------+ +---+---+

    Split horizontally After=True After=False After=True After=False +---+---+---+ +---+---+---+ +---+---+---+ +---+---+---+ | 1 | 3 | 4 | | 4 | 1 | 3 | | 1 | 3 | 4 | | 1 | 4 | 3 | +---+ | | | +---+ | +---+ | | +---+ | | | 2 | | | | | 2 | | | 2 | | | | 2 | | | +---+---+---+ +---+---+---+ +---+---+---+ +---+---+---+

  • procedure Freeze (Win : access Gtkada_Multi_Paned_Record);
    Freeze the window, ie when a child is inserted, no computation of its size is done, and will not generate immediate resizing. You only need to call this procedure when restoring Win to a previously state saved, and never if you are using the GtkAda.MDI which takes care of it on its own.
  • procedure Thaw (Win : access Gtkada_Multi_Paned_Record);
    Opposite of Freeze. You should call Size_Allocate on Win afterward to force a recomputation of the size
  • Iterators

  • function Start (Win : access Gtkada_Multi_Paned_Record) return Child_Iterator;
    Return an iterator to the first child of the window. This also returns children which are not widget, but are used to organize the window into horizontal and vertical panes
  • function At_End (Iter : Child_Iterator) return Boolean;
    True if there is no more child to be returned
  • procedure Next (Iter : in out Child_Iterator);
    Move to the next child of Iterator
  • function Get_Widget (Iter : Child_Iterator) return Gtk.Widget.Gtk_Widget;
    Return the widget embedded in the current child. This returns null if the current child is only used as a pane separator (horizontal or vertical). You mustn't remove the widget from the paned widget, or the iterator becomes invalid.
  • function Get_Orientation (Iter : Child_Iterator) return Gtk.Enums.Gtk_Orientation;
    Return the orientation of the current child. This is only relevant if the child doesn't contain a widget (and therefore Get_Widget has returned null).
  • function Get_Depth (Iter : Child_Iterator) return Natural;
    Return the depth of the current child (0 means the child is at the toplevel, 1 that this is a child directly underneath,...). This can be used to detect when the Iter has finished traversing one of the panes.
  • procedure Dump (Split : access Gtkada_Multi_Paned_Record'Class);
    Dump the configuration of Split to stdout. This is only intended for testing purposes. If you want to save and restore this configuration, you should look at Gtkada.MDI instead, which contains all the subprograms needed to handle desktops.

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) 2003 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- Copyright (C) 2004-2005 -- -- AdaCore -- -- -- -- 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; use Gtk; with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Frame; use Gtk.Frame; with Gtk.Widget; use Gtk.Widget; with Gtkada.Multi_Paned; use Gtkada.Multi_Paned; with Gtk.Toolbar; use Gtk.Toolbar; with Gtkada.Handlers; use Gtkada.Handlers; with Gtk.Vbutton_Box; use Gtk.Vbutton_Box; with Gtk.Toggle_Button; use Gtk.Toggle_Button; with Gtk.Enums; use Gtk.Enums; package body Create_Splittable is function Create_Child (Bar : Gtk_Toolbar; Title : String) return Gtk_Widget; procedure On_Destroy (Button : access Gtk_Widget_Record'Class); procedure On_Toggle (Button : access Gtk_Widget_Record'Class); procedure On_Resize (Button : access Gtk_Widget_Record'Class); procedure On_Split_V (Button : access Gtk_Widget_Record'Class); procedure On_Split_H (Button : access Gtk_Widget_Record'Class); procedure On_Fixed (Button : access Gtk_Widget_Record'Class); procedure On_Opaque (Button : access Gtk_Widget_Record'Class); Pane : Gtkada_Multi_Paned; Item : Natural := 6; Opaque : Boolean := False; ---------- -- Help -- ---------- function Help return String is begin return "A Gtkada-specific widget, where children can be resized" & " interactively by the user, as well as splitted."; end Help; --------------- -- On_Opaque -- --------------- procedure On_Opaque (Button : access Gtk_Widget_Record'Class) is pragma Unreferenced (Button); begin Opaque := not Opaque; Set_Opaque_Resizing (Pane, Opaque); end On_Opaque; ---------------- -- On_Destroy -- ---------------- procedure On_Destroy (Button : access Gtk_Widget_Record'Class) is begin Destroy (Button); end On_Destroy; --------------- -- On_Toggle -- --------------- procedure On_Toggle (Button : access Gtk_Widget_Record'Class) is begin if Visible_Is_Set (Button) then Hide (Button); else Show (Button); end if; end On_Toggle; --------------- -- On_Resize -- --------------- procedure On_Resize (Button : access Gtk_Widget_Record'Class) is begin Set_Size (Pane, Button, 100, 100); end On_Resize; ---------------- -- On_Split_V -- ---------------- procedure On_Split_V (Button : access Gtk_Widget_Record'Class) is Child : constant Gtk_Widget := Create_Child (null, Integer'Image (Item)); begin Item := Item + 1; Split (Pane, Button, Child, Orientation_Vertical); end On_Split_V; ---------------- -- On_Split_H -- ---------------- procedure On_Split_H (Button : access Gtk_Widget_Record'Class) is Child : constant Gtk_Widget := Create_Child (null, Integer'Image (Item)); begin Item := Item + 1; Split (Pane, Button, Child, Orientation_Horizontal); end On_Split_H; -------------- -- On_Fixed -- -------------- procedure On_Fixed (Button : access Gtk_Widget_Record'Class) is begin Set_Size (Pane, Button, Get_Allocation_Width (Button), Get_Allocation_Height (Button), Fixed_Size => True); end On_Fixed; ------------------ -- Create_Child -- ------------------ function Create_Child (Bar : Gtk_Toolbar; Title : String) return Gtk_Widget is Frame : Gtk_Frame; Box : Gtk_Vbutton_Box; Button : Gtk_Button; Item : Gtk_Button; begin Gtk_New (Frame); Gtk_New (Box); Add (Frame, Box); Set_Layout (Box, Buttonbox_Start); Gtk_New (Button, "Destroy_" & Title); Pack_Start (Box, Button, Expand => False); Widget_Callback.Object_Connect (Button, "clicked", Widget_Callback.To_Marshaller (On_Destroy'Unrestricted_Access), Frame); Gtk_New (Button, "Resize_" & Title); Pack_Start (Box, Button, Expand => False); Widget_Callback.Object_Connect (Button, "clicked", Widget_Callback.To_Marshaller (On_Resize'Unrestricted_Access), Frame); Gtk_New (Button, "Split_V " & Title); Pack_Start (Box, Button, Expand => False); Widget_Callback.Object_Connect (Button, "clicked", Widget_Callback.To_Marshaller (On_Split_V'Unrestricted_Access), Frame); Gtk_New (Button, "Split_H " & Title); Pack_Start (Box, Button, Expand => False); Widget_Callback.Object_Connect (Button, "clicked", Widget_Callback.To_Marshaller (On_Split_H'Unrestricted_Access), Frame); Gtk_New (Button, "Fixed_Size " & Title); Pack_Start (Box, Button, Expand => False); Widget_Callback.Object_Connect (Button, "clicked", Widget_Callback.To_Marshaller (On_Fixed'Unrestricted_Access), Frame); if Bar /= null then Gtk_New (Item, "Toggle_" & Title); Add (Bar, Item); Widget_Callback.Object_Connect (Item, "clicked", Widget_Callback.To_Marshaller (On_Toggle'Unrestricted_Access), Frame); end if; Show_All (Frame); return Gtk_Widget (Frame); end Create_Child; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Button, Button1, Button2, Button3, Button4 : Gtk_Widget; Bar : Gtk_Toolbar; Box : Gtk_Box; Toggle : Gtk_Toggle_Button; begin Gtk_New_Vbox (Box, Homogeneous => False); Add (Frame, Box); Gtk_New (Bar); Pack_Start (Box, Bar, Expand => False); Gtk_New (Toggle, "Opaque Resizing"); Pack_Start (Box, Toggle, Expand => False); Widget_Callback.Connect (Toggle, "toggled", On_Opaque'Access); Gtk_New (Pane); Pack_Start (Box, Pane, Expand => True, Fill => True); Button1 := Create_Child (Bar, "1"); Add_Child (Pane, Button1); Button2 := Create_Child (Bar, "2"); Add_Child (Pane, Button2); -- Should split horizontally Button3 := Create_Child (Bar, "3"); Add_Child (Pane, Button3); -- Should split horizontally Button4 := Create_Child (Bar, "4"); Split (Pane, Button2, Button4, Orientation_Vertical); Button := Create_Child (Bar, "5"); Split (Pane, Button4, Button, Orientation_Horizontal); Show_All (Frame); end Run; end Create_Splittable;

Alphabetical Index