PtDivider

PtDivider — A container with re-sizable rows or columns.

Synopsis

class PtDivider PtContainer
{
    divider_flags;     // flag  (Pt_ARG_DIVIDER_FLAGS)    
    divider_offset;    // short  (Pt_ARG_DIVIDER_OFFSET)    
    divider_sizes;     // PhPoint array  (Pt_ARG_DIVIDER_SIZES)    
}
		

Base Classes

PtWidget <-- PtBasic <-- PtContainer <-- PtDivider

Description

This widget is a container that makes adjustable rows or columns out of its child widgets, such as PtButtons or PtPanes. Its instance variables let you control how or whether the children get resized, and to find their relative positions.

[Note]

For detailed information, please refer to PtDivider in the Photon documentation.

Instance Variables

divider_flags

This instance variable specifies divider characteristics, and may be a combination of zero or more of the following flags:

ConstantDescription
Pt_DIVIDER_NORESIZEGenerates the callback without resizing children.
Pt_DIVIDER_RESIZE_BOTHON, the default, resizes the widgets on either side of the handle. OFF moves the immediately right (or bottom) children and resizes the immediately left (or top) child and the far right (or bottom) child.
Pt_DIVIDER_INVISIBLEHides the drag outline. Used with Pt_DIVIDER_NORESIZE.
Pt_DIVIDER_CASCADEInternal informational bit.

divider_offset

An integer specifying how much to offset the PtPoints in the divider_sizes array in both the x and y directions. This is used to modify the divider_sizes array, but has no effect on the positioning of the children of the PtDivider.

divider_sizes

A read-only array of PhPoints indicating the top left-hand corner of each child of the PtDivider.

Callbacks

The following callbacks are associated with this widget:

CallbackDescription
Pt_CB_DIVIDER_DRAGThis callback is generated after each drag event the widget receives.
Pt_CB_DIVIDER_SETRESOURCESThis callback is generated when the divider resources are set.

Associated Classes

PtDividerCallback, PtCallbackInfo

Example

This example, ex_PtDivider.g, is included in the product distribution.

#!/usr/cogent/bin/phgamma

/*
 * This example loads a PtDivider that holds three
 * buttons arranged vertically. 
 */
require_lisp("PhotonWidgets.lsp");
require_lisp("PhabTemplate.lsp");
PtInit(nil);

/* This function lets a button control the divider resize
 * feature (on or off), and makes the label on the button
 * change accordingly.
 */
function toggle_resize(button, division)
{
  if((button.flags & Pt_SET) != 0)
  {
	button.text_string = "Resizing\nis switched\nOFF";
	division.divider_flags = Pt_DIVIDER_NORESIZE;
  }
  else
  {
	button.text_string = "Resizing\nis switched\nON";
	division.divider_flags = cons(Pt_DIVIDER_NORESIZE, nil);
  }
}

wfile = PhabReadWidgetFile (string(_os_, "-WidgetFiles/wgt/divider.wgtw"));
window = PhabCreateWidgets(wfile, nil, nil);

win = PhabLookupWidget(window,#divider,nil);
div = PhabLookupWidget(window,#MainDivider,nil);
tbut = PhabLookupWidget(window,#DivButton2,nil);
exitbut = PhabLookupWidget(window,#DivButton3,nil);

div.divider_flags = Pt_DIVIDER_INVISIBLE;

PtAttachCallback(tbut, Pt_CB_ACTIVATE, `toggle_resize(@tbut, @div));
PtAttachCallback(exitbut, Pt_CB_ACTIVATE, #exit_program(1));

PtRealizeWidget(win);

/*
 * Assign an offset, and then print the offset and sizes.
 */
div.divider_offset = -10;
pretty_princ("Offset: ",div.divider_offset,"\n");
pretty_princ("Sizes: ",div.divider_sizes,"\n");

PtMainLoop();