| 1 | # Copyright (c) 1997-1998 Dominique Dumont. All rights reserved. | ||
| 2 | # This program is free software; you can redistribute it and/or | ||
| 3 | # modify it under the same terms as Perl itself. | ||
| 4 | |||
| 5 | package Tk::Multi::Frame ; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | |||
| 9 | use vars qw($printCmd $defaultPrintCmd $VERSION); | ||
| 10 | |||
| 11 | use base qw(Tk::Derived Tk::TFrame Tk::Multi::Any); | ||
| 12 | |||
| 13 | $VERSION = sprintf "%d.%03d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/; | ||
| 14 | |||
| 15 | # Items to export into callers namespace by default. Note: do not export | ||
| 16 | # names by default without a very good reason. Use EXPORT_OK instead. | ||
| 17 | # Do not simply export all your public functions/methods/constants. | ||
| 18 | |||
| 19 | $printCmd = $defaultPrintCmd = 'lp -ol70 -otl66 -o12 -olm10' ; | ||
| 20 | |||
| 21 | Tk::Widget->Construct('MultiFrame'); | ||
| 22 | |||
| 23 | # Preloaded methods go here. | ||
| 24 | |||
| 25 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||
| 26 | |||
| 27 | sub Populate | ||
| 28 | { | ||
| 29 | my ($cw,$args) = @_ ; | ||
| 30 | Tk::Multi::Any::normalize($cw,$args) ; | ||
| 31 | |||
| 32 | require Tk::Label; | ||
| 33 | require Tk::Frame; | ||
| 34 | |||
| 35 | $cw->{_printCmdRef} = \$printCmd ; | ||
| 36 | |||
| 37 | my $title = $cw ->{'title'} = delete $args->{'-title'} || 'anonymous'; | ||
| 38 | $args->{-label} = [ -text => $title ]; # for TFrame; | ||
| 39 | $cw->{printSub} = delete $args->{-print}; | ||
| 40 | |||
| 41 | my $menu = delete $args->{'-menu_button'}; | ||
| 42 | die "Multi window $title: missing menu_button argument\n" | ||
| 43 | unless defined $menu ; | ||
| 44 | |||
| 45 | $menu->command(-label=>'print...', -command => [$cw, 'print' ]) | ||
| 46 | if defined $cw->{printSub}; | ||
| 47 | |||
| 48 | # print stuff | ||
| 49 | $cw->{_printToFile} = 0; | ||
| 50 | $cw->{_printFile} = ''; | ||
| 51 | |||
| 52 | my $subref = sub {$menu->Popup(-popover => 'cursor', -popanchor => 'nw')}; | ||
| 53 | |||
| 54 | $cw -> bind('<Button-3>', $subref); | ||
| 55 | |||
| 56 | $cw->ConfigSpecs( | ||
| 57 | '-borderwidth' => [$cw, undef, undef, 2 ], | ||
| 58 | -relief => [$cw, undef, undef,'groove'], | ||
| 59 | 'DEFAULT' => [$cw] | ||
| 60 | ) ; | ||
| 61 | |||
| 62 | $cw->Delegates('-command' => $menu, | ||
| 63 | DEFAULT => $cw) ; | ||
| 64 | |||
| 65 | $cw->SUPER::Populate($args); | ||
| 66 | } | ||
| 67 | |||
| 68 | sub resetPrintCmd | ||
| 69 | { | ||
| 70 | my $cw=shift ; | ||
| 71 | $printCmd=$defaultPrintCmd ; | ||
| 72 | } | ||
| 73 | |||
| 74 | sub printableDump | ||
| 75 | { | ||
| 76 | my $cw= shift ; | ||
| 77 | return &{$cw->{printSub}} ; | ||
| 78 | } | ||
| 79 | |||
| 80 | 1; | ||
| 81 | __END__ |