List.h
declares the API that this chapter describes. For more information on lists, see the section "Lists" in the Palm OS Programmer's Companion.
ListAttrType
bit field defines the visible characteristics of the list.
typedef struct {
    UInt16 usable :1;
    UInt16 enabled :1;
    UInt16 visible :1;
    UInt16 poppedUp :1;
    UInt16 hasScrollBar :1.
    UInt16 search :1;
    UInt16 reserved :2;
} ListAttrType;
ListType
structure is defined as follows:
typedef struct {
    UInt16 id;
    RectangleType bounds;
    ListAttrType attr;
    Char ** itemsText;
    Int16 numItems;
    Int16 currentItem;
    Int16 topItem;
    FontID font;
    UInt8 reserved;
    WinHandle popupWin;
    ListDrawDataFuncPtr drawItemCallback;
} ListType;
id
| ID value, specified by the application developer. This ID value is part of the event data of lstEnterEvent and lstSelectEvent. |
bounds
| Bounds of the list, relative to the window. |
attr
|
List attributes. See ListAttrType .
|
itemsText
| Pointer to an array of pointers to the text of the choices. |
numItems
| Number of choices in the list. |
currentItem
| Currently-selected list choice (0 = first choice). |
topItem
| First choice displayed in the list. |
font
| ID of the font used to draw all list text strings. |
reserved
| Reserved for future use. |
popupWin
|
Handle of the window created when a list is displayed if the poppedUp attribute is set.
|
drawItemCallback
|
Function used to draw an item in the list. If NULL , the default drawing routine is used instead. See Application-Defined Function.
|
visible
attribute to true
.
void LstDrawList (ListType *listP)
  |
listP |
Pointer to list object (ListType). |
void LstEraseList (ListType *listP)
  |
listP |
Pointer to a list object (ListType). |
visible
attribute is set to false by this function.
Int16 LstGetNumberOfItems (const ListType *listP)
  |
listP |
Pointer to a list object (ListType). |
Int16 LstGetSelection (const ListType *listP)
noListSelection
if none of the items are selected.
NULL
if no such item exists.
Char * LstGetSelectionText (const ListType *listP, Int16 itemNum)
  |
listP |
Pointer to list object. |
  |
itemNum |
Item to select (0 = first item in list). |
NULL
if out of bounds.
Int16 LstGetVisibleItems (const ListType *listP)
usable
and visible
attribute set to true
.This routine handles two type of events, penDownEvent and lstEnterEvent; see Comments.
Boolean LstHandleEvent (ListType *listP, const EventType *eventP)
  |
listP |
Pointer to a list object (ListType). |
  |
eventP |
Pointer to an EventType structure. |
penDownEvent
, it checks if the pen position is within the bounds of the list object. If it is, this routine tracks the pen until the pen comes up. If the pen comes up within the bounds of the list, a lstEnterEvent
is added to the event queue, and the routine is exited.
lstEnterEvent
, it checks that the list ID in the event record matches the ID of the specified list. If there is a match, this routine creates and displays a popup window containing the list's choices and the routine is exited.
penDownEvent
is received while the list's popup window is displayed and the pen position is outside the bounds of the popup window, the window is dismissed. If the pen position is within the bounds of the window, this routine tracks the pen until it comes up. If the pen comes up outside the list object, a lstEnterEvent
is added to the event queue.
void LstMakeItemVisible (ListType *listP, Int16 itemNum)
  |
listP |
Pointer to a list object (ListType). |
  |
itemNum |
Item to select (0 = first item in list). |
Err LstNewList (void **formPP, UInt16 id, Coord x, Coord y, Coord width, Coord height, FontID font, Int16 visibleItems, Int16 triggerId)
  |
id |
Symbolic ID of the list, specified by the developer. By convention, this ID should match the resource ID (not mandatory). |
  |
x |
Horizontal coordinate of the upper-left corner of the list's boundaries, relative to the window in which it appears. |
  |
y |
Vertical coordinate of the upper-left corner of the list's boundaries, relative to the window in which it appears. |
  |
width |
Width of the list, expressed in pixels. Valid values are 1 - 160. |
  |
height |
Height of the list, expressed in pixels.Valid values are 1 - 160. |
  |
visibleItems |
Number of list items that can be viewed together. |
  |
triggerId |
Symbolic ID of the popup trigger associated with the new list. This ID is specified by the developer; by convention, this ID should match the resource ID (not mandatory). |
LstDrawList
,
FrmRemoveObject
Int16 LstPopupList (ListType *listP)
FrmGetObjectPtr
Boolean LstScrollList (ListType *listP, WinDirectionType direction, Int16 itemCount)
  |
|
Pointer to list object. |
  |
|
Direction to scroll. |
  |
|
Items to scroll in direction. |
true
when the list is actually scrolled, false
otherwise. May return false
if a scroll past the end of the list is requested.
void LstSetDrawFunction (ListType *listP, ListDrawDataFuncPtr func)
void LstSetHeight (ListType *listP, Int16 visibleItems)
  |
listP |
Pointer to list object. |
  |
visibleItems |
Number of choices visible at once. |
FrmGetObjectPtr
void LstSetListChoices (ListType *listP, Char **itemsText, UInt16 numItems)
  |
listP |
Pointer to a list object. |
  |
itemsText |
Pointer to an array of text strings. |
  |
numItems |
Number of choices in the list. |
void LstSetPosition (ListType *listP, Coord x, Coord y)
FrmGetObjectPtr
void LstSetSelection (ListType *listP, Int16 itemNum)
  |
listP |
Pointer to a list object. |
  |
itemNum |
Item to select (0 = first item in list; -1 = none). |
FrmGetObjectPtr
void LstSetTopItem (ListType *listP, Int16 itemNum)
  |
listP |
Pointer to list object. |
  |
itemNum |
Item to select (0 = first item in list). |
If you need to perform special drawing for items in the list, call
LstSetDrawFunction
to set the list drawing callback function. The callback function's prototype is:
void ListDrawDataFuncType (Int16 itemNum,
RectangleType *bounds, Char **itemsText)
  |   |