static void DlgInit( gui_window *wnd, void *param ) { char buffer[MAX_LENGTH]; dlg_init *info; info = (dlg_init *)param; TotalWindows++; ChildWindows[TotalWindows-1] = wnd; if( GUIGetWindowText( wnd, buffer, sizeof( buffer ) ) != 0 ) { GUIAddText( info->dlg_wnd, info->list_id, buffer ); } else { GUIAddText( info->dlg_wnd, info->list_id, "" ); } if( wnd == GUICurrWnd ) { GUISetCurrSelect( info->dlg_wnd, info->list_id, TotalWindows - 1 ); } }
static void InitTextList( gui_window *gui, unsigned id, const char **text_list ) { int i; for( i = 0; text_list[i] != NULL; i++ ) { GUIAddText( gui, id, text_list[i] ); } GUISetCurrSelect( gui, id, 0 ); }
extern bool CmdEvent( gui_window * gui, gui_event gui_ev, void * param ) { gui_ctl_id id; char *text; char *cmd; int i; cmd = GUIGetExtra( gui ); switch( gui_ev ) { case GUI_INIT_DIALOG: GUISetText( gui, CTL_CMD_EDIT, "Hi Lisa!" ); GUISetFocus( gui, CTL_CMD_EDIT ); GUIClearList( gui, CTL_CMD_HISTORY ); for( i = 0; i < ArraySize( Stuff ); ++i ) { GUIAddText( gui, CTL_CMD_HISTORY, Stuff[i] ); } GUISetCurrSelect( gui, CTL_CMD_HISTORY, 1 ); return( TRUE ); case GUI_KEY_CONTROL: GUISetCurrSelect( gui, CTL_CMD_HISTORY, 2 ); cmd = GUIGetText( gui, CTL_CMD_HISTORY ); GUISetText( gui, CTL_CMD_EDIT, cmd ); GUISelectAll( gui, CTL_CMD_EDIT, TRUE ); GUIMemFree( cmd ); return( TRUE ); case GUI_CONTROL_DCLICKED: case GUI_CONTROL_CLICKED: GUI_GETID( param, id ); switch( id ) { case CTL_CMD_HISTORY: text = GUIGetText( gui, CTL_CMD_HISTORY ); GUISetText( gui, CTL_CMD_EDIT, text ); GUIMemFree( text ); if( gui_ev == GUI_CONTROL_CLICKED ) return( TRUE ); /* fall through */ case CTL_CMD_OK: text = GUIGetText( gui, CTL_CMD_EDIT ); if( text != NULL ) DoCmd( text ); GUIMemFree( text ); break; case CTL_CMD_CHECK: return( FALSE ); } GUICloseDialog( gui ); /* fall through */ case GUI_DESTROY: WndFree( cmd ); return( TRUE ); default: return( FALSE ); } }
static void InitList( gui_window *gui, unsigned id, int index ) { int i; char **text; text = (char **)dlgControls[index].text; for( i = 0; text[i] != NULL; i++ ) { GUIAddText( gui, id, text[i] ); } GUISetCurrSelect( gui, id, 0 ); }
bool GUIAddTextList( gui_window *wnd, gui_ctl_id id, int items, const void *data_handle, GUIPICKGETTEXT *getstring ) { int item; GUIControlSetRedraw( wnd, id, false ); for( item = 0; item < items; item++ ) { GUIAddText( wnd, id, (*getstring)( data_handle, item ) ); } GUIControlSetRedraw( wnd, id, true ); GUIControlDirty( wnd, id ); return( true ); }
int WEXPORT WListBox::insertString( const char *s, int index ) { /**************************************************************/ int newIndex; if( index < 0 ) { GUIAddText( parent()->handle(), controlId(), (char *)s ); newIndex = count() - 1; } else { GUIInsertText( parent()->handle(), controlId(), index, (char *)s ); newIndex = index; } if( count() == 1 ) { select( 0 ); } return newIndex; }
extern void DlgSetHistory( gui_window *gui, void *history, char *cmd, int edit, int list ) { int i; GUISetFocus( gui, edit ); if( !WndPrevFromHistory( history, cmd ) ) return; GUISetText( gui, edit, cmd ); GUISelectAll( gui, edit, true ); GUIClearList( gui, list ); while( WndPrevFromHistory( history, cmd ) ) { /* nothing */ } i = -1; for( ;; ) { if( !WndNextFromHistory( history, cmd ) ) break; GUIAddText( gui, list, cmd ); ++i; } if( i >= 0 ) GUISetCurrSelect( gui, list, i ); }
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 ); } }
/* * setDirList - set current directory list */ static bool setDirList( gui_window *gui ) { char path[_MAX_PATH]; char dir[_MAX_DIR]; char drive[_MAX_DRIVE + 3]; DIR *directory; struct dirent *dent; char *ptr,*start; char indent[80]; char tmp[256]; const char **drvlist; int i; size_t len; int curr,cnt; const char **list; GUIClearList( gui, CTL_DIR_LIST ); cnt = 0; list = NULL; if( getcwd( path, sizeof( path ) ) == NULL ) { return( true ); } if( path[strlen( path ) - 1] == FILE_SEP_CHAR ) { #if !defined( __UNIX__ ) && !defined( __NETWARE__ ) strcat( path, FILES_ALL ); #endif } else { #if defined( __UNIX__ ) || defined( __NETWARE__ ) strcat( path, FILE_SEP ); #else strcat( path, FILE_SEP FILES_ALL ); #endif } splitPath( path, drive + 1, dir, NULL, NULL ); directory = opendir( path ); if( directory == NULL ) { return( false ); } drive[0] = OPENED_DIR_CHAR; drvlist = NULL; #if !defined( __UNIX__ ) && !defined( __NETWARE__ ) drvlist = GetDriveTextList(); #endif i = 0; while( drvlist != NULL ) { if( drvlist[i] == NULL ) { break; } if( drvlist[i][0] == drive[1] ) { GUISetCurrSelect( gui, CTL_DRIVES, i ); break; } i++; } #if !defined( __UNIX__ ) && !defined( __NETWARE__ ) drive[3] = '\\'; drive[4] = '\0'; #endif if( !addToList( &list, cnt, drive, strlen( drive ) ) ) { freeStringList( &list ); return( false ); } cnt++; strcpy( indent, INDENT_STR ); ptr = dir + 1; start = ptr; while( *ptr != 0 ) { if( *ptr == FILE_SEP_CHAR ) { *ptr = 0; len = strlen( indent ); memcpy( tmp, indent, len ); tmp[len++] = OPENED_DIR_CHAR; strcpy( tmp + len, start ); if( !addToList( &list, cnt, tmp, strlen( tmp ) ) ) { freeStringList( &list ); return( false ); } cnt++; start = ptr + 1; strcat( indent, INDENT_STR ); } ptr++; } curr = cnt; while( ( dent = readdir( directory ) ) != NULL ) { if( isdir( dent, path ) ) { if( (dent->d_name[0] == '.') && ((dent->d_name[1] == 0) || (dent->d_name[1] == '.' && dent->d_name[2] == 0)) ) { continue; } len = strlen( indent ); memcpy( tmp, indent, len ); tmp[len++] = UNOPENED_DIR_CHAR; strcpy( tmp + len, dent->d_name ); if( !addToList( &list, cnt, tmp, strlen( tmp ) ) ) { freeStringList( &list ); return( false ); } cnt++; } } closedir( directory ); qsort( list, cnt, sizeof( char * ), Compare ); for( i = 0; i < cnt; i++ ) { GUIAddText( gui, CTL_DIR_LIST, list[i] ); } GUISetCurrSelect( gui, CTL_DIR_LIST, curr - 1 ); freeStringList( &list ); return( true ); } /* setDirList */
/* * setFileList - get list of files in current directory */ static bool setFileList( gui_window *gui, const char *ext ) { char path[_MAX_PATH]; DIR *directory; struct dirent *dent; char *ptr; const char **list; int cnt; char ext1[_MAX_PATH]; int i; dlg_info *dlg = GUIGetExtra( gui ); cnt = 0; list = NULL; strcpy( ext1, ext ); ptr = strtok( ext1, ";" ); while( ptr != NULL ) { if( getcwd( path, sizeof( path ) ) == NULL ) { break; } #if !defined( __UNIX__ ) && !defined( __NETWARE__ ) if( path[strlen(path)-1] != FILE_SEP_CHAR ) { strcat( path, FILE_SEP ); } strcat( path, ptr ); #endif directory = opendir( path ); if( directory != NULL ) { while( ( dent = readdir( directory ) ) != NULL ) { if( !isdir( dent, path ) ) { if( ( dlg->currOFN->flags & OFN_HIDEREADONLY ) && isrdonly( dent, path ) ) { continue; } #if defined( __UNIX__ ) || defined( __NETWARE__ ) if( fnmatch( ptr, dent->d_name, FNM_PATHNAME ) != 0 ) { continue; } #endif if( !addToList( &list, cnt, dent->d_name, strlen( dent->d_name ) ) ) { freeStringList( &list ); closedir( directory ); return( false ); } cnt++; } } closedir( directory ); } ptr = strtok( NULL, ";" ); } GUIClearList( gui, CTL_FILE_LIST ); if( cnt > 0 ) { qsort( list, cnt, sizeof( char * ), Compare ); for( i = 0; i < cnt; i++ ) { GUIAddText( gui, CTL_FILE_LIST, list[i] ); } freeStringList( &list ); } return( true ); } /* setFileList */