![]() |
![]() |
![]() |
![]() |
Draw a string
void PtGenListDrawString( PtWidget_t *list, const char *string, PhRect_t const *where, int lmarg, int rmarg );
This function can be used by a child class of PtGenList for drawing strings. The list and where arguments should be the same as those used to call the List Draw method. The string argument is the string to display. Any Tab characters in the string are interpreted as column separators.
The where argument is a pointer to a PhRect_t structure (see the Photon Library Reference) that defines the rectangle in which the text is positioned. The x values for the rectangle should be the same as those used in the where argument of the List Draw method. The y values define the vertical position of the string to be drawn between the given values.
The lmarg and rmarg arguments define additional margins. The value of lmarg is added to the from value of the first column, and rmarg is subtracted from the to value of the last column. If the widget doesn't have columns, the width of the widget's canvas is used as a column.
Here's an excerpt showing the List Draw method of a widget (taken from PtList):
static PtGenListDrawF_t list_draw; static void list_draw( PtWidget_t *const widget, PtGenListItem_t *items, unsigned index, unsigned nitems, PhRect_t *where ) { PtGenListWidget_t *const glist = (PtGenListWidget_t*) widget; PtBasicWidget_t *const basic = (PtBasicWidget_t*) widget; const item_height = items->size.h; PtGenListDrawBackground( widget, items, nitems, where, 0, 0, 0, 0 ); do { short bot; bot = where->ul.y + item_height; if ( items->flags & Pt_LIST_ITEM_DAMAGED ) { PgColor_t fg, bg; where->lr.y = bot - 1; PtGenListGetColors( widget, items, &fg, &bg ); PgSetFillColor( bg ); PgSetTextColor( fg ); PtGenListDrawString( widget, STRING(items), where, 0, 0 ); } where->ul.y = bot; items = items->next; } while ( --nitems ); }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PhRect_t in the Photon Library Reference
![]() |
![]() |
![]() |
![]() |