On Tue, Jul 02, 2002 at 08:31:16AM -0700, Steve Mann wrote:
> >There is nothing special to do actually, just handle the sclRepeatEvent
> >and use LstScrollList() to scroll the List. You'll also have to update
> >the scroller using SclSetScrollBar().
>
> Sounds pretty easy. I'll have to revisit this and give it a try.
As I am at it, I'll provide an actual source code excerpt,
slightly edited for brevity and clarity (forgive its length please):
static void ViewUpdateScrollers( void )
{
ListPtr listP;
ScrollBarPtr scrollP;
Int16 nItems, listHeight, pgSize, maxValue;
Int16 topItem;
// Set scrollbar values
listP = GetObjectPtr( TheList );
nItems = LstGetNumberOfItems( listP );
listHeight = LstGetVisibleItems( listP );
if (nItems > listHeight)
maxValue = nItems - listHeight;
else
maxValue = 0;
topItem = LstGetTopItem( listP ); /* top vis. item, >= PalmOS 4.0 */
if (topItem < 0)
topItem = 0;
if (topItem > maxValue)
topItem = maxValue;
pgSize = listHeight;
scrollP = GetObjectPtr( TheScrollBar );
SclSetScrollBar( scrollP,
topItem, /* value */
0, /* min */
maxValue, /* max */
pgSize ); /* page size */
}
static void ViewScroll( Int16 linesToScroll, Boolean updateScrollbar )
{
ListPtr listP;
listP = GetObjectPtr( TheList );
if (linesToScroll < 0)
LstScrollList( listP, winUp, -linesToScroll );
else if (linesToScroll > 0)
LstScrollList( listP, winDown, linesToScroll );
if (updateScrollbar)
ViewUpdateScrollers();
}
static void ViewContentUpdate( void )
{
FormPtr formP;
ListPtr listP;
...
listP = GetObjectPtr( TheList );
/* use LstSetListChoices() to set list contents */
LstSetListChoices( listP, items, numItems );
LstSetSelection( listP, -1 );
...
ViewUpdateScrollers();
LstDrawList( listP );
}
static void ViewInit( FormPtr formP )
{
...
ViewContentUpdate();
}
Boolean EventHandler( EventPtr eventP )
{
Boolean handled = false;
FormType *formP;
switch (eventP->eType)
{
case frmOpenEvent:
formP = FrmGetActiveForm();
ViewInit( formP );
FrmDrawForm( formP );
handled = true;
break;
case frmCloseEvent:
...
break;
case lstSelectEvent:
...
break;
case sclRepeatEvent:
ViewScroll( (eventP->data.sclRepeat.newValue -
eventP->data.sclRepeat.value), false );
break;
}
return handled;
}
Cheers,
Marco
--
========================================================================
Marco Pantaleoni [EMAIL PROTECTED]
Padova, Italy [EMAIL PROTECTED]
elastiC language developer http://www.elasticworld.org
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/