Ejemplo n.º 1
0
bool StatusInit( void )
/*********************/
{
    char        buff[MAXBUF];

    ReplaceVars( buff, sizeof( buff ), GetVariableStrVal( "AppName" ) );
    return( OpenStatusWindow( buff ) );
}
Ejemplo n.º 2
0
extern dlg_state GenericDialog( gui_window *parent, a_dialog_header *curr_dialog )
/********************************************************************************/
{
    char                *title;
    DLG_WINDOW_SET      result;
    int                 width;
    int                 height;
    char                buff[MAXBUF];

    if( curr_dialog == NULL ) {
        return( DLG_CAN );
    }
    AdjustDialogControls( curr_dialog );

    result.state = DLG_CAN;
    result.current_dialog = curr_dialog;
    if( curr_dialog->title != NULL ) {
        title = curr_dialog->title;
    } else {
        ReplaceVars( buff, GetVariableStrVal( "Appname" ) );
        title = buff;
    }
    width = curr_dialog->cols;
    height = curr_dialog->rows;
#if defined( __OS2__ ) && !defined( _UI )
    height -= 1;
#endif
    if( width < strlen(title) + WIDTH_BORDER + 2 ) {
        width = strlen(title) + WIDTH_BORDER + 2;
    }

    GUIRefresh();
    GUIModalDlgOpen( parent == NULL ? MainWnd : parent, title, height, width,
                     curr_dialog->controls, curr_dialog->num_controls,
                     &GenericEventProc, &result );
    ResetDriveInfo();
    return( result.state );
}
Ejemplo n.º 3
0
extern void GUImain( void )
/*************************/
{
    int                 argc = 0;
    char                **argv = NULL;
    char                *dir;
    char                *drive;
    char                *inf_name;
    char                *tmp_path;
    char                *arc_name;
    char                *new_inf;
    char                current_dir[_MAX_PATH];
    bool                ret = FALSE;
    dlg_state           state;

    GUIMemOpen();
    GUIGetArgs( &argv, &argc );
#if defined( __NT__ )
    if( CheckWin95Uninstall( argc, argv ) ) return;
#endif
#ifdef __WINDOWS__
    if( CheckForSetup32( argc, argv ) ) return;
#endif

    // initialize paths and env. vbls.

    if( !SetupPreInit() ) return;
    if( !GetDirParams( argc, argv, &inf_name, &tmp_path, &arc_name ) ) return;
    if( !SetupInit() ) return;
    GUIDrainEvents();   // push things along
    FileInit( arc_name );
    InitGlobalVarList();
    strcpy( current_dir, tmp_path );
    while( InitInfo( inf_name, tmp_path ) ) {

        ret = DoMainLoop( &state );

        if( state == DLG_DONE ) break;
//        if( CancelSetup == TRUE || !ret ) break;
        if( CancelSetup == TRUE ) break;
//        if( !ret ) break;

        // look for another SETUP.INF
        if( GetVariableByName( "SetupPath" ) == NO_VAR ) {
            if( DirParamStack( &inf_name, &tmp_path, Stack_IsEmpty ) == FALSE ) {  // "IsEmpty"?
                DirParamStack( &inf_name, &tmp_path, Stack_Pop ); // "Pop"
                CloseDownMessage( ret );
                CancelSetup = FALSE;
                ret = TRUE;
            } else {
                CloseDownMessage( ret );
                break;
            }
        } else {
            if( GetVariableIntVal( "IsMultiInstall" ) ) {
                // push current script on stack
                DirParamStack( &inf_name, &tmp_path, Stack_Push ); // "Push"
            }
            new_inf = GUIMemAlloc( _MAX_PATH );
            drive = GUIMemAlloc( _MAX_DRIVE );
            dir = GUIMemAlloc( _MAX_PATH );
            if( new_inf == NULL || drive == NULL || dir == NULL ) {
                GUIMemFree( new_inf );
                GUIMemFree( drive );
                GUIMemFree( dir );
                break;
            }
            // construct new path relative to previous
            ReplaceVars( new_inf, GetVariableStrVal( "SetupPath" ) );
            _splitpath( current_dir, drive, dir, NULL, NULL );
            _makepath( inf_name, drive, dir, new_inf, NULL );

            _splitpath( inf_name, drive, dir, NULL, NULL );
            _makepath( tmp_path, drive, dir, NULL, NULL );
//          strcpy( current_dir, tmp_path );

            GUIMemFree( new_inf );
            GUIMemFree( drive );
            GUIMemFree( dir );
        } /* if */

        FreeGlobalVarList( FALSE );
        FreeDefaultDialogs();
        FreeAllStructs();
        ConfigModified = FALSE;
    } /* while */


    FileFini();
    FreeGlobalVarList( TRUE );
    FreeDefaultDialogs();
    FreeAllStructs();
    FreeDirParams( &inf_name, &tmp_path, &arc_name );
    CloseDownProgram();
}
Ejemplo n.º 4
0
extern bool DoMainLoop( dlg_state * state )
/*****************************************/
{
    const char          *diag_list[MAX_DIAGS + 1];
    const char          *diags;
    const char          *dstdir;
    int                 dstlen;
    bool                got_disk_sizes = FALSE;
    int                 i;
    char                newdst[_MAX_PATH];
    char                *next;
    bool                ret = FALSE;

    SetupTitle();

    // display initial dialog
    diags = GetVariableStrVal( "DialogOrder" );
    if( stricmp( diags, "" ) == 0 ) {
        diags = "Welcome";
    }
    i = 0;
    for( ;; ) {
        diag_list[i] = diags;
        next = strchr( diags, ',' );
        if( next == NULL ) break;
        *next = '\0';
        diags = next + 1;
        ++i;
    }
    diag_list[i + 1] = NULL;
    /* process installation dialogs */

    i = 0;
    for( ;; ) {
        if( i < 0 ) break;
        if( diag_list[i] == NULL ) {
            if( GetVariableIntVal( "DoCopyFiles" ) == 1 ) {
                if( !CheckDrive( TRUE ) ) {
                    i = 0;
                }
            }
            if( GetVariableByName( "SetupPath" ) != NO_VAR ) {
                ret = TRUE;
                break;
            }
            if( diag_list[i] == NULL ) {
                    StatusShow( TRUE );
                    ret = SetupOperations();
                    StatusShow( FALSE );
                    if( ret ) DoDialog( "Finished" );
                    break;
            }
        }
        if( stricmp( diag_list[i], "GetDiskSizesHere" ) == 0 ) {
            if( *state == DLG_NEXT ) {

                dstdir = GetVariableStrVal( "DstDir" );
                dstlen = strlen( dstdir );
                if( dstlen != 0 &&
                    (dstdir[dstlen - 1] == '\\' || dstdir[dstlen - 1] == '/') ) {
                    strcpy( newdst, dstdir );
                    if( dstlen == 3 && dstdir[1] == ':' ) {
                        newdst[dstlen] = '.';
                        newdst[dstlen + 1] = '\0';
                    } else {
                        newdst[dstlen - 1] = '\0';
                    }
                    SetVariableByName( "DstDir", newdst );
                }
                SimSetNeedGetDiskSizes();
                ResetDiskInfo();
                got_disk_sizes = TRUE;

            }
        } else {
            *state = DoDialog( diag_list[i] );
            GUIWndDirty( NULL );
            StatusCancelled();
        }
        if( *state == DLG_CAN ) {
            if( MsgBox( NULL, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) {
                CancelSetup = TRUE;
                break;
            }
        } else if( *state == DLG_DONE ) {
            CancelSetup = TRUE;
            break;
        }
        if( got_disk_sizes ) {
            if( !CheckDrive( FALSE ) ) {
                break;
            }
        }
        if( *state == DLG_SAME ) {
            /* nothing */
        } else if( *state == DLG_NEXT || *state == DLG_SKIP ) {
            if( SkipDialogs ) {
                ++i;
            } else {
                for( ;; ) {
                    ++i;
                    if( diag_list[i] == NULL ) break;
                    if( CheckDialog( diag_list[i] ) ) break;
                }
            }
        } else if( *state == DLG_PREV ) {
            for( ;; ) {
                --i;
                if( i < 0 ) break;
                if( CheckDialog( diag_list[i] ) ) break;
            }
        } else if( *state == DLG_START ) {
            i = 0;
        }
    } /* for */

    return( ret );
}
Ejemplo n.º 5
0
static bool StatusEventProc( gui_window *gui, gui_event gui_ev, void *parm )
/**************************************************************************/
{
    static bool         button_pressed = false;
    gui_ctl_id          id;
    gui_key             key;
    gui_keystate        state;
    const char          *msg;

    parm = parm;
    if( gui == NULL )
        return( false );

    switch( gui_ev ) {

    case GUI_INIT_WINDOW:
        return( true );

    case GUI_PAINT:
        {
            if( StatusBarLen == 0 ) {
                break;
            }
            msg = GetVariableStrVal( Messages[MsgLine0] );
            GUIDrawTextExtent( gui, msg, strlen( msg ), LINE0_ROW,
                               LINE0_COL * CharSize.x, WND_STATUS_TEXT, GUI_NO_COLUMN );
            GUIDrawTextExtent( gui, StatusLine1, strlen( StatusLine1 ), LINE1_ROW,
                               LINE1_COL * CharSize.x, WND_STATUS_TEXT, GUI_NO_COLUMN );
#ifdef _UI
            {
                int         len1, len2;
                char        num[20];

                memset( StatusBarBuf, ' ', StatusBarLen );
                StatusBarBuf[StatusBarLen] = '\0';
                itoa( Percent, num, 10 );
                strcat( num, "%" );
                memcpy( StatusBarBuf + StatusBarLen / 2 - 1, num, strlen( num ) );
                // draw bar in two parts
                len1 = (StatusBarLen * (long)Percent) / 100;
                if( len1 < 0 ) {
                    len1 = 0;
                } else if( len1 > StatusBarLen ) {
                    len1 = StatusBarLen;
                }
                len2 = StatusBarLen - len1;
                if( len1 > 0 ) {
                    GUIDrawText( gui, StatusBarBuf, len1, STATUS_ROW,
                                 StatusBarRect.x, WND_STATUS_BAR );
                }
                if( len2 > 0 ) {
                    GUIDrawText( gui, StatusBarBuf + len1, len2, STATUS_ROW,
                                 StatusBarRect.x + len1 * CharSize.x, WND_STATUS_TEXT );
                }
                memset( StatusBarBuf, UiGChar[UI_SBOX_TOP_LINE], StatusBarLen );
                GUIDrawText( gui, StatusBarBuf, StatusBarLen, STATUS_ROW - 1,
                             StatusBarRect.x, WND_STATUS_TEXT );
                GUIDrawText( gui, StatusBarBuf, StatusBarLen, STATUS_ROW + 1,
                             StatusBarRect.x, WND_STATUS_TEXT );
            }
#else
            {
                gui_coord   coord;
                int         str_len, width, height;
                int         bar_width, len1, len2, divider;
                gui_point   start, end;
                gui_rect    rStatusBar;

//              sprintf( StatusBarBuf, "%d%%", Percent );
                // clear whole bar
                GUIFillRect( gui, &StatusBarRect, WND_STATUS_BAR );
                // calculate where divider splits rectangle
                bar_width = StatusBarRect.width;
                divider = (bar_width * (long)Percent) / 100;
                if( divider < 0 ) {
                    divider = 0;
                } else if( divider > bar_width ) {
                    divider = bar_width;
                }
                rStatusBar = StatusBarRect;
                rStatusBar.width = divider;
                // calculate position for text (centre it)
                str_len = strlen( StatusBarBuf );
                width = GUIGetExtentX( gui, StatusBarBuf, str_len );
                height = GUIGetExtentY( gui, StatusBarBuf );
                coord.y = StatusBarRect.y + (StatusBarRect.height - height) / 2;
                coord.x = StatusBarRect.x + (StatusBarRect.width - width) / 2;
                divider += StatusBarRect.x;
                if( coord.x > divider ) {
                    // text is completely to right of divider
                    GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT );
                    GUIDrawTextPos( gui, StatusBarBuf, str_len, &coord,
                                    WND_STATUS_TEXT );
                } else if( coord.x + width < divider ) {
                    // text is completely to left of divider
                    GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT );
                    GUIDrawTextPos( gui, StatusBarBuf, str_len, &coord,
                                    WND_STATUS_BAR );
                } else {
                    // need to split text
                    len1 = ((long)(divider - coord.x) * str_len) / width;
                    if( len1 < 0 ) {
                        len1 = 0;
                    } else if( len1 > str_len ) {
                        len1 = str_len;
                    }
                    len2 = str_len - len1;
                    // recalc divider, so it falls on a character boundary
                    divider = coord.x + GUIGetExtentX( gui, StatusBarBuf, len1 );
                    rStatusBar.width = divider - StatusBarRect.x;
                    GUIFillRect( gui, &rStatusBar, WND_STATUS_TEXT );
                    if( len1 > 0 ) {
                        GUIDrawTextPos( gui, StatusBarBuf, len1, &coord,
                                        WND_STATUS_BAR );
                    }
                    if( len2 > 0 ) {
                        coord.x = divider;
                        GUIDrawTextPos( gui, StatusBarBuf + len1, len2, &coord,
                                        WND_STATUS_TEXT );
                    }
                }
                // draw frame
                start.x = StatusBarRect.x;
                start.y = StatusBarRect.y;
                end.x = StatusBarRect.width + StatusBarRect.x;
                end.y = start.y;                                // top line
                GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME );
                start.y = StatusBarRect.y + StatusBarRect.height; // bottom line
                end.y = start.y;
                GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME );
                end.y = StatusBarRect.y;
                start.x = StatusBarRect.x;
                end.x = start.x;                            // left side
                GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME );
                start.x = StatusBarRect.x + StatusBarRect.width;
                end.x = start.x;                           // right side
                GUIDrawLine( gui, &start, &end, GUI_PEN_SOLID, 1, WND_STATUS_FRAME );
            }
#endif
            return( false );
        }

    case GUI_DESTROY:
        StatusWnd = NULL;
        return( false );

    case GUI_CONTROL_CLICKED:
        GUIGetFocus( gui, &id );
        GUI_GETID( parm, id );
        switch( id ) {
        case CTL_CANCEL:
            if( !button_pressed ) {
                button_pressed = true;
                if( MsgBox( gui, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) {
                    CancelSetup = true;
                }
                button_pressed = false;
                break;
            }
        case CTL_DONE:
            if( !button_pressed ) {
                CancelSetup = true;
                break;
            }
        }
        return( true );
    case GUI_KEYDOWN:
        GUI_GET_KEY_STATE( parm, key, state );
        state = state;
        switch( key ) {
        case GUI_KEY_ESCAPE:
            if( !button_pressed ) {
                button_pressed = true;
                if( MsgBox( gui, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) {
                    CancelSetup = true;
                }
                button_pressed = false;
                break;
            }
        default:
            break;
        }
        return( true );
    default:
        break;
    }
    return( false );
}