예제 #1
0
파일: list.c 프로젝트: ekrumme/naev
/**
 * @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;
}
예제 #2
0
파일: list.c 프로젝트: Dinth/naev
/**
 * @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;
}
예제 #3
0
파일: list.c 프로젝트: Dinth/naev
/**
 * @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 ];
}
예제 #4
0
파일: list.c 프로젝트: ekrumme/naev
/**
 * @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 ];
}
예제 #5
0
파일: list.c 프로젝트: ekrumme/naev
/**
 * @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;
}