749N/A/* $XConsortium: Paned.c,v 1.27 94/04/17 20:12:28 kaleb Exp $ */
749N/A
749N/A/***********************************************************
749N/A
749N/ACopyright (c) 1987, 1988, 1994 X Consortium
749N/A
749N/APermission is hereby granted, free of charge, to any person obtaining a copy
749N/Aof this software and associated documentation files (the "Software"), to deal
749N/Ain the Software without restriction, including without limitation the rights
749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell
749N/Acopies of the Software, and to permit persons to whom the Software is
749N/Afurnished to do so, subject to the following conditions:
749N/A
749N/AThe above copyright notice and this permission notice shall be included in
749N/Aall copies or substantial portions of the Software.
749N/A
749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
749N/AX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
749N/A
749N/AExcept as contained in this notice, the name of the X Consortium shall not be
749N/Aused in advertising or otherwise to promote the sale, use or other dealings
749N/Ain this Software without prior written authorization from the X Consortium.
749N/A
749N/A
749N/ACopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
749N/A
749N/A All Rights Reserved
749N/A
749N/APermission to use, copy, modify, and distribute this software and its
749N/Adocumentation for any purpose and without fee is hereby granted,
749N/Aprovided that the above copyright notice appear in all copies and that
749N/Aboth that copyright notice and this permission notice appear in
749N/Asupporting documentation, and that the name of Digital not be
749N/Aused in advertising or publicity pertaining to distribution of the
749N/Asoftware without specific, written prior permission.
749N/A
749N/ADIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
749N/AALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
749N/ADIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
749N/AANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
749N/AWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
749N/AARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
749N/ASOFTWARE.
749N/A
749N/A******************************************************************/
749N/A
749N/A/*
749N/A * Paned.c - Paned Composite Widget.
749N/A *
749N/A * Updated and significantly modified from the Athena VPaned Widget.
749N/A *
749N/A * Date: March 1, 1989
749N/A *
749N/A * By: Chris D. Peterson
749N/A * MIT X Consortium
749N/A * kit@expo.lcs.mit.edu
749N/A */
749N/A
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/cursorfont.h>
749N/A#include <X11/StringDefs.h>
749N/A
749N/A#include <X11/Xmu/Misc.h>
749N/A#include <X11/Xmu/Converters.h>
749N/A
749N/A#include <X11/Xaw/XawInit.h>
749N/A#include <X11/Xaw/Grip.h>
749N/A#include <X11/Xaw/PanedP.h>
749N/A
749N/A/* I don't know why Paned.c calls _XawImCallVendorShellExtResize, but... */
749N/A#include <X11/Xaw/XawImP.h>
749N/A
749N/A#include <ctype.h>
749N/A
749N/Atypedef enum {UpLeftPane = 'U', LowRightPane = 'L',
749N/A ThisBorderOnly = 'T', AnyPane = 'A' } Direction;
749N/A
749N/A#define NO_INDEX -100
749N/A#define IS_GRIP NULL
749N/A
749N/A#define PaneInfo(w) ((Pane)(w)->core.constraints)
749N/A#define HasGrip(w) (PaneInfo(w)->grip != NULL)
749N/A#define IsPane(w) ((w)->core.widget_class != gripWidgetClass)
749N/A#define PaneIndex(w) (PaneInfo(w)->position)
749N/A#define IsVert(w) ( (w)->paned.orientation == XtorientVertical )
749N/A
749N/A#define ForAllPanes(pw, childP) \
749N/A for ( (childP) = (pw)->composite.children ; \
749N/A (childP) < (pw)->composite.children + (pw)->paned.num_panes ; \
749N/A (childP)++ )
749N/A
749N/A#define ForAllChildren(pw, childP) \
749N/A for ( (childP) = (pw)->composite.children ; \
749N/A (childP) < (pw)->composite.children + (pw)->composite.num_children ; \
749N/A (childP)++ )
749N/A
749N/A/*****************************************************************************
749N/A *
749N/A * Full instance record declaration
749N/A *
749N/A ****************************************************************************/
749N/A
749N/Astatic char defGripTranslations[] =
749N/A "<Btn1Down>: GripAction(Start, UpLeftPane) \n\
749N/A <Btn2Down>: GripAction(Start, ThisBorderOnly) \n\
749N/A <Btn3Down>: GripAction(Start, LowRightPane) \n\
749N/A <Btn1Motion>: GripAction(Move, UpLeft) \n\
749N/A <Btn2Motion>: GripAction(Move, ThisBorder) \n\
749N/A <Btn3Motion>: GripAction(Move, LowRight) \n\
749N/A Any<BtnUp>: GripAction(Commit)";
749N/A
749N/A#define offset(field) XtOffsetOf(PanedRec, paned.field)
749N/A
749N/Astatic XtResource resources[] = {
749N/A {XtNinternalBorderColor, XtCBorderColor, XtRPixel, sizeof(Pixel),
749N/A offset(internal_bp), XtRString,
749N/A (XtPointer) XtDefaultForeground},
749N/A {XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension),
749N/A offset(internal_bw), XtRImmediate, (XtPointer) 1},
749N/A {XtNgripIndent, XtCGripIndent, XtRPosition, sizeof(Position),
749N/A offset(grip_indent), XtRImmediate, (XtPointer) 10},
749N/A {XtNrefigureMode, XtCBoolean, XtRBoolean, sizeof(Boolean),
749N/A offset(refiguremode), XtRImmediate, (XtPointer) TRUE},
749N/A {XtNgripTranslations, XtCTranslations, XtRTranslationTable,
749N/A sizeof(XtTranslations),
749N/A offset(grip_translations), XtRString, (XtPointer)defGripTranslations},
749N/A {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
749N/A offset(orientation), XtRImmediate, (XtPointer) XtorientVertical},
749N/A
749N/A /* Cursors - both horiz and vertical have to work. */
749N/A
749N/A {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(cursor), XtRImmediate, None},
749N/A {XtNgripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(grip_cursor), XtRImmediate, None},
749N/A {XtNverticalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(v_grip_cursor), XtRString, "sb_v_double_arrow"},
749N/A {XtNhorizontalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(h_grip_cursor), XtRString, "sb_h_double_arrow"},
749N/A
749N/A {XtNbetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(adjust_this_cursor), XtRString, None},
749N/A {XtNverticalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(v_adjust_this_cursor), XtRString, "sb_left_arrow"},
749N/A {XtNhorizontalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(h_adjust_this_cursor), XtRString, "sb_up_arrow"},
749N/A
749N/A {XtNupperCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(adjust_upper_cursor), XtRString, "sb_up_arrow"},
749N/A {XtNlowerCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(adjust_lower_cursor), XtRString, "sb_down_arrow"},
749N/A {XtNleftCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(adjust_left_cursor), XtRString, "sb_left_arrow"},
749N/A {XtNrightCursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(adjust_right_cursor), XtRString, "sb_right_arrow"},
749N/A};
749N/A
749N/A#undef offset
749N/A
749N/A#define offset(field) XtOffsetOf(PanedConstraintsRec, paned.field)
749N/A
749N/Astatic XtResource subresources[] = {
749N/A {XtNallowResize, XtCBoolean, XtRBoolean, sizeof(Boolean),
749N/A offset(allow_resize), XtRImmediate, (XtPointer) FALSE},
749N/A {XtNposition, XtCPosition, XtRInt, sizeof(int),
749N/A offset(position), XtRImmediate, (XtPointer) 0},
749N/A {XtNmin, XtCMin, XtRDimension, sizeof(Dimension),
749N/A offset(min), XtRImmediate, (XtPointer) PANED_GRIP_SIZE},
749N/A {XtNmax, XtCMax, XtRDimension, sizeof(Dimension),
749N/A offset(max), XtRImmediate, (XtPointer) ~0},
749N/A {XtNpreferredPaneSize, XtCPreferredPaneSize, XtRDimension,
749N/A sizeof(Dimension), offset(preferred_size),
749N/A XtRImmediate, (XtPointer) PANED_ASK_CHILD},
749N/A {XtNresizeToPreferred, XtCBoolean, XtRBoolean, sizeof(Boolean),
749N/A offset(resize_to_pref), XtRImmediate, (XtPointer) FALSE},
749N/A {XtNskipAdjust, XtCBoolean, XtRBoolean, sizeof(Boolean),
749N/A offset(skip_adjust), XtRImmediate, (XtPointer) FALSE},
749N/A {XtNshowGrip, XtCShowGrip, XtRBoolean, sizeof(Boolean),
749N/A offset(show_grip), XtRImmediate, (XtPointer) TRUE},
749N/A};
749N/A
749N/A#undef offset
749N/A
749N/Astatic void ClassInitialize(), Initialize();
749N/Astatic void Realize(), Resize();
749N/Astatic void Redisplay();
749N/Astatic void GetGCs(), ReleaseGCs();
749N/Astatic void RefigureLocationsAndCommit();
749N/Astatic Boolean SetValues();
749N/Astatic XtGeometryResult GeometryManager();
749N/Astatic void ChangeManaged();
749N/Astatic void InsertChild();
749N/Astatic void DeleteChild();
749N/Astatic Boolean PaneSetValues();
749N/Astatic Dimension PaneSize(), GetRequestInfo();
749N/Astatic Boolean SatisfiesRule1(), SatisfiesRule2(), SatisfiesRule3();
749N/A
749N/Astatic void PushPaneStack();
749N/Astatic void GetPaneStack();
749N/Astatic Boolean PopPaneStack();
749N/Astatic void ClearPaneStack();
749N/A
749N/A#define SuperClass ((ConstraintWidgetClass)&constraintClassRec)
749N/A
749N/APanedClassRec panedClassRec = {
749N/A {
749N/A/* core class fields */
749N/A /* superclass */ (WidgetClass) SuperClass,
749N/A /* class name */ "Paned",
749N/A /* size */ sizeof(PanedRec),
749N/A /* class_initialize */ ClassInitialize,
749N/A /* class_part init */ NULL,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ Initialize,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ Realize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ resources,
749N/A /* resource_count */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ TRUE,
749N/A /* compress_exposure */ TRUE,
749N/A /* compress_enterleave*/ TRUE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ ReleaseGCs,
749N/A /* resize */ Resize,
749N/A /* expose */ Redisplay,
749N/A /* set_values */ SetValues,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost */ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ NULL,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ NULL,
749N/A /* query_geometry */ XtInheritQueryGeometry,
749N/A /* display_accelerator*/ XtInheritDisplayAccelerator,
749N/A /* extension */ NULL
749N/A }, {
749N/A/* composite class fields */
749N/A /* geometry_manager */ GeometryManager,
749N/A /* change_managed */ ChangeManaged,
749N/A /* insert_child */ InsertChild,
749N/A /* delete_child */ DeleteChild,
749N/A /* extension */ NULL
749N/A }, {
749N/A/* constraint class fields */
749N/A /* subresources */ subresources,
749N/A /* subresource_count */ XtNumber(subresources),
749N/A /* constraint_size */ sizeof(PanedConstraintsRec),
749N/A /* initialize */ NULL,
749N/A /* destroy */ NULL,
749N/A /* set_values */ PaneSetValues,
749N/A /* extension */ NULL
749N/A }
749N/A};
749N/A
749N/AWidgetClass panedWidgetClass = (WidgetClass) &panedClassRec;
749N/A
749N/A/* For compatibility. */
749N/AWidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec;
749N/A
749N/A/***********************************************************
749N/A *
749N/A * Private Functions.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: AdjustPanedSize
749N/A * Description: Adjusts the size of the pane.
749N/A * Arguments: pw - the paned widget to adjust.
749N/A * off_size - the new off_size to use.
749N/A * result_ret - result of query ** RETURNED **
749N/A * on_size_ret - the new on_size ** RETURNED **
749N/A * off_size_ret - the new off_size ** RETURNED **
749N/A * Returns: the amount of change in size.
749N/A */
749N/A
749N/Astatic void
749N/AAdjustPanedSize(pw, off_size, result_ret, on_size_ret, off_size_ret)
749N/APanedWidget pw;
749N/ADimension off_size;
749N/AXtGeometryResult * result_ret;
749N/ADimension * on_size_ret, * off_size_ret;
749N/A{
749N/A Dimension old_size = PaneSize( (Widget) pw, IsVert(pw));
749N/A Dimension newsize = 0;
749N/A Widget * childP;
749N/A XtWidgetGeometry request, reply;
749N/A request.request_mode = CWWidth | CWHeight;
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A int size = Max(PaneInfo(*childP)->size, (int)PaneInfo(*childP)->min);
749N/A AssignMin(size, (int) PaneInfo(*childP)->max);
749N/A newsize += size + pw->paned.internal_bw;
749N/A }
749N/A newsize -= pw->paned.internal_bw;
749N/A
749N/A if (newsize < 1) newsize = 1;
749N/A
749N/A if ( IsVert(pw) ) {
749N/A request.width = off_size;
749N/A request.height = newsize;
749N/A }
749N/A else {
749N/A request.width = newsize;
749N/A request.height = off_size;
749N/A }
749N/A
749N/A if (result_ret != NULL) {
749N/A request.request_mode |= XtCWQueryOnly;
749N/A
749N/A *result_ret = XtMakeGeometryRequest( (Widget) pw, &request, &reply );
749N/A _XawImCallVendorShellExtResize( (Widget) pw );
749N/A
749N/A if ( (newsize == old_size) || (*result_ret == XtGeometryNo) ) {
749N/A *on_size_ret = old_size;
749N/A *off_size_ret = off_size;
749N/A return;
749N/A }
749N/A if (*result_ret != XtGeometryAlmost) {
749N/A *on_size_ret = GetRequestInfo( &request, IsVert(pw) );
749N/A *off_size_ret = GetRequestInfo( &request, !IsVert(pw) );
749N/A return;
749N/A }
749N/A *on_size_ret = GetRequestInfo( &reply, IsVert(pw) );
749N/A *off_size_ret = GetRequestInfo( &reply, !IsVert(pw) );
749N/A return;
749N/A }
749N/A
749N/A if (newsize == old_size) return;
749N/A
749N/A if (XtMakeGeometryRequest( (Widget) pw,
749N/A &request, &reply) == XtGeometryAlmost)
749N/A XtMakeGeometryRequest( (Widget) pw, &reply, &request);
749N/A}
749N/A
749N/A/* Function Name: PaneSize
749N/A * Description: returns the width or height of the pane depending
749N/A * upon the orientation we are using.
749N/A * Arguments: w - and widget.
749N/A * vertical - TRUE if this is vertically oriented pane.
749N/A * Returns: the size requested
749N/A *
749N/A * vertical - return height
749N/A * !vertical - return width
749N/A */
749N/A
749N/Astatic Dimension
749N/APaneSize(w, vertical)
749N/AWidget w;
749N/ABoolean vertical;
749N/A{
749N/A if (vertical) return (w->core.height);
749N/A return (w->core.width);
749N/A}
749N/A
749N/A/* Function Name: GetRequestInfo
749N/A * Description: returns request information.
749N/A * Arguments: geo_struct - a geometry struct to get information out of.
749N/A * vert - TRUE if this is a vertical paned widget.
749N/A * Returns: the request information.
749N/A */
749N/A
749N/Astatic Dimension
749N/AGetRequestInfo(geo_struct, vert)
749N/AXtWidgetGeometry * geo_struct;
749N/ABoolean vert;
749N/A{
749N/A if ( vert ) return ( (Dimension) geo_struct->height);
749N/A return ( (Dimension) geo_struct->width);
749N/A}
749N/A
749N/A/* Function Name: ChoosePaneToResize.
749N/A * Description: This function chooses a pane to resize.
749N/A * They are chosen using the following rules:
749N/A *
749N/A * 1) size < max && size > min
749N/A * 2) skip adjust == FALSE
749N/A * 3) widget not its prefered height &&
749N/A * this change will bring it closer &&
749N/A * The user has not resized this pane.
749N/A *
749N/A * If no widgets are found that fits all the rules then
749N/A * rule #3 is broken.
749N/A * If there are still no widgets found than
749N/A * rule #2 is broken.
749N/A * Rule #1 is never broken.
749N/A * If no widgets are found then NULL is returned.
749N/A *
749N/A * Arguments: pw - the paned widget.
749N/A * paneindex - the index of the current pane.
749N/A * dir - direction to search first.
749N/A * shrink - TRUE if we need to shrink a pane, FALSE otherwise.
749N/A * Returns: pane to resize or NULL.
749N/A */
749N/A
749N/Astatic Pane
749N/AChoosePaneToResize(pw, paneindex, dir, shrink)
749N/APanedWidget pw;
749N/Aint paneindex;
749N/ADirection dir;
749N/ABoolean shrink;
749N/A{
749N/A Widget *childP;
749N/A int rules = 3;
749N/A Direction _dir = dir;
749N/A int _index = paneindex;
749N/A
749N/A if ( (paneindex == NO_INDEX) || (dir == AnyPane) ) { /* Use defaults. */
749N/A _dir = LowRightPane; /* Go up. - really. */
749N/A _index = pw->paned.num_panes - 1; /* Start the last pane, and work
749N/A backwards. */
749N/A }
749N/A childP = pw->composite.children + _index;
749N/A
749N/A /* CONSTCOND */
749N/A while(TRUE) {
749N/A Pane pane = PaneInfo(*childP);
749N/A
749N/A if ( (rules < 3 || SatisfiesRule3(pane, shrink)) &&
749N/A (rules < 2 || SatisfiesRule2(pane)) &&
749N/A (SatisfiesRule1(pane, shrink)) &&
749N/A ((paneindex != PaneIndex(*childP)) || (dir == AnyPane)) )
749N/A return(pane);
749N/A
749N/A/*
749N/A * This is counter-intuitive, but if we are resizing the pane
749N/A * above the grip we want to choose a pane below the grip to lose,
749N/A * and visa-versa.
749N/A */
749N/A
749N/A if (_dir == LowRightPane) --childP; else ++childP;
749N/A
749N/A/*
749N/A * If we have come to and edge then reduce the rule set, and try again.
749N/A * If we are reduced the rules to none, then return NULL.
749N/A */
749N/A
749N/A if ( (childP - pw->composite.children < 0) ||
749N/A (childP - pw->composite.children >= (long)pw->paned.num_panes) ) {
749N/A if (--rules < 1) /* less strict rules. */
749N/A return(NULL);
749N/A childP = pw->composite.children + _index;
749N/A }
749N/A }
749N/A}
749N/A
749N/A/* Function Name: StatisfiesRule1
749N/A * Description: check for to see if this pane satisfies rule 1.
749N/A * Arguments: pane - the pane to check.
749N/A * shrink -TRUE if we want to shrink this pane, FALSE otherwise
749N/A * Returns: TRUE if the rule is satisfied.
749N/A */
749N/A
749N/Astatic Boolean
749N/ASatisfiesRule1(pane, shrink)
749N/APane pane;
749N/ABoolean shrink;
749N/A{
749N/A return( (shrink && (pane->size != pane->min)) ||
749N/A (!shrink && (pane->size != pane->max)) );
749N/A}
749N/A
749N/A/* Function Name: StatisfiesRule2
749N/A * Description: check for to see if this pane satisfies rule 2.
749N/A * Arguments: pane - the pane to check.
749N/A * Returns: TRUE if the rule is satisfied.
749N/A */
749N/A
749N/Astatic Boolean
749N/ASatisfiesRule2(pane)
749N/APane pane;
749N/A{
749N/A return(!pane->skip_adjust || pane->paned_adjusted_me);
749N/A}
749N/A
749N/A/* Function Name: StatisfiesRule3
749N/A * Description: check for to see if this pane satisfies rule 3.
749N/A * Arguments: pane - the pane to check.
749N/A * shrink -TRUE if we want to shrink this pane, FALSE otherwise
749N/A * Returns: TRUE if the rule is satisfied.
749N/A */
749N/A
749N/Astatic Boolean
749N/ASatisfiesRule3(pane, shrink)
749N/APane pane;
749N/ABoolean shrink;
749N/A{
749N/A return ( pane->paned_adjusted_me &&
749N/A ( (shrink && ((int)pane->wp_size <= pane->size)) ||
749N/A (!shrink && ((int)pane->wp_size >= pane->size))) );
749N/A}
749N/A
749N/A/* Function Name: LoopAndRefigureChildren.
749N/A * Description: if we are resizing either the UpleftPane or LowRight Pane
749N/A * loop through all the children to see if any will allow us
749N/A * to resize them.
749N/A * Arguments: pw - the paned widget.
749N/A * paneindex - the number of the pane border we are moving.
749N/A * dir - the pane to move (either UpLeftPane or LowRightPane).
749N/A * sizeused - current amount of space used.
749N/A * THIS VALUE IS USED AND RETURNED.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ALoopAndRefigureChildren(pw, paneindex, dir, sizeused)
749N/APanedWidget pw;
749N/Aint paneindex, *sizeused;
749N/ADirection dir;
749N/A{
749N/A int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw));
749N/A Boolean shrink = (*sizeused > pane_size);
749N/A
749N/A if (dir == LowRightPane) paneindex++;
749N/A
749N/A while (*sizeused != pane_size) { /* While all panes do not fit properly. */
749N/A/*
749N/A * Choose a pane to resize.
749N/A * First look on the Pane Stack, and then go hunting for another one.
749N/A * If we fail to find a pane to resize then give up.
749N/A */
749N/A Pane pane;
749N/A int start_size;
749N/A Dimension old;
749N/A Boolean rule3_ok = FALSE, from_stack = TRUE;
749N/A
749N/A GetPaneStack(pw, shrink, &pane, &start_size);
749N/A if (pane == NULL) {
749N/A pane = ChoosePaneToResize(pw, paneindex, dir, shrink);
749N/A if (pane == NULL)
749N/A return; /* no one to resize, give up. */
749N/A
749N/A rule3_ok = SatisfiesRule3(pane, shrink);
749N/A from_stack = FALSE;
749N/A PushPaneStack(pw, pane);
749N/A }
749N/A
749N/A
749N/A/*
749N/A * Try to resize this pane so that all panes will fit, take min and max
749N/A * into account.
749N/A */
749N/A old = pane->size;
749N/A pane->size += pane_size - *sizeused;
749N/A
749N/A if (from_stack) {
749N/A if (shrink) {
749N/A AssignMax(pane->size, start_size);
749N/A } /* don't remove these braces. */
749N/A else
749N/A AssignMin(pane->size, start_size);
749N/A
749N/A if (pane->size == start_size) (void) PopPaneStack(pw);
749N/A }
749N/A else if (rule3_ok) {
749N/A if (shrink) {
749N/A AssignMax(pane->size, (int) pane->wp_size);
749N/A } /* don't remove these braces. */
749N/A else
749N/A AssignMin(pane->size, (int) pane->wp_size);
749N/A }
749N/A
749N/A pane->paned_adjusted_me = (pane->size != pane->wp_size);
749N/A AssignMax(pane->size, (int) pane->min);
749N/A AssignMin(pane->size, (int) pane->max);
749N/A *sizeused += (pane->size - old);
749N/A }
749N/A}
749N/A
749N/A/* Function Name: RefigureLocations
749N/A * Description: refigures all locations of children.
749N/A * Arguments: pw - the paned widget.
749N/A * paneindex - child to start refiguring at.
749N/A * dir - direction to move from child.
749N/A * Returns: none.
749N/A *
749N/A * There are special arguments to paneindex and dir, they are:
749N/A * paneindex - NO_INDEX.
749N/A * dir - AnyPane.
749N/A *
749N/A * If either of these is true then all panes may be resized and
749N/A * the choosing of panes procedes in reverse order starting with the
749N/A * last child.
749N/A */
749N/A
749N/Astatic void
749N/ARefigureLocations(pw, paneindex, dir)
749N/APanedWidget pw;
749N/Aint paneindex;
749N/ADirection dir;
749N/A{
749N/A Widget *childP;
749N/A int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw) );
749N/A int sizeused = 0;
749N/A Position loc = 0;
749N/A
749N/A if (pw->paned.num_panes == 0 || !pw->paned.refiguremode) return;
749N/A
749N/A/*
749N/A * Get an initial estimate of the size we will use.
749N/A */
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A Pane pane = PaneInfo(*childP);
749N/A AssignMax(pane->size, (int) pane->min);
749N/A AssignMin(pane->size, (int) pane->max);
749N/A sizeused += (int) pane->size + (int) pw->paned.internal_bw;
749N/A }
749N/A sizeused -= (int) pw->paned.internal_bw;
749N/A
749N/A if ( (dir != ThisBorderOnly) && (sizeused != pane_size) )
749N/A LoopAndRefigureChildren(pw, paneindex, dir, &sizeused);
749N/A
749N/A/*
749N/A * If we still are not the right size, then tell the pane that
749N/A * wanted to resize that it can't.
749N/A */
749N/A
749N/A
749N/A if ( (paneindex != NO_INDEX) && (dir != AnyPane) ) {
749N/A Pane pane = PaneInfo(*(pw->composite.children + paneindex));
749N/A Dimension old = pane->size;
749N/A
749N/A pane->size += pane_size - sizeused;
749N/A AssignMax(pane->size, (int) pane->min);
749N/A AssignMin(pane->size, (int) pane->max);
749N/A sizeused += pane->size - old;
749N/A }
749N/A
749N/A/*
749N/A * It is possible that the panes will not fit inside the vpaned widget, but
749N/A * we have tried out best.
749N/A *
749N/A * Assign each pane a location.
749N/A */
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A PaneInfo(*childP)->delta = loc;
749N/A loc += PaneInfo(*childP)->size + pw->paned.internal_bw;
749N/A }
749N/A}
749N/A
749N/A/* Function Name: CommitNewLocations
749N/A * Description: Commits all of the previously figured locations.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ACommitNewLocations(pw)
749N/APanedWidget pw;
749N/A{
749N/A Widget *childP;
749N/A XWindowChanges changes;
749N/A
749N/A changes.stack_mode = Above;
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A Pane pane = PaneInfo(*childP);
749N/A Widget grip = pane->grip; /* may be NULL. */
749N/A
749N/A if (IsVert(pw)) {
749N/A XtMoveWidget(*childP, (Position) 0, pane->delta);
749N/A XtResizeWidget(*childP, pw->core.width, (Dimension) pane->size,
749N/A (Dimension) 0);
749N/A
749N/A if (HasGrip(*childP)) { /* Move and Display the Grip */
749N/A changes.x = pw->core.width - pw->paned.grip_indent -
749N/A grip->core.width - grip->core.border_width*2;
749N/A changes.y = (*childP)->core.y + (*childP)->core.height -
749N/A grip->core.height/2 - grip->core.border_width +
749N/A pw->paned.internal_bw/2;
749N/A }
749N/A }
749N/A else {
749N/A XtMoveWidget(*childP, pane->delta, (Position) 0);
749N/A XtResizeWidget(*childP, (Dimension) pane->size, pw->core.height,
749N/A (Dimension) 0);
749N/A
749N/A
749N/A if (HasGrip(*childP)) { /* Move and Display the Grip */
749N/A changes.x = (*childP)->core.x + (*childP)->core.width -
749N/A grip->core.width/2 - grip->core.border_width +
749N/A pw->paned.internal_bw/2;
749N/A changes.y = pw->core.height - pw->paned.grip_indent -
749N/A grip->core.height - grip->core.border_width*2;
749N/A }
749N/A }
749N/A
749N/A/*
749N/A * This should match XtMoveWidget, except that we're also insuring the
749N/A * grip is Raised in the same request.
749N/A */
749N/A
749N/A if (HasGrip(*childP)) {
749N/A grip->core.x = changes.x;
749N/A grip->core.y = changes.y;
749N/A
749N/A if (XtIsRealized(pane->grip))
749N/A XConfigureWindow( XtDisplay(pane->grip), XtWindow(pane->grip),
749N/A CWX | CWY | CWStackMode, &changes );
749N/A }
749N/A }
749N/A ClearPaneStack(pw);
749N/A}
749N/A
749N/A/* Function Name: RefigureLocationsAndCommit
749N/A * Description: Refigures all locations in a paned widget and
749N/A * commits them immediately.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none
749N/A *
749N/A * This function does nothing if any of the following are true.
749N/A * o refiguremode is false.
749N/A * o The widget is unrealized.
749N/A * o There are no panes is the paned widget.
749N/A *
749N/A * NOTE: This is the resize Procedure for the Paned widget.
749N/A */
749N/A
749N/Astatic void
749N/ARefigureLocationsAndCommit(w)
749N/AWidget w;
749N/A{
749N/A PanedWidget pw = (PanedWidget) w;
749N/A if (pw->paned.refiguremode && XtIsRealized( (Widget) pw) &&
749N/A pw->paned.num_panes > 0 ) {
749N/A RefigureLocations(pw, NO_INDEX, AnyPane);
749N/A CommitNewLocations(pw);
749N/A }
749N/A}
749N/A
749N/A/* Function Name: _DrawRect
749N/A * Description: Draws a rectangle in the proper orientation.
749N/A * Arguments: pw - the paned widget.
749N/A * gc - gc to used for the draw.
749N/A * on_olc, off_loc - location of upper left corner of rect.
749N/A * on_size, off_size - size of rectangle.
749N/A * Returns: none
749N/A */
749N/A
749N/Astatic void
749N/A_DrawRect(pw, gc, on_loc, off_loc, on_size, off_size)
749N/APanedWidget pw;
749N/AGC gc;
749N/Aint on_loc, off_loc;
749N/Aunsigned int on_size, off_size;
749N/A{
749N/A if (IsVert(pw))
749N/A XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
749N/A off_loc, on_loc, off_size, on_size);
749N/A else
749N/A XFillRectangle(XtDisplay(pw), XtWindow(pw), gc,
749N/A on_loc, off_loc, on_size, off_size);
749N/A}
749N/A
749N/A/* Function Name: _DrawInternalBorders
749N/A * Description: Draws the internal borders into the paned widget.
749N/A * Arguments: pw - the paned widget.
749N/A * gc - the GC to use to draw the borders.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/A_DrawInternalBorders(pw, gc)
749N/APanedWidget pw;
749N/AGC gc;
749N/A{
749N/A Widget *childP;
749N/A int on_loc, off_loc;
749N/A unsigned int on_size, off_size;
749N/A
749N/A/*
749N/A * This is an optimization. Do not paint the internal borders if
749N/A * they are the same color as the background.
749N/A */
749N/A
749N/A if (pw->core.background_pixel == pw->paned.internal_bp)
749N/A return;
749N/A
749N/A off_loc = 0;
749N/A off_size = (unsigned int) PaneSize( (Widget) pw, !IsVert(pw) );
749N/A on_size = (unsigned int) pw->paned.internal_bw;
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A on_loc = IsVert(pw) ? (*childP)->core.y : (*childP)->core.x;
749N/A on_loc -= (int) on_size;
749N/A
749N/A _DrawRect( pw, gc, on_loc, off_loc, on_size, off_size);
749N/A }
749N/A}
749N/A
749N/A/*
749N/A * This allows good reuse of code, as well as descriptive function names.
749N/A */
749N/A
749N/A#define DrawInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.normgc);
749N/A#define EraseInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.invgc);
749N/A
749N/A/* Function Name: _DrawTrackLines
749N/A * Description: Draws the lines that animate the pane borders when the
749N/A * grips are moved.
749N/A * Arguments: pw - the Paned widget.
749N/A * erase - if True then just erase track lines, else
749N/A * draw them in.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/A_DrawTrackLines(pw, erase)
749N/APanedWidget pw;
749N/ABoolean erase;
749N/A{
749N/A Widget *childP;
749N/A Pane pane;
749N/A int on_loc, off_loc;
749N/A unsigned int on_size, off_size;
749N/A
749N/A off_loc = 0;
749N/A off_size = PaneSize( (Widget) pw, !IsVert(pw));
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A pane = PaneInfo(*childP);
749N/A if ( erase || (pane->olddelta != pane->delta) ) {
749N/A on_size = pw->paned.internal_bw;
749N/A if (!erase) {
749N/A on_loc = PaneInfo(*childP)->olddelta - (int) on_size;
749N/A
749N/A _DrawRect( pw, pw->paned.flipgc,
749N/A on_loc, off_loc, on_size, off_size);
749N/A }
749N/A
749N/A on_loc = PaneInfo(*childP)->delta - (int) on_size;
749N/A
749N/A _DrawRect(pw, pw->paned.flipgc,
749N/A on_loc, off_loc, on_size, off_size);
749N/A
749N/A pane->olddelta = pane->delta;
749N/A }
749N/A }
749N/A}
749N/A
749N/A/*
749N/A * This allows good reuse of code, as well as descriptive function names.
749N/A */
749N/A
749N/A#define DrawTrackLines(pw) _DrawTrackLines((pw), FALSE);
749N/A#define EraseTrackLines(pw) _DrawTrackLines((pw), TRUE);
749N/A
749N/A/* Function Name: GetEventLocation
749N/A * Description: Converts and event to an x and y location.
749N/A * Arguments: pw - the paned widget.
749N/A * event - a pointer to an event.
749N/A * Returns: if this is a vertical pane then (y) else (x).
749N/A */
749N/A
749N/Astatic int
749N/AGetEventLocation(pw, event)
749N/APanedWidget pw;
749N/AXEvent *event;
749N/A{
749N/A int x, y;
749N/A
749N/A switch (event->xany.type) {
749N/A case ButtonPress:
749N/A case ButtonRelease:
749N/A x = event->xbutton.x_root;
749N/A y = event->xbutton.y_root;
749N/A break;
749N/A case KeyPress:
749N/A case KeyRelease:
749N/A x = event->xkey.x_root;
749N/A y = event->xkey.y_root;
749N/A break;
749N/A case MotionNotify:
749N/A x = event->xmotion.x_root;
749N/A y = event->xmotion.y_root;
749N/A break;
749N/A default:
749N/A x = pw->paned.start_loc;
749N/A y = pw->paned.start_loc;
749N/A }
749N/A if (IsVert(pw))
749N/A return(y);
749N/A return(x);
749N/A}
749N/A
749N/A/* Function Name: StartGripAdjustment
749N/A * Description: Starts the grip adjustment procedure.
749N/A * Arguments: pw - the paned widget.
749N/A * grip - the grip widget selected.
749N/A * dir - the direction that we are to be moving.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AStartGripAdjustment(pw, grip, dir)
749N/APanedWidget pw;
749N/AWidget grip;
749N/ADirection dir;
749N/A{
749N/A Widget *childP;
749N/A Cursor cursor;
749N/A
749N/A pw->paned.whichadd = pw->paned.whichsub = (Widget) NULL;
749N/A
749N/A if (dir == ThisBorderOnly || dir == UpLeftPane)
749N/A pw->paned.whichadd = pw->composite.children[PaneIndex(grip)];
749N/A if (dir == ThisBorderOnly || dir == LowRightPane)
749N/A pw->paned.whichsub = pw->composite.children[PaneIndex(grip) + 1];
749N/A
749N/A/*
749N/A * Change the cursor.
749N/A */
749N/A
749N/A if (XtIsRealized(grip)) {
749N/A if ( IsVert(pw) ) {
749N/A if (dir == UpLeftPane)
749N/A cursor = pw->paned.adjust_upper_cursor;
749N/A else if (dir == LowRightPane)
749N/A cursor = pw->paned.adjust_lower_cursor;
749N/A else {
749N/A if ( pw->paned.adjust_this_cursor == None)
749N/A cursor = pw->paned.v_adjust_this_cursor;
749N/A else
749N/A cursor = pw->paned.adjust_this_cursor;
749N/A }
749N/A }
749N/A else {
749N/A if (dir == UpLeftPane)
749N/A cursor = pw->paned.adjust_left_cursor;
749N/A else if (dir == LowRightPane)
749N/A cursor = pw->paned.adjust_right_cursor;
749N/A else {
749N/A if (pw->paned.adjust_this_cursor == None)
749N/A cursor = pw->paned.h_adjust_this_cursor;
749N/A else
749N/A cursor = pw->paned.adjust_this_cursor;
749N/A }
749N/A }
749N/A
749N/A XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
749N/A }
749N/A
749N/A EraseInternalBorders(pw);
749N/A ForAllPanes(pw, childP)
749N/A PaneInfo(*childP)->olddelta = -99;
749N/A}
749N/A
749N/A/* Function Name: MoveGripAdjustment
749N/A * Description: This routine moves all panes around when a grip is moved.
749N/A * Arguments: pw - the paned widget.
749N/A * grip - the grip that we are moving.
749N/A * dir - the direction the pane we are interested is w.r.t the
749N/A * grip.
749N/A * loc - location of pointer in proper direction.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AMoveGripAdjustment(pw, grip, dir, loc)
749N/APanedWidget pw;
749N/AWidget grip;
749N/ADirection dir;
749N/Aint loc;
749N/A{
749N/A int diff, add_size = 0, sub_size = 0;
749N/A
749N/A diff = loc - pw->paned.start_loc;
749N/A
749N/A if (pw->paned.whichadd)
749N/A add_size = PaneSize(pw->paned.whichadd, IsVert(pw) ) + diff;
749N/A
749N/A if (pw->paned.whichsub)
749N/A sub_size = PaneSize(pw->paned.whichsub, IsVert(pw) ) - diff;
749N/A
749N/A/*
749N/A * If moving this border only then do not allow either of the borders
749N/A * to go beyond the min or max size allowed.
749N/A */
749N/A
749N/A if ( (dir == ThisBorderOnly) ) {
749N/A int old_add_size = add_size, old_sub_size;
749N/A
749N/A AssignMax(add_size, (int) PaneInfo(pw->paned.whichadd)->min);
749N/A AssignMin(add_size, (int) PaneInfo(pw->paned.whichadd)->max);
749N/A if (add_size != old_add_size)
749N/A sub_size += old_add_size - add_size;
749N/A
749N/A old_sub_size = sub_size;
749N/A AssignMax(sub_size, (int) PaneInfo(pw->paned.whichsub)->min);
749N/A AssignMin(sub_size, (int) PaneInfo(pw->paned.whichsub)->max);
749N/A if (sub_size != old_sub_size) return; /* Abort to current sizes. */
749N/A }
749N/A
749N/A if (add_size != 0)
749N/A PaneInfo(pw->paned.whichadd)->size = add_size;
749N/A if (sub_size != 0)
749N/A PaneInfo(pw->paned.whichsub)->size = sub_size;
749N/A RefigureLocations(pw, PaneIndex(grip), dir);
749N/A DrawTrackLines(pw);
749N/A}
749N/A
749N/A/* Function Name: CommitGripAdjustment
749N/A * Description: Commits the grip adjustment.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none
749N/A */
749N/A
749N/Astatic void
749N/ACommitGripAdjustment(pw)
749N/APanedWidget pw;
749N/A{
749N/A EraseTrackLines(pw);
749N/A CommitNewLocations(pw);
749N/A DrawInternalBorders(pw);
749N/A
749N/A/*
749N/A * Since the user selected this size then use it as the preferred size.
749N/A */
749N/A
749N/A if (pw->paned.whichadd) {
749N/A Pane pane = PaneInfo(pw->paned.whichadd);
749N/A pane->wp_size = pane->size;
749N/A }
749N/A if (pw->paned.whichsub) {
749N/A Pane pane = PaneInfo(pw->paned.whichsub);
749N/A pane->wp_size = pane->size;
749N/A }
749N/A}
749N/A
749N/A/* Function Name: HandleGrip
749N/A * Description: Handles the grip manipulations.
749N/A * Arguments: grip - the grip widget that has been moved.
749N/A * junk - ** NOT USED **
749N/A * call_data - data passed to us from the grip widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AHandleGrip(grip, junk, callData)
749N/AWidget grip;
749N/AXtPointer junk, callData;
749N/A{
749N/A XawGripCallData call_data = (XawGripCallData)callData;
749N/A PanedWidget pw = (PanedWidget) XtParent(grip);
749N/A int loc;
749N/A char action_type;
749N/A Cursor cursor;
749N/A Direction direction;
749N/A Arg arglist[1];
749N/A
749N/A action_type = *call_data->params[0];
749N/A
749N/A if (call_data->num_params == 0 ||
749N/A (action_type == 'C' && call_data->num_params != 1) ||
749N/A (action_type != 'C' && call_data->num_params != 2))
749N/A XtError( "Paned GripAction has been passed incorrect parameters." );
749N/A
749N/A if (islower(action_type)) action_type = toupper(action_type);
749N/A
749N/A loc = GetEventLocation(pw, (XEvent *) (call_data->event));
749N/A
749N/A if (action_type != 'C') {
749N/A if ( isupper(*call_data->params[1]) )
749N/A direction = (Direction) *call_data->params[1];
749N/A else
749N/A direction = (Direction) toupper(*call_data->params[1]);
749N/A }
749N/A
749N/A switch (action_type) {
749N/A case 'S': /* Start adjustment */
749N/A pw->paned.resize_children_to_pref = FALSE;
749N/A StartGripAdjustment(pw, grip, direction);
749N/A pw->paned.start_loc = loc;
749N/A break;
749N/A
749N/A case 'M':
749N/A MoveGripAdjustment(pw, grip, direction, loc);
749N/A break;
749N/A
749N/A case 'C':
749N/A XtSetArg(arglist[0], XtNcursor, &cursor);
749N/A XtGetValues(grip, arglist, (Cardinal) 1);
749N/A XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor);
749N/A CommitGripAdjustment(pw);
749N/A break;
749N/A
749N/A default:
749N/A XtError( "Paned GripAction(); 1st parameter invalid" );
749N/A }
749N/A}
749N/A
749N/A/* Function Name: ResortChildren
749N/A * Description: Resorts the children so that all managed children
749N/A * are first.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AResortChildren(pw)
749N/APanedWidget pw;
749N/A{
749N/A Widget * unmanagedP, * childP;
749N/A
749N/A unmanagedP = NULL;
749N/A ForAllChildren(pw, childP) {
749N/A if (!IsPane(*childP) || !XtIsManaged(*childP)) {
749N/A /*
749N/A * We only keep track of the first unmanaged pane.
749N/A */
749N/A if (unmanagedP == NULL)
749N/A unmanagedP = childP;
749N/A }
749N/A else { /* must be a managed pane */
749N/A /*
749N/A * If an earlier widget was not a managed pane, then swap
749N/A */
749N/A if (unmanagedP != NULL) {
749N/A Widget child = *unmanagedP;
749N/A *unmanagedP = *childP;
749N/A *childP = child;
749N/A childP = unmanagedP; /* easiest to just back-track */
749N/A unmanagedP = NULL; /* in case there is another managed */
749N/A }
749N/A }
749N/A }
749N/A}
749N/A
749N/A/* Function Name: ManageAndUnmanageGrips
749N/A * Description: This function manages and unmanages the grips so that
749N/A * the managed state of each grip matches that of its pane.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AManageAndUnmanageGrips(pw)
749N/APanedWidget pw;
749N/A{
749N/A WidgetList managed_grips, unmanaged_grips;
749N/A Widget *managedP, *unmanagedP, *childP;
749N/A Cardinal alloc_size;
749N/A
749N/A alloc_size = (Cardinal) sizeof(Widget) * pw->composite.num_children / 2;
749N/A managedP = managed_grips = (WidgetList) XtMalloc(alloc_size);
749N/A unmanagedP = unmanaged_grips = (WidgetList) XtMalloc(alloc_size);
749N/A
749N/A ForAllChildren(pw, childP)
749N/A if (IsPane(*childP) && HasGrip(*childP))
749N/A if ( XtIsManaged(*childP) )
749N/A *managedP++ = PaneInfo(*childP)->grip;
749N/A else
749N/A *unmanagedP++ = PaneInfo(*childP)->grip;
749N/A
749N/A if (managedP != managed_grips) {
749N/A *unmanagedP++ = *--managedP; /* Last grip is never managed */
749N/A XtManageChildren( managed_grips, (Cardinal)(managedP - managed_grips) );
749N/A }
749N/A
749N/A if (unmanagedP != unmanaged_grips)
749N/A XtUnmanageChildren( unmanaged_grips,
749N/A (Cardinal)(unmanagedP - unmanaged_grips) );
749N/A
749N/A XtFree((char *)managed_grips);
749N/A XtFree((char *)unmanaged_grips);
749N/A}
749N/A
749N/A/* Function Name: CreateGrip
749N/A * Description: Creates a grip widget.
749N/A * Arguments: child - the child that wants a grip to be created for it.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ACreateGrip(child)
749N/AWidget child;
749N/A{
749N/A PanedWidget pw = (PanedWidget) XtParent(child);
749N/A Arg arglist[2];
749N/A Cardinal num_args = 0;
749N/A Cursor cursor;
749N/A
749N/A XtSetArg(arglist[num_args], XtNtranslations, pw->paned.grip_translations);
749N/A num_args++;
749N/A if ( (cursor = pw->paned.grip_cursor) == None )
749N/A if (IsVert(pw))
749N/A cursor = pw->paned.v_grip_cursor;
749N/A else
749N/A cursor = pw->paned.h_grip_cursor;
749N/A
749N/A XtSetArg(arglist[num_args], XtNcursor, cursor);
749N/A num_args++;
749N/A PaneInfo(child)->grip = XtCreateWidget("grip", gripWidgetClass, (Widget)pw,
749N/A arglist, num_args);
749N/A
749N/A XtAddCallback(PaneInfo(child)->grip, XtNcallback,
749N/A HandleGrip, (XtPointer) child);
749N/A}
749N/A
749N/A/* Function Name: GetGCs
749N/A * Description: Gets new GC's.
749N/A * Arguments: w - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AGetGCs(w)
749N/AWidget w;
749N/A{
749N/A PanedWidget pw = (PanedWidget) w;
749N/A XtGCMask valuemask;
749N/A XGCValues values;
749N/A
749N/A/*
749N/A * Draw pane borders in internal border color.
749N/A */
749N/A
749N/A values.foreground = pw->paned.internal_bp;
749N/A valuemask = GCForeground;
749N/A pw->paned.normgc = XtGetGC(w, valuemask, &values);
749N/A
749N/A/*
749N/A * Erase pane borders with background color.
749N/A */
749N/A
749N/A values.foreground = pw->core.background_pixel;
749N/A valuemask = GCForeground;
749N/A pw->paned.invgc = XtGetGC(w, valuemask, &values);
749N/A
749N/A/*
749N/A * Draw Track lines (animate pane borders) in internal border color ^ bg color.
749N/A */
749N/A
749N/A values.function = GXinvert;
749N/A values.plane_mask = pw->paned.internal_bp ^ pw->core.background_pixel;
749N/A values.subwindow_mode = IncludeInferiors;
749N/A valuemask = GCPlaneMask | GCFunction | GCSubwindowMode;
749N/A pw->paned.flipgc = XtGetGC(w, valuemask, &values);
749N/A}
749N/A
749N/A/* Function Name: SetChildrenPrefSizes.
749N/A * Description: Sets the preferred sizes of the children.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ASetChildrenPrefSizes(pw, off_size)
749N/APanedWidget pw;
749N/ADimension off_size;
749N/A{
749N/A Widget * childP;
749N/A Boolean vert = IsVert(pw);
749N/A XtWidgetGeometry request, reply;
749N/A
749N/A ForAllPanes(pw, childP)
749N/A if ( pw->paned.resize_children_to_pref ||
749N/A (PaneInfo(*childP)->size == 0) ||
749N/A (PaneInfo(*childP)->resize_to_pref) ) {
749N/A
749N/A if (PaneInfo(*childP)->preferred_size != PANED_ASK_CHILD)
749N/A PaneInfo(*childP)->wp_size=PaneInfo(*childP)->preferred_size;
749N/A else {
749N/A if( vert ) {
749N/A request.request_mode = CWWidth;
749N/A request.width = off_size;
749N/A }
749N/A else {
749N/A request.request_mode = CWHeight;
749N/A request.height = off_size;
749N/A }
749N/A
749N/A if ((XtQueryGeometry( *childP, &request, &reply )
749N/A == XtGeometryAlmost) &&
749N/A (reply.request_mode = (vert ? CWHeight : CWWidth)))
749N/A PaneInfo(*childP)->wp_size = GetRequestInfo(&reply, vert);
749N/A else
749N/A PaneInfo(*childP)->wp_size = PaneSize(*childP, vert);
749N/A }
749N/A
749N/A PaneInfo(*childP)->size = PaneInfo(*childP)->wp_size;
749N/A }
749N/A}
749N/A
749N/A/* Function Name: ChangeAllGripCursors
749N/A * Description: Changes all the grip cursors.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none
749N/A */
749N/A
749N/Astatic void
749N/AChangeAllGripCursors(pw)
749N/APanedWidget pw;
749N/A{
749N/A Widget * childP;
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A Arg arglist[1];
749N/A Cursor cursor;
749N/A
749N/A if ( (cursor = pw->paned.grip_cursor) == None )
749N/A if ( IsVert(pw) )
749N/A cursor = pw->paned.v_grip_cursor;
749N/A else
749N/A cursor = pw->paned.h_grip_cursor;
749N/A
749N/A if (HasGrip (*childP)) {
749N/A XtSetArg(arglist[0], XtNcursor, cursor);
749N/A XtSetValues(PaneInfo(*childP)->grip, arglist, (Cardinal) 1);
749N/A }
749N/A }
749N/A}
749N/A
749N/A/************************************************************
749N/A *
749N/A * Stack Manipulation routines (Private).
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: PushPaneStack
749N/A * Description: Pushes a value onto the pane stack.
749N/A * Arguments: pw - the paned widget.
749N/A * pane - the pane that we are pushing.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/APushPaneStack(pw, pane)
749N/APanedWidget pw;
749N/APane pane;
749N/A{
749N/A PaneStack * stack = (PaneStack *) XtMalloc(sizeof(PaneStack));
749N/A
749N/A stack->next = pw->paned.stack;
749N/A stack->pane = pane;
749N/A stack->start_size = pane->size;
749N/A
749N/A pw->paned.stack = stack;
749N/A}
749N/A
749N/A/* Function Name: GetPaneStack
749N/A * Description: Gets the top value from the pane stack.
749N/A * Arguments: pw - the paned widget.
749N/A * shrink - TRUE if we want to shrink this pane,
749N/A * FALSE otherwise.
749N/A * ** RETURNED ** pane - the pane that we are popping.
749N/A * ** RETURNED ** start_size - the size that this pane started at.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AGetPaneStack(pw, shrink, pane, start_size)
749N/APanedWidget pw;
749N/ABoolean shrink;
749N/APane * pane;
749N/Aint * start_size;
749N/A{
749N/A if (pw->paned.stack == NULL) {
749N/A *pane = NULL;
749N/A return;
749N/A }
749N/A
749N/A *pane = pw->paned.stack->pane;
749N/A *start_size = pw->paned.stack->start_size;
749N/A
749N/A if (shrink != ((*pane)->size > *start_size)) *pane = NULL;
749N/A}
749N/A
749N/A/* Function Name: PopPaneStack
749N/A * Description: Pops the top item off the pane stack.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: TRUE if this is not the last element on the stack.
749N/A */
749N/A
749N/Astatic Boolean
749N/APopPaneStack(pw)
749N/APanedWidget pw;
749N/A{
749N/A PaneStack * stack = pw->paned.stack;
749N/A
749N/A if (stack == NULL) return(FALSE);
749N/A
749N/A pw->paned.stack = stack->next;
749N/A XtFree((char*)stack);
749N/A
749N/A if (pw->paned.stack == NULL) return(FALSE);
749N/A return(TRUE);
749N/A}
749N/A
749N/A/* Function Name: ClearPaneStack
749N/A * Description: removes all entries from the pane stack.
749N/A * Arguments: pw - the paned widget.
749N/A * Returns: none
749N/A */
749N/A
749N/Astatic void
749N/AClearPaneStack(pw)
749N/APanedWidget pw;
749N/A{
749N/A while(PopPaneStack(pw));
749N/A}
749N/A
749N/A/************************************************************
749N/A *
749N/A * Semi-public routines.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: ClassInitialize
749N/A * Description: The Paned widgets class initialization proc.
749N/A * Arguments: none.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AClassInitialize()
749N/A{
749N/A XawInitializeWidgetSet();
749N/A XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
749N/A (XtConvertArgList)NULL, (Cardinal)0 );
749N/A}
749N/A
749N/A/* The Geometry Manager only allows changes after Realize if
749N/A * allow_resize is True in the constraints record.
749N/A *
749N/A * For vertically paned widgets:
749N/A *
749N/A * It only allows height changes, but offers the requested height
749N/A * as a compromise if both width and height changes were requested.
749N/A *
749N/A * For horizontal widgets the converse is true.
749N/A * As all good Geometry Managers should, we will return No if the
749N/A * request will have no effect; i.e. when the requestor is already
749N/A * of the desired geometry.
749N/A */
749N/A
749N/Astatic XtGeometryResult GeometryManager(w, request, reply)
749N/AWidget w;
749N/AXtWidgetGeometry *request, *reply;
749N/A{
749N/A PanedWidget pw = (PanedWidget) XtParent(w);
749N/A XtGeometryMask mask = request->request_mode;
749N/A Dimension old_size, old_wpsize, old_paned_size;
749N/A Pane pane = PaneInfo(w);
749N/A Boolean vert = IsVert(pw);
749N/A Dimension on_size, off_size;
749N/A XtGeometryResult result;
749N/A Boolean almost = FALSE;
749N/A
749N/A/*
749N/A * If any of the following is true, disallow the geometry change.
749N/A *
749N/A * o The paned widget is realized and allow_resize is false for the pane.
749N/A * o The child did not ask to change the on_size.
749N/A * o The request is not a width or height request.
749N/A * o The requested size is the same as the current size.
749N/A */
749N/A
749N/A if ( (XtIsRealized((Widget)pw) && !pane->allow_resize) ||
749N/A !(mask & ((vert) ? CWHeight : CWWidth)) ||
749N/A (mask & ~(CWWidth | CWHeight)) ||
749N/A (GetRequestInfo(request, vert) == PaneSize(w, vert)) ) {
749N/A return XtGeometryNo;
749N/A }
749N/A
749N/A old_paned_size = PaneSize( (Widget) pw, vert);
749N/A old_wpsize = pane->wp_size;
749N/A old_size = pane->size;
749N/A
749N/A pane->wp_size = pane->size = GetRequestInfo(request, vert);
749N/A
749N/A AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), &result, &on_size,
749N/A &off_size);
749N/A
749N/A/*
749N/A * Fool the Refigure Locations proc to thinking that we are
749N/A * a different on_size;
749N/A */
749N/A
749N/A if (result != XtGeometryNo)
749N/A if (vert)
749N/A pw->core.height = on_size;
749N/A else
749N/A pw->core.width = on_size;
749N/A
749N/A RefigureLocations(pw, PaneIndex(w), AnyPane);
749N/A
749N/A/*
749N/A * Set up reply struct and reset core on_size.
749N/A */
749N/A
749N/A if (vert) {
749N/A pw->core.height = old_paned_size;
749N/A reply->height = pane->size;
749N/A reply->width = off_size;
749N/A }
749N/A else {
749N/A pw->core.width = old_paned_size;
749N/A reply->height = off_size;
749N/A reply->width = pane->size;
749N/A }
749N/A
749N/A/*
749N/A * IF either of the following is true.
749N/A *
749N/A * o There was a "off_size" request and the new "off_size" is different
749N/A * from that requested.
749N/A * o There was no "off_size" request and the new "off_size" is different
749N/A *
749N/A * o The "on_size" we will allow is different from that requested.
749N/A *
749N/A * THEN: set almost
749N/A */
749N/A
749N/A if ( !((vert ? CWWidth : CWHeight) & mask))
749N/A if (vert)
749N/A request->width = w->core.width;
749N/A else
749N/A request->height = w->core.height;
749N/A
749N/A almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert);
749N/A almost |= (GetRequestInfo(request, vert) != GetRequestInfo(reply, vert));
749N/A
749N/A if ( (mask & XtCWQueryOnly) || almost ) {
749N/A pane->wp_size = old_wpsize;
749N/A pane->size = old_size;
749N/A RefigureLocations(pw, PaneIndex(w), AnyPane);
749N/A reply->request_mode = CWWidth | CWHeight;
749N/A if (almost) return XtGeometryAlmost;
749N/A }
749N/A else {
749N/A AdjustPanedSize(pw, PaneSize((Widget) pw, !vert),
749N/A (XtGeometryResult *)NULL,
749N/A (Dimension *)NULL, (Dimension *)NULL);
749N/A CommitNewLocations( pw ); /* layout already refigured. */
749N/A }
749N/A return XtGeometryDone;
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic void Initialize(request, new, args, num_args)
749N/AWidget request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A PanedWidget pw = (PanedWidget)new;
749N/A
749N/A GetGCs( (Widget) pw);
749N/A
749N/A pw->paned.recursively_called = False;
749N/A pw->paned.stack = NULL;
749N/A pw->paned.resize_children_to_pref = TRUE;
749N/A pw->paned.num_panes = 0;
749N/A}
749N/A
749N/Astatic void
749N/ARealize(w, valueMask, attributes)
749N/AWidget w;
749N/AMask *valueMask;
749N/AXSetWindowAttributes *attributes;
749N/A{
749N/A PanedWidget pw = (PanedWidget) w;
749N/A Widget * childP;
749N/A
749N/A if ((attributes->cursor = (pw)->paned.cursor) != None)
749N/A *valueMask |= CWCursor;
749N/A
749N/A (*SuperClass->core_class.realize) (w, valueMask, attributes);
749N/A
749N/A/*
749N/A * Before we commit the new locations we need to realize all the panes and
749N/A * their grips.
749N/A */
749N/A
749N/A ForAllPanes(pw, childP) {
749N/A XtRealizeWidget( *childP );
749N/A if (HasGrip (*childP))
749N/A XtRealizeWidget( PaneInfo(*childP)->grip );
749N/A }
749N/A
749N/A RefigureLocationsAndCommit(w);
749N/A pw->paned.resize_children_to_pref = FALSE;
749N/A} /* Realize */
749N/A
749N/Astatic void
749N/AReleaseGCs(w)
749N/AWidget w;
749N/A{
749N/A PanedWidget pw = (PanedWidget)w;
749N/A
749N/A XtReleaseGC( w, pw->paned.normgc );
749N/A XtReleaseGC( w, pw->paned.invgc );
749N/A XtReleaseGC( w, pw->paned.flipgc );
749N/A}
749N/A
749N/Astatic void InsertChild(w)
749N/AWidget w;
749N/A{
749N/A Pane pane = PaneInfo(w);
749N/A
749N/A /* insert the child widget in the composite children list with the */
749N/A /* superclass insert_child routine. */
749N/A (*SuperClass->composite_class.insert_child)(w);
749N/A
749N/A if (!IsPane(w)) return;
749N/A
749N/A /* ||| Panes will be added in the order they are created, temporarily */
749N/A
749N/A if ( pane->show_grip == TRUE ) {
749N/A CreateGrip(w);
749N/A if (pane->min == PANED_GRIP_SIZE)
749N/A pane->min = PaneSize(pane->grip, IsVert((PanedWidget) XtParent(w)));
749N/A }
749N/A else {
749N/A if (pane->min == PANED_GRIP_SIZE)
749N/A pane->min = 1;
749N/A pane->grip = NULL;
749N/A }
749N/A
749N/A pane->size = 0;
749N/A pane->paned_adjusted_me = FALSE;
749N/A
749N/A} /* InsertChild */
749N/A
749N/Astatic void DeleteChild(w)
749N/AWidget w;
749N/A{
749N/A /* remove the subwidget info and destroy the grip */
749N/A
749N/A if ( IsPane(w) && HasGrip(w) ) XtDestroyWidget(PaneInfo(w)->grip);
749N/A
749N/A /* delete the child widget in the composite children list with the */
749N/A /* superclass delete_child routine. */
749N/A (*SuperClass->composite_class.delete_child) (w);
749N/A
749N/A} /* DeleteChild */
749N/A
749N/Astatic void ChangeManaged(w)
749N/A Widget w;
749N/A{
749N/A PanedWidget pw = (PanedWidget)w;
749N/A Boolean vert = IsVert(pw);
749N/A Dimension size;
749N/A Widget *childP;
749N/A
749N/A if (pw->paned.recursively_called++) return;
749N/A
749N/A/*
749N/A * If the size is zero then set it to the size of the widest or tallest pane.
749N/A */
749N/A
749N/A if ( (size = PaneSize( (Widget) pw, !vert )) == 0) {
749N/A size = 1;
749N/A ForAllChildren(pw, childP)
749N/A if ( XtIsManaged(*childP) && (PaneSize( *childP, !vert ) > size) )
749N/A size = PaneSize( *childP, !vert );
749N/A }
749N/A
749N/A ManageAndUnmanageGrips(pw);
749N/A pw->paned.recursively_called = False;
749N/A ResortChildren(pw);
749N/A
749N/A pw->paned.num_panes = 0;
749N/A ForAllChildren(pw, childP)
749N/A if ( IsPane(*childP) )
749N/A if ( XtIsManaged(*childP) ) {
749N/A Pane pane = PaneInfo(*childP);
749N/A if (HasGrip(*childP))
749N/A PaneInfo(pane->grip)->position = pw->paned.num_panes;
749N/A pane->position = pw->paned.num_panes; /*TEMPORY -CDP 3/89 */
749N/A pw->paned.num_panes++;
749N/A }
749N/A else
749N/A break; /* This list is already sorted. */
749N/A
749N/A SetChildrenPrefSizes( (PanedWidget) w, size);
749N/A
749N/A/*
749N/A * ForAllPanes can now be used.
749N/A */
749N/A
749N/A if ( PaneSize((Widget) pw, vert) == 0 )
749N/A AdjustPanedSize(pw, size, (XtGeometryResult *)NULL,
749N/A (Dimension *)NULL, (Dimension *)NULL);
749N/A
749N/A if (XtIsRealized( (Widget) pw))
749N/A RefigureLocationsAndCommit( (Widget) pw);
749N/A
749N/A} /* ChangeManaged */
749N/A
749N/A/* Function Name: Resize
749N/A * Description: The paned widget's resize proc.
749N/A * Arguments: w - the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AResize(w)
749N/AWidget w;
749N/A{
749N/A SetChildrenPrefSizes( (PanedWidget) w,
749N/A PaneSize(w, !IsVert((PanedWidget) w)) );
749N/A RefigureLocationsAndCommit(w);
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/ARedisplay(w, event, region)
749N/AWidget w;
749N/AXEvent * event; /* unused. */
749N/ARegion region; /* unused. */
749N/A{
749N/A DrawInternalBorders( (PanedWidget) w);
749N/A}
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean
749N/ASetValues(old, request, new, args, num_args)
749N/AWidget old, request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A PanedWidget old_pw = (PanedWidget) old;
749N/A PanedWidget new_pw = (PanedWidget) new;
749N/A Boolean redisplay = FALSE;
749N/A
749N/A if ( (old_pw->paned.cursor != new_pw->paned.cursor) && XtIsRealized(new))
749N/A XDefineCursor(XtDisplay(new), XtWindow(new), new_pw->paned.cursor);
749N/A
749N/A if ( (old_pw->paned.internal_bp != new_pw->paned.internal_bp) ||
749N/A (old_pw->core.background_pixel != new_pw->core.background_pixel) ) {
749N/A ReleaseGCs(old);
749N/A GetGCs(new);
749N/A redisplay = TRUE;
749N/A }
749N/A
749N/A if ( (old_pw->paned.grip_cursor != new_pw->paned.grip_cursor) ||
749N/A (old_pw->paned.v_grip_cursor != new_pw->paned.v_grip_cursor) ||
749N/A (old_pw->paned.h_grip_cursor != new_pw->paned.h_grip_cursor) ) {
749N/A ChangeAllGripCursors(new_pw);
749N/A }
749N/A
749N/A if ( IsVert(old_pw) != IsVert(new_pw)) {
749N/A/*
749N/A * We are fooling the paned widget into thinking that is needs to
749N/A * fully refigure everything, which is what we want.
749N/A */
749N/A if (IsVert(new_pw))
749N/A new_pw->core.width = 0;
749N/A else
749N/A new_pw->core.height = 0;
749N/A
749N/A new_pw->paned.resize_children_to_pref = TRUE;
749N/A ChangeManaged(new); /* Seems weird, but does the right thing. */
749N/A new_pw->paned.resize_children_to_pref = FALSE;
749N/A if (new_pw->paned.grip_cursor == None)
749N/A ChangeAllGripCursors(new_pw);
749N/A return(TRUE);
749N/A }
749N/A
749N/A if (old_pw->paned.internal_bw != new_pw->paned.internal_bw) {
749N/A AdjustPanedSize( new_pw, PaneSize(new, !IsVert(old_pw)),
749N/A (XtGeometryResult *)NULL,
749N/A (Dimension *)NULL, (Dimension *)NULL);
749N/A RefigureLocationsAndCommit(new);
749N/A return(TRUE); /* We have done a full configuration, return.*/
749N/A }
749N/A
749N/A if ( (old_pw->paned.grip_indent != new_pw->paned.grip_indent) &&
749N/A (XtIsRealized(new)) ) {
749N/A CommitNewLocations(new_pw);
749N/A redisplay = TRUE;
749N/A }
749N/A
749N/A return (redisplay);
749N/A} /* SetValues */
749N/A
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean
749N/APaneSetValues(old, request, new, args, num_args)
749N/AWidget old, request, new;
749N/AArgList args;
749N/ACardinal *num_args;
749N/A{
749N/A Pane old_pane = PaneInfo(old);
749N/A Pane new_pane = PaneInfo(new);
749N/A Boolean redisplay = FALSE;
749N/A
749N/A /* Check for new min and max. */
749N/A
749N/A if (old_pane->min != new_pane->min || old_pane->max != new_pane->max)
749N/A XawPanedSetMinMax(new, (int)new_pane->min, (int)new_pane->max);
749N/A
749N/A /* Check for change in XtNshowGrip. */
749N/A
749N/A if (old_pane->show_grip != new_pane->show_grip)
749N/A if (new_pane->show_grip == TRUE) {
749N/A CreateGrip(new);
749N/A if (XtIsRealized(XtParent(new))) {
749N/A if (XtIsManaged(new)) /* if paned is unrealized this will
749N/A happen automatically at realize time.*/
749N/A XtManageChild(PaneInfo(new)->grip); /* manage the grip. */
749N/A XtRealizeWidget(PaneInfo(new)->grip); /* realize the grip. */
749N/A CommitNewLocations( (PanedWidget) XtParent(new) );
749N/A }
749N/A }
749N/A else if ( HasGrip(old) ) {
749N/A XtDestroyWidget( old_pane->grip );
749N/A new_pane->grip = NULL;
749N/A redisplay = TRUE;
749N/A }
749N/A
749N/A /* ||| need to look at position changes */
749N/A
749N/A return(redisplay);
749N/A}
749N/A
749N/A/************************************************************
749N/A *
749N/A * Public routines.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: XawPanedSetMinMax
749N/A * Description: Sets the min and max size for a pane.
749N/A * Arguments: widget - the widget that is a child of the Paned widget.
749N/A * min, max - the new min and max size for the pane.
749N/A * Returns: none.
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawPanedSetMinMax(Widget widget, int min, int max)
749N/A#else
749N/AXawPanedSetMinMax(widget, min, max)
749N/AWidget widget;
749N/Aint min, max;
749N/A#endif
749N/A{
749N/A Pane pane = PaneInfo(widget);
749N/A
749N/A pane->min = min;
749N/A pane->max = max;
749N/A RefigureLocationsAndCommit( widget->core.parent );
749N/A}
749N/A
749N/A/* Function Name: XawPanedGetMinMax
749N/A * Description: Gets the min and max size for a pane.
749N/A * Arguments: widget - the widget that is a child of the Paned widget.
749N/A ** RETURNED ** min, max - the current min and max size for the pane.
749N/A * Returns: none.
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawPanedGetMinMax(Widget widget, int *min, int *max)
749N/A#else
749N/AXawPanedGetMinMax(widget, min, max)
749N/AWidget widget;
749N/Aint *min, *max;
749N/A#endif
749N/A{
749N/A Pane pane = PaneInfo(widget);
749N/A
749N/A *min = pane->min;
749N/A *max = pane->max;
749N/A}
749N/A
749N/A/* Function Name: XawPanedSetRefigureMode
749N/A * Description: Allows a flag to be set the will inhibit
749N/A * the paned widgets relayout routine.
749N/A * Arguments: w - the paned widget.
749N/A * mode - if FALSE then inhibit refigure.
749N/A * Returns: none.
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawPanedSetRefigureMode(Widget w,
749N/A#if NeedWidePrototypes
749N/A int mode)
749N/A#else
749N/A Boolean mode)
749N/A#endif
749N/A#else
749N/AXawPanedSetRefigureMode(w, mode)
749N/AWidget w;
749N/ABoolean mode;
749N/A#endif
749N/A{
749N/A ((PanedWidget) w)->paned.refiguremode = mode;
749N/A RefigureLocationsAndCommit( w );
749N/A}
749N/A
749N/A/* Function Name: XawPanedGetNumSub
749N/A * Description: Returns the number of panes in the paned widget.
749N/A * Arguments: w - the paned widget.
749N/A * Returns: the number of panes in the paned widget.
749N/A */
749N/A
749N/Aint
749N/A#if NeedFunctionPrototypes
749N/AXawPanedGetNumSub(Widget w)
749N/A#else
749N/AXawPanedGetNumSub(w)
749N/AWidget w;
749N/A#endif
749N/A{
749N/A return ((PanedWidget)w)->paned.num_panes;
749N/A}
749N/A
749N/A/* Function Name: XawPanedAllowResize
749N/A * Description: Allows a flag to be set that determines if the paned
749N/A * widget will allow geometry requests from this child
749N/A * Arguments: widget - a child of the paned widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawPanedAllowResize(Widget widget,
749N/A#if NeedWidePrototypes
749N/A int allow_resize)
749N/A#else
749N/A Boolean allow_resize)
749N/A#endif
749N/A#else
749N/AXawPanedAllowResize(widget, allow_resize)
749N/AWidget widget;
749N/ABoolean allow_resize;
749N/A#endif
749N/A{
749N/A PaneInfo(widget)->allow_resize = allow_resize;
749N/A}