summaryrefslogtreecommitdiffstats
path: root/generic/tkSquare.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkSquare.c')
-rw-r--r--generic/tkSquare.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/generic/tkSquare.c b/generic/tkSquare.c
index a35832a..36d2d6e 100644
--- a/generic/tkSquare.c
+++ b/generic/tkSquare.c
@@ -16,6 +16,12 @@
#if 0
#define __NO_OLD_CONFIG
#endif
+#ifndef USE_TCL_STUBS
+# define USE_TCL_STUBS
+#endif
+#ifndef USE_TK_STUBS
+# define USE_TK_STUBS
+#endif
#include "tkInt.h"
/*
@@ -61,47 +67,44 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
"#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0,
- (ClientData) "white"},
+ "white", 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
- (ClientData) "-borderwidth"},
+ "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
- (ClientData) "-background"},
+ "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- "2", Tk_Offset(Square, borderWidthPtr), -1},
+ "2", Tk_Offset(Square, borderWidthPtr), -1, 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer",
- "1", Tk_Offset(Square, doubleBufferPtr), -1},
+ "1", Tk_Offset(Square, doubleBufferPtr), -1, 0 , NULL, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, -1, 0,
- (ClientData) "-foreground"},
+ "-foreground", 0},
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
"#b03060", Tk_Offset(Square, fgBorderPtr), -1, 0,
- (ClientData) "black"},
+ "black", 0},
{TK_OPTION_PIXELS, "-posx", "posx", "PosX", "0",
- Tk_Offset(Square, xPtr), -1},
+ Tk_Offset(Square, xPtr), -1, 0, NULL, 0},
{TK_OPTION_PIXELS, "-posy", "posy", "PosY", "0",
- Tk_Offset(Square, yPtr), -1},
+ Tk_Offset(Square, yPtr), -1, 0, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", Tk_Offset(Square, reliefPtr), -1},
+ "raised", Tk_Offset(Square, reliefPtr), -1, 0, NULL, 0},
{TK_OPTION_PIXELS, "-size", "size", "Size", "20",
- Tk_Offset(Square, sizeObjPtr), -1},
- {TK_OPTION_END}
+ Tk_Offset(Square, sizeObjPtr), -1, 0, NULL, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
/*
* Forward declarations for procedures defined later in this file:
*/
-int SquareObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * CONST objv[]);
static void SquareDeletedProc(ClientData clientData);
static int SquareConfigure(Tcl_Interp *interp, Square *squarePtr);
-static void SquareDestroy(char *memPtr);
+static void SquareDestroy(void *memPtr);
static void SquareDisplay(ClientData clientData);
static void KeepInWindow(Square *squarePtr);
static void SquareObjEventProc(ClientData clientData,
XEvent *eventPtr);
static int SquareWidgetObjCmd(ClientData clientData,
- Tcl_Interp *, int objc, Tcl_Obj * CONST objv[]);
+ Tcl_Interp *, int objc, Tcl_Obj * const objv[]);
/*
*--------------------------------------------------------------
@@ -125,14 +128,14 @@ SquareObjCmd(
ClientData clientData, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj *CONST objv[]) /* Argument objects. */
+ Tcl_Obj *const objv[]) /* Argument objects. */
{
Square *squarePtr;
Tk_Window tkwin;
Tk_OptionTable optionTable;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?");
+ Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
return TCL_ERROR;
}
@@ -157,27 +160,27 @@ SquareObjCmd(
* just the non-NULL/0 items.
*/
- squarePtr = (Square *) ckalloc(sizeof(Square));
- memset((void *) squarePtr, 0, (sizeof(Square)));
+ squarePtr = ckalloc(sizeof(Square));
+ memset(squarePtr, 0, sizeof(Square));
squarePtr->tkwin = tkwin;
squarePtr->display = Tk_Display(tkwin);
squarePtr->interp = interp;
squarePtr->widgetCmd = Tcl_CreateObjCommand(interp,
- Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd,
- (ClientData) squarePtr, SquareDeletedProc);
+ Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, squarePtr,
+ SquareDeletedProc);
squarePtr->gc = None;
squarePtr->optionTable = optionTable;
if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin)
!= TCL_OK) {
Tk_DestroyWindow(squarePtr->tkwin);
- ckfree((char *) squarePtr);
+ ckfree(squarePtr);
return TCL_ERROR;
}
Tk_CreateEventHandler(squarePtr->tkwin, ExposureMask|StructureNotifyMask,
- SquareObjEventProc, (ClientData) squarePtr);
+ SquareObjEventProc, squarePtr);
if (Tk_SetOptions(interp, (char *) squarePtr, optionTable, objc - 2,
objv + 2, tkwin, NULL, NULL) != TCL_OK) {
goto error;
@@ -218,11 +221,11 @@ SquareWidgetObjCmd(
ClientData clientData, /* Information about square widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
- Tcl_Obj * CONST objv[]) /* Argument objects. */
+ Tcl_Obj * const objv[]) /* Argument objects. */
{
- Square *squarePtr = (Square *) clientData;
+ Square *squarePtr = clientData;
int result = TCL_OK;
- static CONST char *squareOptions[] = {"cget", "configure", NULL};
+ static const char *const squareOptions[] = {"cget", "configure", NULL};
enum {
SQUARE_CGET, SQUARE_CONFIGURE
};
@@ -234,12 +237,12 @@ SquareWidgetObjCmd(
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObj(interp, objv[1], squareOptions, "command",
- 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[1], squareOptions,
+ sizeof(char *), "command", 0, &index) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_Preserve((ClientData) squarePtr);
+ Tcl_Preserve(squarePtr);
switch (index) {
case SQUARE_CGET:
@@ -277,7 +280,7 @@ SquareWidgetObjCmd(
result = SquareConfigure(interp, squarePtr);
}
if (!squarePtr->updatePending) {
- Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr);
+ Tcl_DoWhenIdle(SquareDisplay, squarePtr);
squarePtr->updatePending = 1;
}
}
@@ -285,11 +288,11 @@ SquareWidgetObjCmd(
Tcl_SetObjResult(interp, resultObjPtr);
}
}
- Tcl_Release((ClientData) squarePtr);
+ Tcl_Release(squarePtr);
return result;
error:
- Tcl_Release((ClientData) squarePtr);
+ Tcl_Release(squarePtr);
return TCL_ERROR;
}
@@ -350,7 +353,7 @@ SquareConfigure(
&borderWidth);
Tk_SetInternalBorder(squarePtr->tkwin, borderWidth);
if (!squarePtr->updatePending) {
- Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr);
+ Tcl_DoWhenIdle(SquareDisplay, squarePtr);
squarePtr->updatePending = 1;
}
KeepInWindow(squarePtr);
@@ -380,17 +383,17 @@ SquareObjEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Square *squarePtr = (Square *) clientData;
+ Square *squarePtr = clientData;
if (eventPtr->type == Expose) {
if (!squarePtr->updatePending) {
- Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr);
+ Tcl_DoWhenIdle(SquareDisplay, squarePtr);
squarePtr->updatePending = 1;
}
} else if (eventPtr->type == ConfigureNotify) {
KeepInWindow(squarePtr);
if (!squarePtr->updatePending) {
- Tcl_DoWhenIdle(SquareDisplay, (ClientData) squarePtr);
+ Tcl_DoWhenIdle(SquareDisplay, squarePtr);
squarePtr->updatePending = 1;
}
} else if (eventPtr->type == DestroyNotify) {
@@ -405,9 +408,9 @@ SquareObjEventProc(
squarePtr->widgetCmd);
}
if (squarePtr->updatePending) {
- Tcl_CancelIdleCall(SquareDisplay, (ClientData) squarePtr);
+ Tcl_CancelIdleCall(SquareDisplay, squarePtr);
}
- Tcl_EventuallyFree((ClientData) squarePtr, SquareDestroy);
+ Tcl_EventuallyFree(squarePtr, (Tcl_FreeProc *) SquareDestroy);
}
}
@@ -433,7 +436,7 @@ static void
SquareDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Square *squarePtr = (Square *) clientData;
+ Square *squarePtr = clientData;
Tk_Window tkwin = squarePtr->tkwin;
/*
@@ -470,7 +473,7 @@ static void
SquareDisplay(
ClientData clientData) /* Information about window. */
{
- Square *squarePtr = (Square *) clientData;
+ Square *squarePtr = clientData;
Tk_Window tkwin = squarePtr->tkwin;
Pixmap pm = None;
Drawable d;
@@ -551,11 +554,11 @@ SquareDisplay(
static void
SquareDestroy(
- char *memPtr) /* Info about square widget. */
+ void *memPtr) /* Info about square widget. */
{
- Square *squarePtr = (Square *) memPtr;
+ Square *squarePtr = memPtr;
- ckfree((char *) squarePtr);
+ ckfree(squarePtr);
}
/*