summaryrefslogtreecommitdiffstats
path: root/generic/tkGeometry.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGeometry.c')
-rw-r--r--generic/tkGeometry.c342
1 files changed, 173 insertions, 169 deletions
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index d53b6dd..4c8e4f8 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -1,23 +1,22 @@
-/*
+/*
* tkGeometry.c --
*
- * This file contains generic Tk code for geometry management
- * (stuff that's used by all geometry managers).
+ * This file contains generic Tk code for geometry management (stuff
+ * that's used by all geometry managers).
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tkPort.h"
#include "tkInt.h"
/*
- * Data structures of the following type are used by Tk_MaintainGeometry.
- * For each slave managed by Tk_MaintainGeometry, there is one of these
- * structures associated with its master.
+ * Data structures of the following type are used by Tk_MaintainGeometry. For
+ * each slave managed by Tk_MaintainGeometry, there is one of these structures
+ * associated with its master.
*/
typedef struct MaintainSlave {
@@ -29,68 +28,67 @@ typedef struct MaintainSlave {
* master. */
int width, height; /* Desired dimensions of slave. */
struct MaintainSlave *nextPtr;
- /* Next in list of Maintains associated
- * with master. */
+ /* Next in list of Maintains associated with
+ * master. */
} MaintainSlave;
/*
- * For each window that has been specified as a master to
- * Tk_MaintainGeometry, there is a structure of the following type:
+ * For each window that has been specified as a master to Tk_MaintainGeometry,
+ * there is a structure of the following type:
*/
typedef struct MaintainMaster {
- Tk_Window ancestor; /* The lowest ancestor of this window
- * for which we have *not* created a
- * StructureNotify handler. May be the
- * same as the window itself. */
- int checkScheduled; /* Non-zero means that there is already a
- * call to MaintainCheckProc scheduled as
- * an idle handler. */
- MaintainSlave *slavePtr; /* First in list of all slaves associated
- * with this master. */
+ Tk_Window ancestor; /* The lowest ancestor of this window for
+ * which we have *not* created a
+ * StructureNotify handler. May be the same as
+ * the window itself. */
+ int checkScheduled; /* Non-zero means that there is already a call
+ * to MaintainCheckProc scheduled as an idle
+ * handler. */
+ MaintainSlave *slavePtr; /* First in list of all slaves associated with
+ * this master. */
} MaintainMaster;
/*
* Prototypes for static procedures in this file:
*/
-static void MaintainCheckProc _ANSI_ARGS_((ClientData clientData));
-static void MaintainMasterProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void MaintainSlaveProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
+static void MaintainCheckProc(ClientData clientData);
+static void MaintainMasterProc(ClientData clientData,
+ XEvent *eventPtr);
+static void MaintainSlaveProc(ClientData clientData,
+ XEvent *eventPtr);
/*
*--------------------------------------------------------------
*
* Tk_ManageGeometry --
*
- * Arrange for a particular procedure to manage the geometry
- * of a given slave window.
+ * Arrange for a particular procedure to manage the geometry of a given
+ * slave window.
*
* Results:
* None.
*
* Side effects:
- * Proc becomes the new geometry manager for tkwin, replacing
- * any previous geometry manager. The geometry manager will
- * be notified (by calling procedures in *mgrPtr) when interesting
- * things happen in the future. If there was an existing geometry
- * manager for tkwin different from the new one, it is notified
- * by calling its lostSlaveProc.
+ * Proc becomes the new geometry manager for tkwin, replacing any
+ * previous geometry manager. The geometry manager will be notified (by
+ * calling procedures in *mgrPtr) when interesting things happen in the
+ * future. If there was an existing geometry manager for tkwin different
+ * from the new one, it is notified by calling its lostSlaveProc.
*
*--------------------------------------------------------------
*/
void
-Tk_ManageGeometry(tkwin, mgrPtr, clientData)
- Tk_Window tkwin; /* Window whose geometry is to
- * be managed by proc. */
- Tk_GeomMgr *mgrPtr; /* Static structure describing the
- * geometry manager. This structure
- * must never go away. */
- ClientData clientData; /* Arbitrary one-word argument to
- * pass to geometry manager procedures. */
+Tk_ManageGeometry(
+ Tk_Window tkwin, /* Window whose geometry is to be managed by
+ * proc. */
+ 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
+ * geometry manager procedures. */
{
register TkWindow *winPtr = (TkWindow *) tkwin;
@@ -110,37 +108,35 @@ Tk_ManageGeometry(tkwin, mgrPtr, clientData)
*
* Tk_GeometryRequest --
*
- * This procedure is invoked by widget code to indicate
- * its preferences about the size of a window it manages.
- * In general, widget code should call this procedure
- * rather than Tk_ResizeWindow.
+ * This procedure is invoked by widget code to indicate its preferences
+ * about the size of a window it manages. In general, widget code should
+ * call this procedure rather than Tk_ResizeWindow.
*
* Results:
* None.
*
* Side effects:
- * The geometry manager for tkwin (if any) is invoked to
- * handle the request. If possible, it will reconfigure
- * tkwin and/or other windows to satisfy the request. The
- * caller gets no indication of success or failure, but it
- * will get X events if the window size was actually
+ * The geometry manager for tkwin (if any) is invoked to handle the
+ * request. If possible, it will reconfigure tkwin and/or other windows
+ * to satisfy the request. The caller gets no indication of success or
+ * failure, but it will get X events if the window size was actually
* changed.
*
*--------------------------------------------------------------
*/
void
-Tk_GeometryRequest(tkwin, reqWidth, reqHeight)
- Tk_Window tkwin; /* Window that geometry information
- * pertains to. */
- int reqWidth, reqHeight; /* Minimum desired dimensions for
- * window, in pixels. */
+Tk_GeometryRequest(
+ Tk_Window tkwin, /* Window that geometry information pertains
+ * to. */
+ int reqWidth, int reqHeight)/* Minimum desired dimensions for window, in
+ * pixels. */
{
register TkWindow *winPtr = (TkWindow *) tkwin;
/*
- * X gets very upset if a window requests a width or height of
- * zero, so rounds requested sizes up to at least 1.
+ * X gets very upset if a window requests a width or height of zero, so
+ * rounds requested sizes up to at least 1.
*/
if (reqWidth <= 0) {
@@ -165,9 +161,9 @@ Tk_GeometryRequest(tkwin, reqWidth, reqHeight)
*
* Tk_SetInternalBorderEx --
*
- * Notify relevant geometry managers that a window has an internal
- * border of a given width and that child windows should not be
- * placed on that border.
+ * Notify relevant geometry managers that a window has an internal border
+ * of a given width and that child windows should not be placed on that
+ * border.
*
* Results:
* None.
@@ -181,10 +177,10 @@ Tk_GeometryRequest(tkwin, reqWidth, reqHeight)
*/
void
-Tk_SetInternalBorderEx(tkwin, left, right, top, bottom)
- Tk_Window tkwin; /* Window that will have internal border. */
- int left, right; /* Width of internal border, in pixels. */
- int top, bottom;
+Tk_SetInternalBorderEx(
+ Tk_Window tkwin, /* Window that will have internal border. */
+ int left, int right, /* Width of internal border, in pixels. */
+ int top, int bottom)
{
register TkWindow *winPtr = (TkWindow *) tkwin;
register int changed = 0;
@@ -223,40 +219,40 @@ Tk_SetInternalBorderEx(tkwin, left, right, top, bottom)
/*
* All the slaves for which this is the master window must now be
- * repositioned to take account of the new internal border width.
- * To signal all the geometry managers to do this, just resize the
- * window to its current size. The ConfigureNotify event will
- * cause geometry managers to recompute everything.
+ * repositioned to take account of the new internal border width. To
+ * signal all the geometry managers to do this, just resize the window to
+ * its current size. The ConfigureNotify event will cause geometry
+ * managers to recompute everything.
*/
if (changed) {
Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin));
}
}
+
/*
*----------------------------------------------------------------------
*
* Tk_SetInternalBorder --
*
- * Notify relevant geometry managers that a window has an internal
- * border of a given width and that child windows should not be
- * placed on that border.
+ * Notify relevant geometry managers that a window has an internal border
+ * of a given width and that child windows should not be placed on that
+ * border.
*
* Results:
* None.
*
* Side effects:
- * The border width is recorded for the window, and all geometry
- * managers of all children are notified so that can re-layout, if
- * necessary.
+ * The border width is recorded for the window, and all geometry managers
+ * of all children are notified so that can re-layout, if necessary.
*
*----------------------------------------------------------------------
*/
void
-Tk_SetInternalBorder(tkwin, width)
- Tk_Window tkwin; /* Window that will have internal border. */
- int width; /* Width of internal border, in pixels. */
+Tk_SetInternalBorder(
+ Tk_Window tkwin, /* Window that will have internal border. */
+ int width) /* Width of internal border, in pixels. */
{
Tk_SetInternalBorderEx(tkwin, width, width, width, width);
}
@@ -266,23 +262,23 @@ Tk_SetInternalBorder(tkwin, width)
*
* Tk_SetMinimumRequestSize --
*
- * Notify relevant geometry managers that a window has a minimum
- * request size.
+ * Notify relevant geometry managers that a window has a minimum request
+ * size.
*
* Results:
* None.
*
* Side effects:
- * The minimum request size is recorded for the window, and
- * a new size is requested for the window, if necessary.
+ * The minimum request size is recorded for the window, and a new size is
+ * requested for the window, if necessary.
*
*----------------------------------------------------------------------
*/
void
-Tk_SetMinimumRequestSize(tkwin, minWidth, minHeight)
- Tk_Window tkwin; /* Window that will have internal border. */
- int minWidth, minHeight; /* Minimum requested size, in pixels. */
+Tk_SetMinimumRequestSize(
+ Tk_Window tkwin, /* Window that will have internal border. */
+ int minWidth, int minHeight)/* Minimum requested size, in pixels. */
{
register TkWindow *winPtr = (TkWindow *) tkwin;
@@ -295,11 +291,11 @@ Tk_SetMinimumRequestSize(tkwin, minWidth, minHeight)
winPtr->minReqHeight = minHeight;
/*
- * The changed min size may cause geometry managers to get a
- * different result, so make them recompute.
- * To signal all the geometry managers to do this, just resize the
- * window to its current size. The ConfigureNotify event will
- * cause geometry managers to recompute everything.
+ * The changed min size may cause geometry managers to get a different
+ * result, so make them recompute. To signal all the geometry managers to
+ * do this, just resize the window to its current size. The
+ * ConfigureNotify event will cause geometry managers to recompute
+ * everything.
*/
Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin));
@@ -310,40 +306,40 @@ Tk_SetMinimumRequestSize(tkwin, minWidth, minHeight)
*
* Tk_MaintainGeometry --
*
- * This procedure is invoked by geometry managers to handle slaves
- * whose master's are not their parents. It translates the desired
- * geometry for the slave into the coordinate system of the parent
- * and respositions the slave if it isn't already at the right place.
- * Furthermore, it sets up event handlers so that if the master (or
- * any of its ancestors up to the slave's parent) is mapped, unmapped,
- * or moved, then the slave will be adjusted to match.
+ * This procedure is invoked by geometry managers to handle slaves whose
+ * master's are not their parents. It translates the desired geometry for
+ * the slave into the coordinate system of the parent and respositions
+ * the slave if it isn't already at the right place. Furthermore, it sets
+ * up event handlers so that if the master (or any of its ancestors up to
+ * the slave's parent) is mapped, unmapped, or moved, then the slave will
+ * be adjusted to match.
*
* Results:
* None.
*
* Side effects:
- * Event handlers are created and state is allocated to keep track
- * of slave. Note: if slave was already managed for master by
- * Tk_MaintainGeometry, then the previous information is replaced
- * with the new information. The caller must eventually call
- * Tk_UnmaintainGeometry to eliminate the correspondence (or, the
- * state is automatically freed when either window is destroyed).
+ * Event handlers are created and state is allocated to keep track of
+ * slave. Note: if slave was already managed for master by
+ * Tk_MaintainGeometry, then the previous information is replaced with
+ * the new information. The caller must eventually call
+ * Tk_UnmaintainGeometry to eliminate the correspondence (or, the state
+ * is automatically freed when either window is destroyed).
*
*----------------------------------------------------------------------
*/
void
-Tk_MaintainGeometry(slave, master, x, y, width, height)
- Tk_Window slave; /* Slave for geometry management. */
- Tk_Window master; /* Master for slave; must be a descendant
- * of slave's parent. */
- int x, y; /* Desired position of slave within master. */
- int width, height; /* Desired dimensions for slave. */
+Tk_MaintainGeometry(
+ Tk_Window slave, /* Slave for geometry management. */
+ Tk_Window master, /* Master for slave; must be a descendant of
+ * slave's parent. */
+ int x, int y, /* Desired position of slave within master. */
+ int width, int height) /* Desired dimensions for slave. */
{
Tcl_HashEntry *hPtr;
MaintainMaster *masterPtr;
register MaintainSlave *slavePtr;
- int new, map;
+ int isNew, map;
Tk_Window ancestor, parent;
TkDisplay *dispPtr = ((TkWindow *) master)->dispPtr;
@@ -354,6 +350,7 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
* call to Tk_MoveResizeWindow; the parent/child relationship will
* take care of the rest.
*/
+
Tk_MoveResizeWindow(slave, x, y, width, height);
/*
@@ -361,6 +358,7 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
* until the master is mapped later (in which case mapping the slave
* is taken care of elsewhere).
*/
+
if (Tk_IsMapped(master)) {
Tk_MapWindow(slave);
}
@@ -373,14 +371,14 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
}
/*
- * See if there is already a MaintainMaster structure for the master;
- * if not, then create one.
+ * See if there is already a MaintainMaster structure for the master; if
+ * not, then create one.
*/
parent = Tk_Parent(slave);
- hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
- (char *) master, &new);
- if (!new) {
+ hPtr = Tcl_CreateHashEntry(&dispPtr->maintainHashTable,
+ (char *) master, &isNew);
+ if (!isNew) {
masterPtr = (MaintainMaster *) Tcl_GetHashValue(hPtr);
} else {
masterPtr = (MaintainMaster *) ckalloc(sizeof(MaintainMaster));
@@ -391,8 +389,8 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
}
/*
- * Create a MaintainSlave structure for the slave if there isn't
- * already one.
+ * Create a MaintainSlave structure for the slave if there isn't already
+ * one.
*/
for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
@@ -410,10 +408,10 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
(ClientData) slavePtr);
/*
- * Make sure that there are event handlers registered for all
- * the windows between master and slave's parent (including master
- * but not slave's parent). There may already be handlers for master
- * and some of its ancestors (masterPtr->ancestor tells how many).
+ * Make sure that there are event handlers registered for all the windows
+ * between master and slave's parent (including master but not slave's
+ * parent). There may already be handlers for master and some of its
+ * ancestors (masterPtr->ancestor tells how many).
*/
for (ancestor = master; ancestor != parent;
@@ -426,11 +424,11 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
}
/*
- * Fill in up-to-date information in the structure, then update the
- * window if it's not currently in the right place or state.
+ * Fill in up-to-date information in the structure, then update the window
+ * if it's not currently in the right place or state.
*/
- gotSlave:
+ gotSlave:
slavePtr->x = x;
slavePtr->y = y;
slavePtr->width = width;
@@ -464,26 +462,25 @@ Tk_MaintainGeometry(slave, master, x, y, width, height)
*
* Tk_UnmaintainGeometry --
*
- * This procedure cancels a previous Tk_MaintainGeometry call,
- * so that the relationship between slave and master is no longer
- * maintained.
+ * This procedure cancels a previous Tk_MaintainGeometry call, so that
+ * the relationship between slave and master is no longer maintained.
*
* Results:
* None.
*
* Side effects:
- * The slave is unmapped and state is released, so that slave won't
- * track master any more. If we weren't previously managing slave
- * relative to master, then this procedure has no effect.
+ * The slave is unmapped and state is released, so that slave won't track
+ * master any more. If we weren't previously managing slave relative to
+ * master, then this procedure has no effect.
*
*----------------------------------------------------------------------
*/
void
-Tk_UnmaintainGeometry(slave, master)
- Tk_Window slave; /* Slave for geometry management. */
- Tk_Window master; /* Master for slave; must be a descendant
- * of slave's parent. */
+Tk_UnmaintainGeometry(
+ Tk_Window slave, /* Slave for geometry management. */
+ Tk_Window master) /* Master for slave; must be a descendant of
+ * slave's parent. */
{
Tcl_HashEntry *hPtr;
MaintainMaster *masterPtr;
@@ -495,11 +492,11 @@ Tk_UnmaintainGeometry(slave, master)
/*
* If the slave is a direct descendant of the master,
* Tk_MaintainGeometry will not have set up any of the extra
- * infrastructure. Don't even bother to look for it, just return.
+ * infrastructure. Don't even bother to look for it, just return.
*/
return;
}
-
+
if (!dispPtr->geomInit) {
dispPtr->geomInit = 1;
Tcl_InitHashTable(&dispPtr->maintainHashTable, TCL_ONE_WORD_KEYS);
@@ -554,27 +551,27 @@ Tk_UnmaintainGeometry(slave, master)
*
* MaintainMasterProc --
*
- * This procedure is invoked by the Tk event dispatcher in
- * response to StructureNotify events on the master or one
- * of its ancestors, on behalf of Tk_MaintainGeometry.
+ * This procedure is invoked by the Tk event dispatcher in response to
+ * StructureNotify events on the master or one of its ancestors, on
+ * behalf of Tk_MaintainGeometry.
*
* Results:
* None.
*
* Side effects:
- * It schedules a call to MaintainCheckProc, which will eventually
- * caused the postions and mapped states to be recalculated for all
- * the maintained slaves of the master. Or, if the master window is
- * being deleted then state is cleaned up.
+ * It schedules a call to MaintainCheckProc, which will eventually caused
+ * the postions and mapped states to be recalculated for all the
+ * maintained slaves of the master. Or, if the master window is being
+ * deleted then state is cleaned up.
*
*----------------------------------------------------------------------
*/
static void
-MaintainMasterProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to MaintainMaster structure
- * for the master window. */
- XEvent *eventPtr; /* Describes what just happened. */
+MaintainMasterProc(
+ ClientData clientData, /* Pointer to MaintainMaster structure for the
+ * master window. */
+ XEvent *eventPtr) /* Describes what just happened. */
{
MaintainMaster *masterPtr = (MaintainMaster *) clientData;
MaintainSlave *slavePtr;
@@ -589,9 +586,9 @@ MaintainMasterProc(clientData, eventPtr)
}
} else if (eventPtr->type == DestroyNotify) {
/*
- * Delete all of the state associated with this master, but
- * be careful not to use masterPtr after the last slave is
- * deleted, since its memory will have been freed.
+ * Delete all of the state associated with this master, but be careful
+ * not to use masterPtr after the last slave is deleted, since its
+ * memory will have been freed.
*/
done = 0;
@@ -610,25 +607,25 @@ MaintainMasterProc(clientData, eventPtr)
*
* MaintainSlaveProc --
*
- * This procedure is invoked by the Tk event dispatcher in
- * response to StructureNotify events on a slave being managed
- * by Tk_MaintainGeometry.
+ * This procedure is invoked by the Tk event dispatcher in response to
+ * StructureNotify events on a slave being managed by
+ * Tk_MaintainGeometry.
*
* Results:
* None.
*
* Side effects:
- * If the event is a DestroyNotify event then the Maintain state
- * and event handlers for this slave are deleted.
+ * If the event is a DestroyNotify event then the Maintain state and
+ * event handlers for this slave are deleted.
*
*----------------------------------------------------------------------
*/
static void
-MaintainSlaveProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to MaintainSlave structure
- * for master-slave pair. */
- XEvent *eventPtr; /* Describes what just happened. */
+MaintainSlaveProc(
+ ClientData clientData, /* Pointer to MaintainSlave structure for
+ * master-slave pair. */
+ XEvent *eventPtr) /* Describes what just happened. */
{
MaintainSlave *slavePtr = (MaintainSlave *) clientData;
@@ -642,12 +639,11 @@ MaintainSlaveProc(clientData, eventPtr)
*
* MaintainCheckProc --
*
- * This procedure is invoked by the Tk event dispatcher as an
- * idle handler, when a master or one of its ancestors has been
- * reconfigured, mapped, or unmapped. Its job is to scan all of
- * the slaves for the master and reposition them, map them, or
- * unmap them as needed to maintain their geometry relative to
- * the master.
+ * This procedure is invoked by the Tk event dispatcher as an idle
+ * handler, when a master or one of its ancestors has been reconfigured,
+ * mapped, or unmapped. Its job is to scan all of the slaves for the
+ * master and reposition them, map them, or unmap them as needed to
+ * maintain their geometry relative to the master.
*
* Results:
* None.
@@ -659,9 +655,9 @@ MaintainSlaveProc(clientData, eventPtr)
*/
static void
-MaintainCheckProc(clientData)
- ClientData clientData; /* Pointer to MaintainMaster structure
- * for the master window. */
+MaintainCheckProc(
+ ClientData clientData) /* Pointer to MaintainMaster structure for the
+ * master window. */
{
MaintainMaster *masterPtr = (MaintainMaster *) clientData;
MaintainSlave *slavePtr;
@@ -696,3 +692,11 @@ MaintainCheckProc(clientData)
}
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */