void WEXPORT WListBox::getString( int index, WString& str ) { /***********************************************************/ char *list_item; list_item = GUIGetListItem( parent()->handle(), controlId(), index ); WString s( list_item ); GUIMemFree( list_item ); str = s; }
char *GUIGetText( gui_window *wnd, gui_ctl_id id ) { LONG length; char *text; gui_control_class control_class; HWND hwnd; gui_ctl_idx choice; if( !GUIGetControlClass( wnd, id, &control_class ) ) { return( NULL ); } switch( control_class ) { case GUI_LISTBOX : choice = GUIGetCurrSelect( wnd, id ); if( choice == -1 ) { return( NULL ); } return( GUIGetListItem( wnd, id, choice ) ); default : hwnd = _wpi_getdlgitem( wnd->hwnd, id ); if( hwnd == NULLHANDLE ) { return( NULL ); } length = _wpi_getwindowtextlength( hwnd ); if( length > 0 ) { text = (char *)GUIMemAlloc( length + 1 ); if( text != NULL ) { _wpi_getwindowtext( hwnd, (LPSTR)text, length + 1 ); switch( control_class ) { case GUI_PUSH_BUTTON: case GUI_DEFPUSH_BUTTON: case GUI_RADIO_BUTTON: case GUI_CHECK_BOX: case GUI_STATIC: case GUI_GROUPBOX: _wpi_menutext2win( text ); break; } } return( text ); } return( NULL ); } }
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 ); } }
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 ); } }
/* * ProcessOKorDClick -- user clicked OK or double clicked on a file */ void ProcessOKorDClick( gui_window *gui, unsigned id ) { process_rc prc; int sel; int realsel; char path[_MAX_PATH]; char *optr; char *ptr; int i; unsigned focusid; dlg_info *dlg = GUIGetExtra( gui ); if( id == CTL_OK ) { /* hit enter or clicked ok */ GUIGetFocus( gui, &focusid ); switch( focusid ) { case CTL_DIR_LIST : id = focusid; break; case CTL_FILE_LIST : ptr = GUIGetText( gui, CTL_FILE_LIST ); GUISetText( gui, CTL_EDIT, ptr ); GUIMemFree( ptr ); break; } } switch( id ) { case CTL_FILE_LIST : case CTL_OK : prc = processFileName( gui ); if( prc == PROCESS_TRUE ) { dlg->dialogRC = OFN_RC_FILE_SELECTED; GUICloseDialog( gui ); } else if( prc == PROCESS_FAIL ) { dlg->dialogRC = OFN_RC_RUNTIME_ERROR; GUICloseDialog( gui ); } break; case CTL_DIR_LIST : sel = GUIGetCurrSelect( gui, id ); #if defined( __UNIX__ ) || defined( __NETWARE__ ) path[0] = FILE_SEP_CHAR; path[1] = 0; #else path[0] = 0; #endif realsel = 0; for( i=0;i<sel;i++ ) { ptr = GUIGetListItem( gui, id, i ); if( ptr == NULL ) { return; } optr = ptr; while( *ptr == INDENT_CHAR ) { ptr++; } if( *ptr == '-' ) { strcat( path, ptr+1 ); realsel++; if( i > 0 ) { strcat( path, FILE_SEP ); } } else { GUIMemFree( optr ); break; } GUIMemFree( optr ); } ptr = GUIGetListItem( gui, id, sel ); if( ptr == NULL ) { return; } optr = ptr; while( *ptr == INDENT_CHAR ) { ptr++; } strcat( path, ptr+1 ); GUIMemFree( optr ); goToDir( gui, path ); if( !initDialog( gui, NULL, NULL ) ) { dlg->dialogRC = OFN_RC_RUNTIME_ERROR; GUICloseDialog( gui ); } else { GUISetCurrSelect( gui, id, realsel ); } break; } } /* ProcessOKorDClick */