#include #include #include "builtins.h" #include "blocktype.h" static int my_w = -1; static int my_h; static BLOCKDIMS size(void) { int xte_dir; int xte_asc; int xte_desc; XCharStruct cs; if (my_w < 0) { XTextExtents(font," -0.0000 V ",11,&xte_dir,&xte_asc,&xte_desc,&cs); my_w = cs.width; my_h = 3 * font_baselineskip; } return((BLOCKDIMS){.w=my_w,.h=my_h}); } static void render(Drawable d, GC gc_bg, GC gc_fg) { XFillRectangle(disp,d,gc_bg,0,0,my_w,my_h); XDrawLine(disp,d,gc_fg,0,0,my_w-2,0); XDrawLine(disp,d,gc_fg,my_w-1,0,my_w-1,my_h-2); XDrawLine(disp,d,gc_fg,my_w-1,my_h-1,1,my_h-1); XDrawLine(disp,d,gc_fg,0,my_h-1,0,1); } static const char *outs[] = { "V" }; static BLOCKPARAM params[] = { { .name = "Value", .type = PAR_SIGNAL } }; BLOCKTYPE block_constant = { .name = "Constant", .n_in = 0, .ins = 0, .n_out = 1, .outs = &outs[0], .n_param = 1, .params = ¶ms[0], .size = &size, .render = &render };