HWin MakeAWindow(char *name,int x, int y, int w, int h, int n) { HWin win; int xx,yy; char buf[100]; win = MakeHWin(name,x,y,w,h,1); strcpy(buf,"Window: "); strcat(buf,name); xx = CentreX(win,w/2,buf); yy = CentreY(win,h/2,buf); HSetColour(win,RED+n); HDrawLine(win,0,0,w,h); HPrintf(win,xx,yy,"%s",buf); return win; }
/* EXPORT->RedrawHButton: readraw a single button object */ void RedrawHButton(HButton *btn) { int pad = 2; int x, y, w, h, r, s, pos; HPoint poly[9], shad[4]; char sbuf[256], nullchar = '\0'; x = btn->x; y=btn->y; w=btn->w; h=btn->h; r=3; s=1; /* set up the polygon */ poly[0].x = x; poly[0].y = y+r; poly[1].x = x; poly[1].y = y+h-r; poly[2].x = x+r; poly[2].y = y+h; poly[3].x = x+w-r; poly[3].y = y+h; poly[4].x = x+w; poly[4].y = y+h-r; poly[5].x = x+w; poly[5].y = y+r; poly[6].x = x+w-r; poly[6].y = y; poly[7].x = x+r; poly[7].y = y; poly[8].x = x; poly[8].y = y+r; /* set up the extra lines for the shadow */ shad[0].x = x+r+s; shad[0].y = y+h+s; shad[1].x = x+w-r+s; shad[1].y = y+h+s; shad[2].x = x+w+s; shad[2].y = y+h-r+s; shad[3].x = x+w+s; shad[3].y = y+r+s; if (btn->lit) HSetColour(btn->fg); else HSetColour(btn->bg); HFillPolygon(poly, 9); HSetColour(btn->fg); HDrawLines(poly, 9); HDrawLines(shad, 4); if (btn->active) if (btn->lit) HSetColour(btn->bg); else HSetColour(btn->fg); else HSetGrey(30); strcpy(sbuf, btn->str); pos = strlen(sbuf); while(HTextWidth(sbuf) > (w - 2*pad)) sbuf[--pos]=nullchar; HPrintf(CentreX(x+w/2, sbuf), CentreY(y+h/2, sbuf), "%s", sbuf); }