Generic superclass for list and tree widgets
PtWidget --> PtBasic --> PtContainer --> PtCompound --> PtGenList
For more information, see the diagram of the widget hierarchy.
None - not normally instantiated.
<photon/PtGenList.h>
The PtGenList class is a superclass for creating list widgets. It's discussed in more detail in Building Custom Widgets.
PtGenList handles a vertical, left-aligned list of rectangular items that may have different sizes. You can select one or more items, depending on the selection policy (see Pt_ARG_SELECTION_MODE).
PtGenListItem_t is the data structure used for the items.
A PtGenList widget can have one child, provided it's a PtDivider widget. In this case, PtGenList attaches a callback to the child so that the columns are set automatically to match the children of PtDivider The items are drawn below the PtDivider widget. Some child classes of PtGenList, such as PtList and PtTree, use Tab characters as column separators.
The PtGenList widget creates a scroll bar if the list's area isn't large enough to display all the items in the list. By default, the scroll bar is displayed only when necessary. This behavior is controlled by the Pt_LIST_SCROLLBAR_ALWAYS and (the default) Pt_LIST_SCROLLBAR_AS_REQUIRED bits in the Pt_ARG_LIST_FLAGS resource.
Mouse actions depend on the current selection mode.
Button action | Result |
---|---|
Press | Result depends on the value of Pt_ARG_SELECTION_MODE |
Release | Invokes callbacks. |
Keyboard actions depend on the current selection mode.
Key | Action |
---|---|
Enter | Result depends on value of Pt_ARG_SELECTION_MODE |
/\ | Previous item |
\/ | Next item |
Pg Up | Previous page |
Pg Dn | Next page |
Home | First item |
End | Last item |
Resource | C type | Pt type | Default |
---|---|---|---|
Pt_ARG_BALLOON_COLOR | PgColor_t | Scalar | Pg_BLACK |
Pt_ARG_BALLOON_FILL_COLOR | PgColor_t | Scalar | See below |
Pt_ARG_LIST_COLUMN_ATTR | PtListColumnAttributes_t *, short | Array | NULL |
Pt_ARG_LIST_COLUMN_POS | PtListColumn_t *, short | Array | NULL |
Pt_ARG_LIST_FLAGS | unsigned short | Flag | See below |
Pt_ARG_LIST_FONT | char * | String | "helv12" |
Pt_ARG_LIST_ITEM_COUNT | unsigned short | Scalar | 0 (read-only) |
Pt_ARG_LIST_SB_RES | PtArg_t, int | Array | |
Pt_ARG_LIST_SCROLL_RATE | short | Scalar | 2 |
Pt_ARG_LIST_SEL_COUNT | unsigned short | Scalar | 0 (read-only) |
Pt_ARG_LIST_TOTAL_HEIGHT | unsigned | Scalar | 0 (read-only) |
Pt_ARG_SCROLLBAR_WIDTH | unsigned short | Scalar | 0 (see below) |
Pt_ARG_SELECTION_FILL_COLOR | PgColor_t | Scalar | Pg_BLUE |
Pt_ARG_SELECTION_MODE | unsigned short | Scalar | See below |
Pt_ARG_SELECTION_TEXT_COLOR | PgColor_t | Scalar | Pg_WHITE |
Pt_ARG_TOP_ITEM_POS | unsigned short | Scalar | 1 |
Pt_ARG_VISIBLE_COUNT | unsigned short | Scalar | 0 (read-only) |
Pt_CB_SCROLL_MOVE | PtCallback_t * | Link | NULL |
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_BLACK |
The balloon's text color.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_BALLOONCOLOR |
The balloon's fill color.
C type | Pt type | Default |
---|---|---|
PtListColumnAttributes_t *, short | Array | NULL |
An array of PtListColumnAttributes_t structures, each containing at least the following:
The Pt_LIST_COLUMN_DAMAGE_ALWAYS flag tells the widget to redraw the column when the column's position or size changes, even if it doesn't seem necessary. For example, if a right-aligned column is made narrower but its right edge doesn't move, there's no need to redraw the column. The flag can be set to force a redraw, which needs to be done if the column contains some elements that aren't right-aligned. This flag is usually set by the child class of PtGenList that knows what's drawn in the columns.
C type | Pt type | Default |
---|---|---|
PtListColumn_t *, short | Array | NULL |
An array of PtListColumn_t column structures. The structure contains at least the following:
C type | Pt type | Default |
---|---|---|
unsigned short | Flag | Pt_LIST_BALLOONS_IN_COLUMNS | Pt_LIST_SCROLLBAR_AS_REQUIRED |
Flags that control the appearance and behavior of the list. The possible values are:
If this flag is set, a cursor key event is consumed only if it actually changes the current item. For example, an /\ or Home event won't be consumed if the first item in the list is already the current item.
C type | Pt type | Default |
---|---|---|
char * | String | "helv12" |
The font used for the items in the list.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 |
The number of items.
C type | Pt type | Default |
---|---|---|
PtArg_t | Array |
An array of PtArg_t records that are passed to the scrollbar. Note that only a selected set of resources can be modified: the PtGenList widget won't let you modify resources that might affect the position or size of the scrollbar. The main purpose of this resource is to change the colors of the scrollbar.
To get the Pt_ARG_LIST_SB_RES resource, the application must supply a buffer and pass its address and length to the PtSetArg() macro.
An equivalent of:
PtGetResources( scrollbar, N, args );
would be:
PtArg_t tmp; PtSetArg( &tmp, Pt_ARG_LIST_SB_RES, args, N ); PtGetResources( list, 1, &tmp );
C type | Pt type | Default |
---|---|---|
short | Scalar | 2 |
If you drag in a list and move outside the widget, the list scrolls at a rate determined by the number of "button repeats". This resource specifies the number of button repeats that must be received before scrolling occurs. The default value is 2. To make the scrolling faster, set this resource to 1; to make scrolling slower, set this resource to a larger number.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 |
The number of selected items.
C type | Pt type | Default |
---|---|---|
unsigned | Scalar | 0 |
The total height (in pixels) of all items.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 (see below) |
The width of the accompanying scrollbar, if displayed. The minimum width is 6 pixels. If you set this resource to 0, the default width of 15 is used.
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_BLUE |
The fill color for selected items.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | See below |
The selection mode. PtGenList supports the selection of items using the mouse or the keyboard. The descriptions below assume the user will be using a mouse. If a mouse isn't available, the /\ and \/ keys on the numeric pad can be used to highlight items in a list. The current selection is accepted by the widget when Enter is pressed.
The PtGenList widget supports several "predefined" selection modes, but you can also set "compose selection modes" using special flag values. To define a compose mode, start with one of the following values, which describe what kind of sets of items can be selected:
You can OR one of these values with zero or more of the following flags, which describe how the mouse and keyboard should work:
Note that zero isn't a valid value for the selection mode, neither is a mixture of predefined and compose values.
The "predefined" selection modes are equivalent to the following compose modes:
C type | Pt type | Default |
---|---|---|
PgColor_t | Scalar | Pg_WHITE |
The text color for selected items.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 1 |
The item index that appears at the top of the list. (The first item is 1.) Note that unless the widget has been held (using PtContainerHold()), setting the Pt_ARG_TOP_ITEM_POS resource will cause the widget to draw if damaged and possibly blit afterwards. The widget doesn't blit when its fill color is set to Pg_TRANSPARENT.
C type | Pt type | Default |
---|---|---|
unsigned short | Scalar | 0 |
The number of items currently visible.
C type | Pt type | Default |
---|---|---|
PtCallback_t * | Link | NULL |
The list of callbacks that the widget invokes when the top item position changes.
If the widget has the Pt_CALLBACKS_ACTIVE bit set in its Pt_ARG_FLAGS resource, this callback is also invoked when the top item position (Pt_ARG_TOP_ITEM_POS) is changed by a call to PtSetResources().
Each callback is passed a PtCallbackInfo_t structure that contains at least the following members:
The action field can be one of the following:
These callbacks should return Pt_CONTINUE.
If the widget modifies an inherited resource, the "Default override" column indicates the new value. This modification affects any subclasses of the widget.
Most of PtGenList's convenience functions are useful only if you're creating a custom list widget; they're described in the Creating a List Widget chapter of the Building Custom Widget manual.
The following convenience functions and data structure are useful when working with descendants of PtGenList: