static void SelectListLast( gui_window *gui ) { int size; size = GUIGetListSize( gui, CTL_LIST_LIST ); if( size != 0 ) { GUISetCurrSelect( gui, CTL_LIST_LIST, size - 1 ); } }
bool GUIDeleteItem( gui_window *wnd, gui_ctl_id id, gui_ctl_idx choice ) { if( ( choice >= 0 ) && ( choice < GUIGetListSize( wnd, id ) ) ) { GUIToComboList( wnd, id, LB_DELETESTRING, CB_DELETESTRING, (WPI_PARAM1)choice, (WPI_PARAM2)NULL, (WPI_MRESULT)NULL ); return( true ); } return( false ); }
static void MoveCursor( gui_window *gui, int edit, int list, int direction ) { int i,size; char *cmd; i = GUIGetCurrSelect( gui, list ); size = GUIGetListSize( gui, list ); if( size == 0 ) return; --size; i += direction; if( i < 0 ) i = 0; if( i > size ) i = size; GUISetCurrSelect( gui, list, i ); cmd = GUIGetText( gui, list ); GUISetText( gui, edit, cmd ); GUIMemFree( cmd ); GUISelectAll( gui, edit, true ); }
static void AddText( gui_window *gui, char *add ) { int size; int i; char *text; bool dup; size = GUIGetListSize( gui, CTL_LIST_LIST ); dup = false; for( i = 0; i < size; ++i ) { text = GUIGetListItem( gui, CTL_LIST_LIST, i ); if( text != NULL ) { dup = ( strcmp( add, text ) == 0 ); GUIMemFree( text ); if( dup ) { break; } } } if( !dup ) { GUIAddText( gui, CTL_LIST_LIST, add ); } }
int WEXPORT WListBox::count() { /******************************/ return( GUIGetListSize( parent()->handle(), controlId() ) ); }
static bool SourceEvent( gui_window *gui, gui_event gui_ev, void *param ) { gui_ctl_id id; void *curr; int i; int size; char *text; dlg_list *dlg; dlg = GUIGetExtra( gui ); switch( gui_ev ) { case GUI_DESTROY: WndFree( dlg->title ); return( true ); case GUI_INIT_DIALOG: GUISetWindowText( gui, dlg->title ); GUIClearList( gui, CTL_LIST_LIST ); for( curr = dlg->next( NULL ); curr != NULL; curr = dlg->next( curr ) ) { AddText( gui, dlg->name( curr ) ); } GUISetFocus( gui, CTL_LIST_EDIT ); return( true ); case GUI_CONTROL_CLICKED: GUI_GETID( param, id ); switch( id ) { case CTL_LIST_LIST: GUIDlgBuffGetText( gui, CTL_LIST_LIST, TxtBuff, TXT_LEN ); GUISetText( gui, CTL_LIST_EDIT, TxtBuff ); break; case CTL_LIST_DELETE: i = GUIGetCurrSelect( gui, CTL_LIST_LIST ); if( i != -1 ) { GUIDeleteItem( gui, CTL_LIST_LIST, i ); } size = GUIGetListSize( gui, CTL_LIST_LIST ); if( i < size ) { GUISetCurrSelect( gui, CTL_LIST_LIST, i ); } else { SelectListLast( gui ); } GUISetFocus( gui, CTL_LIST_LIST ); GUISetText( gui, CTL_LIST_EDIT, NULL ); break; case CTL_LIST_ADD: case CTL_LIST_OK: GUIDlgBuffGetText( gui, CTL_LIST_EDIT, TxtBuff, TXT_LEN ); if( TxtBuff[0] != '\0' ) AddText( gui, TxtBuff ); SelectListLast( gui ); GUIClearText( gui, CTL_LIST_EDIT ); GUISetFocus( gui, CTL_LIST_EDIT ); if( id == CTL_LIST_ADD ) break; dlg->clear(); size = GUIGetListSize( gui, CTL_LIST_LIST ); for( i = 0; i < size; ++i ) { text = GUIGetListItem( gui, CTL_LIST_LIST, i ); if( text != NULL ) { dlg->add( text, strlen( text ) ); GUIMemFree( text ); } } /* fall through */ case CTL_LIST_CANCEL: GUICloseDialog( gui ); break; case CTL_LIST_BROWSE: GUIDlgBuffGetText( gui, CTL_LIST_EDIT, TxtBuff, TXT_LEN ); if( !AllBrowse( TxtBuff ) ) return( true ); GUISetText( gui, CTL_LIST_EDIT, TxtBuff ); GUISetFocus( gui, CTL_LIST_EDIT ); return( true ); } return( true ); default: return( false ); } }