# Paned Widget

    Application Header file	<X11/Xaw/Paned.h>

    Class Header file	<X11/Xaw/PanedP.h>

    Class		panedWidgetClass

    Class Name	Paned

    Superclass	Constraint

The Paned widget manages children in a vertically or horizontally tiled fashion. The panes may be dynamically resized by the user by using the grips that appear near the right or bottom edge of the border between two panes.

The Paned widget may accept any widget class as a pane `except` Grip. Grip widgets have a special meaning for the Paned widget, and adding a Grip as its own pane will confuse the Paned widget.

## Using the Paned Widget

The grips allow the panes to be resized by the user. The semantics of how these panes resize is somewhat complicated, and warrants further explanation here. When the mouse pointer is positioned on a grip and pressed, an arrow is displayed that indicates the pane that is to be to be resized. While keeping the mouse button down, the user can move the grip up and down (or left and right). This, in turn, changes the size of the pane. The size of the Paned widget will not change. Instead, it chooses another pane (or panes) to resize. For more details on which pane it chooses to resize, see `Layout Semantics`.

One pointer binding allows the border between two panes to be moved, without affecting any of the other panes. When this occurs the pointer will change to an arrow that points along the pane border.

The default bindings for the Paned widget's grips are:

Mouse button | Pane to Resize - Vertical | Pane to Resize - Horizontal
--- | --- | ---
1 (left) | above the grip | left of the grip
2 (middle) | adjust border | adjust border
3 (right) | below the grip | right of the grip
_

## Resources

When creating a Paned widget instance, the following resources are retrieved from the argument list or the resource database:

Name | Class | Type | Notes | Default Value
--- | --- | --- | --- | ---
accelerators | Accelerators | AcceleratorTable |  | NULL
ancestorSensitive | AncestorSensitive | Boolean | D | True
background | Background | Pixel |  | XtDefaultBackground
backgroundPixmap | Pixmap | Pixmap |  | XtUnspecifiedPixmap
betweenCursor | Cursor | Cursor | A | Depends on orientation
borderColor | BorderColor | Pixel |  | XtDefaultForeground
borderPixmap | Pixmap | Pixmap |  | XtUnspecifiedPixmap
borderWidth | BorderWidth | Dimension |  | 1
children | ReadOnly | WidgetList | R | NULL
colormap | Colormap | Colormap |  | Parent's Colormap
cursor | Cursor | Cursor |  | None
depth | Depth | int | C | Parent's Depth
destroyCallback | Callback | XtCallbackList |  | NULL
gripCursor | Cursor | Cursor | A | Depends on orientation
gripIndent | GripIndent | Position |  | 10
gripTranslations | Translations | TranslationTable |  | see below
height | Height | Dimension | A | Depends on orientation
horizontalBetweenCursor | Cursor | Cursor |  | sb_up_arrow
horizontalGripCursor | Cursor | Cursor |  | sb_h_double_arrow
internalBorderColor | BorderColor | Pixel |  | XtDefaultForeground
internalBorderWidth | BorderWidth | Dimension |  | 1
leftCursor | Cursor | Cursor |  | sb_left_arrow
lowerCursor | Cursor | Cursor |  | sb_down_arrow
mappedWhenManaged | MappedWhenManaged | Boolean |  | True
numChildren | ReadOnly | Cardinal | R | 0
orientation | Orientation | Orientation |  | XtorientVertical
refigureMode | Boolean | Boolean |  | True
rightCursor | Cursor | Cursor |  | sb_right_arrow
screen | Screen | Screen | R | Parent's Screen
sensitive | Sensitive | Boolean |  | True
translations | Translations | TranslationTable |  | NULL
upperCursor | Cursor | Cursor |  | sb_up_arrow
verticalBetweenCursor | Cursor | Cursor |  | sb_left_arrow
verticalGripCursor | Cursor | Cursor |  | sb_v_double_arrow
width | Width | Dimension | A | Depends on orientation
x | Paned | Position |  | 0
y | Paned | Position |  | 0
_

`cursor`

  The cursor to use when the mouse pointer is over the Paned widget, but not in any of its children (children may also inherit this cursor). It should be noted that the internal borders are actually part of the Paned widget, not the children.

`gripCursor`

  The cursor to use when the grips are not active. The default value is `verticalGripCursor` or `horizontalGripCursor` depending on the orientation of the Paned widget.

`gripIndent`

  The amount of space left between the right (or bottom) edge of the Paned widget and all the grips.

`gripTranslation`

  Translation table that will be applied to all grips.

`horizontalBetweenCursor`

`verticalBetweenCursor`

  The cursor to be used for the grip when changing the boundary between two panes. These resources allow the cursors to be different depending on the orientation of the Paned widget.

`horizontalGripCursor`

`verticalGripCursor`

  The cursor to be used for the grips when they are not active. These resources allow the cursors to be different depending on the orientation of the Paned widget.

`internalBorderColor`

  A pixel value which indexes the widget's colormap to derive the internal border color of the widget's window. The class name of this resource allows Paned*BorderColor: blue to set the internal border color for the Paned widget. An optimization is invoked if `internalBorderColor` and `background` are the same, and the internal borders are not drawn. `internalBorderWidth` is still left between the panes, however.

`internalBorderWidth`

  The width of the internal borders. This is the amount of space left between the panes. The class name of this resource allows Paned*BorderWidth: 3 to set the internal border width for the Paned widget.

`leftCursor`

`rightCursor`

  The cursor used to indicate which is the important pane to resize when the Paned widget is oriented horizontally.

`lowerCursor`

`upperCursor`

  The cursor used to indicate which is the important pane to resize when the Paned widget is oriented vertically. This is not the same as the number of panes, since this also contains a grip for some of the panes, use to retrieve the number of panes.

`orientation`

  The orientation to stack the panes. This value can be either `XtorientVertical` or `XtorientHorizontal`.

`refigureMode`

  This resource allows pane layout to be suspended. If this value is `False`, then no layout actions will be taken. This may improve efficiency when adding or removing more than one pane from the Paned widget.

## Constraint Resources

Each child of the Paned widget may request special layout resources be applied to it. These constraint resources allow the Paned widget's children to specify individual layout requirements.

Name | Class | Type | Notes | Default Value
--- | --- | --- | --- | ---
allowResize | Boolean | Boolean |  | False
max | Max | Dimension |  | Infinity
min | Min | Dimension |  | Height of Grips
preferredPaneSize | PreferredPaneSize | Dimension |  | ask child
resizeToPreferred | Boolean | Boolean |  | False
showGrip | ShowGrip | Boolean |  | True
skipAdjust | Boolean | Boolean |  | False
_

`allowResize`

  If this value is `False` the the Paned widget will disallow all geometry requests from this child.

`max`

`min`

  The absolute maximum or minimum size for this pane. These values will never be overridden by the Paned widget. This may cause some panes to be pushed off the bottom (or right) edge of the paned widget.

`preferredPaneSize`

  Normally the paned widget makes a QueryGeometry call on a child to determine the preferred size of the child's pane. There are times when the application programmer or the user has a better idea of the preferred size of a pane. Setting this resource causes the value passed to be interpreted as the preferred size, in pixels, of this pane.

`resizeToPreferred`

  Determines whether or not to resize each pane to its preferred size when the Paned widget is resized. See `Layout Semantics` for details.

`showGrip`

  If `True` then a grip will be shown for this pane. The grip associated with a pane is either below or to the right of the pane. No grip is ever shown for the last pane.

`skipAdjust`

  This resource is used to determine which pane is forced to be resized. Setting this value to `True` makes this pane less likely to be forced to be resized. See `Layout Semantics` for details.

## Layout Semantics

In order to make effective use of the Paned widget it is helpful to know the rules it uses to determine which child will be resized in any given situation. There are three rules used to determine which child is resized. While these rules are always the same, the panes that are searched can change depending upon what caused the relayout.

`Layout Rules`

`1`

  Do not let a pane grow larger than its `max` or smaller than its `min`.

`2`

  Do not adjust panes with `skipAdjust` set.

`3`

  Do not adjust panes away from their preferred size, although moving one closer to its preferred size is fine.

When searching the children the Paned widget looks for panes that satisfy all the rules, and if unsuccessful then it eliminates rule 3 and then 2. Rule 1 is always enforced.

If the relayout is due to a resize or change in management then the panes are searched from bottom to top. If the relayout is due to grip movement then they are searched from the grip selected in the direction opposite the pane selected.

### Resizing Panes from a Grip Action

The pane above the grip is resized by invoking the GripAction with `UpLeftPane` specified. The panes below the grip are each checked against all rules, then rules 2 and 1 and finally against rule 1 only. No pane above the chosen pane will ever be resized.

The pane below the grip is resized by invoking the GripAction with `LowRightPane` specified. The panes above the grip are each checked in this case. No pane below the chosen pane will ever be resized.

Invoking GripAction with `ThisBorderOnly` specified just moves the border between the panes. No other panes are ever resized.

### Resizing Panes after the Paned widget is resized.

When the Pane widget is resized it must determine a new size for each pane. There are two methods of doing this. The Paned widget can either give each pane its preferred size and then resize the panes to fit, or it can use the current sizes and then resize the panes to fit. The `resizeToPreferred` resource allows the application to tell the Paned widget whether to query the child about its preferred size (subject to the the `preferredPaneSize`) or to use the current size when refiguring the pane locations after the pane has been resized.

There is one special case. All panes assume they should resize to their preferred size until the Paned widget becomes visible to the user.

### Managing Children and Geometry Management

The Paned widget always resizes its children to their preferred sizes when a new child is managed, or a geometry management request is honored. The Paned widget will first attempt to resize itself to contain its panes exactly. If this is not possible then it will hunt through the children, from bottom to top (right to left), for a pane to resize.

### Special Considerations

When a user resizes a pane with the grips, the Paned widget assumes that this new size is the preferred size of the pane.

## Grip Translations

The Paned widget has no action routines of its own, as all actions are handled through the grips. The grips are each assigned a default Translation table.

    	<Btn1Down>:	GripAction(Start, UpLeftPane)

    	<Btn2Down>:	GripAction(Start, ThisBorderOnly)
    	<Btn3Down>:	GripAction(Start, LowRightPane)
    	<Btn1Motion>:	GripAction(Move, UpLeftPane)
    	<Btn2Motion>:	GripAction(Move, ThisBorderOnly)
    	<Btn3Motion>:	GripAction(Move, LowRightPane)
    	Any<BtnUp>:	GripAction(Commit)

The Paned widget interprets the `GripAction` as taking two arguments. The first argument may be any of the following:

`Start`

  Sets up the Paned widget for resizing and changes the cursor of the grip. The second argument determines which pane will be resized, and can take on any of the three values shown above.

`Move`

  The internal borders are drawn over the current pane locations to animate where the borders would actually be placed if you were to move this border as shown. The second argument must match the second argument that was passed to the `Start` action, that began this process. If these arguments are not passed, the behavior is undefined.

`Commit`

  This argument causes the Paned widget to commit the changes selected by the previously started action. The cursor is changed back to the grip's inactive cursor. No second argument is needed in this case.

## Convenience Routines

To enable or disable a child's request for pane resizing, use `XawPanedAllowResize :`

      void XawPanedAllowResize
      Widget w
      Boolean allow_resize

w

  Specifies the child pane.

allow_resize

  Specifies whether or not resizing requests for this child will be granted by the Paned widget.

If allow_resize is `True`, the Paned widget allows geometry requests from the child to change the pane's height. If allow_resize is `False`, the Paned widget ignores geometry requests from the child to change the pane's height. The default state is `True` before the Pane is realized and `False` after it is realized. This procedure is equivalent to changing the `allowResize` constraint resource for the child.

To change the minimum and maximum height settings for a pane, use `XawPanedSetMinMax :`

      void XawPanedSetMinMax
      Widget w
      intmin, max

w

  Specifies the child pane.

min

  Specifies the new minimum height of the child, expressed in pixels.

max

  Specifies new maximum height of the child, expressed in pixels.

This procedure is equivalent to setting the `min` and `max` constraint resources for the child.

To retrieve the minimum and maximum height settings for a pane, use `XawPanedGetMinMax :`

      void XawPanedGetMinMax
      Widget w
      int*min_return, *max_return

w

  Specifies the child pane.

min_return

  Returns the minimum height of the child, expressed in pixels.

max_return

  Returns the maximum height of the child, expressed in pixels.

This procedure is equivalent to getting the `min` and `max` resources for this child child.

To enable or disable automatic recalculation of pane sizes and positions, use `XawPanedSetRefigureMode :`

      void XawPanedSetRefigureMode
      Widget w
      Boolean mode

w

  Specifies the Paned widget.

mode

  Specifies whether the layout of the Paned widget is enabled (`True`) or disabled (`False`).

When making several changes to the children of a Paned widget after the Paned has been realized, it is a good idea to disable relayout until after all changes have been made.

To retrieve the number of panes in a paned widget use :

      int XawPanedGetNumSub
      Widget w

w

  Specifies the Paned widget.

This function returns the number of panes in the Paned widget. This is `not` the same as the number of children, since the grips are also children of the Paned widget.