[Previous] [Contents] [Index] [Next]

PtGenListDrawString()

Draw a string

Synopsis:

void PtGenListDrawString( PtWidget_t *list, 
                          const char *string,
                          PhRect_t const *where, 
                          int lmarg, 
                          int rmarg );

Description:

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 defines the rectangle in which the text will be 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.

Examples:

Here's an excerpt showing the List Draw method of a widget (taken from PtList):

static PtGenListDrawF_t list_draw;

static void list_draw( 
        PtGenListWidget_t *const glist, PtGenListItem_t *items, 
        unsigned index, unsigned nitems, PhRect_t *where
        ) {
    PtBasicWidget_t *const basic = (PtBasicWidget_t*) glist;
    PtGenListDrawBackground( glist, items, nitems, where, 
                             0, 0 );
    do    {
        short bot;
        bot = where->ul.y + items->size.h;
        if ( items->flags & Pt_LIST_ITEM_DAMAGED ) {
            where->lr.y = bot - 1;
            PgSetTextColor(
                items->flags & Pt_LIST_ITEM_SELECTED
                ?   glist->selection_text_color
                :   basic->color
                );
            PtGenListDrawString( glist, STRING(items), where, 
                                 0, 0 );
            }
        where->ul.y = bot;
        items = items->next;
        }    while ( --nitems );
    }

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

[Previous] [Contents] [Index] [Next]