/** * @brief Get the position of current item in the list. * * @param wid Window identifier where the list is. * @param name Name of the list. * @return The position in the list or -1 on error. */ int toolkit_getListPos( const unsigned int wid, char* name ) { Widget *wgt = lst_getWgt( wid, name ); if (wgt == NULL) return -1; return wgt->dat.lst.selected; }
/** * @brief Gets the offset of a list. */ int toolkit_getListOffset( const unsigned int wid, const char* name ) { Widget *wgt = lst_getWgt( wid, name ); if (wgt == NULL) return -1; return wgt->dat.lst.pos; }
/** * @brief Sets the list value by position. */ char* toolkit_setListPos( const unsigned int wid, const char* name, int pos ) { Widget *wgt = lst_getWgt( wid, name ); if (wgt == NULL) return NULL; /* Set by pos. */ wgt->dat.lst.selected = CLAMP( 0, wgt->dat.lst.noptions-1, pos ); lst_scroll( wgt, 0 ); /* checks boundaries and triggers callback */ return wgt->dat.lst.options[ wgt->dat.lst.selected ]; }
/** * @brief Gets what is selected currently in a list. * * List includes Image Arrays. */ char* toolkit_getList( const unsigned int wid, char* name ) { Widget *wgt = lst_getWgt( wid, name ); if (wgt == NULL) return NULL; /* Nothing selected. */ if (wgt->dat.lst.selected == -1) return NULL; return wgt->dat.lst.options[ wgt->dat.lst.selected ]; }
/** * @brief Sets the list value by name. */ char* toolkit_setList( const unsigned int wid, char* name, char* value ) { int i; Widget *wgt = lst_getWgt( wid, name ); if (wgt == NULL) return NULL; for (i=0; i<wgt->dat.lst.noptions; i++) { if (strcmp(wgt->dat.lst.options[i],value)==0) { wgt->dat.lst.selected = i; lst_scroll( wgt, 0 ); /* checks boundries and triggers callback */ return value; } } return NULL; }