static void GetVariableVals( gui_window *gui, a_dialog_header *curr_dialog, bool closing ) /***********************************************************************/ /* Get the input variable values. Decide how to set these */ /* default values based on edit control type. */ { char *text; int i; int is_checked; gui_control_class a_control_class; vhandle *pVariable; vhandle var_handle; bool drive_checked; drive_checked = FALSE; pVariable = curr_dialog->pVariables; for( i = 0; pVariable[i] != NO_VAR; i++ ) { var_handle = pVariable[i]; a_control_class = ControlClass( VarGetId( var_handle ), curr_dialog ); switch( a_control_class ) { case GUI_STATIC: if( !closing ) { SetDynamic( gui, var_handle, &drive_checked ); } break; case GUI_RADIO_BUTTON: case GUI_CHECK_BOX: is_checked = (int)GUIIsChecked( gui, VarGetId( var_handle ) ); if( is_checked ) { if( VarIsRestrictedFalse( var_handle ) ) { if( !closing ) { MsgBox( gui, "IDS_NODISKFOROPTION", GUI_OK ); GUISetChecked( gui, VarGetId( var_handle ), 0 ); if( var_handle == FullInstall ) { GUISetChecked( gui, VarGetId( SelectiveInstall ), 1 ); } } SetVariableByHandle( var_handle, "0" ); if( var_handle == FullInstall ) { SetVariableByHandle( SelectiveInstall, "1" ); } } else { SetVariableByHandle( var_handle, "1" ); } } else { SetVariableByHandle( var_handle, "0" ); } break; case GUI_EDIT: text = GUIGetText( gui, VarGetId( var_handle ) ); if( text != NULL ) { SetVariableByHandle( var_handle, text ); GUIMemFree( text ); } break; default: break; } } }
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 ); }
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 ); }
static void SetRXStatus( gui_window *gui ) { int i; for( i = CTL_FIRST_RX; i <= CTL_LAST_RX; ++i ) { GUISetChecked( gui, i, strchr( SrchMagicChars, MetaChar(i) ) != NULL ); } }
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 void SetDlgStatus( gui_window *gui ) { unsigned old; old = NewCurrRadix( 10 ); GUISetChecked( gui, CTL_OPT_AUTO, _IsOn( SW_AUTO_SAVE_CONFIG ) ); GUISetChecked( gui, CTL_OPT_BELL, _IsOn( SW_BELL ) ); GUISetChecked( gui, CTL_OPT_IMPLICIT, _IsOn( SW_IMPLICIT ) ); GUISetChecked( gui, CTL_OPT_RECURSE, _IsOn( SW_RECURSE_CHECK ) ); GUISetChecked( gui, CTL_OPT_FLIP, _IsOn( SW_FLIP ) ); GUISetChecked( gui, CTL_OPT_CASE, _IsOn( SW_CASE_IGNORE ) ); DlgSetLong( gui, CTL_OPT_RADIX, old ); DlgSetLong( gui, CTL_OPT_DCLICK, WndGetDClick() ); NewCurrRadix( old ); GUIEnableControl( gui, CTL_OPT_BR_ON_WRITE, SupportsExactBreakpoints ); GUISetChecked( gui, CTL_OPT_NOHEX, _IsOn( SW_DONT_EXPAND_HEX ) ); if( SupportsExactBreakpoints ) GUISetChecked( gui, CTL_OPT_BR_ON_WRITE, _IsOn ( SW_BREAK_ON_WRITE ) ); else GUISetChecked( gui, CTL_OPT_BR_ON_WRITE, FALSE ); }
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; }
void WThreeState::setCheckState( WCheckState3 state ) { /*****************************************************/ GUISetChecked( parent()->handle(), controlId(), state ); }
static void SetDlgStatus( gui_window *gui ) { unsigned old; old = NewCurrRadix( 10 ); GUISetChecked( gui, CTL_WIND_ASM_SOURCE, _IsOn( SW_ASM_SOURCE ) ); GUISetChecked( gui, CTL_WIND_ASM_HEX, _IsOn( SW_ASM_HEX ) ); GUISetChecked( gui, CTL_WIND_VAR_EXPR, _IsOn( SW_VAR_WHOLE_EXPR ) ); GUISetChecked( gui, CTL_WIND_VAR_CODE, _IsOn( SW_VAR_SHOW_CODE ) ); GUISetChecked( gui, CTL_WIND_VAR_INHERIT, _IsOn( SW_VAR_SHOW_INHERIT ) ); GUISetChecked( gui, CTL_WIND_VAR_COMPILER, _IsOn( SW_VAR_SHOW_COMPILER ) ); GUISetChecked( gui, CTL_WIND_VAR_MEMBERS, _IsOn( SW_VAR_SHOW_MEMBERS ) ); GUISetChecked( gui, CTL_WIND_VAR_PRIVATE, _IsOn( SW_VAR_SHOW_PRIVATE ) ); GUISetChecked( gui, CTL_WIND_VAR_PROTECTED, _IsOn( SW_VAR_SHOW_PROTECTED ) ); GUISetChecked( gui, CTL_WIND_VAR_STATIC, _IsOn( SW_VAR_SHOW_STATIC ) ); GUISetChecked( gui, CTL_WIND_FUNC_TYPED, _IsOn( SW_FUNC_D2_ONLY ) ); GUISetChecked( gui, CTL_WIND_GLOB_TYPED, _IsOn( SW_GLOB_D2_ONLY ) ); GUISetChecked( gui, CTL_WIND_MOD_ALL, _IsOn( SW_MOD_ALL_MODULES ) ); DlgSetLong( gui, CTL_WIND_FILE_TAB, TabIntervalGet() ); NewCurrRadix( old ); }
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 ); }
static void UpdateControlVisibility( gui_window *gui, a_dialog_header *curr_dialog, bool init ) /*********************************************************************************************/ // Hide controls which have the optional visibility condition evaluate to false, and show // the ones that have it evaluate to true. (Controls with no vis. condition are always shown.) // When a control is hidden, the controls BELOW it move up by the hidden control's height. // A currently hidden controls that needs to be made visible causes all controls BELOW it // to move down by the "appearing" control's height so that it can be shown again. // The dialog window height also gets affected, while the top edge remains fixed on the screen. // // NOTE: be careful with RADIO_BUTTONS... making radio buttons appear and disappear because of // other radio buttons in the same dialog being checked may not work (nor does it make sense anyways) { gui_ord last_height; gui_rect rect; gui_rect control_rect; gui_rect parent_rect; gui_window *parent; int i, j, sign; unsigned id_i; unsigned id_j; unsigned checked_radio_id = 0; unsigned new_check_candidate; unsigned focus; unsigned new_focus; bool enabled; bool control_on_new_line[MAX_VARS]; bool visible_checked_radiobutton; vhandle var_handle; // vhandle *pVariable; if( gui == NULL ) return; if( init ) { // How much the height of the dialog has changed from its original value curr_dialog->height_change = 0; // The GUIGetRect below gets the dialog's position so that when it is resized, // it can be put back in its original position // NOTE that GUIGetRect does not want to give the EXACT location of the dialog, // so if you set the position to the coordinates that you got with GUIGetRect, // the dialog will MOVE slightly (not pleasing to the eye). // The current hack is to get the original coordinates, and go back to them every time // the dialog is resized with GUIResizeWindow. // This way, the dialog will be off by the same amount from the original // every time, and not appear to move. GUIGetRect( gui, &curr_dialog->original_rect ); // Make child windows appear in the correct place, since GUIGetRect() gives back // a rect that is tranlsated off by the parent's x and y. parent = GUIGetParentWindow( gui ); if( parent != MainWnd && parent != NULL ) { GUIGetRect( parent, &parent_rect ); curr_dialog->original_rect.x -= parent_rect.x; curr_dialog->original_rect.y -= parent_rect.y; } // Return if there are radio buttons // because UpdateControlVisibility is going to be called again anyways after init. // Without returning, the visibility conditions having to do with radio buttons // would not work sometimes. // We do not want to return if there are no radio buttons // because UpdateControlVisibility will not be called before showing // the dialog in that case. for( i = 0; i < curr_dialog->num_controls; i++ ) { if( curr_dialog->controls[i].control_class == GUI_RADIO_BUTTON ) { return; } } } memcpy( &rect, &curr_dialog->original_rect, sizeof( gui_rect ) ); last_height = rect.height + curr_dialog->height_change; control_on_new_line[0] = TRUE; GUIGetFocus( gui, &focus ); // Figure out which controls are on a separate line from the last control for( i = 1; i < curr_dialog->num_controls; i++ ) { if( curr_dialog->controls[i].rect.y > curr_dialog->controls[i - 1].rect.y ) { control_on_new_line[i] = TRUE; } else { control_on_new_line[i] = FALSE; } } // Initialize Variables corresponding to radio buttons and check boxes // This needs to be done for the part further below that checks to see if any // buttons are checked to work. // Also, figure out which radio button is currently checked. for( i = 0; i < curr_dialog->num_controls; i++ ) { if( curr_dialog->controls[i].control_class == GUI_RADIO_BUTTON || curr_dialog->controls[i].control_class == GUI_CHECK_BOX ) { // pVariable = curr_dialog->pVariables; var_handle = curr_dialog->controls[i].id; if( curr_dialog->controls[i].control_class == GUI_RADIO_BUTTON && GUIIsChecked( gui, VarGetId( var_handle ) ) ) { checked_radio_id = var_handle; } for( j = 0; curr_dialog->pVariables[j] != NO_VAR; j++ ) { if( curr_dialog->pVariables[j] == var_handle && GUIIsChecked( gui, VarGetId( var_handle ) ) ) { SetVariableByHandle( var_handle, "1" ); } } } } // Allow EvalCondition to evaluate conditions with no 'shortcuts' // (See GetOptionVarValue() in setupinf.c) // Kind of like an on and off (below) switch // for special behaviour of GetOptionVarValue() // SetVariableByName( "_Visibility_Condition_", "1" ); VisibilityCondition = 1; for( i = 0; i < curr_dialog->num_controls; i++ ) { // Figure out which controls to hide and which to show. // Move all the controls below any control in transition // either up or down. if( curr_dialog->pVisibilityConds[i] != NULL ) { id_i = curr_dialog->controls[i].id; enabled = GUIIsControlEnabled( gui, id_i ); if( EvalCondition( curr_dialog->pVisibilityConds[i] ) ) { if( !enabled ) { GUIEnableControl( gui, id_i, TRUE ); sign = 1; } else { continue; } } else if( enabled ) { GUIEnableControl( gui, id_i, FALSE ); GUIHideControl( gui, curr_dialog->controls[i].id ); sign = -1; } else { continue; } if( control_on_new_line[i] ) { for( j = i + 1; j < curr_dialog->num_controls && !control_on_new_line[j]; j++ ); for( ; j < curr_dialog->num_controls; j++ ) { id_j = curr_dialog->controls[j].id; enabled = GUIIsControlEnabled( gui, id_j ); GUIGetControlRect( gui, curr_dialog->controls[j].id, &control_rect ); control_rect.y += curr_dialog->controls[i].rect.height * sign; if( enabled ) { GUIHideControl( gui, id_j ); // control will be made visible again below // after being moved. } GUIResizeControl( gui, id_j, &control_rect ); } curr_dialog->height_change += curr_dialog->controls[i].rect.height * sign; } } } // SetVariableByName( "_Visibility_Condition_", "0" ); VisibilityCondition = 0; visible_checked_radiobutton = FALSE; new_check_candidate = 0; for( i = 0; i < curr_dialog->num_controls; i++ ) { id_i = curr_dialog->controls[i].id; // figure out if there are no enabled radio buttons that are checked // use this info further down... if( curr_dialog->controls[i].control_class == GUI_RADIO_BUTTON && !visible_checked_radiobutton && GUIIsControlEnabled( gui, id_i ) ) { if( GUIIsChecked( gui, id_i ) == GUI_CHECKED ) { visible_checked_radiobutton = TRUE; } else if( new_check_candidate == 0 ) { new_check_candidate = id_i; } } // show enabled controls that were hidden for moving only if( GUIIsControlEnabled( gui, id_i ) && !GUIIsControlVisible( gui, id_i ) ) { GUIShowControl( gui, id_i ); } } // Keep the original focus in case it has changed. GUIGetFocus( gui, &new_focus ); if( new_focus != focus && GUIIsControlEnabled( gui, focus ) ) { GUISetFocus( gui, focus ); } if( GUIIsControlEnabled( gui, checked_radio_id ) ) { GUISetChecked( gui, checked_radio_id, 1 ); } else if( !visible_checked_radiobutton && new_check_candidate != 0 ) { // 'Check' a visible radio button if the currently checked button // is invisible. GUISetChecked( gui, new_check_candidate, 1 ); } rect.height += curr_dialog->height_change; if( rect.height != last_height ) { GUIResizeWindow( gui, &rect ); } }
void WEXPORT WBoolSwitch::setCheck( bool check ) { /************************************************/ GUISetChecked( parent()->handle(), controlId(), check ); }