static void echoline( VSCREEN *vptr, VEDITLINE *editline ) /********************************************************/ { SAREA area; unsigned start; unsigned trim; if( editline->invisible ) { area.row = editline->row; area.col = editline->col; area.height = 1; area.width = editline->fldlen; uivfill( vptr, area, editline->attr, ' ' ); for( trim = editline->length ; trim > editline->index ; --trim ) { if( editline->buffer[ trim - 1 ] != ' ' ) break; } area.width = min( editline->fldlen, trim - editline->scroll ); uivfill( vptr, area, editline->attr, '*' ); } else { uitextfield( vptr, editline->row, editline->col, editline->fldlen, editline->attr, editline->buffer + editline->scroll, editline->length - editline->scroll ); } if( editline->marking ) { area.row = editline->row; area.height = 1; if( editline->mark_anchor < editline->index ) { start = editline->mark_anchor; area.width = editline->index - editline->mark_anchor; } else { start = editline->index; area.width = editline->mark_anchor - editline->index; } if( area.width + start >= editline->scroll && area.width > 0 ) { if( start > editline->scroll ) { area.col = editline->col + start - editline->scroll; } else { area.col = editline->col; area.width = area.width - editline->scroll + start; } if( area.width + area.col > editline->col + editline->fldlen ) { area.width = editline->fldlen + editline->col - area.col; } uivattribute( vptr, area, editline->mark_attr ); } } }
static bool DrawRect( gui_window *wnd, gui_rect *rect, gui_attr attr, bool fill, bool outline, char draw_char ) { SAREA area; gui_coord coord; if( ( rect->width == 0 ) || ( rect->height == 0 ) || ( (wnd->flags & CONTENTS_INVALID) == 0 ) ) { return( false ); } coord.x = rect->x; coord.y = rect->y; GUIScaleToScreenR( &coord ); area.col = coord.x; area.row = coord.y; coord.x = rect->width; coord.y = rect->height; GUIScaleToScreenR( &coord ); area.width = coord.x; area.height = coord.y; if( AdjustRect( wnd, &area ) ) { if( fill ) { uivfill( &wnd->screen, area, wnd->colours[attr], draw_char ); } if( outline ) { uidrawbox( &wnd->screen, &area, wnd->colours[attr], NULL ); } } return( true ); }
bool GUIDrawLine( gui_window *wnd, gui_point *start, gui_point *end, gui_line_styles style, gui_ord thickness, gui_attr attr ) { gui_point my_start; gui_point my_end; SAREA area; char to_use; /* unused parameters */ (void)style; (void)thickness; my_start = *start; my_end = *end; GUIScaleToScreenRPt( &my_start ); GUIScaleToScreenRPt( &my_end ); area.row = my_start.y; area.height = my_end.y - my_start.y + 1; area.col = my_start.x; area.width = my_end.x - my_start.x + 1; if( my_start.x == my_end.x ) { to_use = DRAW( VERT_FRAME ); } else { if( my_start.y == my_end.y ) { to_use = DRAW( HOR_FRAME ); } else { return( false ); } } if( AdjustRect( wnd, &area ) ) { uivfill( &wnd->screen, area, wnd->colours[attr], to_use ); } return( true ); }
void GUIDrawIcon( gui_window * wnd ) { SAREA area; int length; ATTR attr; char *str; COPYAREA( wnd->screen.area, area ); area.row = 0; area.col = 0; attr = wnd->colours[GUI_ICON]; uivfill( &wnd->screen, area, attr, ' ' ); uidrawbox( &wnd->screen, &area, attr, NULL ); str = NULL; if( wnd->icon_name != NULL ) { str = wnd->icon_name; } else { if( wnd->screen.name != NULL ) { str = wnd->screen.name; } } if( str != NULL ) { length = strlen( str ); if( length > ( area.width - 2 ) ) { length = area.width - 2; } uivtextput( &wnd->screen, ( area.height / 2 ), 1, attr, str, length ); } }
/* * handleHeader - scan through and process header information */ static void handleHeader( int *start, SAREA *line ) { int cur; cur = 0; if( strnicmp( helpInBuf, ":h", 2 ) == 0 ) { for( ;; ) { if( !mygetline() ) break; if( strnicmp( helpInBuf, ":t", 2 ) == 0 ) break; if( strnicmp( helpInBuf, ":eh", 3 ) == 0 ) break; processLine( helpInBuf, helpOutBuf, cur, false ); putline( helpOutBuf, cur ); cur ++; } line->row = cur; uivfill( &helpScreen, *line, AT( ATTR_NORMAL ), UiGChar[UI_SBOX_HORIZ_LINE] ); cur++; topPos = HelpTell( helpFileHdl ); if( strnicmp( helpInBuf, ":eh", 3 ) == 0 ) { mygetline(); } } *start = cur; }
/* * handleFooter - scan through and process footer information */ static void handleFooter( int *startline, SAREA *use, SAREA *line ) { int start; start = *startline; if( strnicmp( helpInBuf, ":t", 2 ) == 0 ) { ++start; /* leave room for line */ for( ;; ) { if( !mygetline() ) break; if( strnicmp( helpInBuf, ":et", 3 ) == 0 ) break; processLine( helpInBuf, helpOutBuf, start, false ); putline( helpOutBuf, start ); ++start; } vscroll_fields( &helpTab, *use, start - use->row - use->height ); vvscroll( &helpScreen, *use, start - use->row - use->height ); use->height -= start - use->row; line->row = use->row + use->height; uivfill( &helpScreen, *line, AT( ATTR_NORMAL ), UiGChar[UI_SBOX_HORIZ_LINE] ); topPos = HelpTell( helpFileHdl ); } *startline = start; }
VSCREEN* global uivopen( register VSCREEN *vptr ) /***********************************************/ { register char* box; register ATTR attr; register int priority; register void (_FAR *updatertn)( struct sarea, void * ); register bool okbuffer; register int len; register ORD col; register unsigned int flags; register bool covered; auto SAREA area; okarea( vptr->area ); flags = vptr->flags; area = vptr->area; if( ( flags & V_DIALOGUE ) != 0 ) { if( flags & V_LISTBOX ) { box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_NORMAL ]; } else { box = (char *)&UiGChar[ UI_BOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_DIAL_FRAME ]; } priority = P_DIALOGUE; } else { flags &= ~V_UNBUFFERED; box = (char *)&UiGChar[ UI_SBOX_TOP_LEFT ]; attr = UIData->attrs[ ATTR_FRAME ]; priority = P_VSCREEN; } if( ( flags & V_UNFRAMED ) == 0 ) { (area.row)--; (area.col)--; (area.height) += 2; (area.width) += 2; okarea( area ); } if( ( flags & V_UNBUFFERED ) != 0 ) { priority = P_UNBUFFERED; bfake( &(vptr->window.type.buffer), area.row, area.col ); okbuffer = TRUE; updatertn = NULL; } else { okbuffer = balloc( &(vptr->window.type.buffer), area.height, area.width ); updatertn = (void(*)(struct sarea,void *))update; } if( okbuffer ) { vptr->window.area = area; vptr->window.priority = priority; vptr->window.update = updatertn; vptr->window.parm = vptr; covered = openwindow( &(vptr->window) ); vptr->flags = flags; if( ( flags & V_UNFRAMED ) == 0 ) { if( ( !UIData->no_blowup ) && ( covered == FALSE ) && ( ( flags & V_NO_ZOOM ) == 0 ) ) { blowup( &UIData->screen, area, box, attr ); } area.row = 0; area.col = 0; drawbox( &(vptr->window.type.buffer), area, box, attr, FALSE ); if( vptr->name != NULL ) { #if 0 do not delete this stuff col = 0; len = area.width; bstring( &(vptr->window.type.buffer), 0, col, UIData->attrs[ATTR_CURR_SELECT_DIAL], " ", len ); len = __min( strlen( vptr->name ), area.width ); col = ( area.width - len ) / 2; bstring( &(vptr->window.type.buffer), 0, col, UIData->attrs[ATTR_CURR_SELECT_DIAL], vptr->name, len ); #else len = __min( strlen( vptr->name ), area.width ); col = ( area.width - len ) / 2; bstring( &(vptr->window.type.buffer), 0, col, attr, vptr->name, len ); #endif } bframe( &(vptr->window.type.buffer ) ); } area = vptr->area; area.row = 0; area.col = 0; vptr->open = TRUE; uivfill( vptr, area, UIData->attrs[ ATTR_NORMAL ], ' ' ); uivsetcursor( vptr ); return( vptr ); } return( NULL ); }
void GUIXDrawText( gui_window *wnd, const char *text, size_t length, gui_coord *in_pos, gui_attr attr, gui_ord extentx, bool draw_extent ) { int vscroll; /* vertical scroll adjust amount */ int hscroll; /* horizontal scroll adjust amount */ size_t my_length; /* actual length of text (may be > length) */ gui_coord my_pos; /* pos in screen coords */ int pos; /* position to draw on VSCREEN */ int col; /* index into string */ gui_coord extent; SAREA area; int width; int frame_adjust; if( attr >= wnd->num_attrs ) { return; } if( !( wnd->style & GUI_VISIBLE ) ) { return; } if( wnd->style & GUI_NOFRAME ) { frame_adjust = 0; } else { frame_adjust = 1; } my_pos.x = in_pos->x; my_pos.y = in_pos->y; GUIScaleToScreenR( &my_pos ); /* adjust for scrolling */ vscroll = 0; if( ( wnd->vgadget != NULL ) && ( !GUI_VSCROLL_EVENTS_SET( wnd ) ) ) { vscroll += wnd->vgadget->pos; } hscroll = 0; if( ( wnd->hgadget != NULL ) && !GUI_HSCROLL_EVENTS_SET( wnd ) ) { hscroll += wnd->hgadget->pos; } if( ( my_pos.y - vscroll + frame_adjust ) < frame_adjust ) { /* row to draw is not visible with vertical scrolling */ return; } if( text != NULL ) { my_length = strlen( text ); if( my_length < length ) { length = my_length; } } else { my_length = 0; } /* if text shows even with scrolling */ if( ( my_pos.x + length ) > hscroll ) { pos = frame_adjust; /* position on VSCREEN */ col = 0; /* index into curr string */ /* start of text in dirty region */ if( ( ( wnd->dirty.col - 1 ) <= ( my_pos.x - hscroll ) ) && ( my_pos.x >= hscroll ) ) { pos += ( my_pos.x - hscroll ); } else { /* start of text to left of dirty region */ pos += wnd->dirty.col - 1; if( my_pos.x < hscroll ) { /* start of text scrolled off screen */ col += ( hscroll - my_pos.x + wnd->dirty.col - 1 ); length -= ( hscroll - my_pos.x + wnd->dirty.col - 1 ); } else { /* start of text visible but to left of dirty region */ col += ( wnd->dirty.col - 1 + hscroll - my_pos.x ); length -= ( wnd->dirty.col - 1 + hscroll - my_pos.x ); } } /* should deal with decreasing length due to text off screen to right */ if( ( length > 0 ) && ( ( col - hscroll ) < ( wnd->dirty.col + wnd->dirty.width ) ) ) { if( ( pos + length ) > ( wnd->dirty.col + wnd->dirty.width ) ) { length = wnd->dirty.col + wnd->dirty.width - pos; } if( length > 0 ) { char *p; const char *cp; for( cp = text; cp < text+col; cp += GUICharLen( *cp ) ) ; if( cp != text + col ) { p = alloca( length ); cp = memcpy( p, text+col, length ); p[0] = ' '; } uivtextput( &wnd->screen, my_pos.y - vscroll + frame_adjust, pos, wnd->colours[attr], cp, length ); } else { length = 0; } } else { length = 0; } } else { pos = -length + 1; /* so (pos+length) will be 1 for drawing extent */ } if( draw_extent ) { if( extentx == GUI_NO_COLUMN ) { /* this is the most that will be covered. It will be adjust for starting position and dirty rect */ extentx = wnd->use.width; } else { /* record total width user wants to cover, adjusting for * portion not visible due to scrolling scrolling */ extent.x = extentx + in_pos->x; GUIScaleToScreenR( &extent ); extentx = extent.x - hscroll; } if( ( pos + length ) <= extentx ) { area.row = my_pos.y - vscroll + frame_adjust; area.height = 1; area.col = pos + length; /* adjust left border for dirty area */ if( area.col < wnd->dirty.col ) { area.col = wnd->dirty.col; } width = extentx - area.col + 1; /* adjust right border for dirty area */ if( ( area.col + width ) > ( wnd->dirty.col + wnd->dirty.width ) ) { width = wnd->dirty.width + wnd->dirty.col - area.col; } if( width > 0 ) { area.width = width; uivfill( &wnd->screen, area, wnd->colours[attr], ' ' ); } } } }