/******************************************************************************* G_LINE in popup menu *******************************************************************************/ int cdecl _drawNiceLine(PARMBLK *parm) { vqf_attributes(glb.vdi.ha,fattr); vql_attributes(glb.vdi.ha,lattr); my1.g_x=parm->pb_x; my1.g_y=parm->pb_y; my1.g_w=parm->pb_w; my1.g_h=parm->pb_h; my2.g_x=parm->pb_xc; my2.g_y=parm->pb_yc; my2.g_w=parm->pb_wc; my2.g_h=parm->pb_hc; _rcIntersect(&my1,&my2); tab_clip[0]=my2.g_x; tab_clip[1]=my2.g_y; tab_clip[2]=tab_clip[0]+my2.g_w-1; tab_clip[3]=tab_clip[1]+my2.g_h-1; vs_clip(glb.vdi.ha,TRUE,tab_clip); bar[0]=my1.g_x; bar[1]=my1.g_y; bar[2]=bar[0]+my1.g_w-1; bar[3]=bar[1]+my1.g_h-1; vswr_mode(glb.vdi.ha,MD_REPLACE); vsf_perimeter(glb.vdi.ha,FALSE); vsf_interior(glb.vdi.ha,FIS_SOLID); vsf_style(glb.vdi.ha,0); vsf_color(glb.vdi.ha,WHITE); v_bar(glb.vdi.ha,bar); vsl_type(glb.vdi.ha,USERLINE); vsl_width(glb.vdi.ha,1); vsl_udsty(glb.vdi.ha,(int)0x5555); x=parm->pb_x; y=parm->pb_y+parm->pb_h/2; bar[0]=x; bar[1]=y; bar[2]=x+parm->pb_w; bar[3]=y; v_pline(glb.vdi.ha,2,bar); bar[1]+=1; bar[3]+=1; vsl_udsty(glb.vdi.ha,(int)0xAAAA); v_pline(glb.vdi.ha,2,bar); vs_clip(glb.vdi.ha,FALSE,tab_clip); vsl_type(glb.vdi.ha,lattr[0]); vsl_color(glb.vdi.ha,lattr[1]); vsf_interior(glb.vdi.ha,fattr[2]); vsf_style(glb.vdi.ha,fattr[0]); vsf_perimeter(glb.vdi.ha,fattr[4]); return parm->pb_currstate&~DISABLED; }
void iw_xdraw(ICONWIND iw) { WORD xy[4], bxy[10]; wind_update(BEG_UPDATE); graf_mouse(M_OFF, NULL); rc_getpts(&iw->w.rwind, xy); vs_clip(iw->w.wsid, 1, xy); vswr_mode(iw->w.wsid, MD_XOR); vsl_color(iw->w.wsid, BLACK); vsl_ends(iw->w.wsid, 0, 0); vsl_type(iw->w.wsid, 1); vsl_width(iw->w.wsid, 1); rc_boxpts(&iw->w.rwind, bxy); bxy[9]--; v_pline(iw->w.wsid, 5, bxy); vsf_color(iw->w.wsid, BLACK); vsf_interior(iw->w.wsid, FIS_SOLID); vsf_perimeter(iw->w.wsid, 0); xy[0]++, xy[2]--; xy[3] = xy[1]++ + 7; v_bar(iw->w.wsid, xy); graf_mouse(M_ON, NULL); wind_update(END_UPDATE); }
static void draw_icns(ICND *icns, int n, int mx, int my, int *clip) { int i, j, c[18], x, y; clip_coords(clip, mx, my, &x, &y); vswr_mode(vdi_handle, MD_XOR); vsl_color(vdi_handle, 1); vsl_ends(vdi_handle, 0, 0); vsl_type(vdi_handle, 7); vsl_udsty(vdi_handle, 0xCCCC); vsl_width(vdi_handle, 1); graf_mouse(M_OFF, NULL); for (i = 0; i < n; i++) { for (j = 0; j < icns[i].np; j++) { c[j * 2] = icns[i].coords[j * 2] + x; c[j * 2 + 1] = icns[i].coords[j * 2 + 1] + y; } v_pline(vdi_handle, icns[i].np, c); } graf_mouse(M_ON, NULL); }
void set_rect_default(void) { vswr_mode(vdi_handle, MD_XOR); vsl_color(vdi_handle, 1); vsl_ends(vdi_handle, 0, 0); vsl_type(vdi_handle, 7); vsl_udsty(vdi_handle, 0xCCCC); vsl_width(vdi_handle, 1); }
/* Draw the two lines for the axes */ void draw_axes_lines (int app_handle, int x, int y, int w, int h) { int axes[6]; vsl_color (app_handle, BLACK); vsl_type (app_handle, SOLID); vsl_width (app_handle, 1); axes[0] = x; axes[1] = y-h; axes[2] = x; axes[3] = y; axes[4] = x+w; axes[5] = y; v_pline (app_handle, 3, axes); }
static void xw_redraw_menu(WINDOW *w, int object, RECT *r) { RECT r1, r2, in; OBJECT *menu = w->xw_menu; int pxy[4]; if (menu != NULL) { /* xw_bar_rect(w,&r1);*/ xd_objrect(w->xw_menu, object, &r1); if (object == w->xw_bar) r1.h += 1; /* Begin en eind coordinaten van lijn onder de menubalk. */ pxy[0] = w->xw_work.x; pxy[1] = pxy[3] = w->xw_work.y + r1.h - 1; pxy[2] = w->xw_work.x + w->xw_work.w - 1; if (xd_rcintersect(r, &r1, &r1) == TRUE) { xd_wdupdate(BEG_UPDATE); xd_mouse_off(); vswr_mode(xd_vhandle, MD_REPLACE); vsl_color(xd_vhandle, 1); vsl_ends(xd_vhandle, 0, 0); vsl_type(xd_vhandle, 1); vsl_width(xd_vhandle, 1); xw_get(w, WF_FIRSTXYWH, &r2); while ((r2.w != 0) && (r2.h != 0)) { if (xd_rcintersect(&r1, &r2, &in) == TRUE) { objc_draw(menu, w->xw_bar, MAX_DEPTH, in.x, in.y, in.w, in.h); xd_clip_on(&in); v_pline(xd_vhandle, 2, pxy); xd_clip_off(); } xw_get(w, WF_NEXTXYWH, &r2); } xd_mouse_on(); xd_wdupdate(END_UPDATE); } } }
WORD gsx_start(VOID) { WORD char_height, nc, attrib[10]; gl_xclip = 0; gl_yclip = 0; gl_width = gl_wclip = gl_ws.ws_xres + 1; gl_height = gl_hclip = gl_ws.ws_yres + 1; nc = gl_ws.ws_ncolors; gl_nplanes = 0; while (nc != 1) { nc >>= 1; gl_nplanes++; } vqt_attributes( gl_handle, &attrib[0] ); gl_ws.ws_chmaxh = attrib[7]; gl_ws.ws_pts2 = attrib[6]; char_height = gl_ws.ws_chminh; vst_height( gl_handle, char_height, &gl_wsptschar, &gl_hsptschar, &gl_wschar, &gl_hschar ); char_height = gl_ws.ws_chmaxh; vst_height( gl_handle, char_height, &gl_wptschar, &gl_hptschar, &gl_wchar, &gl_hchar ); gl_ncols = gl_width / gl_wchar; gl_nrows = gl_height / gl_hchar; gl_hbox = gl_hchar + 3; gl_wbox = (gl_hbox * gl_ws.ws_hpixel) / gl_ws.ws_wpixel; vsl_type( gl_handle, 7 ); vsl_width( gl_handle, 1 ); vsl_udsty( gl_handle, 0xffff ); rc_set(&gl_rscreen, 0, 0, gl_width, gl_height); rc_set(&gl_rfull, 0, gl_hbox, gl_width, (gl_height - gl_hbox)); rc_set(&gl_rzero, 0, 0, 0, 0); rc_set(&gl_rcenter, (gl_width-gl_wbox)/2, (gl_height-(2*gl_hbox))/2, gl_wbox, gl_hbox); rc_set(&gl_rmenu, 0, 0, gl_width, gl_hbox); ad_intin = (LONG)ADDR(&intin[0]); return (TRUE); }
static int line(GEM_PLOTTER self,int x0, int y0, int x1, int y1, const plot_style_t * pstyle) { short pxy[4]; uint32_t lt; int sw = pstyle->stroke_width; pxy[0] = VIEW(self).x + x0; pxy[1] = VIEW(self).y + y0; pxy[2] = VIEW(self).x + x1; pxy[3] = VIEW(self).y + y1; plotter_vdi_clip( self, 1); if( sw == 0) sw = 1; NSLT2VDI(lt, pstyle) vsl_type( self->vdi_handle, (lt&0x0F) ); /* if the line style is not available within VDI system,define own style: */ if( (lt&0x0F) == 7 ){ vsl_udsty(self->vdi_handle, ((lt&0xFFFF00) >> 8) ); }
static void __CDECL evnt_sb_redraw( COMPONENT *c, long buff[8] ) { size_t i; struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER); assert(gw != NULL); CMP_STATUSBAR sb = gw->root->statusbar; assert( sb != NULL ); if( sb == NULL ) return; if( sb->attached == false ) return; LGRECT work, lclip; short pxy[8], d, pxyclip[4]; mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work); lclip = work; if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) { return; } vsf_interior(atari_plot_vdi_handle, FIS_SOLID ); vsl_color(atari_plot_vdi_handle, BLACK ); vsl_type(atari_plot_vdi_handle, 1); vsl_width(atari_plot_vdi_handle, 1 ); vst_color(atari_plot_vdi_handle, BLACK); vst_height(atari_plot_vdi_handle, atari_sysinfo.medium_sfont_pxh, &pxy[0], &pxy[1], &pxy[2], &pxy[3] ); vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d ); vst_effects(atari_plot_vdi_handle, 0 ); pxyclip[0] = lclip.g_x; pxyclip[1] = lclip.g_y; pxyclip[2] = lclip.g_x + lclip.g_w-1; pxyclip[3] = lclip.g_y + lclip.g_h-1; vs_clip(atari_plot_vdi_handle, 1, (short*)&pxyclip ); vswr_mode(atari_plot_vdi_handle, MD_REPLACE ); if( lclip.g_y <= work.g_y ) { pxy[0] = work.g_x; pxy[1] = work.g_y; pxy[2] = MIN( work.g_x + work.g_w, lclip.g_x + lclip.g_w ); pxy[3] = work.g_y; v_pline(atari_plot_vdi_handle, 2, (short*)&pxy ); } if(app.nplanes > 2) { vsf_color(atari_plot_vdi_handle, LWHITE); } else { vsf_color(atari_plot_vdi_handle, WHITE ); } pxy[0] = work.g_x; pxy[1] = work.g_y+1; pxy[2] = work.g_x + work.g_w-1; pxy[3] = work.g_y + work.g_h-1; v_bar(atari_plot_vdi_handle, pxy ); if( sb->textlen > 0 ) { short curx; short vqw[4]; char t[2]; short cw = 8; t[1]=0; if( atari_sysinfo.sfont_monospaced ) { t[0]='A'; int r = vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] ); cw = vqw[0]; } vswr_mode(atari_plot_vdi_handle, MD_TRANS ); for( curx = work.g_x + 2, i=0 ; (curx+cw < work.g_x+work.g_w ) && i < sb->textlen; i++ ){ t[0] = sb->text[i]; if( !atari_sysinfo.sfont_monospaced ) { vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] ); cw = vqw[0]; } if( curx >= lclip.g_x - cw ) { v_gtext(atari_plot_vdi_handle, curx, work.g_y + 5, (char*)&t ); } curx += cw; if( curx >= lclip.g_x + lclip.g_w ) break; } } vswr_mode(atari_plot_vdi_handle, MD_REPLACE ); pxy[0] = work.g_x + work.g_w; pxy[1] = work.g_y + work.g_h; pxy[2] = work.g_x + work.g_w; pxy[3] = work.g_y + work.g_h-work.g_h; v_pline(atari_plot_vdi_handle, 2, (short*)&pxy ); vs_clip(atari_plot_vdi_handle, 0, (short*)&pxyclip ); return; }
/* * draw the polynomial into the editfield * Note: User VDI must be initialized! */ WORD cdecl draw_polynomial(PARMBLK *pb) { int i,j, field_w, field_h, *polyfactors; double x, y; int xo,yo; OBJECT *tree; int clipper[4], box[4], zero[4]; if (userhandle<=0) return(NORMAL); /* NO VDI!!! */ tree = rs_trindex[POLY_ED]; /* check: draw only if current state = old state */ if (pb->pb_prevstate!=pb->pb_currstate) return (pb->pb_currstate & ~SELECTED); field_w = ObW(P_EDITFIELD); field_h = ObH(P_EDITFIELD); polyfactors = *(int**)pb->pb_parm; box[0] = pb->pb_x-1; box[1] = pb->pb_y-1; box[2] = pb->pb_x+pb->pb_w; box[3] = pb->pb_y+pb->pb_h; /* get pixel offsets */ xo = box[0]; yo = box[1]+ObY(P_ZEROLINE)+ObH(P_ZEROLINE); /* Set Clip: */ clipper[0] = MAX(box[0], pb->pb_xc); clipper[1] = MAX(box[1], pb->pb_yc); clipper[2] = MIN(box[2], pb->pb_xc+pb->pb_wc-1); clipper[3] = MIN(box[3], pb->pb_yc+pb->pb_hc-1); vs_clip(userhandle, 1, clipper); /* draw box */ vsf_perimeter(userhandle, 1); /* visible fill perimeter */ vsf_color(userhandle, BLACK); vsf_interior(userhandle, FIS_HOLLOW); v_bar(userhandle, (int *)box); /* fill rectangle */ /* draw zeroline */ zero[0]=xo; zero[1]=yo; zero[2]=xo+field_w; zero[3]=yo; vsl_type(userhandle, 3); vsl_color(userhandle, BLUE); v_pline(userhandle, 2, (int*)zero); /* calc polyarray */ for (i=0; i<=POLYPOINTS; i++) { x = (XSCALE*(double)i)/(double)POLYPOINTS; for (j=0, y=0.0; j<4; j++) y=x*y+polyfactors[j]; y=y*x/256.0; polyarray[i][0] = xo + ((double)field_w*i)/(double)POLYPOINTS; polyarray[i][1] = yo - ((double)field_h*y)/YSCALE; if (polyarray[i][1]<0) polyarray[i][1]=0; }; /* draw curve */ vsl_type(userhandle, 1); vsl_color(userhandle, RED); v_pline(userhandle, POLYPOINTS, (int *)&polyarray[0]); return (pb->pb_currstate & ~SELECTED); }
void chart_draw_line (struct line_chart * lc, int app_handle, int x, int y, int w, int h) { int lx, ly, lw, lh; /* dimensions of area in which to draw the line chart */ int max_y_value, min_y_value, max_value_width; int min_x_value, max_x_value; int i; int dum, key_char_w, key_char_h; int kx, ky; /* position of key */ clear_area (app_handle, x, y, w, h); if ((w < 50) || (h < 50)) return; /* too small to draw anything */ if (lc->lines[0] == NULL) return; /* no line, so don't draw anything */ max_y_value = find_max (lc->lines[0]->ys, lc->lines[0]->num_points); min_y_value = find_min (lc->lines[0]->ys, lc->lines[0]->num_points); for (i = 1; i < lc->num_lines; i += 1) { int t = find_max (lc->lines[i]->ys, lc->lines[i]->num_points); if (t > max_y_value) max_y_value = t; t = find_min (lc->lines[i]->ys, lc->lines[i]->num_points); if (t < min_y_value) min_y_value = t; } max_x_value = find_max (lc->lines[0]->xs, lc->lines[0]->num_points); min_x_value = find_min (lc->lines[0]->xs, lc->lines[0]->num_points); for (i = 1; i < lc->num_lines; i += 1) { int t = find_max (lc->lines[i]->xs, lc->lines[i]->num_points); if (t > max_x_value) max_x_value = t; t = find_min (lc->lines[i]->xs, lc->lines[i]->num_points); if (t < min_x_value) min_x_value = t; } /* Find dimensions for display of chart */ find_chart_dimensions (app_handle, min_y_value, max_y_value, x, y, w, h, &max_value_width, &lx, &ly, &lw, &lh); vst_point (app_handle, AXES_TITLE_FONT, &dum, &dum, &key_char_w, &key_char_h); /* adjust dimensions to fit in a key */ if (w > h) { /* wide area, so key on right */ int max_width, i; max_width = strlen(lc->lines[0]->label); for (i=1; i<lc->num_lines; i+=1) { if (strlen(lc->lines[i]->label) > max_width) { max_width = strlen(lc->lines[i]->label); } } kx = x + w - key_char_w*(4 + max_width); ky = y + 2*key_char_h; lw = kx - lx - key_char_w; } else { /* tall area, so key below */ int diff_y = key_char_h*(2+2+lc->num_lines); kx = x+5*key_char_w; ly -= diff_y; lh -= diff_y; ky = ly + 4*key_char_h; /* remember gap for labels */ } draw_axes_lines (app_handle, lx, ly, lw, lh); draw_main_labels (app_handle, lc->title, lc->x_label, lc->y_label, lx, ly, lw, lh, max_value_width); draw_x_axis_labels (app_handle, min_x_value, max_x_value, lx, ly, lw); draw_y_axis_labels (app_handle, min_y_value, max_y_value, lx, ly, lh); /* draw points and lines */ for (i = 0; i < lc->num_lines; i += 1) { int p; int * pts; pts = malloc(sizeof(int)*lc->lines[i]->num_points*2); for (p = 0; p < lc->lines[i]->num_points; p += 1) { pts[2*p] = lx + rescale (lc->lines[i]->xs[p], min_x_value, max_x_value, lw); pts[2*p+1] = ly - rescale (lc->lines[i]->ys[p], min_y_value, max_y_value, lh); } /* set colour/styles */ vsl_width (app_handle, 1); vsl_color (app_handle, lc->lines[i]->colour); vsm_color (app_handle, lc->lines[i]->colour); #ifdef PMARKS /* use own pmarker code */ vsf_color (app_handle, lc->lines[i]->colour); my_pmarker (app_handle, lc->lines[i]->point_style, lc->lines[i]->num_points, pts); #else /* use builtin pmarker code */ vsm_type (app_handle, lc->lines[i]->point_style); /* call v_pmarker to draw points */ v_pmarker (app_handle, lc->lines[i]->num_points, pts); #endif vsl_type (app_handle, lc->lines[i]->line_style); /* call v_pline to draw lines */ v_pline (app_handle, lc->lines[i]->num_points, pts); free (pts); } /* draw key */ vsf_color (app_handle, BLACK); vst_point (app_handle, AXES_TITLE_FONT, &dum, &dum, &dum, &dum); v_gtext (app_handle, kx, ky, " KEY"); ky += 2*key_char_h; for (i = 0; i < lc->num_lines; i += 1) { int pxy[4]; pxy[0]=kx; pxy[1]=ky; pxy[2]=kx+2.5*key_char_w; pxy[3]=pxy[1]; vsl_color (app_handle, lc->lines[i]->colour); vsl_width (app_handle, 1); vsm_color (app_handle, lc->lines[i]->colour); #ifdef PMARKS /* use own pmarker code */ vsf_color (app_handle, lc->lines[i]->colour); my_pmarker (app_handle, lc->lines[i]->point_style, 2, pxy); #else /* use builtin pmarker code */ vsm_type (app_handle, lc->lines[i]->point_style); v_pmarker (app_handle, 2, pxy); #endif vsl_type (app_handle, lc->lines[i]->line_style); v_pline (app_handle, 2, pxy); v_gtext (app_handle, kx+3.5*key_char_w, ky, lc->lines[i]->label); ky += key_char_h; } }
/* draw the given set of points using a mark: this replaces v_pmarker, which is not implemented in fVDI on the Firebee 1 = dot, 2 = plus, 3 = star, 4 = square, 5 = cross, 6 = diamond Note: only 3-pt size used here. Not adjustable in line-chart. vsm_height can alter the size, for the built in pmarker. */ void my_pmarker (int app_handle, int point_style, int num_points, int * points) { int i; int s = 3; /* size of graphic to draw */ /* ensure line style solid, and fill type hollow */ vsl_type (app_handle, SOLID); vsf_interior (app_handle, 0); for (i = 0; i < num_points; i += 1) { int x = points[2*i]; int y = points[2*i+1]; int pxy[10]; switch (point_style) { case 1: /* dot */ v_circle (app_handle, x, y, 1); break; case 2: /* plus */ pxy[0] = x; pxy[1] = y-s; pxy[2] = x; pxy[3] = y+s; v_pline (app_handle, 2, pxy); pxy[0] = x-s; pxy[1] = y; pxy[2] = x+s; pxy[3] = y; v_pline (app_handle, 2, pxy); break; case 3: /* star */ pxy[0] = x; pxy[1] = y-s; pxy[2] = x; pxy[3] = y; pxy[4] = x-2*s/3; pxy[5] = y+s; v_pline (app_handle, 3, pxy); pxy[0] = x-s; pxy[1] = y-s; pxy[2] = x; pxy[3] = y; pxy[4] = x+2*s/3; pxy[5] = y+s; v_pline (app_handle, 3, pxy); pxy[0] = x+s; pxy[1] = y-s; pxy[2] = x; pxy[3] = y; v_pline (app_handle, 2, pxy); break; case 4: /* square */ pxy[0] = x-s; pxy[1] = y-s; pxy[2] = x+s; pxy[3] = y-s; pxy[4] = x+s; pxy[5] = y+s; pxy[6] = x-s; pxy[7] = y+s; pxy[8] = x-s; pxy[9] = y-s; v_fillarea (app_handle, 5, pxy); break; case 5: /* cross */ pxy[0] = x-s; pxy[1] = y-s; pxy[2] = x+s; pxy[3] = y+s; v_pline (app_handle, 2, pxy); pxy[0] = x+s; pxy[1] = y-s; pxy[2] = x-s; pxy[3] = y+s; v_pline (app_handle, 2, pxy); break; case 6: /* diamond */ pxy[0] = x; pxy[1] = y-s; pxy[2] = x-s; pxy[3] = y; pxy[4] = x; pxy[5] = y+s; pxy[6] = x+s; pxy[7] = y; pxy[8] = x; pxy[9] = y-s; v_fillarea (app_handle, 5, pxy); break; } } }