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