Tk
view release on metacpan or search on metacpan
pod/composite.pod view on Meta::CPAN
widget, it must call the B<Construct> method from class B<Widget>. That
method accepts the name of the new class to create, i.e. the package name
of your composite widget:
Construct Tk::Widget 'MyNewWidget';
Here, B<MyNewWidget> is the package name (aka the widget's B<class>). This
will define a constructor method for B<MyNewWidget>, normally named after the
widget's class. Instanciating that composite in client code would
the look like:
$mw = MainWindow->new; # creates a top-level MainWindow
$self = $mw->MyNewWidget(); # creates an instance of the
# composite widget MyNewWidget
Whenever a composite is instanciated in client code,
C<Tk::Widget::new()> will be invoked via the widget's class
constructor. That B<new> method will call
$self->Populate(\%args);
where I<%args> is the arguments passed to the widget's constructor. Note
that B<Populate> receives a B<reference> to the hash array
containing all arguments.
B<Populate> is typically defined in the composite class (package),
which creates the characteristic subwidgets of the class.
=head2 Creating Subwidgets
Subwidget creation happens usually in B<Populate()>.
The composite usually calls the
subwidget's constructor method either directly, for "private" subwidgets,
or indirectly through the B<Component> method for subwidgets that should
be advertised to clients.
B<Populate> may call B<Delegates> to direct calls to methods
of chosen subwidgets. For simple composites, typically most if not all
methods are directed
to a single subwidget - e.g. B<ScrListbox> directs all methods to the core
B<Listbox> so that I<$composite>-E<gt>B<get>(...) calls
I<$listbox>-E<gt>B<get>(...).
=head2 Defining mega-widget options
B<Populate> should also call B<ConfigSpecs()> to specify the
way that configure-like options should be handled in the composite.
Once B<Populate> returns, method B<Tk::Frame::ConfigDefault>
walks through the B<ConfigSpecs> entries and populates
%$args hash with defaults for options from X resources (F<.Xdefaults>, etc).
When B<Populate> returns to B<Tk::Widget::new()>,
a call to B<$self>-E<gt>I<configure>(%$args) is made which sets *all*
the options.
=head1 SEE ALSO
L<Tk::ConfigSpecs|Tk::ConfigSpecs>
L<Tk::mega|Tk::mega>
L<Tk::Derived|Tk::Derived>
=cut
( run in 0.323 second using v1.01-cache-2.11-cpan-96521ef73a4 )