1Derived(3)            User Contributed Perl Documentation           Derived(3)
2
3
4

NAME

6       Tk::Derived - Base class for widgets derived from others
7

SYNOPSIS

9           package Tk::MyNewWidget;
10
11           use Tk::widgets qw/ BaseWidget, list of Tk widgets /;
12           use base qw/ Tk::Derived Tk::BaseWidget /;
13
14           Construct Tk::Widget 'MyNewWidget';
15
16           sub ClassInit {
17               my( $class, $mw ) = @_;
18               #... e.g., class bindings here ...
19               $class->SUPER::ClassInit( $mw );
20           }
21
22           sub Populate {
23               my( $self, $args ) = @_;
24
25               my $flag = delete $args->{-flag};
26               if( defined $flag ) {
27                   # handle -flag => xxx which can only be done at create
28                   # time the delete above ensures that new() does not try
29                   # and do  $self->configure( -flag => xxx );
30               }
31
32               $self->SUPER::Populate( $args );
33
34               $self = $self->Component( ... );
35
36               $self->Delegates( ... );
37
38               $self->ConfigSpecs(
39                   '-cursor'    => [ SELF, 'cursor', 'Cursor',   undef ],
40                   '-something' => [ METHOD, dbName,  dbClass, default ],
41                   '-text'      => [ $label, dbName,  dbClass, default ],
42                   '-heading'   => [ {-text => $head},
43                                       heading, Heading,  'My Heading' ],
44              );
45          }
46
47          sub something {
48              my( $self, $value) = @_;
49              if ( @_ > 1 ) {
50                 # set it
51              }
52              return # current value
53          }
54

DESCRIPTION

56       Tk::Derived is used with Perl's multiple inheritance to override some
57       methods normally inherited from Tk::Widget.
58
59       Tk::Derived should precede any Tk widgets in the class's base class
60       definition.
61
62       Tk::Derived's main purpose is to apply wrappers to "configure" and
63       "cget" methods of widgets to allow the derived widget to add to or
64       modify behaviour of the configure options supported by the base widget.
65
66       The derived class should normally override the "Populate" method
67       provided by Tk::Derived and call "ConfigSpecs" to declare configure
68       options.
69
70       The public methods provided by Tk::Derived are as follows:
71
72       ->ConfigSpecs(-key => [kind, name, Class, default], ...)
73

SEE ALSO

75       Tk::ConfigSpecs Tk::mega Tk::composite
76
77
78
79perl v5.30.1                      2020-01-30                        Derived(3)
Impressum