/* * initDialog - initialize all dialog fields */ static bool initDialog( gui_window *gui, const char *ext, char *name ) { char path[_MAX_PATH]; dlg_info *dlg = GUIGetExtra( gui ); if( ext != NULL && hasWild( ext ) ) { char *str; size_t len; len = strlen( ext ) + 1; str = GUIMemAlloc( len ); GUIMemFree( dlg->currExt ); dlg->currExt = str; if( str == NULL ) { return( false ); } memcpy( str, ext, len ); } if( !setFileList( gui, dlg->currExt ) ) { return( false ); } if( !setDirList( gui ) ) { return( false ); } getcwd( path, sizeof( path ) ); GUISetText( gui, CTL_DIR_NAME, path ); if( name != NULL && *name != '\0' ) { GUISetText( gui, CTL_EDIT, name ); } else if( ext != NULL ) { GUISetText( gui, CTL_EDIT, ext ); } return( true ); } /* initDialog */
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 ); } }
extern void DlgClickHistory( gui_window *gui, int edit, int list ) { char *cmd; cmd = GUIGetText( gui, list ); GUISetText( gui, edit, cmd ); GUIMemFree( cmd ); }
static void SetDlgStatus( gui_window *gui, dlg_search *dlg ) { char cmd[256]; dlg->direction = 0; GUISetChecked( gui, CTL_SRCH_CASE, dlg->case_ignore ); GUISetChecked( gui, CTL_SRCH_RX, dlg->use_rx ); GUISetText( gui, CTL_SRCH_EDIT, dlg->wnd->searchitem ); DlgSetHistory( gui, dlg->history, cmd, CTL_SRCH_EDIT, CTL_SRCH_LIST ); }
OVL_EXTERN bool ProgEvent( gui_window * gui, gui_event gui_ev, void * param ) { gui_ctl_id id; dlg_new_prog *dlg; dlg = GUIGetExtra( gui ); switch( gui_ev ) { case GUI_INIT_DIALOG: GUILimitEditText( gui, CTL_NEWP_PROG, UTIL_LEN - 1 ); GUILimitEditText( gui, CTL_NEWP_ARGS, UTIL_LEN - 1 ); GUISetText( gui, CTL_NEWP_PROG, dlg->prog ); GUISetText( gui, CTL_NEWP_ARGS, dlg->args ); GUISetFocus( gui, CTL_NEWP_PROG ); return( true ); case GUI_CONTROL_CLICKED : GUI_GETID( param, id ); switch( id ) { case CTL_NEWP_BROWSE: GUIDlgBuffGetText( gui, CTL_NEWP_PROG, TxtBuff, TXT_LEN ); if( !ExeBrowse() ) return( true ); GUISetText( gui, CTL_NEWP_PROG, TxtBuff ); GUISetFocus( gui, CTL_NEWP_PROG ); return( true ); case CTL_NEWP_OK: GUIDlgBuffGetText( gui, CTL_NEWP_PROG, prog, sizeof( prog ) ); GUIDlgBuffGetText( gui, CTL_NEWP_ARGS, args, sizeof( args ) ); dlg->cancel = false; GUICloseDialog( gui ); return( true ); case CTL_NEWP_CANCEL: GUICloseDialog( gui ); return( true ); } return( false ); case GUI_DESTROY: return( true ); } return( false ); }
STATIC void setDlgValues( gui_window *gui ) /*****************************************/ { char *add_ext; GUISetChecked( gui, CTL_DIF_FMT, OptDIFFormat ); GUISetChecked( gui, CTL_COMMA_FMT, OptCommaFormat ); if( OptDIFFormat ) { add_ext = ".dif"; } else { add_ext = ".txt"; } ReplaceExt( convertPath, add_ext ); GUISetText( gui, CTL_NAME, convertPath ); }
bool GUIClearList( gui_window *wnd, unsigned id ) { VFIELD *field; a_list *list; if( GetList( wnd, id, &field, &list ) ) { if( !GUIClearListBox( list ) ) { return( FALSE ); } if( !GUISetText( wnd, id, NULL ) ) { /* temporary */ return( FALSE ); } return( RefreshListCombobox( field, wnd, id ) ); } 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 SetDefaultVals( gui_window *gui, a_dialog_header *curr_dialog ) /*************************************************************************/ /* Set the default variable values. Decide how to set these */ /* default values based on edit control type. */ { int i; gui_control_class a_control_class; vhandle var_handle; char *cond; bool drive_checked; drive_checked = FALSE; for( i = 0; curr_dialog->pVariables[i] != NO_VAR; ++i ) { var_handle = curr_dialog->pVariables[i]; cond = curr_dialog->pConditions[i]; if( !curr_dialog->defaults_set && cond != NULL && VarGetIntVal( var_handle ) == 0 ) { if( isdigit( *cond ) ) { SetVariableByHandle( var_handle, cond ); } else if( EvalCondition( cond ) ) { SetVariableByHandle( var_handle, "1" ); } } a_control_class = ControlClass( VarGetId( var_handle ), curr_dialog ); switch( a_control_class ) { case GUI_STATIC: SetDynamic( gui, var_handle, &drive_checked ); break; case GUI_RADIO_BUTTON: case GUI_CHECK_BOX: GUISetChecked( gui, VarGetId( var_handle ), VarGetIntVal( var_handle ) != 0 ); break; case GUI_EDIT_MLE: case GUI_EDIT: GUISetText( gui, VarGetId( var_handle ), VarGetStrVal( var_handle ) ); break; default: break; } } curr_dialog->defaults_set = TRUE; }
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 SetDynamic( gui_window *gui, vhandle var_handle, bool *drive_checked ) /*******************************************************************************/ { char buff[256]; const char *p; p = VarGetStrVal( var_handle ); if( !*drive_checked ) { while( *p ) { if( *p == '%' ) { if( strnicmp( p, "%DriveFree", 10 ) == 0 ) { CheckDrive( FALSE ); *drive_checked = TRUE; } } ++p; } } ReplaceVars( buff, VarGetStrVal( var_handle ) ); AddInstallName( buff, FALSE ); GUISetText( gui, VarGetId( var_handle ), buff ); }
void GUISetText(heroWindow* hwnd, int f, std::string& p) { GUISetText(hwnd, f, &p[0]); }
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 ); } }
/* * GetFileNameEvent - event handler for GetFileName dialog */ extern bool GetFileNameEvent( gui_window *gui, gui_event gui_ev, void *param ) { unsigned id; int sel; char *ptr; char path[_MAX_PATH]; dlg_info *dlg = GUIGetExtra( gui ); switch( gui_ev ) { case GUI_INIT_DIALOG: dlg->initted = false; InitTextList( gui, CTL_FILE_TYPES, GetFileTypesTextList() ); #if !defined( __UNIX__ ) && !defined( __NETWARE__ ) InitTextList( gui, CTL_DRIVES, GetDriveTextList() ); #endif if( !initDialog( gui, dlg->fileExtensions[dlg->currExtIndex], dlg->currOFN->file_name ) ) { dlg->dialogRC = OFN_RC_FAILED_TO_INITIALIZE; return( false ); } dlg->initted = true; GUISetFocus( gui, CTL_EDIT ); return( true ); break; case GUI_CONTROL_DCLICKED: GUI_GETID( param, id ); switch( id ) { case CTL_FILE_LIST: case CTL_DIR_LIST: ProcessOKorDClick( gui, id ); break; } break; case GUI_CONTROL_CLICKED: if( !dlg->initted ) break; GUI_GETID( param, id ); switch( id ) { case CTL_OK: ProcessOKorDClick( gui, id ); break; case CTL_CANCEL: GUICloseDialog( gui ); break; case CTL_FILE_LIST: ptr = GUIGetText( gui, id ); GUISetText( gui, CTL_EDIT, ptr ); GUIMemFree( ptr ); break; case CTL_DRIVES : sel = GUIGetCurrSelect( gui, id ); strcpy( path, GetDriveTextList()[sel] ); path[2] = 0; goToDir( gui, path ); if( !initDialog( gui, NULL, NULL ) ) { dlg->dialogRC = OFN_RC_RUNTIME_ERROR; GUICloseDialog( gui ); } break; case CTL_FILE_TYPES: sel = GUIGetCurrSelect( gui, id ); if( !initDialog( gui, dlg->fileExtensions[sel], NULL ) ) { dlg->dialogRC = OFN_RC_RUNTIME_ERROR; GUICloseDialog( gui ); } break; } return( true ); default: break; // makes GCC happy. } return( false ); } /* GetFileNameEvent */
/* * 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 */
static bool GenericEventProc( gui_window *gui, gui_event gui_ev, void *param ) /****************************************************************************/ { #if !defined( _UI ) static bool first_time = TRUE; #endif unsigned id; DLG_WINDOW_SET *result; a_dialog_header *curr_dialog; static int initializing = FALSE; char buff[MAXBUF]; gui_text_metrics metrics; if( gui == NULL ) return( FALSE ); result = GUIGetExtra( gui ); curr_dialog = result->current_dialog; switch( gui_ev ) { case GUI_INIT_DIALOG: initializing = TRUE; UpdateControlVisibility( gui, curr_dialog, TRUE ); SetDefaultVals( gui, curr_dialog ); SetFocusCtrl( gui, curr_dialog ); GUIGetTextMetrics( gui, &metrics ); if( stricmp( curr_dialog->name, "InsertDisk" ) == 0 ) { DoBeep(); } #if defined( __OS2__ ) { int i; for( i = 0; i < curr_dialog->num_controls; i++ ) { if( curr_dialog->controls[i].control_class == GUI_EDIT_MLE ) { GUILimitEditText( gui, curr_dialog->controls[i].id, -1 ); GUISetText( gui, curr_dialog->controls[i].id, curr_dialog->controls[i].text ); } } } #endif #if defined( _UI ) if( stricmp( curr_dialog->name, "Welcome" ) == 0 ) { if( GetVariableIntVal( "AutoOptionsDialog" ) == 1 ) { // call Options dialog DoDialogWithParent( gui, "Options" ); } } #endif #if !defined( _UI ) first_time = TRUE; #endif initializing = FALSE; return( TRUE ); #if !defined( _UI ) case GUI_PAINT: if( first_time ) { first_time = FALSE; if( stricmp( curr_dialog->name, "Welcome" ) == 0 ) { if( GetVariableIntVal( "AutoOptionsDialog" ) == 1 ) { // call Options dialog DoDialogWithParent( gui, "Options" ); } } } break; #endif case GUI_DESTROY: break; case GUI_CONTROL_CLICKED : GUI_GETID( param, id ); switch( id ) { case CTL_OK: case CTL_PREVIOUS: case CTL_FIRST: case CTL_SKIP: GetVariableVals( gui, curr_dialog, TRUE ); GUICloseDialog( gui ); result->state = IdToDlgState( id ); break; case CTL_CANCEL: GUICloseDialog( gui ); result->state = DLG_CAN; break; case CTL_DONE: GUICloseDialog( gui ); result->state = DLG_DONE; break; case CTL_OPTIONS: // Options button on Welcome dialog // call Options dialog DoDialogWithParent( gui, "Options" ); GetVariableVals( gui, curr_dialog, FALSE ); break; default: { const char *dlg_name; a_dialog_header *child; int old_val; dlg_state return_state; dlg_name = VarGetStrVal( GetVariableById( id ) ); if( dlg_name != NULL ) { child = FindDialogByName( dlg_name ); if( child != NULL ) { GetVariableVals( gui, curr_dialog, FALSE ); if( child->any_check != NO_VAR ) { old_val = VarGetIntVal( child->any_check ); SetVariableByHandle( child->any_check, "1" ); GUISetChecked( gui, VarGetId( child->any_check ), 1 ); CheckChildChecks( child ); return_state = DoDialogByPointer( gui, child ); if( return_state != DLG_CAN && return_state != DLG_DONE ) { CheckAnyCheck( gui, child ); } else { SetVariableByHandle( child->any_check, old_val ? "1" : "0" ); GUISetChecked( gui, VarGetId( child->any_check ), old_val ); } } else { DoDialogByPointer( gui, child ); } } } } if( !initializing ) GetVariableVals( gui, curr_dialog, FALSE ); UpdateControlVisibility( gui, curr_dialog, FALSE ); break; case CTL_HELP: strcpy( buff, "Help_" ); strcat( buff, curr_dialog->name ); DoDialogWithParent( gui, buff ); break; } return( TRUE ); default: break; } return( FALSE ); }
void WEXPORT WStatDialog::setCtrlText( WControlId id, const char *text ) { /************************************************************************/ GUISetText( handle(), id, text ); }