The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Gtk2::Ex::FormFactory - Makes building complex GUI's easy

SYNOPSIS

  #-- Refer to http://www.exit1.org/ for 
  #-- a comprehensive online documentation.

  #-- Read Gtk2::Ex::FormFactory::Intro

  use Gtk2::Ex::FormFactory;

  my $context  = Gtk2::Ex::FormFactory::Context->new;
  
  $context->add_object (
    name   => "worksheet",
    object => My::Worksheet->new,
  );
  
  # derived from Gtk2::Ex::FormFactory::Layout
  my $layouter = My::Layout->new;

  # derived from Gtk2::Ex::FormFactory::Rules
  my $rule_checker = My::Rules->new;

  my $ff = Gtk2::Ex::FormFactory->new (
    context      => $context,
    layouter     => $layouter,
    rule_checker => $rule_checker,
    content      => [
      Gtk2::Ex::FormFactory::Window->new (
        title   => "Worksheet Editor",
        content => [
          Gtk2::Ex::FormFactory::Form->new (
            title   => "Main data",
            content => [
              Gtk2::Ex::FormFactory::Entry->new (
                label => "Worksheet title",
                attr  => "worksheet.title",
                tip   => "Title of this worksheet",
              ),
              #-- More widgets...
            ],
          ),
          Gtk2::Ex::FormFactory->DialogButtons->new,
        ],
      ),
    ],
  );

  $ff->open;
  $ff->update;
  
  Gtk2->main;

ABSTRACT

With Gtk2::Ex::FormFactory you can build a GUI which consistently represents the data of your application.

DESCRIPTION

This is a framework which tries to make building complex GUI's easy, by offering these two main features:

  * Consistent looking GUI without the need to code resp. tune
    each widget by hand. Instead you declare the structure of your
    GUI, connect it to the data of your program (which should be
    a well defined set of objects) and control how this structure
    is transformed into a specific layout in a very generic way.

  * Automatically keep widget and object states in sync (in both
    directions), even with complex data structures with a lot of
    internal dependencies, object nesting etc.

This manpage describes the facilities of Gtk2::Ex::FormFactory objects which are only a small part of the whole framework. To get a full introduction and overview of how this framework works refer to Gtk2::Ex::FormFactory::Intro.

OBJECT HIERARCHY

  Gtk2::Ex::FormFactory::Widget
  +--- Gtk2::Ex::FormFactory::Container
       +--- Gtk2::Ex::FormFactory

ATTRIBUTES

Attributes are handled through the common get_ATTR(), set_ATTR() style accessors, but they are mostly passed once to the object constructor and must not be altered after the associated FormFactory was built.

context = Gtk2::Ex::FormFactory::Context [optional]

This is the Context of this FormFactory. The Context connects your application objects and their attributes with the GUI build through the FormFactory. Refer to Gtk2::Ex::FormFactory::Context for details.

If you omit this option in the new() object constructor an empty Context is created which can be accessed with get_context.

layouter = Gtk2::Ex::FormFactory::Layout [optional]

This is the Layout module of this FormFactory. The Layout module actually builds the GUI and thus controls all details of appearance. Refer to Gtk2::Ex::FormFactory::Layout for details, if you're interested in writing your own Layout module.

If you omit this option in the new() object constructor a default Gtk2::Ex::FormFactory::Layout object is created which can be accessed with get_layouter.

rule_checker = Gtk2::Ex::FormFactory::Rules [optional]

This is the rule checker module of this FormFactory. It's responsible to check user input against a set of rules which may be associated with a widget.

Refer to Gtk2::Ex::FormFactory::Rules for details, if you're interested in writing your own rule checker module.

If you omit this option in the new() object constructor a default Gtk2::Ex::FormFactory::Rules object is created which can be accessed with get_rule_checker.

sync = BOOL [optional]

By default all changes on the GUI trigger corresopndent updates on your application objects immediately. If you want to build dialogs with local changes on the GUI only, e.g. to be able to implement a Cancel button in a simple fashion (refer to Gtk2::Ex::FormFactory::DialogButtons), you may switch this synchronisation off by setting sync to FALSE.

But note that asynchronous dialogs are static. Dependencies between objects and attributes, which are defined in the associated Gtk2::Ex::FormFactory::Context, don't work on widget/GUI level. That's why automatic dependency resolution / widget updating only works for FormFactory's with sync set to TRUE.

parent_ff = Gtk2::Ex::FormFactory object [optional]

You may specify a parent Gtk2::Ex::FormFactory object. The Gtk Window of this FormFactory will be set transient to the Gtk Window of the parent FormFactory.

METHODS

$form_factory->open ( [ hide => BOOL ])

This actually builds and displays the GUI, if you set the hide parameter to a true value. Until this method is called you can add new or modify existent Widgets of this FormFactory.

If you set hide you need to call $form_factory->show later, otherwise all widgets will keep invisible.

No object data will be transfered to the GUI, so it will be more or less empty. Call update to put data into the GUI.

$form_factory->update ()

After building the GUI you should call update to transfer your application data to the GUI.

$form_factory->ok ()

This method applies all changes of a asynchronous FormFactory and closes it afterwards.

$form_factory->apply ()

All changes to Widgets inside this FormFactory are applied to the associated application object attributes.

Useful only in a FormFactory with sync=FALSE.

$form_factory->close ()

When you exit the program you must call close on all FormFactories which are actually open. Otherwise you will get error messages like this from Perl's garbage collector:

  Attempt to free unreferenced scalar: SV 0x85d7374
    during global destruction.

That's because circular references are necessary between Gtk2 and Gtk2::Ex::FormFactory widgets. These references need first to be deleted until Perl can exit the program cleanly.

$form_factory->cancel

Currently this simply calls $form_factory->close.

$form_factory->open_confirm_window ( parameters )

This is a convenience method to open a confirmation window which is set modal and transient to the window of this FormFactory. The following parameters are known:

  message       The message resp. question, HTML markup allowed
  position      Position of the dialog. Defaults to 'center-on-parent'.
                Other known values are: 'none', 'center', 'mouse'
                and 'center-always'
  yes_callback  Code reference to be called if the user
                answered your question with "Yes"
  no_callback   Code reference to be called if the user
                answered your question with "No"
  yes_label     (Stock-)Label for the yes button. Default 'gtk-yes'
  no_label      (Stock-)Label for the no button. Default 'gtk-no'
  
$form_factory->open_message_window ( parameters )

This is a convenience method to open a message window which is set modal and transient to the window of this FormFactory. The following parameters are known:

  type          Type of the dialog. Defaults to 'info'.
                Other known values are: 'warning', 'question' and 'error'
  message       The message, HTML markup allowed
  position      Position of the dialog. Defaults to 'center-on-parent'.
                Other known values are: 'none', 'center', 'mouse'
                and 'center-always'
$filename = $form_factory->get_image_path

This is a convenience method to find a filename inside Perl's @INC path. You will need this if you ship images or icons inside your module namespace and want to retreive the actual filenames of them.

$form_factory->change_mouse_cursor ( $type [, $gtk_widget] )

This convenience method changes the mouse cursor of the window of this FormFactory, or of an arbitrary widget passed as $gtk_widget. $type is the cursor type, e.g. "watch" for a typical busy / sandglass cursor. Refer to the Gtk documentation for a complete list of possible mouse cursors.

AUTHORS

 Jörn Reder <joern at zyn dot de>

COPYRIGHT AND LICENSE

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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 564:

Non-ASCII character seen before =encoding in 'Jörn'. Assuming CP1252