head	1.16;
access;
symbols
	core-8-5-9:1.13
	core-8-5-8:1.13
	macosx-cocoa-merge:1.15
	macosx-cocoa-premerge:1.15
	macosx-carbon-freeze:1.15
	core-8-5-7:1.13
	core-8-5-6:1.13
	core-8-6-b1:1.15
	core-8-6-a3:1.14
	core-8-5-5:1.13
	core-8-6-a2:1.14
	core-8-5-4:1.13
	core-8-5-3:1.13
	core-8-6-a1:1.14
	core-8-4-19:1.10
	core-8-5-branch:1.13.0.2
	core-8-5-2:1.13
	core-8-4-18:1.10
	core-8-5-1:1.13
	core-8-4-17:1.10
	core-8-5-0:1.13
	core-8-5-b3:1.12
	core-8-5-b2:1.12
	core-8-4-16:1.10
	core-8-5-b1:1.12
	core-stablilizer-merge:1.11
	core-stabilizer-branch:1.11.0.2
	core-stabilizer-merge:1.13
	core-8-4-15:1.10
	core-8-5-a6:1.11
	core-8-5-a5:1.11
	core-8-4-14:1.10
	core-8-5-a4:1.11
	core-8-4-13:1.10
	core-8-4-12:1.10
	core-8-4-11:1.10
	core-8-5-a3:1.10
	core-8-4-10:1.10
	core-8-4-9-branch:1.10.0.6
	core-8-5-a2:1.10
	core-8-4-9:1.10
	core-8-4-8:1.10
	core-8-4-7:1.10
	core-8-5-a1:1.10
	core-8-4-6:1.10
	core-8-4-5:1.10
	mistachkin-dev-branch:1.10.0.4
	core-8-4-4:1.10
	core-8-4-3:1.10
	core-8-4-branch:1.10.0.2
	core-8-4-2:1.10
	core-8-4-1:1.10
	core-8-3-5:1.6
	core-8-4-0:1.10
	macosx-8-4-merge-2002-08-31-trunk:1.10
	macosx-8-4-premerge-2002-08-31-branch:1.6.8.3
	macosx-8-4-premerge-2002-08-31-trunk:1.10
	macosx-8-4-merge-2002-08-30-branch:1.6.8.3
	macosx-8-4-merge-2002-08-30-trunk:1.10
	macosx-8-4-merge-2002-08-20-branch:1.6.8.3
	macosx-8-4-merge-2002-08-20-trunk:1.10
	core-8-4-b2:1.10
	core-8-4-b1:1.9
	macosx-premerge-6-9-02:1.6.8.1
	core-8-4-a4:1.8
	core-8-3-4:1.6
	macosx-8-4-branch:1.6.0.8
	macosx-8-4-branchpoint:1.6
	core-8-4-a3:1.6
	core-8-3-3:1.6
	dgp-privates-into-namespace:1.6.0.6
	tclpro-1-5-0:1.6
	core-8-4-win-speedup:1.6.0.4
	core-8-4-a2:1.6
	tclpro-1-4-1:1.6
	tclpro-1-4-0:1.6
	core-8-3-2:1.6
	ajuba-ajuba2-2-1-base:1.6
	ajuba-ajuba2-2-0:1.6
	core-8-4-a1:1.6
	core-8-3-1-branch:1.6.0.2
	core-8-3-1:1.6
	scriptics-sc-2-0-b5:1.6
	scriptics-sc-2-0-fixed:1.6
	scriptics-sc-2-0-b2:1.6
	scriptics-sc-2-0-b1:1.6
	core-8-3-0:1.6
	core-8-3-b2:1.6
	core-8-3-b1:1.6
	scriptics-sc-1-1:1.5
	scriptics-sc-1-1-b1:1.5
	core-8-2-3:1.5
	scriptics-sc-1-1-branch:1.5.0.10
	scriptics-sc-1-1-base:1.5
	scriptics-sc-1-0:1.5
	scriptics-sc-1-0-branch:1.5.0.8
	scriptics-sc-1-0-base:1.5
	core-8-2-2:1.5
	core-8-2-1:1.5
	scriptics-bc-1-0-b1:1.5
	core-8-2-1-branch:1.5.0.6
	scriptics-tclpro-1-3-0:1.5
	core-8-2-0:1.5
	core-8-2-b3-branch:1.5.0.2
	core-8-2-b3-base:1.5
	scriptics-tclpro-1-3-b4:1.5
	core-8-2-b2:1.5
	scriptics-tclpro-1-3-b3:1.5
	core-8-2-b1:1.5
	scriptics-tclpro-1-3-b2:1.5
	merge-to-mainline-5/21/99:1.5
	scriptics-tclpro-1-3-b2-branch:1.5.0.4
	core-8-1-1:1.5
	scriptics-tclpro-1-3-b1:1.5
	core-8-1-1-base:1.5
	core-8-1-0:1.5
	merge-to-mainline-4-29-99:1.5
	merge-to-mainline-4-23-99:1.5
	core-8-1-branch-old:1.1.0.4
	core-8-0-6-branch:1.2.0.6
	core-8-0-6-base:1.2
	core-8-0-5:1.2
	core-8-1-b3:1.1.4.5
	core-8-1-b2:1.1.4.5
	dev-8-1-stubs-branch:1.1.4.5.0.2
	dev-stubs-branch:1.2.0.4
	scriptics-tclpro-1-2:1.2
	scriptics-tclpro-1-2-b2:1.2
	core-8-1-merge-2/10/99:1.2
	core-8-0-5-branch:1.2.0.2
	core-8-0-5-base:1.2
	scriptics-tclpro-1-2-b1:1.2
	scriptics-tclpro-1-2-a1:1.2
	core-8-1-b1:1.1.4.2
	core-8-0-4:1.2
	core-8-1-a2:1.1.4.1
	core-8-0-2:1.1
	core-8-0-3:1.2;
locks; strict;
comment	@ * @;


1.16
date	2010.01.02.22.52.38;	author dkf;	state Exp;
branches;
next	1.15;

1.15
date	2008.10.17.23.18.37;	author nijtmans;	state Exp;
branches;
next	1.14;

1.14
date	2008.04.27.22.38.56;	author dkf;	state Exp;
branches;
next	1.13;

1.13
date	2007.12.13.15.24.14;	author dgp;	state Exp;
branches;
next	1.12;

1.12
date	2007.09.07.00.34.52;	author dgp;	state Exp;
branches;
next	1.11;

1.11
date	2005.11.07.15.58.21;	author dkf;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2002.08.05.04.30.38;	author dgp;	state Exp;
branches;
next	1.9;

1.9
date	2002.04.12.07.44.45;	author hobbs;	state Exp;
branches;
next	1.8;

1.8
date	2002.01.25.21.09.37;	author dgp;	state Exp;
branches;
next	1.7;

1.7
date	2002.01.17.05.13.11;	author dgp;	state Exp;
branches;
next	1.6;

1.6
date	99.12.14.06.52.28;	author hobbs;	state Exp;
branches
	1.6.4.1
	1.6.8.1;
next	1.5;

1.5
date	99.04.21.21.53.26;	author rjohnson;	state Exp;
branches;
next	1.4;

1.4
date	99.04.16.18.30.27;	author surles;	state Exp;
branches;
next	1.3;

1.3
date	99.04.16.01.51.14;	author stanton;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	98.09.14.18.23.11;	author stanton;	state Exp;
branches;
next	1.1;

1.1
date	98.04.01.09.51.57;	author rjohnson;	state Exp;
branches
	1.1.4.1;
next	;

1.1.4.1
date	98.09.29.00.25.18;	author stanton;	state Exp;
branches;
next	1.1.4.2;

1.1.4.2
date	98.09.30.02.17.00;	author stanton;	state Exp;
branches;
next	1.1.4.3;

1.1.4.3
date	98.12.13.08.16.05;	author lfb;	state Exp;
branches;
next	1.1.4.4;

1.1.4.4
date	99.01.07.02.42.50;	author lfb;	state Exp;
branches;
next	1.1.4.5;

1.1.4.5
date	99.02.16.11.39.31;	author lfb;	state Exp;
branches;
next	;

1.3.2.1
date	99.04.21.02.31.51;	author rjohnson;	state Exp;
branches;
next	;

1.6.4.1
date	2002.04.02.21.00.49;	author hobbs;	state Exp;
branches;
next	;

1.6.8.1
date	2002.02.05.02.25.15;	author wolfsuit;	state Exp;
branches;
next	1.6.8.2;

1.6.8.2
date	2002.06.10.05.38.23;	author wolfsuit;	state Exp;
branches;
next	1.6.8.3;

1.6.8.3
date	2002.08.20.20.27.04;	author das;	state Exp;
branches;
next	;

1.11.2.1
date	2007.09.07.01.25.34;	author dgp;	state Exp;
branches;
next	;


desc
@@


1.16
log
@SMALL FIX: Remove useless explicit casts now that we require C89 or later.
@
text
@/*
 * tkGet.c --
 *
 *	This file contains a number of "Tk_GetXXX" procedures, which parse
 *	text strings into useful forms for Tk. This file has the simpler
 *	functions, like Tk_GetDirection and Tk_GetUid. The more complex
 *	functions like Tk_GetColor are in separate files.
 *
 * Copyright (c) 1991-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @@(#) $Id: tkGet.c,v 1.15 2008/10/17 23:18:37 nijtmans Exp $
 */

#include "tkInt.h"

/*
 * One of these structures is created per thread to store thread-specific
 * data. In this case, it is used to house the Tk_Uid structs used by each
 * thread. The "dataKey" below is used to locate the ThreadSpecificData for
 * the current thread.
 */

typedef struct ThreadSpecificData {
    int initialized;
    Tcl_HashTable uidTable;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

static void		FreeUidThreadExitProc(ClientData clientData);

/*
 * The following tables defines the string values for reliefs, which are
 * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj.
 */

static const char *const anchorStrings[] = {
    "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", NULL
};
static const char *const justifyStrings[] = {
    "left", "right", "center", NULL
};

/*
 *----------------------------------------------------------------------
 *
 * Tk_GetAnchorFromObj --
 *
 *	Return a Tk_Anchor value based on the value of the objPtr.
 *
 * Results:
 *	The return value is a standard Tcl result. If an error occurs during
 *	conversion, an error message is left in the interpreter's result
 *	unless "interp" is NULL.
 *
 * Side effects:
 *	The object gets converted by Tcl_GetIndexFromObj.
 *
 *----------------------------------------------------------------------
 */

int
Tk_GetAnchorFromObj(
    Tcl_Interp *interp,		/* Used for error reporting. */
    Tcl_Obj *objPtr,		/* The object we are trying to get the value
				 * from. */
    Tk_Anchor *anchorPtr)	/* Where to place the Tk_Anchor that
				 * corresponds to the string value of
				 * objPtr. */
{
    int index, code;

    code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
	    &index);
    if (code == TCL_OK) {
	*anchorPtr = (Tk_Anchor) index;
    }
    return code;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetAnchor --
 *
 *	Given a string, return the corresponding Tk_Anchor.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the position is stored at
 *	*anchorPtr; otherwise TCL_ERROR is returned and an error message is
 *	left in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetAnchor(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    const char *string,		/* String describing a direction. */
    Tk_Anchor *anchorPtr)	/* Where to store Tk_Anchor corresponding to
				 * string. */
{
    switch (string[0]) {
    case 'n':
	if (string[1] == 0) {
	    *anchorPtr = TK_ANCHOR_N;
	    return TCL_OK;
	} else if ((string[1] == 'e') && (string[2] == 0)) {
	    *anchorPtr = TK_ANCHOR_NE;
	    return TCL_OK;
	} else if ((string[1] == 'w') && (string[2] == 0)) {
	    *anchorPtr = TK_ANCHOR_NW;
	    return TCL_OK;
	}
	goto error;
    case 's':
	if (string[1] == 0) {
	    *anchorPtr = TK_ANCHOR_S;
	    return TCL_OK;
	} else if ((string[1] == 'e') && (string[2] == 0)) {
	    *anchorPtr = TK_ANCHOR_SE;
	    return TCL_OK;
	} else if ((string[1] == 'w') && (string[2] == 0)) {
	    *anchorPtr = TK_ANCHOR_SW;
	    return TCL_OK;
	} else {
	    goto error;
	}
    case 'e':
	if (string[1] == 0) {
	    *anchorPtr = TK_ANCHOR_E;
	    return TCL_OK;
	}
	goto error;
    case 'w':
	if (string[1] == 0) {
	    *anchorPtr = TK_ANCHOR_W;
	    return TCL_OK;
	}
	goto error;
    case 'c':
	if (strncmp(string, "center", strlen(string)) == 0) {
	    *anchorPtr = TK_ANCHOR_CENTER;
	    return TCL_OK;
	}
	goto error;
    }

  error:
    Tcl_AppendResult(interp, "bad anchor position \"", string,
	    "\": must be n, ne, e, se, s, sw, w, nw, or center", NULL);
    return TCL_ERROR;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_NameOfAnchor --
 *
 *	Given a Tk_Anchor, return the string that corresponds to it.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

const char *
Tk_NameOfAnchor(
    Tk_Anchor anchor)		/* Anchor for which identifying string is
				 * desired. */
{
    switch (anchor) {
    case TK_ANCHOR_N: return "n";
    case TK_ANCHOR_NE: return "ne";
    case TK_ANCHOR_E: return "e";
    case TK_ANCHOR_SE: return "se";
    case TK_ANCHOR_S: return "s";
    case TK_ANCHOR_SW: return "sw";
    case TK_ANCHOR_W: return "w";
    case TK_ANCHOR_NW: return "nw";
    case TK_ANCHOR_CENTER: return "center";
    }
    return "unknown anchor position";
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetJoinStyle --
 *
 *	Given a string, return the corresponding Tk JoinStyle.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the justification is stored at
 *	*joinPtr; otherwise TCL_ERROR is returned and an error message is left
 *	in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetJoinStyle(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    const char *string,		/* String describing a justification style. */
    int *joinPtr)		/* Where to store join style corresponding to
				 * string. */
{
    int c;
    size_t length;

    c = string[0];
    length = strlen(string);

    if ((c == 'b') && (strncmp(string, "bevel", length) == 0)) {
	*joinPtr = JoinBevel;
	return TCL_OK;
    }
    if ((c == 'm') && (strncmp(string, "miter", length) == 0)) {
	*joinPtr = JoinMiter;
	return TCL_OK;
    }
    if ((c == 'r') && (strncmp(string, "round", length) == 0)) {
	*joinPtr = JoinRound;
	return TCL_OK;
    }

    Tcl_AppendResult(interp, "bad join style \"", string,
	    "\": must be bevel, miter, or round", NULL);
    return TCL_ERROR;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_NameOfJoinStyle --
 *
 *	Given a Tk JoinStyle, return the string that corresponds to it.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

const char *
Tk_NameOfJoinStyle(
    int join)			/* Join style for which identifying string is
				 * desired. */
{
    switch (join) {
    case JoinBevel: return "bevel";
    case JoinMiter: return "miter";
    case JoinRound: return "round";
    }
    return "unknown join style";
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetCapStyle --
 *
 *	Given a string, return the corresponding Tk CapStyle.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the justification is stored at
 *	*capPtr; otherwise TCL_ERROR is returned and an error message is left
 *	in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetCapStyle(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    const char *string,		/* String describing a justification style. */
    int *capPtr)		/* Where to store cap style corresponding to
				 * string. */
{
    int c;
    size_t length;

    c = string[0];
    length = strlen(string);

    if ((c == 'b') && (strncmp(string, "butt", length) == 0)) {
	*capPtr = CapButt;
	return TCL_OK;
    }
    if ((c == 'p') && (strncmp(string, "projecting", length) == 0)) {
	*capPtr = CapProjecting;
	return TCL_OK;
    }
    if ((c == 'r') && (strncmp(string, "round", length) == 0)) {
	*capPtr = CapRound;
	return TCL_OK;
    }

    Tcl_AppendResult(interp, "bad cap style \"", string,
	    "\": must be butt, projecting, or round", NULL);
    return TCL_ERROR;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_NameOfCapStyle --
 *
 *	Given a Tk CapStyle, return the string that corresponds to it.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

const char *
Tk_NameOfCapStyle(
    int cap)			/* Cap style for which identifying string is
				 * desired. */
{
    switch (cap) {
    case CapButt: return "butt";
    case CapProjecting: return "projecting";
    case CapRound: return "round";
    }
    return "unknown cap style";
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_GetJustifyFromObj --
 *
 *	Return a Tk_Justify value based on the value of the objPtr.
 *
 * Results:
 *	The return value is a standard Tcl result. If an error occurs during
 *	conversion, an error message is left in the interpreter's result
 *	unless "interp" is NULL.
 *
 * Side effects:
 *	The object gets converted by Tcl_GetIndexFromObj.
 *
 *----------------------------------------------------------------------
 */

int
Tk_GetJustifyFromObj(
    Tcl_Interp *interp,		/* Used for error reporting. */
    Tcl_Obj *objPtr,		/* The object we are trying to get the value
				 * from. */
    Tk_Justify *justifyPtr)	/* Where to place the Tk_Justify that
				 * corresponds to the string value of
				 * objPtr. */
{
    int index, code;

    code = Tcl_GetIndexFromObj(interp, objPtr, justifyStrings,
	    "justification", 0, &index);
    if (code == TCL_OK) {
	*justifyPtr = (Tk_Justify) index;
    }
    return code;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetJustify --
 *
 *	Given a string, return the corresponding Tk_Justify.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the justification is stored at
 *	*justifyPtr; otherwise TCL_ERROR is returned and an error message is
 *	left in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetJustify(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    const char *string,		/* String describing a justification style. */
    Tk_Justify *justifyPtr)	/* Where to store Tk_Justify corresponding to
				 * string. */
{
    int c;
    size_t length;

    c = string[0];
    length = strlen(string);

    if ((c == 'l') && (strncmp(string, "left", length) == 0)) {
	*justifyPtr = TK_JUSTIFY_LEFT;
	return TCL_OK;
    }
    if ((c == 'r') && (strncmp(string, "right", length) == 0)) {
	*justifyPtr = TK_JUSTIFY_RIGHT;
	return TCL_OK;
    }
    if ((c == 'c') && (strncmp(string, "center", length) == 0)) {
	*justifyPtr = TK_JUSTIFY_CENTER;
	return TCL_OK;
    }

    Tcl_AppendResult(interp, "bad justification \"", string,
	    "\": must be left, right, or center", NULL);
    return TCL_ERROR;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_NameOfJustify --
 *
 *	Given a Tk_Justify, return the string that corresponds
 *	to it.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

const char *
Tk_NameOfJustify(
    Tk_Justify justify)		/* Justification style for which identifying
				 * string is desired. */
{
    switch (justify) {
    case TK_JUSTIFY_LEFT: return "left";
    case TK_JUSTIFY_RIGHT: return "right";
    case TK_JUSTIFY_CENTER: return "center";
    }
    return "unknown justification style";
}

/*
 *----------------------------------------------------------------------
 *
 * FreeUidThreadExitProc --
 *
 *	Cleans up memory used for Tk_Uids in the thread.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	All information in the identifier table is deleted.
 *
 *----------------------------------------------------------------------
 */

static void
FreeUidThreadExitProc(
    ClientData clientData)		/* Not used. */
{
    ThreadSpecificData *tsdPtr =
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    Tcl_DeleteHashTable(&tsdPtr->uidTable);
    tsdPtr->initialized = 0;
}

/*
 *----------------------------------------------------------------------
 *
 * Tk_GetUid --
 *
 *	Given a string, this function returns a unique identifier for the
 *	string.
 *
 * Results:
 *	This function returns a Tk_Uid corresponding to the "string" argument.
 *	The Tk_Uid has a string value identical to string (strcmp will return
 *	0), but it's guaranteed that any other calls to this function with a
 *	string equal to "string" will return exactly the same result (i.e. can
 *	compare Tk_Uid *values* directly, without having to call strcmp on
 *	what they point to).
 *
 * Side effects:
 *	New information may be entered into the identifier table.
 *
 *----------------------------------------------------------------------
 */

Tk_Uid
Tk_GetUid(
    const char *string)		/* String to convert. */
{
    int dummy;
    ThreadSpecificData *tsdPtr =
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    Tcl_HashTable *tablePtr = &tsdPtr->uidTable;

    if (!tsdPtr->initialized) {
	Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS);
	Tcl_CreateThreadExitHandler(FreeUidThreadExitProc, NULL);
	tsdPtr->initialized = 1;
    }
    return (Tk_Uid) Tcl_GetHashKey(tablePtr,
	    Tcl_CreateHashEntry(tablePtr, string, &dummy));
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetScreenMM --
 *
 *	Given a string, returns the number of screen millimeters corresponding
 *	to that string.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the screen distance is stored
 *	at *doublePtr; otherwise TCL_ERROR is returned and an error message is
 *	left in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetScreenMM(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    Tk_Window tkwin,		/* Window whose screen determines conversion
				 * from centimeters and other absolute
				 * units. */
    const char *string,		/* String describing a screen distance. */
    double *doublePtr)		/* Place to store converted result. */
{
    char *end;
    double d;

    d = strtod(string, &end);
    if (end == string) {
	error:
	Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", NULL);
	return TCL_ERROR;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    switch (*end) {
    case 0:
	d /= WidthOfScreen(Tk_Screen(tkwin));
	d *= WidthMMOfScreen(Tk_Screen(tkwin));
	break;
    case 'c':
	d *= 10;
	end++;
	break;
    case 'i':
	d *= 25.4;
	end++;
	break;
    case 'm':
	end++;
	break;
    case 'p':
	d *= 25.4/72.0;
	end++;
	break;
    default:
	goto error;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    if (*end != 0) {
	goto error;
    }
    *doublePtr = d;
    return TCL_OK;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_GetPixels --
 *
 *	Given a string, returns the number of pixels corresponding to that
 *	string.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the rounded pixel distance is
 *	stored at *intPtr; otherwise TCL_ERROR is returned and an error
 *	message is left in the interp's result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
Tk_GetPixels(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    Tk_Window tkwin,		/* Window whose screen determines conversion
				 * from centimeters and other absolute
				 * units. */
    const char *string,		/* String describing a number of pixels. */
    int *intPtr)		/* Place to store converted result. */
{
    double d;

    if (TkGetDoublePixels(interp, tkwin, string, &d) != TCL_OK) {
	return TCL_ERROR;
    }

    if (d < 0) {
	*intPtr = (int) (d - 0.5);
    } else {
	*intPtr = (int) (d + 0.5);
    }
    return TCL_OK;
}
/*
 *--------------------------------------------------------------
 *
 * TkGetDoublePixels --
 *
 *	Given a string, returns the number of pixels corresponding to that
 *	string.
 *
 * Results:
 *	The return value is a standard Tcl return result. If TCL_OK is
 *	returned, then everything went well and the pixel distance is stored
 *	at *doublePtr; otherwise TCL_ERROR is returned and an error message is
 *	left in interp->result.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
TkGetDoublePixels(
    Tcl_Interp *interp,		/* Use this for error reporting. */
    Tk_Window tkwin,		/* Window whose screen determines conversion
				 * from centimeters and other absolute
				 * units. */
    const char *string,		/* String describing a number of pixels. */
    double *doublePtr)		/* Place to store converted result. */
{
    char *end;
    double d;

    d = strtod((char *) string, &end);
    if (end == string) {
    error:
	Tcl_AppendResult(interp, "bad screen distance \"", string, "\"", NULL);
	return TCL_ERROR;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    switch (*end) {
    case 0:
	break;
    case 'c':
	d *= 10*WidthOfScreen(Tk_Screen(tkwin));
	d /= WidthMMOfScreen(Tk_Screen(tkwin));
	end++;
	break;
    case 'i':
	d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
	d /= WidthMMOfScreen(Tk_Screen(tkwin));
	end++;
	break;
    case 'm':
	d *= WidthOfScreen(Tk_Screen(tkwin));
	d /= WidthMMOfScreen(Tk_Screen(tkwin));
	end++;
	break;
    case 'p':
	d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
	d /= WidthMMOfScreen(Tk_Screen(tkwin));
	end++;
	break;
    default:
	goto error;
    }
    while ((*end != '\0') && isspace(UCHAR(*end))) {
	end++;
    }
    if (*end != 0) {
	goto error;
    }
    *doublePtr = d;
    return TCL_OK;
}

/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */
@


1.15
log
@Add "const" to many internal
const tables, so those will be
put by the C-compiler in the
TEXT segment in stead of the
DATA segment. This makes those
table sharable in shared libraries.
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.14 2008/04/27 22:38:56 dkf Exp $
d492 1
a492 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
d526 1
a526 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@


1.14
log
@Get rid of pre-C89-isms (esp. CONST vs const).
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.13 2007/12/13 15:24:14 dgp Exp $
d40 1
a40 1
static const char *anchorStrings[] = {
d43 1
a43 1
static const char *justifyStrings[] = {
@


1.13
log
@merge stable branch onto HEAD
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.11.2.1 2007/09/07 01:25:34 dgp Exp $
d40 1
a40 1
static CONST char *anchorStrings[] = {
d43 1
a43 1
static CONST char *justifyStrings[] = {
d106 1
a106 1
    CONST char *string,		/* String describing a direction. */
d178 1
a178 1
CONST char *
d219 1
a219 1
    CONST char *string,		/* String describing a justification style. */
d263 1
a263 1
CONST char *
d298 1
a298 1
    CONST char *string,		/* String describing a justification style. */
d342 1
a342 1
CONST char *
d414 1
a414 1
    CONST char *string,		/* String describing a justification style. */
d459 1
a459 1
CONST char *
d494 1
d523 1
a523 1
    CONST char *string)		/* String to convert. */
d565 1
a565 1
    CONST char *string,		/* String describing a screen distance. */
d639 1
a639 1
    CONST char *string,		/* String describing a number of pixels. */
a663 1

d681 1
a681 1
    CONST char *string,		/* String describing a number of pixels. */
@


1.12
log
@header cleanup
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.11 2005/11/07 15:58:21 dkf Exp $
@


1.11
log
@ANSIfy
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.10 2002/08/05 04:30:38 dgp Exp $
a18 1
#include "tkPort.h"
@


1.11.2.1
log
@merge updates from HEAD
@
text
@d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.11 2005/11/07 15:58:21 dkf Exp $
d19 1
@


1.10
log
@Applied companion patch for Tcl Patch 585105,
updating Tk to use Tcl 8.4's fully CONST-ified
interface, and fully CONSTifying Tk at the
same time.

This patch includes purging Tk of its last
direct access to interp->result.  [Bug 589853]

The substantial changes include copying
event sequence strings into Tcl_DStrings
in tkBind.c, and copying [text] indices into
Tcl_DStrings because parsing them involved
overwriting them.  If this causes performance
trouble, that can be resolved by further
converting them to Tcl_Obj's.

The #defines USE_NON_CONST and USE_COMPAT_CONST
have the same effect for Tk as they do for Tcl.
(They actually change tcl.h)
@
text
@d1 1
a1 1
/* 
d4 4
a7 5
 *	This file contains a number of "Tk_GetXXX" procedures, which
 *	parse text strings into useful forms for Tk.  This file has
 *	the simpler procedures, like Tk_GetDirection and Tk_GetUid.
 *	The more complex procedures like Tk_GetColor are in separate
 *	files.
d12 2
a13 2
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
d15 1
a15 1
 * RCS: @@(#) $Id: tkGet.c,v 1.9 2002/04/12 07:44:45 hobbs Exp $
d22 4
a25 4
 * One of these structures is created per thread to store 
 * thread-specific data.  In this case, it is used to house the 
 * Tk_Uid structs used by each thread.  The "dataKey" below is 
 * used to locate the ThreadSpecificData for the current thread.
d34 1
a34 1
static void	FreeUidThreadExitProc _ANSI_ARGS_((ClientData clientData));
d42 1
a42 1
    "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", (char *) NULL
d45 1
a45 1
    "left", "right", "center", (char *) NULL
a46 1

d67 5
a71 5
Tk_GetAnchorFromObj(interp, objPtr, anchorPtr)
    Tcl_Interp *interp;		/* Used for error reporting. */
    Tcl_Obj *objPtr;		/* The object we are trying to get the 
				 * value from. */
    Tk_Anchor *anchorPtr;	/* Where to place the Tk_Anchor that
d77 1
a77 1
    code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0, 
d93 4
a96 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	position is stored at *anchorPtr;  otherwise TCL_ERROR
 *	is returned and an error message is left in
 *	the interp's result.
d105 5
a109 5
Tk_GetAnchor(interp, string, anchorPtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    CONST char *string;		/* String describing a direction. */
    Tk_Anchor *anchorPtr;	/* Where to store Tk_Anchor corresponding
				 * to string. */
d112 23
a134 42
	case 'n':
	    if (string[1] == 0) {
		*anchorPtr = TK_ANCHOR_N;
		return TCL_OK;
	    } else if ((string[1] == 'e') && (string[2] == 0)) {
		*anchorPtr = TK_ANCHOR_NE;
		return TCL_OK;
	    } else if ((string[1] == 'w') && (string[2] == 0)) {
		*anchorPtr = TK_ANCHOR_NW;
		return TCL_OK;
	    }
	    goto error;
	case 's':
	    if (string[1] == 0) {
		*anchorPtr = TK_ANCHOR_S;
		return TCL_OK;
	    } else if ((string[1] == 'e') && (string[2] == 0)) {
		*anchorPtr = TK_ANCHOR_SE;
		return TCL_OK;
	    } else if ((string[1] == 'w') && (string[2] == 0)) {
		*anchorPtr = TK_ANCHOR_SW;
		return TCL_OK;
	    } else {
		goto error;
	    }
	case 'e':
	    if (string[1] == 0) {
		*anchorPtr = TK_ANCHOR_E;
		return TCL_OK;
	    }
	    goto error;
	case 'w':
	    if (string[1] == 0) {
		*anchorPtr = TK_ANCHOR_W;
		return TCL_OK;
	    }
	    goto error;
	case 'c':
	    if (strncmp(string, "center", strlen(string)) == 0) {
		*anchorPtr = TK_ANCHOR_CENTER;
		return TCL_OK;
	    }
d136 19
d157 1
a157 1
    error:
d159 1
a159 2
	    "\": must be n, ne, e, se, s, sw, w, nw, or center",
	    (char *) NULL);
d168 1
a168 2
 *	Given a Tk_Anchor, return the string that corresponds
 *	to it.
d180 3
a182 3
Tk_NameOfAnchor(anchor)
    Tk_Anchor anchor;		/* Anchor for which identifying string
				 * is desired. */
d185 9
a193 9
	case TK_ANCHOR_N: return "n";
	case TK_ANCHOR_NE: return "ne";
	case TK_ANCHOR_E: return "e";
	case TK_ANCHOR_SE: return "se";
	case TK_ANCHOR_S: return "s";
	case TK_ANCHOR_SW: return "sw";
	case TK_ANCHOR_W: return "w";
	case TK_ANCHOR_NW: return "nw";
	case TK_ANCHOR_CENTER: return "center";
d206 4
a209 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	justification is stored at *joinPtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	the interp's result.
d218 5
a222 5
Tk_GetJoinStyle(interp, string, joinPtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    CONST char *string;		/* String describing a justification style. */
    int *joinPtr;		/* Where to store join style corresponding
				 * to string. */
d244 1
a244 2
	    "\": must be bevel, miter, or round",
	    (char *) NULL);
d253 1
a253 2
 *	Given a Tk JoinStyle, return the string that corresponds
 *	to it.
d265 3
a267 3
Tk_NameOfJoinStyle(join)
    int join;			/* Join style for which identifying string
				 * is desired. */
d270 3
a272 3
	case JoinBevel: return "bevel";
	case JoinMiter: return "miter";
	case JoinRound: return "round";
d285 4
a288 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	justification is stored at *capPtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	the interp's result.
d297 5
a301 5
Tk_GetCapStyle(interp, string, capPtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    CONST char *string;		/* String describing a justification style. */
    int *capPtr;		/* Where to store cap style corresponding
				 * to string. */
d323 1
a323 2
	    "\": must be butt, projecting, or round",
	    (char *) NULL);
d332 1
a332 2
 *	Given a Tk CapStyle, return the string that corresponds
 *	to it.
d344 3
a346 3
Tk_NameOfCapStyle(cap)
    int cap;			/* Cap style for which identifying string
				 * is desired. */
d349 3
a351 3
	case CapButt: return "butt";
	case CapProjecting: return "projecting";
	case CapRound: return "round";
d375 5
a379 5
Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)
    Tcl_Interp *interp;		/* Used for error reporting. */
    Tcl_Obj *objPtr;		/* The object we are trying to get the 
				 * value from. */
    Tk_Justify *justifyPtr;	/* Where to place the Tk_Justify that
d401 4
a404 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	justification is stored at *justifyPtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	the interp's result.
d413 5
a417 5
Tk_GetJustify(interp, string, justifyPtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    CONST char *string;		/* String describing a justification style. */
    Tk_Justify *justifyPtr;	/* Where to store Tk_Justify corresponding
				 * to string. */
d439 1
a439 2
	    "\": must be left, right, or center",
	    (char *) NULL);
d461 3
a463 3
Tk_NameOfJustify(justify)
    Tk_Justify justify;		/* Justification style for which
				 * identifying string is desired. */
d466 3
a468 3
	case TK_JUSTIFY_LEFT: return "left";
	case TK_JUSTIFY_RIGHT: return "right";
	case TK_JUSTIFY_CENTER: return "center";
d490 2
a491 2
FreeUidThreadExitProc(clientData)
    ClientData clientData;		/* Not used. */
d493 1
a493 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
d504 2
a505 2
 *	Given a string, this procedure returns a unique identifier
 *	for the string.
d508 6
a513 7
 *	This procedure returns a Tk_Uid corresponding to the "string"
 *	argument.  The Tk_Uid has a string value identical to string
 *	(strcmp will return 0), but it's guaranteed that any other
 *	calls to this procedure with a string equal to "string" will
 *	return exactly the same result (i.e. can compare Tk_Uid
 *	*values* directly, without having to call strcmp on what they
 *	point to).
d522 2
a523 2
Tk_GetUid(string)
    CONST char *string;		/* String to convert. */
d526 1
a526 1
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
d544 2
a545 2
 *	Given a string, returns the number of screen millimeters
 *	corresponding to that string.
d548 4
a551 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	screen distance is stored at *doublePtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	the interp's result.
d560 3
a562 3
Tk_GetScreenMM(interp, tkwin, string, doublePtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    Tk_Window tkwin;		/* Window whose screen determines conversion
d565 2
a566 2
    CONST char *string;		/* String describing a screen distance. */
    double *doublePtr;		/* Place to store converted result. */
d574 1
a574 2
	Tcl_AppendResult(interp, "bad screen distance \"", string,
		"\"", (char *) NULL);
d581 21
a601 21
	case 0:
	    d /= WidthOfScreen(Tk_Screen(tkwin));
	    d *= WidthMMOfScreen(Tk_Screen(tkwin));
	    break;
	case 'c':
	    d *= 10;
	    end++;
	    break;
	case 'i':
	    d *= 25.4;
	    end++;
	    break;
	case 'm':
	    end++;
	    break;
	case 'p':
	    d *= 25.4/72.0;
	    end++;
	    break;
	default:
	    goto error;
d618 2
a619 2
 *	Given a string, returns the number of pixels corresponding
 *	to that string.
d622 4
a625 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	rounded pixel distance is stored at *intPtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	the interp's result.
d634 3
a636 3
Tk_GetPixels(interp, tkwin, string, intPtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    Tk_Window tkwin;		/* Window whose screen determines conversion
d639 2
a640 2
    CONST char *string;		/* String describing a number of pixels. */
    int *intPtr;		/* Place to store converted result. */
d660 2
a661 2
 *	Given a string, returns the number of pixels corresponding
 *	to that string.
d664 5
a668 5
 *	The return value is a standard Tcl return result.  If
 *	TCL_OK is returned, then everything went well and the
 *	pixel distance is stored at *doublePtr;  otherwise
 *	TCL_ERROR is returned and an error message is left in
 *	interp->result.
d677 3
a679 3
TkGetDoublePixels(interp, tkwin, string, doublePtr)
    Tcl_Interp *interp;		/* Use this for error reporting. */
    Tk_Window tkwin;		/* Window whose screen determines conversion
d682 2
a683 2
    CONST char *string;		/* String describing a number of pixels. */
    double *doublePtr;		/* Place to store converted result. */
d690 2
a691 3
	error:
	Tcl_AppendResult(interp, "bad screen distance \"", string,
		"\"", (char *) NULL);
d698 24
a721 24
	case 0:
	    break;
	case 'c':
	    d *= 10*WidthOfScreen(Tk_Screen(tkwin));
	    d /= WidthMMOfScreen(Tk_Screen(tkwin));
	    end++;
	    break;
	case 'i':
	    d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
	    d /= WidthMMOfScreen(Tk_Screen(tkwin));
	    end++;
	    break;
	case 'm':
	    d *= WidthOfScreen(Tk_Screen(tkwin));
	    d /= WidthMMOfScreen(Tk_Screen(tkwin));
	    end++;
	    break;
	case 'p':
	    d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
	    d /= WidthMMOfScreen(Tk_Screen(tkwin));
	    end++;
	    break;
	default:
	    goto error;
d732 8
a739 2


@


1.9
log
@	* generic/tkGet.c (FreeUidThreadExitProc): free thread-specific
	resources on thread exit
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.8 2002/01/25 21:09:37 dgp Exp $
d110 1
a110 1
    char *string;		/* String describing a direction. */
d184 1
a184 1
char *
d226 1
a226 1
    char *string;		/* String describing a justification style. */
d272 1
a272 1
char *
d308 1
a308 1
    char *string;		/* String describing a justification style. */
d354 1
a354 1
char *
d427 1
a427 1
    char *string;		/* String describing a justification style. */
d473 1
a473 1
char *
@


1.8
log
@	* Updated callers of Tcl_SplitList and Tcl_Merge.
	* Updated callers of Tcl_GetStringResult.
	  Rewrote PrintScrollFractions to ScrollFractions to stop scribbling
	  directly on interp->result.
	* Updated callers of Tcl_GetVar, Tcl_GetVar2
	* Updated callers of Tcl_SplitPath, Tcl_JoinPath, and
	  Tcl_TranslateFileName.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.7 2002/01/17 05:13:11 dgp Exp $
d35 2
d489 26
d546 1
@


1.7
log
@	* Updates to handle change in type of tablePtr
        argument of Tcl_GetIndexFromObj(Struct) from (char **) to
        (CONST char **).  [TIP 27] [Patch 504705]
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.6 1999/12/14 06:52:28 hobbs Exp $
d551 1
a551 1
    char *string;		/* String describing a screen distance. */
d627 1
a627 1
    char *string;		/* String describing a number of pixels. */
@


1.6
log
@	* generic/tkStubInit.c:
	* generic/tkDecls.h:
	* generic/tkIntXlibDecls.h:
	* generic/tkInt.decls: added XSetDashes and XWarpPointer
	* generic/tk.decls: added Tk_CreateSmoothMethod, and reserved
	two spots
	* generic/tk.h: added Tk_SmoothMethod struct,
	state item to canvas record, #defines for item state,
	support for using old char*-based canvas item C creation
	procedures with -DUSE_OLD_CANVAS,
	Tk_Dash, Tk_TSOffset (-offsets) & Tk_Outline structs and #defs,
	decls for dash, outline and postscript routines
	* generic/tkBind.c: added support for Quadruple clicks, and added
	the -warp option to 'event' with pointer warping routines
	* xlib/xgc.c:
	* generic/tkRectOval.c:
	* generic/tkCanvArc.c:
	* generic/tkCanvBmap.c:
	* generic/tkCanvImg.c:
	* generic/tkCanvLine.c:
	* generic/tkCanvPoly.c:
	* generic/tkCanvPs.c:
	* generic/tkCanvText.c:
	* generic/tkCanvUtil.c:
	* generic/tkCanvWind.c:
	* generic/tkCanvas.c:
	* generic/tkCanvas.h: Canvas and items received overhaul to with
	the addition of the dash patch (Nijtmans, et al)  This includes
	objectification of the 'canvas' command, as well as support for
	(where appropriate) dashes in items, extended stipple support,
	state for all items, and postscript generation of images and
	windows.  See the new canvas man page for related docs.
	* generic/tkEntry.c: added entry widget validation, see entry.n
	* generic/tkEvent.c: on simulated events, ButtonPress should
	be matched with ButtonRelease to be correct
	* generic/tkFont.c: corrected possible null reference
	* generic/tkFrame.c: made frame a Tcl_Obj based command
	* generic/tkGet.c: added TkGetDoublePixels
	* generic/tkImage.c: bug fixes from Img patch and new
	Tk_PostscriptImage and Tk_SetTSOrigin functions
	* generic/tkImgBmap.c: new ImgBmapPostscript function
	* generic/tkImgPhoto.c: new Tk_CreatePhotoOption, Tk_DitherPhoto
	* generic/tkInt.h: declarations for some new functions
	* generic/tkMessage.c: reworked relief drawing
	* generic/tkOldConfig.c: added TK_CONFIG_OBJS so old style
	ConfigureWidget calls can pass in Tcl_Obj arrays
	* generic/tkScrollbar.c:
	* generic/tkScrollbar.h: made -orient use an option table
	* generic/tkText.c:
	* generic/tkText.h: made -wrap and -state use option tables
	* generic/tkTextBTree.c:
	* generic/tkTextDisp.c:
	* generic/tkTextImage.c:
	* generic/tkTextMark.c:
	* generic/tkTextTag.c:
	* generic/tkTextWind.c: added support for -elide and -state hidden
	* generic/tkTrig.c: changed TkMakeBezierCurve to support returning
	the upper limit of points needed for spline
	* generic/tkUtil.c: new option table parsing routines
	* generic/tkWindow.c: init'ing of warp stuff, mouseButtonState
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.5 1999/04/21 21:53:26 rjohnson Exp $
d40 6
a45 3
static char *anchorStrings[] = {"n", "ne", "e", "se", "s", "sw", "w", "nw",
	"center", (char *) NULL};
static char *justifyStrings[] = {"left", "right", "center", (char *) NULL};
@


1.6.4.1
log
@sync with head
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.8 2002/01/25 21:09:37 dgp Exp $
d40 3
a42 6
static CONST char *anchorStrings[] = {
    "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", (char *) NULL
};
static CONST char *justifyStrings[] = {
    "left", "right", "center", (char *) NULL
};
d548 1
a548 1
    CONST char *string;		/* String describing a screen distance. */
d624 1
a624 1
    CONST char *string;		/* String describing a number of pixels. */
@


1.6.8.1
log
@Merge with current TOT
Added support for the wm stackorder command
Fixed crash when selecting Menu items in the Application menu that we didn't
put there.
Added first bits of the use of CG for low-level drawing.  The line-drawing works,
the rest doesn't yet.  You have to set the file static useCGDrawing to 1 and
rebuild to activate this code.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.6 1999/12/14 06:52:28 hobbs Exp $
d40 3
a42 6
static CONST char *anchorStrings[] = {
    "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", (char *) NULL
};
static CONST char *justifyStrings[] = {
    "left", "right", "center", (char *) NULL
};
d548 1
a548 1
    CONST char *string;		/* String describing a screen distance. */
d624 1
a624 1
    CONST char *string;		/* String describing a number of pixels. */
@


1.6.8.2
log
@Merging with TOT as of 06/09/2002.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id$
a34 2
static void	FreeUidThreadExitProc _ANSI_ARGS_((ClientData clientData));

a486 26
 * FreeUidThreadExitProc --
 *
 *	Cleans up memory used for Tk_Uids in the thread.
 *
 * Results:
 *	None.
 *
 * Side effects:
 *	All information in the identifier table is deleted.
 *
 *----------------------------------------------------------------------
 */

static void
FreeUidThreadExitProc(clientData)
    ClientData clientData;		/* Not used. */
{
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    Tcl_DeleteHashTable(&tsdPtr->uidTable);
    tsdPtr->initialized = 0;
}

/*
 *----------------------------------------------------------------------
 *
a517 1
	Tcl_CreateThreadExitHandler(FreeUidThreadExitProc, NULL);
@


1.6.8.3
log
@merged with trunk at tag macosx-8-4-merge-2002-08-20-trunk
@
text
@d110 1
a110 1
    CONST char *string;		/* String describing a direction. */
d184 1
a184 1
CONST char *
d226 1
a226 1
    CONST char *string;		/* String describing a justification style. */
d272 1
a272 1
CONST char *
d308 1
a308 1
    CONST char *string;		/* String describing a justification style. */
d354 1
a354 1
CONST char *
d427 1
a427 1
    CONST char *string;		/* String describing a justification style. */
d473 1
a473 1
CONST char *
@


1.5
log
@
Merged 8-1-0 into mainline.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.4 1999/04/16 18:30:27 surles Exp $
d624 1
a624 1
    char *string;		/* String describing a justification style. */
d627 43
d673 1
a673 1
    d = strtod(string, &end);
d715 1
a715 5
    if (d < 0) {
	*intPtr = (int) (d - 0.5);
    } else {
	*intPtr = (int) (d + 0.5);
    }
@


1.4
log
@fixed Tk comment errors
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.3 1999/04/16 01:51:14 stanton Exp $
@


1.3
log
@* Merged 8.1 branch into the main trunk
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id$
d25 2
a26 2
 * Tk_Uids used by each thread.  The "dataKey" below is used to 
 * locate the ThreadSpecificData for the current thread.
d203 1
a203 1
 *	Given a string, return the corresponding Tk_JoinStyle.
d255 1
a255 1
 *	Given a Tk_JoinStyle, return the string that corresponds
d285 1
a285 1
 *	Given a string, return the corresponding Tk_CapStyle.
d337 1
a337 1
 *	Given a Tk_CapStyle, return the string that corresponds
@


1.3.2.1
log
@
Merged with mainline.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.4 1999/04/16 18:30:27 surles Exp $
d25 2
a26 2
 * Tk_Uid structs used by each thread.  The "dataKey" below is 
 * used to locate the ThreadSpecificData for the current thread.
d203 1
a203 1
 *	Given a string, return the corresponding Tk JoinStyle.
d255 1
a255 1
 *	Given a Tk JoinStyle, return the string that corresponds
d285 1
a285 1
 *	Given a string, return the corresponding Tk CapStyle.
d337 1
a337 1
 *	Given a Tk CapStyle, return the string that corresponds
@


1.2
log
@Replaced SCCS strings, fixed binary files
@
text
@d11 1
a11 1
 * Copyright (c) 1994-1995 Sun Microsystems, Inc.
d23 4
a26 2
 * The hash table below is used to keep track of all the Tk_Uids created
 * so far.
d29 52
a80 2
static Tcl_HashTable uidTable;
static int initialized = 0;
d94 1
a94 1
 *	interp->result.
d210 1
a210 1
 *	interp->result.
d292 1
a292 1
 *	interp->result.
d363 37
d411 1
a411 1
 *	interp->result.
d509 7
a515 4

    if (!initialized) {
	Tcl_InitHashTable(&uidTable, TCL_STRING_KEYS);
	initialized = 1;
d517 2
a518 2
    return (Tk_Uid) Tcl_GetHashKey(&uidTable,
	    Tcl_CreateHashEntry(&uidTable, string, &dummy));
d534 1
a534 1
 *	interp->result.
d610 1
a610 1
 *	interp->result.
d679 2
@


1.1
log
@Initial revision
@
text
@d16 1
a16 1
 * SCCS: @@(#) tkGet.c 1.13 96/04/26 10:25:46
@


1.1.4.1
log
@initial tk8.1a2 version
@
text
@d11 1
a11 1
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
d16 1
a16 1
 * SCCS: @@(#) tkGet.c 1.15 97/12/22 11:04:29
a22 9
 * The following tables defines the string values for reliefs, which are
 * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj.
 */

static char *anchorStrings[] = {"n", "ne", "e", "se", "s", "sw", "w", "nw",
	"center", (char *) NULL};
static char *justifyStrings[] = {"left", "right", "center", (char *) NULL};

/*
a30 37
 *----------------------------------------------------------------------
 *
 * Tk_GetAnchorFromObj --
 *
 *	Return a Tk_Anchor value based on the value of the objPtr.
 *
 * Results:
 *	The return value is a standard Tcl result. If an error occurs during
 *	conversion, an error message is left in the interpreter's result
 *	unless "interp" is NULL.
 *
 * Side effects:
 *	The object gets converted by Tcl_GetIndexFromObj.
 *
 *----------------------------------------------------------------------
 */

int
Tk_GetAnchorFromObj(interp, objPtr, anchorPtr)
    Tcl_Interp *interp;		/* Used for error reporting. */
    Tcl_Obj *objPtr;		/* The object we are trying to get the 
				 * value from. */
    Tk_Anchor *anchorPtr;	/* Where to place the Tk_Anchor that
				 * corresponds to the string value of
				 * objPtr. */
{
    int index, code;

    code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0, 
	    &index);
    if (code == TCL_OK) {
	*anchorPtr = (Tk_Anchor) index;
    }
    return code;
}

/*
d42 1
a42 1
 *	the interp's result.
d158 1
a158 1
 *	the interp's result.
d240 1
a240 1
 *	the interp's result.
a310 37
 *----------------------------------------------------------------------
 *
 * Tk_GetJustifyFromObj --
 *
 *	Return a Tk_Justify value based on the value of the objPtr.
 *
 * Results:
 *	The return value is a standard Tcl result. If an error occurs during
 *	conversion, an error message is left in the interpreter's result
 *	unless "interp" is NULL.
 *
 * Side effects:
 *	The object gets converted by Tcl_GetIndexFromObj.
 *
 *----------------------------------------------------------------------
 */

int
Tk_GetJustifyFromObj(interp, objPtr, justifyPtr)
    Tcl_Interp *interp;		/* Used for error reporting. */
    Tcl_Obj *objPtr;		/* The object we are trying to get the 
				 * value from. */
    Tk_Justify *justifyPtr;	/* Where to place the Tk_Justify that
				 * corresponds to the string value of
				 * objPtr. */
{
    int index, code;

    code = Tcl_GetIndexFromObj(interp, objPtr, justifyStrings,
	    "justification", 0, &index);
    if (code == TCL_OK) {
	*justifyPtr = (Tk_Justify) index;
    }
    return code;
}

/*
d322 1
a322 1
 *	the interp's result.
d442 1
a442 1
 *	the interp's result.
d518 1
a518 1
 *	the interp's result.
@


1.1.4.2
log
@Merged 8.0.3 changes into 8.1
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
@


1.1.4.3
log
@
Tk 8.1 Muti-threading changes.

Moved static and global data elements into thread-local storage,
or introduced locks where not possible, as first stage of adding
thread safety to Tk.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.1.4.2 1998/09/30 02:17:00 stanton Exp $
a22 13
 * One of these structures is created per thread to store 
 * thread-specific data.  In this case, it is used to house the 
 * Tk_Uids used by each thread.  The "dataKey" below is used to 
 * locate the ThreadSpecificData for the current thread.
 */

typedef struct ThreadSpecificData {
    int initialized;
    Tcl_HashTable uidTable;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;

/*
d31 7
d503 4
a506 7
    ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
    Tcl_HashTable *tablePtr = &tsdPtr->uidTable;

    if (!tsdPtr->initialized) {
	Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS);
	tsdPtr->initialized = 1;
d508 2
a509 2
    return (Tk_Uid) Tcl_GetHashKey(tablePtr,
	    Tcl_CreateHashEntry(tablePtr, string, &dummy));
@


1.1.4.4
log
@Removed perky gloabal Tk_Uids causing concurrency problems.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.1.4.3 1998/12/13 08:16:05 lfb Exp $
a678 81

/*
 *----------------------------------------------------------------------
 *
 * Tk_GetState --
 *
 *	Parse a state description and return the corresponding
 *	state value, or an error.
 *
 * Results:
 *	A standard Tcl return value.  If all goes well then
 *	*statePtr is filled in with one of the values
 *	TK_STATE_ACTIVE, TK_STATE_DISABLED, or TK_STATE_NORMAL.
 *      If an unknown state value is used, then *statePtr is
 *      filled with TK_STATE_UNDEFINED.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

int
Tk_GetState(interp, name, statePtr)
    Tcl_Interp *interp;		/* For error messages. */
    char *name;			/* Name of a state type. */
    int *statePtr;		/* Where to store converted state. */
{
    char c;
    size_t length;

    c = name[0];
    length = strlen(name);
    if ((c == 'a') && (strncmp(name, "active", length) == 0)) {
	*statePtr = TK_STATE_ACTIVE;
    } else if ((c == 'd') && (strncmp(name, "disabled", length) == 0)
	    && (length >= 2)) {
        *statePtr = TK_STATE_DISABLED;
    } else if ((c == 'n') && (strncmp(name, "normal", length) == 0)
	    && (length >= 2)) {
	*statePtr = TK_STATE_NORMAL;
    } else {
        *statePtr = TK_STATE_UNDEFINED;
    }
    return TCL_OK;
}

/*
 *--------------------------------------------------------------
 *
 * Tk_NameOfState --
 *
 *	Given a state value, produce a string describing that
 *	state value.
 *
 * Results:
 *	The return value is a static string that is equivalent
 *	to state.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

char *
Tk_NameOfState(state)
    int state;		/* One of TK_STATE_ACTIVE, TK_STATE_DISABLED,
			 * or TK_STATE_NORMAL */
{
    if (state == TK_STATE_ACTIVE) {
	return "active";
    } else if (state == TK_STATE_DISABLED) {
	return "disabled";
    } else if (state == TK_STATE_NORMAL) {
	return "normal";
    } else {
	return "unknown state";
    }
}

@


1.1.4.5
log
@Eliminated last stronghold of static data in the Tk core...until the next one.
@
text
@d16 1
a16 1
 * RCS: @@(#) $Id: tkGet.c,v 1.1.4.4 1999/01/07 02:42:50 lfb Exp $
d679 30
d710 49
@


