Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  GTK2::EX::FORMFACTORY::LAYOUT (3)

.ds Aq ’


Gtk2::Ex::FormFactory::Layout - Do layout in a FormFactory framework



  package My::Layout;

  use base qw/Gtk2::Ex::FormFactory::Layout/;

  sub build_form         { ... }
  sub add_widget_to_form { ... }

  package main;
  $ff = Gtk2::Ex::FormFactory->new (
    layouter => My::Layout->new(),


This class implements the layout of Containers and their Widgets in a Gtk2::Ex::FormFactory framework. Layout means, how are the widgets aligned to each other, how much space is between them, how are titles rendered, how labels, etc.

The idea behind Gtk2::Ex::FormFactory::Layout is to have a unique point in a GUI application which actually implements these things. The advantage of this approach is obvious: the implementation is very generic and if you want to change layout things you subclass from Gtk2::Ex::FormFactory::Layout and implement your changes there, and not at hundreds of spots distributed over the source code of your application.

The natural result: a consistent looking GUI.


As described above implementing your own layout module starts with subclassing from Gtk2::Ex::FormFactory::Layout. To use your layout implementation set an object of your class as <B>layouterB> in your Gtk2::Ex::FormFactory objects.

Gtk2::Ex::FormFactory::Layout mainly defines two sorts of methods.


The names of the methods are derived from the Widget’s short names (which can be retrieved with $widget->get_type), with a prepended <B>build_B>, e.g.:

  build_form  ( ... )
  build_label ( ... )
  build_table ( ... )

The method prototype looks like this:
$layout-><B>build_TYPEB> ($widget) <B>B>$widget<B>B> is the actual Gtk2::Ex::FormFactory::Widget, e.g. Gtk2::Ex::FormFactory::Form for <B>build_formB>($form).
The <B>build_TYPEB> method actually creates the necessary Gtk2 widgets, e.g. a Gtk2::Table for a Gtk2::Ex::FormFactory::Form and adds these to the FormFactory’s widget instance using the <B>set_gtk_widgetB>() and <B>set_gtk_parent_widgetB>() methods of Gtk2::Ex::FormFactory::Widget.

Call $widget-><B>set_gtk_widgetB>($gtk_widget) for the primary Gtk2 widget which directly displays the value in question, e.g. a Gtk2::Entry if you’re dealing with a Gtk2::Ex::FormFactory::Entry.

If you like to do more layout things which require to add the primary Gtk2 widget to a container, e.g. a Gtk2::Frame, you must call $widget-><B>set_gtk_parent_widgetB>($gtk_parent_widget) with the most top level container widget.

<B>Note:B> the implemenations of all the FormFactory’s widgets expect a specific <B>gtk_widgetB> to be set. If you like to change the primary Gtk widget you need to create your own Gtk2::Ex::FormFactory::Widget for this, because the default implemention most probably won’t work with a another Gtk2::Widget.


The second type of methods are so called add-to methods, which place a widget inside a container. The prototye is as follows:
$layout-><B>add_TYPE_to_TYPEB> ($widget, $container) <B>B>$widget<B>B> is the actual Gtk2::Ex::FormFactory::Widget, e.g. Gtk2::Ex::FormFactory::Form for <B>build_formB>($form).

  add_form_to_window ( ... )
  add_table_to_form  ( ... )

This way you can adjust layout at a very detailed level, but you need not. E.g. the implementation of these methods is most likely the same:

  add_entry_to_form ( ... )
  add_popup_to_form ( ... )

because the implemenation mainly depends on the <B>formB> (the container widget) and not on the widget which is added to the form.

That’s why Gtk2::Ex::FormFactory::Layout knows a default mechanism: if no add-to method is found for a specific widget/container pair, a generic default implementation is used instead. These are named as follows:

  add_widget_to_window ( ... )
  add_widget_to_form   ( ... )
  add_widget_to_table  ( ... )
  add_widget_to_vbox   ( ... )

For a new Container you just need to implement the generic <B>add_widget_to_TYPEB> method, and everything will work. If you want to slightly modify the implementation for specific child widgets, you implement only the methods for these and you’re done.

For a example for such a specific add-to message refer to <B>add_menu_to_windowB>() which attaches the menu without any space around it. The default of a Gtk2::Ex::FormFactory::Window is to have some spacing, which looks ugly around a menu.




This class has not attributes.


 Joern Reder <joern at zyn dot de>


Copyright 2004-2006 by Joern Reder.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2.1 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 Library General Public License for more details.

You should have received a copy of the GNU Library 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.


Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 1275: Non-ASCII character seen before =encoding in ’Joern’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 GTK2::EX::FORMFACTORY::LAYOUT (3) 2011-08-10

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.