window.icn: Procedure for opening window

link window
October 10, 1997; Gregg M. Townsend
Requires: Version 9 graphics
This file is in the public domain.

Window() opens a window with provisions for option processing and
error handling.  The returned window is assigned to &window if
&window is null.  If the window cannot be opened, the program is
aborted.

The characteristics of the window are set from several sources:
Window's arguments, optionally including the program argument list;
user defaults; and built-in defaults.  These built-in defaults are
the same as for optwindow(): bg=pale gray, fg=black, size=500,300.
____________________________________________________________

With one exception, arguments to Window() are attribute specifications
such as those used with open() and WAttrib().  Order is significant,
with later attributes overriding earlier ones.

Additionally, the program argument list -- the single argument passed
to the main procedure -- can be passed as an argument to Window().
Options specified with a capital letter are removed from the list and
interpreted as attribute specifications, again in a manner consistent
with optwindow().

Because the Window() arguments are processed in order, attributes that
appear before the program arglist can be overridden by command-line
options when the program is executed.  If attributes appear after the
program arglist, they cannot be overridden.  For example, with

     procedure main(args)
     Window("size=600,400", "fg=yellow", args, "bg=black")

the program user can change the size and foreground color
but not the background color.

User defaults are applied at the point where the program arglist appears
(and before processing the arglist).  If no arglist is supplied, no
defaults are applied.  Defaults are obtained by calling WDefault().
Icon attribute names are used as option names;  &progname is used
as the program name after trimming directories and extensions.

The following table lists the options recognized in the program arglist,
the corresponding attribute (and WDefault()) names, the default values
if any, and the meanings.  All legal attributes are allowed in the
Window() call, but only these are set from the command line or
environment:

     arg     attribute       default         meaning
     ---     ---------       -------         --------------------------
     -B      bg              pale gray       background color
     -F      fg              black           foreground color
     -T      font             -              text font
     -L      label           &progname       window title
                             (trimmed)

     -D      display          -              window device
     -X      posx             -              horizontal position
     -Y      posy             -              vertical position
     -W      width           500             window width
     -H      height          300             window height

     -S      size            500,300         size
     -P      pos              -              position
     -G      geometry         -              window size and/or position

     -A      <any>            -              use "-A name=value"
                                             to set arbitrary attribute

     -!       -               -              write open() params to &error
                                             (for debugging)

Source code | Program Library Page | Icon Home Page