Index: generic/tkPanedWindow.c ================================================================== --- generic/tkPanedWindow.c +++ generic/tkPanedWindow.c @@ -87,12 +87,10 @@ Tcl_Obj *padYObj; /* Additional padding requested for pane, in * the y dimension. */ Tcl_Obj *widthObj, *heightObj; /* Tcl_Obj rep's of pane width/height, to * allow for null values. */ - int width; /* Pane width. */ - int height; /* Pane height. */ int sticky; /* Sticky string. */ int x, y; /* Coordinates of the widget. */ int paneWidth, paneHeight; /* Pane dimensions (may be different from * pane width/height). */ int sashx, sashy; /* Coordinates of the sash of the right or @@ -105,12 +103,12 @@ struct PanedWindow *containerPtr; /* Paned window managing the window. */ Tk_Window after; /* Placeholder for parsing options. */ Tk_Window before; /* Placeholder for parsing options. */ #ifdef BUILD_tk - int padX, padY; - int minSize; + int width; /* Pane width. */ + int height; /* Pane height. */ #endif } Pane; /* * A data structure of the following type is kept for each paned window widget @@ -125,44 +123,40 @@ Tcl_Command widgetCmd; /* Token for square's widget command. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ Tk_OptionTable paneOpts; /* Token for pane cget table. */ Tk_3DBorder background; /* Background color. */ - int borderWidth; /* Value of -borderwidth option. */ + Tcl_Obj *borderWidthObj; int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */ Tcl_Obj *widthObj; /* Tcl_Obj rep for width. */ Tcl_Obj *heightObj; /* Tcl_Obj rep for height. */ - int width, height; /* Width and height of the widget. */ enum orient orient; /* Orientation of the widget. */ Tk_Cursor cursor; /* Current cursor for window, or None. */ int resizeOpaque; /* Boolean indicating whether resize should be * opaque or rubberband style. */ int sashRelief; /* Relief used to draw sash. */ - int sashWidth; /* Width of each sash, in pixels. */ - Tcl_Obj *sashWidthPtr; /* Tcl_Obj rep for sash width. */ - int sashPad; /* Additional padding around each sash. */ - Tcl_Obj *sashPadPtr; /* Tcl_Obj rep for sash padding. */ + Tcl_Obj *sashWidthObj; /* Tcl_Obj rep for sash width. */ + Tcl_Obj *sashPadObj; /* Tcl_Obj rep for sash padding. */ int showHandle; /* Boolean indicating whether sash handles * should be drawn. */ - int handleSize; /* Size of one side of a sash handle (handles + Tcl_Obj *handleSizeObj; /* Size of one side of a sash handle (handles * are square), in pixels. */ - int handlePad; /* Distance from border to draw handle. */ - Tcl_Obj *handleSizePtr; /* Tcl_Obj rep for handle size. */ + Tcl_Obj *handlePadObj; /* Distance from border to draw handle. */ Tk_Cursor sashCursor; /* Cursor used when mouse is above a sash. */ GC gc; /* Graphics context for copying from * off-screen pixmap onto screen. */ int proxyx, proxyy; /* Proxy x,y coordinates. */ Tk_3DBorder proxyBackground;/* Background color used to draw proxy. If NULL, use background. */ - Tcl_Obj *proxyBorderWidthPtr; /* Tcl_Obj rep for proxyBorderWidth */ - int proxyBorderWidth; /* Borderwidth used to draw proxy. */ + Tcl_Obj *proxyBorderWidthObj; /* Tcl_Obj rep for proxyBorderWidth */ int proxyRelief; /* Relief used to draw proxy, if TK_RELIEF_NULL then use relief. */ Pane **panes; /* Pointer to array of Panes. */ int numPanes; /* Number of panes. */ int sizeofPanes; /* Number of elements in the panes array. */ int flags; /* Flags for widget; see below. */ - Tcl_Obj *borderWidthObj; - Tcl_Obj *handlePadPtr; +#ifdef BUILD_tk + int width, height; /* Width and height of the widget. */ +#endif } PanedWindow; /* * Flags used for paned windows: * @@ -283,21 +277,21 @@ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_PANEDWINDOW_BORDERWIDTH, offsetof(PanedWindow, borderWidthObj), offsetof(PanedWindow, borderWidth), + DEF_PANEDWINDOW_BORDERWIDTH, offsetof(PanedWindow, borderWidthObj), TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad", - DEF_PANEDWINDOW_HANDLEPAD, offsetof(PanedWindow, handlePadPtr), offsetof(PanedWindow, handlePad), + DEF_PANEDWINDOW_HANDLEPAD, offsetof(PanedWindow, handlePadObj), TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize", - DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr), - offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY}, + DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizeObj), + TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-height", "height", "Height", DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightObj), offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY}, {TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize", DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE, @@ -307,29 +301,29 @@ TK_OPTION_ENUM_VAR, orientStrings, GEOMETRY}, {TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground", 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK, (void *)DEF_PANEDWINDOW_BG_MONO, 0}, {TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth", - DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr), - offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY}, + DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthObj), + TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief", 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0}, {TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor", DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad", - DEF_PANEDWINDOW_SASHPAD, offsetof(PanedWindow, sashPadPtr), offsetof(PanedWindow, sashPad), + DEF_PANEDWINDOW_SASHPAD, offsetof(PanedWindow, sashPadObj), TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief", DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief), 0, 0, 0}, {TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width", - DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr), - offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY}, + DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthObj), + TCL_INDEX_NONE, 0, 0, GEOMETRY}, {TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle", DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-width", "width", "Width", DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthObj), @@ -348,15 +342,15 @@ DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightObj), offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY}, {TK_OPTION_PIXELS, "-minsize", NULL, NULL, - DEF_PANEDWINDOW_PANE_MINSIZE, offsetof(Pane, minSizeObj), offsetof(Pane, minSize), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_MINSIZE, offsetof(Pane, minSizeObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADX, offsetof(Pane, padXObj), offsetof(Pane, padX), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADX, offsetof(Pane, padXObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADY, offsetof(Pane, padYObj), offsetof(Pane, padY), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADY, offsetof(Pane, padYObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_CUSTOM, "-sticky", NULL, NULL, DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky), 0, &stickyOption, 0}, {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch", DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), @@ -925,15 +919,19 @@ pwPtr->tkwin); found = 0; for (j = 0; j < pwPtr->numPanes; j++) { if (pwPtr->panes[j] != NULL && pwPtr->panes[j]->tkwin == tkwin) { + int minSize; Tk_SetOptions(interp, pwPtr->panes[j], pwPtr->paneOpts, objc - firstOptionArg, objv + firstOptionArg, pwPtr->tkwin, NULL, NULL); - if (pwPtr->panes[j]->minSize < 0) { - pwPtr->panes[j]->minSize = 0; + Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->panes[j]->minSizeObj, &minSize); + if (minSize < 0) { + Tcl_DecrRefCount(pwPtr->panes[j]->minSizeObj); + pwPtr->panes[j]->minSizeObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(pwPtr->panes[j]->minSizeObj); } found = 1; /* * If the pane is supposed to move, add it to the inserts @@ -969,10 +967,11 @@ /* * Create a new pane structure and initialize it. All panes start * out with their "natural" dimensions. */ + int minSize; panePtr = (Pane *)ckalloc(sizeof(Pane)); memset(panePtr, 0, sizeof(Pane)); Tk_InitOptions(interp, panePtr, pwPtr->paneOpts, pwPtr->tkwin); @@ -990,12 +989,15 @@ if (panePtr->height > 0) { panePtr->paneHeight = panePtr->height; } else { panePtr->paneHeight = Tk_ReqHeight(tkwin) + doubleBw; } - if (panePtr->minSize < 0) { - panePtr->minSize = 0; + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &minSize); + if (minSize < 0) { + Tcl_DecrRefCount(panePtr->minSizeObj); + panePtr->minSizeObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(panePtr->minSizeObj); } /* * Set up the geometry management callbacks for this pane. */ @@ -1300,10 +1302,11 @@ void *instanceData) /* Information about the paned window. */ { XGCValues gcValues; GC newGC; PanedWindow *pwPtr = (PanedWindow *)instanceData; + int borderWidth; /* * Allocated a graphics context for drawing the paned window widget * elements (background, sashes, etc.) and set the window background. */ @@ -1318,11 +1321,12 @@ /* * Issue geometry size requests to Tk. */ - Tk_SetInternalBorder(pwPtr->tkwin, pwPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->borderWidthObj, &borderWidth); + Tk_SetInternalBorder(pwPtr->tkwin, borderWidth); if (pwPtr->width > 0 && pwPtr->height > 0) { Tk_GeometryRequest(pwPtr->tkwin, pwPtr->width, pwPtr->height); } /* @@ -1453,10 +1457,11 @@ Pixmap pixmap; Tk_Window tkwin = pwPtr->tkwin; int i, sashWidth, sashHeight; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); int first, last; + int borderWidth; pwPtr->flags &= ~REDRAW_PENDING; if ((pwPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } @@ -1478,33 +1483,35 @@ /* * Redraw the widget's background and border. */ + Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->borderWidthObj, &borderWidth); Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, 0, 0, - Tk_Width(tkwin), Tk_Height(tkwin), pwPtr->borderWidth, + Tk_Width(tkwin), Tk_Height(tkwin), borderWidth, pwPtr->relief); /* * Set up boilerplate geometry values for sashes (width, height, common * coordinates). */ - if (horizontal) { + Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->sashWidthObj, &sashWidth); + if (horizontal) { sashHeight = Tk_Height(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); - sashWidth = pwPtr->sashWidth; } else { + sashHeight = sashWidth; sashWidth = Tk_Width(tkwin) - (2 * Tk_InternalBorderLeft(tkwin)); - sashHeight = pwPtr->sashWidth; } /* * Draw the sashes. */ GetFirstLastVisiblePane(pwPtr, &first, &last); for (i = 0; i < pwPtr->numPanes - 1; i++) { + panePtr = pwPtr->panes[i]; if (panePtr->hide || i == last) { continue; } if (sashWidth > 0 && sashHeight > 0) { @@ -1511,13 +1518,15 @@ Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, panePtr->sashx, panePtr->sashy, sashWidth, sashHeight, 1, pwPtr->sashRelief); } if (pwPtr->showHandle) { + int handleSize; + Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->handleSizeObj, &handleSize); Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->background, panePtr->handlex, panePtr->handley, - pwPtr->handleSize, pwPtr->handleSize, 1, + handleSize, handleSize, 1, TK_RELIEF_RAISED); } } #ifndef TK_NO_DOUBLE_BUFFERING @@ -1731,10 +1740,11 @@ int internalBW; int paneDynSize, paneDynMinSize, pwHeight, pwWidth, pwSize; int first, last; int stretchReserve, stretchAmount; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); + int handleSize, sashPad, handlePad; pwPtr->flags &= ~(REQUESTED_RELAYOUT|RESIZE_PENDING); /* * If the parent has no panes anymore, then don't do anything at all: @@ -1769,22 +1779,25 @@ /* * Calculate the sash width, including handle and padding, and the sash * and handle offsets. */ - sashOffset = handleOffset = pwPtr->sashPad; - if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { - sashWidth = (2 * pwPtr->sashPad) + pwPtr->handleSize; - sashOffset = ((pwPtr->handleSize - pwPtr->sashWidth) / 2) - + pwPtr->sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashPadObj, &sashPad); + sashOffset = handleOffset = sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handleSizeObj, &handleSize); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashWidthObj, &sashWidth); + if (pwPtr->showHandle && handleSize > sashWidth) { + sashOffset = ((handleSize - sashWidth) / 2) + sashPad; + sashWidth = (2 * sashPad) + handleSize; } else { - sashWidth = (2 * pwPtr->sashPad) + pwPtr->sashWidth; - handleOffset = ((pwPtr->sashWidth - pwPtr->handleSize) / 2) - + pwPtr->sashPad; + handleOffset = ((sashWidth - handleSize) / 2) + sashPad; + sashWidth = (2 * sashPad) + sashWidth; } for (i = sashCount = 0; i < pwPtr->numPanes; i++) { + int padX, padY, minSize; + panePtr = pwPtr->panes[i]; if (panePtr->hide) { continue; } @@ -1792,29 +1805,32 @@ /* * Compute the total size needed by all the panes and the left-over, * or shortage of space available. */ + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padYObj, &padY); if (horizontal) { if (panePtr->width > 0) { paneSize = panePtr->width; } else { paneSize = panePtr->paneWidth; } - stretchReserve -= paneSize + (2 * panePtr->padX); + stretchReserve -= paneSize + (2 * padX); } else { if (panePtr->height > 0) { paneSize = panePtr->height; } else { paneSize = panePtr->paneHeight; } - stretchReserve -= paneSize + (2 * panePtr->padY); + stretchReserve -= paneSize + (2 * padY); } + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &minSize); if (IsStretchable(panePtr->stretch,i,first,last) && Tk_IsMapped(pwPtr->tkwin)) { paneDynSize += paneSize; - paneDynMinSize += panePtr->minSize; + paneDynMinSize += minSize; } if (i != last) { stretchReserve -= sashWidth; sashCount++; } @@ -1823,10 +1839,12 @@ /* * Second pass; adjust/arrange panes. */ for (i = 0; i < pwPtr->numPanes; i++) { + int padX, padY; + panePtr = pwPtr->panes[i]; if (panePtr->hide) { Tk_UnmaintainGeometry(panePtr->tkwin, pwPtr->tkwin); Tk_UnmapWindow(panePtr->tkwin); @@ -1847,11 +1865,11 @@ doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; newPaneWidth = (panePtr->width > 0 ? panePtr->width : Tk_ReqWidth(panePtr->tkwin) + doubleBw); newPaneHeight = (panePtr->height > 0 ? panePtr->height : Tk_ReqHeight(panePtr->tkwin) + doubleBw); - paneMinSize = panePtr->minSize; + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &paneMinSize); /* * Calculate pane width and height. */ @@ -1878,11 +1896,11 @@ } else { frac = (double)paneSize / (double)pwSize; } paneDynSize -= paneSize; - paneDynMinSize -= panePtr->minSize; + paneDynMinSize -= paneMinSize; stretchAmount = (int) (frac * stretchReserve); if (paneSize + stretchAmount >= paneMinSize) { stretchReserve -= stretchAmount; paneSize += stretchAmount; } else { @@ -1901,15 +1919,17 @@ } else { paneSize += paneDynSize - paneDynMinSize + stretchReserve; stretchReserve = paneDynMinSize - paneDynSize; } } + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padYObj, &padY); if (horizontal) { paneWidth = paneSize; - paneHeight = pwHeight - (2 * panePtr->padY); + paneHeight = pwHeight - (2 * padY); } else { - paneWidth = pwWidth - (2 * panePtr->padX); + paneWidth = pwWidth - (2 * padX); paneHeight = paneSize; } /* * Adjust for area reserved for sashes. @@ -1948,28 +1968,29 @@ /* * Compute the location of the sash at the right or bottom of the * parcel and the location of the next parcel. */ + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handlePadObj, &handlePad); if (horizontal) { - x += paneWidth + (2 * panePtr->padX); + x += paneWidth + (2 * padX); if (x < internalBW) { x = internalBW; } panePtr->sashx = x + sashOffset; panePtr->sashy = y; panePtr->handlex = x + handleOffset; - panePtr->handley = y + pwPtr->handlePad; + panePtr->handley = y + handlePad; x += sashWidth; } else { - y += paneHeight + (2 * panePtr->padY); + y += paneHeight + (2 * padY); if (y < internalBW) { y = internalBW; } panePtr->sashx = x; panePtr->sashy = y + sashOffset; - panePtr->handlex = x + pwPtr->handlePad; + panePtr->handlex = x + handlePad; panePtr->handley = y + handleOffset; y += sashWidth; } /* @@ -1979,12 +2000,12 @@ paneX = panePtr->x; paneY = panePtr->y; AdjustForSticky(panePtr->sticky, paneWidth, paneHeight, &paneX, &paneY, &newPaneWidth, &newPaneHeight); - paneX += panePtr->padX; - paneY += panePtr->padY; + paneX += padX; + paneY += padY; /* * Now put the window in the proper spot. */ @@ -2198,13 +2219,14 @@ ComputeGeometry( PanedWindow *pwPtr) /* Pointer to the Paned Window structure. */ { int i, x, y, doubleBw, internalBw; int sashWidth, sashOffset, handleOffset; - int reqWidth, reqHeight, dim; + int reqWidth, reqHeight, dim, handleSize; Pane *panePtr; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); + int sashPad; pwPtr->flags |= REQUESTED_RELAYOUT; x = y = internalBw = Tk_InternalBorderLeft(pwPtr->tkwin); reqWidth = reqHeight = 0; @@ -2214,22 +2236,24 @@ * below, precompute the x and y offsets of the handles and sashes within * the space occupied by their combination; later, just add those offsets * blindly (avoiding the extra showHandle, etc, checks). */ - sashOffset = handleOffset = pwPtr->sashPad; - if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { - sashWidth = (2 * pwPtr->sashPad) + pwPtr->handleSize; - sashOffset = ((pwPtr->handleSize - pwPtr->sashWidth) / 2) - + pwPtr->sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashPadObj, &sashPad); + sashOffset = handleOffset = sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handleSizeObj, &handleSize); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashWidthObj, &sashWidth); + if (pwPtr->showHandle && handleSize > sashWidth) { + sashOffset = ((handleSize - sashWidth) / 2) + sashPad; + sashWidth = (2 * sashPad) + handleSize; } else { - sashWidth = (2 * pwPtr->sashPad) + pwPtr->sashWidth; - handleOffset = ((pwPtr->sashWidth - pwPtr->handleSize) / 2) - + pwPtr->sashPad; + handleOffset = ((sashWidth - handleSize) / 2) + sashPad; + sashWidth = (2 * sashPad) + sashWidth; } for (i = 0; i < pwPtr->numPanes; i++) { + int padX, padY, minSize, handlePad; panePtr = pwPtr->panes[i]; if (panePtr->hide) { continue; } @@ -2246,37 +2270,41 @@ * Make sure the pane's paned dimension is at least minsize. This * check may be redundant, since the only way to change a pane's size * is by moving a sash, and that code checks the minsize. */ + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &minSize); if (horizontal) { - if (panePtr->paneWidth < panePtr->minSize) { - panePtr->paneWidth = panePtr->minSize; + if (panePtr->paneWidth < minSize) { + panePtr->paneWidth = minSize; } } else { - if (panePtr->paneHeight < panePtr->minSize) { - panePtr->paneHeight = panePtr->minSize; + if (panePtr->paneHeight < minSize) { + panePtr->paneHeight = minSize; } } /* * Compute the location of the sash at the right or bottom of the * parcel. */ + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padYObj, &padY); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handlePadObj, &handlePad); if (horizontal) { - x += panePtr->paneWidth + (2 * panePtr->padX); + x += panePtr->paneWidth + (2 * padX); panePtr->sashx = x + sashOffset; panePtr->sashy = y; panePtr->handlex = x + handleOffset; - panePtr->handley = y + pwPtr->handlePad; + panePtr->handley = y + handlePad; x += sashWidth; } else { - y += panePtr->paneHeight + (2 * panePtr->padY); + y += panePtr->paneHeight + (2 * padY); panePtr->sashx = x; panePtr->sashy = y + sashOffset; - panePtr->handlex = x + pwPtr->handlePad; + panePtr->handlex = x + handlePad; panePtr->handley = y + handleOffset; y += sashWidth; } /* @@ -2294,11 +2322,11 @@ dim = panePtr->height; } else { doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; dim = Tk_ReqHeight(panePtr->tkwin) + doubleBw; } - dim += 2 * panePtr->padY; + dim += 2 * padY; if (dim > reqHeight) { reqHeight = dim; } } else { /* @@ -2310,11 +2338,11 @@ dim = panePtr->width; } else { doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; dim = Tk_ReqWidth(panePtr->tkwin) + doubleBw; } - dim += 2 * panePtr->padX; + dim += 2 * padX; if (dim > reqWidth) { reqWidth = dim; } } } @@ -2618,35 +2646,41 @@ int expandPane, reduceFirst, reduceLast, reduceIncr, paneSize, sashOffset; Pane *panePtr; int stretchReserve = 0; int nextSash = sash + 1; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); + int handleSize, sashPad, sashWidth; if (diff == 0) return; /* * Update the pane sizes with their real sizes. */ - if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { - sashOffset = ((pwPtr->handleSize - pwPtr->sashWidth) / 2) - + pwPtr->sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handleSizeObj, &handleSize); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashPadObj, &sashPad); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashWidthObj, &sashWidth); + if (pwPtr->showHandle && handleSize > sashWidth) { + sashOffset = ((handleSize - sashWidth) / 2) + sashPad; } else { - sashOffset = pwPtr->sashPad; + sashOffset = sashPad; } for (i = 0; i < pwPtr->numPanes; i++) { + int padX, padY; panePtr = pwPtr->panes[i]; if (panePtr->hide) { continue; } + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padXObj, &padX); + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->padYObj, &padY); if (horizontal) { panePtr->paneWidth = panePtr->width = panePtr->sashx - - sashOffset - panePtr->x - (2 * panePtr->padX); + - sashOffset - panePtr->x - (2 * padX); } else { panePtr->paneHeight = panePtr->height = panePtr->sashy - - sashOffset - panePtr->y - (2 * panePtr->padY); + - sashOffset - panePtr->y - (2 * padY); } } /* * There must be a next sash since it is only possible to enter this @@ -2677,20 +2711,23 @@ /* * Calculate how much room we have to stretch in and adjust diff value * accordingly. */ + int minSize; + Tk_GetPixelsFromObj(NULL, panePtr->tkwin, panePtr->minSizeObj, &minSize); for (i = reduceFirst; i != reduceLast; i += reduceIncr) { + panePtr = pwPtr->panes[i]; if (panePtr->hide) { continue; } if (horizontal) { - stretchReserve += panePtr->width - panePtr->minSize; + stretchReserve += panePtr->width - minSize; } else { - stretchReserve += panePtr->height - panePtr->minSize; + stretchReserve += panePtr->height - minSize; } } if (stretchReserve <= 0) { return; } @@ -2721,13 +2758,13 @@ if (horizontal) { paneSize = panePtr->width; } else { paneSize = panePtr->height; } - if (diff > (paneSize - panePtr->minSize)) { - diff -= paneSize - panePtr->minSize; - paneSize = panePtr->minSize; + if (diff > (paneSize - minSize)) { + diff -= paneSize - minSize; + paneSize = minSize; } else { paneSize -= diff; i = reduceLast - reduceIncr; } if (horizontal) { @@ -2794,10 +2831,12 @@ void *clientData) /* Information about window. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; Pixmap pixmap; Tk_Window tkwin = pwPtr->proxywin; + int proxyBorderWidth; + pwPtr->flags &= ~PROXY_REDRAW_PENDING; if ((tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } @@ -2814,13 +2853,14 @@ /* * Redraw the widget's background and border. */ - Tk_Fill3DRectangle(tkwin, pixmap, + Tk_GetPixelsFromObj(NULL, tkwin, pwPtr->proxyBorderWidthObj, &proxyBorderWidth); + Tk_Fill3DRectangle(tkwin, pixmap, pwPtr->proxyBackground ? pwPtr->proxyBackground : pwPtr->background, - 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), pwPtr->proxyBorderWidth, + 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), proxyBorderWidth, (pwPtr->proxyRelief != TK_RELIEF_NULL) ? pwPtr->proxyRelief : pwPtr->sashRelief); #ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the pixmap to the display. @@ -2912,20 +2952,20 @@ if (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { return TCL_ERROR; } internalBW = Tk_InternalBorderLeft(pwPtr->tkwin); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashWidthObj, &sashWidth); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (x < 0) { x = 0; } pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW); if (x > pwWidth) { x = pwWidth; } y = Tk_InternalBorderLeft(pwPtr->tkwin); - sashWidth = pwPtr->sashWidth; sashHeight = Tk_Height(pwPtr->tkwin) - (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } else { if (y < 0) { y = 0; @@ -2933,11 +2973,11 @@ pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW); if (y > pwHeight) { y = pwHeight; } x = Tk_InternalBorderLeft(pwPtr->tkwin); - sashHeight = pwPtr->sashWidth; + sashHeight = sashWidth; sashWidth = Tk_Width(pwPtr->tkwin) - (2 * Tk_InternalBorderLeft(pwPtr->tkwin)); } if (sashWidth < 1) { @@ -3063,40 +3103,42 @@ Tcl_Interp *interp, /* Interpreter in which to store result. */ int x, int y) /* Coordinates of the point to identify. */ { int i, sashHeight, sashWidth, thisx, thisy; int found, isHandle, lpad, rpad, tpad, bpad; - int first, last; + int first, last, handleSize, sashPad; + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->handleSizeObj, &handleSize); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashPadObj, &sashPad); + Tk_GetPixelsFromObj(NULL, pwPtr->tkwin, pwPtr->sashWidthObj, &sashWidth); if (pwPtr->orient == ORIENT_HORIZONTAL) { if (Tk_IsMapped(pwPtr->tkwin)) { sashHeight = Tk_Height(pwPtr->tkwin); } else { sashHeight = Tk_ReqHeight(pwPtr->tkwin); } sashHeight -= 2 * Tk_InternalBorderLeft(pwPtr->tkwin); - if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { - sashWidth = pwPtr->handleSize; - lpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; - rpad = pwPtr->handleSize - lpad; - lpad += pwPtr->sashPad; - rpad += pwPtr->sashPad; + if (pwPtr->showHandle && handleSize > sashWidth) { + lpad = (handleSize - sashWidth) / 2; + rpad = handleSize - lpad; + lpad += sashPad; + rpad += sashPad; + sashWidth = handleSize; } else { - sashWidth = pwPtr->sashWidth; - lpad = rpad = pwPtr->sashPad; + lpad = rpad = sashPad; } tpad = bpad = 0; } else { - if (pwPtr->showHandle && pwPtr->handleSize > pwPtr->sashWidth) { - sashHeight = pwPtr->handleSize; - tpad = (pwPtr->handleSize - pwPtr->sashWidth) / 2; - bpad = pwPtr->handleSize - tpad; - tpad += pwPtr->sashPad; - bpad += pwPtr->sashPad; + if (pwPtr->showHandle && handleSize > sashWidth) { + sashHeight = handleSize; + tpad = (handleSize - sashWidth) / 2; + bpad = handleSize - tpad; + tpad += sashPad; + bpad += sashPad; } else { - sashHeight = pwPtr->sashWidth; - tpad = bpad = pwPtr->sashPad; + sashHeight = sashWidth; + tpad = bpad = sashPad; } if (Tk_IsMapped(pwPtr->tkwin)) { sashWidth = Tk_Width(pwPtr->tkwin); } else { sashWidth = Tk_ReqWidth(pwPtr->tkwin); @@ -3125,15 +3167,15 @@ if (pwPtr->showHandle) { thisx = pwPtr->panes[i]->handlex; thisy = pwPtr->panes[i]->handley; if (pwPtr->orient == ORIENT_HORIZONTAL) { - if (thisy <= y && y <= (thisy + pwPtr->handleSize)) { + if (thisy <= y && y <= (thisy + handleSize)) { isHandle = 1; } } else { - if (thisx <= x && x <= (thisx + pwPtr->handleSize)) { + if (thisx <= x && x <= (thisx + handleSize)) { isHandle = 1; } } } break;