This code may help people who want to deal with custom drawn lists, but want
to keep it as simple as possible.  Note that it doesn't include much in the
way or error condition handling, special font cases, buffer overruns, and so
forth, so it's assumed you know what you're doing.

Hope this helps out some noobs out there.

Feel free to (pref. constructively) comment on it.


Firstly the "boilerplate" code...


#include "PalmOSGlue.h"

typedef void CustomListGetTextFuncType(Char* sListEntry, UInt16 iIndex);

static void CustomListTextDraw(Int16 location, RectanglePtr bounds,
CustomListGetTextFuncType* fnGetText) {
 Char sBuffer[32];
 fnGetText(sBuffer, location);
 WinEraseRectangle(bounds, 0);
 WinGlueDrawTruncChars(sBuffer, StrLen(sBuffer), bounds->topLeft.x,
bounds->topLeft.y, bounds->extent.x);
}

void CustomListSetup(ListType* lstP, CustomListGetTextFuncType* fGetText,
UInt16 iCount, UInt16 iHeight) {
 LstSetDrawFunction(lstP, (ListDrawDataFuncPtr)CustomListTextDraw);
 LstSetListChoices(lstP, (Char**)fGetText, iCount);
 LstSetHeight(lstP, iHeight);
}


... And in your main code:


static void FunkyListGetText(Char* sOut, UInt16 iIndex) {
 StrPrintF(sOut, "Entry : %i", (iIndex+1)*5);
}

When initialising the form...

CustomListSetup(lstP, FunkyListGetText, 16, 5);

Alan



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to