diff options
Diffstat (limited to 'generic/tkPack.c')
-rw-r--r-- | generic/tkPack.c | 788 |
1 files changed, 393 insertions, 395 deletions
diff --git a/generic/tkPack.c b/generic/tkPack.c index 796530a..239b00a 100644 --- a/generic/tkPack.c +++ b/generic/tkPack.c @@ -20,7 +20,7 @@ static const char *const sideNames[] = { /* * For each window that the packer cares about (either because the window is - * managed by the packer or because the window has slaves that are managed by + * managed by the packer or because the window has content that are managed by * the packer), there is a structure of the following type: */ @@ -29,15 +29,15 @@ typedef struct Packer { * window has been deleted, but the packet * hasn't had a chance to clean up yet because * the structure is still in use. */ - struct Packer *masterPtr; /* Master window within which this window is + struct Packer *containerPtr; /* Container window within which this window is * packed (NULL means this window isn't * managed by the packer). */ - struct Packer *nextPtr; /* Next window packed within same master. List + struct Packer *nextPtr; /* Next window packed within same container. List * is priority-ordered: first on list gets * packed first. */ - struct Packer *slavePtr; /* First in list of slaves packed inside this - * window (NULL means no packed slaves). */ - Side side; /* Side of master against which this window is + struct Packer *contentPtr; /* First in list of content packed inside this + * window (NULL means no packed content). */ + Side side; /* Side of container against which this window is * packed. */ Tk_Anchor anchor; /* If frame allocated for window is larger * than window needs, this indicates how where @@ -55,13 +55,13 @@ typedef struct Packer { * each side). */ int doubleBw; /* Twice the window's last known border width. * If this changes, the window must be - * repacked within its master. */ + * repacked within its container. */ int *abortPtr; /* If non-NULL, it means that there is a * nested call to ArrangePacking already * working on this window. *abortPtr may be * set to 1 to abort that nested call. This * happens, for example, if tkwin or any of - * its slaves is deleted. */ + * its content is deleted. */ int flags; /* Miscellaneous flags; see below for * definitions. */ } Packer; @@ -70,7 +70,7 @@ typedef struct Packer { * Flag values for Packer structures: * * REQUESTED_REPACK: 1 means a Tcl_DoWhenIdle request has already - * been made to repack all the slaves of this + * been made to repack all the content of this * window. * FILLX: 1 means if frame allocated for window is wider * than window needs, expand window to fill @@ -78,17 +78,17 @@ typedef struct Packer { * than needed. * FILLY: Same as FILLX, except for height. * EXPAND: 1 means this window's frame will absorb any - * extra space in the master window. + * extra space in the container window. * OLD_STYLE: 1 means this window is being managed with the * old-style packer algorithms (before Tk version * 3.3). The main difference is that padding and * filling are done differently. * DONT_PROPAGATE: 1 means don't set this window's requested - * size. 0 means if this window is a master then + * size. 0 means if this window is a container then * Tk will set its requested size to fit the - * needs of its slaves. - * ALLOCED_MASTER 1 means that Pack has allocated itself as - * geometry master for this window. + * needs of its content. + * ALLOCED_CONTAINER 1 means that Pack has allocated itself as + * geometry container for this window. */ #define REQUESTED_REPACK 1 @@ -97,20 +97,20 @@ typedef struct Packer { #define EXPAND 8 #define OLD_STYLE 16 #define DONT_PROPAGATE 32 -#define ALLOCED_MASTER 64 +#define ALLOCED_CONTAINER 64 /* * The following structure is the official type record for the packer: */ static void PackReqProc(ClientData clientData, Tk_Window tkwin); -static void PackLostSlaveProc(ClientData clientData, +static void PackLostContentProc(ClientData clientData, Tk_Window tkwin); static const Tk_GeomMgr packerType = { "pack", /* name */ PackReqProc, /* requestProc */ - PackLostSlaveProc, /* lostSlaveProc */ + PackLostContentProc, /* lostContentProc */ }; /* @@ -118,19 +118,19 @@ static const Tk_GeomMgr packerType = { */ static void ArrangePacking(ClientData clientData); -static int ConfigureSlaves(Tcl_Interp *interp, Tk_Window tkwin, +static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin, int objc, Tcl_Obj *const objv[]); static void DestroyPacker(void *memPtr); static Packer * GetPacker(Tk_Window tkwin); #ifndef TK_NO_DEPRECATED static int PackAfter(Tcl_Interp *interp, Packer *prevPtr, - Packer *masterPtr, int objc,Tcl_Obj *const objv[]); + Packer *containerPtr, int objc,Tcl_Obj *const objv[]); #endif /* !TK_NO_DEPRECATED */ static void PackStructureProc(ClientData clientData, XEvent *eventPtr); static void Unlink(Packer *packPtr); -static int XExpansion(Packer *slavePtr, int cavityWidth); -static int YExpansion(Packer *slavePtr, int cavityHeight); +static int XExpansion(Packer *contentPtr, int cavityWidth); +static int YExpansion(Packer *contentPtr, int cavityHeight); /* *------------------------------------------------------------------------ @@ -202,19 +202,21 @@ Tk_PackObjCmd( #ifndef TK_NO_DEPRECATED "after", "append", "before", "unpack", #endif /* !TK_NO_DEPRECATED */ - "configure", "forget", "info", "propagate", "slaves", NULL }; + "configure", "content", "forget", "info", "propagate", "slaves", NULL }; + static const char *const optionStringsNoDep[] = { + "configure", "content", "forget", "info", "propagate", NULL }; enum options { #ifndef TK_NO_DEPRECATED PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, #endif /* !TK_NO_DEPRECATED */ - PACK_CONFIGURE, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; + PACK_CONFIGURE, PACK_CONTENT, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES }; int index; if (objc >= 2) { const char *string = Tcl_GetString(objv[1]); if (string[0] == '.') { - return ConfigureSlaves(interp, tkwin, objc-1, objv+1); + return ConfigureContent(interp, tkwin, objc-1, objv+1); } } if (objc < 3) { @@ -222,19 +224,16 @@ Tk_PackObjCmd( return TCL_ERROR; } - if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings, + if (Tcl_GetIndexFromObjStruct(NULL, objv[1], optionStrings, sizeof(char *), "option", 0, &index) != TCL_OK) { -#ifndef TK_NO_DEPRECATED /* * Call it again without the deprecated ones to get a proper error * message. This works well since there can't be any ambiguity between * deprecated and new options. */ - Tcl_ResetResult(interp); - Tcl_GetIndexFromObjStruct(interp, objv[1], &optionStrings[4], + Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep, sizeof(char *), "option", 0, &index); -#endif /* TK_NO_DEPRECATED */ return TCL_ERROR; } @@ -249,33 +248,33 @@ Tk_PackObjCmd( return TCL_ERROR; } prevPtr = GetPacker(tkwin2); - if (prevPtr->masterPtr == NULL) { + if (prevPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } - return PackAfter(interp, prevPtr, prevPtr->masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, prevPtr->containerPtr, objc-3, objv+3); } case PACK_APPEND: { - Packer *masterPtr; + Packer *containerPtr; Packer *prevPtr; Tk_Window tkwin2; if (TkGetWindowFromObj(interp, tkwin, objv[2], &tkwin2) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(tkwin2); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(tkwin2); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; } } - return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3); } case PACK_BEFORE: { - Packer *packPtr, *masterPtr; + Packer *packPtr, *containerPtr; Packer *prevPtr; Tk_Window tkwin2; @@ -283,14 +282,14 @@ Tk_PackObjCmd( return TCL_ERROR; } packPtr = GetPacker(tkwin2); - if (packPtr->masterPtr == NULL) { + if (packPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); return TCL_ERROR; } - masterPtr = packPtr->masterPtr; - prevPtr = masterPtr->slavePtr; + containerPtr = packPtr->containerPtr; + prevPtr = containerPtr->contentPtr; if (prevPtr == packPtr) { prevPtr = NULL; } else { @@ -303,7 +302,7 @@ Tk_PackObjCmd( } } } - return PackAfter(interp, prevPtr, masterPtr, objc-3, objv+3); + return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3); } #endif /* !TK_NO_DEPRECATED */ case PACK_CONFIGURE: @@ -313,43 +312,43 @@ Tk_PackObjCmd( Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL); return TCL_ERROR; } - return ConfigureSlaves(interp, tkwin, objc-2, objv+2); + return ConfigureContent(interp, tkwin, objc-2, objv+2); case PACK_FORGET: { - Tk_Window slave; - Packer *slavePtr; + Tk_Window content; + Packer *contentPtr; int i; for (i = 2; i < objc; i++) { - if (TkGetWindowFromObj(interp, tkwin, objv[i], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[i], &content) != TCL_OK) { continue; } - slavePtr = GetPacker(slave); - if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) { - Tk_ManageGeometry(slave, NULL, NULL); - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); + contentPtr = GetPacker(content); + if ((contentPtr != NULL) && (contentPtr->containerPtr != NULL)) { + Tk_ManageGeometry(content, NULL, NULL); + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, + contentPtr->containerPtr->tkwin); } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } } break; } case PACK_INFO: { - Packer *slavePtr; - Tk_Window slave; + Packer *contentPtr; + Tk_Window content; Tcl_Obj *infoObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &content) != TCL_OK) { return TCL_ERROR; } - slavePtr = GetPacker(slave); - if (slavePtr->masterPtr == NULL) { + contentPtr = GetPacker(content); + if (contentPtr->containerPtr == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", argv2)); Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL); @@ -358,12 +357,12 @@ Tk_PackObjCmd( infoObj = Tcl_NewObj(); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1), - TkNewWindowObj(slavePtr->masterPtr->tkwin)); + Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", -1), - Tcl_NewStringObj(Tk_NameOfAnchor(slavePtr->anchor), -1)); + Tcl_NewStringObj(Tk_NameOfAnchor(contentPtr->anchor), -1)); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", -1), - Tcl_NewBooleanObj(slavePtr->flags & EXPAND)); - switch (slavePtr->flags & (FILLX|FILLY)) { + Tcl_NewBooleanObj(contentPtr->flags & EXPAND)); + switch (contentPtr->flags & (FILLX|FILLY)) { case 0: Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1), Tcl_NewStringObj("none", -1)); @@ -381,31 +380,31 @@ Tk_PackObjCmd( Tcl_NewStringObj("both", -1)); break; } - TkAppendPadAmount(infoObj, "-ipadx", slavePtr->iPadX/2, slavePtr->iPadX); - TkAppendPadAmount(infoObj, "-ipady", slavePtr->iPadY/2, slavePtr->iPadY); - TkAppendPadAmount(infoObj, "-padx", slavePtr->padLeft,slavePtr->padX); - TkAppendPadAmount(infoObj, "-pady", slavePtr->padTop, slavePtr->padY); + TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX); + TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY); + TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft,contentPtr->padX); + TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY); Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", -1), - Tcl_NewStringObj(sideNames[slavePtr->side], -1)); + Tcl_NewStringObj(sideNames[contentPtr->side], -1)); Tcl_SetObjResult(interp, infoObj); break; } case PACK_PROPAGATE: { - Tk_Window master; - Packer *masterPtr; + Tk_Window container; + Packer *containerPtr; int propagate; if (objc > 4) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(master); + containerPtr = GetPacker(container); if (objc == 3) { Tcl_SetObjResult(interp, - Tcl_NewBooleanObj(!(masterPtr->flags & DONT_PROPAGATE))); + Tcl_NewBooleanObj(!(containerPtr->flags & DONT_PROPAGATE))); return TCL_OK; } if (Tcl_GetBooleanFromObj(interp, objv[3], &propagate) != TCL_OK) { @@ -413,56 +412,57 @@ Tk_PackObjCmd( } if (propagate) { /* - * If we have slaves, we need to register as geometry master. + * If we have content windows, we need to register as geometry container. */ - if (masterPtr->slavePtr != NULL) { - if (TkSetGeometryMaster(interp, master, "pack") != TCL_OK) { + if (containerPtr->contentPtr != NULL) { + if (TkSetGeometryContainer(interp, container, "pack") != TCL_OK) { return TCL_ERROR; } - masterPtr->flags |= ALLOCED_MASTER; + containerPtr->flags |= ALLOCED_CONTAINER; } - masterPtr->flags &= ~DONT_PROPAGATE; + containerPtr->flags &= ~DONT_PROPAGATE; /* - * Repack the master to allow new geometry information to - * propagate upwards to the master's master. + * Repack the container to allow new geometry information to + * propagate upwards to the container's container. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } } else { - if (masterPtr->flags & ALLOCED_MASTER) { - TkFreeGeometryMaster(master, "pack"); - masterPtr->flags &= ~ALLOCED_MASTER; + if (containerPtr->flags & ALLOCED_CONTAINER) { + TkFreeGeometryContainer(container, "pack"); + containerPtr->flags &= ~ALLOCED_CONTAINER; } - masterPtr->flags |= DONT_PROPAGATE; + containerPtr->flags |= DONT_PROPAGATE; } break; } - case PACK_SLAVES: { - Tk_Window master; - Packer *masterPtr, *slavePtr; + case PACK_SLAVES: + case PACK_CONTENT: { + Tk_Window container; + Packer *containerPtr, *contentPtr; Tcl_Obj *resultObj; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (TkGetWindowFromObj(interp, tkwin, objv[2], &master) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[2], &container) != TCL_OK) { return TCL_ERROR; } resultObj = Tcl_NewObj(); - masterPtr = GetPacker(master); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { + containerPtr = GetPacker(container); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { Tcl_ListObjAppendElement(NULL, resultObj, - TkNewWindowObj(slavePtr->tkwin)); + Tk_NewWindowObj(contentPtr->tkwin)); } Tcl_SetObjResult(interp, resultObj); break; @@ -480,11 +480,11 @@ Tk_PackObjCmd( return TCL_ERROR; } packPtr = GetPacker(tkwin2); - if ((packPtr != NULL) && (packPtr->masterPtr != NULL)) { + if ((packPtr != NULL) && (packPtr->containerPtr != NULL)) { Tk_ManageGeometry(tkwin2, NULL, NULL); - if (packPtr->masterPtr->tkwin != Tk_Parent(packPtr->tkwin)) { + if (packPtr->containerPtr->tkwin != Tk_Parent(packPtr->tkwin)) { Tk_UnmaintainGeometry(packPtr->tkwin, - packPtr->masterPtr->tkwin); + packPtr->containerPtr->tkwin); } Unlink(packPtr); Tk_UnmapWindow(packPtr->tkwin); @@ -519,13 +519,12 @@ static void PackReqProc( ClientData clientData, /* Packer's information about window that got * new preferred geometry. */ - Tk_Window tkwin) /* Other Tk-related information about the + TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { Packer *packPtr = (Packer *)clientData; - (void)tkwin; - packPtr = packPtr->masterPtr; + packPtr = packPtr->containerPtr; if (!(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); @@ -535,34 +534,33 @@ PackReqProc( /* *------------------------------------------------------------------------ * - * PackLostSlaveProc -- + * PackLostContentProc -- * * This function is invoked by Tk whenever some other geometry claims - * control over a slave that used to be managed by us. + * control over a content window that used to be managed by us. * * Results: * None. * * Side effects: - * Forgets all packer-related information about the slave. + * Forgets all packer-related information about the content. * *------------------------------------------------------------------------ */ static void -PackLostSlaveProc( - ClientData clientData, /* Packer structure for slave window that was +PackLostContentProc( + void *clientData, /* Packer structure for content window that was * stolen away. */ - Tk_Window tkwin) /* Tk's handle for the slave window. */ + TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */ { - Packer *slavePtr = (Packer *)clientData; - (void)tkwin; + Packer *contentPtr = (Packer *)clientData; - if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin); + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); } - Unlink(slavePtr); - Tk_UnmapWindow(slavePtr->tkwin); + Unlink(contentPtr); + Tk_UnmapWindow(contentPtr->tkwin); } /* @@ -579,22 +577,22 @@ PackLostSlaveProc( * None. * * Side effects: - * The packed slaves of masterPtr may get resized or moved. + * The packed content of containerPtr may get resized or moved. * *------------------------------------------------------------------------ */ static void ArrangePacking( - ClientData clientData) /* Structure describing master whose slaves + ClientData clientData) /* Structure describing container whose content * are to be re-layed out. */ { - Packer *masterPtr = (Packer *)clientData; - Packer *slavePtr; + Packer *containerPtr = (Packer *)clientData; + Packer *contentPtr; int cavityX, cavityY, cavityWidth, cavityHeight; /* These variables keep track of the * as-yet-unallocated space remaining in the - * middle of the master window. */ + * middle of the container window. */ int frameX, frameY, frameWidth, frameHeight; /* These variables keep track of the frame * allocated to the current window. */ @@ -607,15 +605,15 @@ ArrangePacking( int borderLeft, borderRight; int maxWidth, maxHeight, tmp; - masterPtr->flags &= ~REQUESTED_REPACK; + containerPtr->flags &= ~REQUESTED_REPACK; /* - * If the master has no slaves anymore, then leave the master's size as-is. - * Otherwise there is no way to "relinquish" control over the master + * If the container has no content anymore, then leave the container's size as-is. + * Otherwise there is no way to "relinquish" control over the container * so another geometry manager can take over. */ - if (masterPtr->slavePtr == NULL) { + if (containerPtr->contentPtr == NULL) { return; } @@ -625,52 +623,52 @@ ArrangePacking( * necessary. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - masterPtr->abortPtr = &abort; + containerPtr->abortPtr = &abort; abort = 0; - Tcl_Preserve(masterPtr); + Tcl_Preserve(containerPtr); /* - * Pass #1: scan all the slaves to figure out the total amount of space + * Pass #1: scan all the content to figure out the total amount of space * needed. Two separate width and height values are computed: * * width - Holds the sum of the widths (plus padding) of all the - * slaves seen so far that were packed LEFT or RIGHT. + * content seen so far that were packed LEFT or RIGHT. * height - Holds the sum of the heights (plus padding) of all the - * slaves seen so far that were packed TOP or BOTTOM. + * content seen so far that were packed TOP or BOTTOM. * - * maxWidth - Gradually builds up the width needed by the master to - * just barely satisfy all the slave's needs. For each - * slave, the code computes the width needed for all the - * slaves so far and updates maxWidth if the new value is + * maxWidth - Gradually builds up the width needed by the container to + * just barely satisfy all the content's needs. For each + * content, the code computes the width needed for all the + * content so far and updates maxWidth if the new value is * greater. * maxHeight - Same as maxWidth, except keeps height info. */ - width = maxWidth = Tk_InternalBorderLeft(masterPtr->tkwin) + - Tk_InternalBorderRight(masterPtr->tkwin); - height = maxHeight = Tk_InternalBorderTop(masterPtr->tkwin) + - Tk_InternalBorderBottom(masterPtr->tkwin); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { - tmp = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX + width; + width = maxWidth = Tk_InternalBorderLeft(containerPtr->tkwin) + + Tk_InternalBorderRight(containerPtr->tkwin); + height = maxHeight = Tk_InternalBorderTop(containerPtr->tkwin) + + Tk_InternalBorderBottom(containerPtr->tkwin); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { + tmp = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX + width; if (tmp > maxWidth) { maxWidth = tmp; } - height += Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; + height += Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; } else { - tmp = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY + height; + tmp = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY + height; if (tmp > maxHeight) { maxHeight = tmp; } - width += Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; + width += Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; } } if (width > maxWidth) { @@ -680,31 +678,31 @@ ArrangePacking( maxHeight = height; } - if (maxWidth < Tk_MinReqWidth(masterPtr->tkwin)) { - maxWidth = Tk_MinReqWidth(masterPtr->tkwin); + if (maxWidth < Tk_MinReqWidth(containerPtr->tkwin)) { + maxWidth = Tk_MinReqWidth(containerPtr->tkwin); } - if (maxHeight < Tk_MinReqHeight(masterPtr->tkwin)) { - maxHeight = Tk_MinReqHeight(masterPtr->tkwin); + if (maxHeight < Tk_MinReqHeight(containerPtr->tkwin)) { + maxHeight = Tk_MinReqHeight(containerPtr->tkwin); } /* - * If the total amount of space needed in the master window has changed, + * If the total amount of space needed in the container window has changed, * and if we're propagating geometry information, then notify the next * geometry manager up and requeue ourselves to start again after the - * master has had a chance to resize us. + * container has had a chance to resize us. */ - if (((maxWidth != Tk_ReqWidth(masterPtr->tkwin)) - || (maxHeight != Tk_ReqHeight(masterPtr->tkwin))) - && !(masterPtr->flags & DONT_PROPAGATE)) { - Tk_GeometryRequest(masterPtr->tkwin, maxWidth, maxHeight); - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (((maxWidth != Tk_ReqWidth(containerPtr->tkwin)) + || (maxHeight != Tk_ReqHeight(containerPtr->tkwin))) + && !(containerPtr->flags & DONT_PROPAGATE)) { + Tk_GeometryRequest(containerPtr->tkwin, maxWidth, maxHeight); + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); goto done; } /* - * Pass #2: scan the slaves a second time assigning new sizes. The + * Pass #2: scan the content a second time assigning new sizes. The * "cavity" variables keep track of the unclaimed space in the cavity of * the window; this shrinks inward as we allocate windows around the * edges. The "frame" variables keep track of the space allocated to the @@ -712,22 +710,22 @@ ArrangePacking( * somewhere inside the frame, depending on anchor. */ - cavityX = x = Tk_InternalBorderLeft(masterPtr->tkwin); - cavityY = y = Tk_InternalBorderTop(masterPtr->tkwin); - cavityWidth = Tk_Width(masterPtr->tkwin) - - Tk_InternalBorderLeft(masterPtr->tkwin) - - Tk_InternalBorderRight(masterPtr->tkwin); - cavityHeight = Tk_Height(masterPtr->tkwin) - - Tk_InternalBorderTop(masterPtr->tkwin) - - Tk_InternalBorderBottom(masterPtr->tkwin); - for (slavePtr = masterPtr->slavePtr; slavePtr != NULL; - slavePtr = slavePtr->nextPtr) { - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { + cavityX = x = Tk_InternalBorderLeft(containerPtr->tkwin); + cavityY = y = Tk_InternalBorderTop(containerPtr->tkwin); + cavityWidth = Tk_Width(containerPtr->tkwin) - + Tk_InternalBorderLeft(containerPtr->tkwin) - + Tk_InternalBorderRight(containerPtr->tkwin); + cavityHeight = Tk_Height(containerPtr->tkwin) - + Tk_InternalBorderTop(containerPtr->tkwin) - + Tk_InternalBorderBottom(containerPtr->tkwin); + for (contentPtr = containerPtr->contentPtr; contentPtr != NULL; + contentPtr = contentPtr->nextPtr) { + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { frameWidth = cavityWidth; - frameHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; - if (slavePtr->flags & EXPAND) { - frameHeight += YExpansion(slavePtr, cavityHeight); + frameHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; + if (contentPtr->flags & EXPAND) { + frameHeight += YExpansion(contentPtr, cavityHeight); } cavityHeight -= frameHeight; if (cavityHeight < 0) { @@ -735,7 +733,7 @@ ArrangePacking( cavityHeight = 0; } frameX = cavityX; - if (slavePtr->side == TOP) { + if (contentPtr->side == TOP) { frameY = cavityY; cavityY += frameHeight; } else { @@ -743,10 +741,10 @@ ArrangePacking( } } else { frameHeight = cavityHeight; - frameWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; - if (slavePtr->flags & EXPAND) { - frameWidth += XExpansion(slavePtr, cavityWidth); + frameWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; + if (contentPtr->flags & EXPAND) { + frameWidth += XExpansion(contentPtr, cavityWidth); } cavityWidth -= frameWidth; if (cavityWidth < 0) { @@ -754,7 +752,7 @@ ArrangePacking( cavityWidth = 0; } frameY = cavityY; - if (slavePtr->side == LEFT) { + if (contentPtr->side == LEFT) { frameX = cavityX; cavityX += frameWidth; } else { @@ -771,31 +769,31 @@ ArrangePacking( * completely ignored except when computing frame size). */ - if (slavePtr->flags & OLD_STYLE) { + if (contentPtr->flags & OLD_STYLE) { borderX = borderY = 0; borderTop = borderBtm = 0; borderLeft = borderRight = 0; } else { - borderX = slavePtr->padX; - borderY = slavePtr->padY; - borderLeft = slavePtr->padLeft; + borderX = contentPtr->padX; + borderY = contentPtr->padY; + borderLeft = contentPtr->padLeft; borderRight = borderX - borderLeft; - borderTop = slavePtr->padTop; + borderTop = contentPtr->padTop; borderBtm = borderY - borderTop; } - width = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->iPadX; - if ((slavePtr->flags & FILLX) + width = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->iPadX; + if ((contentPtr->flags & FILLX) || (width > (frameWidth - borderX))) { width = frameWidth - borderX; } - height = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->iPadY; - if ((slavePtr->flags & FILLY) + height = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->iPadY; + if ((contentPtr->flags & FILLY) || (height > (frameHeight - borderY))) { height = frameHeight - borderY; } - switch (slavePtr->anchor) { + switch (contentPtr->anchor) { case TK_ANCHOR_N: x = frameX + (borderLeft + frameWidth - width - borderRight)/2; y = frameY + borderTop; @@ -835,44 +833,44 @@ ArrangePacking( default: Tcl_Panic("bad frame factor in ArrangePacking"); } - width -= slavePtr->doubleBw; - height -= slavePtr->doubleBw; + width -= contentPtr->doubleBw; + height -= contentPtr->doubleBw; /* * The final step is to set the position, size, and mapped/unmapped - * state of the slave. If the slave is a child of the master, then do + * state of the content. If the content is a child of the container, then do * this here. Otherwise let Tk_MaintainGeometry do the work. */ - if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) { + if (containerPtr->tkwin == Tk_Parent(contentPtr->tkwin)) { if ((width <= 0) || (height <= 0)) { - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - if ((x != Tk_X(slavePtr->tkwin)) - || (y != Tk_Y(slavePtr->tkwin)) - || (width != Tk_Width(slavePtr->tkwin)) - || (height != Tk_Height(slavePtr->tkwin))) { - Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height); + if ((x != Tk_X(contentPtr->tkwin)) + || (y != Tk_Y(contentPtr->tkwin)) + || (width != Tk_Width(contentPtr->tkwin)) + || (height != Tk_Height(contentPtr->tkwin))) { + Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height); } if (abort) { goto done; } /* - * Don't map the slave if the master isn't mapped: wait until - * the master gets mapped later. + * Don't map the content if the container isn't mapped: wait until + * the container gets mapped later. */ - if (Tk_IsMapped(masterPtr->tkwin)) { - Tk_MapWindow(slavePtr->tkwin); + if (Tk_IsMapped(containerPtr->tkwin)) { + Tk_MapWindow(contentPtr->tkwin); } } } else { if ((width <= 0) || (height <= 0)) { - Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin); - Tk_UnmapWindow(slavePtr->tkwin); + Tk_UnmaintainGeometry(contentPtr->tkwin, containerPtr->tkwin); + Tk_UnmapWindow(contentPtr->tkwin); } else { - Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin, + Tk_MaintainGeometry(contentPtr->tkwin, containerPtr->tkwin, x, y, width, height); } } @@ -889,8 +887,8 @@ ArrangePacking( } done: - masterPtr->abortPtr = NULL; - Tcl_Release(masterPtr); + containerPtr->abortPtr = NULL; + Tcl_Release(containerPtr); } /* @@ -898,7 +896,7 @@ ArrangePacking( * * XExpansion -- * - * Given a list of packed slaves, the first of which is packed on the + * Given a list of packed content, the first of which is packed on the * left or right and is expandable, compute how much to expand the child. * * Results: @@ -913,9 +911,9 @@ ArrangePacking( static int XExpansion( - Packer *slavePtr, /* First in list of remaining slaves. */ + Packer *contentPtr, /* First in list of remaining content. */ int cavityWidth) /* Horizontal space left for all remaining - * slaves. */ + * content. */ { int numExpand, minExpand, curExpand; int childWidth; @@ -933,10 +931,10 @@ XExpansion( minExpand = cavityWidth; numExpand = 0; - for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { - childWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padX + slavePtr->iPadX; - if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) { + for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { + childWidth = Tk_ReqWidth(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padX + contentPtr->iPadX; + if ((contentPtr->side == TOP) || (contentPtr->side == BOTTOM)) { if (numExpand) { curExpand = (cavityWidth - childWidth)/numExpand; if (curExpand < minExpand) { @@ -945,7 +943,7 @@ XExpansion( } } else { cavityWidth -= childWidth; - if (slavePtr->flags & EXPAND) { + if (contentPtr->flags & EXPAND) { numExpand++; } } @@ -964,7 +962,7 @@ XExpansion( * * YExpansion -- * - * Given a list of packed slaves, the first of which is packed on the top + * Given a list of packed content, the first of which is packed on the top * or bottom and is expandable, compute how much to expand the child. * * Results: @@ -979,9 +977,9 @@ XExpansion( static int YExpansion( - Packer *slavePtr, /* First in list of remaining slaves. */ + Packer *contentPtr, /* First in list of remaining content. */ int cavityHeight) /* Vertical space left for all remaining - * slaves. */ + * content. */ { int numExpand, minExpand, curExpand; int childHeight; @@ -992,10 +990,10 @@ YExpansion( minExpand = cavityHeight; numExpand = 0; - for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) { - childHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw - + slavePtr->padY + slavePtr->iPadY; - if ((slavePtr->side == LEFT) || (slavePtr->side == RIGHT)) { + for ( ; contentPtr != NULL; contentPtr = contentPtr->nextPtr) { + childHeight = Tk_ReqHeight(contentPtr->tkwin) + contentPtr->doubleBw + + contentPtr->padY + contentPtr->iPadY; + if ((contentPtr->side == LEFT) || (contentPtr->side == RIGHT)) { if (numExpand) { curExpand = (cavityHeight - childHeight)/numExpand; if (curExpand < minExpand) { @@ -1004,7 +1002,7 @@ YExpansion( } } else { cavityHeight -= childHeight; - if (slavePtr->flags & EXPAND) { + if (contentPtr->flags & EXPAND) { numExpand++; } } @@ -1064,9 +1062,9 @@ GetPacker( } packPtr = (Packer *)ckalloc(sizeof(Packer)); packPtr->tkwin = tkwin; - packPtr->masterPtr = NULL; + packPtr->containerPtr = NULL; packPtr->nextPtr = NULL; - packPtr->slavePtr = NULL; + packPtr->contentPtr = NULL; packPtr->side = TOP; packPtr->anchor = TK_ANCHOR_CENTER; packPtr->padX = packPtr->padY = 0; @@ -1087,7 +1085,7 @@ GetPacker( * PackAfter -- * * This function does most of the real work of adding one or more windows - * into the packing order for its master. + * into the packing order for its container. * * Results: * A standard Tcl return value. @@ -1105,8 +1103,8 @@ PackAfter( Tcl_Interp *interp, /* Interpreter for error reporting. */ Packer *prevPtr, /* Pack windows in argv just after this * window; NULL means pack as first child of - * masterPtr. */ - Packer *masterPtr, /* Master in which to pack windows. */ + * containerPtr. */ + Packer *containerPtr, /* Container in which to pack windows. */ int objc, /* Number of elements in objv. */ Tcl_Obj *const objv[]) /* Array of lists, each containing 2 elements: * window name and side against which to @@ -1138,21 +1136,21 @@ PackAfter( * its parent. */ - if (TkGetWindowFromObj(interp, masterPtr->tkwin, objv[0], &tkwin) + if (TkGetWindowFromObj(interp, containerPtr->tkwin, objv[0], &tkwin) != TCL_OK) { return TCL_ERROR; } parent = Tk_Parent(tkwin); - for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { + for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) { badWindow: Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside %s", Tcl_GetString(objv[0]), - Tk_PathName(masterPtr->tkwin))); + "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[0]), + Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } @@ -1160,7 +1158,7 @@ PackAfter( if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_HIERARCHY) { goto badWindow; } - if (tkwin == masterPtr->tkwin) { + if (tkwin == containerPtr->tkwin) { goto badWindow; } packPtr = GetPacker(tkwin); @@ -1270,53 +1268,53 @@ PackAfter( * Unpack this window if it's currently packed. */ - if (packPtr->masterPtr != NULL) { - if ((packPtr->masterPtr != masterPtr) && - (packPtr->masterPtr->tkwin + if (packPtr->containerPtr != NULL) { + if ((packPtr->containerPtr != containerPtr) && + (packPtr->containerPtr->tkwin != Tk_Parent(packPtr->tkwin))) { Tk_UnmaintainGeometry(packPtr->tkwin, - packPtr->masterPtr->tkwin); + packPtr->containerPtr->tkwin); } Unlink(packPtr); } /* - * Add the window in the correct place in its master's packing + * Add the window in the correct place in its container's packing * order, then make sure that the window is managed by us. */ - packPtr->masterPtr = masterPtr; + packPtr->containerPtr = containerPtr; if (prevPtr == NULL) { - packPtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = packPtr; + packPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = packPtr; } else { packPtr->nextPtr = prevPtr->nextPtr; prevPtr->nextPtr = packPtr; } Tk_ManageGeometry(tkwin, &packerType, packPtr); - if (!(masterPtr->flags & DONT_PROPAGATE)) { - if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack") + if (!(containerPtr->flags & DONT_PROPAGATE)) { + if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack") != TCL_OK) { Tk_ManageGeometry(tkwin, NULL, NULL); Unlink(packPtr); return TCL_ERROR; } - masterPtr->flags |= ALLOCED_MASTER; + containerPtr->flags |= ALLOCED_CONTAINER; } } } /* - * Arrange for the master to be re-packed at the first idle moment. + * Arrange for the container to be re-packed at the first idle moment. */ - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } return TCL_OK; } @@ -1327,13 +1325,13 @@ PackAfter( * * Unlink -- * - * Remove a packer from its master's list of slaves. + * Remove a packer from its container's list of content. * * Results: * None. * * Side effects: - * The master will be scheduled for repacking. + * The container will be scheduled for repacking. * *---------------------------------------------------------------------- */ @@ -1342,16 +1340,16 @@ static void Unlink( Packer *packPtr) /* Window to unlink. */ { - Packer *masterPtr, *packPtr2; + Packer *containerPtr, *packPtr2; - masterPtr = packPtr->masterPtr; - if (masterPtr == NULL) { + containerPtr = packPtr->containerPtr; + if (containerPtr == NULL) { return; } - if (masterPtr->slavePtr == packPtr) { - masterPtr->slavePtr = packPtr->nextPtr; + if (containerPtr->contentPtr == packPtr) { + containerPtr->contentPtr = packPtr->nextPtr; } else { - for (packPtr2 = masterPtr->slavePtr; ; packPtr2 = packPtr2->nextPtr) { + for (packPtr2 = containerPtr->contentPtr; ; packPtr2 = packPtr2->nextPtr) { if (packPtr2 == NULL) { Tcl_Panic("Unlink couldn't find previous window"); } @@ -1361,28 +1359,28 @@ Unlink( } } } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - packPtr->masterPtr = NULL; + packPtr->containerPtr = NULL; /* - * If we have emptied this master from slaves it means we are no longer + * If we have emptied this container from content it means we are no longer * handling it and should mark it as free. * - * Send the event "NoManagedChild" to the master to inform it about there + * Send the event "NoManagedChild" to the container to inform it about there * being no managed children inside it. */ - if ((masterPtr->slavePtr == NULL) && (masterPtr->flags & ALLOCED_MASTER)) { - TkFreeGeometryMaster(masterPtr->tkwin, "pack"); - masterPtr->flags &= ~ALLOCED_MASTER; - TkSendVirtualEvent(masterPtr->tkwin, "NoManagedChild", NULL); + if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) { + TkFreeGeometryContainer(containerPtr->tkwin, "pack"); + containerPtr->flags &= ~ALLOCED_CONTAINER; + Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL); } } @@ -1428,7 +1426,7 @@ DestroyPacker( * * Side effects: * If a window was just deleted, clean up all its packer-related - * information. If it was just resized, repack its slaves, if any. + * information. If it was just resized, repack its content, if any. * *---------------------------------------------------------------------- */ @@ -1442,33 +1440,33 @@ PackStructureProc( Packer *packPtr = (Packer *)clientData; if (eventPtr->type == ConfigureNotify) { - if ((packPtr->slavePtr != NULL) + if ((packPtr->contentPtr != NULL) && !(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); } - if ((packPtr->masterPtr != NULL) + if ((packPtr->containerPtr != NULL) && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) { - if (!(packPtr->masterPtr->flags & REQUESTED_REPACK)) { + if (!(packPtr->containerPtr->flags & REQUESTED_REPACK)) { packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width; - packPtr->masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, packPtr->masterPtr); + packPtr->containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, packPtr->containerPtr); } } } else if (eventPtr->type == DestroyNotify) { - Packer *slavePtr, *nextPtr; + Packer *contentPtr, *nextPtr; - if (packPtr->masterPtr != NULL) { + if (packPtr->containerPtr != NULL) { Unlink(packPtr); } - for (slavePtr = packPtr->slavePtr; slavePtr != NULL; - slavePtr = nextPtr) { - Tk_ManageGeometry(slavePtr->tkwin, NULL, NULL); - Tk_UnmapWindow(slavePtr->tkwin); - slavePtr->masterPtr = NULL; - nextPtr = slavePtr->nextPtr; - slavePtr->nextPtr = NULL; + for (contentPtr = packPtr->contentPtr; contentPtr != NULL; + contentPtr = nextPtr) { + Tk_ManageGeometry(contentPtr->tkwin, NULL, NULL); + Tk_UnmapWindow(contentPtr->tkwin); + contentPtr->containerPtr = NULL; + nextPtr = contentPtr->nextPtr; + contentPtr->nextPtr = NULL; } if (packPtr->tkwin != NULL) { @@ -1484,11 +1482,11 @@ PackStructureProc( Tcl_EventuallyFree(packPtr, (Tcl_FreeProc *) DestroyPacker); } else if (eventPtr->type == MapNotify) { /* - * When a master gets mapped, must redo the geometry computation so - * that all of its slaves get remapped. + * When a container gets mapped, must redo the geometry computation so + * that all of its content get remapped. */ - if ((packPtr->slavePtr != NULL) + if ((packPtr->contentPtr != NULL) && !(packPtr->flags & REQUESTED_REPACK)) { packPtr->flags |= REQUESTED_REPACK; Tcl_DoWhenIdle(ArrangePacking, packPtr); @@ -1497,11 +1495,11 @@ PackStructureProc( Packer *packPtr2; /* - * Unmap all of the slaves when the master gets unmapped, so that they + * Unmap all of the content when the container gets unmapped, so that they * don't bother to keep redisplaying themselves. */ - for (packPtr2 = packPtr->slavePtr; packPtr2 != NULL; + for (packPtr2 = packPtr->contentPtr; packPtr2 != NULL; packPtr2 = packPtr2->nextPtr) { Tk_UnmapWindow(packPtr2->tkwin); } @@ -1511,36 +1509,36 @@ PackStructureProc( /* *---------------------------------------------------------------------- * - * ConfigureSlaves -- + * ConfigureContent -- * * This implements the guts of the "pack configure" command. Given a list - * of slaves and configuration options, it arranges for the packer to - * manage the slaves and sets the specified options. + * of content and configuration options, it arranges for the packer to + * manage the content and sets the specified options. * * Results: * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is returned * and the interp's result is set to contain an error message. * * Side effects: - * Slave windows get taken over by the packer. + * Content windows get taken over by the packer. * *---------------------------------------------------------------------- */ static int -ConfigureSlaves( +ConfigureContent( Tcl_Interp *interp, /* Interpreter for error reporting. */ Tk_Window tkwin, /* Any window in application containing - * slaves. Used to look up slave names. */ + * content. Used to look up content names. */ int objc, /* Number of elements in argv. */ Tcl_Obj *const objv[]) /* Argument objects: contains one or more * window names followed by any number of * "option value" pairs. Caller must make sure * that there is at least one window name. */ { - Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr; - Tk_Window other, slave, parent, ancestor; - TkWindow *master; + Packer *containerPtr, *contentPtr, *prevPtr, *otherPtr; + Tk_Window other, content, parent, ancestor; + TkWindow *container; int i, j, numWindows, tmp, positionGiven; const char *string; static const char *const optionStrings[] = { @@ -1563,45 +1561,45 @@ ConfigureSlaves( } /* - * Iterate over all of the slave windows, parsing the configuration - * options for each slave. It's a bit wasteful to re-parse the options for - * each slave, but things get too messy if we try to parse the arguments - * just once at the beginning. For example, if a slave already is packed + * Iterate over all of the content windows, parsing the configuration + * options for each content. It's a bit wasteful to re-parse the options for + * each content, but things get too messy if we try to parse the arguments + * just once at the beginning. For example, if a content already is packed * we want to just change a few existing values without resetting * everything. If there are multiple windows, the -after, -before, and -in * options only get processed for the first window. */ - masterPtr = NULL; + containerPtr = NULL; prevPtr = NULL; positionGiven = 0; for (j = 0; j < numWindows; j++) { - if (TkGetWindowFromObj(interp, tkwin, objv[j], &slave) != TCL_OK) { + if (TkGetWindowFromObj(interp, tkwin, objv[j], &content) != TCL_OK) { return TCL_ERROR; } - if (Tk_TopWinHierarchy(slave)) { + if (Tk_TopWinHierarchy(content)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't pack \"%s\": it's a top-level window", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL); return TCL_ERROR; } - slavePtr = GetPacker(slave); - slavePtr->flags &= ~OLD_STYLE; + contentPtr = GetPacker(content); + contentPtr->flags &= ~OLD_STYLE; /* - * If the slave isn't currently packed, reset all of its configuration + * If the content isn't currently packed, reset all of its configuration * information to default values (there could be old values left from * a previous packing). */ - if (slavePtr->masterPtr == NULL) { - slavePtr->side = TOP; - slavePtr->anchor = TK_ANCHOR_CENTER; - slavePtr->padX = slavePtr->padY = 0; - slavePtr->padLeft = slavePtr->padTop = 0; - slavePtr->iPadX = slavePtr->iPadY = 0; - slavePtr->flags &= ~(FILLX|FILLY|EXPAND); + if (contentPtr->containerPtr == NULL) { + contentPtr->side = TOP; + contentPtr->anchor = TK_ANCHOR_CENTER; + contentPtr->padX = contentPtr->padY = 0; + contentPtr->padLeft = contentPtr->padTop = 0; + contentPtr->iPadX = contentPtr->iPadY = 0; + contentPtr->flags &= ~(FILLX|FILLY|EXPAND); } for (i = numWindows; i < objc; i+=2) { @@ -1625,7 +1623,7 @@ ConfigureSlaves( return TCL_ERROR; } prevPtr = GetPacker(other); - if (prevPtr->masterPtr == NULL) { + if (prevPtr->containerPtr == NULL) { notPacked: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" isn't packed", @@ -1634,12 +1632,12 @@ ConfigureSlaves( NULL); return TCL_ERROR; } - masterPtr = prevPtr->masterPtr; + containerPtr = prevPtr->containerPtr; positionGiven = 1; } break; case CONF_ANCHOR: - if (Tk_GetAnchorFromObj(interp, objv[i+1], &slavePtr->anchor) + if (Tk_GetAnchorFromObj(interp, objv[i+1], &contentPtr->anchor) != TCL_OK) { return TCL_ERROR; } @@ -1651,11 +1649,11 @@ ConfigureSlaves( return TCL_ERROR; } otherPtr = GetPacker(other); - if (otherPtr->masterPtr == NULL) { + if (otherPtr->containerPtr == NULL) { goto notPacked; } - masterPtr = otherPtr->masterPtr; - prevPtr = masterPtr->slavePtr; + containerPtr = otherPtr->containerPtr; + prevPtr = containerPtr->contentPtr; if (prevPtr == otherPtr) { prevPtr = NULL; } else { @@ -1670,21 +1668,21 @@ ConfigureSlaves( if (Tcl_GetBooleanFromObj(interp, objv[i+1], &tmp) != TCL_OK) { return TCL_ERROR; } - slavePtr->flags &= ~EXPAND; + contentPtr->flags &= ~EXPAND; if (tmp) { - slavePtr->flags |= EXPAND; + contentPtr->flags |= EXPAND; } break; case CONF_FILL: string = Tcl_GetString(objv[i+1]); if (strcmp(string, "none") == 0) { - slavePtr->flags &= ~(FILLX|FILLY); + contentPtr->flags &= ~(FILLX|FILLY); } else if (strcmp(string, "x") == 0) { - slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX; + contentPtr->flags = (contentPtr->flags & ~FILLY) | FILLX; } else if (strcmp(string, "y") == 0) { - slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY; + contentPtr->flags = (contentPtr->flags & ~FILLX) | FILLY; } else if (strcmp(string, "both") == 0) { - slavePtr->flags |= FILLX|FILLY; + contentPtr->flags |= FILLX|FILLY; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad fill style \"%s\": must be " @@ -1699,8 +1697,8 @@ ConfigureSlaves( != TCL_OK) { return TCL_ERROR; } - masterPtr = GetPacker(other); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(other); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; @@ -1710,7 +1708,7 @@ ConfigureSlaves( } break; case CONF_IPADX: - if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipadx value \"%s\": must be positive screen" @@ -1718,10 +1716,10 @@ ConfigureSlaves( Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadX = tmp * 2; + contentPtr->iPadX = tmp * 2; break; case CONF_IPADY: - if ((Tk_GetPixelsFromObj(interp, slave, objv[i+1], &tmp) + if ((Tk_GetPixelsFromObj(interp, content, objv[i+1], &tmp) != TCL_OK) || (tmp < 0)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad ipady value \"%s\": must be positive screen" @@ -1729,17 +1727,17 @@ ConfigureSlaves( Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL); return TCL_ERROR; } - slavePtr->iPadY = tmp * 2; + contentPtr->iPadY = tmp * 2; break; case CONF_PADX: - if (TkParsePadAmount(interp, slave, objv[i+1], - &slavePtr->padLeft, &slavePtr->padX) != TCL_OK) { + if (TkParsePadAmount(interp, content, objv[i+1], + &contentPtr->padLeft, &contentPtr->padX) != TCL_OK) { return TCL_ERROR; } break; case CONF_PADY: - if (TkParsePadAmount(interp, slave, objv[i+1], - &slavePtr->padTop, &slavePtr->padY) != TCL_OK) { + if (TkParsePadAmount(interp, content, objv[i+1], + &contentPtr->padTop, &contentPtr->padY) != TCL_OK) { return TCL_ERROR; } break; @@ -1748,42 +1746,42 @@ ConfigureSlaves( sizeof(char *), "side", TCL_EXACT, &side) != TCL_OK) { return TCL_ERROR; } - slavePtr->side = (Side) side; + contentPtr->side = (Side) side; break; } } /* - * If no position in a packing list was specified and the slave is + * If no position in a packing list was specified and the content is * already packed, then leave it in its current location in its * current packing list. */ - if (!positionGiven && (slavePtr->masterPtr != NULL)) { - masterPtr = slavePtr->masterPtr; + if (!positionGiven && (contentPtr->containerPtr != NULL)) { + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } /* - * If the slave is going to be put back after itself or the same -in + * If the content is going to be put back after itself or the same -in * window is passed in again, then just skip the whole operation, * since it won't work anyway. */ - if (prevPtr == slavePtr) { - masterPtr = slavePtr->masterPtr; + if (prevPtr == contentPtr) { + containerPtr = contentPtr->containerPtr; goto scheduleLayout; } /* * If none of the "-in", "-before", or "-after" options has been - * specified, arrange for the slave to go at the end of the order for + * specified, arrange for the content to go at the end of the order for * its parent. */ if (!positionGiven) { - masterPtr = GetPacker(Tk_Parent(slave)); - prevPtr = masterPtr->slavePtr; + containerPtr = GetPacker(Tk_Parent(content)); + prevPtr = containerPtr->contentPtr; if (prevPtr != NULL) { while (prevPtr->nextPtr != NULL) { prevPtr = prevPtr->nextPtr; @@ -1792,27 +1790,27 @@ ConfigureSlaves( } /* - * Make sure that the slave's parent is either the master or an - * ancestor of the master, and that the master and slave aren't the + * Make sure that the content's parent is either the container or an + * ancestor of the container, and that the container and content aren't the * same. */ - parent = Tk_Parent(slave); - for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { + parent = Tk_Parent(content); + for (ancestor = containerPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) { if (ancestor == parent) { break; } if (Tk_TopWinHierarchy(ancestor)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside %s", Tcl_GetString(objv[j]), - Tk_PathName(masterPtr->tkwin))); + "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[j]), + Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL); return TCL_ERROR; } } - if (slave == masterPtr->tkwin) { + if (content == containerPtr->tkwin) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't pack %s inside itself", Tcl_GetString(objv[j]))); + "can't pack \"%s\" inside itself", Tcl_GetString(objv[j]))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL); return TCL_ERROR; } @@ -1821,67 +1819,67 @@ ConfigureSlaves( * Check for management loops. */ - for (master = (TkWindow *)masterPtr->tkwin; master != NULL; - master = (TkWindow *)TkGetGeomMaster(master)) { - if (master == (TkWindow *)slave) { + for (container = (TkWindow *)containerPtr->tkwin; container != NULL; + container = (TkWindow *)TkGetContainer(container)) { + if (container == (TkWindow *)content) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't put %s inside %s, would cause management loop", - Tcl_GetString(objv[j]), Tk_PathName(masterPtr->tkwin))); + "can't put \"%s\" inside \"%s\": would cause management loop", + Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); return TCL_ERROR; } } - if (masterPtr->tkwin != Tk_Parent(slave)) { - ((TkWindow *)slave)->maintainerPtr = (TkWindow *)masterPtr->tkwin; + if (containerPtr->tkwin != Tk_Parent(content)) { + ((TkWindow *)content)->maintainerPtr = (TkWindow *)containerPtr->tkwin; } /* - * Unpack the slave if it's currently packed, then position it after + * Unpack the content if it's currently packed, then position it after * prevPtr. */ - if (slavePtr->masterPtr != NULL) { - if ((slavePtr->masterPtr != masterPtr) && - (slavePtr->masterPtr->tkwin - != Tk_Parent(slavePtr->tkwin))) { - Tk_UnmaintainGeometry(slavePtr->tkwin, - slavePtr->masterPtr->tkwin); + if (contentPtr->containerPtr != NULL) { + if ((contentPtr->containerPtr != containerPtr) && + (contentPtr->containerPtr->tkwin + != Tk_Parent(contentPtr->tkwin))) { + Tk_UnmaintainGeometry(contentPtr->tkwin, + contentPtr->containerPtr->tkwin); } - Unlink(slavePtr); + Unlink(contentPtr); } - slavePtr->masterPtr = masterPtr; + contentPtr->containerPtr = containerPtr; if (prevPtr == NULL) { - slavePtr->nextPtr = masterPtr->slavePtr; - masterPtr->slavePtr = slavePtr; + contentPtr->nextPtr = containerPtr->contentPtr; + containerPtr->contentPtr = contentPtr; } else { - slavePtr->nextPtr = prevPtr->nextPtr; - prevPtr->nextPtr = slavePtr; + contentPtr->nextPtr = prevPtr->nextPtr; + prevPtr->nextPtr = contentPtr; } - Tk_ManageGeometry(slave, &packerType, slavePtr); - prevPtr = slavePtr; + Tk_ManageGeometry(content, &packerType, contentPtr); + prevPtr = contentPtr; - if (!(masterPtr->flags & DONT_PROPAGATE)) { - if (TkSetGeometryMaster(interp, masterPtr->tkwin, "pack") + if (!(containerPtr->flags & DONT_PROPAGATE)) { + if (TkSetGeometryContainer(interp, containerPtr->tkwin, "pack") != TCL_OK) { - Tk_ManageGeometry(slave, NULL, NULL); - Unlink(slavePtr); + Tk_ManageGeometry(content, NULL, NULL); + Unlink(contentPtr); return TCL_ERROR; } - masterPtr->flags |= ALLOCED_MASTER; + containerPtr->flags |= ALLOCED_CONTAINER; } /* - * Arrange for the master to be re-packed at the first idle moment. + * Arrange for the container to be re-packed at the first idle moment. */ scheduleLayout: - if (masterPtr->abortPtr != NULL) { - *masterPtr->abortPtr = 1; + if (containerPtr->abortPtr != NULL) { + *containerPtr->abortPtr = 1; } - if (!(masterPtr->flags & REQUESTED_REPACK)) { - masterPtr->flags |= REQUESTED_REPACK; - Tcl_DoWhenIdle(ArrangePacking, masterPtr); + if (!(containerPtr->flags & REQUESTED_REPACK)) { + containerPtr->flags |= REQUESTED_REPACK; + Tcl_DoWhenIdle(ArrangePacking, containerPtr); } } return TCL_OK; |