ScrollBar.h
declares the API that this chapter describes. For more information on scroll bars, see the section "Scroll Bars" in the Palm OS Programmer's Companion.
ScrollBarAttrType
bit field defines a scroll bar's visible characteristics.
typedef str
uct {
    UInt16 usable : 1;
    UInt16 visible : 1;
    UInt16 hilighted : 1;
    UInt16 shown : 1;
    UInt16 activeRegion: 4;
} ScrollBarAttrType;
ScrollBarPtr
type defines a pointer to a
ScrollBarType
structure.
typedef ScrollBarType *ScrollBarPtr;
ScrollBarPtr
as an argument to all scroll bar functions. You can obtain the ScrollBarPtr
using the function
FrmGetObjectPtr
in this way:
scrollBarPtr = FrmGetObjectPtr(frm,
FrmGetObjectIndex(frm, scrollBarID));
ScrollBarType
represents a scroll bar.
typedef struct {
    RectangleType bounds;
    UInt16 id;
    ScrollBarAttrType attr;
    Int16 value;
    Int16 minValue;
    Int16 maxValue;
    Int16 pageSize;
    Int16 penPosInCar;
    Int16 savePos;
} ScrollBarType;
ScrollBarType
structure as opaque. Use the functions described in this chapter to retrieve and set each value. Do not attempt to change structure member values directly.
bounds
| Position (using absolute coordinates) and size (in pixels) of the scroll bar on the screen. |
id
| ID value you specified when you created the scroll bar object. |
attr
|
Scroll bar's attributes. See ScrollBarAttrType .
|
value
| Current value of the scroll bar. This value is used to determine where to position the scroll car (the dark region in the scroll bar that indicates the position in the document). |
The number given is typically a number relative to minValue and maxValue . These values have nothing to do with any physical characteristics of the object that the scroll bar is attached to, such as the number of lines in the object.
| |
This value is typically set to 0 initially and then adjusted programmatically with SclSetScrollBar .
| |
minValue
|
Minimum value. When value equals minValue , the scroll car is positioned at the very top of the scrolling region. This value is typically 0.
|
maxValue
|
Maximum value. When value equals maxValue , the scroll car is positioned at the very bottom of the scrolling region. This value is typically set to 0 initially and then adjusted programmatically with SclSetScrollBar .
|
pageSize
| Number of lines to scroll when user scrolls one page. |
penPosInChar
| Used internally. |
savePos
| Used internally. |
void SclDrawScrollBar (const ScrollBarPtr bar)
SclSetScrollBar
and
FrmDrawForm
. You rarely need to call it yourself.
void SclGetScrollBar (const ScrollBarPtr bar, Int16 *valueP, Int16 *minP, Int16 *maxP, Int16 *pageSizeP)
  |
-> |
Pointer to a scroll bar structure (see ScrollBarType ). |
  |
<- |
A value representing the scroll car's current position. (The scroll car is the dark region that indicates the position in the document.) |
  |
<- |
A value representing the top of the user interface object. |
  |
<- |
A value representing the bottom of the user interface object. |
  |
<- |
Pointer to size of a page (used when page scrolling). |
valueP
, minP
, maxP
, and pageSizeP
.
SclSetScrollBar
to update the scroll bar. SclGetScrollBar
returns the scroll bar's current values, which you can then adjust as necessary and pass to SclSetScrollBar
.
SclSetScrollBar
Boolean SclHandleEvent (const ScrollBarPtr bar, const EventType *event)
  |
-> |
Pointer to a scroll bar structure (see ScrollBarType ). |
  |
-> |
Pointer to an event (EventType). |
true
if the event was handled.
sclEnterEvent
to the event queue.
sclEnterEvent
occurs, the scroll bar determines what its new value should be based on which region of the scroll bar is receiving the pen down events. It then sends either an sclRepeatEvent or an sclExitEvent to the event queue.
sclExitEvent
arrives. Applications that implement dynamic scrolling can ignore this event.
void SclSetScrollBar (const ScrollBarPtr bar, Int16 value, const Int16 min, const Int16 max, const Int16 pageSize)
  |
-> |
Pointer to a scroll bar structure (see ScrollBarType ). |
  |
-> |
The position the scroll car should move to. (The scroll car is the dark region that indicates the position in the document.) |
  |
-> |
Minimum value. |
  |
-> |
Maximum value. |
  |
-> |
Number of lines of text that can be displayed on a the screen at one time (used when page scrolling). |
min
parameter is greater than the max
parameter.
fldChangedEvent
and update the scroll bar at that time.
max
parameter is computed as:
max
value would be 90 or 91, depending on the overlap. So if value is greater than or equal to 90 or 91, the scroll car is at the very bottom of the scrolling region.
FldGetScrollValues
function to compute the values you pass for value
, min
, and max
. For example:
FldGetScrollValues (fld, &scrollPos,
    &textHeight, &fieldHeight);
if (textHeight > fieldHeight)
    maxValue = textHeight - fieldHeight;
else if (scrollPos)
    maxValue = scrollPos;
else
    maxValue = 0;
SclSetScrollBar (bar, scrollPos, 0, maxValue,
    fieldHeight-1);
textHeight
is the number of lines of text and fieldHeight
is the page size. No lines overlap when you scroll one page. Notice that if the page size is greater than the lines of text, then max
equals min
, which means that the scroll bar is not displayed.
FldGetScrollValues
. Your application must scroll the table itself and keep track of the scroll values. See the ListViewUpdateScrollers
function in the Memo example application (MemoMain.c
) for an example of setting scroll bar values for a table.
  |   |