float tailx = -100; float taily = 440; float minwidth = 100; float minheight = 50; float cursx = 0; float cursy = 0; boolean dragable = false; boolean savebehind = true; boolean mapbeep = true; /**************************************************************** * creating the tail path */ void triWpath() { if (tailx < 0) { moveto(0,0); lineto(0,h); lineto(tailx,taily); closepath(); } } void triEpath() { if (tailx > w) { moveto(w,0); lineto(w,h); lineto(tailx,taily); closepath(); } } void triSpath() { if (taily < 0) { moveto(0,0); lineto(w,0); lineto(tailx,taily); closepath(); } } void triNpath() { if (taily > h) { moveto(0,h); lineto(w,h); lineto(tailx,taily); closepath(); } } void canvaspath() { triWpath(); triNpath(); triEpath(); triSpath(); rectpath(0,0,w,h); } void Paint() { rectpath(0,0,w,h); setcolor(BG); fill(); newpath(); triNpath(); setcolor(BG2); fill(); newpath(); triWpath(); triEpath(); setcolor((taily < 0) ? BG2 : BG3); fill(); newpath(); triSpath(); setcolor(BG3); fill(); setcolor(FG); rectframe(2,0,0,w,h); eofill(); rectpath(insetstroke(4,[0,0,w,h])); stroke(); } void warpcursor() { float *pt; gsave(); setcanvas(framebuffer); pt = currentcursorlocation; cursx = pt[0]; cursy = pt[1]; grestore(); setcursorlocation(w/2,h/4); } /**************************************************************** * creating the tail path */ void move(float X, float Y) { float oldx, oldy; if ((x != X) || (y != Y)) { oldx = x; oldy = y; softpromote(/mx,mtranslate(mx,X,Y)); tailx -= x - oldx; taily -= y - oldy; greset(); } } operator float *local2global(float,float) = "gsave transform currentcanvas setcanvas itransform currentcanvas framebuffer setcanvas getcanvaslocation xyadd grestore 2 array astore"; #define HTAIL 80 #define VTAIL 40 void map() { Send freeze(self) to @parent; @freezer = null; super.map(); gexec(/warpcursor); if (mapbeep) beep(); } void mapxy(float X, float Y) { float *pt; pt = local2global(X,Y); X = cvi(round(pt[0])); Y = cvi(round(pt[1])); unmap(); tailx = X - x; taily = Y - y; if (X < screenwidth/2) X = X + HTAIL; else X = X - (w + HTAIL); X = max(0,min(X,screenwidth-w)); if (Y < screenheight/2) Y = Y + VTAIL; else Y = Y - (h + VTAIL); Y = max(0,min(Y,screenheight-h)); move(X,Y); map(); } void unmap() { super.unmap(); if (cursx || cursy) { gsave(); setcanvas(framebuffer); setcursorlocation(cursx,cursy); unpromote(/cursx); unpromote(/cursy); grestore(); } unpromote(/@freezer); Send defrost() to @parent; } void owner_open() { } void onmenu() { if (edit_mode) super.onmenu(); } void Action() { }