static void open( void ) /**********************/ { ui_event ui_ev; if( uivopen( &opwin ) ) { uipushlist( oplist ); uivtextput( &opwin, 1, 2, UIData->attrs[ATTR_NORMAL], "Enter file name.", 16 ); inputline.attr = UIData->attrs[ATTR_EDIT]; /* blank out the buffer */ inputline.index = 0; inputline.scroll = 0; inputline.update = true; for( ;; ) { ui_ev = uiveditline( &opwin, &inputline ); if( ui_ev != EV_NO_EVENT ) { break; } } if( ui_ev == EV_ENTER ) { /* open file */ } else if( ui_ev == EV_ESCAPE ) { /* do nothing */ } else { /* must be an event handled in the mainline */ uiungetevent(); } uipoplist( /* oplist */ ); uivclose( &opwin ); } }
VSCREEN intern *uiopen( SAREA *area, const char *title, screen_flags flags ) /**************************************************************************/ { VSCREEN *s; s = uimalloc( sizeof( VSCREEN ) ); if( s == NULL ) { return( s ); } s->event = EV_NO_EVENT; s->area = *area; s->flags = flags; s->col = 0; s->row = 0; s->cursor = C_OFF; s->title = NULL; s->dynamic_title = false; if( title != NULL ) { unsigned len; char *str; len = strlen( title ); str = uimalloc( len + 1 ); memcpy( str, title, len ); str[len] = '\0'; s->title = str; s->dynamic_title = true; } uivopen( s ); return( s ); }
void uiredrawdialog( a_dialog *ui_dlg_info ) { VSCREEN *vs; VFIELD *fields; vs = ui_dlg_info->vs; uivclose( vs ); uivopen( vs ); for( fields = ui_dlg_info->fields; fields->typ != FLD_NONE; fields++ ) { print_field( ui_dlg_info->vs, fields, ( fields == ui_dlg_info->curr ) ); } }
void uiredrawdialog( a_dialog *info ) { VSCREEN *vs; int i; vs = (VSCREEN *)info->vs; uivclose( vs ); uivopen( vs ); for( i = 0 ; info->fields[i].typ != FLD_VOID ; ++i ) { print_field( info->vs, &info->fields[i], &info->fields[i] == info->curr ); } }
bool uiresizedialog( a_dialog *info, SAREA *new_area ) { int row_diff; int col_diff; VSCREEN *vs; VFIELD *curr; int i; bool resize; vs = (VSCREEN *)info->vs; if( new_area->row < 2 ) { new_area->row = 2; } if( new_area->col < 1 ) { new_area->col = 1; } if( new_area->row + vs->area.height >= UIData->height ) { new_area->row = UIData->height - vs->area.height - 1; } if( new_area->col + vs->area.width >= UIData->width ) { new_area->col = UIData->width - vs->area.width - 1; } row_diff = new_area->row - vs->area.row; col_diff = new_area->col - vs->area.col; resize = ( new_area->width != vs->area.width ) || ( new_area->height != vs->area.height ); if( resize ) { uivclose( vs ); vs->area = *new_area; uivopen( vs ); } else { uivmove( info->vs, new_area->row, new_area->col ); } /* close all open pull down boxes */ for( curr = info->fields; curr->typ != FLD_VOID; curr++ ) { uimovefield( info, curr, row_diff, col_diff ); } if( resize ) { for( i = 0 ; info->fields[i].typ != FLD_VOID ; ++i ) { print_field( info->vs, &info->fields[i], &info->fields[i] == info->curr ); } } return( TRUE ); }
bool uiresizedialog( a_dialog *ui_dlg_info, SAREA *new_area ) { int row_diff; int col_diff; VSCREEN *vs; VFIELD *fields; bool resize; vs = ui_dlg_info->vs; if( new_area->row < 2 ) { new_area->row = 2; } if( new_area->col < 1 ) { new_area->col = 1; } if( new_area->row + vs->area.height >= UIData->height ) { new_area->row = UIData->height - vs->area.height - 1; } if( new_area->col + vs->area.width >= UIData->width ) { new_area->col = UIData->width - vs->area.width - 1; } row_diff = new_area->row - vs->area.row; col_diff = new_area->col - vs->area.col; resize = ( new_area->width != vs->area.width ) || ( new_area->height != vs->area.height ); if( resize ) { uivclose( vs ); vs->area = *new_area; uivopen( vs ); } else { uivmove( ui_dlg_info->vs, new_area->row, new_area->col ); } /* close all open pull down boxes */ for( fields = ui_dlg_info->fields; fields->typ != FLD_NONE; fields++ ) { uimovefield( ui_dlg_info, fields, row_diff, col_diff ); } if( resize ) { for( fields = ui_dlg_info->fields; fields->typ != FLD_NONE; fields++ ) { print_field( ui_dlg_info->vs, fields, ( fields == ui_dlg_info->curr ) ); } } return( true ); }
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(); } }
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 ); }
/* * dispHelp */ static int dispHelp( char *str, VTAB *tab ) { EVENT ev; bool done; int lastline; int start; SAREA use; SAREA line; char helpname[81]; ignoreMouseRelease = true; helpSet( str, helpname, sizeof( helpname ) ); if( uivopen( &helpScreen ) == NULL ) return( HELP_NO_VOPEN ); use.height = helpScreen.area.height - 3; use.width = helpScreen.area.width; use.col = 0; line.height = 1; line.width = helpScreen.area.width; line.col = 0; topPos = HelpTell( helpFileHdl ); mygetline(); handleHeader( &start, &line ); use.row = start; use.height -= start; handleFooter( &start, &use, &line ); setupScrollBar( &use ); if( helpLines > 0 ) { maxPos = helpLines + 1; helpPos = HelpMemAlloc( maxPos * sizeof( *helpPos ) ); } else { maxPos = 0; helpPos = NULL; } maxLine = 0; lastHelpLine = 0; save_line( 0, topPos ); currLine = helpStack->line; seek_line( currLine ); lastline = currLine + use.height; done = false; ev = EV_NO_EVENT; while( !done ) { currentColour = C_PLAIN; currentAttr = AT( ATTR_NORMAL ); if( lastline != currLine ) { lastline = scrollHelp( &use, lastline, ( ev != EV_NO_EVENT ) ); } ev = hlpwait( tab ); switch( ev ) { case E_UP: case EV_CURSOR_UP: case EV_TOP: if( currLine > 0 ) { --currLine; } break; case E_DOWN: case EV_CURSOR_DOWN: case EV_BOTTOM: ++currLine; if( maxLine != 0 && currLine+use.height > maxLine ) { --currLine; } break; case EV_SCROLL_VERTICAL: currLine = vGadget.pos; break; case EV_PAGE_UP: currLine -= use.height; if( currLine < 0 ) { currLine = 0; } break; case EV_PAGE_DOWN: currLine += use.height; if( maxLine != 0 && currLine >= maxLine ) { currLine -= use.height; } break; default: done = true; break; } } clearline(); uivclose( &helpScreen ); if( helpPos != NULL ) { HelpMemFree( helpPos ); helpPos = NULL; } return( HELP_OK ); }