line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: TFrame.pm,v 2.2 2007/12/06 20:09:39 eserte Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Tk::TFrame; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6609
|
use Tk; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use strict; |
7
|
|
|
|
|
|
|
use vars qw($VERSION @ISA); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Tk::Derived Tk::Frame); |
10
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 2.2 $ =~ /(\d+)\.(\d+)/); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Construct Tk::Widget "TFrame"; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub ClassInit { |
15
|
|
|
|
|
|
|
my ($class,$mw) = @_; |
16
|
|
|
|
|
|
|
$mw->bind($class,'',['layoutRequest']); |
17
|
|
|
|
|
|
|
$mw->bind($class,'', 'NoOp'); |
18
|
|
|
|
|
|
|
return $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub Populate { |
22
|
|
|
|
|
|
|
my($frame,$args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$frame->Tk::configure(-borderwidth => 0, -highlightthickness => 0); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $border = $frame->Component(Frame => "border"); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my @label = ( |
29
|
|
|
|
|
|
|
-padx => 4, |
30
|
|
|
|
|
|
|
-pady => 2, |
31
|
|
|
|
|
|
|
-borderwidth => 2, |
32
|
|
|
|
|
|
|
-relief => 'flat' |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if (exists $args->{'-label'}) { |
36
|
|
|
|
|
|
|
if (not ref $args->{'-label'}) { |
37
|
|
|
|
|
|
|
$args->{'-label'} = [ -text => $args->{'-label'} ]; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
push @label, @{$args->{'-label'}}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $label = $frame->Component(Label => "label",@label); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $container = $frame->Component(Frame => "container", -borderwidth => 0); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$frame->DoWhenIdle(['Manage',$frame]); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$frame->Default("container" => $container); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$frame->ConfigSpecs( |
52
|
|
|
|
|
|
|
-label => [ 'METHOD', undef, undef, undef], |
53
|
|
|
|
|
|
|
-relief => [$border,'relief','Relief','groove'], |
54
|
|
|
|
|
|
|
-borderwidth => [$border,'borderwidth','Borderwidth',2], |
55
|
|
|
|
|
|
|
-ipadx => [PASSIVE => undef, undef, 0], |
56
|
|
|
|
|
|
|
-ipady => [PASSIVE => undef, undef, 0], |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$frame; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub label { |
63
|
|
|
|
|
|
|
my $frame = shift; |
64
|
|
|
|
|
|
|
my $v = shift || []; |
65
|
|
|
|
|
|
|
my $l = $frame->Subwidget('label'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$l->configure(@$v); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub layoutRequest { |
71
|
|
|
|
|
|
|
my($f) = @_; |
72
|
|
|
|
|
|
|
$f->DoWhenIdle(['adjustLayout',$f]) unless $f->{'layout_pending'}; |
73
|
|
|
|
|
|
|
$f->{'layout_pending'} = 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub SlaveGeometryRequest { |
77
|
|
|
|
|
|
|
my ($m,$s) = @_; |
78
|
|
|
|
|
|
|
$m->DoWhenIdle(['_SlaveGeometryRequest',$m]) unless $m->{'geom_pending'}; |
79
|
|
|
|
|
|
|
$m->{'geom_pending'} = 1; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub Manage { |
83
|
|
|
|
|
|
|
my $f = shift; |
84
|
|
|
|
|
|
|
my $l = $f->Subwidget('label'); |
85
|
|
|
|
|
|
|
my $c = $f->Subwidget('container'); |
86
|
|
|
|
|
|
|
my $b = $f->Subwidget('border'); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$f->ManageGeometry($l); |
89
|
|
|
|
|
|
|
$l->MapWindow; |
90
|
|
|
|
|
|
|
$f->ManageGeometry($c); |
91
|
|
|
|
|
|
|
$c->MapWindow; |
92
|
|
|
|
|
|
|
$f->ManageGeometry($b); |
93
|
|
|
|
|
|
|
$b->MapWindow; |
94
|
|
|
|
|
|
|
SlaveGeometryRequest($f,$l); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _SlaveGeometryRequest { |
98
|
|
|
|
|
|
|
my $f = shift; |
99
|
|
|
|
|
|
|
my $l = $f->Subwidget('label'); |
100
|
|
|
|
|
|
|
my $c = $f->Subwidget('container'); |
101
|
|
|
|
|
|
|
my $b = $f->Subwidget('border'); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$f->{'geom_pending'} = 0; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $px = $f->{Configure}{'-ipadx'} || 0; |
106
|
|
|
|
|
|
|
my $py = $f->{Configure}{'-ipady'} || 0; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $bw = $b->cget('-borderwidth')*2; |
109
|
|
|
|
|
|
|
my $w = $c->ReqWidth + $bw + $px*2; |
110
|
|
|
|
|
|
|
my $w2 = $l->ReqWidth + 20 + $bw; |
111
|
|
|
|
|
|
|
my $h = $bw + $l->ReqHeight + $c->ReqHeight #+ $f->cget('-borderwidth')*2 |
112
|
|
|
|
|
|
|
+ $py*2; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$f->GeometryRequest($w > $w2 ? $w : $w2,$h); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub adjustLayout { |
118
|
|
|
|
|
|
|
my $frame = shift; |
119
|
|
|
|
|
|
|
my $label = $frame->Subwidget('label'); |
120
|
|
|
|
|
|
|
my $container = $frame->Subwidget('container'); |
121
|
|
|
|
|
|
|
my $border = $frame->Subwidget('border'); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$frame->{'layout_pending'} = 0; |
124
|
|
|
|
|
|
|
my $rh = $label->ReqHeight; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
my $px = $frame->{Configure}{'-ipadx'} || 0; |
127
|
|
|
|
|
|
|
my $bw = $frame->{Configure}{'-borderwidth'} || 0; |
128
|
|
|
|
|
|
|
my $py = $frame->{Configure}{'-ipady'} || 0; |
129
|
|
|
|
|
|
|
my $W = $frame->Width; |
130
|
|
|
|
|
|
|
my $H = $frame->Height; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
$border->MoveResizeWindow(0,int($rh/2),$W,$H-int($rh/2)); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$container->MoveResizeWindow( |
135
|
|
|
|
|
|
|
$px+$bw,$rh + $py, $W - (($px+$bw) * 2), $H - $rh -$bw - ($px * 2)); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$label->MoveResizeWindow(10,0,$label->ReqWidth,$label->ReqHeight); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub grid { |
141
|
|
|
|
|
|
|
my $w = shift; |
142
|
|
|
|
|
|
|
$w = $w->Subwidget('container') |
143
|
|
|
|
|
|
|
if (@_ && $_[0] =~ /^(?: bbox |
144
|
|
|
|
|
|
|
|columnconfigure |
145
|
|
|
|
|
|
|
|location |
146
|
|
|
|
|
|
|
|propagate |
147
|
|
|
|
|
|
|
|rowconfigure |
148
|
|
|
|
|
|
|
|size |
149
|
|
|
|
|
|
|
|slaves)$/x); |
150
|
|
|
|
|
|
|
$w->SUPER::grid(@_); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub slave { |
154
|
|
|
|
|
|
|
my $w = shift; |
155
|
|
|
|
|
|
|
$w->Subwidget('container'); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub pack { |
159
|
|
|
|
|
|
|
my $w = shift; |
160
|
|
|
|
|
|
|
$w = $w->Subwidget('container') |
161
|
|
|
|
|
|
|
if (@_ && $_[0] =~ /^(?:propagate|slaves)$/x); |
162
|
|
|
|
|
|
|
$w->SUPER::pack(@_); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
__END__ |