1Adjuster(3)           User Contributed Perl Documentation          Adjuster(3)
2
3
4

NAME

6       Tk::Adjuster - Allow size of packed widgets to be adjusted by user
7

SYNOPSIS

9       use Tk::Adjuster;
10
11       $adjuster = $widget->Adjuster(?options?);
12

WIDGET-SPECIFIC OPTIONS

14       Name: restore
15       Class: Restore
16       Switch: -restore
17           Specifies a boolean value that determines whether the Adjuster
18           should forcibly attempt to make room for itself (by reducing the
19           size of its managed widget) when it is unmapped (for example, due
20           to a size change in a top level window).  The default value is 1.
21
22       Name: side
23       Class: Side
24       Switch: -side
25           Specifies the side on which the managed widget lies relative to the
26           Adjuster. In conjunction with the pack geometry manager, this
27           relates to the side of the master against which the managed widget
28           and the Adjuster are packed.  Must be left, right, top, or bottom.
29           Defaults to top.
30
31       Name: widget
32       Class: Widget
33       Switch: -widget
34           Specifies the widget which is to be managed by the Adjuster.
35

DESCRIPTION

37       Tk::Adjuster is a Frame containing a "line" and a "blob".
38
39       Dragging with Mouse Button-1 results in a line being dragged to
40       indicate new size. Releasing Button-1 submits GeometryRequests on
41       behalf of the managed widget which will cause the packer to change the
42       widget's size.
43
44       If Drag is done with Shift button down, then GeometryRequests are made
45       in "real time" so that text-flow effects can be seen, but as a lot more
46       work is done behaviour may be sluggish.
47
48       If widget is packed with -side => left or -side => right then width is
49       adjusted. If packed -side => top or -side => bottom then height is
50       adjusted.
51
52       packPropagate is turned off for the master window to prevent adjustment
53       changing overall window size. Similarly packPropagate is turned off for
54       the managed widget if it has things packed inside it. This is so that
55       the GeometryRequests made by Tk::Adjuster are not overridden by pack.
56
57       In addition, the managed widget is made non-expandable to prevent the
58       geometry manager reallocating freed space in the master back to the
59       managed widget.  Note however that expansion is turned off only after
60       the Adjuster is mapped, which allows the managed widget to expand
61       naturally on window creation.
62
63       The Tk::Widget method, packAdjust, calls pack on the widget, then
64       creates an instance of Tk::Adjuster, and packs that "after" the widget.
65       Its use has two disadvantages however: the Adjuster widget is not made
66       available to the caller, and options cannot be set on the Adjuster. For
67       these reasons, the Tk::Adjuster method, packAfter is preferred, but
68       packAdjust is retained for backwards compatibility.
69

WIDGET METHODS

71       $adjuster->packAfter(managed_widget, ?pack_options?)
72           This command configures the Adjuster's -widget and -side options
73           respectively to managed_widget and the -side value specified in
74           pack_options (top if not specified). It then packs the Adjuster
75           after managed_widget, with -fill set to x or y as appropriate.
76
77       $adjuster->packForget?(boolean)?
78           This command calls Tk::Widget::packForget on the Adjuster.  If a
79           parameter is provided and it has a true boolean value, then
80           packForget is also called on the managed widget.
81
82       $adjuster->slave
83           This command returns the value $adjuster->cget('-widget'), ie. the
84           reference to the managed widget.
85

EXAMPLES

87       Using an Adjuster to separate two widgets, whereby the left widget is
88       managed, and right widget expands to fill space on a window resize
89
90       a) Using packAfter (preferred interface)
91
92         use Tk;
93         use Tk::Adjuster;
94
95         my $f = MainWindow->new;
96         my $lst1 = $f->Listbox();
97         my $adj1 = $f->Adjuster();
98         my $lst2 = $f->Listbox();
99
100         my $side = 'left';
101         $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
102         $adj1->packAfter($lst1, -side => $side);
103         $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
104         MainLoop;
105
106       b) Using packAdjust
107
108         use Tk;
109         use Tk::Adjuster;
110
111         my $f = MainWindow->new;
112         my $lst1 = $f->Listbox();
113         my $lst2 = $f->Listbox();
114
115         my $side = 'left';
116         $lst1->packAdjust(-side => $side, -fill => 'both');
117         $lst2->pack      (-side => $side, -fill => 'both', -expand => 1);
118         MainLoop;
119
120       c) Using the standard Tk::Widget::pack
121
122         use Tk;
123         use Tk::Adjuster;
124
125         my $f = MainWindow->new;
126         my $side = 'left';
127         my $lst1 = $f->Listbox();
128         my $adj  = $f->Adjuster(-widget => $lst1, -side => $side);
129         my $lst2 = $f->Listbox();
130
131         $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
132         $adj->pack (-side => $side, -fill => 'y');
133         $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
134
135         MainLoop;
136
137       Changing the above examples so that $side has the value 'right' means
138       the left widget expands to fill space on a window resize.
139
140       Changing the above examples so that $side has the value 'top' produces
141       a testcase with a horizontal Adjuster.  Here the bottom widget expands
142       to fill space on a window resize.  Packing to the 'bottom' makes the
143       top widget expand to fill space on window resize.
144
145       Using -restore => 0 for multiple columns
146
147       In the case of multiple columns (or rows) the "restore" functionality
148       of the Adjuster can be inconvenient. When the user adjusts the width of
149       one column and thereby pushes the Adjuster of another column off the
150       window, this adjuster tries to restore itself by reducing the size of
151       its managed widget.  This has the effect that column widths shrink; and
152       the original size is not restored when the user reverses the
153       originating change. The -restore option can be used to turn off this
154       functionality. (It makes some sense, however, to leave -restore turned
155       on for the first-packed Adjuster, so that at least one Adjuster always
156       remains visible.)
157
158         use Tk;
159         use Tk::Adjuster;
160         my $f = MainWindow->new;
161         my $lst1 = $f->Listbox();
162         my $adj1 = $f->Adjuster();
163         my $lst2 = $f->Listbox();
164         my $adj2 = $f->Adjuster(-restore => 0);
165         my $lst3 = $f->Listbox();
166
167         my $side = 'left';
168         $lst1->pack(-side => $side, -fill => 'both', -expand => 1);
169         $adj1->packAfter($lst1, -side => $side);
170         $lst2->pack(-side => $side, -fill => 'both', -expand => 1);
171         $adj2->packAfter($lst2, -side => $side);
172         $lst3->pack(-side => $side, -fill => 'both', -expand => 1);
173
174         MainLoop;
175

BUGS

177       It is currently not possible to configure the appearance of the
178       Adjuster.  It would be nice to be able to set the width and relief of
179       the Adjuster "line" and the presence/absence of the "blob" on the
180       Adjuster.
181
182       Tk::Adjuster works theoretically with the grid geometry manager but
183       there are currently some problems which seem to be due to bugs in grid:
184
185         a) There's never an Unmap event for the adjuster, so the "restore"
186            functionality has no effect.
187         b) After adjusting, widgets protrude into the border of the master.
188         c) grid('Propagate', 0) on MainWindow has no effect - window shrinks/grows
189            when widgets are adjusted.
190         d) Widgets shuffle to correct position on startup
191
192
193
194perl v5.30.1                      2020-01-30                       Adjuster(3)
Impressum