1 package Pod::Perldoc::ToTk;
8 use parent qw(Pod::Perldoc::BaseTo);
11 sub write_with_binmode { 0 }
12 sub output_extension { 'txt' } # doesn't matter
13 sub if_zero_length { } # because it will be 0-length!
14 sub new { return bless {}, ref($_[0]) || $_[0] }
16 # TODO: document these and their meanings...
17 sub tree { shift->_perldoc_elem('tree' , @_) }
18 sub tk_opt { shift->_perldoc_elem('tk_opt' , @_) }
19 sub forky { shift->_perldoc_elem('forky' , @_) }
22 use File::Spec::Functions qw(catfile);
24 BEGIN{ # Tk is not core, but this is
25 eval { require Tk } ||
26 __PACKAGE__->die( <<"HERE" );
27 You must have the Tk module to use Pod::Perldoc::ToTk.
28 If you have it installed, ensure it's in your Perl library
34 " doesn't work nice with Tk.pm version $Tk::VERSION"
35 ) if $Tk::VERSION eq '800.003';
39 BEGIN { eval { require Tk::FcyEntry; }; };
40 BEGIN{ # Tk::Pod is not core, but this is
41 eval { require Tk::Pod } ||
42 __PACKAGE__->die( <<"HERE" );
43 You must have the Tk::Pod module to use Pod::Perldoc::ToTk.
44 If you have it installed, ensure it's in your Perl library
49 # The following was adapted from "tkpod" in the Tk-Pod dist.
53 my($self, $Input_File) = @_;
54 if($self->{'forky'}) {
55 return if fork; # i.e., parent process returns
58 $Input_File =~ s{\\}{/}g
59 if $self->is_mswin32 or $self->is_dos
64 $tree = $self->{'tree' };
65 $tk_opt = $self->{'tk_opt'};
67 #require Tk::ErrorDialog;
69 # Add 'Tk' subdirectories to search path so, e.g.,
70 # 'Scrolled' will find doc in 'Tk/Scrolled'
73 push @INC, grep -d $_, map catfile($_,'Tk'), @INC;
76 my $mw = MainWindow->new();
77 #eval 'use blib "/home/e/eserte/src/perl/Tk-App";require Tk::App::Debug';
80 # CDE use Font Settings if available
81 my $ufont = $mw->optionGet('userFont','UserFont'); # fixed width
82 my $sfont = $mw->optionGet('systemFont','SystemFont'); # proportional
83 if (defined($ufont) and defined($sfont)) {
84 foreach ($ufont, $sfont) { s/:$//; };
85 $mw->optionAdd('*Font', $sfont);
86 $mw->optionAdd('*Entry.Font', $ufont);
87 $mw->optionAdd('*Text.Font', $ufont);
90 $mw->optionAdd('*Menu.tearOff', $Tk::platform ne 'MSWin32' ? 1 : 0);
93 '-file' => $Input_File,
94 (($Tk::Pod::VERSION >= 4) ? ('-tree' => $tree) : ())
97 # xxx dirty but it works. A simple $mw->destroy if $mw->children
98 # does not work because Tk::ErrorDialogs could be created.
99 # (they are withdrawn after Ok instead of destory'ed I guess)
102 $mw->repeat(1000, sub {
103 # ErrorDialog is withdrawn not deleted :-(
104 foreach ($mw->children) {
105 return if "$_" =~ /^Tk::Pod/ # ->isa('Tk::Pod')
115 exit if $self->{'forky'}; # we were the child! so exit now!
125 Pod::Perldoc::ToTk - let Perldoc use Tk::Pod to render Pod
129 perldoc -o tk Some::Modulename &
133 This is a "plug-in" class that allows Perldoc to use
134 Tk::Pod as a formatter class.
136 You have to have installed Tk::Pod first, or this class won't load.
140 L<Tk::Pod>, L<Pod::Perldoc>
144 Current maintainer: Mark Allen C<< <mallen@cpan.org> >>
146 Past contributions from:
147 brian d foy C<< <bdfoy@cpan.org> >>
148 Adriano R. Ferreira C<< <ferreira@cpan.org> >>;
149 Sean M. Burke C<< <sburke@cpan.org> >>;
150 significant portions copied from
151 F<tkpod> in the Tk::Pod dist, by Nick Ing-Simmons, Slaven Rezic, et al.