|
78 | 78 | #undef Tcl_InitHashTable |
79 | 79 | #define Tcl_InitHashTable (tclStubsPtr->tcl_InitHashTable) |
80 | 80 | #endif |
81 | | -#if (TK_MAJOR_VERSION>=8 && TK_MINOR_VERSION>=4) |
| 81 | +#if TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION >= 804 |
82 | 82 | # define HAVE_TK_SETCLASSPROCS |
83 | 83 | #endif |
84 | 84 |
|
|
87 | 87 | * (this is needed for Tcl ver =< 8.4a3) |
88 | 88 | */ |
89 | 89 |
|
| 90 | +#ifndef _ANSI_ARGS_ |
| 91 | +#define _ANSI_ARGS_(x) x |
| 92 | +#endif |
| 93 | + |
| 94 | +#ifndef Tk_Offset |
| 95 | +#define Tk_Offset offsetof |
| 96 | +#endif |
| 97 | + |
90 | 98 | typedef int (TkBindEvalProc) _ANSI_ARGS_((ClientData clientData, |
91 | 99 | Tcl_Interp *interp, XEvent *eventPtr, Tk_Window tkwin, |
92 | 100 | KeySym keySym)); |
@@ -700,18 +708,18 @@ int Togl_Init(Tcl_Interp *interp) |
700 | 708 | int major,minor,patchLevel,releaseType; |
701 | 709 |
|
702 | 710 | #ifdef USE_TCL_STUBS |
703 | | - if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {return TCL_ERROR;} |
| 711 | + if (Tcl_InitStubs(interp, TCL_VERSION, 0) == NULL) {return TCL_ERROR;} |
704 | 712 | #endif |
705 | 713 | #ifdef USE_TK_STUBS |
706 | | - if (Tk_InitStubs(interp, "8.1", 0) == NULL) {return TCL_ERROR;} |
| 714 | + if (Tk_InitStubs(interp, TK_VERSION, 0) == NULL) {return TCL_ERROR;} |
707 | 715 | #endif |
708 | 716 |
|
709 | 717 | /* Skip all this on Tcl/Tk 8.0 or older. Seems to work */ |
710 | 718 | #if TCL_MAJOR_VERSION * 100 + TCL_MINOR_VERSION > 800 |
711 | 719 | Tcl_GetVersion(&major,&minor,&patchLevel,&releaseType); |
712 | 720 |
|
713 | 721 | #ifndef HAVE_TK_SETCLASSPROCS |
714 | | - if (major >= 8 && minor >= 4) { |
| 722 | + if (major * 100 + minor >= 804) { |
715 | 723 | TCL_ERR(interp,"Sorry, this instance of Togl was not compiled to work with Tcl/Tk 8.4 or higher."); |
716 | 724 | } |
717 | 725 | #endif |
@@ -1049,13 +1057,26 @@ int Togl_Configure(Tcl_Interp *interp, struct Togl *togl, |
1049 | 1057 | int oldStencilSize = togl->StencilSize; |
1050 | 1058 | int oldAuxNumber = togl->AuxNumber; |
1051 | 1059 |
|
1052 | | -#ifndef CONST84 |
1053 | | -#define CONST84 |
| 1060 | +#if TK_MAJOR_VERSION >= 9 |
| 1061 | + // Version 9+ uses Tcl_Obj* array as config whereas older uses a char* array |
| 1062 | + Tcl_Obj **optr = calloc(argc+1, sizeof(*optr)); // argc+1 to terminate list with a NULL pointer |
| 1063 | + for(int u = 0; u < argc; u++) { |
| 1064 | + optr[u] = Tcl_NewStringObj(argv[u], -1); |
| 1065 | + } |
| 1066 | +#else |
| 1067 | + char **optr = argv; |
1054 | 1068 | #endif |
1055 | 1069 | if (Tk_ConfigureWidget(interp, togl->TkWin, configSpecs, |
1056 | | - argc, (CONST84 char**)argv, (char *)togl, flags) == TCL_ERROR) { |
| 1070 | + argc, (void *)optr, (char *)togl, flags) == TCL_ERROR) { |
1057 | 1071 | return(TCL_ERROR); |
1058 | 1072 | } |
| 1073 | +#if TK_VERSION_MAJOR >= 9 |
| 1074 | + for(int u = 0; u < argc; u++) { |
| 1075 | + Tcl_DecrRefCount(optr[u]); |
| 1076 | + } |
| 1077 | + free(optr); |
| 1078 | +#endif |
| 1079 | + |
1059 | 1080 | #ifndef USE_OVERLAY |
1060 | 1081 | if (togl->OverlayFlag) { |
1061 | 1082 | TCL_ERR(interp,"Sorry, overlay was disabled"); |
@@ -1126,7 +1147,7 @@ int Togl_Widget(ClientData clientData, Tcl_Interp *interp, |
1126 | 1147 | return TCL_ERROR; |
1127 | 1148 | } |
1128 | 1149 |
|
1129 | | - Tk_Preserve((ClientData)togl); |
| 1150 | + Tcl_Preserve((ClientData)togl); |
1130 | 1151 |
|
1131 | 1152 | if (!strncmp(argv[1], "configure", MAX(1, strlen(argv[1])))) { |
1132 | 1153 | if (argc == 2) { |
@@ -1237,12 +1258,10 @@ int Togl_Widget(ClientData clientData, Tcl_Interp *interp, |
1237 | 1258 | } |
1238 | 1259 | } |
1239 | 1260 |
|
1240 | | - Tk_Release((ClientData)togl); |
| 1261 | + Tcl_Release((ClientData)togl); |
1241 | 1262 | return result; |
1242 | 1263 | } |
1243 | 1264 |
|
1244 | | - |
1245 | | - |
1246 | 1265 | /* |
1247 | 1266 | * Togl_Cmd |
1248 | 1267 | * |
@@ -1421,7 +1440,7 @@ static int Togl_Cmd(ClientData clientData, Tcl_Interp *interp, |
1421 | 1440 |
|
1422 | 1441 | /* If defined, setup timer */ |
1423 | 1442 | if (togl->TimerProc){ |
1424 | | - Tk_CreateTimerHandler( togl->TimerInterval, Togl_Timer, (ClientData)togl ); |
| 1443 | + Tcl_CreateTimerHandler( togl->TimerInterval, Togl_Timer, (ClientData)togl ); |
1425 | 1444 | } |
1426 | 1445 |
|
1427 | 1446 | Tcl_AppendResult(interp, Tk_PathName(tkwin), NULL); |
@@ -2153,7 +2172,11 @@ static void ToglCmdDeletedProc( ClientData clientData ) |
2153 | 2172 | * Gets called when an Togl widget is destroyed. |
2154 | 2173 | */ |
2155 | 2174 | #if (TK_MAJOR_VERSION * 100 + TK_MINOR_VERSION) >= 401 |
| 2175 | +#if TK_MAJOR_VERSION >= 9 |
| 2176 | +static void Togl_Destroy( void *clientData ) |
| 2177 | +#else |
2156 | 2178 | static void Togl_Destroy( char *clientData ) |
| 2179 | +#endif |
2157 | 2180 | #else |
2158 | 2181 | static void Togl_Destroy( ClientData clientData ) |
2159 | 2182 | #endif |
@@ -2284,7 +2307,7 @@ void Togl_PostRedisplay( struct Togl *togl ) |
2284 | 2307 | { |
2285 | 2308 | if (!togl->UpdatePending) { |
2286 | 2309 | togl->UpdatePending = GL_TRUE; |
2287 | | - Tk_DoWhenIdle( Togl_Render, (ClientData) togl ); |
| 2310 | + Tcl_DoWhenIdle( Togl_Render, (ClientData) togl ); |
2288 | 2311 | } |
2289 | 2312 | } |
2290 | 2313 |
|
@@ -2863,7 +2886,7 @@ void Togl_PostOverlayRedisplay( struct Togl *togl ) |
2863 | 2886 | { |
2864 | 2887 | if (!togl->OverlayUpdatePending |
2865 | 2888 | && togl->OverlayWindow && togl->OverlayDisplayProc) { |
2866 | | - Tk_DoWhenIdle( RenderOverlay, (ClientData) togl ); |
| 2889 | + Tcl_DoWhenIdle( RenderOverlay, (ClientData) togl ); |
2867 | 2890 | togl->OverlayUpdatePending = 1; |
2868 | 2891 | } |
2869 | 2892 | } |
|
0 commit comments