File Coverage

blib/lib/Tk/Wizard/Installer/Sizer.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1            
2             # $Id: Sizer.pm,v 1.11 2008/01/22 03:56:26 Daddy Exp $
3            
4             package Tk::Wizard::Installer::Sizer;
5            
6 1     1   2758 use strict;
  1         1  
  1         29  
7 1     1   5 use warnings;
  1         1  
  1         68  
8            
9             our
10             $VERSION = do { my @r = ( q$Revision: 1.11 $ =~ /\d+/g ); sprintf "%d." . "%03d" x $#r, @r };
11            
12             =head1 NAME
13            
14             Tk::Wizard::Installer::Sizer - Interactively determine the best size for your Wizard::Installer
15            
16             use Tk::Wizard::Installer::Sizer;
17             my $wizard = new Tk::Wizard::Installer::Sizer(
18             # Same arguments as Tk::Wizard::Installer
19             );
20             $wizard->Show;
21             MainLoop;
22            
23             =cut
24            
25 1     1   4 use Carp;
  1         2  
  1         45  
26 1     1   351 use Tk::Wizard::Installer;
  0            
  0            
27             use Tk::Wizard::Sizer;
28            
29             our @ISA = qw( Tk::Wizard::Installer Tk::Wizard::Sizer );
30            
31             =head1 DESCRIPTION
32            
33             A typical Wizard application utilizes a fixed-size window;
34             Tk::Wizard follows this philosophy by creating a window
35             without resize handles.
36             In addition, Tk::Wizard allows you to specify the size of the content area.
37             But there's a problem with this mechanism --
38             how do you know how large to make your window?
39             You know what you want to appear in the window,
40             and you know how you want it to be arranged,
41             but you do not know the dimensions of that combination of elements.
42            
43             Fret no more, dear programmer!
44             Simply replace your call to Tk::Wizard::Installer->new with
45             a call to Tk::Wizard::Installer::Sizer->new, and run your Wizard application.
46             On each page, adjust the size of the window for best aesthetics.
47             After you click the Next button on each page,
48             on STDOUT will be printed the ideal height and width arguments.
49             After you click the Finish button on the last page,
50             on STDOUT will be printed the ideal dimensions that will
51             contain all your pages
52             (i.e. the width of the widest page and the height of the tallest page).
53            
54             =head1 METHODS
55            
56             =head2 new
57            
58             Create a new Sizer wizard.
59            
60             =cut
61            
62             sub new
63             {
64             my $class = shift;
65             # This is NOT a clone mechanism:
66             return if ref($class);
67             # Our arguments are exactly the same as Tk::Wizard::Installer::new:
68             my $oWiz = $class->SUPER::new(@_);
69             # Make sure the window is resizable!
70             $oWiz->{Configure}{-resizable} = 1;
71             # Make sure the window does not auto-forward:
72             $oWiz->{Configure}{-wait} = 0;
73             # Add our size adder-upper:
74             $oWiz->configure(
75             -preNextButtonAction => sub { $oWiz->_prenext() },
76             -finishButtonAction => sub { $oWiz->_finish() },
77             );
78             $oWiz->{_max_width_} = -999;
79             $oWiz->{_max_height_} = -999;
80             return bless $oWiz, __PACKAGE__;
81             } # new
82            
83             1;
84            
85             __END__