/*
* tkConfig.c --
*
* This file contains the Tk_ConfigureWidget procedure.
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkConfig.c 1.52 96/02/15 18:52:39
*/
#include "tkInt.h"
/*
* Values for "flags" field of Tk_ConfigSpec structures. Be sure
* to coordinate these values with those defined in tk.h
* (TK_CONFIG_COLOR_ONLY, etc.). There must not be overlap!
*
* INIT - Non-zero means (char *) things have been
* converted to Tk_Uid's.
*/
/*
* Forward declarations for procedures defined later in this file:
*/
char *widgRec));
Tcl_FreeProc **freeProcPtr));
/*
*--------------------------------------------------------------
*
* Tk_ConfigureWidget --
*
* Process command-line options and database options to
* fill in fields of a widget record with resources and
* other parameters.
*
* Results:
* A standard Tcl return value. In case of an error,
* interp->result will hold an error message.
*
* Side effects:
* The fields of widgRec get filled in with information
* in widgRec's fields gets recycled.
*
*--------------------------------------------------------------
*/
int
* set up X resources). */
int argc; /* Number of elements in argv. */
char **argv; /* Command-line options. */
char *widgRec; /* Record whose fields are to be
* modified. Values must be properly
* initialized. */
int flags; /* Used to specify additional flags
* that must be present in config specs
* for them to be considered. Also,
* may have TK_CONFIG_ARGV_ONLY set. */
{
* or else they are not considered. */
* not considered. */
} else {
}
/*
* Pass one: scan through all the option specs, replacing strings
* with Tk_Uids (if this hasn't been done already) and clearing
* the TK_CONFIG_OPTION_SPECIFIED flags.
*/
}
}
}
}
| INIT;
}
/*
* Pass two: scan through all of the arguments, processing those
* that match entries in the specs.
*/
return TCL_ERROR;
}
/*
* Process the entry.
*/
if (argc < 2) {
"\" missing", (char *) NULL);
return TCL_ERROR;
}
return TCL_ERROR;
}
}
/*
* Pass three: scan through all of the specs again; if no
* command-line argument matched a spec, then check for info
* in the option database. If there was nothing in the
* database, then use the default.
*/
if (!(flags & TK_CONFIG_ARGV_ONLY)) {
continue;
}
continue;
}
}
TCL_OK) {
"database entry for",
return TCL_ERROR;
}
} else {
TCL_OK) {
"\n (%s \"%.50s\" in widget \"%.50s\")",
"default value for",
return TCL_ERROR;
}
}
}
}
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* FindConfigSpec --
*
* Search through a table of configuration specs, looking for
* one that matches a given argvName.
*
* Results:
* The return value is a pointer to the matching entry, or NULL
* if nothing matched. In that case an error message is left
* in interp->result.
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
static Tk_ConfigSpec *
* specifications for a widget. */
char *argvName; /* Name (suitable for use in a "config"
* command) identifying particular option. */
int needFlags; /* Flags that must be present in matching
* entry. */
int hateFlags; /* Flags that must NOT be present in
* matching entry. */
{
register char c; /* First character of current argument. */
c = argvName[1];
continue;
}
continue;
}
continue;
}
goto gotMatch;
}
"\"", (char *) NULL);
return (Tk_ConfigSpec *) NULL;
}
}
"\"", (char *) NULL);
return (Tk_ConfigSpec *) NULL;
}
/*
* Found a matching entry. If it's a synonym, then find the
* entry that it's a synonym for.
*/
"couldn't find synonym for option \"",
return (Tk_ConfigSpec *) NULL;
}
break;
}
}
}
return specPtr;
}
/*
*--------------------------------------------------------------
*
* DoConfig --
*
* This procedure applies a single configuration option
* to a widget record.
*
* Results:
* A standard Tcl return value.
*
* Side effects:
* WidgRec is modified as indicated by specPtr and value.
* The old value is recycled, if that is appropriate for
* the value type.
*
*--------------------------------------------------------------
*/
static int
* set up X resources). */
char *value; /* Value to use to fill in widgRec. */
int valueIsUid; /* Non-zero means value is a Tk_Uid;
* zero means it's an ordinary string. */
char *widgRec; /* Record whose fields are to be
* modified. Values must be properly
* initialized. */
{
char *ptr;
int nullValue;
nullValue = 0;
nullValue = 1;
}
do {
case TK_CONFIG_BOOLEAN:
return TCL_ERROR;
}
break;
case TK_CONFIG_INT:
return TCL_ERROR;
}
break;
case TK_CONFIG_DOUBLE:
return TCL_ERROR;
}
break;
case TK_CONFIG_STRING: {
if (nullValue) {
} else {
}
}
break;
}
case TK_CONFIG_UID:
if (nullValue) {
} else {
}
break;
case TK_CONFIG_COLOR: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
}
break;
}
case TK_CONFIG_FONT: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
}
break;
}
case TK_CONFIG_BITMAP: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
}
break;
}
case TK_CONFIG_BORDER: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
}
break;
}
case TK_CONFIG_RELIEF:
return TCL_ERROR;
}
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
}
}
break;
}
case TK_CONFIG_JUSTIFY:
return TCL_ERROR;
}
break;
case TK_CONFIG_ANCHOR:
return TCL_ERROR;
}
break;
case TK_CONFIG_CAP_STYLE:
return TCL_ERROR;
}
break;
case TK_CONFIG_JOIN_STYLE:
return TCL_ERROR;
}
break;
case TK_CONFIG_PIXELS:
!= TCL_OK) {
return TCL_ERROR;
}
break;
case TK_CONFIG_MM:
!= TCL_OK) {
return TCL_ERROR;
}
break;
case TK_CONFIG_WINDOW: {
if (nullValue) {
} else {
return TCL_ERROR;
}
}
break;
}
case TK_CONFIG_CUSTOM:
return TCL_ERROR;
}
break;
default: {
return TCL_ERROR;
}
}
specPtr++;
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* Tk_ConfigureInfo --
*
* Return information about the configuration options
* for a window, and their current values.
*
* Results:
* Always returns TCL_OK. Interp->result will be modified
* hold a description of either a single configuration option
* available for "widgRec" via "specs", or all the configuration
* options available. In the "all" case, the result will
* available for "widgRec" via "specs". The result will
* be a list, each of whose entries describes one option.
* Each entry will itself be a list containing the option's
* name for use on command lines, database name, database
* class, default value, and current value (empty string
* if none). For options that are synonyms, the list will
* contain only two values: name and synonym name. If the
* "name" argument is non-NULL, then the only information
* returned is that for the named argument (i.e. the corresponding
* entry in the overall list is returned).
*
* Side effects:
* None.
*
*--------------------------------------------------------------
*/
int
char *widgRec; /* Record whose fields contain current
* values for options. */
char *argvName; /* If non-NULL, indicates a single option
* whose info is to be returned. Otherwise
* info is returned for all options. */
int flags; /* Used to specify additional flags
* that must be present in config specs
* for them to be considered. */
{
char *list;
} else {
}
/*
* If information is only wanted for a single configuration
* spec, then handle that one spec specially.
*/
return TCL_ERROR;
}
return TCL_OK;
}
/*
* Loop through all the specs, creating a big list with all
* their information.
*/
continue;
}
continue;
}
continue;
}
leader = " {";
}
return TCL_OK;
}
/*
*--------------------------------------------------------------
*
* FormatConfigInfo --
*
* Create a valid Tcl list holding the configuration information
* for a single configuration option.
*
* Results:
* A Tcl list, dynamically allocated. The caller is expected to
* arrange for this list to be freed eventually.
*
* Side effects:
* Memory is allocated.
*
*--------------------------------------------------------------
*/
static char *
* like floating-point precision. */
* option. */
char *widgRec; /* Pointer to record holding current
* values of info for widget. */
{
}
&freeProc);
}
}
}
}
} else {
}
}
return result;
}
/*
*----------------------------------------------------------------------
*
* FormatConfigValue --
*
* This procedure formats the current value of a configuration
* option.
*
* Results:
* The return value is the formatted value of the option given
* by specPtr and widgRec. If the value is static, so that it
* need not be freed, *freeProcPtr will be set to NULL; otherwise
* *freeProcPtr will be set to the address of a procedure to
* free the result, and the caller must invoke this procedure
* when it is finished with the result.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static char *
* Must not point to a synonym option. */
char *widgRec; /* Pointer to record holding current
* values of info for widget. */
char *buffer; /* Static buffer to use for small values.
* Must have at least 200 bytes of storage. */
* of procedure to free the result, or NULL
* if result is static. */
{
*freeProcPtr = NULL;
result = "";
case TK_CONFIG_BOOLEAN:
if (*((int *) ptr) == 0) {
result = "0";
} else {
result = "1";
}
break;
case TK_CONFIG_INT:
break;
case TK_CONFIG_DOUBLE:
break;
case TK_CONFIG_STRING:
result = "";
}
break;
case TK_CONFIG_UID: {
}
break;
}
case TK_CONFIG_COLOR: {
}
break;
}
case TK_CONFIG_FONT: {
if (fontStructPtr != NULL) {
}
break;
}
case TK_CONFIG_BITMAP: {
}
break;
}
case TK_CONFIG_BORDER: {
}
break;
}
case TK_CONFIG_RELIEF:
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR: {
}
break;
}
case TK_CONFIG_JUSTIFY:
break;
case TK_CONFIG_ANCHOR:
break;
case TK_CONFIG_CAP_STYLE:
break;
case TK_CONFIG_JOIN_STYLE:
break;
case TK_CONFIG_PIXELS:
break;
case TK_CONFIG_MM:
break;
case TK_CONFIG_WINDOW: {
}
break;
}
case TK_CONFIG_CUSTOM:
break;
default:
result = "?? unknown type ??";
}
return result;
}
/*
*----------------------------------------------------------------------
*
* Tk_ConfigureValue --
*
* This procedure returns the current value of a configuration
* option for a widget.
*
* Results:
* The return value is a standard Tcl completion code (TCL_OK or
* TCL_ERROR). Interp->result will be set to hold either the value
* of the option given by argvName (if TCL_OK is returned) or
* an error message (if TCL_ERROR is returned).
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
char *widgRec; /* Record whose fields contain current
* values for options. */
char *argvName; /* Gives the command-line name for the
* option whose value is to be returned. */
int flags; /* Used to specify additional flags
* that must be present in config specs
* for them to be considered. */
{
} else {
}
return TCL_ERROR;
}
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
* Tk_FreeOptions --
*
* Free up all resources associated with configuration options.
*
* Results:
* None.
*
* Side effects:
* Any resource in widgRec that is controlled by a configuration
* option (e.g. a Tk_3DBorder or XColor) is freed in the appropriate
* fashion.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
void
char *widgRec; /* Record whose fields contain current
* values for options. */
* resources. */
int needFlags; /* Used to specify additional flags
* that must be present in config specs
* for them to be considered. */
{
char *ptr;
continue;
}
case TK_CONFIG_STRING:
}
break;
case TK_CONFIG_COLOR:
}
break;
case TK_CONFIG_FONT:
}
break;
case TK_CONFIG_BITMAP:
}
break;
case TK_CONFIG_BORDER:
}
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR:
}
}
}
}