Blame lib/Xm/GMUtils.c

Packit b099d7
/* 
Packit b099d7
 * Motif
Packit b099d7
 *
Packit b099d7
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are free software; you can
Packit b099d7
 * redistribute them and/or modify them under the terms of the GNU
Packit b099d7
 * Lesser General Public License as published by the Free Software
Packit b099d7
 * Foundation; either version 2 of the License, or (at your option)
Packit b099d7
 * any later version.
Packit b099d7
 *
Packit b099d7
 * These libraries and programs are distributed in the hope that
Packit b099d7
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
Packit b099d7
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Packit b099d7
 * PURPOSE. See the GNU Lesser General Public License for more
Packit b099d7
 * details.
Packit b099d7
 *
Packit b099d7
 * You should have received a copy of the GNU Lesser General Public
Packit b099d7
 * License along with these librararies and programs; if not, write
Packit b099d7
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
Packit b099d7
 * Floor, Boston, MA 02110-1301 USA
Packit b099d7
*/ 
Packit b099d7
/* 
Packit b099d7
 * HISTORY
Packit b099d7
*/ 
Packit b099d7
#ifdef REV_INFO
Packit b099d7
#ifndef lint
Packit b099d7
static char rcsid[] = "$XConsortium: GMUtils.c /main/11 1995/09/19 23:03:32 cde-sun $"
Packit b099d7
#endif
Packit b099d7
#endif
Packit b099d7
/* (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
Packit b099d7
/* (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
Packit b099d7
Packit b099d7
#ifdef HAVE_CONFIG_H
Packit b099d7
#include <config.h>
Packit b099d7
#endif
Packit b099d7
Packit b099d7
Packit b099d7
/*******************************************************************
Packit b099d7
 * This file contains the common geometry management set of routines
Packit b099d7
 * for both pure BulletinBoard (not subclasses) and DrawingArea.
Packit b099d7
 ****************/
Packit b099d7
Packit b099d7
Packit b099d7
#include "XmI.h"
Packit b099d7
#include "GMUtilsI.h"
Packit b099d7
#include <Xm/ManagerP.h>
Packit b099d7
Packit b099d7
Packit b099d7
/********    Static Function Declarations    ********/
Packit b099d7
Packit b099d7
Packit b099d7
/********    End Static Function Declarations    ********/
Packit b099d7
Packit b099d7
Packit b099d7
/*******************************************************************
Packit b099d7
 * Figure out how much size we need. Shrink wrap around the children.
Packit b099d7
 ****************/
Packit b099d7
void 
Packit b099d7
_XmGMCalcSize(XmManagerWidget manager,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
            int margin_width,
Packit b099d7
            int margin_height,        
Packit b099d7
#else
Packit b099d7
            Dimension margin_width,
Packit b099d7
            Dimension margin_height,        
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
            Dimension *replyWidth,
Packit b099d7
            Dimension *replyHeight )
Packit b099d7
{
Packit b099d7
    register int i ;
Packit b099d7
    register Widget child ;   
Packit b099d7
    int right, bottom ;
Packit b099d7
Packit b099d7
    *replyWidth = *replyHeight = 0 ;
Packit b099d7
Packit b099d7
    for (i = 0; i < manager->composite.num_children; i++) {
Packit b099d7
        child = manager->composite.children[i];
Packit b099d7
        if (XtIsManaged (child)) {
Packit b099d7
          right = XtX(child) + 2*XtBorderWidth(child) + XtWidth(child) ;
Packit b099d7
            bottom = XtY(child) + 2*XtBorderWidth(child) + XtHeight(child) ;
Packit b099d7
Packit b099d7
          if (right > (int) *replyWidth) *replyWidth = right ;
Packit b099d7
          if (bottom > (int) *replyHeight) *replyHeight = bottom ;
Packit b099d7
      }
Packit b099d7
    }
Packit b099d7
Packit b099d7
    *replyWidth += margin_width + MGR_ShadowThickness(manager);
Packit b099d7
    *replyHeight += margin_height + MGR_ShadowThickness(manager);
Packit b099d7
Packit b099d7
    if (!(*replyWidth)) *replyWidth = 10;
Packit b099d7
    if (!(*replyHeight)) *replyHeight = 10;
Packit b099d7
}
Packit b099d7
Packit b099d7
Packit b099d7
/****************************************************************
Packit b099d7
 * Calculate the size needed for the Manager
Packit b099d7
 * Request a change in size from parent if needed.
Packit b099d7
 ****************/
Packit b099d7
Boolean 
Packit b099d7
_XmGMDoLayout(XmManagerWidget manager,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
            int margin_width,
Packit b099d7
            int margin_height,        
Packit b099d7
#else
Packit b099d7
            Dimension margin_width,
Packit b099d7
            Dimension margin_height,        
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
            int resize_policy,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
            int queryonly
Packit b099d7
#else
Packit b099d7
            Boolean queryonly
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
)
Packit b099d7
{
Packit b099d7
    /* return:
Packit b099d7
         True means that the layout is accepted, either with no request
Packit b099d7
       to the parent, or with a successfull serie of requests. 
Packit b099d7
       No means that the layout is denied, without request (NONE
Packit b099d7
       policy for instance) or with request (parent does not accept the
Packit b099d7
       change in size or proposes something unacceptable).
Packit b099d7
       Note that when the parent returns almost, since this function returns
Packit b099d7
       either true or false (see below), we don't handle almost reply 
Packit b099d7
       to the instigator. 
Packit b099d7
       The queryonly flag just controls the "reality" of the parent request
Packit b099d7
       and the call to resize.
Packit b099d7
    */
Packit b099d7
Packit b099d7
    XtWidgetGeometry request ;
Packit b099d7
    XtWidgetGeometry reply ;
Packit b099d7
    XtWidgetProc resize;
Packit b099d7
Packit b099d7
Packit b099d7
    request.request_mode = CWWidth|CWHeight ;
Packit b099d7
    if (queryonly) request.request_mode |= XtCWQueryOnly ;
Packit b099d7
Packit b099d7
    _XmGMCalcSize(manager, margin_width, margin_height, 
Packit b099d7
                &request.width, &request.height);
Packit b099d7
    
Packit b099d7
    /* no change, just accept it */
Packit b099d7
    if ((XtWidth(manager) == request.width) && 
Packit b099d7
      (XtHeight(manager) == request.height)) 
Packit b099d7
      return (True);   
Packit b099d7
Packit b099d7
    /* the current manager sizes are bigger than the new ones and
Packit b099d7
       we don't want to strink, just accept the layout as is, since
Packit b099d7
       it already fits */
Packit b099d7
    if ((resize_policy == XmRESIZE_GROW ||
Packit b099d7
       resize_policy == XmRESIZE_NONE) &&
Packit b099d7
      ((XtWidth(manager) >= request.width) && 
Packit b099d7
       (XtHeight(manager) >= request.height)) )
Packit b099d7
      return (True);
Packit b099d7
Packit b099d7
    /* the previous test passes over, so one of the needed sizes must be 
Packit b099d7
       bigger than one of the current, and we can't do that with NONE */
Packit b099d7
    if (resize_policy == XmRESIZE_NONE )
Packit b099d7
      return (False);
Packit b099d7
Packit b099d7
    /* we can't shrink on one side while growing on the other, just
Packit b099d7
       overwrite the shrinking side */
Packit b099d7
    if(resize_policy == XmRESIZE_GROW    ) {   
Packit b099d7
      if(request.width < XtWidth(manager)) 
Packit b099d7
          request.width = XtWidth(manager) ;
Packit b099d7
        if(request.height < XtHeight(manager)) 
Packit b099d7
          request.height = XtHeight(manager) ;
Packit b099d7
    } 
Packit b099d7
Packit b099d7
    _XmProcessLock();
Packit b099d7
    resize = XtCoreProc(manager,resize);
Packit b099d7
    _XmProcessUnlock();
Packit b099d7
    
Packit b099d7
    /* now the request */
Packit b099d7
    switch(XtMakeGeometryRequest((Widget)manager, 
Packit b099d7
                               &request,
Packit b099d7
                               &reply)) {
Packit b099d7
    case XtGeometryYes:
Packit b099d7
      if (!queryonly) 
Packit b099d7
             /* call the resize proc, since the widget set has now
Packit b099d7
                a Yes policy */
Packit b099d7
          (*resize)((Widget)manager) ;
Packit b099d7
      return(True) ;
Packit b099d7
    case XtGeometryAlmost:  
Packit b099d7
         /* The following behavior is based on the shrink wrapper
Packit b099d7
            behavior of this manager. What we have asked is the minimum.
Packit b099d7
            If the almost returned size is smaller than the 
Packit b099d7
            requested one, refuse, since it will always clip something */
Packit b099d7
      if ((reply.width < request.width) || 
Packit b099d7
          (reply.height < request.height)) {   
Packit b099d7
          return( False) ;
Packit b099d7
      } else {
Packit b099d7
         /* if almost returned a bigger size than requested, 
Packit b099d7
            accept it since it cannot hurt the shrink wrap behavior,
Packit b099d7
            neither the Grow policy (requested always > current).
Packit b099d7
            Apply it if not queryonly. If queryonly, we don't 
Packit b099d7
            have to re-request something, since no change is needed 
Packit b099d7
            and we already know it's OK */
Packit b099d7
          if (!queryonly) {
Packit b099d7
              (void) XtMakeResizeRequest((Widget)manager, 
Packit b099d7
                                        reply.width, 
Packit b099d7
                                        reply.height, 
Packit b099d7
                                        NULL, NULL) ;
Packit b099d7
              (*resize)((Widget)manager) ;
Packit b099d7
          }
Packit b099d7
          return(True) ;
Packit b099d7
      }
Packit b099d7
    case XtGeometryNo:
Packit b099d7
    default:
Packit b099d7
      break ;
Packit b099d7
    }
Packit b099d7
    return( False) ;
Packit b099d7
}
Packit b099d7
Packit b099d7
/* Enforce margins for children if margins are non-zero */
Packit b099d7
void 
Packit b099d7
_XmGMEnforceMargin(XmManagerWidget manager,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
                 int margin_width,
Packit b099d7
                 int margin_height, 
Packit b099d7
                 int setvalue
Packit b099d7
#else
Packit b099d7
                 Dimension margin_width,
Packit b099d7
                 Dimension margin_height,        
Packit b099d7
                 Boolean setvalue
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
)
Packit b099d7
{
Packit b099d7
    int i ;
Packit b099d7
    register Widget child ;
Packit b099d7
    register Boolean do_move ;
Packit b099d7
    Position newx, newy ;
Packit b099d7
           
Packit b099d7
    for(i = 0 ; i < manager->composite.num_children ; i++) {   
Packit b099d7
        do_move = False ;
Packit b099d7
        child = (Widget) manager->composite.children[i] ;
Packit b099d7
        if(XtIsManaged (child)) {   
Packit b099d7
            if ((margin_width != 0) && 
Packit b099d7
              (XtX(child) < (int) margin_width )) {   
Packit b099d7
              do_move = True ;
Packit b099d7
              newx = margin_width ;
Packit b099d7
          } else 
Packit b099d7
              newx = XtX(child) ;
Packit b099d7
          if ((margin_height != 0) && 
Packit b099d7
              (XtY(child) < (int) margin_height )) {   
Packit b099d7
              do_move = True ;
Packit b099d7
                newy = margin_height  ;
Packit b099d7
          } else
Packit b099d7
              newy = XtY(child) ;
Packit b099d7
          if(do_move) {
Packit b099d7
              if (setvalue) {
Packit b099d7
                  Arg args[2] ;
Packit b099d7
                  XtSetArg(args[0], XmNx, newx); 
Packit b099d7
                  XtSetArg(args[1], XmNy, newy);
Packit b099d7
                  XtSetValues(child, args, 2);
Packit b099d7
              } else
Packit b099d7
              XmeConfigureObject(child, newx, newy,
Packit b099d7
				 child->core.width, child->core.height,
Packit b099d7
				 child->core.border_width);
Packit b099d7
          }
Packit b099d7
        }
Packit b099d7
    }
Packit b099d7
}
Packit b099d7
             
Packit b099d7
Packit b099d7
/****************************************************************
Packit b099d7
 * Handle query geometry requests for both BB and DA.
Packit b099d7
 ****************/
Packit b099d7
XtGeometryResult
Packit b099d7
_XmGMHandleQueryGeometry(Widget widget,
Packit b099d7
                       XtWidgetGeometry * intended,
Packit b099d7
                       XtWidgetGeometry * desired,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
                       int margin_width,
Packit b099d7
                       int margin_height,        
Packit b099d7
#else
Packit b099d7
                       Dimension margin_width,
Packit b099d7
                       Dimension margin_height,    
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
                       int resize_policy)
Packit b099d7
{
Packit b099d7
    Dimension width, height ;
Packit b099d7
    
Packit b099d7
    /* first determine what is the desired size, using the resize_policy. */
Packit b099d7
    if (resize_policy == XmRESIZE_NONE) {
Packit b099d7
	desired->width = XtWidth(widget) ;
Packit b099d7
	desired->height = XtHeight(widget) ;
Packit b099d7
    } else {
Packit b099d7
	if (GMode( intended) & CWWidth) width = intended->width;
Packit b099d7
	if (GMode( intended) & CWHeight) height = intended->height;
Packit b099d7
	
Packit b099d7
	_XmGMCalcSize ((XmManagerWidget)widget, 
Packit b099d7
		       margin_width, margin_height, &width, &height);
Packit b099d7
	if ((resize_policy == XmRESIZE_GROW) &&
Packit b099d7
	    ((width < XtWidth(widget)) ||
Packit b099d7
	     (height < XtHeight(widget)))) {
Packit b099d7
	    desired->width = XtWidth(widget) ;
Packit b099d7
	    desired->height = XtHeight(widget) ;
Packit b099d7
	} else {
Packit b099d7
	    desired->width = width ;
Packit b099d7
	    desired->height = height ;
Packit b099d7
	}
Packit b099d7
    }
Packit b099d7
    
Packit b099d7
    /* deal with user initial size setting */
Packit b099d7
    if (!XtIsRealized(widget))  {
Packit b099d7
	if (XtWidth(widget) != 0) desired->width = XtWidth(widget) ;
Packit b099d7
	if (XtHeight(widget) != 0) desired->height = XtHeight(widget) ;
Packit b099d7
    }	    
Packit b099d7
Packit b099d7
    return XmeReplyToQueryGeometry(widget, intended, desired) ;
Packit b099d7
}
Packit b099d7
Packit b099d7
Packit b099d7
/****************************************************************
Packit b099d7
 *
Packit b099d7
 * XmeReplyToQueryGeometry.
Packit b099d7
 *
Packit b099d7
 * This is the generic handling of Almost, No and Yes replies
Packit b099d7
 * based on the intended values and the given desirs.
Packit b099d7
 *
Packit b099d7
 * This can be used by any widget that really only care about is
Packit b099d7
 * width and height dimension. It just has to compute its desired size
Packit b099d7
 * using its own private layout routine and resources before calling
Packit b099d7
 * this one that will deal with the Xt reply value cuisine.
Packit b099d7
 *
Packit b099d7
 ****************/
Packit b099d7
XtGeometryResult
Packit b099d7
XmeReplyToQueryGeometry(Widget widget,
Packit b099d7
			XtWidgetGeometry * intended,
Packit b099d7
			XtWidgetGeometry * desired)
Packit b099d7
{
Packit b099d7
    _XmWidgetToAppContext(widget);
Packit b099d7
    /* the caller should have set desired width and height*/
Packit b099d7
    desired->request_mode = (CWWidth | CWHeight) ;
Packit b099d7
Packit b099d7
    /* Accept any x, y, border and stacking. If the proposed
Packit b099d7
       geometry matches the desired one, and the parent intends
Packit b099d7
       to use these values (flags are set in intended),
Packit b099d7
       return Yes. Otherwise, the parent intends to use values for
Packit b099d7
       width and height that differ from the desired size, return No
Packit b099d7
       if the desired is the current and Almost if the desired size
Packit b099d7
       is different from the current size */
Packit b099d7
    if ((IsWidth(intended)) &&
Packit b099d7
      (intended->width == desired->width) &&
Packit b099d7
      (IsHeight(intended)) &&
Packit b099d7
      (intended->height == desired->height)) {
Packit b099d7
      return XtGeometryYes ;
Packit b099d7
    }
Packit b099d7
    
Packit b099d7
    _XmAppLock(app);
Packit b099d7
    if ((desired->width == XtWidth(widget)) &&
Packit b099d7
      (desired->height == XtHeight(widget))) {
Packit b099d7
      _XmAppUnlock(app);
Packit b099d7
      return XtGeometryNo ;
Packit b099d7
    }
Packit b099d7
Packit b099d7
    _XmAppUnlock(app);
Packit b099d7
    return XtGeometryAlmost ;
Packit b099d7
}
Packit b099d7
Packit b099d7
Packit b099d7
/****************
Packit b099d7
 * Return True if w intersects with any other siblins.
Packit b099d7
 ****************/
Packit b099d7
Boolean
Packit b099d7
_XmGMOverlap(XmManagerWidget manager,
Packit b099d7
           Widget w)
Packit b099d7
{   
Packit b099d7
    register int      i ;
Packit b099d7
    Position  left1 = XtX(w) ;
Packit b099d7
    Position  top1 = XtY(w) ;
Packit b099d7
    Dimension right1 = XtX(w) + 2*XtBorderWidth(w) + XtWidth(w) ;
Packit b099d7
    Dimension bottom1 = XtY(w) + 2*XtBorderWidth(w) + XtHeight(w);
Packit b099d7
Packit b099d7
/****************/
Packit b099d7
    for(i=0 ; i<manager->composite.num_children ; i++) {   
Packit b099d7
      Widget          kid = manager->composite.children[i] ;
Packit b099d7
      Position        left2 = XtX(kid) ;
Packit b099d7
      Position        top2 = XtY(kid) ;
Packit b099d7
      Dimension       right2 = XtX(kid) + 2*XtBorderWidth(kid) + 
Packit b099d7
                               XtWidth(kid);
Packit b099d7
      Dimension       bottom2 = XtY(kid) + 2*XtBorderWidth(kid) + 
Packit b099d7
                                XtHeight(kid) ;
Packit b099d7
        if(w != kid && 
Packit b099d7
         (((left1 >= left2) && ((Dimension)left1 <= right2)) ||
Packit b099d7
          ((left2 >= left1) && ((Dimension)left2 <= right1))) &&
Packit b099d7
         (((top1 >= top2) && ((Dimension)top1 <= bottom2)) ||
Packit b099d7
          ((top2 >= top1) && ((Dimension)top2 <= bottom1)))    )
Packit b099d7
          {   return( True) ;
Packit b099d7
            } 
Packit b099d7
    }
Packit b099d7
    return( False) ;
Packit b099d7
}
Packit b099d7
Packit b099d7
Packit b099d7
/****************
Packit b099d7
 * Handle geometry requests from children.
Packit b099d7
 ****************/
Packit b099d7
XtGeometryResult
Packit b099d7
_XmGMHandleGeometryManager(Widget parent, Widget w,
Packit b099d7
                         XtWidgetGeometry * request,
Packit b099d7
                         XtWidgetGeometry * reply,
Packit b099d7
#if NeedWidePrototypes
Packit b099d7
                         int margin_width,
Packit b099d7
                         int margin_height,        
Packit b099d7
#else
Packit b099d7
                         Dimension margin_width,
Packit b099d7
                         Dimension margin_height,    
Packit b099d7
#endif /* NeedWidePrototypes */
Packit b099d7
                         int resize_policy,
Packit b099d7
                         int allow_overlap)
Packit b099d7
{
Packit b099d7
Packit b099d7
    /* Policy: Yes
Packit b099d7
         if margin is non null requests inside the margin or negative 
Packit b099d7
       are a priori almosted (or denied if the resizepolicy does not
Packit b099d7
       authorize it).
Packit b099d7
         That's the only case where almost is returned, no management
Packit b099d7
         of a limit position or size is done 
Packit b099d7
    */
Packit b099d7
Packit b099d7
Packit b099d7
    XtWidgetGeometry localReply ;
Packit b099d7
    Dimension width, height, borderWidth ;
Packit b099d7
    Position  x, y ;
Packit b099d7
    XtGeometryResult returnCode = XtGeometryNo ;
Packit b099d7
    Boolean geoFlag = False, queryonly = False ;
Packit b099d7
    XmManagerWidget manager = (XmManagerWidget) parent ;
Packit b099d7
Packit b099d7
    localReply = *request ;
Packit b099d7
    localReply.request_mode = CWX|CWY|CWWidth|CWHeight|CWBorderWidth ;
Packit b099d7
Packit b099d7
    if(!IsX(request)) localReply.x = XtX(w) ;
Packit b099d7
    if(!IsY(request)) localReply.y = XtY(w) ;
Packit b099d7
    if(!IsWidth(request)) localReply.width = XtWidth(w) ;
Packit b099d7
    if(!IsHeight(request)) localReply.height = XtHeight(w) ;
Packit b099d7
    if(!IsBorder(request)) localReply.border_width = XtBorderWidth(w) ;
Packit b099d7
Packit b099d7
    /*  check for x less than margin width
Packit b099d7
    */
Packit b099d7
    if(IsX(request) && (margin_width != 0)
Packit b099d7
       && (request->x < (int)margin_width)) {   
Packit b099d7
        localReply.x = (Position) margin_width ;
Packit b099d7
        returnCode = XtGeometryAlmost ;
Packit b099d7
    }
Packit b099d7
    /*  check for y less than margin height  */
Packit b099d7
    if(IsY(request) && (margin_height != 0)
Packit b099d7
       && (request->y < (int)margin_height)) {   
Packit b099d7
        localReply.y = (Position) margin_height ;
Packit b099d7
        returnCode = XtGeometryAlmost ;
Packit b099d7
    }
Packit b099d7
Packit b099d7
    /* Save current size and set to new size
Packit b099d7
    */
Packit b099d7
    x = XtX(w) ;
Packit b099d7
    y = XtY(w) ;
Packit b099d7
    width = XtWidth(w) ;
Packit b099d7
    height = XtHeight(w) ;
Packit b099d7
    borderWidth = XtBorderWidth(w) ;
Packit b099d7
Packit b099d7
    XtX(w) = localReply.x ;
Packit b099d7
    XtY(w) = localReply.y ;
Packit b099d7
    XtWidth(w) = localReply.width ;
Packit b099d7
    XtHeight(w) = localReply.height ;
Packit b099d7
    XtBorderWidth(w) = localReply.border_width ;
Packit b099d7
Packit b099d7
    if(!allow_overlap && _XmGMOverlap (manager, w)) {   
Packit b099d7
        returnCode = XtGeometryNo ;
Packit b099d7
    } else  {   
Packit b099d7
      /* if we already know that we are not gonna change anything */
Packit b099d7
      if ((returnCode == XtGeometryAlmost) || IsQueryOnly(request)) 
Packit b099d7
          queryonly = True ;
Packit b099d7
Packit b099d7
      /* see if the new layout is OK */
Packit b099d7
      geoFlag = _XmGMDoLayout(manager, 
Packit b099d7
                              margin_width, margin_height, 
Packit b099d7
                              resize_policy, queryonly) ;
Packit b099d7
      /* if we cannot adapt the new size but the child is still inside
Packit b099d7
	 go for it */
Packit b099d7
      if(!geoFlag && ((localReply.x + localReply.width +
Packit b099d7
		       (localReply.border_width << 1))
Packit b099d7
		      <= (XtWidth(manager) - margin_width))
Packit b099d7
	 && ((localReply.y + localReply.height +
Packit b099d7
	      (localReply.border_width << 1))
Packit b099d7
	     <= (XtHeight(manager) - margin_height)))
Packit b099d7
	  geoFlag = True ;
Packit b099d7
Packit b099d7
      if (geoFlag) {
Packit b099d7
          if (returnCode != XtGeometryAlmost)
Packit b099d7
              returnCode = XtGeometryYes ;
Packit b099d7
        } else
Packit b099d7
          returnCode = XtGeometryNo ;
Packit b099d7
            
Packit b099d7
      if  (returnCode == XtGeometryAlmost){
Packit b099d7
          if (reply) *reply = localReply ;
Packit b099d7
          else returnCode = XtGeometryNo ;
Packit b099d7
            } 
Packit b099d7
    }
Packit b099d7
Packit b099d7
    if ((returnCode != XtGeometryYes) || queryonly) {   
Packit b099d7
	/* Can't oblige, so restore previous values. */
Packit b099d7
	XtX(w) = x ;
Packit b099d7
	XtY(w) = y ;
Packit b099d7
	XtWidth(w) = width ;
Packit b099d7
	XtHeight(w) = height ;
Packit b099d7
	XtBorderWidth(w) = borderWidth ;
Packit b099d7
      } 
Packit b099d7
Packit b099d7
    return returnCode ;
Packit b099d7
}