home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _c7207616e900524f3ea311c078eadfe1 < prev    next >
Encoding:
Text File  |  2004-06-01  |  2.3 KB  |  90 lines

  1.  
  2. =head1 NAME
  3.  
  4. Tk::Derived - Base class for widgets derived from others
  5.  
  6. =for pm Tk/Derived.pm
  7.  
  8. =for category Derived Widgets
  9.  
  10. =head1 SYNOPSIS
  11.  
  12.     package Tk::MyNewWidget;
  13.  
  14.     use Tk::widgets qw/ BaseWidget, list of Tk widgets /;
  15.     use base qw/ Tk::Derived Tk::BaseWidget /;
  16.  
  17.     Construct Tk::Widget 'MyNewWidget';
  18.  
  19.     sub ClassInit {
  20.         my( $class, $mw ) = @_;
  21.         #... e.g., class bindings here ...
  22.         $class->SUPER::ClassInit( $mw );
  23.     }
  24.  
  25.     sub Populate {
  26.         my( $self, $args ) = @_;
  27.  
  28.         my $flag = delete $args->{-flag};
  29.         if( defined $flag ) {
  30.             # handle -flag => xxx which can only be done at create
  31.             # time the delete above ensures that new() does not try
  32.             # and do  $self->configure( -flag => xxx );
  33.         }
  34.  
  35.         $self->SUPER::Populate( $args );
  36.  
  37.         $self = $self->Component( ... );
  38.  
  39.         $self->Delegates( ... );
  40.  
  41.         $self->ConfigSpecs(
  42.             '-cursor'    => [ SELF, 'cursor', 'Cursor',   undef ],
  43.             '-something' => [ METHOD, dbName,  dbClass, default ],
  44.             '-text'      => [ $label, dbName,  dbClass, default ],
  45.             '-heading'   => [ {-text => $head},
  46.                                 heading, Heading,  'My Heading' ],
  47.        ); 
  48.    }
  49.  
  50.    sub something {
  51.        my( $self, $value) = @_;
  52.        if ( @_ > 1 ) {
  53.           # set it
  54.        }
  55.        return # current value
  56.    }
  57.  
  58. =head1 DESCRIPTION
  59.  
  60. Tk::Derived is used with Perl's multiple inheritance to override some
  61. methods normally inherited from Tk::Widget.
  62.  
  63. Tk::Derived should precede any Tk widgets in the class's base class
  64. definition.
  65.  
  66. Tk::Derived's main purpose is to apply wrappers to C<configure> and C<cget>
  67. methods of widgets to allow the derived widget to add to or modify behaviour
  68. of the configure options supported by the base widget.
  69.  
  70. The derived class should normally override the C<Populate> method provided
  71. by Tk::Derived and call C<ConfigSpecs> to declare configure options.
  72.  
  73. The public methods provided by Tk::Derived are as follows:
  74.  
  75. =over 4
  76.  
  77. =item -E<gt>ConfigSpecs(-I<key> =E<gt> [I<kind>, I<name>, I<Class>, I<default>], ...)
  78.  
  79. =back
  80.  
  81. =head1 SEE ALSO
  82.  
  83. L<Tk::ConfigSpecs|Tk::ConfigSpecs>
  84. L<Tk::mega|Tk::mega>
  85. L<Tk::composite|Tk::composite>
  86.  
  87.  
  88. =cut
  89.  
  90.