Toc Gallery Index Tree Gtk.Notebook

Screenshot

No screeshot

Hierarchy

Description

A Gtk_Notebook is a container that displays all of its children at the same location on the screen. They are organized into pages, that can be selected through tabs (either by clicking on them or by a contextual menu). This is the best way to organize complicated interfaces that have a lot of widgets, by putting the children into groups of coherent widgets.

You can hide some of the pages of the notebook by simply calling Hide on the widget that is contained in the page (or returned from Get_Nth_Page).

Types

  • type Gtk_Notebook is access all Gtk_Notebook_Record'Class;
  • type Gtk_Notebook_Page is Gtk.Gtk_Notebook_Page;
  • type Gtk_Notebook_Record is new Gtk.Container.Gtk_Container_Record with private;
  • type Gtk_Notebook_Tab is (Notebook_Tab_First, Notebook_Tab_Last);
  • type Gtk_Notebook_Window_Creation_Func is access function (Source : System.Address; -- Gtk_Notebook Page : System.Address; -- Gtk_Widget X : System.Address; -- Gint Y : System.Address; -- Gint Data : System.Address) return Gtk_Notebook;

Subprograms

    Creating a notebook and inserting pages

  • procedure Gtk_New (Widget : out Gtk_Notebook);
    Create a new empty notebook.
  • procedure Initialize (Widget : access Gtk_Notebook_Record'Class);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with a Gtk_Notebook.
  • procedure Append_Page (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Insert a new page in Notebook. The page is put at the end of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. No entry is associated with the page in the contextual menu.
  • procedure Append_Page (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class);
    Same as above, but no label is specified.
  • procedure Append_Page_Menu (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class; Menu_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Insert a new page in Notebook. The page is put at the end of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. A new entry is inserted into the contextual menu. This new entry is made with Menu_Label.
  • procedure Prepend_Page (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Insert a new page in Notebook. The page is put at the beginning of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. No entry is associated with the page in the contextual menu.
  • procedure Prepend_Page_Menu (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class; Menu_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Insert a new page in Notebook. The page is put at the beginning of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. A new entry is inserted into the contextual menu. This new entry is made with Menu_Label.
  • procedure Insert_Page (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class; Position : Gint);
    Insert a new page at a specific position in Notebook. The page is put at the beginning of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. No entry is associated with the page in the contextual menu. The first position in the list of pages is 0.
  • procedure Insert_Page_Menu (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class; Menu_Label : access Gtk.Widget.Gtk_Widget_Record'Class; Position : Gint);
    Insert a new page at a specific position in Notebook. The page is put at the beginning of the list of pages. The user will select it through a button that contains the Tab_Label widget, which is generally a Gtk_Label, but could be a box with a pixmap in it for instance. A new entry is inserted into the contextual menu. This new entry is made with Menu_Label. The first position in the list of pages is 0.
  • procedure Remove_Page (Notebook : access Gtk_Notebook_Record; Page_Num : Gint);
    Remove a page from the notebook. The first position in the list of pages is 0.
  • Tabs drag and drop

  • procedure Set_Window_Creation_Hook (Func : Gtk_Notebook_Window_Creation_Func; Data : System.Address; Destroy : Glib.G_Destroy_Notify_Address);
    Install a global function used to create a window when a detached tab is dropped in an empty area.
  • procedure Set_Group_Id (Notebook : access Gtk_Notebook_Record; Group_Id : Gint);
    Set a group identificator for Notebook. Notebooks sharing the same group identificator will be able to exchange tabs via drag and drop. A notebook with group identificator -1 will not be able to exchange tabs with any other notebook.
  • function Get_Group_Id (Notebook : access Gtk_Notebook_Record) return Gint;
    Gets the current group identificator for Notebook or -1 if not set.
  • Modifying and getting the current page

  • function Get_Current_Page (Notebook : access Gtk_Notebook_Record) return Gint;
    Get the number of the current page. The first page has the number 0.
  • function Get_Nth_Page (Widget : access Gtk_Notebook_Record'Class; Page_Num : Gint) return Gtk.Widget.Gtk_Widget;
    Convert from a page number to the real page.
  • function Get_N_Pages (Notebook : access Gtk_Notebook_Record) return Gint;
    Return the number of pages in the notebook
  • function Page_Num (Widget : access Gtk_Notebook_Record'Class; Child : access Gtk.Widget.Gtk_Widget_Record'Class) return Gint;
    Convert from a child to a page number. Note that Child is not the notebook page, but the widget you inserted with Insert_Page, Append_Page,...
  • procedure Set_Current_Page (Notebook : access Gtk_Notebook_Record; Page_Num : in Gint := -1);
    Modify the current page. The current page is the page that is currently visible on the screen. Nothing happens if there is no such page. Note also that the page has to be visible on the screen (ie you must have called Gtk.Widget.Show on it first). Use -1 to set the current page to the last one.

    Note: This call won't succeeded unless you have called Show on the widget displayed in the page.

  • procedure Set_Page (Notebook : access Gtk_Notebook_Record; Page_Num : in Gint := -1) renames Set_Current_Page;
    This function is deprecated. Use Set_Current_Page instead.
  • procedure Next_Page (Notebook : access Gtk_Notebook_Record);
    Display the next page on the screen.
  • procedure Prev_Page (Notebook : access Gtk_Notebook_Record);
    Display the previous page on the screen.
  • Style and visual aspect

  • procedure Set_Show_Border (Notebook : access Gtk_Notebook_Record; Show_Border : Boolean := True);
    Indicate whether the notebook should display borders. This border gives a 3D aspect to the notebook.
  • function Get_Show_Border (Notebook : access Gtk_Notebook_Record) return Boolean;
    Return whether the notebook displays borders.
  • procedure Set_Show_Tabs (Notebook : access Gtk_Notebook_Record; Show_Tabs : Boolean := True);
    Indicate whether the tabs should be displayed. If the tabs are not displayed, the only way for the user to select a new page is through the contextual menu, and thus you should make sure that the pages were created with the Insert_Page_Menu, ... subprograms.
  • function Get_Show_Tabs (Notebook : access Gtk_Notebook_Record) return Boolean;
    Return whether the tabs are displayed.
  • procedure Set_Tab_Pos (Notebook : access Gtk_Notebook_Record; Pos : Gtk.Enums.Gtk_Position_Type);
    Change the position of the tabs. The tabs can be displayed on any of the four sides of the notebook.
  • function Get_Tab_Pos (Widget : access Gtk_Notebook_Record) return Gtk.Enums.Gtk_Position_Type;
    Return the current position of the tabs.
  • procedure Set_Scrollable (Notebook : access Gtk_Notebook_Record; Scrollable : in Boolean := True);
    Indicate whether Notebook display scrolling arrows when there are too many tabs. The default is not to display such scrolling arrows. Note also that a notebook with too many pages, even if the scrolling is activated, is sometimes hard to use for the user.
  • function Get_Scrollable (Notebook : access Gtk_Notebook_Record) return Boolean;
    Return whether Notebook is scrollable. See Set_Scrollable for more details.
  • Popup Menu

    The pages of a notebook can be selected both via tabs and a contextual menu (right mouse button). Note however that the menu is available only if the pages were inserted with Insert_Page_Menu, Append_Page_Menu or Prepend_Page_Menu.
  • procedure Popup_Enable (Notebook : access Gtk_Notebook_Record);
    Enable the popup menu. When the user pressed the right mouse button, a menu is selected that allows him to select a new page.
  • procedure Popup_Disable (Notebook : access Gtk_Notebook_Record);
    Disable the popup menu. This menu won't be display any more when the user pressed the right mouse button.
  • Page properties

  • function Get_Tab_Label (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class) return Gtk.Widget.Gtk_Widget;
    Return the widget displayed in the tab used to select Page. This widget is in fact the one given in argument to Insert_Page,etc. when the page was created.
  • procedure Set_Tab_Label (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Modify the widget displayed in the tab for the page that contains Child. Tab_Label is generally a Gtk_Label, although it can also be a Gtk_Box that contains a Gtk_Pixmap and a Gtk_Label if you want to show pixmaps.
  • procedure Set_Tab_Label_Text (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Tab_Text : UTF8_String);
    Modify the text displayed in the tab for the page that contains Child. This is a less general form of Set_Tab_Label above.
  • function Get_Tab_Label_Text (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class) return UTF8_String;
    Return the text displayed in the tab for the page that contains Child.
  • procedure Set_Tab (Notebook : access Gtk_Notebook_Record; Page_Num : Gint; Tab_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Set Notebook tab widget for a given page number. This function is mainly intended for use by Gate.
  • function Get_Menu_Label (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class) return Gtk.Widget.Gtk_Widget;
    Return the widget displayed in the contextual menu for the Child. This is the widget given in argument to Insert_Page_Menu, Append_Page_Menu and Prepend_Page_Menu.
  • procedure Set_Menu_Label (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Menu_Label : access Gtk.Widget.Gtk_Widget_Record'Class);
    Modify the widget displayed in the contextual menu for the page that contains Child.
  • procedure Set_Menu_Label_Text (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Menu_Text : UTF8_String);
    Modify the text displayed in the contextual menu for the page that contains Child. This is a less general form of Set_Menu_Label above.
  • function Get_Menu_Label_Text (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class) return UTF8_String;
    Return the text displayed in the contextual menu for the page that contains Child.
  • procedure Query_Tab_Label_Packing (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Expand : out Boolean; Fill : out Boolean; Pack_Type : out Gtk.Enums.Gtk_Pack_Type);
    Return the packing used for the tab associated with the page that contains Child. See the Gtk.Box package for more information on the parameters.
  • procedure Set_Tab_Label_Packing (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Expand : Boolean; Fill : Boolean; Pack_Type : Gtk.Enums.Gtk_Pack_Type);
    Modify the packing used for the tab associated with the page that contains Child.
  • procedure Reorder_Child (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Position : Gint);
    Change the position of the page that contains Child.
  • function Get_Tab_Reorderable (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Position : Gint) return Boolean;
    Get whether the tab can be reordered via drag and drop or not.
  • procedure Set_Tab_Reorderable (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Reorderable : Boolean := True);
    Set whether the notebook tab can be reordered.
  • function Get_Tab_Detachable (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Position : Gint) return Boolean;
    Return whether the tab contents can be detached from Notebook.
  • procedure Set_Tab_Detachable (Notebook : access Gtk_Notebook_Record; Child : access Gtk.Widget.Gtk_Widget_Record'Class; Detachable : Boolean := True);
    Set whether the tab can be detached from Notebook to another notebook or widget.

    Note that 2 notebooks must share a common group identificator (see Set_Group_Id) to allow automatic tabs interchange between them.

    If you want a widget to interact with a notebook through DnD (i.e.: accept dragged tabs from it) it must be set as a drop destination and accept the target "GTK_NOTEBOOK_TAB". The notebook will fill the selection with a Gtk_Widget pointing to the child widget that corresponds to the dropped tab.

    If you want a notebook to accept drags from other widgets, you will have to set your own DnD code to do it.

  • GValue support

  • function Get_Notebook_Page (Value : Glib.Values.GValue) return Gtk_Notebook_Page;
    Convert a Value into a notebook page.

Signals

  • change_current_page
    procedure Handler (Notebook : access Gtk_Notebook_Record'Class; Offset : Gint);
    You should emit this signal to request that the notebook selects another page as the current page. The offset is relative to the currently selected page.
  • focus_tab
    function Handler (Notebook : access Gtk_Notebook_Record'Class; Tab : Gtk_Notebook_Tab) return Boolean;
    Gives the focus to one of the tabs in the notebook. This signal is mostly used as a keybinding for Home, End,... so that the proper behavior can be implemented
  • move_focus_out
    procedure Handler (Notebook : access Gtk_Notebook_Record'Class; Direction : Gtk_Direction_Type);
    You should emit this signal to request that the focus be transfered from the current page to the parent widget. Seldom used.
  • select_page
    function Handler (Notebook : access Gtk_Notebook_Record'Class; Move_Focus : Boolean) return Boolean;
    You should emit this signal to request that the notebook selects the page corresponding to the focus tab. If Move_Focus is true, the page acquires the keyboard focus. Seldom used.
  • switch_page
    procedure Handler (Notebook : access Gtk_Notebook_Record'Class; Page : Gtk_Notebook_Page; Page_Num : Guint);
    Notify when the current page is modified in the notebook. This is called every time the user selected a new page, or the program selected a new page with Next_Page, Prev_Page, ...

Properties

  • Enable_Popup_Property
    Boolean
  • Group_Id_Property
    Int
  • Homogeneous_Property
    Boolean
  • Page_Property
    Gint
  • Scrollable_Property
    Boolean
  • Show_Border_Property
    Boolean
  • Show_Tabs_Property
    Boolean
  • Tab_Border_Property
    Guint
    Width of the border around the tab labels
  • Tab_HBorder_Property
    Guint
    Width of the horizontal border around the tab labels
  • Tab_Pos_Property
    Gtk_Position_Type
  • Tab_VBorder_Property
    Guint
    Width of the vertical border around the tab labels

Child Properties

  • Detachable_Property
    Boolean
  • Menu_Label_Property
    String
    The string displayed in the child's menu entry
  • Position_Property
    Int
    The index of the child in the parent
  • Reorderable_Property
    Boolean
  • Tab_Expand_Property
    Boolean
    Whether to expand the child's tab or not
  • Tab_Fill_Property
    Boolean
    Whether the child's tab should fill the allocated area or not
  • Tab_Label_Property
    String
    The string displayed on the child's tab label
  • Tab_Pack_Property
    Enum
    A Gtk_Pack_Type indicating whether the child is packed with

Style Properties

  • Has_Backward_Stepper_Property
    Boolean
    Display the standard backward arrow button
  • Has_Forward_Stepper_Property
    Boolean
    Display the standard forward arrow button
  • Has_Secondary_Backward_Stepper_Property
    Boolean
    Display a second backward arrow button on the opposite end of the
  • Has_Secondary_Forward_Stepper_Property
    Boolean
    Display a second forward arrow button on the opposite end of the
  • Tab_Curvature_Property
    Int
    Size of tab curvature
  • Tab_Overlap_Property
    Int
    Size of tab overlap area

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-2000 E. Briot, J. Brobecker and A. Charlet -- -- Copyright (C) 2001-2007 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 Gdk; with Gdk.Bitmap; use Gdk.Bitmap; with Gdk.Color; use Gdk.Color; with Gdk.Pixmap; use Gdk.Pixmap; with Glib; use Glib; with Glib.Properties; use Glib.Properties; with Gtk.Arguments; use Gtk.Arguments; with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Check_Button; use Gtk.Check_Button; with Gtk.Combo_Box; use Gtk.Combo_Box; with Gtk.Enums; use Gtk.Enums; with Gtk.Handlers; use Gtk.Handlers; with Gtk.Image; use Gtk.Image; with Gtk.Label; use Gtk.Label; with Gtk.Notebook; use Gtk.Notebook; with Gtk.Separator; use Gtk.Separator; with Gtk.Widget; use Gtk.Widget; with Gtk; use Gtk; with Common; use Common; package body Create_Notebook is package Note_Cb is new Handlers.Callback (Gtk_Notebook_Record); package Button_Cb is new Handlers.User_Callback (Gtk_Check_Button_Record, Gtk_Notebook); package Combo_Cb is new Handlers.User_Callback (Gtk_Combo_Box_Record, Gtk_Notebook); package Notebook_Cb is new Handlers.Callback (Gtk_Notebook_Record); package Frame_Cb is new Handlers.User_Callback (Gtk_Check_Button_Record, Gtk_Frame); Book_Open : Gdk_Pixmap; Book_Open_Mask : Gdk_Bitmap; Book_Closed : Gdk_Pixmap; Book_Closed_Mask : Gdk_Bitmap; Notebook : Gtk_Notebook; procedure Tab_Fill (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame); -- Fill all the space with tabs procedure Tab_Expand (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame); -- Expand tabs procedure Hide (Widget : access Gtk_Widget_Record'Class); -- Hide tabs procedure Next_Page (Notebook : access Gtk_Notebook_Record'Class); -- Switch to the next page procedure Prev_Page (Notebook : access Gtk_Notebook_Record'Class); -- Switch to the previous page procedure Tab_Pack (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame); procedure Create_Pages (Notebook : access Gtk_Notebook_Record'Class; The_Start : Gint; The_End : Gint); -- Create the notebook pages procedure Rotate_Notebook (Notebook : access Gtk_Notebook_Record'Class); -- Rotate the tabs around the notebook procedure Show_All_Pages (Notebook : access Gtk_Notebook_Record'Class); -- Show all pages procedure Change_Tabs_Display (Combo : access Gtk_Combo_Box_Record'Class; Notebook : Gtk_Notebook); -- Change notebook to be displayed without tabs, with scrollable tabs or -- with the standard tabs. procedure Notebook_Popup (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook); -- Allow popup window to switch from a page to another procedure Homogeneous (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook); -- Set tabs homogeneous procedure Set_Tabs_Detachable (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook); -- Set tabs detachable procedure Set_Tabs_Reorderable (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook); -- Set tabs reorderable procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class; Params : Gtk.Arguments.Gtk_Args); -- Switch the current page ---------- -- Help -- ---------- function Help return String is begin return "A @bGtk_Toolbar@B is a tabbed dialog that contains any kind" & " of widget, like @bGtk_Frame@Bs in this case. Whenever the user" & " selects a new tab, a new page is displayed." & ASCII.LF & "A callback can be called whenever a new page is selected, through" & " the ""page_switch"" signal."; end Help; -------------- -- Tab_Fill -- -------------- procedure Tab_Fill (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame) is Expand, Fill : Boolean; Typ : Gtk_Pack_Type; begin Query_Tab_Label_Packing (Notebook, Child, Expand, Fill, Typ); Set_Tab_Label_Packing (Notebook, Child, Expand, Get_Active (Button), Typ); end Tab_Fill; ---------------- -- Tab_Expand -- ---------------- procedure Tab_Expand (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame) is Expand, Fill : Boolean; Typ : Gtk_Pack_Type; begin Query_Tab_Label_Packing (Notebook, Child, Expand, Fill, Typ); Set_Tab_Label_Packing (Notebook, Child, Get_Active (Button), Fill, Typ); end Tab_Expand; ---------- -- Hide -- ---------- procedure Hide (Widget : access Gtk_Widget_Record'Class) is begin Gtk.Widget.Hide (Widget); end Hide; --------------- -- Next_Page -- --------------- procedure Next_Page (Notebook : access Gtk_Notebook_Record'Class) is begin Gtk.Notebook.Next_Page (Notebook); end Next_Page; --------------- -- Prev_Page -- --------------- procedure Prev_Page (Notebook : access Gtk_Notebook_Record'Class) is begin Gtk.Notebook.Prev_Page (Notebook); end Prev_Page; -------------- -- Tab_Pack -- -------------- procedure Tab_Pack (Button : access Gtk_Check_Button_Record'Class; Child : in Gtk_Frame) is Expand, Fill : Boolean; Typ : Gtk_Pack_Type; begin Query_Tab_Label_Packing (Notebook, Child, Expand, Fill, Typ); if Get_Active (Button) then Set_Tab_Label_Packing (Notebook, Child, Expand, Fill, Pack_Start); else Set_Tab_Label_Packing (Notebook, Child, Expand, Fill, Pack_End); end if; end Tab_Pack; ------------------ -- Create_Pages -- ------------------ procedure Create_Pages (Notebook : access Gtk_Notebook_Record'Class; The_Start : Gint; The_End : Gint) is Child : Gtk_Frame; Label_Box : Gtk_Box; Menu_Box : Gtk_Box; Pixmap : Gtk_Image; Label : Gtk_Label; Vbox : Gtk_Box; Hbox : Gtk_Box; Check : Gtk_Check_Button; Button : Gtk_Button; begin for I in The_Start .. The_End loop Gtk_New (Child, "Page " & Gint'Image (I)); Set_Border_Width (Child, 10); Gtk_New_Vbox (Vbox, True, 0); Set_Border_Width (Vbox, 10); Add (Child, Vbox); Gtk_New_Hbox (Hbox, True, 0); Pack_Start (Vbox, Hbox, False, True, 5); Gtk_New (Check, "Fill tab"); Pack_Start (Hbox, Check, True, True, 5); Set_Active (Check, True); Frame_Cb.Connect (Check, "toggled", Frame_Cb.To_Marshaller (Tab_Fill'Access), Child); Gtk_New (Check, "Expand tab"); Pack_Start (Hbox, Check, True, True, 5); Set_Active (Check, True); Frame_Cb.Connect (Check, "toggled", Frame_Cb.To_Marshaller (Tab_Expand'Access), Child); Gtk_New (Check, "Pack end"); Pack_Start (Hbox, Check, True, True, 5); Set_Active (Check, True); Frame_Cb.Connect (Check, "toggled", Frame_Cb.To_Marshaller (Tab_Pack'Access), Child); Gtk_New (Button, "Hide page"); Pack_Start (Vbox, Button, True, True, 5); Widget_Handler.Object_Connect (Button, "clicked", Widget_Handler.To_Marshaller (Hide'Access), Slot_Object => Child); Show_All (Child); Gtk_New_Hbox (Label_Box, False, 0); Gtk_New (Pixmap, Book_Closed, Book_Closed_Mask); Pack_Start (Label_Box, Pixmap, False, True, 0); Set_Padding (Pixmap, 3, 1); Gtk_New (Label, "Page" & Gint'Image (I)); Pack_Start (Label_Box, Label, False, True, 0); Show_All (Label_Box); Gtk_New_Vbox (Menu_Box, False, 0); Gtk_New (Pixmap, Book_Closed, Book_Closed_Mask); Pack_Start (Menu_Box, Pixmap, False, True, 0); Set_Padding (Pixmap, 3, 1); Gtk_New (Label, "Page" & Gint'Image (I)); Pack_Start (Menu_Box, Label, False, True, 0); Show_All (Menu_Box); Append_Page_Menu (Notebook, Child, Label_Box, Menu_Box); end loop; end Create_Pages; --------------------- -- Rotate_Notebook -- --------------------- procedure Rotate_Notebook (Notebook : access Gtk_Notebook_Record'Class) is begin Set_Tab_Pos (Notebook, Gtk_Position_Type'Val ((Gtk_Position_Type'Pos (Get_Tab_Pos (Notebook)) + 1) mod 4)); end Rotate_Notebook; -------------------- -- Show_All_Pages -- -------------------- procedure Show_All_Pages (Notebook : access Gtk_Notebook_Record'Class) is begin Show_All (Notebook); end Show_All_Pages; ------------------------- -- Change_Tabs_Display -- ------------------------- procedure Change_Tabs_Display (Combo : access Gtk_Combo_Box_Record'Class; Notebook : Gtk_Notebook) is Active_Text : constant String := Get_Active_Text (Combo); begin if Active_Text = "Standard" then Set_Show_Tabs (Notebook, True); Set_Scrollable (Notebook, False); if Get_N_Pages (Notebook) = 15 then for I in 0 .. 9 loop Remove_Page (Notebook, 5); end loop; end if; elsif Active_Text = "w/o tabs" then Set_Show_Tabs (Notebook, False); if Get_N_Pages (Notebook) = 15 then for I in 0 .. 9 loop Remove_Page (Notebook, 5); end loop; end if; elsif Active_Text = "Scrollable" then Set_Show_Tabs (Notebook, True); Set_Scrollable (Notebook, True); if Get_N_Pages (Notebook) = 5 then Create_Pages (Notebook, 6, 15); end if; end if; end Change_Tabs_Display; -------------------- -- Notebook_Popup -- -------------------- procedure Notebook_Popup (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook) is begin if Get_Active (Button) then Popup_Enable (Notebook); else Popup_Disable (Notebook); end if; end Notebook_Popup; ----------------- -- Homogeneous -- ----------------- procedure Homogeneous (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook) is begin Set_Property (Notebook, Gtk.Notebook.Homogeneous_Property, Get_Active (Button)); end Homogeneous; -------------------------- -- Set_Pages_Detachable -- -------------------------- procedure Set_Tabs_Detachable (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook) is begin for N in 0 .. Get_N_Pages (Notebook) - 1 loop Set_Tab_Detachable (Notebook, Get_Nth_Page (Notebook, N), Get_Active (Button)); end loop; end Set_Tabs_Detachable; --------------------------- -- Set_Pages_Reorderable -- --------------------------- procedure Set_Tabs_Reorderable (Button : access Gtk_Check_Button_Record'Class; Notebook : Gtk_Notebook) is begin for N in 0 .. Get_N_Pages (Notebook) - 1 loop Set_Tab_Reorderable (Notebook, Get_Nth_Page (Notebook, N), Get_Active (Button)); end loop; end Set_Tabs_Reorderable; ----------------- -- Page_Switch -- ----------------- procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class; Params : Gtk.Arguments.Gtk_Args) is Old_Page : constant Gint := Get_Current_Page (Notebook); Pixmap : Gtk_Image; Page_Num : constant Gint := Gint (To_Guint (Params, 2)); Widget : Gtk_Widget; begin Widget := Get_Nth_Page (Notebook, Page_Num); Pixmap := Gtk_Image (Get_Child (Gtk_Box (Get_Tab_Label (Notebook, Widget)), 0)); Set (Pixmap, Book_Open, Book_Open_Mask); Pixmap := Gtk_Image (Get_Child (Gtk_Box (Get_Menu_Label (Notebook, Widget)), 0)); Set (Pixmap, Book_Open, Book_Open_Mask); if Old_Page >= 0 then Widget := Get_Nth_Page (Notebook, Old_Page); Pixmap := Gtk_Image (Get_Child (Gtk_Box (Get_Tab_Label (Notebook, Widget)), 0)); Set (Pixmap, Book_Closed, Book_Closed_Mask); Pixmap := Gtk_Image (Get_Child (Gtk_Box (Get_Menu_Label (Notebook, Widget)), 0)); Set (Pixmap, Book_Closed, Book_Closed_Mask); end if; end Page_Switch; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Box1 : Gtk_Box; Box2 : Gtk_Box; Combo : Gtk_Combo_Box; Button : Gtk_Check_Button; Button2 : Gtk_Button; Label : Gtk_Label; Separator : Gtk_Separator; begin Set_Label (Frame, "Notebook"); Gtk_New_Vbox (Box1, False, 0); Add (Frame, Box1); Gtk_New (Notebook); Notebook_Cb.Connect (Notebook, "switch_page", Page_Switch'Access); Set_Tab_Pos (Notebook, Pos_Top); Pack_Start (Box1, Notebook, False, False, 0); Set_Border_Width (Notebook, 10); Realize (Notebook); Create_From_Xpm_D (Book_Open, Get_Window (Notebook), Book_Open_Mask, Null_Color, Book_Open_Xpm); Create_From_Xpm_D (Book_Closed, Get_Window (Notebook), Book_Closed_Mask, Null_Color, Book_Closed_Xpm); Create_Pages (Notebook, 1, 5); Gtk_New_Hseparator (Separator); Pack_Start (Box1, Separator, False, True, 10); Gtk_New_Hbox (Box2, False, 5); Pack_Start (Box1, Box2, False, True, 0); Gtk_New (Button, "popup menu"); Pack_Start (Box2, Button, True, False, 0); Button_Cb.Connect (Button, "clicked", Button_Cb.To_Marshaller (Notebook_Popup'Access), Notebook); Gtk_New (Button, "homogeneous tabs"); Pack_Start (Box2, Button, True, False, 0); Button_Cb.Connect (Button, "clicked", Button_Cb.To_Marshaller (Homogeneous'Access), Notebook); Gtk_New (Button, "reorderable tabs"); Pack_Start (Box2, Button, True, False, 0); Button_Cb.Connect (Button, "clicked", Button_Cb.To_Marshaller (Set_Tabs_Reorderable'Access), Notebook); Gtk_New (Button, "detachable tabs"); Pack_Start (Box2, Button, True, False, 0); Button_Cb.Connect (Button, "clicked", Button_Cb.To_Marshaller (Set_Tabs_Detachable'Access), Notebook); Gtk_New_Hbox (Box2, False, 5); Set_Border_Width (Box2, 10); Pack_Start (Box1, Box2, False, True, 0); Gtk_New (Label, "Notebook Style :"); Pack_Start (Box2, Label, False, True, 0); Gtk_New_Text (Combo); Append_Text (Combo, "Standard"); Append_Text (Combo, "w/o tabs"); Append_Text (Combo, "Scrollable"); Combo_Cb.Connect (Combo, "changed", Combo_Cb.To_Marshaller (Change_Tabs_Display'Access), Notebook); Pack_Start (Box2, Combo, False, False, 0); Gtk_New (Button2, "Show all pages"); Pack_Start (Box2, Button2, False, True, 0); Note_Cb.Object_Connect (Button2, "clicked", Note_Cb.To_Marshaller (Show_All_Pages'Access), Slot_Object => Notebook); Gtk_New_Hbox (Box2, False, 10); Set_Border_Width (Box2, 10); Pack_Start (Box1, Box2, False, True, 0); Gtk_New (Button2, "next"); Note_Cb.Object_Connect (Button2, "clicked", Note_Cb.To_Marshaller (Next_Page'Access), Slot_Object => Notebook); Pack_Start (Box2, Button2, True, True, 0); Gtk_New (Button2, "prev"); Note_Cb.Object_Connect (Button2, "clicked", Note_Cb.To_Marshaller (Prev_Page'Access), Slot_Object => Notebook); Pack_Start (Box2, Button2, True, True, 0); Gtk_New (Button2, "rotate"); Note_Cb.Object_Connect (Button2, "clicked", Note_Cb.To_Marshaller (Rotate_Notebook'Access), Slot_Object => Notebook); Pack_Start (Box2, Button2, True, True, 0); Show_All (Frame); end Run; end Create_Notebook;

Alphabetical Index