diff options
Diffstat (limited to 'doc/ConfigWidg.3')
-rw-r--r-- | doc/ConfigWidg.3 | 198 |
1 files changed, 109 insertions, 89 deletions
diff --git a/doc/ConfigWidg.3 b/doc/ConfigWidg.3 index c7a8c33..6a3e41a 100644 --- a/doc/ConfigWidg.3 +++ b/doc/ConfigWidg.3 @@ -35,7 +35,7 @@ Pointer to table specifying legal configuration options for this widget. .AP int argc in Number of arguments in \fIargv\fR. -.AP "CONST char" **argv in +.AP "const char" **argv in Command-line options for configuring widget. .AP char *widgRec in/out Points to widget record structure. Fields in this structure get @@ -43,14 +43,14 @@ modified by \fBTk_ConfigureWidget\fR to hold configuration information. .AP 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 +\fBTK_CONFIG_ARGV_ONLY\fR causes the option database and defaults to be +ignored, and flag bits \fBTK_CONFIG_USER_BIT\fR and higher are used to selectively disable entries in \fIspecs\fR. .AP "type name" type in The name of the type of a widget record. .AP "field name" field in The name of a field in records of type \fItype\fR. -.AP "CONST char" *argvName in +.AP "const 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 \fBconfigure\fR widget command). If non-NULL, then information is returned only for this @@ -61,12 +61,10 @@ Display containing widget whose record is being freed; needed in order to free up resources. .BE .SH DESCRIPTION -.VS 8.1 .PP -Note: \fBTk_ConfigureWidget\fP should be replaced with the new -\fBTcl_Obj\fP based API \fBTk_SetOptions\fP. The old interface is +Note: \fBTk_ConfigureWidget\fR should be replaced with the new +\fBTcl_Obj\fR based API \fBTk_SetOptions\fR. The old interface is retained for backward compatibility. -.VE .PP \fBTk_ConfigureWidget\fR is called to configure various aspects of a widget, such as colors, fonts, border width, etc. @@ -87,10 +85,10 @@ a table specifying the configuration options that are supported \fIargv\fR) to fill in fields of a record (\fIwidgRec\fR). It uses the option database and defaults specified in \fIspecs\fR to fill in fields of \fIwidgRec\fR that are not specified in \fIargv\fR. -\fBTk_ConfigureWidget\fR normally returns the value TCL_OK; in this +\fBTk_ConfigureWidget\fR normally returns the value \fBTCL_OK\fR; in this case it does not modify \fIinterp\fR. If an error -occurs then TCL_ERROR is returned and \fBTk_ConfigureWidget\fR will +occurs then \fBTCL_ERROR\fR is returned and \fBTk_ConfigureWidget\fR will leave an error message in \fIinterp->result\fR in the standard Tcl fashion. In the event of an error return, some of the fields of \fIwidgRec\fR @@ -104,23 +102,26 @@ expected by the widget. Each of its entries specifies one configuration option and has the following structure: .CS typedef struct { - int \fItype\fR; - char *\fIargvName\fR; - char *\fIdbName\fR; - char *\fIdbClass\fR; - char *\fIdefValue\fR; - int \fIoffset\fR; - int \fIspecFlags\fR; - Tk_CustomOption *\fIcustomPtr\fR; + int \fItype\fR; + char *\fIargvName\fR; + char *\fIdbName\fR; + char *\fIdbClass\fR; + char *\fIdefValue\fR; + int \fIoffset\fR; + int \fIspecFlags\fR; + Tk_CustomOption *\fIcustomPtr\fR; } Tk_ConfigSpec; .CE The \fItype\fR field indicates what type of configuration option this is -(e.g. TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for +(e.g. \fBTK_CONFIG_COLOR\fR for a color value, or \fBTK_CONFIG_INT\fR for an integer value). The \fItype\fR field indicates how to use the value of the option (more on this below). -The \fIargvName\fR field is a string such as ``\-font'' or ``\-bg'', +The \fIargvName\fR field is a string such as +.QW \-font +or +.QW \-bg , which is compared with the values in \fIargv\fR (if \fIargvName\fR is -NULL it means this is a grouped entry; see GROUPED ENTRIES below). The +NULL it means this is a grouped entry; see \fBGROUPED ENTRIES\fR below). The \fIdbName\fR and \fIdbClass\fR fields are used to look up a value for this option in the option database. The \fIdefValue\fR field specifies a default value for this configuration option if no @@ -130,7 +131,7 @@ about this option, and \fIspecFlags\fR contains additional information to control the processing of this configuration option (see FLAGS below). The last field, \fIcustomPtr\fR, is only used if \fItype\fR is -TK_CONFIG_CUSTOM; see CUSTOM OPTION TYPES below. +\fBTK_CONFIG_CUSTOM\fR; see CUSTOM OPTION TYPES below. .PP \fBTk_ConfigureWidget\fR first processes \fIargv\fR to see which (if any) configuration options are specified there. \fIArgv\fR @@ -146,15 +147,15 @@ 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 \fIdefValue\fR field of the \fIspecs\fR entry is used as the value for the configuration option. If the \fIdefValue\fR is -NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in +NULL, or if the \fBTK_CONFIG_DONT_SET_DEFAULT\fR bit is set in \fIflags\fR, then there is no default value and this \fIspecs\fR entry will be ignored if no value is specified in \fIargv\fR or the option database. .PP Once a string value has been determined for a configuration option, \fBTk_ConfigureWidget\fR translates the string value into a more useful -form, such as a color if \fItype\fR is TK_CONFIG_COLOR or an integer -if \fItype\fR is TK_CONFIG_INT. This value is then stored in the +form, such as a color if \fItype\fR is \fBTK_CONFIG_COLOR\fR or an integer +if \fItype\fR is \fBTK_CONFIG_INT\fR. This value is then stored in the record pointed to by \fIwidgRec\fR. This record is assumed to contain information relevant to the manager of the widget; its exact type is unknown to \fBTk_ConfigureWidget\fR. The \fIoffset\fR field @@ -162,7 +163,8 @@ of each \fIspecs\fR entry indicates where in \fIwidgRec\fR to store the information about this configuration option. You should use the \fBTk_Offset\fR macro to generate \fIoffset\fR values (see below for a description of \fBTk_Offset\fR). The location indicated by -\fIwidgRec\fR and \fIoffset\fR will be referred to as the ``target'' +\fIwidgRec\fR and \fIoffset\fR will be referred to as the +.QW target in the descriptions below. .PP The \fItype\fR field of each entry in \fIspecs\fR determines what @@ -177,11 +179,11 @@ The value is converted to a \fBTk_Cursor\fR by calling \fBTk_GetCursor\fR and the result is stored in the target. In addition, the resulting cursor is made the active cursor for \fItkwin\fR by calling \fBXDefineCursor\fR. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR then the value may be an empty string, in which case the target and \fItkwin\fR's active cursor will be set to \fBNone\fR. If the previous value of the target -wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeCursor\fR. +was not \fBNone\fR, then it is freed by passing it to \fBTk_FreeCursor\fR. .TP \fBTK_CONFIG_ANCHOR\fR The value must be an ASCII string identifying an anchor point in one of the ways @@ -194,17 +196,27 @@ The value must be an ASCII string identifying a bitmap in a form suitable for passing to \fBTk_GetBitmap\fR. The value is converted to a \fBPixmap\fR by calling \fBTk_GetBitmap\fR and the result is stored in the target. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR then the value may be an empty string, in which case the target is set to \fBNone\fR. If the previous value of the target -wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeBitmap\fR. +was not \fBNone\fR, then it is freed by passing it to \fBTk_FreeBitmap\fR. .TP \fBTK_CONFIG_BOOLEAN\fR The value must be an ASCII string specifying a boolean value. Any -of the values ``true'', ``yes'', ``on'', or ``1'', +of the values +.QW true , +.QW yes , +.QW on , +or +.QW 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. +any of the values +.QW false , +.QW no , +.QW off , +or +.QW 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. .TP @@ -213,10 +225,10 @@ The value must be an ASCII string identifying a border color in a form suitable for passing to \fBTk_Get3DBorder\fR. The value is converted to a (\fBTk_3DBorder *\fR) by calling \fBTk_Get3DBorder\fR and the result is stored in the target. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR 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 \fBTk_Free3DBorder\fR. +was not NULL, then it is freed by passing it to \fBTk_Free3DBorder\fR. .TP \fBTK_CONFIG_CAP_STYLE\fR The value must be @@ -231,10 +243,10 @@ The value must be an ASCII string identifying a color in a form suitable for passing to \fBTk_GetColor\fR. The value is converted to an (\fBXColor *\fR) by calling \fBTk_GetColor\fR and the result is stored in the target. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR then the value may be an empty string, in which case the target will be set to \fBNone\fR. If the previous value of the target -wasn't NULL, then it is freed by passing it to \fBTk_FreeColor\fR. +was not NULL, then it is freed by passing it to \fBTk_FreeColor\fR. .TP \fBTK_CONFIG_CURSOR\fR This option is identical to \fBTK_CONFIG_ACTIVE_CURSOR\fR except @@ -244,7 +256,7 @@ that the new cursor is not made the active one for \fItkwin\fR. This option allows applications to define new option types. The \fIcustomPtr\fR field of the entry points to a structure defining the new option type. -See the section CUSTOM OPTION TYPES below for details. +See the section \fBCUSTOM OPTION TYPES\fR below for details. .TP \fBTK_CONFIG_DOUBLE\fR The value must be an ASCII floating-point number in @@ -262,15 +274,18 @@ The value must be an ASCII string identifying a font in a form suitable for passing to \fBTk_GetFont\fR. The value is converted to a \fBTk_Font\fR by calling \fBTk_GetFont\fR and the result is stored in the target. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR 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 \fBTk_FreeFont\fR. +was not NULL, then it is freed by passing it to \fBTk_FreeFont\fR. .TP \fBTK_CONFIG_INT\fR The value must be an ASCII integer string -in the format accepted by \fBstrtol\fR (e.g. ``0'' -and ``0x'' prefixes may be used to specify octal or hexadecimal +in the format accepted by \fBstrtol\fR (e.g. +.QW 0 +and +.QW 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. .TP @@ -310,29 +325,32 @@ is stored in the target. \fBTK_CONFIG_STRING\fR A copy of the value is made by allocating memory space with -\fBmalloc\fR and copying the value into the dynamically-allocated +\fBTcl_Alloc\fR 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 \fIspecFlags\fR then the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR 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 \fBfree\fR. +If the previous value of the target was not NULL, then it is +freed by passing it to \fBTcl_Free\fR. .TP \fBTK_CONFIG_SYNONYM\fR This \fItype\fR value identifies special entries in \fIspecs\fR that are synonyms for other entries. If an \fIargv\fR value matches the -\fIargvName\fR of a TK_CONFIG_SYNONYM entry, the entry isn't used +\fIargvName\fR of a \fBTK_CONFIG_SYNONYM\fR entry, the entry is not used directly. Instead, \fBTk_ConfigureWidget\fR searches \fIspecs\fR for another entry whose \fIargvName\fR is the same as the \fIdbName\fR -field in the TK_CONFIG_SYNONYM entry; this new entry is used just +field in the \fBTK_CONFIG_SYNONYM\fR entry; this new entry is used just as if its \fIargvName\fR had matched the \fIargv\fR value. The synonym mechanism allows multiple \fIargv\fR values to be used for -a single configuration option, such as ``\-background'' and ``\-bg''. +a single configuration option, such as +.QW \-background +and +.QW \-bg . .TP \fBTK_CONFIG_UID\fR The value is translated to a \fBTk_Uid\fR (by passing it to \fBTk_GetUid\fR). The resulting value is stored in the target. -If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR and the value +If \fBTK_CONFIG_NULL_OK\fR is specified in \fIspecFlags\fR and the value is an empty string then the target will be set to NULL. .TP \fBTK_CONFIG_WINDOW\fR @@ -344,8 +362,8 @@ The value must be a window path name. It is translated to a 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 +\fBTK_CONFIG_COLOR\fR) and to generate a 3-D border to draw around the +widget (using \fBTK_CONFIG_BORDER\fR). In cases like this it is possible to specify that several consecutive entries in \fIspecs\fR are to be treated as a group. The first entry is used to determine a value (using its \fIargvName\fR, \fIdbName\fR, @@ -366,11 +384,11 @@ options. These values are used in three different ways as described below. .PP First, if the \fIflags\fR argument to \fBTk_ConfigureWidget\fR has -the TK_CONFIG_ARGV_ONLY bit set (i.e., \fIflags\fR | TK_CONFIG_ARGV_ONLY != 0), +the \fBTK_CONFIG_ARGV_ONLY\fR bit set (i.e., \fIflags\fR | \fBTK_CONFIG_ARGV_ONLY\fR != 0), then the option database and \fIdefValue\fR fields are not used. In this case, if an entry in -\fIspecs\fR doesn't match a field in \fIargv\fR then nothing happens: -the corresponding target isn't modified. This feature is useful +\fIspecs\fR does not match a field in \fIargv\fR then nothing happens: +the corresponding target is not 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 \fBconfigure\fR widget command is being processed. @@ -399,7 +417,7 @@ 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 \fBNone\fR so that a window simply inherits its parent's cursor. -If this bit isn't set then empty strings are processed as strings, +If this bit is not set then empty strings are processed as strings, which generally results in an error. .TP \fBTK_CONFIG_DONT_SET_DEFAULT\fR @@ -415,21 +433,23 @@ once, save the value, and provide it before calling \fBTk_ConfigureWidget\fR. .TP \fBTK_CONFIG_OPTION_SPECIFIED\fR -This bit is set and cleared by \fBTk_ConfigureWidget\fR. Whenever -\fBTk_ConfigureWidget\fR returns, this bit will be set in all the -entries where a value was specified in \fIargv\fR. -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 \fBTk_ConfigureWidget\fR. +This bit is +.VS 8.5 +deprecated. It used to be set and cleared by \fBTk_ConfigureWidget\fR +so that callers could detect what entries were specified in +\fIargv\fR, but it was removed because it was inherently +thread-unsafe. Code that wishes to detect what options were specified +should use \fBTk_SetOptions\fR instead. +.VE 8.5 .PP -The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically +The \fBTK_CONFIG_MONO_ONLY\fR and \fBTK_CONFIG_COLOR_ONLY\fR flags are typically used to specify different default values for monochrome and color displays. This is done by creating two entries in \fIspecs\fR that are identical except for their \fIdefValue\fR and \fIspecFlags\fR fields. One entry should have -the value TK_CONFIG_MONO_ONLY in its \fIspecFlags\fR and the +the value \fBTK_CONFIG_MONO_ONLY\fR in its \fIspecFlags\fR and the default value for monochrome displays in its \fIdefValue\fR; the -other entry entry should have the value TK_CONFIG_COLOR_ONLY in +other entry should have the value \fBTK_CONFIG_COLOR_ONLY\fR in its \fIspecFlags\fR and the appropriate \fIdefValue\fR for color displays. .PP @@ -441,7 +461,7 @@ a single \fIspecs\fR 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 \fIspecFlags\fR +equal to or greater than \fBTK_CONFIG_USER_BIT\fR) in \fIspecFlags\fR values or in \fIflags\fR. In order for a particular entry in \fIspecs\fR to be used, its high-order bits must match exactly the high-order bits of the \fIflags\fR value passed to @@ -473,7 +493,7 @@ a widget (\fIwidgRec\fR), and a NULL \fIargvName\fR argument, \fBTk_ConfigureInfo\fR generates a string describing all of the configuration options for the window. The string is placed in \fIinterp->result\fR. Under normal circumstances -it returns TCL_OK; if an error occurs then it returns TCL_ERROR +it returns \fBTCL_OK\fR; if an error occurs then it returns \fBTCL_ERROR\fR and \fIinterp->result\fR contains an error message. .PP If \fIargvName\fR is NULL, then the value left in @@ -481,7 +501,7 @@ If \fIargvName\fR is NULL, then the value left in consists of a list of one or more entries, each of which describes one configuration option (i.e. one entry in \fIspecs\fR). Each entry in the list will contain either two or five values. If the -corresponding entry in \fIspecs\fR has type TK_CONFIG_SYNONYM, then +corresponding entry in \fIspecs\fR has type \fBTK_CONFIG_SYNONYM\fR, then the list will contain two values: the \fIargvName\fR for the entry and the \fIdbName\fR (synonym name). Otherwise the list will contain five values: \fIargvName\fR, \fIdbName\fR, \fIdbClass\fR, \fIdefValue\fR, @@ -503,10 +523,10 @@ the \fIspecs\fR entries to consider, just as for \fBTk_ConfigureWidget\fR. \fBTk_ConfigureValue\fR takes arguments similar to \fBTk_ConfigureInfo\fR; instead of returning a list of values, it just returns the current value of the option given by \fIargvName\fR (\fIargvName\fR must not be NULL). -The value is returned in \fIinterp->result\fR and TCL_OK is +The value is returned in \fIinterp->result\fR and \fBTCL_OK\fR is normally returned as the procedure's result. If an error occurs in \fBTk_ConfigureValue\fR (e.g., \fIargvName\fR is -not a valid option name), TCL_ERROR is returned and an error message +not a valid option name), \fBTCL_ERROR\fR is returned and an error message is left in \fIinterp->result\fR. This procedure is typically called to implement \fBcget\fR widget commands. @@ -517,8 +537,8 @@ The \fBTk_FreeOptions\fR procedure may be invoked during widget cleanup to release all of the resources associated with configuration options. It scans through \fIspecs\fR 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. +type \fBTK_CONFIG_COLOR\fR), it frees the resource in the widget record. +If the field in the widget record does not refer to a resource (e.g. it contains a null pointer) then no resource is freed for that entry. After freeing a resource, \fBTk_FreeOptions\fR sets the @@ -531,25 +551,25 @@ configuration types by writing procedures to parse and print options of the a type and creating a structure pointing to those procedures: .CS typedef struct Tk_CustomOption { - Tk_OptionParseProc *\fIparseProc\fR; - Tk_OptionPrintProc *\fIprintProc\fR; - ClientData \fIclientData\fR; + Tk_OptionParseProc *\fIparseProc\fR; + Tk_OptionPrintProc *\fIprintProc\fR; + ClientData \fIclientData\fR; } Tk_CustomOption; typedef int Tk_OptionParseProc( - ClientData \fIclientData\fR, - Tcl_Interp *\fIinterp\fR, - Tk_Window \fItkwin\fR, - char *\fIvalue\fR, - char *\fIwidgRec\fR, - int \fIoffset\fR); + ClientData \fIclientData\fR, + Tcl_Interp *\fIinterp\fR, + Tk_Window \fItkwin\fR, + char *\fIvalue\fR, + char *\fIwidgRec\fR, + int \fIoffset\fR); typedef char *Tk_OptionPrintProc( - ClientData \fIclientData\fR, - Tk_Window \fItkwin\fR, - char *\fIwidgRec\fR, - int \fIoffset\fR, - Tcl_FreeProc **\fIfreeProcPtr\fR); + ClientData \fIclientData\fR, + Tk_Window \fItkwin\fR, + char *\fIwidgRec\fR, + int \fIoffset\fR, + Tcl_FreeProc **\fIfreeProcPtr\fR); .CE The Tk_CustomOption structure contains three fields, which are pointers to the two procedures and a \fIclientData\fR value to be passed to those @@ -577,8 +597,8 @@ The last argument, \fIoffset\fR, 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 +record. It should normally return \fBTCL_OK\fR, but if an error occurs +in translating the string to a value then it should return \fBTCL_ERROR\fR and store an error message in \fIinterp->result\fR. .PP The \fIprintProc\fR procedure is called @@ -600,7 +620,7 @@ need not do anything with the \fIfreeProcPtr\fR argument. Once \fIparseProc\fR and \fIprintProc\fR 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 \fItype\fR -fields are TK_CONFIG_CUSTOM and whose \fIcustomPtr\fR fields point +fields are \fBTK_CONFIG_CUSTOM\fR and whose \fIcustomPtr\fR fields point to the Tk_CustomOption structure. .SH EXAMPLES |