summaryrefslogtreecommitdiffstats
path: root/generic/tkGeometry.c
diff options
context:
space:
mode:
authorpspjuth <peter.spjuth@gmail.com>2009-08-19 23:01:59 (GMT)
committerpspjuth <peter.spjuth@gmail.com>2009-08-19 23:01:59 (GMT)
commit2b61fda7660e28461b6dfe55f422c70aa390483d (patch)
treea4c7c1cd7c558900a4ca247babd4096d872f1f42 /generic/tkGeometry.c
parentf4cf4a95f73b53ac9c0a6e3c93d9676d2877598e (diff)
downloadtk-2b61fda7660e28461b6dfe55f422c70aa390483d.zip
tk-2b61fda7660e28461b6dfe55f422c70aa390483d.tar.gz
tk-2b61fda7660e28461b6dfe55f422c70aa390483d.tar.bz2
Give an error if grid and pack are used in the same master. [Patch 2475855]
Diffstat (limited to 'generic/tkGeometry.c')
-rw-r--r--generic/tkGeometry.c81
1 files changed, 80 insertions, 1 deletions
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index 53bd140..b5a1654 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkGeometry.c,v 1.14 2008/11/08 18:44:40 dkf Exp $
+ * RCS: @(#) $Id: tkGeometry.c,v 1.15 2009/08/19 23:02:00 pspjuth Exp $
*/
#include "tkInt.h"
@@ -306,6 +306,85 @@ 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_AppendResult(interp, "cannot use geometry manager ", master,
+ " inside ", Tk_PathName(tkwin),
+ " which already has slaves managed by ",
+ winPtr->geometryMaster, 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