Ejemplo n.º 1
0
dlg_state DoDialog( const char *name )
/************************************/
{
    dlg_state result;

    if( SkipDialogs ) {
        result = DLG_NEXT;
    } else {
        result = DoDialogWithParent( NULL, name );
    }
    return result;
}
Ejemplo n.º 2
0
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 );
}