diff options
Diffstat (limited to 'generic/tkPanedWindow.c')
-rw-r--r-- | generic/tkPanedWindow.c | 266 |
1 files changed, 136 insertions, 130 deletions
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index d2da227..74c9999 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -272,11 +272,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, - (ClientData) DEF_PANEDWINDOW_BG_MONO}, + DEF_PANEDWINDOW_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-borderwidth"}, + NULL, 0, -1, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, - NULL, 0, -1, 0, (ClientData) "-background"}, + NULL, 0, -1, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth), 0, 0, GEOMETRY}, @@ -297,7 +297,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, (ClientData) orientStrings, GEOMETRY}, + 0, 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", @@ -318,7 +318,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} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; static const Tk_OptionSpec slaveOptionSpecs[] = { @@ -341,14 +341,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, - (ClientData) &stickyOption, 0}, + &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} + {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; /* @@ -381,12 +381,12 @@ Tk_PanedWindowObjCmd( XSetWindowAttributes atts; if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), - Tcl_GetStringFromObj(objv[1], NULL), NULL); + Tcl_GetString(objv[1]), NULL); if (tkwin == NULL) { return TCL_ERROR; } @@ -401,14 +401,14 @@ Tk_PanedWindowObjCmd( * easy access to it in the future. */ - pwOpts = (OptionTables *) ckalloc(sizeof(OptionTables)); + pwOpts = ckalloc(sizeof(OptionTables)); /* * Set up an exit handler to free the optionTables struct. */ Tcl_SetAssocData(interp, "PanedWindowOptionTables", - DestroyOptionTables, (ClientData) pwOpts); + DestroyOptionTables, pwOpts); /* * Create the paned window option tables. @@ -424,14 +424,14 @@ Tk_PanedWindowObjCmd( * Allocate and initialize the widget record. */ - pwPtr = (PanedWindow *) ckalloc(sizeof(PanedWindow)); + pwPtr = 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, - (ClientData) pwPtr, PanedWindowCmdDeletedProc); + Tk_PathName(pwPtr->tkwin), PanedWindowWidgetObjCmd, pwPtr, + PanedWindowCmdDeletedProc); pwPtr->optionTable = pwOpts->pwOptions; pwPtr->slaveOpts = pwOpts->slaveOpts; pwPtr->relief = TK_RELIEF_RAISED; @@ -444,7 +444,7 @@ Tk_PanedWindowObjCmd( * otherwise Tk might free it while we still need it. */ - Tcl_Preserve((ClientData) pwPtr->tkwin); + Tcl_Preserve(pwPtr->tkwin); if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions, tkwin) != TCL_OK) { @@ -453,7 +453,7 @@ Tk_PanedWindowObjCmd( } Tk_CreateEventHandler(pwPtr->tkwin, ExposureMask|StructureNotifyMask, - PanedWindowEventProc, (ClientData) pwPtr); + PanedWindowEventProc, pwPtr); /* * Find the toplevel ancestor of the panedwindow, and make a proxy win as @@ -483,7 +483,7 @@ Tk_PanedWindowObjCmd( Tk_SetWindowVisual(pwPtr->proxywin, Tk_Visual(tkwin), Tk_Depth(tkwin), Tk_Colormap(tkwin)); Tk_CreateEventHandler(pwPtr->proxywin, ExposureMask, ProxyWindowEventProc, - (ClientData) pwPtr); + pwPtr); atts.save_under = True; Tk_ChangeWindowAttributes(pwPtr->proxywin, CWSaveUnder, &atts); @@ -493,7 +493,7 @@ Tk_PanedWindowObjCmd( return TCL_ERROR; } - Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_PathName(pwPtr->tkwin), -1); + Tcl_SetObjResult(interp, TkNewWindowObj(pwPtr->tkwin)); return TCL_OK; } @@ -522,9 +522,9 @@ PanedWindowWidgetObjCmd( int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; int result = TCL_OK; - static const char *optionStrings[] = { + static const char *const optionStrings[] = { "add", "cget", "configure", "forget", "identify", "panecget", "paneconfigure", "panes", "proxy", "sash", NULL }; @@ -547,7 +547,7 @@ PanedWindowWidgetObjCmd( return TCL_ERROR; } - Tcl_Preserve((ClientData) pwPtr); + Tcl_Preserve(pwPtr); switch ((enum options) index) { case PW_ADD: @@ -605,16 +605,17 @@ 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, (ClientData)NULL); + Tk_ManageGeometry(slave, NULL, NULL); Tk_UnmaintainGeometry(slavePtr->tkwin, pwPtr->tkwin); Tk_DeleteEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, (ClientData) slavePtr); + SlaveStructureProc, slavePtr); Tk_UnmapWindow(slavePtr->tkwin); Unlink(slavePtr); } @@ -659,10 +660,13 @@ 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); @@ -710,15 +714,11 @@ PanedWindowWidgetObjCmd( case PW_PANES: resultObj = Tcl_NewObj(); - - Tcl_IncrRefCount(resultObj); - for (i = 0; i < pwPtr->numSlaves; i++) { - Tcl_ListObjAppendElement(interp, resultObj, - Tcl_NewStringObj(Tk_PathName(pwPtr->slaves[i]->tkwin),-1)); + Tcl_ListObjAppendElement(NULL, resultObj, + TkNewWindowObj(pwPtr->slaves[i]->tkwin)); } Tcl_SetObjResult(interp, resultObj); - Tcl_DecrRefCount(resultObj); break; case PW_PROXY: @@ -729,7 +729,7 @@ PanedWindowWidgetObjCmd( result = PanedWindowSashCommand(pwPtr, interp, objc, objv); break; } - Tcl_Release((ClientData) pwPtr); + Tcl_Release(pwPtr); return result; } @@ -762,7 +762,7 @@ ConfigureSlaves( Tk_Window tkwin = NULL, ancestor, parent; Slave *slavePtr, **inserts, **newSlaves; Slave options; - char *arg; + const char *arg; /* * Find the non-window name arguments; these are the configure options for @@ -788,18 +788,19 @@ ConfigureSlaves( * A panedwindow cannot manage itself. */ - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't add ", arg, " to itself", - NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "can't add %s to itself", arg)); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } else if (Tk_IsTopLevel(tkwin)) { /* * A panedwindow cannot manage a toplevel. */ - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't add toplevel ", arg, " to ", - Tk_PathName(pwPtr->tkwin), NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "can't add toplevel %s to %s", arg, + Tk_PathName(pwPtr->tkwin))); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } else { /* @@ -813,9 +814,11 @@ ConfigureSlaves( break; } if (Tk_IsTopLevel(ancestor)) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't add ", arg, " to ", - Tk_PathName(pwPtr->tkwin), NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "can't add %s to %s", arg, + Tk_PathName(pwPtr->tkwin))); + Tcl_SetErrorCode(interp, "TK", "GEOMETRY", + "HIERARCHY", NULL); return TCL_ERROR; } } @@ -872,9 +875,10 @@ ConfigureSlaves( */ if (haveLoc && index == -1) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "window \"", Tk_PathName(tkwin), - "\" is not managed by ", Tk_PathName(pwPtr->tkwin), NULL); + 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); Tk_FreeConfigOptions((char *) &options, pwPtr->slaveOpts, pwPtr->tkwin); return TCL_ERROR; @@ -886,7 +890,7 @@ ConfigureSlaves( * structures may already have existed, some may be new. */ - inserts = (Slave **)ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); + inserts = ckalloc(sizeof(Slave *) * (firstOptionArg - 2)); insertIndex = 0; /* @@ -953,7 +957,7 @@ ConfigureSlaves( * out with their "natural" dimensions. */ - slavePtr = (Slave *) ckalloc(sizeof(Slave)); + slavePtr = ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); Tk_InitOptions(interp, (char *)slavePtr, pwPtr->slaveOpts, pwPtr->tkwin); @@ -982,9 +986,8 @@ ConfigureSlaves( */ Tk_CreateEventHandler(slavePtr->tkwin, StructureNotifyMask, - SlaveStructureProc, (ClientData) slavePtr); - Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, - (ClientData) slavePtr); + SlaveStructureProc, slavePtr); + Tk_ManageGeometry(slavePtr->tkwin, &panedWindowMgrType, slavePtr); inserts[insertIndex++] = slavePtr; numNewSlaves++; } @@ -993,8 +996,8 @@ ConfigureSlaves( * Allocate the new slaves array, then copy the slaves into it, in order. */ - i = sizeof(Slave *) * (pwPtr->numSlaves+numNewSlaves); - newSlaves = (Slave **)ckalloc((unsigned) i); + i = sizeof(Slave *) * (pwPtr->numSlaves + numNewSlaves); + newSlaves = ckalloc(i); memset(newSlaves, 0, (size_t) i); if (index == -1) { /* @@ -1037,8 +1040,8 @@ ConfigureSlaves( * Make the new slaves array the paned window's slave array, and clean up. */ - ckfree((void *)pwPtr->slaves); - ckfree((void *)inserts); + ckfree(pwPtr->slaves); + ckfree(inserts); pwPtr->slaves = newSlaves; /* @@ -1077,7 +1080,7 @@ PanedWindowSashCommand( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static const char *sashOptionStrings[] = { + static const char *const sashOptionStrings[] = { "coord", "dragto", "mark", "place", NULL }; enum sashOptions { @@ -1097,7 +1100,6 @@ PanedWindowSashCommand( return TCL_ERROR; } - Tcl_ResetResult(interp); switch ((enum sashOptions) index) { case SASH_COORD: if (objc != 4) { @@ -1110,15 +1112,16 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_ResetResult(interp); - Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "invalid sash index", -1)); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } slavePtr = pwPtr->slaves[sash]; coords[0] = Tcl_NewIntObj(slavePtr->sashx); coords[1] = Tcl_NewIntObj(slavePtr->sashy); - Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); break; case SASH_MARK: @@ -1132,8 +1135,9 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_ResetResult(interp); - Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "invalid sash index", -1)); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } @@ -1151,7 +1155,7 @@ PanedWindowSashCommand( } else { coords[0] = Tcl_NewIntObj(pwPtr->slaves[sash]->markx); coords[1] = Tcl_NewIntObj(pwPtr->slaves[sash]->marky); - Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); } break; @@ -1167,8 +1171,9 @@ PanedWindowSashCommand( } if (!ValidSashIndex(pwPtr, sash)) { - Tcl_ResetResult(interp); - Tcl_SetResult(interp, "invalid sash index", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "invalid sash index", -1)); + Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL); return TCL_ERROR; } @@ -1239,7 +1244,7 @@ ConfigurePanedWindow( Tk_FreeSavedOptions(&savedOptions); - PanedWindowWorldChanged((ClientData) pwPtr); + PanedWindowWorldChanged(pwPtr); /* * If an option that affects geometry has changed, make a re-layout @@ -1277,7 +1282,7 @@ PanedWindowWorldChanged( { XGCValues gcValues; GC newGC; - PanedWindow *pwPtr = (PanedWindow *) instanceData; + PanedWindow *pwPtr = instanceData; /* * Allocated a graphics context for drawing the paned window widget @@ -1306,7 +1311,7 @@ PanedWindowWorldChanged( */ if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); pwPtr->flags |= REDRAW_PENDING; } } @@ -1334,18 +1339,18 @@ PanedWindowEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; int i; if (eventPtr->type == Expose) { if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, 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, (ClientData) pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); pwPtr->flags |= REDRAW_PENDING; } } else if (eventPtr->type == DestroyNotify) { @@ -1383,7 +1388,7 @@ static void PanedWindowCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; /* * This function could be invoked either because the window was destroyed @@ -1420,7 +1425,7 @@ static void DisplayPanedWindow( ClientData clientData) /* Information about window. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; Slave *slavePtr; Pixmap pixmap; Tk_Window tkwin = pwPtr->tkwin; @@ -1540,10 +1545,10 @@ DestroyPanedWindow( */ if (pwPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayPanedWindow, (ClientData) pwPtr); + Tcl_CancelIdleCall(DisplayPanedWindow, pwPtr); } if (pwPtr->flags & RESIZE_PENDING) { - Tcl_CancelIdleCall(ArrangePanes, (ClientData) pwPtr); + Tcl_CancelIdleCall(ArrangePanes, pwPtr); } /* @@ -1555,15 +1560,15 @@ DestroyPanedWindow( for (i = 0; i < pwPtr->numSlaves; i++) { Tk_DeleteEventHandler(pwPtr->slaves[i]->tkwin, StructureNotifyMask, - SlaveStructureProc, (ClientData) pwPtr->slaves[i]); + SlaveStructureProc, 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((void *)pwPtr->slaves[i]); + ckfree(pwPtr->slaves[i]); pwPtr->slaves[i] = NULL; } if (pwPtr->slaves) { - ckfree((char *) pwPtr->slaves); + ckfree(pwPtr->slaves); } /* @@ -1577,10 +1582,10 @@ DestroyPanedWindow( */ Tk_FreeConfigOptions((char *) pwPtr, pwPtr->optionTable, pwPtr->tkwin); - Tcl_Release((ClientData) pwPtr->tkwin); + Tcl_Release(pwPtr->tkwin); pwPtr->tkwin = NULL; - Tcl_EventuallyFree((ClientData) pwPtr, TCL_DYNAMIC); + Tcl_EventuallyFree(pwPtr, TCL_DYNAMIC); } /* @@ -1608,12 +1613,13 @@ PanedWindowReqProc( Tk_Window tkwin) /* Other Tk-related information about the * window. */ { - Slave *slavePtr = (Slave *) clientData; - PanedWindow *pwPtr = (PanedWindow *) (slavePtr->masterPtr); + Slave *slavePtr = clientData; + PanedWindow *pwPtr = (PanedWindow *) slavePtr->masterPtr; + if (Tk_IsMapped(pwPtr->tkwin)) { if (!(pwPtr->flags & RESIZE_PENDING)) { pwPtr->flags |= RESIZE_PENDING; - Tcl_DoWhenIdle(ArrangePanes, (ClientData) pwPtr); + Tcl_DoWhenIdle(ArrangePanes, pwPtr); } } else { int doubleBw = 2 * Tk_Changes(slavePtr->tkwin)->border_width; @@ -1652,18 +1658,18 @@ PanedWindowLostSlaveProc( * stolen away. */ Tk_Window tkwin) /* Tk's handle for the slave window. */ { - register Slave *slavePtr = (Slave *) clientData; - PanedWindow *pwPtr = (PanedWindow *) (slavePtr->masterPtr); + register Slave *slavePtr = 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, (ClientData) slavePtr); + SlaveStructureProc, slavePtr); Tk_UnmapWindow(slavePtr->tkwin); slavePtr->tkwin = NULL; - ckfree((void *)slavePtr); + ckfree(slavePtr); ComputeGeometry(pwPtr); } @@ -1691,7 +1697,7 @@ ArrangePanes( ClientData clientData) /* Structure describing parent whose slaves * are to be re-layed out. */ { - register PanedWindow *pwPtr = (PanedWindow *) clientData; + register PanedWindow *pwPtr = clientData; register Slave *slavePtr; int i, slaveWidth, slaveHeight, slaveX, slaveY; int paneWidth, paneHeight, paneSize, paneMinSize; @@ -1718,7 +1724,7 @@ ArrangePanes( return; } - Tcl_Preserve((ClientData) pwPtr); + Tcl_Preserve(pwPtr); /* * Find index of first and last visible panes. @@ -1954,7 +1960,7 @@ ArrangePanes( } sashCount--; } - Tcl_Release((ClientData) pwPtr); + Tcl_Release(pwPtr); } /* @@ -2015,7 +2021,7 @@ Unlink( masterPtr->flags |= REQUESTED_RELAYOUT; if (!(masterPtr->flags & REDRAW_PENDING)) { masterPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) masterPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, masterPtr); } /* @@ -2121,13 +2127,13 @@ SlaveStructureProc( ClientData clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { - Slave *slavePtr = (Slave *) clientData; + Slave *slavePtr = clientData; PanedWindow *pwPtr = slavePtr->masterPtr; if (eventPtr->type == DestroyNotify) { Unlink(slavePtr); slavePtr->tkwin = NULL; - ckfree((void *)slavePtr); + ckfree(slavePtr); ComputeGeometry(pwPtr); } } @@ -2306,7 +2312,7 @@ ComputeGeometry( Tk_GeometryRequest(pwPtr->tkwin, reqWidth, reqHeight); if (Tk_IsMapped(pwPtr->tkwin) && !(pwPtr->flags & REDRAW_PENDING)) { pwPtr->flags |= REDRAW_PENDING; - Tcl_DoWhenIdle(DisplayPanedWindow, (ClientData) pwPtr); + Tcl_DoWhenIdle(DisplayPanedWindow, pwPtr); } } @@ -2333,8 +2339,7 @@ DestroyOptionTables( ClientData clientData, /* Pointer to the OptionTables struct */ Tcl_Interp *interp) /* Pointer to the calling interp */ { - ckfree((char *)clientData); - return; + ckfree(clientData); } /* @@ -2363,22 +2368,22 @@ GetSticky( * sticky value. */ { int sticky = *(int *)(recordPtr + internalOffset); - static char buffer[5]; - int count = 0; + char buffer[5]; + char *p = &buffer[0]; if (sticky & STICK_NORTH) { - buffer[count++] = 'n'; + *p++ = 'n'; } if (sticky & STICK_EAST) { - buffer[count++] = 'e'; + *p++ = 'e'; } if (sticky & STICK_SOUTH) { - buffer[count++] = 's'; + *p++ = 's'; } if (sticky & STICK_WEST) { - buffer[count++] = 'w'; + *p++ = 'w'; } - buffer[count] = '\0'; + *p = '\0'; return Tcl_NewStringObj(buffer, -1); } @@ -2417,7 +2422,8 @@ SetSticky( int flags) /* Flags for the option, set Tk_SetOptions. */ { int sticky = 0; - char c, *string, *internalPtr; + char c, *internalPtr; + const char *string; internalPtr = ComputeSlotAddress(recordPtr, internalOffset); @@ -2447,10 +2453,11 @@ SetSticky( case ' ': case ',': case '\t': case '\r': case '\n': break; default: - 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); + 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); return TCL_ERROR; } } @@ -2703,7 +2710,7 @@ MoveSash( * None. * * Side effects: - * When the window gets deleted, internal structures get cleaned up. Whena + * When the window gets deleted, internal structures get cleaned up. When * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- @@ -2714,11 +2721,11 @@ ProxyWindowEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; if (eventPtr->type == Expose) { if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) { - Tcl_DoWhenIdle(DisplayProxyWindow, (ClientData) pwPtr); + Tcl_DoWhenIdle(DisplayProxyWindow, pwPtr); pwPtr->flags |= PROXY_REDRAW_PENDING; } } @@ -2746,7 +2753,7 @@ static void DisplayProxyWindow( ClientData clientData) /* Information about window. */ { - PanedWindow *pwPtr = (PanedWindow *) clientData; + PanedWindow *pwPtr = clientData; Pixmap pixmap; Tk_Window tkwin = pwPtr->proxywin; pwPtr->flags &= ~PROXY_REDRAW_PENDING; @@ -2807,7 +2814,7 @@ PanedWindowProxyCommand( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - static const char *optionStrings[] = { + static const char *const optionStrings[] = { "coord", "forget", "place", NULL }; enum options { @@ -2836,7 +2843,7 @@ PanedWindowProxyCommand( coords[0] = Tcl_NewIntObj(pwPtr->proxyx); coords[1] = Tcl_NewIntObj(pwPtr->proxyy); - Tcl_SetListObj(Tcl_GetObjResult(interp), 2, coords); + Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords)); break; case PROXY_FORGET: @@ -2891,12 +2898,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. @@ -2958,7 +2965,7 @@ ObjectIsEmpty( if (objPtr->bytes != NULL) { return (objPtr->length == 0); } - Tcl_GetStringFromObj(objPtr, &length); + (void)Tcl_GetStringFromObj(objPtr, &length); return (length == 0); } @@ -3017,10 +3024,8 @@ 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)) { @@ -3095,16 +3100,17 @@ PanedWindowIdentifyCoords( } /* - * Set results. + * Set results. Note that the empty string is the default (this function + * is called inside the implementation of a command). */ if (found != -1) { - Tcl_ListObjAppendElement(interp, list, Tcl_NewIntObj(found)); - Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj( - (isHandle ? "handle" : "sash"), -1)); - } + Tcl_Obj *list[2]; - Tcl_SetObjResult(interp, list); + list[0] = Tcl_NewIntObj(found); + list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1); + Tcl_SetObjResult(interp, Tcl_NewListObj(2, list)); + } return TCL_OK; } |