summaryrefslogtreecommitdiffstats
path: root/generic/tkGeometry.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGeometry.c')
-rw-r--r--generic/tkGeometry.c118
1 files changed, 100 insertions, 18 deletions
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index 4c8e4f8..2e0009a 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -84,7 +84,7 @@ void
Tk_ManageGeometry(
Tk_Window tkwin, /* Window whose geometry is to be managed by
* proc. */
- CONST Tk_GeomMgr *mgrPtr, /* Static structure describing the geometry
+ const Tk_GeomMgr *mgrPtr, /* Static structure describing the geometry
* manager. This structure must never go
* away. */
ClientData clientData) /* Arbitrary one-word argument to pass to
@@ -96,7 +96,7 @@ Tk_ManageGeometry(
&& ((winPtr->geomMgrPtr != mgrPtr)
|| (winPtr->geomData != clientData))
&& (winPtr->geomMgrPtr->lostSlaveProc != NULL)) {
- (*winPtr->geomMgrPtr->lostSlaveProc)(winPtr->geomData, tkwin);
+ winPtr->geomMgrPtr->lostSlaveProc(winPtr->geomData, tkwin);
}
winPtr->geomMgrPtr = mgrPtr;
@@ -152,7 +152,7 @@ Tk_GeometryRequest(
winPtr->reqHeight = reqHeight;
if ((winPtr->geomMgrPtr != NULL)
&& (winPtr->geomMgrPtr->requestProc != NULL)) {
- (*winPtr->geomMgrPtr->requestProc)(winPtr->geomData, tkwin);
+ winPtr->geomMgrPtr->requestProc(winPtr->geomData, tkwin);
}
}
@@ -304,6 +304,88 @@ Tk_SetMinimumRequestSize(
/*
*----------------------------------------------------------------------
*
+ * TkSetGeometryMaster --
+ *
+ * Set a geometry master for this window. Only one master may own
+ * a window at any time.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * The geometry master is recorded for the window.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkSetGeometryMaster(
+ Tcl_Interp *interp, /* Current interpreter, for error. */
+ Tk_Window tkwin, /* Window that will have geometry master
+ * set. */
+ const char *master) /* The master identity. */
+{
+ register TkWindow *winPtr = (TkWindow *) tkwin;
+
+ if (winPtr->geometryMaster != NULL &&
+ strcmp(winPtr->geometryMaster, master) == 0) {
+ return TCL_OK;
+ }
+ if (winPtr->geometryMaster != NULL) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "cannot use geometry manager %s inside %s which already"
+ " has slaves managed by %s",
+ master, Tk_PathName(tkwin), winPtr->geometryMaster));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL);
+ }
+ return TCL_ERROR;
+ }
+
+ winPtr->geometryMaster = ckalloc(strlen(master) + 1);
+ strcpy(winPtr->geometryMaster, master);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkFreeGeometryMaster --
+ *
+ * Remove a geometry master for this window. Only one master may own
+ * a window at any time.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The geometry master is cleared for the window.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkFreeGeometryMaster(
+ Tk_Window tkwin, /* Window that will have geometry master
+ * cleared. */
+ const char *master) /* The master identity. */
+{
+ register TkWindow *winPtr = (TkWindow *) tkwin;
+
+ if (winPtr->geometryMaster != NULL &&
+ strcmp(winPtr->geometryMaster, master) != 0) {
+ Tcl_Panic("Trying to free %s from geometry manager %s",
+ winPtr->geometryMaster, master);
+ }
+ if (winPtr->geometryMaster != NULL) {
+ ckfree(winPtr->geometryMaster);
+ winPtr->geometryMaster = NULL;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tk_MaintainGeometry --
*
* This procedure is invoked by geometry managers to handle slaves whose
@@ -379,9 +461,9 @@ Tk_MaintainGeometry(
hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
(char *) master, &isNew);
if (!isNew) {
- masterPtr = (MaintainMaster *) Tcl_GetHashValue(hPtr);
+ masterPtr = Tcl_GetHashValue(hPtr);
} else {
- masterPtr = (MaintainMaster *) ckalloc(sizeof(MaintainMaster));
+ masterPtr = ckalloc(sizeof(MaintainMaster));
masterPtr->ancestor = master;
masterPtr->checkScheduled = 0;
masterPtr->slavePtr = NULL;
@@ -399,13 +481,13 @@ Tk_MaintainGeometry(
goto gotSlave;
}
}
- slavePtr = (MaintainSlave *) ckalloc(sizeof(MaintainSlave));
+ slavePtr = ckalloc(sizeof(MaintainSlave));
slavePtr->slave = slave;
slavePtr->master = master;
slavePtr->nextPtr = masterPtr->slavePtr;
masterPtr->slavePtr = slavePtr;
Tk_CreateEventHandler(slave, StructureNotifyMask, MaintainSlaveProc,
- (ClientData) slavePtr);
+ slavePtr);
/*
* Make sure that there are event handlers registered for all the windows
@@ -418,7 +500,7 @@ Tk_MaintainGeometry(
ancestor = Tk_Parent(ancestor)) {
if (ancestor == masterPtr->ancestor) {
Tk_CreateEventHandler(ancestor, StructureNotifyMask,
- MaintainMasterProc, (ClientData) masterPtr);
+ MaintainMasterProc, masterPtr);
masterPtr->ancestor = Tk_Parent(ancestor);
}
}
@@ -509,7 +591,7 @@ Tk_UnmaintainGeometry(
if (hPtr == NULL) {
return;
}
- masterPtr = (MaintainMaster *) Tcl_GetHashValue(hPtr);
+ masterPtr = Tcl_GetHashValue(hPtr);
slavePtr = masterPtr->slavePtr;
if (slavePtr->slave == slave) {
masterPtr->slavePtr = slavePtr->nextPtr;
@@ -526,23 +608,23 @@ Tk_UnmaintainGeometry(
}
}
Tk_DeleteEventHandler(slavePtr->slave, StructureNotifyMask,
- MaintainSlaveProc, (ClientData) slavePtr);
- ckfree((char *) slavePtr);
+ MaintainSlaveProc, slavePtr);
+ ckfree(slavePtr);
if (masterPtr->slavePtr == NULL) {
if (masterPtr->ancestor != NULL) {
for (ancestor = master; ; ancestor = Tk_Parent(ancestor)) {
Tk_DeleteEventHandler(ancestor, StructureNotifyMask,
- MaintainMasterProc, (ClientData) masterPtr);
+ MaintainMasterProc, masterPtr);
if (ancestor == masterPtr->ancestor) {
break;
}
}
}
if (masterPtr->checkScheduled) {
- Tcl_CancelIdleCall(MaintainCheckProc, (ClientData) masterPtr);
+ Tcl_CancelIdleCall(MaintainCheckProc, masterPtr);
}
Tcl_DeleteHashEntry(hPtr);
- ckfree((char *) masterPtr);
+ ckfree(masterPtr);
}
}
@@ -573,7 +655,7 @@ MaintainMasterProc(
* master window. */
XEvent *eventPtr) /* Describes what just happened. */
{
- MaintainMaster *masterPtr = (MaintainMaster *) clientData;
+ MaintainMaster *masterPtr = clientData;
MaintainSlave *slavePtr;
int done;
@@ -582,7 +664,7 @@ MaintainMasterProc(
|| (eventPtr->type == UnmapNotify)) {
if (!masterPtr->checkScheduled) {
masterPtr->checkScheduled = 1;
- Tcl_DoWhenIdle(MaintainCheckProc, (ClientData) masterPtr);
+ Tcl_DoWhenIdle(MaintainCheckProc, masterPtr);
}
} else if (eventPtr->type == DestroyNotify) {
/*
@@ -627,7 +709,7 @@ MaintainSlaveProc(
* master-slave pair. */
XEvent *eventPtr) /* Describes what just happened. */
{
- MaintainSlave *slavePtr = (MaintainSlave *) clientData;
+ MaintainSlave *slavePtr = clientData;
if (eventPtr->type == DestroyNotify) {
Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
@@ -659,7 +741,7 @@ MaintainCheckProc(
ClientData clientData) /* Pointer to MaintainMaster structure for the
* master window. */
{
- MaintainMaster *masterPtr = (MaintainMaster *) clientData;
+ MaintainMaster *masterPtr = clientData;
MaintainSlave *slavePtr;
Tk_Window ancestor, parent;
int x, y, map;