The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Tk::Multi::Any - Tk virtual composite widget

SYNOPSIS

 package Tk::Multi::YourWidget ;
 use strict;
 require Tk::Multi::Any;
 require Tk::Derived;

 use vars qw(@ISA $printCmd $defaultPrintCmd $VERSION);

 @ISA = qw(Tk::Derived Tk::Multi::Any);

 ( $VERSION ) = '$Revision: 1.5 $ ' =~ /\$Revision:\s+([^\s]+)/;

 $printCmd = $defaultPrintCmd = 'lp -owhatever' ;

 Tk::Widget->Construct('YourWidget');


 use Tk::Multi::Any ; 

 sub Populate
  {
    my ($cw,$args) = @_ ;
    require Tk::Label;
    require Tk::ROText;

    $cw->{_printCmdRef} = \$printCmd ;
    $args->{_resize_amount} = 5 ;# units depend on your widget type
    $cw->{minWidth} = 40 ; 
    $cw->{minHeight} = 4 ;

    $args->{_slave} = $cw -> 
 #      Scrolled('ROText',
 #              -scrollbars => 'oe',
      ROText( relief => 'sunken', bd => '2', setgrid => 'true', height => 5);

    $cw-> SUPER::Populate($args) -> pack ;

  }

DESCRIPTION

This virtual class must be inherited by your composite widget to make a brand new composite widget usable to Tk::Multi::Manager

WIDGET-SPECIFIC OPTIONS

title

Some text which will be displayed above the slave window.

The slave window feature a set of menu items which must be added in a menu. This menu ref must be passed with the menu_button prameter to the object during its instanciation. Usually, this parameter is passed by the Multi::Manager.

WIDGET-SPECIFIC METHODS

setSize( height, [ width ])

Will resize the text window.

resize ( height_increment [, width_increment])

Will increment or decrement the slave window size.

print

Will raise a popup window with an Entry to modify the actual print command, a print button, a default button (to restore the default print command), and a cancel button.

hide

Will hide the widget.

setPrintCmd('print command')

Will set the $printCmd class variable to the passed string. You may use this method to set the appropriate print command on your machine. Note that using this method will all other instance of YourWidget since the modified variable is not an instance variable but a class variable.

doPrint

Print the title and the content of the text window. The print is invoked by dumping the text content into a piped command. By default this command is set to 'lp -ol70 -otl66 -o12 -olm10' which works fine on my HP-UX machine with A4 paper.

You may want to set up a new command to print correctly on your machine. You may do it by using the setPrintCmd method or by invoking the 'print' method.

Delegated methods

By default all widget method are delegated to the Text widget. Excepted :

command(-label => 'some text', -command => sub {...} )

Delegated to the menu entry managed by Multi::Manager. Will add a new command to the aforementionned menu.

Mandatory method in child class

The following methods must be defined in your child class.

Populate

Must define the slave widget included in the Multi class. Within this Populate method, you must define the following paramaters which are to be passed to Any::Populate.

  • _slave: Array ref containing the specs of the slave widget (for instance [qw/ROText bd 2/]). No default.

  • _resize_amount: Number or string which will be used to increment or decrement the slave window size.

  • _hscroll: Slave window will have a horizontal scroll if set to 1 (default 0)

  • _pack: Pack arguments used when packing the frame containing the slave window. (empty by default).

  • minWidth : minimum width of the widget

  • minHeight : minimum height of the widget

  • _printCmdRef: a reference to the $printCmd class variable.

clear

Clear the slave widget

resetPrintCmd

printableDump

Must return a string usable to print the content of the slave widget.

BUGS

Popup menus don't work on canvas based widget. In this case the Popup appears on the title on top of the widget.

TO DO

I'm not really satisfied with print management. May be one day, I'll write a print management composite widget which will look like Netscape's print window. But that's quite low on my priority list. Any volunteer ?

Use Scrolled to get better scrolling interface.

Disable button when size limit is reached (or use PackAdjust when it's fixed)

AUTHOR

Dominique Dumont, Dominique_Dumont@grenoble.hp.com

Copyright (c) 1997-1998 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

perl(1), Tk(3), Tk::Multi(3), Tk::Multi::Manager(3)

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 438:

'=item' outside of any '=over'

Around line 471:

You forgot a '=back' before '=head2'