dlg_state DoDialogWithParent( void *parent, const char *name ) /************************************************************/ { a_dialog_header *dlg; dlg_state return_state; dlg = FindDialogByName( name ); if( dlg == NULL ) { return( DLG_CAN ); } return_state = DoDialogByPointer( parent, dlg ); if( return_state == DLG_CAN ) { // This block is a kludgy hack which allows a dialog to // return DLG_DONE when the ESC key is pressed, if it has a // DONE button rather than a CANCEL button. int i; bool can = false; bool done = false; for( i = 0; i < dlg->num_controls; i++ ) { if( dlg->controls[i].id == CTL_CANCEL ) { can = true; break; } if( dlg->controls[i].id == CTL_DONE ) { done = true; } } if( can == false && done == true ) { return_state = DLG_DONE; } } return( return_state ); }
extern a_dialog_header *AddNewDialog( const char *dlg_name ) /**********************************************************/ // Add new dialogs to front of linked list. // Delete default dialogs if specified. { a_dialog_header *tmp_dialog; a_dialog_header *new_dialog; new_dialog = (a_dialog_header *)GUIMemAlloc( sizeof( a_dialog_header ) ); memset( new_dialog, '\0', sizeof( *new_dialog ) ); new_dialog->name = GUIStrDup( dlg_name, NULL ); new_dialog->adjusted = false; new_dialog->def_dlg = false; new_dialog->defaults_set = false; new_dialog->ret_val = DLG_NEXT; new_dialog->any_check = NO_VAR; new_dialog->pVariables[0] = NO_VAR; new_dialog->pConditions[0] = NULL; /* check if old dialog existed */ tmp_dialog = FindDialogByName( dlg_name ); if( tmp_dialog != NULL ) { new_dialog->next = tmp_dialog->next; new_dialog->prev = tmp_dialog->prev; if( new_dialog->next != NULL ) { new_dialog->next->prev = new_dialog; } if( new_dialog->prev != NULL ) { new_dialog->prev->next = new_dialog; } if( FirstDialog == NULL ) { FirstDialog = new_dialog; LastDialog = new_dialog; } if( FirstDialog == tmp_dialog ) { FirstDialog = new_dialog; } if( LastDialog == tmp_dialog ) { LastDialog = new_dialog; } FreeDialog( tmp_dialog ); // replace old default dialog } else { new_dialog->prev = LastDialog; new_dialog->next = NULL; if( FirstDialog == NULL ) { FirstDialog = new_dialog; LastDialog = new_dialog; } else { LastDialog->next = new_dialog; } LastDialog = new_dialog; } return( new_dialog ); }
bool CheckDialog( const char *name ) /**********************************/ { a_dialog_header *dlg; dlg = FindDialogByName( name ); if( dlg == NULL ) { return( false ); } return( EvalCondition( dlg->condition ) ); }
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 ); }