Beispiel #1
0
void main( void )
/***************/
{
    ui_event            ui_ev;
    SAREA               area;
    char                buff[80];
    an_event_string     *ptr;
    ORD                 evrow = TOP_ROW;
    int                 mrow, mcol;
    int                 diff;

    if( uistart() ) {
#ifdef CHARMAP
        uiinitgmouse( INIT_MOUSE_INITIALIZED ); /* the 0=mouseless,1=mouse,2=initialized mouse */
//      uivgaattrs();
        FlipCharacterMap();
#else
        initmouse( INIT_MOUSE_INITIALIZED );
#endif
        uimenus( barmenu, pulldownuimenus, EV_F1 );
        UIData->mouse_clk_delay = uiclockdelay( 250  /* ms */ );
        UIData->tick_delay      = uiclockdelay( 3000 /* ms */ );
        mainwin.area.height = UIData->height - 7;
        if( uivopen( &mainwin ) ) {
            for( ;; ) {
                uipushlist( evlist );
                ui_ev = uivgetevent( &mainwin );
                uipoplist( /* evlist */ );
                if( ui_ev == EV_MOUSE_PRESS_R ) {
                    uimousepos( NULL, &mrow, &mcol );
                    mrow++;
                    mcol++;
                    uipushlist( evlist );
                    ui_ev = uicreatepopup( mrow, mcol, filemenu, false, true, EV_NO_EVENT );
                    uipoplist( /* evlist */ );
                }
                switch( ui_ev ) {
                case EV_QUIT:
                    break;
                case EV_BACKGROUND_RESIZE:
                    uivclose( &mainwin );
                    mainwin.area.height = UIData->height - 7;
                    uivopen( &mainwin );
                    if( evrow > mainwin.area.height ) {
                        evrow = TOP_ROW;
                    }
                    break;
                case EV_SAMPLE_DIALOG:
                    sample_dialog();
                    break;
                case EV_OPEN:
                    open();
                    break;
                case EV_GO:
                    uispawnstart();
                    uiblankscreen();
                    printf( "Type exit to return\n" );
#if defined( __QNX__ ) || defined( __UNIX__ )
                    system( "" );
#elif defined( __WINDOWS__ )
                    // do nothing
#else
                    {
                        const char  *command;

                        command = getenv( "COMSPEC" );
                        if( command == NULL ) {
                            command = "c:\\command.com";
                        }
                        system( command );
                    }
#endif
                    uispawnend();
//                      uibackground( "wf.img" );
                    area.row = 0;
                    area.col = 0;
                    area.height = UIData->height;
                    area.width = UIData->width;
                    uidirty( area );
                    break;
                case EV_F1:
                    area.width = 10;
                    area.height = 10;
                    area.row = 1;
                    area.col = 1;
                    uivattribute( &mainwin, area, (ATTR) 1 );
                    break;
                }
                if( ui_ev == EV_QUIT ) {
                    break;
                } else if( ui_ev != EV_NO_EVENT ) {
                    for( ptr = evstrs; ; ++ptr ) {
                        if( ptr->ui_ev == EV_NO_EVENT ) {
                            sprintf( buff, "event 0x%4.4x", ui_ev );
                            break;
                        } else if( ptr->ui_ev == ui_ev ) {
                            sprintf( buff, "event 0x%4.4x (%s)", ui_ev, ptr->str );
                            break;
                        }
                    }
                    uivtextput( &mainwin, evrow, 2, UIData->attrs[ATTR_NORMAL], buff, 40 );
                    if( ++evrow >= mainwin.area.height ) {
                        evrow = TOP_ROW;
                    }
                    uivtextput( &mainwin, evrow, 2, UIData->attrs[ATTR_NORMAL], "", 40 );
                    switch( ui_ev ) {
                    case EV_MOUSE_PRESS:
                        BandOn = 1;
                        uimousepos( NULL, &mrow, &mcol );
                        BandArea.row = mrow;
                        BandArea.col = mcol;
                        BandArea.width = 0;
                        BandArea.height = 0;
                        uibandinit( BandArea, UIData->attrs[ATTR_ACTIVE] );
                        break;
                    case EV_MOUSE_DRAG:
                        if( BandOn ) {
                            uimousepos( NULL, &mrow, &mcol );
                            diff = mcol - BandArea.col;
                            if( diff < 0 )
                                diff = 0;
                            BandArea.width = diff;
                            diff = mrow - BandArea.row;
                            if( diff < 0 )
                                diff = 0;
                            BandArea.height = diff;
                            uibandmove( BandArea );
                        }
                        break;
                    case EV_MOUSE_RELEASE:
                        if( BandOn )
                            uibandfini();
                        BandOn = 0;
                        break;
                    }
                }
            }
            uivclose( &mainwin );
        }
        uinomenus();
        uiswap();
        uirestorebackground();  /* must be after uiswap */
#ifdef CHARMAP
        FlipCharacterMap();
        uifinigmouse();
#else
        finimouse();
#endif
        uistop();
    }
}
Beispiel #2
0
int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance,
                    LPSTR lpCmdLine, int nShowCmd ) {

    EVENT               ev;
    SAREA               area;
    char                buff[80];
    an_event_string     *ptr;
    ORD                 evrow = TOP_ROW;
    BOOL                fixup = FALSE;
    int                 mrow, mcol;
    int                 diff;

    hInstance = hInstance;
    hPrevInstance = hPrevInstance;
    lpCmdLine = lpCmdLine;
    nShowCmd = nShowCmd;
    if( InitSwapper() ) return( 0 ); // Yes - well, I would make the swapper
                                     // return 1 on error, unlike everything
                                     // else, wouldn't I?
    if( !uistart() ) return( 0 );
    ToCharacter();

    initmouse( 2 );
    uimenus( barmenu, pulldownuimenus, EV_FUNC( 1 ) );
    UIData->mouse_clk_delay = uiclockdelay( 250 );
    UIData->tick_delay = uiclockdelay( 3000 );
    mainwin.area.height = UIData->height - 7;

    area.row = 0;
    area.col = 0;
    area.width = UIData->width;
    area.height = UIData->height;
    uidirty( area );
    uirefresh();

    if( uivopen( &mainwin ) ) {
        uirefresh();
        sprintf( buff, "screen height : %d\0", UIData->height );
        uivtextput( &mainwin, TOP_ROW - 1, 2,
                  UIData->attrs[ ATTR_NORMAL ],
                  buff, 30 );
        for( ; ; ) {
            uipushlist( evlist );
            ev = uivgetevent( NULL );
            uipoplist();
            if( ev == EV_QUIT ) break;
            if( ev == EV_ALT_R ) break;
            if( ev == EV_MOUSE_PRESS_R ) {
                uimousepos( NULL, &mrow, &mcol );
                mrow++;
                mcol++;
                uipushlist( evlist );
                ev = uicreatepopup( mrow, mcol, &filemenu, FALSE, TRUE, NULL );
                uipoplist();
            }
            switch ( ev ) {
                case EV_SAMPLE_DIALOG:
                    sample_dialog();
                    break;
                case EV_OPEN:
                    open();
                    break;
                case EV_FUNC(1):
                    area.width = 10;
                    area.height = 10;
                    area.row = 1;
                    area.col = 1;
                    uivattribute( &mainwin, area, (ATTR) 1 );
                    break;
                case EV_CURSOR_RIGHT:
                    mainwin.col++;
                    if( mainwin.col >= mainwin.area.width ) mainwin.col--;
                    fixup = TRUE;
                    break;
                case EV_CURSOR_DOWN:
                    mainwin.row++;
                    if( mainwin.row >= mainwin.area.height ) mainwin.row--;
                    fixup = TRUE;
                    break;
                case EV_CURSOR_LEFT:
                    if( mainwin.col > 0 ) {
                        mainwin.col--;
                        fixup = TRUE;
                    }
                    break;
                case EV_CURSOR_UP:
                    if( mainwin.row > 0 ) {
                        mainwin.row--;
                        fixup = TRUE;
                    }
                    break;
            }
            if( fixup ) {
                fixup = FALSE;
                uivsetcursor( &mainwin );
            }
            if( ev != EV_NO_EVENT ) {
                for( ptr=evstrs; ; ++ptr ){
                    if( ptr->ev == EV_NO_EVENT ) {
                        sprintf( buff, "event 0x%4.4x", ev );
                        break;
                    } else if( ptr->ev == ev ) {
                        strcpy( buff, ptr->str );
                        break;
                    }
                }
                uivtextput( &mainwin, evrow, 2,
                          UIData->attrs[ ATTR_NORMAL ],
                          buff, 30 );
                if( ++evrow >= mainwin.area.height ){
                    evrow = TOP_ROW;
                }
                uivtextput( &mainwin, evrow, 2,
                          UIData->attrs[ ATTR_NORMAL ],
                          "", 30 );
                switch( ev ) {
                case EV_MOUSE_PRESS:
                    BandOn = 1;
                    uimousepos( NULL, &mrow, &mcol );
                    BandArea.row = mrow;
                    BandArea.col = mcol;
                    BandArea.width = 0;
                    BandArea.height = 0;
                    uibandinit( BandArea, UIData->attrs[ ATTR_ACTIVE ] );
                    break;
                case EV_MOUSE_DRAG:
                    if( BandOn ) {
                        uimousepos( NULL, &mrow, &mcol );
                        diff = mcol - BandArea.col;
                        if( diff < 0 ) diff = 0;
                        BandArea.width = diff;
                        diff = mrow - BandArea.row;
                        if( diff < 0 ) diff = 0;
                        BandArea.height = diff;
                        uibandmove( BandArea );
                    }
                    break;
                case EV_MOUSE_RELEASE:
                    if( BandOn ) uibandfini();
                    BandOn = 0;
                    break;
                }
            }
        }
        uivclose( &mainwin );
    }
    uinomenus();
    uiswap();
    uirestorebackground();      /* must be after uiswap */
    finimouse();
    ToGraphical();
    uistop();
    FiniSwapper();
    return( 0 );
}