| Tk-Multi documentation | Contained in the Tk-Multi distribution. |
Tk::Multi::Canvas - Tk composite widget with a scroll window and more
use Tk::Multi::Manager;
use Tk::Multi::Canvas ;
my $manager = yourWindow -> MultiManager
(
menu => $menu_ref , # optionnal
title => "windows" # optionnal
) -> pack ();
# Don't pack it, the manager will do it
my $w1 = $manager -> newSlave('type' => 'MultiCanvas', 'title' => 'a_label');
This composite widget features :
This widget will forward all unrecognize commands to the Canvas object.
Note that this widget should be created only by the Multi::Manager.
Some text which will be displayed above the test window.
Will resize the canvas window.
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.
Print the label and the content of the text window. The print is invoked by dumping the text content into a piped command.
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.
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 affect all other Tk::Multi::Canvas object since the modified variable is not an instance variable but a class variable.
clear all items in the canvas.
By default all widget method are delegated to the Text widget. Excepted :
Delegated to the menu entry managed by Multi::Manager. Will add a new command to the aforementionned menu.
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 ?
Dragging middle mouse button to scroll the canvas.
Defines ressources for the config options.
Dominique Dumont, domi@komarr.grenoble.hp.com
Copyright (c) 1997-1998,2004 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.
perl(1), Tk(3), Tk::Multi(3), Tk::Multi::Manager(3)
| Tk-Multi documentation | Contained in the Tk-Multi distribution. |
# 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. package Tk::Multi::Canvas ; use strict; use vars qw($printCmd $defaultPrintCmd $VERSION); use base qw(Tk::Derived Tk::Frame Tk::Multi::Any); $VERSION = sprintf "%d.%03d", q$Revision: 2.5 $ =~ /(\d+)\.(\d+)/; # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. $printCmd = $defaultPrintCmd = 'lp -opostscript' ; Tk::Widget->Construct('MultiCanvas'); # Preloaded methods go here. # Autoload methods go after =cut, and are processed by the autosplit program. sub Populate { my ($cw,$args) = @_ ; Tk::Multi::Any::normalize($cw,$args) ; require Tk::Label; require Tk::Canvas; $cw->{_printCmdRef} = \$printCmd ; my $title = $cw->{'title'} = delete $args->{'-title'} || 'anonymous'; my $menu = delete $args->{'-menu_button'}; die "Multi window $title: missing -menu_button argument\n" unless defined $menu ; my $titleLabel = $cw->Label(-text => $title.' display')-> pack(qw/-fill x/) ; $menu->command(-label=>'print...', -command => [$cw, 'print' ]) ; $menu->command(-label=>'clear', -command => [$cw, 'clear' ]); # print stuff $cw->{_printToFile} = 0; $cw->{_printFile} = ''; my $slaveWindow = $cw -> Scrolled (qw/Canvas -relief sunken -bd 2/) -> pack(qw/-fill both -expand 1/) ; my $subref = sub {$menu->Popup(-popover => 'cursor', -popanchor => 'nw')}; #$slaveWindow->Subwidget('scrolled') -> bind ('<Button-3>', $subref); $titleLabel -> bind('<Button-3>', $subref); $cw->ConfigSpecs( '-relief' => [$cw, undef, undef, 'raised'], '-borderwidth' => [$cw, undef, undef, 2 ], '-scrollbars'=> [$slaveWindow, undef, undef,'osoe'], '-width' => [$slaveWindow, undef, undef, 400], '-height' => [$slaveWindow, undef, undef, 200], 'DEFAULT' => [$slaveWindow] ) ; $cw->Delegates('command' => $menu, 'clear' => $cw, DEFAULT => $slaveWindow) ; $cw->SUPER::Populate($args); } sub clear { my $cw= shift ; $cw-> delete('all') ; } sub resetPrintCmd { my $cw=shift ; $printCmd=$defaultPrintCmd ; } sub printableDump { my $cw= shift ; my $array = $cw->cget('-scrollregion') ; return $cw-> postscript (qw/-colormode gray -pageheight 29c -pagewidth 21c/, -width => $array->[2], -height => $array->[3]); } 1; __END__ # Below is the stub of documentation for your module. You better edit it!