OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / ALPHALINUX5 / util / ALPHALINUX5 / man / man3 / Tk_ConfigureValue.3
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.5 1999/04/21 21:53:20 rjohnson 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.3 1999/04/16 00:46:35 stanton 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 4c 8c 12c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See 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
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database 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
249 Tk_ConfigureWidget, Tk_Offset, Tk_ConfigureInfo, Tk_ConfigureValue, Tk_FreeOptions \- process configuration options for widgets
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tk.h>\fR
253 .sp
254 int
255 \fBTk_ConfigureWidget(\fIinterp, tkwin, specs, argc, argv, widgRec, flags\fB)\fR
256 .sp
257 int
258 \fBTk_Offset(\fItype, field\fB)\fR
259 .sp
260 int
261 \fBTk_ConfigureInfo(\fIinterp, tkwin, specs, widgRec, argvName, flags\fB)\fR
262 .sp
263 int
264 \fBTk_ConfigureValue(\fIinterp, tkwin, specs, widgRec, argvName, flags\fB)\fR
265 .sp
266 \fBTk_FreeOptions(\fIspecs, widgRec, display, flags\fB)\fR
267 .SH ARGUMENTS
268 .AS Tk_ConfigSpec *widgRec in/out
269 .AP Tcl_Interp *interp in
270 Interpreter to use for returning error messages.
271 .AP Tk_Window tkwin in
272 Window used to represent widget (needed to set up X resources).
273 .AP Tk_ConfigSpec *specs in
274 Pointer to table specifying legal configuration options for this
275 widget.
276 .AP int argc in
277 Number of arguments in \fIargv\fR.
278 .AP char **argv in
279 Command-line options for configuring widget.
280 .AP char *widgRec in/out
281 Points to widget record structure.  Fields in this structure get
282 modified by \fBTk_ConfigureWidget\fR to hold configuration information.
283 .AP int flags in
284 If non-zero, then it specifies an OR-ed combination of flags that
285 control the processing of configuration information.
286 TK_CONFIG_ARGV_ONLY causes the option database and defaults to be
287 ignored, and flag bits TK_CONFIG_USER_BIT and higher are used to
288 selectively disable entries in \fIspecs\fR.
289 .AP "type name" type in
290 The name of the type of a widget record.
291 .AP "field name" field in
292 The name of a field in records of type \fItype\fR.
293 .AP char *argvName in
294 The name used on Tcl command lines to refer to a particular option
295 (e.g. when creating a widget or invoking the \fBconfigure\fR widget
296 command).  If non-NULL, then information is returned only for this
297 option.  If NULL, then information is returned for all available
298 options.
299 .AP Display *display in
300 Display containing widget whose record is being freed;  needed in
301 order to free up resources.
302 .BE
303 .SH DESCRIPTION
304 .PP
305 \fBTk_ConfigureWidget\fR is called to configure various aspects of a
306 widget, such as colors, fonts, border width, etc.
307 It is intended as a convenience procedure to reduce the amount
308 of code that must be written in individual widget managers to
309 handle configuration information.
310 It is typically
311 invoked when widgets are created, and again when the \fBconfigure\fR
312 command is invoked for a widget.
313 Although intended primarily for widgets, \fBTk_ConfigureWidget\fR
314 can be used in other situations where \fIargc-argv\fR information
315 is to be used to fill in a record structure, such as configuring
316 graphical elements for a canvas widget or entries of a menu.
317 .PP
318 \fBTk_ConfigureWidget\fR processes
319 a table specifying the configuration options that are supported
320 (\fIspecs\fR) and a collection of command-line arguments (\fIargc\fR and
321 \fIargv\fR) to fill in fields of a record (\fIwidgRec\fR).
322 It uses the option database and defaults specified in \fIspecs\fR
323 to fill in fields of \fIwidgRec\fR that are not specified in \fIargv\fR.
324 \fBTk_ConfigureWidget\fR normally returns the value TCL_OK; in this
325 case it does not modify \fIinterp\fR.
326 If an error
327 occurs then TCL_ERROR is returned and \fBTk_ConfigureWidget\fR will
328 leave an error message in \fIinterp->result\fR in the standard Tcl
329 fashion.
330 In the event of an error return, some of the fields of \fIwidgRec\fR
331 could already have been set, if configuration information for them
332 was successfully processed before the error occurred.
333 The other fields will be set to reasonable initial values so that
334 \fBTk_FreeOptions\fR can be called for cleanup.
335 .PP
336 The \fIspecs\fR array specifies the kinds of configuration options
337 expected by the widget.  Each of its entries specifies one configuration
338 option and has the following structure:
339 .CS
340 typedef struct {
341         int \fItype\fR;
342         char *\fIargvName\fR;
343         char *\fIdbName\fR;
344         char *\fIdbClass\fR;
345         char *\fIdefValue\fR;
346         int \fIoffset\fR;
347         int \fIspecFlags\fR;
348         Tk_CustomOption *\fIcustomPtr\fR;
349 } Tk_ConfigSpec;
350 .CE
351 The \fItype\fR field indicates what type of configuration option this is
352 (e.g. TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for
353 an integer value).  The \fItype\fR field indicates how to use the
354 value of the option (more on this below).
355 The \fIargvName\fR field is a string such as ``\-font'' or ``\-bg'',
356 which is compared with the values in \fIargv\fR (if \fIargvName\fR is
357 NULL it means this is a grouped entry;  see GROUPED ENTRIES below).  The
358 \fIdbName\fR and \fIdbClass\fR fields are used to look up a value
359 for this option in the option database.  The \fIdefValue\fR field
360 specifies a default value for this configuration option if no
361 value is specified in either \fIargv\fR or the option database.
362 \fIOffset\fR indicates where in \fIwidgRec\fR to store information
363 about this option, and \fIspecFlags\fR contains additional information
364 to control the processing of this configuration option (see FLAGS
365 below).
366 The last field, \fIcustomPtr\fR, is only used if \fItype\fR is
367 TK_CONFIG_CUSTOM;  see CUSTOM OPTION TYPES below.
368 .PP
369 \fBTk_ConfigureWidget\fR first processes \fIargv\fR to see which
370 (if any) configuration options are specified there.  \fIArgv\fR
371 must contain an even number of fields;  the first of each pair
372 of fields must match the \fIargvName\fR of some entry in \fIspecs\fR
373 (unique abbreviations are acceptable),
374 and the second field of the pair contains the value for that
375 configuration option.  If there are entries in \fIspec\fR for which
376 there were no matching entries in \fIargv\fR,
377 \fBTk_ConfigureWidget\fR uses the \fIdbName\fR and \fIdbClass\fR
378 fields of the \fIspecs\fR entry to probe the option database;  if
379 a value is found, then it is used as the value for the option.
380 Finally, if no entry is found in the option database, the
381 \fIdefValue\fR field of the \fIspecs\fR entry is used as the
382 value for the configuration option.  If the \fIdefValue\fR is
383 NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in
384 \fIflags\fR, then there is no default value and this \fIspecs\fR entry
385 will be ignored if no value is specified in \fIargv\fR or the
386 option database.
387 .PP
388 Once a string value has been determined for a configuration option,
389 \fBTk_ConfigureWidget\fR translates the string value into a more useful
390 form, such as a color if \fItype\fR is TK_CONFIG_COLOR or an integer
391 if \fItype\fR is TK_CONFIG_INT.  This value is then stored in the
392 record pointed to by \fIwidgRec\fR.  This record is assumed to
393 contain information relevant to the manager of the widget;  its exact
394 type is unknown to \fBTk_ConfigureWidget\fR.  The \fIoffset\fR field
395 of each \fIspecs\fR entry indicates where in \fIwidgRec\fR to store
396 the information about this configuration option.  You should use the
397 \fBTk_Offset\fR macro to generate \fIoffset\fR values (see below for
398 a description of \fBTk_Offset\fR).  The location indicated by
399 \fIwidgRec\fR and \fIoffset\fR will be referred to as the ``target''
400 in the descriptions below.
401 .PP
402 The \fItype\fR field of each entry in \fIspecs\fR determines what
403 to do with the string value of that configuration option.  The
404 legal values for \fItype\fR, and the corresponding actions, are:
405 .TP
406 \fBTK_CONFIG_ACTIVE_CURSOR\fR
407 The value
408 must be an ASCII string identifying a cursor in a form
409 suitable for passing to \fBTk_GetCursor\fR. 
410 The value is converted to a \fBTk_Cursor\fR by calling
411 \fBTk_GetCursor\fR and the result is stored in the target.
412 In addition, the resulting cursor is made the active cursor
413 for \fItkwin\fR by calling \fBXDefineCursor\fR.
414 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
415 may be an empty string, in which case the target and \fItkwin\fR's
416 active cursor will be set to \fBNone\fR.
417 If the previous value of the target
418 wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeCursor\fR.
419 .TP
420 \fBTK_CONFIG_ANCHOR\fR
421 The value must be an ASCII string identifying an anchor point in one of the ways
422 accepted by \fBTk_GetAnchor\fR.
423 The string is converted to a \fBTk_Anchor\fR by calling
424 \fBTk_GetAnchor\fR and the result is stored in the target.
425 .TP
426 \fBTK_CONFIG_BITMAP\fR
427 The value must be an ASCII string identifying a bitmap in a form
428 suitable for passing to \fBTk_GetBitmap\fR.  The value is converted
429 to a \fBPixmap\fR by calling \fBTk_GetBitmap\fR and the result
430 is stored in the target.
431 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
432 may be an empty string, in which case the target is set to \fBNone\fR.
433 If the previous value of the target
434 wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeBitmap\fR.
435 .TP
436 \fBTK_CONFIG_BOOLEAN\fR
437 The value must be an ASCII string specifying a boolean value.  Any
438 of the values ``true'', ``yes'', ``on'', or ``1'',
439 or an abbreviation of one of these values, means true;
440 any of the values ``false'', ``no'', ``off'', or ``0'', or an abbreviation of
441 one of these values, means false.
442 The target is expected to be an integer;  for true values it will
443 be set to 1 and for false values it will be set to 0.
444 .TP
445 \fBTK_CONFIG_BORDER\fR
446 The value must be an ASCII string identifying a border color in a form
447 suitable for passing to \fBTk_Get3DBorder\fR.  The value is converted
448 to a (\fBTk_3DBorder *\fR) by calling \fBTk_Get3DBorder\fR and the result
449 is stored in the target.
450 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
451 may be an empty string, in which case the target will be set to NULL.
452 If the previous value of the target
453 wasn't NULL, then it is freed by passing it to \fBTk_Free3DBorder\fR.
454 .TP
455 \fBTK_CONFIG_CAP_STYLE\fR
456 The value must be
457 an ASCII string identifying a cap style in one of the ways
458 accepted by \fBTk_GetCapStyle\fR.
459 The string is converted to an integer value corresponding
460 to the cap style by calling
461 \fBTk_GetCapStyle\fR and the result is stored in the target.
462 .TP
463 \fBTK_CONFIG_COLOR\fR
464 The value must be an ASCII string identifying a color in a form
465 suitable for passing to \fBTk_GetColor\fR.  The value is converted
466 to an (\fBXColor *\fR) by calling \fBTk_GetColor\fR and the result
467 is stored in the target.
468 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
469 may be an empty string, in which case the target will be set to \fBNone\fR.
470 If the previous value of the target
471 wasn't NULL, then it is freed by passing it to \fBTk_FreeColor\fR.
472 .TP
473 \fBTK_CONFIG_CURSOR\fR
474 This option is identical to \fBTK_CONFIG_ACTIVE_CURSOR\fR except
475 that the new cursor is not made the active one for \fItkwin\fR.
476 .TP
477 \fBTK_CONFIG_CUSTOM\fR
478 This option allows applications to define new option types.
479 The \fIcustomPtr\fR field of the entry points to a structure
480 defining the new option type.
481 See the section CUSTOM OPTION TYPES below for details.
482 .TP
483 \fBTK_CONFIG_DOUBLE\fR
484 The value must be an ASCII floating-point number in
485 the format accepted by \fBstrtol\fR.  The string is converted
486 to a \fBdouble\fR value, and the value is stored in the
487 target.
488 .TP
489 \fBTK_CONFIG_END\fR
490 Marks the end of the table.  The last entry in \fIspecs\fR
491 must have this type;  all of its other fields are ignored and it
492 will never match any arguments.
493 .TP
494 \fBTK_CONFIG_FONT\fR
495 The value must be an ASCII string identifying a font in a form
496 suitable for passing to \fBTk_GetFont\fR.  The value is converted
497 to an (\fBXFontStruct *\fR) by calling \fBTk_GetFont\fR and the result
498 is stored in the target.
499 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
500 may be an empty string, in which case the target will be set to NULL.
501 If the previous value of the target
502 wasn't NULL, then it is freed by passing it to \fBTk_FreeFont\fR.
503 .TP
504 \fBTK_CONFIG_INT\fR
505 The value must be an ASCII integer string
506 in the format accepted by \fBstrtol\fR (e.g. ``0''
507 and ``0x'' prefixes may be used to specify octal or hexadecimal
508 numbers, respectively).  The string is converted to an integer
509 value and the integer is stored in the target.
510 .TP
511 \fBTK_CONFIG_JOIN_STYLE\fR
512 The value must be
513 an ASCII string identifying a join style in one of the ways
514 accepted by \fBTk_GetJoinStyle\fR.
515 The string is converted to an integer value corresponding
516 to the join style by calling
517 \fBTk_GetJoinStyle\fR and the result is stored in the target.
518 .TP
519 \fBTK_CONFIG_JUSTIFY\fR
520 The value must be
521 an ASCII string identifying a justification method in one of the
522 ways accepted by \fBTk_GetJustify\fR.
523 The string is converted to a \fBTk_Justify\fR by calling
524 \fBTk_GetJustify\fR and the result is stored in the target.
525 .TP
526 \fBTK_CONFIG_MM\fR
527 The value must specify a screen distance in one of the forms acceptable
528 to \fBTk_GetScreenMM\fR.
529 The string is converted to double-precision floating-point distance
530 in millimeters and the value is stored in the target.
531 .TP
532 \fBTK_CONFIG_PIXELS\fR
533 The value must specify screen units in one of the forms acceptable
534 to \fBTk_GetPixels\fR.
535 The string is converted to an integer distance in pixels and the
536 value is stored in the target.
537 .TP
538 \fBTK_CONFIG_RELIEF\fR
539 The value must be an ASCII string identifying a relief in a form
540 suitable for passing to \fBTk_GetRelief\fR.  The value is converted
541 to an integer relief value by calling \fBTk_GetRelief\fR and the result
542 is stored in the target.
543 .TP
544 \fBTK_CONFIG_STRING\fR
545 A copy
546 of the value is made by allocating memory space with
547 \fBmalloc\fR and copying the value into the dynamically-allocated
548 space.  A pointer to the new string is stored in the target.
549 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
550 may be an empty string, in which case the target will be set to NULL.
551 If the previous value of the target wasn't NULL, then it is
552 freed by passing it to \fBfree\fR.
553 .TP
554 \fBTK_CONFIG_SYNONYM\fR
555 This \fItype\fR value identifies special entries in \fIspecs\fR that
556 are synonyms for other entries.  If an \fIargv\fR value matches the
557 \fIargvName\fR of a TK_CONFIG_SYNONYM entry, the entry isn't used
558 directly. Instead, \fBTk_ConfigureWidget\fR searches \fIspecs\fR
559 for another entry whose \fIargvName\fR is the same as the \fIdbName\fR
560 field in the TK_CONFIG_SYNONYM entry;  this new entry is used just
561 as if its \fIargvName\fR had matched the \fIargv\fR value.  The
562 synonym mechanism allows multiple \fIargv\fR values to be used for
563 a single configuration option, such as ``\-background'' and ``\-bg''.
564 .TP
565 \fBTK_CONFIG_UID\fR
566 The value is translated to a \fBTk_Uid\fR
567 (by passing it to \fBTk_GetUid\fR).  The resulting value
568 is stored in the target.
569 If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR and the value
570 is an empty string then the target will be set to NULL.
571 .TP
572 \fBTK_CONFIG_WINDOW\fR
573 The value must be a window path name.  It is translated to a
574 \fBTk_Window\fR token and the token is stored in the target.
575
576 .SH "GROUPED ENTRIES"
577 .PP
578 In some cases it is useful to generate multiple resources from
579 a single configuration value.  For example, a color name might
580 be used both to generate the background color for a widget (using
581 TK_CONFIG_COLOR) and to generate a 3-D border to draw around the
582 widget (using TK_CONFIG_BORDER).  In cases like this it is possible
583 to specify that several consecutive entries in \fIspecs\fR are to
584 be treated as a group.  The first entry is used to determine a value
585 (using its \fIargvName\fR, \fIdbName\fR,
586 \fIdbClass\fR, and \fIdefValue\fR fields).  The value will be processed
587 several times (one for each entry in the group), generating multiple
588 different resources and modifying multiple targets within \fIwidgRec\fR.
589 Each of the entries after the first must have a NULL value in its
590 \fIargvName\fR field;  this indicates that the entry is to be grouped
591 with the entry that precedes it.  Only the \fItype\fR and \fIoffset\fR
592 fields are used from these follow-on entries.
593
594 .SH "FLAGS"
595 .PP
596 The \fIflags\fR argument passed to \fBTk_ConfigureWidget\fR is used
597 in conjunction with the \fIspecFlags\fR fields in the entries of \fIspecs\fR
598 to provide additional control over the processing of configuration
599 options.  These values are used in three different ways as
600 described below.
601 .PP
602 First, if the \fIflags\fR argument to \fBTk_ConfigureWidget\fR has
603 the TK_CONFIG_ARGV_ONLY bit set (i.e., \fIflags\fR | TK_CONFIG_ARGV_ONLY != 0),
604 then the option database and
605 \fIdefValue\fR fields are not used.  In this case, if an entry in
606 \fIspecs\fR doesn't match a field in \fIargv\fR then nothing happens:
607 the corresponding target isn't modified.  This feature is useful
608 when the goal is to modify certain configuration options while
609 leaving others in their current state, such as when a \fBconfigure\fR
610 widget command is being processed.
611 .PP
612 Second, the \fIspecFlags\fR field of an entry in \fIspecs\fR may be used
613 to control the processing of that entry.  Each \fIspecFlags\fR
614 field may consists of an OR-ed combination of the following values:
615 .TP
616 \fBTK_CONFIG_COLOR_ONLY\fR
617 If this bit is set then the entry will only be considered if the
618 display for \fItkwin\fR has more than one bit plane.  If the display
619 is monochromatic then this \fIspecs\fR entry will be ignored.
620 .TP
621 \fBTK_CONFIG_MONO_ONLY\fR
622 If this bit is set then the entry will only be considered if the
623 display for \fItkwin\fR has exactly one bit plane.  If the display
624 is not monochromatic then this \fIspecs\fR entry will be ignored.
625 .TP
626 \fBTK_CONFIG_NULL_OK\fR
627 This bit is only relevant for some types of entries (see the
628 descriptions of the various entry types above).
629 If this bit is set, it indicates that an empty string value
630 for the field is acceptable and if it occurs then the
631 target should be set to NULL or \fBNone\fR, depending
632 on the type of the target.
633 This flag is typically used to allow a
634 feature to be turned off entirely, e.g. set a cursor value to
635 \fBNone\fR so that a window simply inherits its parent's cursor.
636 If this bit isn't set then empty strings are processed as strings,
637 which generally results in an error.
638 .TP
639 \fBTK_CONFIG_DONT_SET_DEFAULT\fR
640 If this bit is one, it means that the \fIdefValue\fR field of the
641 entry should only be used for returning the default value in
642 \fBTk_ConfigureInfo\fR.
643 In calls to \fBTk_ConfigureWidget\fR no default will be supplied
644 for entries with this flag set;  it is assumed that the
645 caller has already supplied a default value in the target location.
646 This flag provides a performance optimization where it is expensive
647 to process the default string:  the client can compute the default
648 once, save the value, and provide it before calling
649 \fBTk_ConfigureWidget\fR.
650 .TP
651 \fBTK_CONFIG_OPTION_SPECIFIED\fR
652 This bit is set and cleared by \fBTk_ConfigureWidget\fR.  Whenever
653 \fBTk_ConfigureWidget\fR returns, this bit will be set in all the
654 entries where a value was specified in \fIargv\fR.
655 It will be zero in all other entries.
656 This bit provides a way for clients to determine which values
657 actually changed in a call to \fBTk_ConfigureWidget\fR.
658 .PP
659 The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically
660 used to specify different default values for
661 monochrome and color displays.  This is done by creating two
662 entries in \fIspecs\fR that are identical except for their
663 \fIdefValue\fR and \fIspecFlags\fR fields.  One entry should have
664 the value TK_CONFIG_MONO_ONLY in its \fIspecFlags\fR and the
665 default value for monochrome displays in its \fIdefValue\fR;  the
666 other entry entry should have the value TK_CONFIG_COLOR_ONLY in
667 its \fIspecFlags\fR and the appropriate \fIdefValue\fR for
668 color displays.
669 .PP
670 Third, it is possible to use \fIflags\fR and \fIspecFlags\fR
671 together to selectively disable some entries.  This feature is
672 not needed very often.  It is useful in cases where several
673 similar kinds of widgets are implemented in one place.  It allows
674 a single \fIspecs\fR table to be created with all the configuration
675 options for all the widget types.  When processing a particular
676 widget type, only entries relevant to that type will be used.  This
677 effect is achieved by setting the high-order bits (those in positions
678 equal to or greater than TK_CONFIG_USER_BIT) in \fIspecFlags\fR
679 values or in \fIflags\fR.  In order for a particular entry in
680 \fIspecs\fR to be used, its high-order bits must match exactly
681 the high-order bits of the \fIflags\fR value passed to
682 \fBTk_ConfigureWidget\fR.  If a \fIspecs\fR table is being used
683 for N different widget types, then N of the high-order bits will
684 be used.  Each \fIspecs\fR entry will have one of more of those
685 bits set in its \fIspecFlags\fR field to indicate the widget types
686 for which this entry is valid.  When calling \fBTk_ConfigureWidget\fR,
687 \fIflags\fR will have a single one of these bits set to select the
688 entries for the desired widget type.  For a working example of
689 this feature, see the code in tkButton.c.
690
691 .SH TK_OFFSET
692 .PP
693 The \fBTk_Offset\fR macro is provided as a safe way of generating
694 the \fIoffset\fR values for entries in Tk_ConfigSpec structures.
695 It takes two arguments:  the name of a type of record, and the
696 name of a field in that record.  It returns the byte offset of
697 the named field in records of the given type.
698
699 .SH TK_CONFIGUREINFO
700 .PP
701 The \fBTk_ConfigureInfo\fR procedure may be used to obtain
702 information about one or all of the options for a given widget.
703 Given a token for a window (\fItkwin\fR), a table describing the
704 configuration options for a class of widgets (\fIspecs\fR), a
705 pointer to a widget record containing the current information for
706 a widget (\fIwidgRec\fR), and a NULL \fIargvName\fR argument,
707 \fBTk_ConfigureInfo\fR generates a string describing all of the
708 configuration options for the window.  The string is placed
709 in \fIinterp->result\fR.  Under normal circumstances
710 it returns TCL_OK;  if an error occurs then it returns TCL_ERROR
711 and \fIinterp->result\fR contains an error message.
712 .PP
713 If \fIargvName\fR is NULL, then the value left in
714 \fIinterp->result\fR by \fBTk_ConfigureInfo\fR
715 consists of a list of one or more entries, each of which describes
716 one configuration option (i.e. one entry in \fIspecs\fR).  Each
717 entry in the list will contain either two or five values.  If the
718 corresponding entry in \fIspecs\fR has type TK_CONFIG_SYNONYM, then
719 the list will contain two values:  the \fIargvName\fR for the entry
720 and the \fIdbName\fR (synonym name).  Otherwise the list will contain
721 five values:  \fIargvName\fR, \fIdbName\fR, \fIdbClass\fR, \fIdefValue\fR,
722 and current value.  The current value is computed from the appropriate
723 field of \fIwidgRec\fR by calling procedures like \fBTk_NameOfColor\fR.
724 .PP
725 If the \fIargvName\fR argument to \fBTk_ConfigureInfo\fR is non-NULL,
726 then it indicates a single option, and information is returned only
727 for that option.  The string placed in \fIinterp->result\fR will be
728 a list containing two or five values as described above;  this will
729 be identical to the corresponding sublist that would have been returned
730 if \fIargvName\fR had been NULL.
731 .PP
732 The \fIflags\fR argument to \fBTk_ConfigureInfo\fR is used to restrict
733 the \fIspecs\fR entries to consider, just as for \fBTk_ConfigureWidget\fR.
734
735 .SH TK_CONFIGUREVALUE
736 .PP
737 \fBTk_ConfigureValue\fR takes arguments similar to \fBTk_ConfigureInfo\fR;
738 instead of returning a list of values, it just returns the current value
739 of the option given by \fIargvName\fR (\fIargvName\fR must not be NULL).
740 The value is returned in \fIinterp->result\fR and TCL_OK is
741 normally returned as the procedure's result.
742 If an error occurs in \fBTk_ConfigureValue\fR (e.g., \fIargvName\fR is
743 not a valid option name), TCL_ERROR is returned and an error message
744 is left in \fIinterp->result\fR.
745 This procedure is typically called to implement \fBcget\fR widget
746 commands.
747
748 .SH TK_FREEOPTIONS
749 .PP
750 The \fBTk_FreeOptions\fR procedure may be invoked during widget cleanup
751 to release all of the resources associated with configuration options.
752 It scans through \fIspecs\fR and for each entry corresponding to a
753 resource that must be explicitly freed (e.g. those with
754 type TK_CONFIG_COLOR), it frees the resource in the widget record.
755 If the field in the widget record doesn't refer to a resource (e.g.
756 it contains a null pointer) then no resource is freed for that
757 entry.
758 After freeing a resource, \fBTk_FreeOptions\fR sets the
759 corresponding field of the widget record to null.
760
761 .SH "CUSTOM OPTION TYPES"
762 .PP
763 Applications can extend the built-in configuration types with additional
764 configuration types by writing procedures to parse and print options
765 of the a type and creating a structure pointing to those procedures:
766 .CS
767 typedef struct Tk_CustomOption {
768         Tk_OptionParseProc *\fIparseProc\fR;
769         Tk_OptionPrintProc *\fIprintProc\fR;
770         ClientData \fIclientData\fR;
771 } Tk_CustomOption;
772
773 typedef int Tk_OptionParseProc(
774         ClientData \fIclientData\fR,
775         Tcl_Interp *\fIinterp\fR,
776         Tk_Window \fItkwin\fR,
777         char *\fIvalue\fR,
778         char *\fIwidgRec\fR,
779         int \fIoffset\fR);
780
781 typedef char *Tk_OptionPrintProc(
782         ClientData \fIclientData\fR,
783         Tk_Window \fItkwin\fR,
784         char *\fIwidgRec\fR,
785         int \fIoffset\fR,
786         Tcl_FreeProc **\fIfreeProcPtr\fR);
787 .CE
788 The Tk_CustomOption structure contains three fields, which are pointers
789 to the two procedures and a \fIclientData\fR value to be passed to those
790 procedures when they are invoked.  The \fIclientData\fR value typically
791 points to a structure containing information that is needed by the
792 procedures when they are parsing and printing options.
793 .PP
794 The \fIparseProc\fR procedure is invoked by
795 \fBTk_ConfigureWidget\fR to parse a string and store the resulting
796 value in the widget record.
797 The \fIclientData\fR argument is a copy of the \fIclientData\fR
798 field in the Tk_CustomOption structure.
799 The \fIinterp\fR argument points to a Tcl interpreter used for
800 error reporting.  \fITkwin\fR is a copy of the \fItkwin\fR argument
801 to \fBTk_ConfigureWidget\fR.  The \fIvalue\fR argument is a string
802 describing the value for the option;  it could have been specified
803 explicitly in the call to \fBTk_ConfigureWidget\fR or it could
804 come from the option database or a default.
805 \fIValue\fR will never be a null pointer but it may point to
806 an empty string.
807 \fIRecordPtr\fR is the same as the \fIwidgRec\fR argument to
808 \fBTk_ConfigureWidget\fR;  it points to the start of the widget
809 record to modify.
810 The last argument, \fIoffset\fR, gives the offset in bytes from the start
811 of the widget record to the location where the option value is to
812 be placed.  The procedure should translate the string to whatever
813 form is appropriate for the option and store the value in the widget
814 record.  It should normally return TCL_OK, but if an error occurs
815 in translating the string to a value then it should return TCL_ERROR
816 and store an error message in \fIinterp->result\fR.
817 .PP
818 The \fIprintProc\fR procedure is called
819 by \fBTk_ConfigureInfo\fR to produce a string value describing an
820 existing option.
821 Its \fIclientData\fR, \fItkwin\fR, \fIwidgRec\fR, and \fIoffset\fR
822 arguments all have the same meaning as for Tk_OptionParseProc
823 procedures.
824 The \fIprintProc\fR procedure should examine the option whose value
825 is stored at \fIoffset\fR in \fIwidgRec\fR, produce a string describing
826 that option, and return a pointer to the string.
827 If the string is stored in dynamically-allocated memory, then
828 the procedure must set \fI*freeProcPtr\fR to the address of
829 a procedure to call to free the string's memory;  \fBTk_ConfigureInfo\fR
830 will call this procedure when it is finished with the string.
831 If the result string is stored in static memory then \fIprintProc\fR
832 need not do anything with the \fIfreeProcPtr\fR argument.
833 .PP
834 Once \fIparseProc\fR and \fIprintProc\fR have been defined and a
835 Tk_CustomOption structure has been created for them, options of this
836 new type may be manipulated with Tk_ConfigSpec entries whose \fItype\fR
837 fields are TK_CONFIG_CUSTOM and whose \fIcustomPtr\fR fields point
838 to the Tk_CustomOption structure.
839
840 .SH EXAMPLES
841 .PP
842 Although the explanation of \fBTk_ConfigureWidget\fR is fairly
843 complicated, its actual use is pretty straightforward.
844 The easiest way to get started is to copy the code
845 from an existing widget.
846 The library implementation of frames
847 (tkFrame.c) has a simple configuration table, and the library
848 implementation of buttons (tkButton.c) has a much more complex
849 table that uses many of the fancy \fIspecFlags\fR mechanisms.
850
851 .SH KEYWORDS
852 anchor, bitmap, boolean, border, cap style, color, configuration options,
853 cursor, custom, double, font, integer, join style, justify, millimeters,
854 pixels, relief, synonym, uid