diff options
Diffstat (limited to 'generic/tkPanedWindow.c')
-rw-r--r-- | generic/tkPanedWindow.c | 266 |
1 files changed, 130 insertions, 136 deletions
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 733610e..cf3611f 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -270,11 +270,11 @@ static const Tk_ObjCustomOption stickyOption = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", DEF_PANEDWINDOW_BG_COLOR, -1, Tk_Offset(PanedWindow, background), 0, - DEF_PANEDWINDOW_BG_MONO, 0}, + (ClientData) DEF_PANEDWINDOW_BG_MONO}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, "-borderwidth", 0}, + NULL, 0, -1, 0, (ClientData) "-borderwidth"}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, "-background", 0}, + NULL, 0, -1, 0, (ClientData) "-background"}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth), 0, 0, GEOMETRY}, @@ -295,7 +295,7 @@ static const Tk_OptionSpec optionSpecs[] = { Tk_Offset(PanedWindow, resizeOpaque), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", DEF_PANEDWINDOW_ORIENT, -1, Tk_Offset(PanedWindow, orient), - 0, orientStrings, GEOMETRY}, + 0, (ClientData) orientStrings, GEOMETRY}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_PANEDWINDOW_RELIEF, -1, Tk_Offset(PanedWindow, relief), 0, 0, 0}, {TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor", @@ -316,7 +316,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-width", "width", "Width", DEF_PANEDWINDOW_WIDTH, Tk_Offset(PanedWindow, widthPtr), Tk_Offset(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} + {TK_OPTION_END} }; static const Tk_OptionSpec slaveOptionSpecs[] = { @@ -339,14 +339,14 @@ static const Tk_OptionSpec slaveOptionSpecs[] = { DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Slave, pady), 0, 0, 0}, {TK_OPTION_CUSTOM, "-sticky", NULL, NULL, DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Slave, sticky), 0, - &stickyOption, 0}, + (ClientData) &stickyOption, 0}, {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch", DEF_PANEDWINDOW_PANE_STRETCH, -1, Tk_Offset(Slave, stretch), 0, (ClientData) stretchStrings, 0}, {TK_OPTION_PIXELS, "-width", NULL, NULL, DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Slave, widthPtr), Tk_Offset(Slave, width), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} + {TK_OPTION_END} }; /* @@ -379,12 +379,12 @@ Tk_PanedWindowObjCmd( XSetWindowAttributes atts; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); return TCL_ERROR; } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetString(objv[1]), NULL); + Tcl_GetStringFromObj(objv[1], NULL), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -399,14 +399,14 @@ Tk_PanedWindowObjCmd( * easy access to it in the future. */ - pwOpts = ckalloc(sizeof(OptionTables)); + pwOpts = (OptionTables *) ckalloc(sizeof(OptionTables)); /* * Set up an exit handler to free the optionTables struct. */ Tcl_SetAssocData(interp, "PanedWindowOptionTables", - DestroyOptionTables, pwOpts); + DestroyOptionTables, (ClientData) pwOpts); /* * Create the paned window option tables. @@ -422,14 +422,14 @@ Tk_PanedWindowObjCmd( * Allocate and initialize the widget record. */ - pwPtr = ckalloc(sizeof(PanedWindow)); + pwPtr = (PanedWindow *) ckalloc(sizeof(PanedWindow)); memset((void *)pwPtr, 0, (sizeof(PanedWindow))); pwPtr->tkwin = tkwin; pwPtr->display = Tk_Display(tkwin); pwPtr->interp = interp; pwPtr->widgetCmd = Tcl_CreateObjCommand(interp, - Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, pwPtr, - PanedWindowCmdDeletedProc); + Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, + (ClientData) pwPtr, PanedWindowCmdDeletedProc); pwPtr->optionTable = pwOpts->pwOptions; pwPtr->slaveOpts = pwOpts->slaveOpts; pwPtr->relief = TK_RELIEF_RAISED; @@ -442,7 +442,7 @@ Tk_PanedWindowObjCmd( * otherwise Tk might free it while we still need it. */ - Tcl_Preserve(pwPtr->tkwin); + Tcl_Preserve((ClientData) pwPtr->tkwin); if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions, tkwin) != TCL_OK) { @@ -451,7 +451,7 @@ Tk_PanedWindowObjCmd( } Tk_CreateEventHandler(pwPtr->tkwin, ExposureMask|StructureNotifyMask, - PanedWindowEventProc, pwPtr); + PanedWindowEventProc, (ClientData) pwPtr); /* * Find the toplevel ancestor of the panedwindow, and make a proxy win as @@ -481,7 +481,7 @@ Tk_PanedWindowObjCmd( Tk_SetWindowVisual(pwPtr->proxywin, Tk_Visual(tkwin), Tk_Depth(tkwin), Tk_Colormap(tkwin)); Tk_CreateEventHandler(pwPtr->proxywin, ExposureMask, ProxyWindowEventProc, - pwPtr); + (ClientData) pwPtr); atts.save_under = True; Tk_ChangeWindowAttributes(pwPtr->proxywin, CWSaveUnder, &atts); @@ -491,7 +491,7 @@ Tk_PanedWindowObjCmd( return TCL_ERROR; } - Tcl_SetObjResult(interp, TkNewWindowObj(pwPtr->tkwin)); + Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(pwPtr->tkwin), -1); return TCL_OK; } @@ -520,9 +520,9 @@ PanedWindowWidgetObjCmd( int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; int result = TCL_OK; - static const char *const optionStrings[] = { + static const char *optionStrings[] = { "add", "cget", "configure", "forget", "identify", "panecget", "paneconfigure", "panes", "proxy", "sash", NULL }; @@ -545,7 +545,7 @@ PanedWindowWidgetObjCmd( return TCL_ERROR; } - Tcl_Preserve(pwPtr); + Tcl_Preserve((ClientData) pwPtr); switch ((enum options) index) { case PW_ADD: @@ -603,17 +603,16 @@ PanedWindowWidgetObjCmd( for (count = 0, i = 2; i < objc; i++) { Tk_Window slave = Tk_NameToWindow(interp, Tcl_GetString(objv[i]), pwPtr->tkwin); - if (slave == NULL) { continue; } slavePtr = GetPane(pwPtr, slave); if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) { count++; - Tk_ManageGeometry(slave, NULL, NULL); + Tk_ManageGeometry(slave, NULL, (ClientData)NULL); Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); + SlaveStructureProc, (ClientData) slavePtr); Tk_UnmapWindow(slavePtr->tkwin); Unlink(slavePtr); } @@ -658,13 +657,10 @@ PanedWindowWidgetObjCmd( objv[3], tkwin); } } + if (i == pwPtr->numSlaves) { + Tcl_SetResult(interp, "not managed by this window", TCL_STATIC); + } if (resultObj == NULL) { - if (i == pwPtr->numSlaves) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "not managed by this window", -1)); - Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", - NULL); - } result = TCL_ERROR; } else { Tcl_SetObjResult(interp, resultObj); @@ -703,11 +699,15 @@ PanedWindowWidgetObjCmd( case PW_PANES: resultObj = Tcl_NewObj(); + + Tcl_IncrRefCount(resultObj); + for (i = 0; i < pwPtr->numSlaves; i++) { - Tcl_ListObjAppendElement(NULL, resultObj, - TkNewWindowObj(pwPtr->slaves[i]->tkwin)); + Tcl_ListObjAppendElement(interp, resultObj, + Tcl_NewStringObj(Tk_PathName(pwPtr->slaves[i]->tkwin),-1)); } Tcl_SetObjResult(interp, resultObj); + Tcl_DecrRefCount(resultObj); break; case PW_PROXY: @@ -718,7 +718,7 @@ PanedWindowWidgetObjCmd( result = PanedWindowSashCommand(pwPtr, interp, objc, objv); break; } - Tcl_Release(pwPtr); + Tcl_Release((ClientData) pwPtr); return result; } @@ -751,7 +751,7 @@ ConfigureSlaves( Tk_Window tkwin = NULL, ancestor, parent; Slave *slavePtr, **inserts, **newSlaves; Slave options; - const char *arg; + char *arg; /* * Find the non-window name arguments; these are the configure options for @@ -777,19 +777,18 @@ ConfigureSlaves( * A panedwindow cannot manage itself. */ - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't add %s to itself", arg)); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add ", arg, " to itself", + NULL); return TCL_ERROR; } else if (Tk_IsTopLevel(tkwin)) { /* * A panedwindow cannot manage a toplevel. */ - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't add toplevel %s to %s", arg, - Tk_PathName(pwPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add toplevel ", arg, " to ", + Tk_PathName(pwPtr->tkwin), NULL); return TCL_ERROR; } else { /* @@ -803,11 +802,9 @@ ConfigureSlaves( break; } if (Tk_IsTopLevel(ancestor)) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't add %s to %s", arg, - Tk_PathName(pwPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "GEOMETRY", - "HIERARCHY", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "can't add ", arg, " to ", + Tk_PathName(pwPtr->tkwin), NULL); return TCL_ERROR; } } @@ -864,10 +861,9 @@ ConfigureSlaves( */ if (haveLoc && index == -1) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "window \"%s\" is not managed by %s", - Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin))); - Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "window \"", Tk_PathName(tkwin), + "\" is not managed by ", Tk_PathName(pwPtr->tkwin), NULL); Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin); return TCL_ERROR; @@ -879,7 +875,7 @@ ConfigureSlaves( * structures may already have existed, some may be new. */ - inserts = ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); + inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); insertIndex = 0; /* @@ -946,7 +942,7 @@ ConfigureSlaves( * out with their "natural" dimensions. */ - slavePtr = ckalloc(sizeof(Slave)); + slavePtr = (Slave *) ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, pwPtr->tkwin); @@ -975,8 +971,9 @@ ConfigureSlaves( */ Tk_CreateEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); - Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, slavePtr); + SlaveStructureProc, (ClientData) slavePtr); + Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, + (ClientData) slavePtr); inserts[insertIndex++] = slavePtr; numNewSlaves++; } @@ -985,8 +982,8 @@ ConfigureSlaves( * Allocate the new slaves array, then copy the slaves into it, in order. */ - i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves); - newSlaves = ckalloc(i); + i = sizeof(Slave *) * (pwPtr->numSlaves+numNewSlaves); + newSlaves = (Slave **)ckalloc((unsigned) i); memset(newSlaves, 0, (size_t) i); if (index == -1) { /* @@ -1029,8 +1026,8 @@ ConfigureSlaves( * Make the new slaves array the paned window's slave array, and clean up. */ - ckfree(pwPtr->slaves); - ckfree(inserts); + ckfree((void *)pwPtr->slaves); + ckfree((void *)inserts); pwPtr->slaves = newSlaves; /* @@ -1069,7 +1066,7 @@ PanedWindowSashCommand( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static const char *const sashOptionStrings[] = { + static const char *sashOptionStrings[] = { "coord", "dragto", "mark", "place", NULL }; enum sashOptions { @@ -1089,6 +1086,7 @@ PanedWindowSashCommand( return TCL_ERROR; } + Tcl_ResetResult(interp); switch ((enum sashOptions) index) { case SASH_COORD: if (objc != 4) { @@ -1101,16 +1099,15 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "invalid sash index", -1)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); return TCL_ERROR; } slavePtr = pwPtr->slaves[sash]; coords[0] = Tcl_NewIntObj(slavePtr->sashx); coords[1] = Tcl_NewIntObj(slavePtr->sashy); - Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); break; case SASH_MARK: @@ -1124,9 +1121,8 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "invalid sash index", -1)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); return TCL_ERROR; } @@ -1144,7 +1140,7 @@ PanedWindowSashCommand( } else { coords[0] = Tcl_NewIntObj(pwPtr->slaves[sash]->markx); coords[1] = Tcl_NewIntObj(pwPtr->slaves[sash]->marky); - Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); } break; @@ -1160,9 +1156,8 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "invalid sash index", -1)); - Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); + Tcl_ResetResult(interp); + Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); return TCL_ERROR; } @@ -1233,7 +1228,7 @@ ConfigurePanedWindow( Tk_FreeSavedOptions(&savedOptions); - PanedWindowWorldChanged(pwPtr); + PanedWindowWorldChanged((ClientData) pwPtr); /* * If an option that affects geometry has changed, make a re-layout @@ -1271,7 +1266,7 @@ PanedWindowWorldChanged( { XGCValues gcValues; GC newGC; - PanedWindow *pwPtr = instanceData; + PanedWindow *pwPtr = (PanedWindow *) instanceData; /* * Allocated a graphics context for drawing the paned window widget @@ -1300,7 +1295,7 @@ PanedWindowWorldChanged( */ if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); pwPtr->flags |= REDRAW_PENDING; } } @@ -1328,17 +1323,17 @@ PanedWindowEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; if (eventPtr->type == Expose) { if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); pwPtr->flags |= REDRAW_PENDING; } } else if (eventPtr->type == ConfigureNotify) { pwPtr->flags |= REQUESTED_RELAYOUT; if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); pwPtr->flags |= REDRAW_PENDING; } } else if (eventPtr->type == DestroyNotify) { @@ -1368,7 +1363,7 @@ static void PanedWindowCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; /* * This function could be invoked either because the window was destroyed @@ -1405,7 +1400,7 @@ static void DisplayPanedWindow( ClientData clientData) /* Information about window. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; Slave *slavePtr; Pixmap pixmap; Tk_Window tkwin = pwPtr->tkwin; @@ -1523,10 +1518,10 @@ DestroyPanedWindow( */ if (pwPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayPanedWindow, pwPtr); + Tcl_CancelIdleCall(DisplayPanedWindow, (ClientData) pwPtr); } if (pwPtr->flags & RESIZE_PENDING) { - Tcl_CancelIdleCall(ArrangePanes, pwPtr); + Tcl_CancelIdleCall(ArrangePanes, (ClientData) pwPtr); } /* @@ -1538,15 +1533,15 @@ DestroyPanedWindow( for (i = 0; i < pwPtr->numSlaves; i++) { Tk_DeleteEventHandler(pwPtr->slaves[i]->tkwin, StructureNotifyMask, - SlaveStructureProc, pwPtr->slaves[i]); + SlaveStructureProc, (ClientData) pwPtr->slaves[i]); Tk_ManageGeometry(pwPtr->slaves[i]->tkwin, NULL, NULL); - Tk_FreeConfigOptions((char *) pwPtr->slaves[i], pwPtr->slaveOpts, + Tk_FreeConfigOptions((char *)pwPtr->slaves[i], pwPtr->slaveOpts, pwPtr->tkwin); - ckfree(pwPtr->slaves[i]); + ckfree((void *)pwPtr->slaves[i]); pwPtr->slaves[i] = NULL; } if (pwPtr->slaves) { - ckfree(pwPtr->slaves); + ckfree((char *) pwPtr->slaves); } /* @@ -1560,10 +1555,10 @@ DestroyPanedWindow( */ Tk_FreeConfigOptions((char *) pwPtr, pwPtr->optionTable, pwPtr->tkwin); - Tcl_Release(pwPtr->tkwin); + Tcl_Release((ClientData) pwPtr->tkwin); pwPtr->tkwin = NULL; - Tcl_EventuallyFree(pwPtr, TCL_DYNAMIC); + Tcl_EventuallyFree((ClientData) pwPtr, TCL_DYNAMIC); } /* @@ -1591,13 +1586,12 @@ PanedWindowReqProc( Tk_Window tkwin) /* Other Tk-related information about the * window. */ { - Slave *slavePtr = clientData; - PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr; - + Slave *slavePtr = (Slave *) clientData; + PanedWindow *pwPtr = (PanedWindow *) (slavePtr->masterPtr); if (Tk_IsMapped(pwPtr->tkwin)) { if (!(pwPtr->flags & RESIZE_PENDING)) { pwPtr->flags |= RESIZE_PENDING; - Tcl_DoWhenIdle(ArrangePanes, pwPtr); + Tcl_DoWhenIdle(ArrangePanes, (ClientData) pwPtr); } } else { int doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; @@ -1636,18 +1630,18 @@ PanedWindowLostSlaveProc( * stolen away. */ Tk_Window tkwin) /* Tk's handle for the slave window. */ { - register Slave *slavePtr = clientData; - PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr; + register Slave *slavePtr = (Slave *) clientData; + PanedWindow *pwPtr = (PanedWindow *) (slavePtr->masterPtr); if (pwPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); } Unlink(slavePtr); Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, slavePtr); + SlaveStructureProc, (ClientData) slavePtr); Tk_UnmapWindow(slavePtr->tkwin); slavePtr->tkwin = NULL; - ckfree(slavePtr); + ckfree((void *)slavePtr); ComputeGeometry(pwPtr); } @@ -1675,7 +1669,7 @@ ArrangePanes( ClientData clientData) /* Structure describing parent whose slaves * are to be re-layed out. */ { - register PanedWindow *pwPtr = clientData; + register PanedWindow *pwPtr = (PanedWindow *) clientData; register Slave *slavePtr; int i, slaveWidth, slaveHeight, slaveX, slaveY; int paneWidth, paneHeight, paneSize, paneMinSize; @@ -1702,7 +1696,7 @@ ArrangePanes( return; } - Tcl_Preserve(pwPtr); + Tcl_Preserve((ClientData) pwPtr); /* * Find index of last visible pane. @@ -1945,7 +1939,7 @@ ArrangePanes( } sashCount--; } - Tcl_Release(pwPtr); + Tcl_Release((ClientData) pwPtr); } /* @@ -2006,7 +2000,7 @@ Unlink( masterPtr->flags |= REQUESTED_RELAYOUT; if (!(masterPtr->flags & REDRAW_PENDING)) { masterPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayPanedWindow, masterPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) masterPtr); } /* @@ -2077,13 +2071,13 @@ SlaveStructureProc( ClientData clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { - Slave *slavePtr = clientData; + Slave *slavePtr = (Slave *) clientData; PanedWindow *pwPtr = slavePtr->masterPtr; if (eventPtr->type == DestroyNotify) { Unlink(slavePtr); slavePtr->tkwin = NULL; - ckfree(slavePtr); + ckfree((void *)slavePtr); ComputeGeometry(pwPtr); } } @@ -2262,7 +2256,7 @@ ComputeGeometry( Tk_GeometryRequest(pwPtr->tkwin, reqWidth, reqHeight); if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { pwPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); } } @@ -2289,7 +2283,8 @@ DestroyOptionTables( ClientData clientData, /* Pointer to the OptionTables struct */ Tcl_Interp *interp) /* Pointer to the calling interp */ { - ckfree(clientData); + ckfree((char *)clientData); + return; } /* @@ -2318,22 +2313,22 @@ GetSticky( * sticky value. */ { int sticky = *(int *)(recordPtr + internalOffset); - char buffer[5]; - char *p = &buffer[0]; + static char buffer[5]; + int count = 0; if (sticky & STICK_NORTH) { - *p++ = 'n'; + buffer[count++] = 'n'; } if (sticky & STICK_EAST) { - *p++ = 'e'; + buffer[count++] = 'e'; } if (sticky & STICK_SOUTH) { - *p++ = 's'; + buffer[count++] = 's'; } if (sticky & STICK_WEST) { - *p++ = 'w'; + buffer[count++] = 'w'; } - *p = '\0'; + buffer[count] = '\0'; return Tcl_NewStringObj(buffer, -1); } @@ -2372,8 +2367,7 @@ SetSticky( int flags) /* Flags for the option, set Tk_SetOptions. */ { int sticky = 0; - char c, *internalPtr; - const char *string; + char c, *string, *internalPtr; internalPtr = ComputeSlotAddress(recordPtr, internalOffset); @@ -2403,11 +2397,10 @@ SetSticky( case ' ': case ',': case '\t': case '\r': case '\n': break; default: - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad stickyness value \"%s\": must be a string" - " containing zero or more of n, e, s, and w", - Tcl_GetString(*value))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL); + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "bad stickyness value \"", + Tcl_GetString(*value), "\": must be a string ", + "containing zero or more of n, e, s, and w", NULL); return TCL_ERROR; } } @@ -2660,7 +2653,7 @@ MoveSash( * None. * * Side effects: - * When the window gets deleted, internal structures get cleaned up. When + * When the window gets deleted, internal structures get cleaned up. Whena * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- @@ -2671,11 +2664,11 @@ ProxyWindowEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; if (eventPtr->type == Expose) { if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayProxyWindow, pwPtr); + Tcl_DoWhenIdle(DisplayProxyWindow, (ClientData) pwPtr); pwPtr->flags |= PROXY_REDRAW_PENDING; } } @@ -2703,7 +2696,7 @@ static void DisplayProxyWindow( ClientData clientData) /* Information about window. */ { - PanedWindow *pwPtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) clientData; Pixmap pixmap; Tk_Window tkwin = pwPtr->proxywin; pwPtr->flags &= ~PROXY_REDRAW_PENDING; @@ -2764,7 +2757,7 @@ PanedWindowProxyCommand( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static const char *const optionStrings[] = { + static const char *optionStrings[] = { "coord", "forget", "place", NULL }; enum options { @@ -2792,7 +2785,7 @@ PanedWindowProxyCommand( coords[0] = Tcl_NewIntObj(pwPtr->proxyx); coords[1] = Tcl_NewIntObj(pwPtr->proxyy); - Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); + Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); break; case PROXY_FORGET: @@ -2838,12 +2831,12 @@ PanedWindowProxyCommand( (2 * Tk_InternalBorderWidth(pwPtr->tkwin)); } - if (sashWidth < 1) { - sashWidth = 1; - } - if (sashHeight < 1) { - sashHeight = 1; - } + if (sashWidth < 1) { + sashWidth = 1; + } + if (sashHeight < 1) { + sashHeight = 1; + } /* * Stash the proxy coordinates for future "proxy coord" calls. @@ -2905,7 +2898,7 @@ ObjectIsEmpty( if (objPtr->bytes != NULL) { return (objPtr->length == 0); } - (void)Tcl_GetStringFromObj(objPtr, &length); + Tcl_GetStringFromObj(objPtr, &length); return (length == 0); } @@ -2964,8 +2957,10 @@ PanedWindowIdentifyCoords( Tcl_Interp *interp, /* Interpreter in which to store result. */ int x, int y) /* Coordinates of the point to identify. */ { + Tcl_Obj *list; int i, sashHeight, sashWidth, thisx, thisy; int found, isHandle, lpad, rpad, tpad, bpad; + list = Tcl_NewObj(); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (Tk_IsMapped(pwPtr->tkwin)) { @@ -3040,17 +3035,16 @@ PanedWindowIdentifyCoords( } /* - * Set results. Note that the empty string is the default (this function - * is called inside the implementation of a command). + * Set results. */ if (found != -1) { - Tcl_Obj *list[2]; - - list[0] = Tcl_NewIntObj(found); - list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1); - Tcl_SetObjResult(interp, Tcl_NewListObj(2, list)); + Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj(found)); + Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj( + (isHandle ? "handle" : "sash"), -1)); } + + Tcl_SetObjResult(interp, list); return TCL_OK; } |