Tkx::MegaConfig
handle configuration options for megawidgets
- Provided by: libtkx-perl (Version: 1.09-1)
- Report a bug
handle configuration options for megawidgets
package Foo;
use base qw(Tkx::widget Tkx::MegaConfig);
__PACKAGE__->_Mega("foo");
__PACKAGE__->_Config(
-option => [$where, $dbName, $dbClass, $default],
);
The "Tkx::MegaConfig" class provide implementations of m_configure() and m_cget() that can handle configuration options for megawidgets. How these methods behave is set up by calling the _Config() class method. The _Config() method takes a set option/option spec pairs as argument.
An option argument is either the name of an option with leading '-' or the string 'DEFAULT' if this spec applies to all option with no explicit spec.
If there is no 'DEFAULT' then unmatched options are applied directly to the megawidget root itself. This is the same behaviour you get if you specify:
__PACKAGE__->_Config(
...
DEFAULT => ['.'],
);
The option spec should be an array reference. The first element of the array ($where) describe how this option is handled. Some $where specs take arguments. If you need to provide argument replace $where with an array reference containg [$where, @args]. The rest of the option spec specify names and default for the options database, but is currently ignored (feature unimplemented).
The following $where specs are understood:
An argument can be given to delegate using a different configuration name name on the "foo" widget. Examples:
-foo => [".inner"], # forward -foo
-bg => [[".", "-background]], # alias
-bg2 => [[".inner", "-background]], # forward as -background
-background => [".*"] # forward --background to kids
__PACKAGE__->_Config(
-foo => ["METHOD"];
-bar => [["METHOD", "bar"]],
}
sub _config_foo {
my $self = shift;
return "foo" unless @_;
print "Ignoring setting configuration option -foo to '$_[0]'";
}
sub handle_bar {
my $self = shift;
return "bar" unless @_;
print "Ignoring setting configuration option -bar to '$_[0]'";
}
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright 2005 ActiveState. All rights reserved.
Tkx, Tkx::LabEntry
Inspiration for this module comes from Tk::ConfigSpecs.