| 1 |
# Copyright (c) 1991-1994 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 3 |
# See the file "license.terms" for information on usage and redistribution |
| 4 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 5 |
# |
| 6 |
# |
| 7 |
|
| 8 |
=head1 NAME |
| 9 |
|
| 10 |
Tk::Wm - Communicate with window manager |
| 11 |
|
| 12 |
=for category Tk Geometry Management |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
S< >I<$toplevel>-E<gt>I<method>(?I<args>?) |
| 17 |
|
| 18 |
=head1 DESCRIPTION |
| 19 |
|
| 20 |
The B<wm> methods are used to interact with window managers in |
| 21 |
order to control such things as the title for a window, its geometry, |
| 22 |
or the increments in terms of which it may be resized. |
| 23 |
The B<wm> methods can take any of a number of different forms, depending on |
| 24 |
the particular I<method> argument. |
| 25 |
All of the forms expect I<$toplevel>, which must be a |
| 26 |
top-level window object. |
| 27 |
|
| 28 |
The legal forms for the B<wm> methods are: |
| 29 |
|
| 30 |
=over 4 |
| 31 |
|
| 32 |
=item I<$toplevel>-E<gt>B<aspect>(?I<minNumer minDenom maxNumer maxDenom>?) |
| 33 |
|
| 34 |
If I<minNumer>, I<minDenom>, I<maxNumer>, and I<maxDenom> |
| 35 |
are all specified, then they will be passed to the window manager |
| 36 |
and the window manager should use them to enforce a range of |
| 37 |
acceptable aspect ratios for I<$toplevel>. The aspect ratio of |
| 38 |
I<$toplevel> (width/length) will be constrained to lie |
| 39 |
between I<minNumer>/I<minDenom> and I<maxNumer>/I<maxDenom>. |
| 40 |
If I<minNumer> etc. are all specified as empty strings, then |
| 41 |
any existing aspect ratio restrictions are removed. |
| 42 |
If I<minNumer> etc. are specified, then the method returns an |
| 43 |
empty string. Otherwise, it returns |
| 44 |
a array containing four elements, which are the current values |
| 45 |
of I<minNumer>, I<minDenom>, I<maxNumer>, and I<maxDenom> |
| 46 |
(if no aspect restrictions are in effect, then an empty string is |
| 47 |
returned). |
| 48 |
|
| 49 |
=item I<$widget>-E<gt>B<attributes>( I<?args?> ); |
| 50 |
|
| 51 |
This subcommand returns or sets platform specific attributes |
| 52 |
associated with a window. |
| 53 |
|
| 54 |
=over 4 |
| 55 |
|
| 56 |
=item I<$widget>-E<gt>B<attributes>; |
| 57 |
|
| 58 |
Returns a list of the platform specific flags and their values. |
| 59 |
|
| 60 |
=item I<$widget>-E<gt>B<attributes>( I<?option?> ); |
| 61 |
|
| 62 |
Returns the value for the specific option. |
| 63 |
|
| 64 |
=item I<$widget>-E<gt>B<attributes>( I<?option value option value...?> ); |
| 65 |
|
| 66 |
Sets one or more of the values. The values are as follows: |
| 67 |
|
| 68 |
On Windows, B<-disabled> gets or sets whether the window is in a |
| 69 |
disabled state. B<-toolwindow> gets or sets the style of the window |
| 70 |
to toolwindow (as defined in the MSDN). B<-topmost> gets or sets |
| 71 |
whether this is a topmost window (displays above all other windows). |
| 72 |
|
| 73 |
On Macintosh, there are currently no special attribute values. |
| 74 |
|
| 75 |
On Unix, there are currently no special attribute values. |
| 76 |
|
| 77 |
=back |
| 78 |
|
| 79 |
=item I<$toplevel>-E<gt>B<client>(?I<name>?) |
| 80 |
|
| 81 |
If I<name> is specified, this method stores I<name> (which |
| 82 |
should be the name of |
| 83 |
the host on which the application is executing) in I<$toplevel>'s |
| 84 |
B<WM_CLIENT_MACHINE> property for use by the window manager or |
| 85 |
session manager. |
| 86 |
The method returns an empty string in this case. |
| 87 |
If I<name> isn't specified, the method returns the last name |
| 88 |
set in a B<client> method for I<$toplevel>. |
| 89 |
If I<name> is specified as an empty string, the method deletes the |
| 90 |
B<WM_CLIENT_MACHINE> property from I<$toplevel>. |
| 91 |
|
| 92 |
=item I<$toplevel>-E<gt>B<colormapwindows>(?I<windowList>?) |
| 93 |
|
| 94 |
This method is used to manipulate the B<WM_COLORMAP_WINDOWS> |
| 95 |
property, which provides information to the window managers about |
| 96 |
windows that have private colormaps. |
| 97 |
If I<windowList> isn't specified, the method returns a list |
| 98 |
whose elements are the names of the windows in the B<WM_COLORMAP_WINDOWS> |
| 99 |
property. |
| 100 |
If I<windowList> is specified, it consists of a list of widgets; |
| 101 |
the method overwrites the B<WM_COLORMAP_WINDOWS> |
| 102 |
property with the given windows and returns an empty string. |
| 103 |
The B<WM_COLORMAP_WINDOWS> property should normally contain a |
| 104 |
list of the internal windows within I<$toplevel> whose colormaps differ |
| 105 |
from their parents. |
| 106 |
The order of the windows in the property indicates a priority order: |
| 107 |
the window manager will attempt to install as many colormaps as possible |
| 108 |
from the head of this list when I<$widget> gets the colormap focus. |
| 109 |
If I<$widget> is not included among the windows in I<windowList>, |
| 110 |
Tk implicitly adds it at the end of the B<WM_COLORMAP_WINDOWS> |
| 111 |
property, so that its colormap is lowest in priority. |
| 112 |
If I<$widget>-E<gt>colormapwindows is not invoked, Tk will automatically set |
| 113 |
the property for each top-level window to all the internal windows |
| 114 |
whose colormaps differ from their parents, followed by the top-level |
| 115 |
itself; the order of the internal windows is undefined. |
| 116 |
See the ICCCM documentation for more information on the |
| 117 |
B<WM_COLORMAP_WINDOWS> property. |
| 118 |
|
| 119 |
=item I<$toplevel>-E<gt>B<command>(?I<value>?) |
| 120 |
|
| 121 |
If I<value> is specified, this method stores I<value> in I<$toplevel>'s |
| 122 |
B<WM_COMMAND> property for use by the window manager or |
| 123 |
session manager and returns an empty string. |
| 124 |
I<Value> must have proper list structure; the elements should |
| 125 |
contain the words of the command used to invoke the application. |
| 126 |
If I<value> isn't specified then the method returns the last value |
| 127 |
set in a B<command> method for I<$toplevel>. |
| 128 |
If I<value> is specified as an empty string, the method |
| 129 |
deletes the B<WM_COMMAND> property from I<$toplevel>. |
| 130 |
|
| 131 |
=item I<$toplevel>-E<gt>B<deiconify> |
| 132 |
|
| 133 |
Arrange for I<$toplevel> to be displayed in normal (non-iconified) form. |
| 134 |
This is done by mapping the window. If the window has never been |
| 135 |
mapped then this method will not map the window, but it will ensure |
| 136 |
that when the window is first mapped it will be displayed |
| 137 |
in de-iconified form. Returns an empty string. |
| 138 |
|
| 139 |
=item I<$toplevel>-E<gt>B<focusmodel>(?B<active>|B<passive>?) |
| 140 |
|
| 141 |
If B<active> or B<passive> is supplied as an optional argument |
| 142 |
to the method, then it specifies the focus model for I<$toplevel>. |
| 143 |
In this case the method returns an empty string. If no additional |
| 144 |
argument is supplied, then the method returns the current focus |
| 145 |
model for I<$toplevel>. |
| 146 |
An B<active> focus model means that I<$toplevel> will claim the |
| 147 |
input focus for itself or its descendants, even at times when |
| 148 |
the focus is currently in some other application. B<Passive> means that |
| 149 |
I<$toplevel> will never claim the focus for itself: the window manager |
| 150 |
should give the focus to I<$toplevel> at appropriate times. However, |
| 151 |
once the focus has been given to I<$toplevel> or one of its descendants, |
| 152 |
the application may re-assign the focus among I<$toplevel>'s descendants. |
| 153 |
The focus model defaults to B<passive>, and Tk's B<focus> method |
| 154 |
assumes a passive model of focusing. |
| 155 |
|
| 156 |
=item I<$toplevel>-E<gt>B<frame> |
| 157 |
|
| 158 |
If I<$widget> has been reparented by the window manager into a |
| 159 |
decorative frame, the method returns the platform specific window |
| 160 |
identifier for the outermost frame that contains I<$toplevel> (the |
| 161 |
window whose parent is the root or virtual root). If I<$toplevel> |
| 162 |
hasn't been reparented by the window manager then the method returns |
| 163 |
the platform specific window identifier for I<$toplevel>. |
| 164 |
|
| 165 |
=item I<$toplevel>-E<gt>B<geometry>(?I<newGeometry>?) |
| 166 |
|
| 167 |
If I<newGeometry> is specified, then the geometry of I<$toplevel> |
| 168 |
is changed and an empty string is returned. Otherwise the current |
| 169 |
geometry for I<$toplevel> is returned (this is the most recent |
| 170 |
geometry specified either by manual resizing or |
| 171 |
in a B<geometry> method). I<NewGeometry> has |
| 172 |
the form B<=>I<width>B<x>I<height>B<+->I<x>B<+->I<y>, where |
| 173 |
any of B<=>, I<width>B<x>I<height>, or B<+->I<x>B<+->I<y> |
| 174 |
may be omitted. I<Width> and I<height> are positive integers |
| 175 |
specifying the desired dimensions of I<$toplevel>. If I<$toplevel> |
| 176 |
is gridded (see L<"GRIDDED GEOMETRY MANAGEMENT"> below) then the dimensions |
| 177 |
are specified in grid units; otherwise they are specified in pixel |
| 178 |
units. I<X> and I<y> specify the desired location of |
| 179 |
I<$toplevel> on the screen, in pixels. |
| 180 |
If I<x> is preceded by B<+>, it specifies |
| 181 |
the number of pixels between the left edge of the screen and the left |
| 182 |
edge of I<$toplevel>'s border; if preceded by B<-> then |
| 183 |
I<x> specifies the number of pixels |
| 184 |
between the right edge of the screen and the right edge of I<$toplevel>'s |
| 185 |
border. If I<y> is preceded by B<+> then it specifies the |
| 186 |
number of pixels between the top of the screen and the top |
| 187 |
of I<$toplevel>'s border; if I<y> is preceded by B<-> then |
| 188 |
it specifies the number of pixels between the bottom of I<$toplevel>'s |
| 189 |
border and the bottom of the screen. |
| 190 |
If I<newGeometry> is specified as an empty string then any |
| 191 |
existing user-specified geometry for I<$toplevel> is cancelled, and |
| 192 |
the window will revert to the size requested internally by its |
| 193 |
widgets. |
| 194 |
|
| 195 |
=item I<$toplevel>-E<gt>B<wmGrid>(?I<baseWidth,baseHeight,widthInc,heightInc>?) |
| 196 |
|
| 197 |
This method indicates that I<$toplevel> is to be managed as a |
| 198 |
gridded window. |
| 199 |
It also specifies the relationship between grid units and pixel units. |
| 200 |
I<BaseWidth> and I<baseHeight> specify the number of grid |
| 201 |
units corresponding to the pixel dimensions requested internally |
| 202 |
by I<$toplevel> using B<Tk_GeometryRequest>. I<WidthInc> |
| 203 |
and I<heightInc> specify the number of pixels in each horizontal |
| 204 |
and vertical grid unit. |
| 205 |
These four values determine a range of acceptable sizes for |
| 206 |
I<$toplevel>, corresponding to grid-based widths and heights |
| 207 |
that are non-negative integers. |
| 208 |
Tk will pass this information to the window manager; during |
| 209 |
manual resizing, the window manager will restrict the window's size |
| 210 |
to one of these acceptable sizes. |
| 211 |
Furthermore, during manual resizing the window manager will display |
| 212 |
the window's current size in terms of grid units rather than pixels. |
| 213 |
If I<baseWidth> etc. are all specified as empty strings, then |
| 214 |
I<$toplevel> will no longer be managed as a gridded window. If |
| 215 |
I<baseWidth> etc. are specified then the return value is an |
| 216 |
empty string. |
| 217 |
Otherwise the return value is a array containing |
| 218 |
four elements corresponding to the current I<baseWidth>, |
| 219 |
I<baseHeight>, I<widthInc>, and I<heightInc>; if |
| 220 |
I<$toplevel> is not currently gridded, then an empty string |
| 221 |
is returned. |
| 222 |
Note: this command should not be needed very often, since the |
| 223 |
B<Tk_SetGrid> library procedure and the B<-setgrid> option |
| 224 |
provide easier access to the same functionality. |
| 225 |
|
| 226 |
=item I<$toplevel>-E<gt>B<group>(?I<$widget>?) |
| 227 |
|
| 228 |
If I<$widget> is specified, it is the the leader of |
| 229 |
a group of related windows. The window manager may use this information, |
| 230 |
for example, to unmap all of the windows in a group when the group's |
| 231 |
leader is iconified. I<$widget> may be specified as an empty string to |
| 232 |
remove I<$toplevel> from any group association. If I<$widget> is |
| 233 |
specified then the method returns an empty string; otherwise it |
| 234 |
returns the I<$toplevel>'s current group leader, or an empty |
| 235 |
string if I<$toplevel> isn't part of any group. |
| 236 |
|
| 237 |
=item I<$toplevel>-E<gt>B<iconbitmap>(?I<bitmap>?) |
| 238 |
|
| 239 |
If I<bitmap> is specified, then it names a bitmap in the standard |
| 240 |
forms accepted by Tk (see the B<Tk_GetBitmap> documentation for details). |
| 241 |
This I<black and white> bitmap is passed to the window manager to be displayed |
| 242 |
in I<$toplevel>'s icon, and the method returns an empty string. If |
| 243 |
an empty string is specified for I<bitmap>, then any current icon |
| 244 |
bitmap or image is cancelled for I<$toplevel>. |
| 245 |
If I<bitmap> is specified then the method returns an empty string. |
| 246 |
Otherwise it returns the name of |
| 247 |
the current icon bitmap associated with I<$toplevel>, or an empty |
| 248 |
string if I<$toplevel> has no icon bitmap. |
| 249 |
|
| 250 |
=item I<$toplevel>-E<gt>B<iconify> |
| 251 |
|
| 252 |
Arrange for I<$toplevel> to be iconified. It I<$toplevel> hasn't |
| 253 |
yet been mapped for the first time, this method will arrange for |
| 254 |
it to appear in the iconified state when it is eventually mapped. |
| 255 |
|
| 256 |
=item I<$toplevel>-E<gt>B<iconimage>(?I<image>?) |
| 257 |
|
| 258 |
If I<image> is specified, then it names a normal Tk image. |
| 259 |
This image is rendered into a private I<coloured> bitmap which is passed to |
| 260 |
the window manager to be displayed in I<$toplevel>'s icon, and the method returns |
| 261 |
an empty string. If an empty string is specified for I<image>, then any current |
| 262 |
icon bitmap or image is cancelled for I<$toplevel>. |
| 263 |
If I<image> is specified then the method returns an empty string. |
| 264 |
Otherwise it returns the name of |
| 265 |
the current icon image associated with I<$toplevel>, or an empty |
| 266 |
string if I<$toplevel> has no icon image. |
| 267 |
The private pixmap is not pre-cleared so images which are partly "transparent" |
| 268 |
display rubbish in their transparent parts. |
| 269 |
|
| 270 |
The sizes of images that can be used as icons in this manner are platform |
| •271 |
dependent. On Win32 this sets the "large" icon, which should be 32x32, it |
| 272 |
will automatically be scaled down to 16x16 for use as a small icon. |
| 273 |
|
| 274 |
=item I<$toplevel>-E<gt>B<iconmask>(?I<bitmap>?) |
| 275 |
|
| 276 |
If I<bitmap> is specified, then it names a bitmap in the standard |
| 277 |
forms accepted by Tk (see the B<Tk_GetBitmap> documentation for details). |
| 278 |
This bitmap is passed to the window manager to be used as a mask |
| 279 |
in conjunction with the B<iconbitmap> option: where the mask |
| 280 |
has zeroes no icon will be displayed; where it has ones, the bits |
| 281 |
from the icon bitmap will be displayed. If |
| 282 |
an empty string is specified for I<bitmap> then any current icon |
| 283 |
mask is cancelled for I<$toplevel> (this is equivalent to specifying |
| 284 |
a bitmap of all ones). If I<bitmap> is specified |
| 285 |
then the method returns an empty string. Otherwise it |
| 286 |
returns the name of the current icon mask associated with |
| 287 |
I<$toplevel>, or an empty string if no mask is in effect. |
| 288 |
|
| 289 |
=item I<$toplevel>-E<gt>B<iconname>(?I<newName>?) |
| 290 |
|
| 291 |
If I<newName> is specified, then it is passed to the window |
| 292 |
manager; the window manager should display I<newName> inside |
| 293 |
the icon associated with I<$toplevel>. In this case an empty |
| 294 |
string is returned as result. If I<newName> isn't specified |
| 295 |
then the method returns the current icon name for I<$toplevel>, |
| 296 |
or an empty string if no icon name has been specified (in this |
| 297 |
case the window manager will normally display the window's title, |
| 298 |
as specified with the B<title> method). |
| 299 |
|
| 300 |
=item I<$toplevel>-E<gt>B<iconphoto>(?-default? I<image1> ?I<image2> |
| 301 |
...?) |
| 302 |
|
| 303 |
Sets the titlebar icon for window based on the named photo |
| 304 |
images. If -default is specified, this is applied to all future |
| 305 |
created toplevels as well. The data in the images is taken as a |
| 306 |
snapshot at the time of invocation. If the images are later |
| 307 |
changed, this is not reflected to the titlebar icons. Multiple |
| 308 |
images are accepted to allow different images sizes (eg, 16x16 |
| 309 |
and 32x32) to be provided. The window manager may scale pro- |
| 310 |
vided icons to an appropriate size. |
| 311 |
|
| 312 |
On Windows, the images are packed into a Windows icon structure. |
| 313 |
This will override an ico specified to wm iconbitmap, and vice |
| 314 |
versa. [NOTE: This is not implemented yet!] |
| 315 |
|
| 316 |
On X, the images are arranged into the _NET_WM_ICON X property, |
| 317 |
which most modern window managers support. A wm iconbitmap may |
| 318 |
exist simultaneously. It is recommended to use not more than 2 |
| 319 |
icons, placing the larger icon first. |
| 320 |
|
| 321 |
On Macintosh, this is currently does nothing. |
| 322 |
|
| 323 |
=item I<$toplevel>-E<gt>B<iconposition>(?I<x y>?) |
| 324 |
|
| 325 |
If I<x> and I<y> are specified, they are passed to the window |
| 326 |
manager as a hint about where to position the icon for I<$toplevel>. |
| 327 |
In this case an empty string is returned. If I<x> and I<y> are |
| 328 |
specified as empty strings then any existing icon position hint is cancelled. |
| 329 |
If neither I<x> nor I<y> is specified, then the method returns |
| 330 |
a array containing two values, which are the current icon position |
| 331 |
hints (if no hints are in effect then an empty string is returned). |
| 332 |
|
| 333 |
=item I<$toplevel>-E<gt>B<iconwindow>(?I<$widget>?) |
| 334 |
|
| 335 |
If I<$widget> is specified, it is a window to |
| 336 |
use as icon for I<$toplevel>: when I<$toplevel> is iconified then |
| 337 |
I<$widget> will be mapped to serve as icon, and when I<$toplevel> |
| 338 |
is de-iconified then I<$widget> will be unmapped again. If |
| 339 |
I<$widget> is specified as an empty string then any existing |
| 340 |
icon window association for I<$toplevel> will be cancelled. If |
| 341 |
the I<$widget> argument is specified then an empty string is |
| 342 |
returned. Otherwise the method returns the |
| 343 |
current icon window for I<$toplevel>, or an empty string if there |
| 344 |
is no icon window currently specified for I<$toplevel>. |
| 345 |
Button press events are disabled for I<$toplevel> as long as it is |
| 346 |
an icon window; this is needed in order to allow window managers |
| 347 |
to ``own'' those events. |
| 348 |
Note: not all window managers support the notion of an icon window. |
| 349 |
|
| 350 |
=item I<$toplevel>-E<gt>B<maxsize>(?I<width,height>?) |
| 351 |
|
| 352 |
If I<width> and I<height> are specified, they give |
| 353 |
the maximum permissible dimensions for I<$toplevel>. |
| 354 |
For gridded windows the dimensions are specified in |
| 355 |
grid units; otherwise they are specified in pixel units. |
| 356 |
The window manager will restrict the window's dimensions to be |
| 357 |
less than or equal to I<width> and I<height>. |
| 358 |
If I<width> and I<height> are |
| 359 |
specified, then the method returns an empty string. Otherwise |
| 360 |
it returns a array with two elements, which are the |
| 361 |
maximum width and height currently in effect. |
| 362 |
The maximum size defaults to the size of the screen. |
| 363 |
If resizing has been disabled with the B<resizable> method, |
| 364 |
then this method has no effect. |
| 365 |
See the sections on geometry management below for more information. |
| 366 |
|
| 367 |
=item I<$toplevel>-E<gt>B<minsize>(?I<width,height>?) |
| 368 |
|
| 369 |
If I<width> and I<height> are specified, they give the |
| 370 |
minimum permissible dimensions for I<$toplevel>. |
| 371 |
For gridded windows the dimensions are specified in |
| 372 |
grid units; otherwise they are specified in pixel units. |
| 373 |
The window manager will restrict the window's dimensions to be |
| 374 |
greater than or equal to I<width> and I<height>. |
| 375 |
If I<width> and I<height> are |
| 376 |
specified, then the method returns an empty string. Otherwise |
| 377 |
it returns a array with two elements, which are the |
| 378 |
minimum width and height currently in effect. |
| 379 |
The minimum size defaults to one pixel in each dimension. |
| 380 |
If resizing has been disabled with the B<resizable> method, |
| 381 |
then this method has no effect. |
| 382 |
See the sections on geometry management below for more information. |
| 383 |
|
| 384 |
=item I<$toplevel>-E<gt>B<overrideredirect(?>I<boolean>?) |
| 385 |
|
| 386 |
If I<boolean> is specified, it must have a proper boolean form and |
| 387 |
the override-redirect flag for I<$toplevel> is set to that value. |
| 388 |
If I<boolean> is not specified then B<1> or B<0> is |
| 389 |
returned to indicate whether or not the override-redirect flag |
| 390 |
is currently set for I<$toplevel>. |
| 391 |
Setting the override-redirect flag for a window causes |
| 392 |
it to be ignored by the window manager; among other things, this means |
| 393 |
that the window will not be reparented from the root window into a |
| 394 |
decorative frame and the user will not be able to manipulate the |
| 395 |
window using the normal window manager mechanisms. |
| 396 |
|
| 397 |
=item I<$toplevel>-E<gt>B<positionfrom>(?I<who>?) |
| 398 |
|
| 399 |
If I<who> is specified, it must be either B<program> or |
| 400 |
B<user>, or an abbreviation of one of these two. It indicates |
| 401 |
whether I<$toplevel>'s current position was requested by the |
| 402 |
program or by the user. Many window managers ignore program-requested |
| 403 |
initial positions and ask the user to manually position the window; if |
| 404 |
B<user> is specified then the window manager should position the |
| 405 |
window at the given place without asking the user for assistance. |
| 406 |
If I<who> is specified as an empty string, then the current position |
| 407 |
source is cancelled. |
| 408 |
If I<who> is specified, then the method returns an empty string. |
| 409 |
Otherwise it returns B<user> or $widget to indicate the |
| 410 |
source of the window's current position, or an empty string if |
| 411 |
no source has been specified yet. Most window managers interpret |
| 412 |
``no source'' as equivalent to B<program>. |
| 413 |
Tk will automatically set the position source to B<user> |
| 414 |
when a B<geometry> method is invoked, unless the source has |
| 415 |
been set explicitly to B<program>. |
| 416 |
|
| 417 |
=item I<$toplevel>-E<gt>B<protocol>(?I<name>?,?I<callback>?) |
| 418 |
|
| 419 |
This method is used to manage window manager protocols such as |
| 420 |
B<WM_DELETE_WINDOW>. |
| 421 |
I<Name> is the name of an atom corresponding to a window manager |
| 422 |
protocol, such as B<WM_DELETE_WINDOW> or B<WM_SAVE_YOURSELF> |
| 423 |
or B<WM_TAKE_FOCUS>. |
| 424 |
If both I<name> and I<callback> are specified, then I<callback> |
| 425 |
is associated with the protocol specified by I<name>. |
| 426 |
I<Name> will be added to I<$toplevel>'s B<WM_PROTOCOLS> |
| 427 |
property to tell the window manager that the application has a |
| 428 |
protocol handler for I<name>, and I<callback> will |
| 429 |
be invoked in the future whenever the window manager sends a |
| 430 |
message to the client for that protocol. |
| 431 |
In this case the method returns an empty string. |
| 432 |
If I<name> is specified but I<callback> isn't, then the current |
| 433 |
callback for I<name> is returned, or an empty string if there |
| 434 |
is no handler defined for I<name>. |
| 435 |
If I<callback> is specified as an empty string then the current |
| 436 |
handler for I<name> is deleted and it is removed from the |
| 437 |
B<WM_PROTOCOLS> property on I<$toplevel>; an empty string is |
| 438 |
returned. |
| 439 |
Lastly, if neither I<name> nor I<callback> is specified, the |
| 440 |
method returns a list of all the protocols for which handlers |
| 441 |
are currently defined for I<$toplevel>. |
| 442 |
|
| 443 |
=over 8 |
| 444 |
|
| 445 |
Tk always defines a protocol handler for B<WM_DELETE_WINDOW>, even if |
| 446 |
you haven't asked for one with B<protocol>. |
| 447 |
If a B<WM_DELETE_WINDOW> message arrives when you haven't defined |
| 448 |
a handler, then Tk handles the message by destroying the window for |
| 449 |
which it was received. |
| 450 |
|
| 451 |
=back |
| 452 |
|
| 453 |
=item I<$toplevel>-E<gt>B<resizable>(?I<width,height>?) |
| 454 |
|
| 455 |
This method controls whether or not the user may interactively |
| 456 |
resize a top-level window. If I<width> and I<height> are |
| 457 |
specified, they are boolean values that determine whether the |
| 458 |
width and height of I<$toplevel> may be modified by the user. |
| 459 |
In this case the method returns an empty string. |
| 460 |
If I<width> and I<height> are omitted then the method |
| 461 |
returns a list with two 0/1 elements that indicate whether the |
| 462 |
width and height of I<$toplevel> are currently resizable. |
| 463 |
By default, windows are resizable in both dimensions. |
| 464 |
If resizing is disabled, then the window's size will be the size |
| 465 |
from the most recent interactive resize or B<geometry> |
| 466 |
method. If there has been no such operation then |
| 467 |
the window's natural size will be used. |
| 468 |
|
| 469 |
=item I<$toplevel>-E<gt>B<sizefrom>(?I<who>?) |
| 470 |
|
| 471 |
If I<who> is specified, it must be either B<program> or |
| 472 |
B<user>, or an abbreviation of one of these two. It indicates |
| 473 |
whether I<$toplevel>'s current size was requested by the |
| 474 |
program or by the user. Some window managers ignore program-requested |
| 475 |
sizes and ask the user to manually size the window; if |
| 476 |
B<user> is specified then the window manager should give the |
| 477 |
window its specified size without asking the user for assistance. |
| 478 |
If I<who> is specified as an empty string, then the current size |
| 479 |
source is cancelled. |
| 480 |
If I<who> is specified, then the method returns an empty string. |
| 481 |
Otherwise it returns B<user> or $widget to indicate the |
| 482 |
source of the window's current size, or an empty string if |
| 483 |
no source has been specified yet. Most window managers interpret |
| 484 |
``no source'' as equivalent to B<program>. |
| 485 |
|
| 486 |
=item I<$toplevel>-E<gt>B<stackorder>( I<?isabove|isbelow $toplevel?> ); |
| 487 |
|
| 488 |
The stackorder command returns a list of toplevel windows in |
| 489 |
stacking order, from lowest to highest. When a single toplevel |
| 490 |
window is passed, the returned list recursively includes all of |
| 491 |
the window's children that are toplevels. Only those toplevels |
| 492 |
that are currently mapped to the screen are returned. The |
| 493 |
stackorder command can also be used to determine if one toplevel |
| 494 |
is positioned above or below a second toplevel. When two window |
| 495 |
arguments separated by either isabove or isbelow are passed, a |
| 496 |
boolean result indicates whether or not the first window is |
| 497 |
currently above or below the second window in the stacking order. |
| 498 |
|
| 499 |
|
| 500 |
=item I<$toplevel>-E<gt>B<state>(?I<newstate>?) |
| 501 |
|
| 502 |
If I<newstate> is specified, the window will be set to |
| 503 |
the new state, otherwise it returns the current state of |
| 504 |
I<$toplevel>: either B<normal>, B<iconic>, B<withdrawn>, B<icon>, or |
| 505 |
(Windows only) B<zoomed>. The |
| 506 |
difference between B<iconic> and B<icon> is that B<iconic> refers to a |
| 507 |
window that has been iconified (e.g., with the B<iconify> method) |
| 508 |
while B<icon> refers to a window whose only purpose is to serve as the |
| 509 |
icon for some other window (via the B<iconwindow> method). The |
| 510 |
B<icon> state cannot be set. |
| 511 |
|
| 512 |
|
| 513 |
=item I<$toplevel>-E<gt>B<title>(?I<string>?) |
| 514 |
|
| 515 |
If I<string> is specified, then it will be passed to the window |
| 516 |
manager for use as the title for I<$toplevel> (the window manager |
| 517 |
should display this string in I<$toplevel>'s title bar). In this |
| 518 |
case the method returns an empty string. If I<string> isn't |
| 519 |
specified then the method returns the current title for the |
| 520 |
I<$toplevel>. The title for a window defaults to its name. |
| 521 |
|
| 522 |
=item I<$toplevel>-E<gt>B<transient>(?I<master>?) |
| 523 |
|
| 524 |
If I<master> is specified, then the window manager is informed |
| 525 |
that I<$toplevel> is a transient window (e.g. pull-down menu) working |
| 526 |
on behalf of I<master> (where I<master> is |
| 527 |
a top-level window). Some window managers will use |
| 528 |
this information to manage I<$toplevel> specially. If I<master> |
| 529 |
is specified as an empty string then I<$toplevel> is marked as not |
| 530 |
being a transient window any more. If I<master> is specified, |
| 531 |
then the method returns an empty string. Otherwise the method |
| 532 |
returns the path name of I<$toplevel>'s current master, or an |
| 533 |
empty string if I<$toplevel> isn't currently a transient window. |
| 534 |
|
| 535 |
=item I<$toplevel>-E<gt>B<withdraw> |
| 536 |
|
| 537 |
Arranges for I<$toplevel> to be withdrawn from the screen. This |
| 538 |
causes the window to be unmapped and forgotten about by the window |
| 539 |
manager. If the window |
| 540 |
has never been mapped, then this method |
| 541 |
causes the window to be mapped in the withdrawn state. Not all |
| 542 |
window managers appear to know how to handle windows that are |
| 543 |
mapped in the withdrawn state. |
| 544 |
Note: it sometimes seems to be necessary to withdraw a |
| 545 |
window and then re-map it (e.g. with B<deiconify>) to get some |
| 546 |
window managers to pay attention to changes in window attributes |
| 547 |
such as group. |
| 548 |
|
| 549 |
=item I<$toplevel>-E<gt>B<wrapper> |
| 550 |
|
| 551 |
Returns a list of two elements: the window id of the wrapper window in |
| 552 |
which Tk has placed I<$toplevel>, and the height of the menu bar. The |
| 553 |
id is the one by which window manager will know I<$toplevel>, and so |
| 554 |
is appropriate place to add X properties. The menu height is only |
| 555 |
returned on X. On Windows, this value is always zero. |
| 556 |
|
| 557 |
=back |
| 558 |
|
| 559 |
=head1 ICON SIZES |
| 560 |
|
| 561 |
The sizes of bitmaps/images that can be used as icons in this manner are platform |
| •562 |
and window manager dependent. Unix window managers are typically more tolerant |
| 563 |
than Win32. It is possible that coloured C<iconimage> icons may cause problems |
| 564 |
on some X window managers. |
| 565 |
|
| 566 |
=over 4 |
| 567 |
|
| 568 |
=item * Win32 |
| 569 |
|
| 570 |
C<iconimage> and C<iconbitmap> set the "large" icon, which should be |
| 571 |
32x32, it will automatically be scaled down to 16x16 for use as a small icon. |
| 572 |
Win32 ignores C<iconwin> requests. |
| 573 |
|
| 574 |
=item * KDE's "kwm" |
| 575 |
|
| 576 |
Accepts coloured C<iconimage> and black and white C<iconbitmap> but |
| 577 |
will scale either to a small (14x14?) icon. Kwm ignores C<iconwin>. |
| 578 |
|
| 579 |
=item * Sun's "olwm" or "olvwm" |
| 580 |
|
| 581 |
Honours C<iconwin> which will override C<iconimage> or C<iconbitmap>. |
| 582 |
Coloured images work. |
| 583 |
|
| 584 |
=item * Sun's CDE window manager |
| 585 |
|
| 586 |
Coloured images work. ... |
| 587 |
|
| 588 |
=back |
| 589 |
|
| 590 |
=head1 GEOMETRY MANAGEMENT |
| 591 |
|
| 592 |
By default a top-level window appears on the screen in its |
| 593 |
I<natural size>, which is the one determined internally by its |
| 594 |
widgets and geometry managers. |
| 595 |
If the natural size of a top-level window changes, then the window's size |
| 596 |
changes to match. |
| 597 |
A top-level window can be given a size other than its natural size in two ways. |
| 598 |
First, the user can resize the window manually using the facilities |
| 599 |
of the window manager, such as resize handles. |
| 600 |
Second, the application can request a particular size for a |
| 601 |
top-level window using the B<geometry> method. |
| 602 |
These two cases are handled identically by Tk; in either case, |
| 603 |
the requested size overrides the natural size. |
| 604 |
You can return the window to its natural by invoking B<geometry> |
| 605 |
with an empty I<geometry> string. |
| 606 |
|
| 607 |
Normally a top-level window can have any size from one pixel in each |
| 608 |
dimension up to the size of its screen. |
| 609 |
However, you can use the B<minsize> and B<maxsize> methods |
| 610 |
to limit the range of allowable sizes. |
| 611 |
The range set by B<minsize> and B<maxsize> applies to |
| 612 |
all forms of resizing, including the window's natural size as |
| 613 |
well as manual resizes and the B<geometry> method. |
| 614 |
You can also use the method B<resizable> to completely |
| 615 |
disable interactive resizing in one or both dimensions. |
| 616 |
|
| 617 |
=head1 GRIDDED GEOMETRY MANAGEMENT |
| 618 |
|
| 619 |
Gridded geometry management occurs when one of the widgets of an |
| 620 |
application supports a range of useful sizes. |
| 621 |
This occurs, for example, in a text editor where the scrollbars, |
| 622 |
menus, and other adornments are fixed in size but the edit widget |
| 623 |
can support any number of lines of text or characters per line. |
| 624 |
In this case, it is usually desirable to let the user specify the |
| 625 |
number of lines or characters-per-line, either with the |
| 626 |
B<geometry> method or by interactively resizing the window. |
| 627 |
In the case of text, and in other interesting cases also, only |
| 628 |
discrete sizes of the window make sense, such as integral numbers |
| 629 |
of lines and characters-per-line; arbitrary pixel sizes are not useful. |
| 630 |
|
| 631 |
Gridded geometry management provides support for this kind of |
| 632 |
application. |
| 633 |
Tk (and the window manager) assume that there is a grid of some |
| 634 |
sort within the application and that the application should be |
| 635 |
resized in terms of I<grid units> rather than pixels. |
| 636 |
Gridded geometry management is typically invoked by turning on |
| 637 |
the B<setGrid> option for a widget; it can also be invoked |
| 638 |
with the B<wmGrid> method or by calling B<Tk_SetGrid>. |
| 639 |
In each of these approaches the particular widget (or sometimes |
| 640 |
code in the application as a whole) specifies the relationship between |
| 641 |
integral grid sizes for the window and pixel sizes. |
| 642 |
To return to non-gridded geometry management, invoke |
| 643 |
B<grid> with empty argument strings. |
| 644 |
|
| 645 |
When gridded geometry management is enabled then all the dimensions specified |
| 646 |
in B<minsize>, B<maxsize>, and B<geometry> methods |
| 647 |
are treated as grid units rather than pixel units. |
| 648 |
Interactive resizing is also carried out in even numbers of grid units |
| 649 |
rather than pixels. |
| 650 |
|
| 651 |
=head1 BUGS |
| 652 |
|
| 653 |
Most existing window managers appear to have bugs that affect the |
| 654 |
operation of the B<wm> methods. For example, some changes won't |
| 655 |
take effect if the window is already active: the window will have |
| 656 |
to be withdrawn and de-iconified in order to make the change happen. |
| 657 |
|
| 658 |
=head1 SEE ALSO |
| 659 |
|
| 660 |
L<Tk::Widget|Tk::Widget> |
| 661 |
L<Tk::tixWm|Tk::tixWm> |
| 662 |
L<Tk::Mwm|Tk::Mwm> |
| 663 |
|
| 664 |
=head1 KEYWORDS |
| 665 |
|
| 666 |
aspect ratio, deiconify, focus model, geometry, grid, group, icon, iconify, increments, position, size, title, top-level window, units, window manager |
| 667 |
|
| 668 |
=cut |
| 669 |
|