Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / man / man3 / Tk_ConfigureValue.3
CommitLineData
86530b38
AT
1'\"
2'\" Copyright (c) 1990-1994 The Regents of the University of California.
3'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4'\"
5'\" See the file "license.terms" for information on usage and redistribution
6'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7'\"
8'\" RCS: @(#) $Id: ConfigWidg.3,v 1.8.2.1 2003/10/06 22:15:17 dgp Exp $
9'\"
10'\" The definitions below are for supplemental macros used in Tcl/Tk
11'\" manual entries.
12'\"
13'\" .AP type name in/out ?indent?
14'\" Start paragraph describing an argument to a library procedure.
15'\" type is type of argument (int, etc.), in/out is either "in", "out",
16'\" or "in/out" to describe whether procedure reads or modifies arg,
17'\" and indent is equivalent to second arg of .IP (shouldn't ever be
18'\" needed; use .AS below instead)
19'\"
20'\" .AS ?type? ?name?
21'\" Give maximum sizes of arguments for setting tab stops. Type and
22'\" name are examples of largest possible arguments that will be passed
23'\" to .AP later. If args are omitted, default tab stops are used.
24'\"
25'\" .BS
26'\" Start box enclosure. From here until next .BE, everything will be
27'\" enclosed in one large box.
28'\"
29'\" .BE
30'\" End of box enclosure.
31'\"
32'\" .CS
33'\" Begin code excerpt.
34'\"
35'\" .CE
36'\" End code excerpt.
37'\"
38'\" .VS ?version? ?br?
39'\" Begin vertical sidebar, for use in marking newly-changed parts
40'\" of man pages. The first argument is ignored and used for recording
41'\" the version when the .VS was added, so that the sidebars can be
42'\" found and removed when they reach a certain age. If another argument
43'\" is present, then a line break is forced before starting the sidebar.
44'\"
45'\" .VE
46'\" End of vertical sidebar.
47'\"
48'\" .DS
49'\" Begin an indented unfilled display.
50'\"
51'\" .DE
52'\" End of indented unfilled display.
53'\"
54'\" .SO
55'\" Start of list of standard options for a Tk widget. The
56'\" options follow on successive lines, in four columns separated
57'\" by tabs.
58'\"
59'\" .SE
60'\" End of list of standard options for a Tk widget.
61'\"
62'\" .OP cmdName dbName dbClass
63'\" Start of description of a specific option. cmdName gives the
64'\" option's name as specified in the class command, dbName gives
65'\" the option's name in the option database, and dbClass gives
66'\" the option's class in the option database.
67'\"
68'\" .UL arg1 arg2
69'\" Print arg1 underlined, then print arg2 normally.
70'\"
71'\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
72'\"
73'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74.if t .wh -1.3i ^B
75.nr ^l \n(.l
76.ad b
77'\" # Start an argument description
78.de AP
79.ie !"\\$4"" .TP \\$4
80.el \{\
81. ie !"\\$2"" .TP \\n()Cu
82. el .TP 15
83.\}
84.ta \\n()Au \\n()Bu
85.ie !"\\$3"" \{\
86\&\\$1 \\fI\\$2\\fP (\\$3)
87.\".b
88.\}
89.el \{\
90.br
91.ie !"\\$2"" \{\
92\&\\$1 \\fI\\$2\\fP
93.\}
94.el \{\
95\&\\fI\\$1\\fP
96.\}
97.\}
98..
99'\" # define tabbing values for .AP
100.de AS
101.nr )A 10n
102.if !"\\$1"" .nr )A \\w'\\$1'u+3n
103.nr )B \\n()Au+15n
104.\"
105.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106.nr )C \\n()Bu+\\w'(in/out)'u+2n
107..
108.AS Tcl_Interp Tcl_CreateInterp in/out
109'\" # BS - start boxed text
110'\" # ^y = starting y location
111'\" # ^b = 1
112.de BS
113.br
114.mk ^y
115.nr ^b 1u
116.if n .nf
117.if n .ti 0
118.if n \l'\\n(.lu\(ul'
119.if n .fi
120..
121'\" # BE - end boxed text (draw box now)
122.de BE
123.nf
124.ti 0
125.mk ^t
126.ie n \l'\\n(^lu\(ul'
127.el \{\
128.\" Draw four-sided box normally, but don't draw top of
129.\" box if the box started on an earlier page.
130.ie !\\n(^b-1 \{\
131\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132.\}
133.el \}\
134\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135.\}
136.\}
137.fi
138.br
139.nr ^b 0
140..
141'\" # VS - start vertical sidebar
142'\" # ^Y = starting y location
143'\" # ^v = 1 (for troff; for nroff this doesn't matter)
144.de VS
145.if !"\\$2"" .br
146.mk ^Y
147.ie n 'mc \s12\(br\s0
148.el .nr ^v 1u
149..
150'\" # VE - end of vertical sidebar
151.de VE
152.ie n 'mc
153.el \{\
154.ev 2
155.nf
156.ti 0
157.mk ^t
158\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159.sp -1
160.fi
161.ev
162.\}
163.nr ^v 0
164..
165'\" # Special macro to handle page bottom: finish off current
166'\" # box/sidebar if in box/sidebar mode, then invoked standard
167'\" # page bottom macro.
168.de ^B
169.ev 2
170'ti 0
171'nf
172.mk ^t
173.if \\n(^b \{\
174.\" Draw three-sided box if this is the box's first page,
175.\" draw two sides but no top otherwise.
176.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178.\}
179.if \\n(^v \{\
180.nr ^x \\n(^tu+1v-\\n(^Yu
181\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182.\}
183.bp
184'fi
185.ev
186.if \\n(^b \{\
187.mk ^y
188.nr ^b 2
189.\}
190.if \\n(^v \{\
191.mk ^Y
192.\}
193..
194'\" # DS - begin display
195.de DS
196.RS
197.nf
198.sp
199..
200'\" # DE - end display
201.de DE
202.fi
203.RE
204.sp
205..
206'\" # SO - start of list of standard options
207.de SO
208.SH "STANDARD OPTIONS"
209.LP
210.nf
211.ta 5.5c 11c
212.ft B
213..
214'\" # SE - end of list of standard options
215.de SE
216.fi
217.ft R
218.LP
219See the \\fBoptions\\fR manual entry for details on the standard options.
220..
221'\" # OP - start of full description for a single option
222.de OP
223.LP
224.nf
225.ta 4c
226Command-Line Name: \\fB\\$1\\fR
227Database Name: \\fB\\$2\\fR
228Database Class: \\fB\\$3\\fR
229.fi
230.IP
231..
232'\" # CS - begin code excerpt
233.de CS
234.RS
235.nf
236.ta .25i .5i .75i 1i
237..
238'\" # CE - end code excerpt
239.de CE
240.fi
241.RE
242..
243.de UL
244\\$1\l'|0\(ul'\\$2
245..
246.TH Tk_ConfigureWidget 3 4.1 Tk "Tk Library Procedures"
247.BS
248.SH NAME
249Tk_ConfigureWidget, Tk_ConfigureInfo, Tk_ConfigureValue, Tk_FreeOptions \- process configuration options for widgets
250.SH SYNOPSIS
251.nf
252\fB#include <tk.h>\fR
253.sp
254int
255\fBTk_ConfigureWidget(\fIinterp, tkwin, specs, argc, argv, widgRec, flags\fB)\fR
256.sp
257int
258\fBTk_ConfigureInfo(\fIinterp, tkwin, specs, widgRec, argvName, flags\fB)\fR
259.sp
260int
261\fBTk_ConfigureValue(\fIinterp, tkwin, specs, widgRec, argvName, flags\fB)\fR
262.sp
263\fBTk_FreeOptions(\fIspecs, widgRec, display, flags\fB)\fR
264.SH ARGUMENTS
265.AS Tk_ConfigSpec *widgRec in/out
266.AP Tcl_Interp *interp in
267Interpreter to use for returning error messages.
268.AP Tk_Window tkwin in
269Window used to represent widget (needed to set up X resources).
270.AP Tk_ConfigSpec *specs in
271Pointer to table specifying legal configuration options for this
272widget.
273.AP int argc in
274Number of arguments in \fIargv\fR.
275.AP "CONST char" **argv in
276Command-line options for configuring widget.
277.AP char *widgRec in/out
278Points to widget record structure. Fields in this structure get
279modified by \fBTk_ConfigureWidget\fR to hold configuration information.
280.AP int flags in
281If non-zero, then it specifies an OR-ed combination of flags that
282control the processing of configuration information.
283TK_CONFIG_ARGV_ONLY causes the option database and defaults to be
284ignored, and flag bits TK_CONFIG_USER_BIT and higher are used to
285selectively disable entries in \fIspecs\fR.
286.AP "type name" type in
287The name of the type of a widget record.
288.AP "field name" field in
289The name of a field in records of type \fItype\fR.
290.AP "CONST char" *argvName in
291The name used on Tcl command lines to refer to a particular option
292(e.g. when creating a widget or invoking the \fBconfigure\fR widget
293command). If non-NULL, then information is returned only for this
294option. If NULL, then information is returned for all available
295options.
296.AP Display *display in
297Display containing widget whose record is being freed; needed in
298order to free up resources.
299.BE
300.SH DESCRIPTION
301.VS 8.1
302.PP
303Note: \fBTk_ConfigureWidget\fP should be replaced with the new
304\fBTcl_Obj\fP based API \fBTk_SetOptions\fP. The old interface is
305retained for backward compatibility.
306.VE
307.PP
308\fBTk_ConfigureWidget\fR is called to configure various aspects of a
309widget, such as colors, fonts, border width, etc.
310It is intended as a convenience procedure to reduce the amount
311of code that must be written in individual widget managers to
312handle configuration information.
313It is typically
314invoked when widgets are created, and again when the \fBconfigure\fR
315command is invoked for a widget.
316Although intended primarily for widgets, \fBTk_ConfigureWidget\fR
317can be used in other situations where \fIargc-argv\fR information
318is to be used to fill in a record structure, such as configuring
319graphical elements for a canvas widget or entries of a menu.
320.PP
321\fBTk_ConfigureWidget\fR processes
322a table specifying the configuration options that are supported
323(\fIspecs\fR) and a collection of command-line arguments (\fIargc\fR and
324\fIargv\fR) to fill in fields of a record (\fIwidgRec\fR).
325It uses the option database and defaults specified in \fIspecs\fR
326to fill in fields of \fIwidgRec\fR that are not specified in \fIargv\fR.
327\fBTk_ConfigureWidget\fR normally returns the value TCL_OK; in this
328case it does not modify \fIinterp\fR.
329If an error
330occurs then TCL_ERROR is returned and \fBTk_ConfigureWidget\fR will
331leave an error message in \fIinterp->result\fR in the standard Tcl
332fashion.
333In the event of an error return, some of the fields of \fIwidgRec\fR
334could already have been set, if configuration information for them
335was successfully processed before the error occurred.
336The other fields will be set to reasonable initial values so that
337\fBTk_FreeOptions\fR can be called for cleanup.
338.PP
339The \fIspecs\fR array specifies the kinds of configuration options
340expected by the widget. Each of its entries specifies one configuration
341option and has the following structure:
342.CS
343typedef struct {
344 int \fItype\fR;
345 char *\fIargvName\fR;
346 char *\fIdbName\fR;
347 char *\fIdbClass\fR;
348 char *\fIdefValue\fR;
349 int \fIoffset\fR;
350 int \fIspecFlags\fR;
351 Tk_CustomOption *\fIcustomPtr\fR;
352} Tk_ConfigSpec;
353.CE
354The \fItype\fR field indicates what type of configuration option this is
355(e.g. TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for
356an integer value). The \fItype\fR field indicates how to use the
357value of the option (more on this below).
358The \fIargvName\fR field is a string such as ``\-font'' or ``\-bg'',
359which is compared with the values in \fIargv\fR (if \fIargvName\fR is
360NULL it means this is a grouped entry; see GROUPED ENTRIES below). The
361\fIdbName\fR and \fIdbClass\fR fields are used to look up a value
362for this option in the option database. The \fIdefValue\fR field
363specifies a default value for this configuration option if no
364value is specified in either \fIargv\fR or the option database.
365\fIOffset\fR indicates where in \fIwidgRec\fR to store information
366about this option, and \fIspecFlags\fR contains additional information
367to control the processing of this configuration option (see FLAGS
368below).
369The last field, \fIcustomPtr\fR, is only used if \fItype\fR is
370TK_CONFIG_CUSTOM; see CUSTOM OPTION TYPES below.
371.PP
372\fBTk_ConfigureWidget\fR first processes \fIargv\fR to see which
373(if any) configuration options are specified there. \fIArgv\fR
374must contain an even number of fields; the first of each pair
375of fields must match the \fIargvName\fR of some entry in \fIspecs\fR
376(unique abbreviations are acceptable),
377and the second field of the pair contains the value for that
378configuration option. If there are entries in \fIspec\fR for which
379there were no matching entries in \fIargv\fR,
380\fBTk_ConfigureWidget\fR uses the \fIdbName\fR and \fIdbClass\fR
381fields of the \fIspecs\fR entry to probe the option database; if
382a value is found, then it is used as the value for the option.
383Finally, if no entry is found in the option database, the
384\fIdefValue\fR field of the \fIspecs\fR entry is used as the
385value for the configuration option. If the \fIdefValue\fR is
386NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in
387\fIflags\fR, then there is no default value and this \fIspecs\fR entry
388will be ignored if no value is specified in \fIargv\fR or the
389option database.
390.PP
391Once a string value has been determined for a configuration option,
392\fBTk_ConfigureWidget\fR translates the string value into a more useful
393form, such as a color if \fItype\fR is TK_CONFIG_COLOR or an integer
394if \fItype\fR is TK_CONFIG_INT. This value is then stored in the
395record pointed to by \fIwidgRec\fR. This record is assumed to
396contain information relevant to the manager of the widget; its exact
397type is unknown to \fBTk_ConfigureWidget\fR. The \fIoffset\fR field
398of each \fIspecs\fR entry indicates where in \fIwidgRec\fR to store
399the information about this configuration option. You should use the
400\fBTk_Offset\fR macro to generate \fIoffset\fR values (see below for
401a description of \fBTk_Offset\fR). The location indicated by
402\fIwidgRec\fR and \fIoffset\fR will be referred to as the ``target''
403in the descriptions below.
404.PP
405The \fItype\fR field of each entry in \fIspecs\fR determines what
406to do with the string value of that configuration option. The
407legal values for \fItype\fR, and the corresponding actions, are:
408.TP
409\fBTK_CONFIG_ACTIVE_CURSOR\fR
410The value
411must be an ASCII string identifying a cursor in a form
412suitable for passing to \fBTk_GetCursor\fR.
413The value is converted to a \fBTk_Cursor\fR by calling
414\fBTk_GetCursor\fR and the result is stored in the target.
415In addition, the resulting cursor is made the active cursor
416for \fItkwin\fR by calling \fBXDefineCursor\fR.
417If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
418may be an empty string, in which case the target and \fItkwin\fR's
419active cursor will be set to \fBNone\fR.
420If the previous value of the target
421wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeCursor\fR.
422.TP
423\fBTK_CONFIG_ANCHOR\fR
424The value must be an ASCII string identifying an anchor point in one of the ways
425accepted by \fBTk_GetAnchor\fR.
426The string is converted to a \fBTk_Anchor\fR by calling
427\fBTk_GetAnchor\fR and the result is stored in the target.
428.TP
429\fBTK_CONFIG_BITMAP\fR
430The value must be an ASCII string identifying a bitmap in a form
431suitable for passing to \fBTk_GetBitmap\fR. The value is converted
432to a \fBPixmap\fR by calling \fBTk_GetBitmap\fR and the result
433is stored in the target.
434If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
435may be an empty string, in which case the target is set to \fBNone\fR.
436If the previous value of the target
437wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeBitmap\fR.
438.TP
439\fBTK_CONFIG_BOOLEAN\fR
440The value must be an ASCII string specifying a boolean value. Any
441of the values ``true'', ``yes'', ``on'', or ``1'',
442or an abbreviation of one of these values, means true;
443any of the values ``false'', ``no'', ``off'', or ``0'', or an abbreviation of
444one of these values, means false.
445The target is expected to be an integer; for true values it will
446be set to 1 and for false values it will be set to 0.
447.TP
448\fBTK_CONFIG_BORDER\fR
449The value must be an ASCII string identifying a border color in a form
450suitable for passing to \fBTk_Get3DBorder\fR. The value is converted
451to a (\fBTk_3DBorder *\fR) by calling \fBTk_Get3DBorder\fR and the result
452is stored in the target.
453If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
454may be an empty string, in which case the target will be set to NULL.
455If the previous value of the target
456wasn't NULL, then it is freed by passing it to \fBTk_Free3DBorder\fR.
457.TP
458\fBTK_CONFIG_CAP_STYLE\fR
459The value must be
460an ASCII string identifying a cap style in one of the ways
461accepted by \fBTk_GetCapStyle\fR.
462The string is converted to an integer value corresponding
463to the cap style by calling
464\fBTk_GetCapStyle\fR and the result is stored in the target.
465.TP
466\fBTK_CONFIG_COLOR\fR
467The value must be an ASCII string identifying a color in a form
468suitable for passing to \fBTk_GetColor\fR. The value is converted
469to an (\fBXColor *\fR) by calling \fBTk_GetColor\fR and the result
470is stored in the target.
471If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
472may be an empty string, in which case the target will be set to \fBNone\fR.
473If the previous value of the target
474wasn't NULL, then it is freed by passing it to \fBTk_FreeColor\fR.
475.TP
476\fBTK_CONFIG_CURSOR\fR
477This option is identical to \fBTK_CONFIG_ACTIVE_CURSOR\fR except
478that the new cursor is not made the active one for \fItkwin\fR.
479.TP
480\fBTK_CONFIG_CUSTOM\fR
481This option allows applications to define new option types.
482The \fIcustomPtr\fR field of the entry points to a structure
483defining the new option type.
484See the section CUSTOM OPTION TYPES below for details.
485.TP
486\fBTK_CONFIG_DOUBLE\fR
487The value must be an ASCII floating-point number in
488the format accepted by \fBstrtol\fR. The string is converted
489to a \fBdouble\fR value, and the value is stored in the
490target.
491.TP
492\fBTK_CONFIG_END\fR
493Marks the end of the table. The last entry in \fIspecs\fR
494must have this type; all of its other fields are ignored and it
495will never match any arguments.
496.TP
497\fBTK_CONFIG_FONT\fR
498The value must be an ASCII string identifying a font in a form
499suitable for passing to \fBTk_GetFont\fR. The value is converted
500to a \fBTk_Font\fR by calling \fBTk_GetFont\fR and the result
501is stored in the target.
502If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
503may be an empty string, in which case the target will be set to NULL.
504If the previous value of the target
505wasn't NULL, then it is freed by passing it to \fBTk_FreeFont\fR.
506.TP
507\fBTK_CONFIG_INT\fR
508The value must be an ASCII integer string
509in the format accepted by \fBstrtol\fR (e.g. ``0''
510and ``0x'' prefixes may be used to specify octal or hexadecimal
511numbers, respectively). The string is converted to an integer
512value and the integer is stored in the target.
513.TP
514\fBTK_CONFIG_JOIN_STYLE\fR
515The value must be
516an ASCII string identifying a join style in one of the ways
517accepted by \fBTk_GetJoinStyle\fR.
518The string is converted to an integer value corresponding
519to the join style by calling
520\fBTk_GetJoinStyle\fR and the result is stored in the target.
521.TP
522\fBTK_CONFIG_JUSTIFY\fR
523The value must be
524an ASCII string identifying a justification method in one of the
525ways accepted by \fBTk_GetJustify\fR.
526The string is converted to a \fBTk_Justify\fR by calling
527\fBTk_GetJustify\fR and the result is stored in the target.
528.TP
529\fBTK_CONFIG_MM\fR
530The value must specify a screen distance in one of the forms acceptable
531to \fBTk_GetScreenMM\fR.
532The string is converted to double-precision floating-point distance
533in millimeters and the value is stored in the target.
534.TP
535\fBTK_CONFIG_PIXELS\fR
536The value must specify screen units in one of the forms acceptable
537to \fBTk_GetPixels\fR.
538The string is converted to an integer distance in pixels and the
539value is stored in the target.
540.TP
541\fBTK_CONFIG_RELIEF\fR
542The value must be an ASCII string identifying a relief in a form
543suitable for passing to \fBTk_GetRelief\fR. The value is converted
544to an integer relief value by calling \fBTk_GetRelief\fR and the result
545is stored in the target.
546.TP
547\fBTK_CONFIG_STRING\fR
548A copy
549of the value is made by allocating memory space with
550\fBmalloc\fR and copying the value into the dynamically-allocated
551space. A pointer to the new string is stored in the target.
552If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
553may be an empty string, in which case the target will be set to NULL.
554If the previous value of the target wasn't NULL, then it is
555freed by passing it to \fBfree\fR.
556.TP
557\fBTK_CONFIG_SYNONYM\fR
558This \fItype\fR value identifies special entries in \fIspecs\fR that
559are synonyms for other entries. If an \fIargv\fR value matches the
560\fIargvName\fR of a TK_CONFIG_SYNONYM entry, the entry isn't used
561directly. Instead, \fBTk_ConfigureWidget\fR searches \fIspecs\fR
562for another entry whose \fIargvName\fR is the same as the \fIdbName\fR
563field in the TK_CONFIG_SYNONYM entry; this new entry is used just
564as if its \fIargvName\fR had matched the \fIargv\fR value. The
565synonym mechanism allows multiple \fIargv\fR values to be used for
566a single configuration option, such as ``\-background'' and ``\-bg''.
567.TP
568\fBTK_CONFIG_UID\fR
569The value is translated to a \fBTk_Uid\fR
570(by passing it to \fBTk_GetUid\fR). The resulting value
571is stored in the target.
572If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR and the value
573is an empty string then the target will be set to NULL.
574.TP
575\fBTK_CONFIG_WINDOW\fR
576The value must be a window path name. It is translated to a
577\fBTk_Window\fR token and the token is stored in the target.
578
579.SH "GROUPED ENTRIES"
580.PP
581In some cases it is useful to generate multiple resources from
582a single configuration value. For example, a color name might
583be used both to generate the background color for a widget (using
584TK_CONFIG_COLOR) and to generate a 3-D border to draw around the
585widget (using TK_CONFIG_BORDER). In cases like this it is possible
586to specify that several consecutive entries in \fIspecs\fR are to
587be treated as a group. The first entry is used to determine a value
588(using its \fIargvName\fR, \fIdbName\fR,
589\fIdbClass\fR, and \fIdefValue\fR fields). The value will be processed
590several times (one for each entry in the group), generating multiple
591different resources and modifying multiple targets within \fIwidgRec\fR.
592Each of the entries after the first must have a NULL value in its
593\fIargvName\fR field; this indicates that the entry is to be grouped
594with the entry that precedes it. Only the \fItype\fR and \fIoffset\fR
595fields are used from these follow-on entries.
596
597.SH "FLAGS"
598.PP
599The \fIflags\fR argument passed to \fBTk_ConfigureWidget\fR is used
600in conjunction with the \fIspecFlags\fR fields in the entries of \fIspecs\fR
601to provide additional control over the processing of configuration
602options. These values are used in three different ways as
603described below.
604.PP
605First, if the \fIflags\fR argument to \fBTk_ConfigureWidget\fR has
606the TK_CONFIG_ARGV_ONLY bit set (i.e., \fIflags\fR | TK_CONFIG_ARGV_ONLY != 0),
607then the option database and
608\fIdefValue\fR fields are not used. In this case, if an entry in
609\fIspecs\fR doesn't match a field in \fIargv\fR then nothing happens:
610the corresponding target isn't modified. This feature is useful
611when the goal is to modify certain configuration options while
612leaving others in their current state, such as when a \fBconfigure\fR
613widget command is being processed.
614.PP
615Second, the \fIspecFlags\fR field of an entry in \fIspecs\fR may be used
616to control the processing of that entry. Each \fIspecFlags\fR
617field may consists of an OR-ed combination of the following values:
618.TP
619\fBTK_CONFIG_COLOR_ONLY\fR
620If this bit is set then the entry will only be considered if the
621display for \fItkwin\fR has more than one bit plane. If the display
622is monochromatic then this \fIspecs\fR entry will be ignored.
623.TP
624\fBTK_CONFIG_MONO_ONLY\fR
625If this bit is set then the entry will only be considered if the
626display for \fItkwin\fR has exactly one bit plane. If the display
627is not monochromatic then this \fIspecs\fR entry will be ignored.
628.TP
629\fBTK_CONFIG_NULL_OK\fR
630This bit is only relevant for some types of entries (see the
631descriptions of the various entry types above).
632If this bit is set, it indicates that an empty string value
633for the field is acceptable and if it occurs then the
634target should be set to NULL or \fBNone\fR, depending
635on the type of the target.
636This flag is typically used to allow a
637feature to be turned off entirely, e.g. set a cursor value to
638\fBNone\fR so that a window simply inherits its parent's cursor.
639If this bit isn't set then empty strings are processed as strings,
640which generally results in an error.
641.TP
642\fBTK_CONFIG_DONT_SET_DEFAULT\fR
643If this bit is one, it means that the \fIdefValue\fR field of the
644entry should only be used for returning the default value in
645\fBTk_ConfigureInfo\fR.
646In calls to \fBTk_ConfigureWidget\fR no default will be supplied
647for entries with this flag set; it is assumed that the
648caller has already supplied a default value in the target location.
649This flag provides a performance optimization where it is expensive
650to process the default string: the client can compute the default
651once, save the value, and provide it before calling
652\fBTk_ConfigureWidget\fR.
653.TP
654\fBTK_CONFIG_OPTION_SPECIFIED\fR
655This bit is set and cleared by \fBTk_ConfigureWidget\fR. Whenever
656\fBTk_ConfigureWidget\fR returns, this bit will be set in all the
657entries where a value was specified in \fIargv\fR.
658It will be zero in all other entries.
659This bit provides a way for clients to determine which values
660actually changed in a call to \fBTk_ConfigureWidget\fR.
661.PP
662The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically
663used to specify different default values for
664monochrome and color displays. This is done by creating two
665entries in \fIspecs\fR that are identical except for their
666\fIdefValue\fR and \fIspecFlags\fR fields. One entry should have
667the value TK_CONFIG_MONO_ONLY in its \fIspecFlags\fR and the
668default value for monochrome displays in its \fIdefValue\fR; the
669other entry entry should have the value TK_CONFIG_COLOR_ONLY in
670its \fIspecFlags\fR and the appropriate \fIdefValue\fR for
671color displays.
672.PP
673Third, it is possible to use \fIflags\fR and \fIspecFlags\fR
674together to selectively disable some entries. This feature is
675not needed very often. It is useful in cases where several
676similar kinds of widgets are implemented in one place. It allows
677a single \fIspecs\fR table to be created with all the configuration
678options for all the widget types. When processing a particular
679widget type, only entries relevant to that type will be used. This
680effect is achieved by setting the high-order bits (those in positions
681equal to or greater than TK_CONFIG_USER_BIT) in \fIspecFlags\fR
682values or in \fIflags\fR. In order for a particular entry in
683\fIspecs\fR to be used, its high-order bits must match exactly
684the high-order bits of the \fIflags\fR value passed to
685\fBTk_ConfigureWidget\fR. If a \fIspecs\fR table is being used
686for N different widget types, then N of the high-order bits will
687be used. Each \fIspecs\fR entry will have one of more of those
688bits set in its \fIspecFlags\fR field to indicate the widget types
689for which this entry is valid. When calling \fBTk_ConfigureWidget\fR,
690\fIflags\fR will have a single one of these bits set to select the
691entries for the desired widget type. For a working example of
692this feature, see the code in tkButton.c.
693
694.SH TK_OFFSET
695.PP
696The \fBTk_Offset\fR macro is provided as a safe way of generating
697the \fIoffset\fR values for entries in Tk_ConfigSpec structures.
698It takes two arguments: the name of a type of record, and the
699name of a field in that record. It returns the byte offset of
700the named field in records of the given type.
701
702.SH TK_CONFIGUREINFO
703.PP
704The \fBTk_ConfigureInfo\fR procedure may be used to obtain
705information about one or all of the options for a given widget.
706Given a token for a window (\fItkwin\fR), a table describing the
707configuration options for a class of widgets (\fIspecs\fR), a
708pointer to a widget record containing the current information for
709a widget (\fIwidgRec\fR), and a NULL \fIargvName\fR argument,
710\fBTk_ConfigureInfo\fR generates a string describing all of the
711configuration options for the window. The string is placed
712in \fIinterp->result\fR. Under normal circumstances
713it returns TCL_OK; if an error occurs then it returns TCL_ERROR
714and \fIinterp->result\fR contains an error message.
715.PP
716If \fIargvName\fR is NULL, then the value left in
717\fIinterp->result\fR by \fBTk_ConfigureInfo\fR
718consists of a list of one or more entries, each of which describes
719one configuration option (i.e. one entry in \fIspecs\fR). Each
720entry in the list will contain either two or five values. If the
721corresponding entry in \fIspecs\fR has type TK_CONFIG_SYNONYM, then
722the list will contain two values: the \fIargvName\fR for the entry
723and the \fIdbName\fR (synonym name). Otherwise the list will contain
724five values: \fIargvName\fR, \fIdbName\fR, \fIdbClass\fR, \fIdefValue\fR,
725and current value. The current value is computed from the appropriate
726field of \fIwidgRec\fR by calling procedures like \fBTk_NameOfColor\fR.
727.PP
728If the \fIargvName\fR argument to \fBTk_ConfigureInfo\fR is non-NULL,
729then it indicates a single option, and information is returned only
730for that option. The string placed in \fIinterp->result\fR will be
731a list containing two or five values as described above; this will
732be identical to the corresponding sublist that would have been returned
733if \fIargvName\fR had been NULL.
734.PP
735The \fIflags\fR argument to \fBTk_ConfigureInfo\fR is used to restrict
736the \fIspecs\fR entries to consider, just as for \fBTk_ConfigureWidget\fR.
737
738.SH TK_CONFIGUREVALUE
739.PP
740\fBTk_ConfigureValue\fR takes arguments similar to \fBTk_ConfigureInfo\fR;
741instead of returning a list of values, it just returns the current value
742of the option given by \fIargvName\fR (\fIargvName\fR must not be NULL).
743The value is returned in \fIinterp->result\fR and TCL_OK is
744normally returned as the procedure's result.
745If an error occurs in \fBTk_ConfigureValue\fR (e.g., \fIargvName\fR is
746not a valid option name), TCL_ERROR is returned and an error message
747is left in \fIinterp->result\fR.
748This procedure is typically called to implement \fBcget\fR widget
749commands.
750
751.SH TK_FREEOPTIONS
752.PP
753The \fBTk_FreeOptions\fR procedure may be invoked during widget cleanup
754to release all of the resources associated with configuration options.
755It scans through \fIspecs\fR and for each entry corresponding to a
756resource that must be explicitly freed (e.g. those with
757type TK_CONFIG_COLOR), it frees the resource in the widget record.
758If the field in the widget record doesn't refer to a resource (e.g.
759it contains a null pointer) then no resource is freed for that
760entry.
761After freeing a resource, \fBTk_FreeOptions\fR sets the
762corresponding field of the widget record to null.
763
764.SH "CUSTOM OPTION TYPES"
765.PP
766Applications can extend the built-in configuration types with additional
767configuration types by writing procedures to parse and print options
768of the a type and creating a structure pointing to those procedures:
769.CS
770typedef struct Tk_CustomOption {
771 Tk_OptionParseProc *\fIparseProc\fR;
772 Tk_OptionPrintProc *\fIprintProc\fR;
773 ClientData \fIclientData\fR;
774} Tk_CustomOption;
775
776typedef int Tk_OptionParseProc(
777 ClientData \fIclientData\fR,
778 Tcl_Interp *\fIinterp\fR,
779 Tk_Window \fItkwin\fR,
780 char *\fIvalue\fR,
781 char *\fIwidgRec\fR,
782 int \fIoffset\fR);
783
784typedef char *Tk_OptionPrintProc(
785 ClientData \fIclientData\fR,
786 Tk_Window \fItkwin\fR,
787 char *\fIwidgRec\fR,
788 int \fIoffset\fR,
789 Tcl_FreeProc **\fIfreeProcPtr\fR);
790.CE
791The Tk_CustomOption structure contains three fields, which are pointers
792to the two procedures and a \fIclientData\fR value to be passed to those
793procedures when they are invoked. The \fIclientData\fR value typically
794points to a structure containing information that is needed by the
795procedures when they are parsing and printing options.
796.PP
797The \fIparseProc\fR procedure is invoked by
798\fBTk_ConfigureWidget\fR to parse a string and store the resulting
799value in the widget record.
800The \fIclientData\fR argument is a copy of the \fIclientData\fR
801field in the Tk_CustomOption structure.
802The \fIinterp\fR argument points to a Tcl interpreter used for
803error reporting. \fITkwin\fR is a copy of the \fItkwin\fR argument
804to \fBTk_ConfigureWidget\fR. The \fIvalue\fR argument is a string
805describing the value for the option; it could have been specified
806explicitly in the call to \fBTk_ConfigureWidget\fR or it could
807come from the option database or a default.
808\fIValue\fR will never be a null pointer but it may point to
809an empty string.
810\fIRecordPtr\fR is the same as the \fIwidgRec\fR argument to
811\fBTk_ConfigureWidget\fR; it points to the start of the widget
812record to modify.
813The last argument, \fIoffset\fR, gives the offset in bytes from the start
814of the widget record to the location where the option value is to
815be placed. The procedure should translate the string to whatever
816form is appropriate for the option and store the value in the widget
817record. It should normally return TCL_OK, but if an error occurs
818in translating the string to a value then it should return TCL_ERROR
819and store an error message in \fIinterp->result\fR.
820.PP
821The \fIprintProc\fR procedure is called
822by \fBTk_ConfigureInfo\fR to produce a string value describing an
823existing option.
824Its \fIclientData\fR, \fItkwin\fR, \fIwidgRec\fR, and \fIoffset\fR
825arguments all have the same meaning as for Tk_OptionParseProc
826procedures.
827The \fIprintProc\fR procedure should examine the option whose value
828is stored at \fIoffset\fR in \fIwidgRec\fR, produce a string describing
829that option, and return a pointer to the string.
830If the string is stored in dynamically-allocated memory, then
831the procedure must set \fI*freeProcPtr\fR to the address of
832a procedure to call to free the string's memory; \fBTk_ConfigureInfo\fR
833will call this procedure when it is finished with the string.
834If the result string is stored in static memory then \fIprintProc\fR
835need not do anything with the \fIfreeProcPtr\fR argument.
836.PP
837Once \fIparseProc\fR and \fIprintProc\fR have been defined and a
838Tk_CustomOption structure has been created for them, options of this
839new type may be manipulated with Tk_ConfigSpec entries whose \fItype\fR
840fields are TK_CONFIG_CUSTOM and whose \fIcustomPtr\fR fields point
841to the Tk_CustomOption structure.
842
843.SH EXAMPLES
844.PP
845Although the explanation of \fBTk_ConfigureWidget\fR is fairly
846complicated, its actual use is pretty straightforward.
847The easiest way to get started is to copy the code
848from an existing widget.
849The library implementation of frames
850(tkFrame.c) has a simple configuration table, and the library
851implementation of buttons (tkButton.c) has a much more complex
852table that uses many of the fancy \fIspecFlags\fR mechanisms.
853
854.SH "SEE ALSO"
855Tk_SetOptions(3)
856
857.SH KEYWORDS
858anchor, bitmap, boolean, border, cap style, color, configuration options,
859cursor, custom, double, font, integer, join style, justify, millimeters,
860pixels, relief, synonym, uid