Gtk2::E...::Layout(3)

πŸ“¦
version 0.67 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::E...::Layout β€” bestie edition πŸ’–

okay so this is the manual page for Gtk2::Ex::FormFactory::Layout, straight out of the User Contributed Perl Documentation, and I'm gonna walk you through it like we're texting at 2am. it's giving layout queen. let's go 🫢


✨ NAME ✨

Gtk2::Ex::FormFactory::Layout β€” literally just: do layout in a FormFactory framework. that's the whole vibe. it lays stuff out. πŸ’…


🌸 SYNOPSIS 🌸

here's how you'd actually roll your own:

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(),
  ...
);

subclass it, drop it in as your layouter, done. iconic. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class implements the layout of Containers and their Widgets in a Gtk2::Ex::FormFactory framework. and "Layout" here means everything: how are the widgets aligned to each other, how much space is between them, how are titles rendered, how labels, etc. the whole aesthetic, basically. πŸ’…

the idea behind Gtk2::Ex::FormFactory::Layout is to have a unique point in a GUI application which actually implements these things. and the advantage of this approach is obvious, bestie: 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. like, no more copy-paste chaos, no more "where did I set that padding". periodt.

the natural result: a consistent looking GUI. πŸ‘‘


πŸŽ€ SUBCLASSING πŸŽ€

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 layouter in your Gtk2::Ex::FormFactory objects.

Gtk2::Ex::FormFactory::Layout mainly defines two sorts of methods. two. iconic duo energy. πŸ‘―

πŸ”₯ BUILD 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 build_, e.g.:

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

the method prototype looks like this:

  • $layout->build_TYPE ($widget) β€” $widget is the actual Gtk2::Ex::FormFactory::Widget, e.g. Gtk2::Ex::FormFactory::Form for build_form($form).

the build_TYPE 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 set_gtk_widget() and set_gtk_parent_widget() methods of Gtk2::Ex::FormFactory::Widget.

call $widget->set_gtk_widget($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->set_gtk_parent_widget($gtk_parent_widget) with the most top level container widget.

note: the implemenations of all the FormFactory's widgets expect a specific gtk_widget 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. ⚠️ like, don't just swap it and hope. she will not cooperate.

πŸ’œ ADD...TO... METHODS

the second type of methods are so called add-to methods, which place a widget inside a container. the prototye is as follows:

  • $layout->add_TYPE_to_TYPE ($widget, $container) β€” $widget is the actual Gtk2::Ex::FormFactory::Widget, e.g. Gtk2::Ex::FormFactory::Form for build_form($form).

examples:

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 form (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 add_widget_to_TYPE 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. slay. ✨

for a example for such a specific add-to message refer to add_menu_to_window() 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. πŸ’€ (fr fr, menus with random padding are a crime)


🌈 OBJECT HIERARCHY 🌈

Gtk2::Ex::FormFactory::Layout

just the one. she stands alone. main character energy. πŸ‘‘


⭐ ATTRIBUTES ⭐

this class has not attributes. not one. zero. clean girl aesthetic. 🧚


πŸ“ AUTHORS πŸ“

JΓΆrn Reder <joern at zyn dot de>


copyright 2004-2006 by JΓΆrn 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.


😭 POD ERRORS 😭

hey! the above document had some coding errors, which are explained below:

around line 1275:

Non-ASCII character seen before =encoding in 'JΓΆrn'. Assuming UTF-8

like… the ΓΆ said "I'm here and I'm UTF-8, deal with it." πŸ’… iconic honestly.


and that's the whole page, bestie!! this one came from the User Contributed Perl Documentation, perl v5.42.0, dated 2025-07-25 β€” mwah, go forth and lay out your widgets consistently πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from