Function Name

Topfield Documentation

void (*TAP_Win_SetDrawItemFunc)( TYPE_Window *win, TYPE_DrawItemFunc func );

This function is undocumented in the Topfield API

Additional Documentation

This function allows you to set a callback function. The callback will execute instead of the normal draw item code. This means that you get the opportunity to draw the lines of the window-list yourself, however you like (including adding graphics, better formatting etc.). This function should be called after creating the window, but before adding items to it.

You provide a function, prototyped as:-

typedef void (*TYPE_DrawItemFunc)( TYPE_Window *win, dword itemNo );

e.g.

void _WinListItemDrawFunc(TYPE_Window *win, dword ItemNo) { }

which will be called individually for each item on the window. It appears that if the window is scrolled, the callback is called for every item on the list. If you move the selection between two items in the list, then this callback is called only for two items, the one which was selected, and the one which is now selected.

The win parameter allows you access to information about the region you must draw to, the size of the region, size of the items, the total number of items in the list, the font size, the text items added ...

The content of the list
win->item[INDEX] - char * text labels, one per list item added.
win->check[INDEX] - always 0?  one per list item. Need more info.
win->idx[INDEX] - always same as INDEX? one per list item. Need more info.

The size of the list, and the view area (which items are visible) win->itemNum - The maximum number of items on this list win->startPos - The item number that is visible at the top of the screen (0 to (maximum-visible) ) win->currentPos - The highlighted item, (0 to maximum) win->maxItemView - (-2144240072). Need more info.

Text string parameters, from the window creation? win->fntType=255 - API says that fntType "should be" 0, I ignore this 255 and pass 0 when writing strings. win->fntSize=1 - An enum to pass to string functions

For drawing in general win->win.rgn - The region to draw into, covers the centre area of the window win->win.bodyX/Y/W/H - The location and size of the region above

The itemNo parameter tells you which item you are expected to redraw, 0 .. Max Items.

Bear in mind your callback will be called for items that are not visible on the screen, so you must handle the case where the selected item is off the top of the screen or off the bottom of the screen.

An example of using this callback is found in the winlist.c source file, in EPGClean, from this site