#  Copyright (c) 1990-1994 The Regents of the University of California.
#  Copyright (c) 1994-1996 Sun Microsystems, Inc.
#  See the file "license.terms" for information on usage and redistribution
#  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#

=head1 NAME

Tk_ConfigureWidget, Tk_Offset, Tk_ConfigureInfo, Tk_ConfigureValue, Tk_FreeOptions - process configuration options for widgets

=for category C Programming

=head1 SYNOPSIS

B<#include E<lt>tk.hE<gt>>

int
B<Tk_ConfigureWidget(>I<interp, tkwin, specs, argc, argv, widgRec, flags>B<)>

int
B<Tk_Offset(>I<type, field>B<)>

int
B<Tk_ConfigureInfo(>I<interp, tkwin, specs, widgRec, argvName, flags>B<)>

int

B<Tk_FreeOptions(>I<specs, widgRec, display, flags>B<)>

=head1 ARGUMENTS

=over 4

=item Tcl_Interp *interp (in)

Interpreter to use for returning error messages.

=item Tk_Window tkwin (in)

Window used to represent widget (needed to set up X resources).

=item Tk_ConfigSpec *specs (in)

Pointer to table specifying legal configuration options for this
widget.

=item int argc (in)

Number of arguments in I<argv>.

=item char **argv (in)

Command-line options for configuring widget.

=item char *widgRec (in/out)

Points to widget record structure.  Fields in this structure get
modified by B<Tk_ConfigureWidget> to hold configuration information.

=item int flags (in)

If non-zero, then it specifies an OR-ed combination of flags that
control the processing of configuration information.
TK_CONFIG_ARGV_ONLY causes the option database and defaults to be
ignored, and flag bits TK_CONFIG_USER_BIT and higher are used to
selectively disable entries in I<specs>.

=item "type name" type (in)

The name of the type of a widget record.

=item "field name" field (in)

The name of a field in records of type I<type>.

=item char *argvName (in)

The name used on Tcl command lines to refer to a particular option
(e.g. when creating a widget or invoking the B<configure> widget
command).  If non-NULL, then information is returned only for this
option.  If NULL, then information is returned for all available
options.

=item Display *display (in)

Display containing widget whose record is being freed;  needed in
order to free up resources.

=back

=head1 DESCRIPTION

B<Tk_ConfigureWidget> is called to configure various aspects of a
widget, such as colors, fonts, border width, etc.
It is intended as a convenience procedure to reduce the amount
of code that must be written in individual widget managers to
handle configuration information.
It is typically
invoked when widgets are created, and again when the B<configure>
command is invoked for a widget.
Although intended primarily for widgets, B<Tk_ConfigureWidget>
can be used in other situations where I<argc-argv> information
is to be used to fill in a record structure, such as configuring
graphical elements for a canvas widget or entries of a menu.

B<Tk_ConfigureWidget> processes
a table specifying the configuration options that are supported
(I<specs>) and a collection of command-line arguments (I<argc> and
I<argv>) to fill in fields of a record (I<widgRec>).
It uses the option database and defaults specified in I<specs>
to fill in fields of I<widgRec> that are not specified in I<argv>.
B<Tk_ConfigureWidget> normally returns the value TCL_OK; in this
case it does not modify I<interp>.
If an error
occurs then TCL_ERROR is returned and B<Tk_ConfigureWidget> will
leave an error message in I<interp-E<gt>result> in the standard Tcl
fashion.
In the event of an error return, some of the fields of I<widgRec>
could already have been set, if configuration information for them
was successfully processed before the error occurred.
The other fields will be set to reasonable initial values so that
B<Tk_FreeOptions> can be called for cleanup.

The I<specs> array specifies the kinds of configuration options
expected by the widget.  Each of its entries specifies one configuration
option and has the following structure:

 typedef struct {
 	int type;
 	char *argvName;
 	char *dbName;
 	char *dbClass;
 	char *defValue;
 	int offset;
 	int specFlags;
 	Tk_CustomOption *customPtr;
 } Tk_ConfigSpec;

The I<type> field indicates what type of configuration option this is
(e.g. TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for
an integer value).  The I<type> field indicates how to use the
value of the option (more on this below).
The I<argvName> field is a string such as ``-font'' or ``-bg'',
which is compared with the values in I<argv> (if I<argvName> is
NULL it means this is a grouped entry;  see L</GROUPED ENTRIES> below).  The
I<dbName> and I<dbClass> fields are used to look up a value
for this option in the option database.  The I<defValue> field
specifies a default value for this configuration option if no
value is specified in either I<argv> or the option database.
I<Offset> indicates where in I<widgRec> to store information
about this option, and I<specFlags> contains additional information
to control the processing of this configuration option (see FLAGS
below).
The last field, I<customPtr>, is only used if I<type> is
TK_CONFIG_CUSTOM;  see L</CUSTOM OPTION TYPES> below.

B<Tk_ConfigureWidget> first processes I<argv> to see which
(if any) configuration options are specified there.  I<Argv>
must contain an even number of fields;  the first of each pair
of fields must match the I<argvName> of some entry in I<specs>
(unique abbreviations are acceptable),
and the second field of the pair contains the value for that
configuration option.  If there are entries in I<spec> for which
there were no matching entries in I<argv>,
B<Tk_ConfigureWidget> uses the I<dbName> and I<dbClass>
fields of the I<specs> entry to probe the option database;  if
a value is found, then it is used as the value for the option.
Finally, if no entry is found in the option database, the
I<defValue> field of the I<specs> entry is used as the
value for the configuration option.  If the I<defValue> is
NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in
I<flags>, then there is no default value and this I<specs> entry
will be ignored if no value is specified in I<argv> or the
option database.

Once a string value has been determined for a configuration option,
B<Tk_ConfigureWidget> translates the string value into a more useful
form, such as a color if I<type> is TK_CONFIG_COLOR or an integer
if I<type> is TK_CONFIG_INT.  This value is then stored in the
record pointed to by I<widgRec>.  This record is assumed to
contain information relevant to the manager of the widget;  its exact
type is unknown to B<Tk_ConfigureWidget>.  The I<offset> field
of each I<specs> entry indicates where in I<widgRec> to store
the information about this configuration option.  You should use the
B<Tk_Offset> macro to generate I<offset> values (see below for
a description of B<Tk_Offset>).  The location indicated by
I<widgRec> and I<offset> will be referred to as the ``target''
in the descriptions below.

The I<type> field of each entry in I<specs> determines what
to do with the string value of that configuration option.  The
legal values for I<type>, and the corresponding actions, are:

=over 4

=item B<TK_CONFIG_ACTIVE_CURSOR>

The value
must be an ASCII string identifying a cursor in a form
suitable for passing to B<Tk_GetCursor>.
The value is converted to a B<Tk_Cursor> by calling
B<Tk_GetCursor> and the result is stored in the target.
In addition, the resulting cursor is made the active cursor
for I<tkwin> by calling B<XDefineCursor>.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target and I<tkwin>'s
active cursor will be set to B<None>.
If the previous value of the target
wasn't B<None>, then it is freed by passing it to B<Tk_FreeCursor>.

=item B<TK_CONFIG_ANCHOR>

The value must be an ASCII string identifying an anchor point in one of the ways
accepted by B<Tk_GetAnchor>.
The string is converted to a B<Tk_Anchor> by calling
B<Tk_GetAnchor> and the result is stored in the target.

=item B<TK_CONFIG_BITMAP>

The value must be an ASCII string identifying a bitmap in a form
suitable for passing to B<Tk_GetBitmap>.  The value is converted
to a B<Pixmap> by calling B<Tk_GetBitmap> and the result
is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target is set to B<None>.
If the previous value of the target
wasn't B<None>, then it is freed by passing it to B<Tk_FreeBitmap>.

=item B<TK_CONFIG_BOOLEAN>

The value must be an ASCII string specifying a boolean value.  Any
of the values ``true'', ``yes'', ``on'', or ``1'',
or an abbreviation of one of these values, means true;
any of the values ``false'', ``no'', ``off'', or ``0'', or an abbreviation of
one of these values, means false.
The target is expected to be an integer;  for true values it will
be set to 1 and for false values it will be set to 0.

=item B<TK_CONFIG_BORDER>

The value must be an ASCII string identifying a border color in a form
suitable for passing to B<Tk_Get3DBorder>.  The value is converted
to a (B<Tk_3DBorder *>) by calling B<Tk_Get3DBorder> and the result
is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target will be set to NULL.
If the previous value of the target
wasn't NULL, then it is freed by passing it to B<Tk_Free3DBorder>.

=item B<TK_CONFIG_CAP_STYLE>

The value must be
an ASCII string identifying a cap style in one of the ways
accepted by B<Tk_GetCapStyle>.
The string is converted to an integer value corresponding
to the cap style by calling
B<Tk_GetCapStyle> and the result is stored in the target.

=item B<TK_CONFIG_COLOR>

The value must be an ASCII string identifying a color in a form
suitable for passing to B<Tk_GetColor>.  The value is converted
to an (B<XColor *>) by calling B<Tk_GetColor> and the result
is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target will be set to B<None>.
If the previous value of the target
wasn't NULL, then it is freed by passing it to B<Tk_FreeColor>.

=item B<TK_CONFIG_CURSOR>

This option is identical to B<TK_CONFIG_ACTIVE_CURSOR> except
that the new cursor is not made the active one for I<tkwin>.

=item B<TK_CONFIG_CUSTOM>

This option allows applications to define new option types.
The I<customPtr> field of the entry points to a structure
defining the new option type.
See the section L</CUSTOM OPTION TYPES> below for details.

=item B<TK_CONFIG_DOUBLE>

The value must be an ASCII floating-point number in
the format accepted by B<strtol>.  The string is converted
to a B<double> value, and the value is stored in the
target.

=item B<TK_CONFIG_END>

Marks the end of the table.  The last entry in I<specs>
must have this type;  all of its other fields are ignored and it
will never match any arguments.

=item B<TK_CONFIG_FONT>

The value must be an ASCII string identifying a font in a form
suitable for passing to B<Tk_GetFontStruct>.  The value is converted
to an (B<XFontStruct *>) by calling B<Tk_GetFontStruct> and the result
is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target will be set to NULL.
If the previous value of the target
wasn't NULL, then it is freed by passing it to B<Tk_FreeFontStruct>.

=item B<TK_CONFIG_INT>

The value must be an ASCII integer string
in the format accepted by B<strtol> (e.g. ``0''
and ``0x'' prefixes may be used to specify octal or hexadecimal
numbers, respectively).  The string is converted to an integer
value and the integer is stored in the target.

=item B<TK_CONFIG_JOIN_STYLE>

The value must be
an ASCII string identifying a join style in one of the ways
accepted by B<Tk_GetJoinStyle>.
The string is converted to an integer value corresponding
to the join style by calling
B<Tk_GetJoinStyle> and the result is stored in the target.

=item B<TK_CONFIG_JUSTIFY>

The value must be
an ASCII string identifying a justification method in one of the
ways accepted by B<Tk_GetJustify>.
The string is converted to a B<Tk_Justify> by calling
B<Tk_GetJustify> and the result is stored in the target.

=item B<TK_CONFIG_MM>

The value must specify a screen distance in one of the forms acceptable
to B<Tk_GetScreenMM>.
The string is converted to double-precision floating-point distance
in millimeters and the value is stored in the target.

=item B<TK_CONFIG_PIXELS>

The value must specify screen units in one of the forms acceptable
to B<Tk_GetPixels>.
The string is converted to an integer distance in pixels and the
value is stored in the target.

=item B<TK_CONFIG_RELIEF>

The value must be an ASCII string identifying a relief in a form
suitable for passing to B<Tk_GetRelief>.  The value is converted
to an integer relief value by calling B<Tk_GetRelief> and the result
is stored in the target.

=item B<TK_CONFIG_STRING>

A copy
of the value is made by allocating memory space with
B<malloc> and copying the value into the dynamically-allocated
space.  A pointer to the new string is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> then the value
may be an empty string, in which case the target will be set to NULL.
If the previous value of the target wasn't NULL, then it is
freed by passing it to B<free>.

=item B<TK_CONFIG_SYNONYM>

This I<type> value identifies special entries in I<specs> that
are synonyms for other entries.  If an I<argv> value matches the
I<argvName> of a TK_CONFIG_SYNONYM entry, the entry isn't used
directly. Instead, B<Tk_ConfigureWidget> searches I<specs>
for another entry whose I<argvName> is the same as the I<dbName>
field in the TK_CONFIG_SYNONYM entry;  this new entry is used just
as if its I<argvName> had matched the I<argv> value.  The
synonym mechanism allows multiple I<argv> values to be used for
a single configuration option, such as ``-background'' and ``-bg''.

=item B<TK_CONFIG_UID>

The value is translated to a B<Tk_Uid>
(by passing it to B<Tk_GetUid>).  The resulting value
is stored in the target.
If TK_CONFIG_NULL_OK is specified in I<specFlags> and the value
is an empty string then the target will be set to NULL.

=item B<TK_CONFIG_WINDOW>

The value must be a window path name.  It is translated to a
B<Tk_Window> token and the token is stored in the target.

=back

=head1 GROUPED ENTRIES

In some cases it is useful to generate multiple resources from
a single configuration value.  For example, a color name might
be used both to generate the background color for a widget (using
TK_CONFIG_COLOR) and to generate a 3-D border to draw around the
widget (using TK_CONFIG_BORDER).  In cases like this it is possible
to specify that several consecutive entries in I<specs> are to
be treated as a group.  The first entry is used to determine a value
(using its I<argvName>, I<dbName>,
I<dbClass>, and I<defValue> fields).  The value will be processed
several times (one for each entry in the group), generating multiple
different resources and modifying multiple targets within I<widgRec>.
Each of the entries after the first must have a NULL value in its
I<argvName> field;  this indicates that the entry is to be grouped
with the entry that precedes it.  Only the I<type> and I<offset>
fields are used from these follow-on entries.

=head1 FLAGS

The I<flags> argument passed to B<Tk_ConfigureWidget> is used
in conjunction with the I<specFlags> fields in the entries of I<specs>
to provide additional control over the processing of configuration
options.  These values are used in three different ways as
described below.

First, if the I<flags> argument to B<Tk_ConfigureWidget> has
the TK_CONFIG_ARGV_ONLY bit set (i.e., I<flags> | TK_CONFIG_ARGV_ONLY != 0),
then the option database and
I<defValue> fields are not used.  In this case, if an entry in
I<specs> doesn't match a field in I<argv> then nothing happens:
the corresponding target isn't modified.  This feature is useful
when the goal is to modify certain configuration options while
leaving others in their current state, such as when a B<configure>
method is being processed.

Second, the I<specFlags> field of an entry in I<specs> may be used
to control the processing of that entry.  Each I<specFlags>
field may consists of an OR-ed combination of the following values:

=over 4

=item B<TK_CONFIG_COLOR_ONLY>

If this bit is set then the entry will only be considered if the
display for I<tkwin> has more than one bit plane.  If the display
is monochromatic then this I<specs> entry will be ignored.

=item B<TK_CONFIG_MONO_ONLY>

If this bit is set then the entry will only be considered if the
display for I<tkwin> has exactly one bit plane.  If the display
is not monochromatic then this I<specs> entry will be ignored.

=item B<TK_CONFIG_NULL_OK>

This bit is only relevant for some types of entries (see the
descriptions of the various entry types above).
If this bit is set, it indicates that an empty string value
for the field is acceptable and if it occurs then the
target should be set to NULL or B<None>, depending
on the type of the target.
This flag is typically used to allow a
feature to be turned off entirely, e.g. set a cursor value to
B<None> so that a window simply inherits its parent's cursor.
If this bit isn't set then empty strings are processed as strings,
which generally results in an error.

=item B<TK_CONFIG_DONT_SET_DEFAULT>

If this bit is one, it means that the I<defValue> field of the
entry should only be used for returning the default value in
B<Tk_ConfigureInfo>.
In calls to B<Tk_ConfigureWidget> no default will be supplied
for entries with this flag set;  it is assumed that the
caller has already supplied a default value in the target location.
This flag provides a performance optimization where it is expensive
to process the default string:  the client can compute the default
once, save the value, and provide it before calling
B<Tk_ConfigureWidget>.

=item B<TK_CONFIG_OPTION_SPECIFIED>

This bit is set and cleared by B<Tk_ConfigureWidget>.  Whenever
B<Tk_ConfigureWidget> returns, this bit will be set in all the
entries where a value was specified in I<argv>.
It will be zero in all other entries.
This bit provides a way for clients to determine which values
actually changed in a call to B<Tk_ConfigureWidget>.

The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically
used to specify different default values for
monochrome and color displays.  This is done by creating two
entries in I<specs> that are identical except for their
I<defValue> and I<specFlags> fields.  One entry should have
the value TK_CONFIG_MONO_ONLY in its I<specFlags> and the
default value for monochrome displays in its I<defValue>;  the
other entry entry should have the value TK_CONFIG_COLOR_ONLY in
its I<specFlags> and the appropriate I<defValue> for
color displays.

Third, it is possible to use I<flags> and I<specFlags>
together to selectively disable some entries.  This feature is
not needed very often.  It is useful in cases where several
similar kinds of widgets are implemented in one place.  It allows
a single I<specs> table to be created with all the configuration
options for all the widget types.  When processing a particular
widget type, only entries relevant to that type will be used.  This
effect is achieved by setting the high-order bits (those in positions
equal to or greater than TK_CONFIG_USER_BIT) in I<specFlags>
values or in I<flags>.  In order for a particular entry in
I<specs> to be used, its high-order bits must match exactly
the high-order bits of the I<flags> value passed to
B<Tk_ConfigureWidget>.  If a I<specs> table is being used
for N different widget types, then N of the high-order bits will
be used.  Each I<specs> entry will have one of more of those
bits set in its I<specFlags> field to indicate the widget types
for which this entry is valid.  When calling B<Tk_ConfigureWidget>,
I<flags> will have a single one of these bits set to select the
entries for the desired widget type.  For a working example of
this feature, see the code in tkButton.c.

=back

=head1 TK_OFFSET

The B<Tk_Offset> macro is provided as a safe way of generating
the I<offset> values for entries in Tk_ConfigSpec structures.
It takes two arguments:  the name of a type of record, and the
name of a field in that record.  It returns the byte offset of
the named field in records of the given type.

=head1 TK_CONFIGUREINFO

The B<Tk_ConfigureInfo> procedure may be used to obtain
information about one or all of the options for a given widget.
Given a token for a window (I<tkwin>), a table describing the
configuration options for a class of widgets (I<specs>), a
pointer to a widget record containing the current information for
a widget (I<widgRec>), and a NULL I<argvName> argument,
B<Tk_ConfigureInfo> generates a string describing all of the
configuration options for the window.  The string is placed
in I<interp-E<gt>result>.  Under normal circumstances
it returns TCL_OK;  if an error occurs then it returns TCL_ERROR
and I<interp-E<gt>result> contains an error message.

If I<argvName> is NULL, then the value left in
I<interp-E<gt>result> by B<Tk_ConfigureInfo>
consists of a list of one or more entries, each of which describes
one configuration option (i.e. one entry in I<specs>).  Each
entry in the list will contain either two or five values.  If the
corresponding entry in I<specs> has type TK_CONFIG_SYNONYM, then
the list will contain two values:  the I<argvName> for the entry
and the I<dbName> (synonym name).  Otherwise the list will contain
five values:  I<argvName>, I<dbName>, I<dbClass>, I<defValue>,
and current value.  The current value is computed from the appropriate
field of I<widgRec> by calling procedures like B<Tk_NameOfColor>.

If the I<argvName> argument to B<Tk_ConfigureInfo> is non-NULL,
then it indicates a single option, and information is returned only
for that option.  The string placed in I<interp-E<gt>result> will be
a list containing two or five values as described above;  this will
be identical to the corresponding sublist that would have been returned
if I<argvName> had been NULL.

The I<flags> argument to B<Tk_ConfigureInfo> is used to restrict
the I<specs> entries to consider, just as for B<Tk_ConfigureWidget>.

=head1 TK_CONFIGUREVALUE

B<Tk_ConfigureValue> takes arguments similar to B<Tk_ConfigureInfo>;
instead of returning a list of values, it just returns the current value
of the option given by I<argvName> (I<argvName> must not be NULL).
The value is returned in I<interp-E<gt>result> and TCL_OK is
normally returned as the procedure's result.
If an error occurs in B<Tk_ConfigureValue> (e.g., I<argvName> is
not a valid option name), TCL_ERROR is returned and an error message
is left in I<interp-E<gt>result>.
This procedure is typically called to implement B<cget> widget
commands.

=head1 TK_FREEOPTIONS

The B<Tk_FreeOptions> procedure may be invoked during widget cleanup
to release all of the resources associated with configuration options.
It scans through I<specs> and for each entry corresponding to a
resource that must be explicitly freed (e.g. those with
type TK_CONFIG_COLOR), it frees the resource in the widget record.
If the field in the widget record doesn't refer to a resource (e.g.
it contains a null pointer) then no resource is freed for that
entry.
After freeing a resource, B<Tk_FreeOptions> sets the
corresponding field of the widget record to null.

=head1 CUSTOM OPTION TYPES

Applications can extend the built-in configuration types with additional
configuration types by writing procedures to parse and print options
of the a type and creating a structure pointing to those procedures:

 typedef struct Tk_CustomOption {
 	Tk_OptionParseProc *parseProc;
 	Tk_OptionPrintProc *printProc;
 	ClientData clientData;
 } Tk_CustomOption;

 typedef int Tk_OptionParseProc(
 	ClientData clientData,
 	Tcl_Interp *interp,
 	Tk_Window tkwin,
 	char *value,
 	char *widgRec,
 	int offset);

 typedef char *Tk_OptionPrintProc(
 	ClientData clientData,
 	Tk_Window tkwin,
 	char *widgRec,
 	int offset,
 	Tcl_FreeProc **freeProcPtr);

The Tk_CustomOption structure contains three fields, which are pointers
to the two procedures and a I<clientData> value to be passed to those
procedures when they are invoked.  The I<clientData> value typically
points to a structure containing information that is needed by the
procedures when they are parsing and printing options.

The I<parseProc> procedure is invoked by
B<Tk_ConfigureWidget> to parse a string and store the resulting
value in the widget record.
The I<clientData> argument is a copy of the I<clientData>
field in the Tk_CustomOption structure.
The I<interp> argument points to a Tcl interpreter used for
error reporting.  I<Tkwin> is a copy of the I<tkwin> argument
to B<Tk_ConfigureWidget>.  The I<value> argument is a string
describing the value for the option;  it could have been specified
explicitly in the call to B<Tk_ConfigureWidget> or it could
come from the option database or a default.
I<Value> will never be a null pointer but it may point to
an empty string.
I<RecordPtr> is the same as the I<widgRec> argument to
B<Tk_ConfigureWidget>;  it points to the start of the widget
record to modify.
The last argument, I<offset>, gives the offset in bytes from the start
of the widget record to the location where the option value is to
be placed.  The procedure should translate the string to whatever
form is appropriate for the option and store the value in the widget
record.  It should normally return TCL_OK, but if an error occurs
in translating the string to a value then it should return TCL_ERROR
and store an error message in I<interp-E<gt>result>.

The I<printProc> procedure is called
by B<Tk_ConfigureInfo> to produce a string value describing an
existing option.
Its I<clientData>, I<tkwin>, I<widgRec>, and I<offset>
arguments all have the same meaning as for Tk_OptionParseProc
procedures.
The I<printProc> procedure should examine the option whose value
is stored at I<offset> in I<widgRec>, produce a string describing
that option, and return a pointer to the string.
If the string is stored in dynamically-allocated memory, then
the procedure must set I<*freeProcPtr> to the address of
a procedure to call to free the string's memory;  B<Tk_ConfigureInfo>
will call this procedure when it is finished with the string.
If the result string is stored in static memory then I<printProc>
need not do anything with the I<freeProcPtr> argument.

Once I<parseProc> and I<printProc> have been defined and a
Tk_CustomOption structure has been created for them, options of this
new type may be manipulated with Tk_ConfigSpec entries whose I<type>
fields are TK_CONFIG_CUSTOM and whose I<customPtr> fields point
to the Tk_CustomOption structure.

=head1 EXAMPLES

Although the explanation of B<Tk_ConfigureWidget> is fairly
complicated, its actual use is pretty straightforward.
The easiest way to get started is to copy the code
from an existing widget.
The library implementation of frames
(tkFrame.c) has a simple configuration table, and the library
implementation of buttons (tkButton.c) has a much more complex
table that uses many of the fancy I<specFlags> mechanisms.

=head1 KEYWORDS

anchor, bitmap, boolean, border, cap style, color, configuration options,
cursor, custom, double, font, integer, join style, justify, millimeters,
pixels, relief, synonym, uid
