/*
* tkGeometry.c --
*
* 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.
*
* SCCS: @(#) tkGeometry.c 1.31 96/02/15 18:53:32
*/
#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.
*/
typedef struct MaintainSlave {
* position; it must be a descendant of
* slave's parent. */
int x, y; /* Desired position of slave relative to
* master. */
/* Next in list of Maintains associated
* with master. */
/*
* For each window that has been specified as a master to
* Tk_MaintainGeometry, there is a structure of the following type:
*/
typedef struct MaintainMaster {
* for which we have *not* created a
* StructureNotify handler. May be the
* same as the window itself. */
* call to MaintainCheckProc scheduled as
* an idle handler. */
* with this master. */
/*
* Hash table that maps from a master's Tk_Window token to a list of
* Maintains for that master:
*/
/*
* Has maintainHashTable been initialized yet?
*/
static int initialized = 0;
/*
* Prototypes for static procedures in this file:
*/
/*
*--------------------------------------------------------------
*
* Tk_ManageGeometry --
*
* 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.
*
*--------------------------------------------------------------
*/
void
* be managed by proc. */
* geometry manager. This structure
* must never go away. */
* pass to geometry manager procedures. */
{
}
}
/*
*--------------------------------------------------------------
*
* 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.
*
* Results:
* None.
*
* Side effects:
* The geometry manager for tkwin (if any) is invoked to
* handle the request. If possible, it will reconfigure
* caller gets no indication of success or failure, but it
* will get X events if the window size was actually
* changed.
*
*--------------------------------------------------------------
*/
void
* pertains to. */
* window, in pixels. */
{
/*
* 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) {
reqWidth = 1;
}
if (reqHeight <= 0) {
reqHeight = 1;
}
return;
}
}
}
/*
*----------------------------------------------------------------------
*
* 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.
*
* 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.
*
*----------------------------------------------------------------------
*/
void
int width; /* Width of internal border, in pixels. */
{
return;
}
if (width < 0) {
width = 0;
}
/*
* 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.
*/
}
/*
*----------------------------------------------------------------------
*
* 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.
*
* 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).
*
*----------------------------------------------------------------------
*/
void
* of slave's parent. */
int x, y; /* Desired position of slave within master. */
{
if (!initialized) {
initialized = 1;
}
/*
* See if there is already a MaintainMaster structure for the master;
* if not, then create one.
*/
if (!new) {
} else {
masterPtr->checkScheduled = 0;
}
/*
* Create a MaintainSlave structure for the slave if there isn't
* already one.
*/
goto gotSlave;
}
}
(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).
*/
}
}
/*
* Fill in up-to-date information in the structure, then update the
* window if it's not currently in the right place or state.
*/
slavePtr->x = x;
slavePtr->y = y;
map = 1;
map = 0;
}
}
if (map) {
} else {
}
break;
}
}
}
/*
*----------------------------------------------------------------------
*
* Tk_UnmaintainGeometry --
*
* 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.
*
*----------------------------------------------------------------------
*/
void
* of slave's parent. */
{
if (!initialized) {
initialized = 1;
}
}
return;
}
} else {
return;
}
break;
}
}
}
break;
}
}
}
if (masterPtr->checkScheduled) {
}
}
}
/*
*----------------------------------------------------------------------
*
* 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.
*
* 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.
*
*----------------------------------------------------------------------
*/
static void
* for the master window. */
{
int done;
if (!masterPtr->checkScheduled) {
}
/*
* 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;
do {
done = 1;
}
} while (!done);
}
}
/*
*----------------------------------------------------------------------
*
* MaintainSlaveProc --
*
* 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.
*
*----------------------------------------------------------------------
*/
static void
* for master-slave pair. */
{
}
}
/*
*----------------------------------------------------------------------
*
* 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.
*
* Results:
* None.
*
* Side effects:
* Slaves can get repositioned, mapped, or unmapped.
*
*----------------------------------------------------------------------
*/
static void
* for the master window. */
{
int x, y, map;
masterPtr->checkScheduled = 0;
x = slavePtr->x;
y = slavePtr->y;
map = 1;
map = 0;
}
}
if (map) {
} else {
}
break;
}
}
}
}