summaryrefslogtreecommitdiffstats
path: root/generic/tkGet.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGet.c')
-rw-r--r--generic/tkGet.c128
1 files changed, 111 insertions, 17 deletions
diff --git a/generic/tkGet.c b/generic/tkGet.c
index 3507e9b..95833a1 100644
--- a/generic/tkGet.c
+++ b/generic/tkGet.c
@@ -8,24 +8,76 @@
* files.
*
* Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * 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.2 1998/09/14 18:23:11 stanton Exp $
+ * RCS: @(#) $Id: tkGet.c,v 1.3 1999/04/16 01:51:14 stanton Exp $
*/
#include "tkInt.h"
#include "tkPort.h"
/*
- * The hash table below is used to keep track of all the Tk_Uids created
- * so far.
+ * 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.
*/
-static Tcl_HashTable uidTable;
-static int initialized = 0;
+typedef struct ThreadSpecificData {
+ int initialized;
+ Tcl_HashTable uidTable;
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
+
+/*
+ * 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};
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * 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;
+}
/*
*--------------------------------------------------------------
@@ -39,7 +91,7 @@ static int initialized = 0;
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -155,7 +207,7 @@ Tk_NameOfAnchor(anchor)
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -237,7 +289,7 @@ Tk_NameOfJoinStyle(join)
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -308,6 +360,43 @@ Tk_NameOfCapStyle(cap)
}
/*
+ *----------------------------------------------------------------------
+ *
+ * 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;
+}
+
+/*
*--------------------------------------------------------------
*
* Tk_GetJustify --
@@ -319,7 +408,7 @@ Tk_NameOfCapStyle(cap)
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -417,13 +506,16 @@ Tk_GetUid(string)
CONST char *string; /* String to convert. */
{
int dummy;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ Tcl_HashTable *tablePtr = &tsdPtr->uidTable;
- if (!initialized) {
- Tcl_InitHashTable(&uidTable, TCL_STRING_KEYS);
- initialized = 1;
+ if (!tsdPtr->initialized) {
+ Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS);
+ tsdPtr->initialized = 1;
}
- return (Tk_Uid) Tcl_GetHashKey(&uidTable,
- Tcl_CreateHashEntry(&uidTable, string, &dummy));
+ return (Tk_Uid) Tcl_GetHashKey(tablePtr,
+ Tcl_CreateHashEntry(tablePtr, string, &dummy));
}
/*
@@ -439,7 +531,7 @@ Tk_GetUid(string)
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -515,7 +607,7 @@ Tk_GetScreenMM(interp, tkwin, string, doublePtr)
* 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
- * interp->result.
+ * the interp's result.
*
* Side effects:
* None.
@@ -584,3 +676,5 @@ Tk_GetPixels(interp, tkwin, string, intPtr)
}
return TCL_OK;
}
+
+