PtDivider

A container that divides space among its children

Class hierarchy:

PtWidgetPtBasicPtContainerPtCompoundPtDivider

For more information, see the diagram of the widget hierarchy.

PhAB icon:

PtDivider button in PhAB

Public header:

<photon/PtDivider.h>

Description:

The PtDivider widget is a container that lays out its children like a one-row or one-column PtGroup widget, but lets you resize the children by dragging “handles” placed between the children.


PtDivider


Two PtDivider widgets: one contains two lists, the other contains some buttons.

The PtDivider class inherits resources from the PtGroup class. Access to these resources is controlled through PtDivider's exporting mechanism.

A blocking mechanism lets PtDivider block the inheritance of certain resources from its subordinate PtGroup widget. This prevents any actions that would negatively affect the look and behavior of a PtDivider widget. For more information, see the Exported subordinate children section.

Examples

In this example, we use the Pt_CB_DIVIDER_HANDLE_CALLBACK callback to set the default widget sizes:

static int default_sizes[] = { 100, 50, 60, 200, ... };


int drag_handle_cb( PtWidget_t *dvdr, ApInfo_t *data,
    PtCallbackInfo_t *cbinfo ) ) {

        PtDividerHandleCallback_t  *cbdata = cbinfo->cbdata;
        PhEvent_t                  *ev = cbinfo->event;
        PhPointerEvent_t           *pe = PhGetData( ev );

        if( ev->type == Ph_EV_BUT_RELEASE
            && ev->subtype == Ph_EV_RELEASE_REAL
            && pe->click_count == 2

        ) {

            // Set the default size on a double click

            PtSetResource( cbdata->left, Pt_ARG_WIDTH,
                default_sizes[cbdata->index], 0 );

       }

}

New resources:

Resource C type Pt type Default
Pt_ARG_DIVIDER_FLAGS unsigned short Flag Pt_DIVIDER_RESIZE_BOTH
Pt_ARG_DIVIDER_OFFSET short Scalar 0
Pt_ARG_DIVIDER_SIZES PtDividerSizes_t *, short Array NULL, 0 (read-only)
Pt_CB_DIVIDER_DRAG PtCallback_t * Link NULL
Pt_CB_DIVIDER_HANDLE_CALLBACK PtCallback_t * Link NULL

Pt_ARG_DIVIDER_FLAGS

C type Pt type Default
unsigned short Flag Pt_DIVIDER_RESIZE_BOTH

Possible values:

Pt_DIVIDER_NORESIZE
Don't resize the children, just invoke the callback.
Pt_DIVIDER_RESIZE_BOTH
Resize both widgets: the one to the left and to the right (or above and below) the dragged handle. If this flag isn't set, only the left child is resized and the right child is moved.
Pt_DIVIDER_INVISIBLE
Never display the drag outline. This flag is useful mainly when Pt_DIVIDER_NORESIZE is also set.
Pt_DIVIDER_CASCADE
The re-sizing of a widget is “cascaded” to adjacent widgets when the widget has reached it's minimum size. At that point the adjacent widget starts to shrink until it reaches its minimum size, and then its neighbor is resized, and so on.
Pt_DIVIDER_LAST_IS_SPACER
Useful when the divider is in a PtList widget with a horizontal scrollbar. The last widget is a spacer. When the Pt_CB_DIVIDER_DRAG callback is invoked, this widget's size is always reported as 1, regardless of its actual size.
Pt_DIVIDER_NODRAG
The divider handles can't be dragged. They don't display a drag cursor when the pointer is hovering over them.

Pt_ARG_DIVIDER_OFFSET

C type Pt type Default
short Scalar 0

This number is added to positions of child widgets (relative to the position of the PtDivider widget) when the values for the Pt_ARG_DIVIDER_SIZES resource are calculated. By setting Pt_ARG_DIVIDER_OFFSET, you can make the Pt_ARG_DIVIDER_SIZES relative to any arbitrary point.

Pt_ARG_DIVIDER_SIZES (read-only)

C type Pt type Default
PtDividerSizes_t *, short Array NULL, 0

The array of positions and sizes of realized children of the divider. Each PtDividerSizes_t structure contains:

short from
The left side or top of the child, depending on the divider's orientation.
short to
The right or bottom of the child, depending on the divider's orientation.

Pt_CB_DIVIDER_DRAG

C type Pt type Default
PtCallback_t * Link NULL

A list of PtCallback_t structures that define the callbacks that are invoked when the widget receives a drag event.

If the widget has the Pt_CALLBACKS_ACTIVE bit set in its Pt_ARG_FLAGS resource, these callbacks are also invoked when your application changes the size of a child by calling PtSetResource() or PtSetResources().

Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:

reason
Pt_CB_DIVIDER_DRAG
reason_subtype
The subtype of the drag event (see Ph_EV_DRAG in the description of the PhEvent_t structure in the Photon Library Reference), or Pt_CB_DIVIDER_SETRESOURCES if a child is being resized through PtSetResources() and the widget has the Pt_CALLBACKS_ACTIVE bit set in its Pt_ARG_FLAGS resource.
event
A pointer to a PhEvent_t structure that describes the received drag event, or NULL if a child is being resized through a call to PtSetResources().
cbdata
A pointer to a PtDividerCallback_t structure that contains at least the following members:
PtWidget_t *left, *right;
The two widgets in the group separated by the divider.
int moved;
How far the widget on the right has been moved.
int resized;
The amount by which the widget on the left has been resized.
PtDividerSizes_t const *sizes;
The new value of the Pt_ARG_DIVIDER_SIZES resource.
int nsizes;
The number of items in the sizes array.

These callbacks should return Pt_CONTINUE.

Pt_CB_DIVIDER_HANDLE_CALLBACK

C type Pt type Default
PtCallback_t * Link NULL

A list of PtCallback_t structures that define the callbacks that are invoked when you press the pointer button when pointing at widget's resize handles, and also when the button is released.

Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:

reason
Pt_CB_DIVIDER_HANDLE_CALLBACK
reason_subtype
0 (not used).
event
A pointer to a PhEvent_t structure that describes the received pointer event.
cbdata
A pointer to a PtDividerHandleCallback_t structure that contains at least the following members:
int start_drag
Set to 1 when a drag operation is requested on a click; you can set to 0 to decline the drag operation.
int index
The drag handle index.
PtWidget_t *handle
The drag handle.
PtWidget_t *left, *right;
The two widgets in the group separated by the divider.

These callbacks should return Pt_CONTINUE.

Exported subordinate children:

Unless the resources are already defined in PtDivider, the PtDivider class uses the resources of its exported subordinate child, PtGroup.

Where PtDivider and PtGroup both define resources having the same name, the resource defined in PtDivider takes precedence.

Inherited resources:

If PtDivider modifies an inherited resource, the “Default override” column indicates the new value. If PtDivider inherits a resource from PtGroup, the default value assigned by PtGroup is inherited too; the “Default override” column shows this default value.

Resource Inherited from Default override
Pt_ARG_ANCHOR_FLAGS PtWidget 0 (no anchors)
Pt_ARG_ANCHOR_OFFSETS PtWidget
Pt_ARG_AREA PtWidget
Pt_ARG_BANDWIDTH_THRESHOLD PtBasic Ph_BAUD_CONSOLE (see below)
Pt_ARG_BASIC_FLAGS PtBasic
Pt_ARG_BEVEL_WIDTH PtWidget 0
Pt_ARG_BITMAP_CURSOR PtWidget
Pt_ARG_BEVEL_COLOR PtBasic
Pt_ARG_BEVEL_CONTRAST PtBasic
Pt_ARG_COLOR PtBasic
Pt_ARG_CONTAINER_FLAGS PtContainer Sets Pt_AUTO_EXTENT and Pt_CHILD_MOVED_RESIZED
Pt_ARG_CONTRAST PtBasic
Pt_ARG_CURSOR_COLOR PtWidget
Pt_ARG_CURSOR_OVERRIDE PtContainer
Pt_ARG_CURSOR_TYPE PtWidget
Pt_ARG_DARK_BEVEL_COLOR PtBasic
Pt_ARG_DARK_FILL_COLOR PtBasic
Pt_ARG_DATA PtWidget
Pt_ARG_DIM PtWidget
Pt_ARG_EFLAGS PtWidget Clears Pt_DAMAGE_ON_FOCUS, sets Pt_CONSUME_EVENTS
Pt_ARG_EXTENT PtWidget
Pt_ARG_FILL_COLOR PtBasic
Pt_ARG_FILL_PATTERN PtBasic
Pt_ARG_FLAGS PtWidget
Pt_ARG_GRID_LAYOUT_DATA PtWidget
Pt_ARG_GROUP_FLAGS PtGroup Sets Pt_GROUP_STRETCH flag
Pt_ARG_GROUP_HORZ_ALIGN PtGroup
Pt_ARG_GROUP_ORIENTATION PtGroup Pt_GROUP_HORIZONTAL (see below)
Pt_ARG_GROUP_ROWS_COLS PtGroup Blocked by this class.
Pt_ARG_GROUP_SPACING PtGroup 0
Pt_ARG_GROUP_SPACING_X PtGroup Blocked by this class.
Pt_ARG_GROUP_SPACING_Y PtGroup Blocked by this class.
Pt_ARG_GROUP_VERT_ALIGN PtGroup 0
Pt_ARG_HEIGHT PtWidget
Pt_ARG_HELP_TOPIC PtWidget
Pt_ARG_HIGHLIGHT_ROUNDNESS PtBasic
Pt_ARG_INLINE_COLOR PtBasic
Pt_ARG_LAYOUT_DATA PtWidget
Pt_ARG_LIGHT_BEVEL_COLOR PtBasic
Pt_ARG_LIGHT_FILL_COLOR PtBasic
Pt_ARG_MARGIN_HEIGHT PtBasic
Pt_ARG_MARGIN_WIDTH PtBasic
Pt_ARG_MAXIMUM_DIM PtWidget
Pt_ARG_MINIMUM_DIM PtWidget
Pt_ARG_OUTLINE_COLOR PtBasic
Pt_ARG_POINTER PtWidget
Pt_ARG_POS PtWidget
Pt_ARG_RESIZE_FLAGS PtWidget 0
Pt_ARG_ROW_LAYOUT_DATA PtWidget
Pt_ARG_SEP_IMAGE PtSeparator
Pt_ARG_SEP_IMAGE_H_ALIGN PtSeparator
Pt_ARG_SEP_IMAGE_V_ALIGN PtSeparator
Pt_ARG_SEP_TYPE PtSeparator
Pt_ARG_STYLE PtBasic
Pt_ARG_TITLE PtContainer
Pt_ARG_TITLE_FONT PtContainer
Pt_ARG_TRANS_PATTERN PtBasic
Pt_ARG_USER_DATA PtWidget
Pt_ARG_WIDTH PtWidget
Pt_CB_ACTIVATE PtBasic
Pt_CB_ARM PtBasic
Pt_CB_BALLOONS PtContainer
Pt_CB_BLOCKED PtWidget
Pt_CB_CHILD_ADDED_REMOVED PtContainer
Pt_CB_DESTROYED PtWidget
Pt_CB_DISARM PtBasic
Pt_CB_DND PtWidget
Pt_CB_FILTER PtWidget
Pt_CB_GOT_FOCUS PtBasic
Pt_CB_HOTKEY PtWidget
Pt_CB_IS_DESTROYED PtWidget
Pt_CB_LOST_FOCUS PtBasic
Pt_CB_MENU PtBasic
Pt_CB_OUTBOUND PtWidget
Pt_CB_RAW PtWidget
Pt_CB_REALIZED PtWidget
Pt_CB_REPEAT PtBasic
Pt_CB_RESIZE PtContainer
Pt_CB_UNREALIZED PtWidget

Pt_ARG_BANDWIDTH_THRESHOLD

Defines the “graphics bandwidth” threshold that determines whether the widget resizes the children after each received drag event or only once, when the drag is completed — see PtQuerySystemInfo().

Pt_ARG_GROUP_ORIENTATION

The value of this resource can be only Pt_GROUP_HORIZONTAL or Pt_GROUP_VERTICAL.