int GCgettextsize(Gwidget_t * widget, Gtextline_t * tlp, int n, char *fn, double fs, Gsize_t * gsp) { Gsize_t gs; PIXsize_t ps; GdkFont *font; int i, dir, asc, des, rbearing, lbearing, width; gs.x = 0, gs.y = fs; ps = sdrawtopix(widget, gs); if (!(font = findfont(fn, ps.y))) { gsp->x = 1, gsp->y = 1; return 0; } SETFONT(font); for (ps.x = ps.y = 0, i = 0; i < n; i++) { gdk_text_extents(font, tlp[i].p, tlp[i].n, &lbearing, &rbearing, &width, &asc, &des); ps.x = max(ps.x, width), ps.y += asc + des; } *gsp = spixtodraw(widget, ps); return 0; }
int GParc ( Gwidget_t *widget, Gpoint_t gc, Gsize_t gs, double ang1, double ang2, Ggattr_t *ap ) { PIXpoint_t pc; PIXsize_t ps; double a1, a2; pc = pdrawtopix (widget, gc), ps = sdrawtopix (widget, gs); setgattr (widget, ap); a1 = ang1 * M_PI / 180, a2 = ang2 * M_PI / 180; if (WPU->gattr.fill) Chord ( GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y, (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x), (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x) ); else Arc ( GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y, (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x), (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x) ); return 0; }
int GCarc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs, double ang1, double ang2, Ggattr_t * ap) { PIXpoint_t pc; PIXsize_t ps; Grect_t gr; gr.o.x = gc.x - gs.x, gr.o.y = gc.y - gs.y; gr.c.x = gc.x + gs.x, gr.c.y = gc.y + gs.y; /* if(!ISVISIBLE(gr)) return 1; */ pc = pdrawtopix(widget, gc), ps = sdrawtopix(widget, gs); setgattr(widget, ap); if (WCU->gattr.fill) { gdk_draw_arc(widget->w->window, GC, TRUE, pc.x - ps.x, pc.y - ps.y, ps.x * 2, ps.y * 2, (int) (ang1 * 64), (ang2 * 64)); } else { gdk_draw_arc(widget->w->window, GC, FALSE, pc.x - ps.x, pc.y - ps.y, ps.x * 2, ps.y * 2, (int) (ang1 * 64), (ang2 * 64)); } return 0; }
int GPtext ( Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go, char *fn, double fs, char *justs, Ggattr_t *ap ) { Gsize_t gs; PIXpoint_t po; PIXsize_t ps; PIXrect_t pr; HFONT font; SIZE size; RECT r; int x, y, w, h, i; po = pdrawtopix (widget, go); gs.x = 0, gs.y = fs; ps = sdrawtopix (widget, gs); if (!(font = findfont (fn, ps.y))) { Rectangle (GC, po.x, po.y, po.x + 1, po.y + 1); return 0; } setgattr (widget, ap); if (font != WPU->font) { WPU->font = font; SelectObject (GC, font); } for (w = h = 0, i = 0; i < n; i++) { if (tlp[i].n) GetTextExtentPoint32 (GC, tlp[i].p, (int) tlp[i].n, &size); else GetTextExtentPoint32 (GC, "M", (int) 1, &size); tlp[i].w = size.cx, tlp[i].h = size.cy; w = max (w, size.cx), h += size.cy; } switch (justs[0]) { case 'l': po.x += w / 2; break; case 'r': po.x -= w / 2; break; } switch (justs[1]) { case 'd': po.y -= h; break; case 'c': po.y -= h / 2; break; } pr.o.x = po.x - w / 2, pr.o.y = po.y; pr.c.x = po.x + w / 2, pr.c.y = po.y + h; for (i = 0; i < n; i++) { switch (tlp[i].j) { case 'l': x = po.x - w / 2; break; case 'n': x = po.x - tlp[i].w / 2; break; case 'r': x = po.x - (tlp[i].w - w / 2); break; } y = po.y + i * tlp[i].h; r.left = x, r.top = y; r.right = x + tlp[i].w, r.bottom = y + tlp[i].h; DrawText ( GC, tlp[i].p, (int) tlp[i].n, &r, DT_LEFT | DT_TOP | DT_NOPREFIX ); } return 0; }
int GCtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go, char *fn, double fs, char *justs, Ggattr_t * ap) { Gsize_t gs; PIXpoint_t po; PIXsize_t ps; PIXrect_t pr; Grect_t gr; GdkFont *font; int dir, asc, des, x = 0, y, w, h, i; int lbearing, rbearing, width; po = pdrawtopix(widget, go); gs.x = 0, gs.y = fs; ps = sdrawtopix(widget, gs); if (!(font = findfont(fn, ps.y))) { printf("NO FONT\n"); gdk_draw_rectangle(widget->w, GC, FALSE, po.x, po.y, 1, 1); return 0; } setgattr(widget, ap); SETFONT(font); for (w = h = 0, i = 0; i < n; i++) { gdk_text_extents(font, tlp[i].p, tlp[i].n, &lbearing, &rbearing, &width, &asc, &des); tlp[i].w = width, tlp[i].h = asc + des; w = max(w, width), h += asc + des; } switch (justs[0]) { case 'l': po.x += w / 2; break; case 'r': po.x -= w / 2; break; } switch (justs[1]) { case 'd': po.y -= h; break; case 'c': po.y -= h / 2; break; } pr.o.x = po.x - w / 2, pr.o.y = po.y; pr.c.x = po.x + w / 2, pr.c.y = po.y + h; gr = rpixtodraw(widget, pr); /* if(!ISVISIBLE(gr)) return 1; */ for (i = 0; i < n; i++) { switch (tlp[i].j) { case 'l': x = po.x - w / 2; break; case 'n': x = po.x - tlp[i].w / 2; break; case 'r': x = po.x - (tlp[i].w - w / 2); break; } y = po.y + (i + 1) * tlp[i].h - des; gdk_draw_text(widget->w->window, font, GC, x, y, tlp[i].p, tlp[i].n); } return 0; }