Version 3 of MacWindowStyle

Updated 2005-07-15 01:54:40 by JH

There is a useful MacOS X command to create toplevel windows with a variety of appearances. It can be used in two different forms:

 ::tk::unsupported::MacWindowStyle style <win> <style>

or

 ::tk::unsupported::MacWindowStyle style <win> <class> <attribute list>

In the first form, <style> can be any of

  • documentProc
  • dBoxProc
  • plainDBox
  • altDBoxProc
  • movableDBoxProc
  • zoomDocProc
  • rDocProc
  • floatProc
  • floatZoomProc
  • floatSideProc
  • floatSideZoomProc

See the documentation "Carbon: Window Manager Legacy Reference: Pre-Appearance Window Definition IDs" [L1 ] for a description of each style. In my (very limited) experience, this list does not correspond exactly to the implementation. For example, rDocProc is not implemented, and floatGrowProc is implemented but not listed.

In the second form, <class> can be any of

  • alert
  • moveableAlert
  • modal
  • moveableModal
  • floating
  • help
  • document
  • toolbar

and <attribute list> should be

  • standardDocument
  • standardFloating
  • or some combination of closeBox, horizontalZoom, verticalZoom, collapseBox, resizable, or sideTitlebar.

See the documentation "Carbon: Window Manager Reference" for a description [L2 ] (see Window Constants and Window Attributes).

In exploring the use of this command, there are two important points of which you should be aware. Firstly, it is only possible to specify the window style when it is created; it cannot be altered. This means that to use the command interactively, it must be given in the same Tcl/Tk command as creates the window. For example:

 toplevel .t; ::tk::unsupported::MacWindowStyle style .t floatGrowProc

It is not usually necessary to do this in a script, so long as care is taken to make sure that no return to the event loop is possible in between. Secondly, not all combinations of attributes are supported for each window class. Unsuported combinations result in the shell being aborted. For example, do try:

 toplevel .t; ::tk::unsupported::MacWindowStyle style .t floating {closeBox resizable}

On the other hand, do not try:

 toplevel .t; ::tk::unsupported::MacWindowStyle style .t moveableAlert {closeBox resizable}

Thirdly, be aware the "movable" in the Apple API and documents is usually rendered "moveable" in the Tcl/Tk ones.

Alastair Davies - 2005/01/27


Category GUI