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; }
static void CheckChildChecks( a_dialog_header *child ) /******************************************************************/ /* If all child checks are off, set them to the defaults */ { int i; for( i = 0; child->pVariables[i] != NO_VAR; i++ ) { if( ControlClass( VarGetId( child->pVariables[i] ), child ) == GUI_CHECK_BOX && VarGetIntVal( child->pVariables[i] ) ) { return; } } for( i = 0; child->pVariables[i] != NO_VAR; i++ ) { if( ControlClass( VarGetId( child->pVariables[i] ), child ) == GUI_CHECK_BOX ) { SetDefaultAutoSetValue( child->pVariables[i] ); } } }
static void CheckAnyCheck( gui_window *gui, a_dialog_header *child ) /******************************************************************/ /* If any of the sub-dialog check boxes are on, turn on the */ /* 'anycheck' variable */ { int i; for( i = 0; child->pVariables[i] != NO_VAR; i++ ) { if( ControlClass( VarGetId( child->pVariables[i] ), child ) == GUI_CHECK_BOX && VarGetIntVal( child->pVariables[i] ) ) { SetVariableByHandle( child->any_check, "1" ); GUISetChecked( gui, VarGetId( child->any_check ), 1 ); return; } } SetVariableByHandle( child->any_check, "0" ); GUISetChecked( gui, VarGetId( child->any_check ), 0 ); }
static bool SetupOperations( void ) /*********************************/ { bool uninstall; // are we doing an UnInstall? uninstall = VarGetIntVal( UnInstall ); if( GetVariableIntVal( "IsUpgrade" ) == 1 ) { if( !CheckUpgrade() ) { return( FALSE ); } } DoSpawn( WHEN_BEFORE ); #ifdef PATCH if( GetVariableIntVal( "Patch" ) == 1 ) { IsPatch = 1; if( !PatchFiles() ) { return( FALSE ); } } #endif DeleteObsoleteFiles(); // Copy the files if( GetVariableIntVal( "DoCopyFiles" ) == 1 ) { if( !CopyAllFiles() ) { return( FALSE ); } } DoSpawn( WHEN_AFTER ); // Modify AUTOEXEC.BAT and CONFIG.SYS if( GetVariableIntVal( "DoModifyAuto" ) == 1 ) { if( !ModifyStartup( uninstall ) ) { return( FALSE ); } } // Perform file associations if( GetVariableIntVal( "DoFileAssociations" ) == 1 ) { if( !ModifyAssociations( uninstall ) ) { return( FALSE ); } } // Generate batch file if( GetVariableIntVal( "GenerateBatchFile" ) == 1 ) { if( !GenerateBatchFile( uninstall ) ) { return( FALSE ); } } // Create program group (folder) if( GetVariableIntVal( "DoCreateIcons" ) == 1 || GetVariableIntVal( "DoCreateHelpIcons" ) == 1 ) { if( !ModifyEnvironment( uninstall ) ) { return( FALSE ); } } // Add uninstaller to Add/Remove Programs if( GetVariableIntVal( "DoUninstall" ) == 1 ) { if( !ModifyUninstall( uninstall ) ) { return( FALSE ); } } DoSpawn( WHEN_END ); return( TRUE ); }
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 ); }
extern int GetVariableIntVal( const char *vbl_name ) /**************************************************/ { return( VarGetIntVal( GetVariableByName( vbl_name ) ) ); }