static inline void vsl_rgbcolor( short vdih, uint32_t cin ) { if( vdi_sysinfo.scr_bpp > 8 ) { unsigned short c[4]; rgb_to_vdi1000( (unsigned char*)&cin, (unsigned short*)&c ); vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c[0] ); vsl_color( vdih, OFFSET_CUSTOM_COLOR ); } else { if( vdi_sysinfo.scr_bpp >= 4 ){ vsl_color( vdih, RGB_TO_VDI(cin) ); } else vsl_color( vdih, BLACK ); } }
short draw_multiline(PARMBLK *parmblock) { GRECT clip_area; short sizing = 4; //Set up clipping OUTPUT_WINDOW *window = (OUTPUT_WINDOW*)parmblock->pb_parm; short handle = window->workstation; char buffer[255]; short last_index = 0; short draw_region[4] = { parmblock->pb_x, parmblock->pb_y, parmblock->pb_x + parmblock->pb_w, parmblock->pb_y + parmblock->pb_h }; short clip_region[4] = { parmblock->pb_xc, parmblock->pb_yc, parmblock->pb_xc + parmblock->pb_wc, parmblock->pb_yc + parmblock->pb_hc }; vs_clip(handle, 1, clip_region); vsf_interior(handle, 1); //vsf_color(handle, 6); //vr_recfl(handle, draw_region); // clear entire message area vsl_color(handle, 1); vst_height(handle, sizing, &sizing, &sizing, &sizing, &sizing); short position = 6; while (tokenize_multiline(buffer, window->text, parmblock->pb_w, sizing, &last_index)) { v_gtext(handle, parmblock->pb_x, parmblock->pb_y + position, buffer); position += sizing; } vs_clip(handle, 0, clip_region); return 0; }
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); }
global void l_color(int m) { static int mode = -1; if (m ne mode) vsl_color(C.vh, mode = m); }
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); }
/* * Highlight or de-highlight a color box */ void outline(int obj, int flag) { int color; GRECT obrect; if (flag == HILITE) color = 1; /* highlight box with foreground color */ else color = 0; /* de-light box with background color */ wind_update(TRUE); HIDE_MOUSE; vsl_color(vhandle, color); obrect = ObRect(obj); objc_offset(tree, obj, &obrect.g_x, &obrect.g_y); pxyarray[0] = pxyarray[2] = pxyarray[8] = obrect.g_x - 2; pxyarray[1] = pxyarray[7] = pxyarray[9] = obrect.g_y - 2; pxyarray[3] = pxyarray[5] = obrect.g_y + obrect.g_h + 1; pxyarray[4] = pxyarray[6] = obrect.g_x + obrect.g_w + 1; v_pline(vhandle, 5, pxyarray); pxyarray[0] = pxyarray[2] = pxyarray[8] = obrect.g_x - 3; pxyarray[1] = pxyarray[7] = pxyarray[9] = obrect.g_y - 3; pxyarray[3] = pxyarray[5] = obrect.g_y + obrect.g_h + 2; pxyarray[4] = pxyarray[6] = obrect.g_x + obrect.g_w + 2; v_pline(vhandle, 5, pxyarray); SHOW_MOUSE; wind_update(FALSE); }
void OnImgDraw(GEM_WINDOW *wnd, int xywh[4]) { WBROWSER *wb = wnd->Extension ; MFDB *raster ; int w, h ; int off_x, off_y, xi, yi, wi, hi ; int xy[8] ; int posx, posy ; /* Bug si mauvaise cle */ if ( IsRegistered && KeyDecrypt( ident.crypted_key ) > KEY_MAX ) wnd = NULL ; /* ANTI-CRACK */ wnd->GetWorkXYWH( wnd, &xi, &yi, &wi, &hi ) ; if ( !wb->img_valid || wb->load_err ) { GWOnDraw( wnd, xywh ) ; if ( wb->load_err ) { vsl_ends( handle, 0, 0 ) ; vsl_width( handle, 3 ) ; vsl_color( handle, 1 ) ; line( xi + wi -1, yi, xi, yi + hi - 1 ) ; line( xi, yi, xi + wi -1, yi + hi - 1 ) ; } return ; } posx = wb->x1 ; posy = wb->y1 ; if ( wb->pczoom == 100 ) raster = &wb->raster ; else raster = &wb->zoom ; off_x = xywh[0] - xi ; off_y = xywh[1] - yi ; w = xywh[2] ; if ( off_x + posx + w > raster->fd_w ) w -= off_x + posx + w - raster->fd_w ; h = xywh[3] ; xy[4] = xywh[0] ; xy[5] = xywh[1] ; xy[6] = xywh[0] + w - 1 ; xy[7] = xywh[1] + h - 1 ; xy[0] = off_x + posx ; xy[1] = off_y + posy ; xy[2] = xy[0] + w - 1 ; xy[3] = xy[1] + h - 1 ; vro_cpyfm( handle, S_ONLY, xy, raster, &screen ) ; if ( w != xywh[2] ) { xy[0] = 1 + xy[6] ; xy[2] = xywh[2] - w ; xy[1] = xywh[1] ; xy[3] = xywh[3] ; GWOnDraw( wnd, xy ) ; } }
static int cdecl draw_aquaback(PARMBLK *p) { int16 pxy[8]; int16 x0; int16 y0; set_clipping(vdi_handle, p->pb_xc, p->pb_yc, p->pb_wc, p->pb_hc, TRUE); vswr_mode(vdi_handle, MD_REPLACE); pxy[0] = x0 = p->pb_x; pxy[1] = y0 = p->pb_y; pxy[2] = p->pb_x + p->pb_w -1 ; pxy[3] = p->pb_y + p->pb_h - 1; vsf_interior(vdi_handle, FIS_PATTERN); /* FIS_PATTERN */ vsf_color(vdi_handle, LWHITE ); vsf_style(vdi_handle, 4); v_bar(vdi_handle, pxy); pxy[3] = pxy[1]; /* while( (pxy[1]-y0) < (p->pb_h) ) { vsl_color(vdi_handle, WHITE); v_pline(vdi_handle, 2, pxy); pxy[1]+=2; pxy[3]+=2; } */ while( (pxy[1]-y0+2) < (p->pb_h) ) { vsl_color(vdi_handle, LWHITE); v_pline(vdi_handle, 2, pxy); pxy[1]+=2; pxy[3]+=2; vsl_color(vdi_handle, WHITE); v_pline(vdi_handle, 2, pxy); pxy[1]+=2; pxy[3]+=2; } if( (pxy[1]-y0) < (p->pb_h) ) { vsl_color(vdi_handle, LWHITE); v_pline(vdi_handle, 2, pxy); } return (p->pb_currstate); }
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); }
void clcursor(short w) { short xy[8]; short blah; vsl_color(ws.handle,col[CBACK]); if(cwin==-1)return; blah=fdtc(); xy[0]=wn[cwin].wwa.g_x+blah+1;xy[1]=wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-ith/8-1; xy[2]=wn[cwin].wwa.g_x+blah+1;xy[3]=wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-ith+1; v_pline(ws.handle,2,xy); }
/******************************************************************************* 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; }
/* 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); } } }
void writeinpinfo(short w) { short junk2; short xy[8]; vsl_color(ws.handle,col[CDIVIDEB]); xy[0]=wn[w].wwa.g_x; xy[1]=wn[w].wwa.g_y+wn[w].wwa.g_h-ith*2-1; xy[2]=wn[w].wwa.g_x+wn[w].wwa.g_w-1; xy[3]=wn[w].wwa.g_y+wn[w].wwa.g_h-ith*2-1; v_pline(ws.handle,2,xy); xy[1]=xy[1]-10;xy[3]=xy[3]-10; vsl_color(ws.handle,col[CDIVIDET]); v_pline(ws.handle,2,xy); vst_font(ws.handle,1); vst_point(ws.handle,8,&junk2,&junk2,&junk2,&junk2); vst_color(ws.handle,col[CINPINFO]); vst_effects(ws.handle,THICKENED); vswr_mode(ws.handle,MD_TRANS); v_gtext(ws.handle,wn[w].wwa.g_x,wn[w].wwa.g_y+wn[w].wwa.g_h-ith*2-3,wn[w].info2); vst_effects(ws.handle,0); vst_font(ws.handle,inpfont); vst_point(ws.handle,inppoint,&junk2,&junk2,&junk2,&junk2); }
int docursor(short w) { short xy[8]; short blah; vsl_color(ws.handle,col[CCURSOR]); if(cwin==-1)return 0; /* Remember to check that cursor output is applicable */ if(wn[cwin].stat==WMCLEAR){ if(blink>3){ blah=fdtc(); xy[0]=wn[cwin].wwa.g_x+blah+1;xy[1]=wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-ith/8-1; xy[2]=wn[cwin].wwa.g_x+blah+1;xy[3]=wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-ith+1; vswr_mode(ws.handle,MD_XOR); v_pline(ws.handle,2,xy); vswr_mode(ws.handle,MD_REPLACE); } } return 0; }
void drawnicklist(int hand,GRECT box) { short mcto=0,junk=1,junk2; short maxj; short xy[4]; if(hand==-1)return; xy[0]=box.g_x;xy[1]=box.g_y;xy[2]=box.g_x+box.g_w-1;xy[3]=box.g_y+box.g_h-1; vs_clip(ws.handle,1,xy); clearwin(box.g_x,box.g_y,box.g_w,box.g_h,col[CNLBACK]); xy[0]=wn[hand].wwa.g_x+wn[hand].wwa.g_w-NLW; xy[1]=wn[hand].wwa.g_y; xy[2]=wn[hand].wwa.g_x+wn[hand].wwa.g_w-NLW; xy[3]=wn[hand].wwa.g_y+wn[hand].wwa.g_h-ith*2-VT+4; vsl_color(ws.handle,col[CNLDIVIDE]); v_pline(ws.handle,2,xy); xy[0]+=1; xy[2]+=1; v_pline(ws.handle,2,xy); if(wn[hand].chan==-1)return; vst_font(ws.handle,1); vst_point(ws.handle,8,&junk2,&junk2,&junk2,&junk2); maxj=(wn[hand].wwa.g_h-ith*2-VT)/8; vst_color(ws.handle,col[CNICKLIST]); vswr_mode(ws.handle,MD_TRANS); while(mcto<128){ if(strlen(chan[wn[hand].chan].nl[mcto])){ v_gtext(ws.handle,wn[hand].wwa.g_x+wn[hand].wwa.g_w-NLW+4,wn[hand].wwa.g_y+junk*8,chan[wn[hand].chan].nl[mcto]); junk++; if(junk>maxj){ mcto=128; v_gtext(ws.handle,wn[hand].wwa.g_x+wn[hand].wwa.g_w-NLW+4,wn[hand].wwa.g_y+junk*8," "); } } mcto++; } vs_clip(ws.handle,0,NULL); return; }
VOID gsx_attr(WORD text, WORD mode, WORD color) { if (mode != gl_mode) { vswr_mode( gl_handle, mode ); gl_mode = mode; } if (text) { if (color != gl_tcolor) { vst_color(gl_handle, color); gl_tcolor = color; } } else { if (color != gl_lcolor) { vsl_color(gl_handle, color); gl_lcolor = color; } } }
/******************************************************************************* PopUp G_BUTTON *******************************************************************************/ int cdecl _drawPopUp(PARMBLK *parm) { pb.pb_tree = glb.rsc.head.trindex[FUSER]; pb.pb_obj = FUSDPOP+glb.vdi.low; pb.pb_prevstate = pb.pb_tree[pb.pb_obj].ob_state; pb.pb_currstate = parm->pb_tree[parm->pb_obj].ob_state; pb.pb_w = pb.pb_tree[pb.pb_obj].ob_width; pb.pb_h = pb.pb_tree[pb.pb_obj].ob_height; pb.pb_x = parm->pb_x+parm->pb_w-pb.pb_w; pb.pb_y = parm->pb_y+(parm->pb_h-pb.pb_h)/2; pb.pb_xc = parm->pb_xc; pb.pb_yc = parm->pb_yc; pb.pb_wc = parm->pb_wc; pb.pb_hc = parm->pb_hc; pb.pb_parm = pb.pb_tree[pb.pb_obj].ob_spec.userblk->ub_parm; vqt_attributes(glb.vdi.ha,tattr); vqf_attributes(glb.vdi.ha,fattr); flags=parm->pb_tree[parm->pb_obj].ob_flags; state=parm->pb_tree[parm->pb_obj].ob_state; vsl_color(glb.vdi.ha,BLACK); vst_effects(glb.vdi.ha,TXT_NORMAL); vst_alignment(glb.vdi.ha,ALI_LEFT,ALI_BASE,&dummy,&dummy); user=(UBLK *)(parm->pb_parm); vst_point(glb.vdi.ha,10-glb.vdi.low,&dummy,&htext,&dummy,&dummy); my1.g_x=parm->pb_x-3; my1.g_y=parm->pb_y-3; my1.g_w=parm->pb_w+6; my1.g_h=parm->pb_h+6; 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); pxy[0]=parm->pb_x-1; pxy[1]=parm->pb_y-1; pxy[2]=parm->pb_x+parm->pb_w; pxy[3]=pxy[1]; pxy[4]=pxy[2]; pxy[5]=parm->pb_y+parm->pb_h; pxy[6]=pxy[0]; pxy[7]=pxy[5]; pxy[8]=pxy[0]; pxy[9]=pxy[1]; v_pline(glb.vdi.ha,5,pxy); pxy[0]=parm->pb_x+parm->pb_w+1; pxy[1]=parm->pb_y; pxy[2]=pxy[0]; pxy[3]=parm->pb_y+parm->pb_h+1; pxy[4]=parm->pb_x; pxy[5]=pxy[3]; v_pline(glb.vdi.ha,3,pxy); pxy[0]=parm->pb_x+parm->pb_w+2; pxy[1]=parm->pb_y; pxy[2]=pxy[0]; pxy[3]=parm->pb_y+parm->pb_h+2; pxy[4]=parm->pb_x; pxy[5]=pxy[3]; v_pline(glb.vdi.ha,3,pxy); 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); if (flags&FL3DACT) backcol=LWHITE; else backcol=WHITE; textcol=BLACK; if (backcol==LWHITE && glb.vdi.extnd[4]<4) backcol=WHITE; bar[0]=parm->pb_x; bar[1]=parm->pb_y; bar[2]=bar[0]+parm->pb_w-1; bar[3]=bar[1]+parm->pb_h-1; vsf_color(glb.vdi.ha,backcol); /**************************************************************************** Fond Blanc/Gris suivant r‚solution et 3D ****************************************************************************/ v_bar(glb.vdi.ha,bar); vst_color(glb.vdi.ha,textcol); vs_clip(glb.vdi.ha,FALSE,tab_clip); 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); vswr_mode(glb.vdi.ha,MD_TRANS); p=(char *)user->spec; while (*p==32) p++; vqt_extent(glb.vdi.ha,p,extent); x=parm->pb_x+pb.pb_w/2; y=parm->pb_y; y+=parm->pb_h/2; y-=(extent[7]-extent[1])/2; y+=htext; /**************************************************************************** Si bouton 3D alors on d‚cale le texte ****************************************************************************/ if (flags&FL3DIND && flags&FL3DACT && state&SELECTED) { x+=1; y+=1; } v_gtext(glb.vdi.ha,x,y,p); vs_clip(glb.vdi.ha,FALSE,tab_clip); vst_effects(glb.vdi.ha,TXT_NORMAL); vst_alignment (glb.vdi.ha,tattr[3],tattr[4],&dummy,&dummy); vsf_interior(glb.vdi.ha,fattr[2]); vsf_style(glb.vdi.ha,fattr[0]); vsf_perimeter(glb.vdi.ha,fattr[4]); _drawCicon(&pb); /**************************************************************************** Si le bouton est en relief alors il faut demander … l'AES de dessiner l'attribut SELECTED pour qu'il inverse le cadre fin gris/noir. Par contre si le bouton n'est pas en relief, il ne faut surtout pas demander … l'AES de dessiner cet attribut sinon; lorsque l'objet est s‚lectionn‚ (donc noir), l'AES le recouvre en blanc !! ****************************************************************************/ if (flags&FL3DIND && flags&FL3DACT || flags&FL3DIND) return parm->pb_currstate; else return parm->pb_currstate&~SELECTED; }
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; } }