9 #include <intuition/intuition.h>
10 #include <intuition/intuitionbase.h>
11 #include <exec/ports.h>
12 #include <proto/exec.h>
13 #include <proto/intuition.h>
14 #include <proto/graphics.h>
17 #define SAFE_BORDER (4)
20 extern void drawgfx(void);
22 long xcur,ycur,xmin,xmax,ymin,ymax;
23 int winx,winy,iniline,minimax=1;
25 int xofs,yofs,xbor,ybor;
27 struct RastPort *rport;
31 struct NewWindow nwin={0,0,0,0,UCHAR_MAX,UCHAR_MAX,
32 IDCMP_NEWSIZE|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_VANILLAKEY,
33 WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SIZEBRIGHT
34 |WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_NOCAREREFRESH,
35 NULL,NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN};
36 #define pubscr (nwin.Screen)
38 #define gfxfail() { fprintf(stderr,"%s: Gfx subsys failed!\n",pname); \
39 exit(EXIT_FAILURE); } while (0)
41 void wl_line(long x,long y)
45 if (minimax) { xmin=xmax=x; ymin=ymax=y; }
46 else Move(rport,(long)(coefx*(x-xmin)+xofs),
47 (long)(yofs-coefy*(y-ymin)));
50 if (x<xmin) xmin=x; if (x>xmax) xmax=x;
51 if (y<ymin) ymin=y; if (y>ymax) ymax=y;
53 else Draw(rport,(long)(coefx*(x-xmin)+xofs),
54 (long)(yofs-coefy*(y-ymin)));
57 static void wl_safeclose(void)
59 struct IntuiMessage *msg;
61 while (msg=(struct IntuiMessage *)GetMsg(win->UserPort))
62 ReplyMsg((struct Message *)msg);
71 struct IntuiMessage *msg;
75 if (xmax==xmin) xmax++;
76 if (ymax==ymin) ymax++;
77 if (IntuitionBase->LibNode.lib_Version>=39) SetWindowPointer(win,TAG_DONE);
80 coefx=(float)(winx-xbor-1)/(xmax-xmin);
81 coefy=(float)(winy-ybor-1)/(ymax-ymin);
82 yofs=winy-SAFE_BORDER-win->BorderBottom;
84 RectFill(rport,(long)win->BorderLeft,(long)win->BorderTop,
85 (long)(winx-win->BorderRight-1),(long)(winy-win->BorderBottom-1));
89 while (!(msg=(struct IntuiMessage *)GetMsg(win->UserPort)))
90 WaitPort(win->UserPort);
92 ReplyMsg((struct Message *)msg);
93 if (cls!=IDCMP_NEWSIZE) { wl_safeclose(); return; }
94 winx=win->Width; winy=win->Height;
98 static void wl_cleanup(void)
100 while (win) wl_safeclose();
102 UnlockPubScreen(NULL,pubscr);
107 void wl_init(int *argcp,char **argv,const char *class)
109 if ((pname=rindex(*argv,'/'))) pname++;
112 if (!(pubscr=LockPubScreen(NULL))) gfxfail();
113 nwin.Title=(char *)class;
114 nwin.LeftEdge=(winx=nwin.Width=pubscr->Width/2)/2;
115 nwin.TopEdge=(winy=nwin.Height=pubscr->Height/2)/2;
116 if (!(win=OpenWindow(&nwin))) gfxfail();
117 if (IntuitionBase->LibNode.lib_Version>=39)
118 SetWindowPointer(win,WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
120 (long)(xbor=(xofs=win->BorderLeft+SAFE_BORDER)
121 +SAFE_BORDER+win->BorderRight )+SIZE_MIN,
122 (long)(ybor=win->BorderTop +SAFE_BORDER
123 +SAFE_BORDER+win->BorderBottom)+SIZE_MIN,~0,~0);
124 SetDrMd(rport=win->RPort,JAM1);