749N/A/* $XConsortium: Paned.c,v 1.27 94/04/17 20:12:28 kaleb Exp $ */ 749N/A/*********************************************************** 749N/ACopyright (c) 1987, 1988, 1994 X Consortium 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/AThe above copyright notice and this permission notice shall be included in 749N/Aall copies or substantial portions of the Software. 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/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/ACopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 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/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/A******************************************************************/ 749N/A * Updated and significantly modified from the Athena VPaned Widget. 749N/A * By: Chris D. Peterson 749N/A/* I don't know why Paned.c calls _XawImCallVendorShellExtResize, but... */ 749N/A/***************************************************************************** 749N/A * Full instance record declaration 749N/A ****************************************************************************/ 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 /* Cursors - both horiz and vertical have to work. */ 749N/A /* class name */ "Paned",
749N/A/* composite class fields */ 749N/A/* constraint class fields */ 749N/A/* For compatibility. */ 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/* 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 * vertical - return height 749N/A * !vertical - return width 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/* Function Name: ChoosePaneToResize. 749N/A * Description: This function chooses a pane to resize. 749N/A * They are chosen using the following rules: 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 * If no widgets are found that fits all the rules then 749N/A * If there are still no widgets found than 749N/A * Rule #1 is never broken. 749N/A * If no widgets are found then NULL is returned. 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 * 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 * 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/* 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/* 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/* 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/* 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 * 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 * 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 return;
/* no one to resize, give up. */ 749N/A * Try to resize this pane so that all panes will fit, take min and max 749N/A }
/* don't remove these braces. */ 749N/A }
/* don't remove these braces. */ 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 * There are special arguments to paneindex and dir, they are: 749N/A * paneindex - NO_INDEX. 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 * Get an initial estimate of the size we will use. 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 * It is possible that the panes will not fit inside the vpaned widget, but 749N/A * we have tried out best. 749N/A * Assign each pane a location. 749N/A/* Function Name: CommitNewLocations 749N/A * Description: Commits all of the previously figured locations. 749N/A * Arguments: pw - the paned widget. 749N/A * This should match XtMoveWidget, except that we're also insuring the 749N/A * grip is Raised in the same request. 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 * 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 * NOTE: This is the resize Procedure for the Paned widget. 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/* 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 * This is an optimization. Do not paint the internal borders if 749N/A * they are the same color as the background. 749N/A * This allows good reuse of code, as well as descriptive function names. 749N/A/* Function Name: _DrawTrackLines 749N/A * Description: Draws the lines that animate the pane borders when the 749N/A * Arguments: pw - the Paned widget. 749N/A * erase - if True then just erase track lines, else 749N/A * This allows good reuse of code, as well as descriptive function names. 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/* 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/* 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 * loc - location of pointer in proper direction. 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/* Function Name: CommitGripAdjustment 749N/A * Description: Commits the grip adjustment. 749N/A * Arguments: pw - the paned widget. 749N/A * Since the user selected this size then use it as the preferred size. 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 XtError(
"Paned GripAction has been passed incorrect parameters." );
749N/A case 'S':
/* Start adjustment */ 749N/A/* Function Name: ResortChildren 749N/A * Description: Resorts the children so that all managed children 749N/A * Arguments: pw - the paned widget. 749N/A * We only keep track of the first unmanaged pane. 749N/A else {
/* must be a managed pane */ 749N/A * If an earlier widget was not a managed pane, then swap 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/* 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/* Function Name: GetGCs 749N/A * Description: Gets new GC's. 749N/A * Arguments: w - the paned widget. 749N/A * Draw pane borders in internal border color. 749N/A * Erase pane borders with background color. 749N/A * Draw Track lines (animate pane borders) in internal border color ^ bg color. 749N/A/* Function Name: SetChildrenPrefSizes. 749N/A * Description: Sets the preferred sizes of the children. 749N/A * Arguments: pw - the paned widget. 749N/A/* Function Name: ChangeAllGripCursors 749N/A * Description: Changes all the grip cursors. 749N/A * Arguments: pw - the paned widget. 749N/A/************************************************************ 749N/A * Stack Manipulation routines (Private). 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/* 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 * ** RETURNED ** pane - the pane that we are popping. 749N/A * ** RETURNED ** start_size - the size that this pane started at. 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/* Function Name: ClearPaneStack 749N/A * Description: removes all entries from the pane stack. 749N/A * Arguments: pw - the paned widget. 749N/A/************************************************************ 749N/A * Semi-public routines. 749N/A ************************************************************/ 749N/A/* Function Name: ClassInitialize 749N/A * Description: The Paned widgets class initialization proc. 749N/A/* The Geometry Manager only allows changes after Realize if 749N/A * allow_resize is True in the constraints record. 749N/A * For vertically paned widgets: 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 * 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 * If any of the following is true, disallow the geometry change. 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 * Fool the Refigure Locations proc to thinking that we are 749N/A * Set up reply struct and reset core on_size. 749N/A * IF either of the following is true. 749N/A * o There was a "off_size" request and the new "off_size" is different 749N/A * o There was no "off_size" request and the new "off_size" is different 749N/A * o The "on_size" we will allow is different from that requested. 749N/A * Before we commit the new locations we need to realize all the panes and 749N/A /* insert the child widget in the composite children list with the */ 749N/A /* superclass insert_child routine. */ 749N/A /* ||| Panes will be added in the order they are created, temporarily */ 749N/A /* remove the subwidget info and destroy the grip */ 749N/A /* delete the child widget in the composite children list with the */ 749N/A /* superclass delete_child routine. */ 749N/A * If the size is zero then set it to the size of the widest or tallest pane. 749N/A break;
/* This list is already sorted. */ 749N/A * ForAllPanes can now be used. 749N/A/* Function Name: Resize 749N/A * Description: The paned widget's resize proc. 749N/A * Arguments: w - the paned widget. 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 return(
TRUE);
/* We have done a full configuration, return.*/ 749N/A /* Check for new min and max. */ 749N/A /* Check for change in XtNshowGrip. */ 749N/A happen automatically at realize time.*/ 749N/A /* ||| need to look at position changes */ 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/* 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/* 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/* 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/* 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.