summaryrefslogtreecommitdiffstats
path: root/generic/tkStyle.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkStyle.c')
-rw-r--r--generic/tkStyle.c92
1 files changed, 45 insertions, 47 deletions
diff --git a/generic/tkStyle.c b/generic/tkStyle.c
index c2eed8f..e7401df 100644
--- a/generic/tkStyle.c
+++ b/generic/tkStyle.c
@@ -146,11 +146,11 @@ static int SetStyleFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
/*
* The following structure defines the implementation of the "style" Tcl
- * object, used for drawing. The internalRep.twoPtrValue.ptr1 field of each style
- * object points to the Style structure for the stylefont, or NULL.
+ * object, used for drawing. The internalRep.twoPtrValue.ptr1 field of each
+ * style object points to the Style structure for the stylefont, or NULL.
*/
-static Tcl_ObjType styleObjType = {
+static const Tcl_ObjType styleObjType = {
"style", /* name */
FreeStyleObjProc, /* freeIntRepProc */
DupStyleObjProc, /* dupIntRepProc */
@@ -180,7 +180,7 @@ void
TkStylePkgInit(
TkMainInfo *mainPtr) /* The application being created. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->nbInit != 0) {
@@ -208,8 +208,7 @@ TkStylePkgInit(
* Create the default system style.
*/
- Tk_CreateStyle(NULL, (Tk_StyleEngine) tsdPtr->defaultEnginePtr,
- (ClientData) 0);
+ Tk_CreateStyle(NULL, (Tk_StyleEngine) tsdPtr->defaultEnginePtr, NULL);
tsdPtr->nbInit++;
}
@@ -236,7 +235,7 @@ void
TkStylePkgFree(
TkMainInfo *mainPtr) /* The application being deleted. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr;
@@ -254,7 +253,7 @@ TkStylePkgFree(
entryPtr = Tcl_FirstHashEntry(&tsdPtr->styleTable, &search);
while (entryPtr != NULL) {
- ckfree((char *) Tcl_GetHashValue(entryPtr));
+ ckfree(Tcl_GetHashValue(entryPtr));
entryPtr = Tcl_NextHashEntry(&search);
}
Tcl_DeleteHashTable(&tsdPtr->styleTable);
@@ -265,9 +264,9 @@ TkStylePkgFree(
entryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (entryPtr != NULL) {
- enginePtr = (StyleEngine *) Tcl_GetHashValue(entryPtr);
+ enginePtr = Tcl_GetHashValue(entryPtr);
FreeStyleEngine(enginePtr);
- ckfree((char *) enginePtr);
+ ckfree(enginePtr);
entryPtr = Tcl_NextHashEntry(&search);
}
Tcl_DeleteHashTable(&tsdPtr->engineTable);
@@ -280,7 +279,7 @@ TkStylePkgFree(
FreeElement(tsdPtr->elements+i);
}
Tcl_DeleteHashTable(&tsdPtr->elementTable);
- ckfree((char *) tsdPtr->elements);
+ ckfree(tsdPtr->elements);
}
/*
@@ -308,7 +307,7 @@ Tk_RegisterStyleEngine(
Tk_StyleEngine parent) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -332,10 +331,10 @@ Tk_RegisterStyleEngine(
* Allocate and intitialize a new engine.
*/
- enginePtr = (StyleEngine *) ckalloc(sizeof(StyleEngine));
+ enginePtr = ckalloc(sizeof(StyleEngine));
InitStyleEngine(enginePtr, Tcl_GetHashKey(&tsdPtr->engineTable, entryPtr),
(StyleEngine *) parent);
- Tcl_SetHashValue(entryPtr, (ClientData) enginePtr);
+ Tcl_SetHashValue(entryPtr, enginePtr);
return (Tk_StyleEngine) enginePtr;
}
@@ -365,7 +364,7 @@ InitStyleEngine(
StyleEngine *parentPtr) /* The engine's parent. NULL means the default
* system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -390,7 +389,7 @@ InitStyleEngine(
*/
if (tsdPtr->nbElements > 0) {
- enginePtr->elements = (StyledElement *) ckalloc(
+ enginePtr->elements = ckalloc(
sizeof(StyledElement) * tsdPtr->nbElements);
for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) {
InitStyledElement(enginePtr->elements+elementId);
@@ -420,7 +419,7 @@ static void
FreeStyleEngine(
StyleEngine *enginePtr) /* The style engine to free. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
int elementId;
@@ -431,7 +430,7 @@ FreeStyleEngine(
for (elementId = 0; elementId < tsdPtr->nbElements; elementId++) {
FreeStyledElement(enginePtr->elements+elementId);
}
- ckfree((char *) enginePtr->elements);
+ ckfree(enginePtr->elements);
}
/*
@@ -455,7 +454,7 @@ Tk_GetStyleEngine(
const char *name) /* Name of the engine to retrieve. NULL or
* empty means the default system engine. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
@@ -468,7 +467,7 @@ Tk_GetStyleEngine(
return NULL;
}
- return (Tk_StyleEngine) Tcl_GetHashValue(entryPtr);
+ return Tcl_GetHashValue(entryPtr);
}
/*
@@ -579,7 +578,7 @@ FreeStyledElement(
for (i = 0; i < elementPtr->nbWidgetSpecs; i++) {
FreeWidgetSpec(elementPtr->widgetSpecs+i);
}
- ckfree((char *) elementPtr->widgetSpecs);
+ ckfree(elementPtr->widgetSpecs);
}
/*
@@ -605,7 +604,7 @@ CreateElement(
* created explicitly (being registered) or
* implicitly (by a derived element). */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr, *engineEntryPtr;
Tcl_HashSearch search;
@@ -637,13 +636,13 @@ CreateElement(
}
elementId = tsdPtr->nbElements++;
- Tcl_SetHashValue(entryPtr, (ClientData) INT2PTR(elementId));
+ Tcl_SetHashValue(entryPtr, INT2PTR(elementId));
/*
* Reallocate element table.
*/
- tsdPtr->elements = (Element *) ckrealloc((char *) tsdPtr->elements,
+ tsdPtr->elements = ckrealloc(tsdPtr->elements,
sizeof(Element) * tsdPtr->nbElements);
InitElement(tsdPtr->elements+elementId,
Tcl_GetHashKey(&tsdPtr->elementTable, entryPtr), elementId,
@@ -655,10 +654,9 @@ CreateElement(
engineEntryPtr = Tcl_FirstHashEntry(&tsdPtr->engineTable, &search);
while (engineEntryPtr != NULL) {
- enginePtr = (StyleEngine *) Tcl_GetHashValue(engineEntryPtr);
+ enginePtr = Tcl_GetHashValue(engineEntryPtr);
- enginePtr->elements = (StyledElement *) ckrealloc(
- (char *) enginePtr->elements,
+ enginePtr->elements = ckrealloc(enginePtr->elements,
sizeof(StyledElement) * tsdPtr->nbElements);
InitStyledElement(enginePtr->elements+elementId);
@@ -688,7 +686,7 @@ int
Tk_GetElementId(
const char *name) /* Name of the element. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int genericId = -1;
@@ -788,7 +786,7 @@ Tk_RegisterStyledElement(
elementPtr = ((StyleEngine *) engine)->elements+elementId;
- specPtr = (Tk_ElementSpec *) ckalloc(sizeof(Tk_ElementSpec));
+ specPtr = ckalloc(sizeof(Tk_ElementSpec));
specPtr->version = templatePtr->version;
specPtr->name = ckalloc(strlen(templatePtr->name)+1);
strcpy(specPtr->name, templatePtr->name);
@@ -797,7 +795,7 @@ Tk_RegisterStyledElement(
srcOptions->name != NULL; nbOptions++, srcOptions++) {
/* empty body */
}
- specPtr->options = (Tk_ElementOptionSpec *)
+ specPtr->options =
ckalloc(sizeof(Tk_ElementOptionSpec) * (nbOptions+1));
for (srcOptions = templatePtr->options, dstOptions = specPtr->options;
/* End condition within loop */; srcOptions++, dstOptions++) {
@@ -846,7 +844,7 @@ GetStyledElement(
int elementId) /* Unique element ID */
{
StyledElement *elementPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
StyleEngine *enginePtr2;
@@ -925,7 +923,7 @@ InitWidgetSpec(
* Build the widget option list.
*/
- widgetSpecPtr->optionsPtr = (const Tk_OptionSpec **)
+ widgetSpecPtr->optionsPtr =
ckalloc(sizeof(Tk_OptionSpec *) * nbOptions);
for (i = 0, elementOptionPtr = elementPtr->specPtr->options;
i < nbOptions; i++, elementOptionPtr++) {
@@ -966,7 +964,7 @@ FreeWidgetSpec(
StyledWidgetSpec *widgetSpecPtr)
/* The widget spec to free. */
{
- ckfree((char *) widgetSpecPtr->optionsPtr);
+ ckfree(widgetSpecPtr->optionsPtr);
}
/*
@@ -1010,8 +1008,7 @@ GetWidgetSpec(
*/
i = elementPtr->nbWidgetSpecs++;
- elementPtr->widgetSpecs = (StyledWidgetSpec *) ckrealloc(
- (char *) elementPtr->widgetSpecs,
+ elementPtr->widgetSpecs = ckrealloc(elementPtr->widgetSpecs,
sizeof(StyledWidgetSpec) * elementPtr->nbWidgetSpecs);
widgetSpecPtr = elementPtr->widgetSpecs+i;
InitWidgetSpec(widgetSpecPtr, elementPtr, optionTable);
@@ -1232,7 +1229,7 @@ Tk_CreateStyle(
Tk_StyleEngine engine, /* The style engine. */
ClientData clientData) /* Private data passed as is to engine code. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
int newEntry;
@@ -1256,11 +1253,11 @@ Tk_CreateStyle(
* Allocate and intitialize a new style.
*/
- stylePtr = (Style *) ckalloc(sizeof(Style));
+ stylePtr = ckalloc(sizeof(Style));
InitStyle(stylePtr, Tcl_GetHashKey(&tsdPtr->styleTable, entryPtr),
- (engine!=NULL ? (StyleEngine *) engine : tsdPtr->defaultEnginePtr),
+ (engine!=NULL ? (StyleEngine*) engine : tsdPtr->defaultEnginePtr),
clientData);
- Tcl_SetHashValue(entryPtr, (ClientData) stylePtr);
+ Tcl_SetHashValue(entryPtr, stylePtr);
return (Tk_Style) stylePtr;
}
@@ -1347,7 +1344,7 @@ Tk_GetStyle(
const char *name) /* Name of the style to retrieve. NULL or empty
* means the default system style. */
{
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashEntry *entryPtr;
Style *stylePtr;
@@ -1359,12 +1356,13 @@ Tk_GetStyle(
entryPtr = Tcl_FindHashEntry(&tsdPtr->styleTable, (name!=NULL?name:""));
if (entryPtr == NULL) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "style \"", name, "\" doesn't exist",
- NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "style \"%s\" doesn't exist", name));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "STYLE", name, NULL);
}
return (Tk_Style) NULL;
}
- stylePtr = (Style *) Tcl_GetHashValue(entryPtr);
+ stylePtr = Tcl_GetHashValue(entryPtr);
return (Tk_Style) stylePtr;
}
@@ -1412,7 +1410,7 @@ Tk_AllocStyleFromObj(
if (objPtr->typePtr != &styleObjType) {
SetStyleFromAny(interp, objPtr);
}
- stylePtr = (Style *) objPtr->internalRep.twoPtrValue.ptr1;
+ stylePtr = objPtr->internalRep.twoPtrValue.ptr1;
return (Tk_Style) stylePtr;
}
@@ -1444,7 +1442,7 @@ Tk_GetStyleFromObj(
SetStyleFromAny(NULL, objPtr);
}
- return (Tk_Style) objPtr->internalRep.twoPtrValue.ptr1;
+ return objPtr->internalRep.twoPtrValue.ptr1;
}
/*
@@ -1495,11 +1493,11 @@ SetStyleFromAny(
name = Tcl_GetString(objPtr);
typePtr = objPtr->typePtr;
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
- (*typePtr->freeIntRepProc)(objPtr);
+ typePtr->freeIntRepProc(objPtr);
}
objPtr->typePtr = &styleObjType;
- objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) Tk_GetStyle(interp, name);
+ objPtr->internalRep.twoPtrValue.ptr1 = Tk_GetStyle(interp, name);
return TCL_OK;
}