示例#1
0
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 );
}
示例#2
0
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;
}
示例#3
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 );
}
示例#4
0
extern const char *GetVariableStrVal( const char *vbl_name )
/**********************************************************/
{
    return( VarGetStrVal( GetVariableByName( vbl_name ) ) );
}
示例#5
0
extern int VarGetIntVal( vhandle var_handle )
/*******************************************/
{
    return( atoi( VarGetStrVal( var_handle ) ) );
}