I initially sent this message on June 1. No reply, so this is my second
try. I really hope that someone has an answer for me.
I'm just looking for one question to be answered. I'm semi-competent and
searched the web, the list archives, any FAQs, all documentation, and
even the Palm Programming (O'Reilly) book to no avail. I believe that
too much information is better than not enough, so I'll try to explain
my problem in detail.
I have a list that uses a custom draw function to just list records in a
database and give a little information (looks like 2 columns). The
problem is easy to show when the list grows to 100+ entries. Normal
scrolling with the scrollbar is fine, as long as I go slow or press the
little arrows on the scrollbar. When I try to go fast, the screen is
mangled after the second screen update (hard to tell, but I think it can
happen on #2 or later). List items will draw outside of the list, both
above and below the list, depending on the way you are scrolling.
Scroll down = extra garbage above the list, and vice-versa. Also,
sometimes list rows are sometimes updated with new data and sometimes
uses the data from the last scroll. It looks like there are two threads
and the Palm is trying to do this: (fixed-width font please)
Process 1
---------
get sclRepeatEvent
tell list to scroll
LstDrawList() (top id of 20)
Draw entry 1 (#20)
Draw entry 2 (#21)
*** at this point, my rapid scrolling generates a second event **
Process 2
---------
get sclRepeatEvent
Draw entry 3 (#22) tell the list to scroll
*** at this point, I assume that the topItem has been updated, and ***
*** the draw functions for Process 1 get strange Rectangles for ***
*** where to put information. ***
LstDrawList() top id of 50
Draw entry 1 (#50)
Draw entry 2 (#51)
Draw entry 4 (#23, weird spot) Draw entry 3 (#52)
Draw entry 4 (#53)
Draw entry 5 (#24, weird spot) Draw entry 5 (#54)
Draw entry 6 (#55)
Draw entry 6 (#25, weird spot) Draw entry 7 (#56)
(etc.)
This isn't an easy thing to describe, so I'll try to post some code so
you can see what I'm doing. It's based off the code to scroll a field
in the Palm Programming book.
Event handler: (I don't use a switch, and I return handled right away)
if (event->eType == sclRepeatEvent)
{
List_Scroll(event->data.sclRepeat.newValue -
event->data.sclRepeat.value, false);
return false; // handled = false
// I found out that returning true only lets you scroll for one
// update instead of allowing you to keep scrolling. :-)
}
void List_Scroll(Int Number, Boolean UpdateScrollbar)
{
ListPtr list;
DirectionType dir;
dir = down;
if (Number < 0)
{
Number = 0 - Number;
dir = up;
}
list = GetObjectPointer(Lst_PropT_Results);
// If I just set the top item, it eliminates the out-of-list drawing,
// but the entries are still mangled and I start to have problems with
// WinEraseRectangle and the currently-selected list item
LstScrollList(list, dir, Number);
// I also tried 'true' instead of false, so that the list draw
function // would be called. No luck.
List_UpdateList(false, UpdateScrollbar);
}
void List_UpdateList(Boolean UpdateList, Boolean UpdateScrollbar)
{
ListPtr list;
ScrollBarPtr bar;
Word maxScroll;
list = GetObjectPointer(Lst_PropT_Results);
if (UpdateList)
{
LstDrawList(list);
}
if (! UpdateScrollbar)
return;
// Proportion_EntriesInList is a #defined constant
// Yeah, I should use the API, but I was looking to get this
// scroll bug fixed before I made the case generalized
if (Prop_PointMax > Proportion_EntriesInList)
maxScroll = Prop_PointMax - Proportion_EntriesInList;
else
maxScroll = 0;
bar = GetObjectPointer(Sb_PropT_Results);
SclSetScrollBar(bar, list->topItem, 0, maxScroll,
Proportion_EntriesInList - 1);
SclDrawScrollBar(bar);
}
My custom draw function, the # of entries in the list, and the strings
(NULL) were set when I enter the form. I also set the hasScrollBar to
true, to eliminate the up and down arrows inside the list.
void List_ListDrawFunc(UInt itemNum, RectanglePtr bounds, CharPtr *data)
{
// This grabs information from a database, calculates some numbers, //
and does whatever.
// I tried it with and without this line. It seems to work better //
when I don't have it and I use the LstScrollList() function
// WinEraseRectangle(bounds, 0);
// Use WinDrawChars() to draw the information within the rectangle.
}
The sad thing is that it works fine if you don't scroll too far too fast.
I've tried accessing the structure directly (I know, bad idea). I've
tried dozens of different ways to update the list. I don't know what
else to do. Could anyone tell me please what I am doing wrong?
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/