Gapp
view release on metacpan or search on metacpan
lib/Gapp/Manual.pod view on Meta::CPAN
format in the example.
=item B<content>
You can add widgets to containers using the C<content> parameter. No formatting
options are specified here, just the hierarchy of the widgets. Spacing and
other rendering details are resolved by the layout. The layout will be discussed
in more detail later in this manual.
=back
=head2 DELEGATION
=over 4
=item B<properties>
=item B<methods>
=back
In our example program, the call to C<gobject> was made implicitly by calling
C<show_all> all on the window. This is because C<show_all> is set up to delegate
to the Gtk widget's C<show_all> method. The documentation for the Gapp widget
will provide more information on methods that have been setup for delegation.
=head1 WIDGET LAYOUT
The layout determines how widgets are displayed on the screen. It has control
over things like spacing, alignment, borders, etc. By centralizing the code
the determines the appearance of widgets, it is is possible to achieve a
consistent look GUI. By making changes to the layout, you can affect the
appearance of your whole application. You can subclass layouts too!
=head2 Using a Layout
Layouts are referenced using their class names. You can specify which layout to
use when constructing your widget. All widgets accept the C<layout> parameter.
Gapp::Window->new( layout => 'My::Custom::Layout', content => ... );
=head2 Creating a Layout
You should see L<Gapp::Layout> for information on creating layouts.
=head1 ACTIONS
Actions can be performed and know how to display themselves in menu's and on
on buttons. You can call them directly or connect them to signals.
use Gapp::Actions::Basic qw( Quit );
# call directly
do_Quit;
# connect to signal
$w = Gapp::Window->new;
$w->signal_connect( 'delete-event' => Quit );
# display as menu item
Gapp::MenuItem->new( action => Quit );
# display as button
Gapp::Button->new( action => Quit );
You should see L<Gapp::Actions> for information on creating and using actions.
=head1 TRAITS
Apply traits and roles to your widgets to change their behavior!
Gapp::Entry->new( traits => [qw( MyCustomTrait )] );
=head1 FORMS
Advanced form handling allows you to easily get form data from widgets and
vice versa. You don't manually need to update each field in the form. To create
a form, add the Form trait to any widget.
$form = Gapp::VBox->new(
traits => [qw( Form )],
content => [ Gapp::Entry->new( field => 'user.name' ) ],
);
=head2 The Stash
Now you can pull values from the form using the stash.
$form->stash->fetch('user.name');
You can also set values in the form using the stash.
$form->stash->store('user.name', 'anonymous' );
You have to call update on the form before changes to the stash will be displayed.
$form->update;
=head2 Contexts
Using a context you can sync data between objects and you form.
$user = Foo::User;
$cx = Gapp::Form::Context->new;
$cx->add( 'user' => $user,
writer_prefix => 'set_',
reader_prefix => '',
);
$form->set_context( $cx );
# update the form from the context
$form->update_from_context;
# update the stash and context
$form->apply
( run in 0.618 second using v1.01-cache-2.11-cpan-39bf76dae61 )