9 typedef struct Box Box;
33 static char *cmds[] = {
36 [EBordercolor] ="bordercolor",
48 boxkey(Control *c, Rune *rp)
53 chanprint(b->event, "%q: key 0x%x", b->name, rp[0]);
57 boxmouse(Control *c, Mouse *m)
62 if (ptinrect(m->xy,b->rect))
63 chanprint(b->event, "%q: mouse %P %d %ld", b->name,
64 m->xy, m->buttons, m->msec);
70 _putctlimage(((Box*)c)->image);
82 border(b->screen, b->rect, b->border, b->bordercolor->image, ZP);
83 r = insetrect(b->rect, b->border);
87 /* BUG: ALIGNMENT AND CLIPPING */
88 draw(b->screen, r, i, nil, ZP);
92 boxctl(Control *c, CParse *cp)
99 cmd = _ctllookup(cp->args[0], cmds, nelem(cmds));
102 ctlerror("%q: unrecognized message '%s'", b->name, cp->str);
105 _ctlargcount(b, cp, 2);
106 b->align = _ctlalignment(cp->args[1]);
109 _ctlargcount(b, cp, 2);
111 ctlerror("%q: bad border: %c", b->name, cp->str);
112 b->border = cp->iargs[1];
115 _ctlargcount(b, cp, 2);
116 _setctlimage(b, &b->bordercolor, cp->args[1]);
119 _ctlargcount(b, cp, 2);
120 chanprint(b->event, "%q: focus %s", b->name, cp->args[1]);
123 _ctlargcount(b, cp, 1);
127 _ctlargcount(b, cp, 2);
128 _setctlimage(b, &b->image, cp->args[1]);
131 _ctlargcount(b, cp, 5);
132 r.min.x = cp->iargs[1];
133 r.min.y = cp->iargs[2];
134 r.max.x = cp->iargs[3];
135 r.max.y = cp->iargs[4];
136 if(Dx(r)<0 || Dy(r)<0)
137 ctlerror("%q: bad rectangle: %s", b->name, cp->str);
141 _ctlargcount(b, cp, 1);
146 _ctlargcount(b, cp, 1);
151 r.max = Pt(0x7fffffff, 0x7fffffff);
153 _ctlargcount(b, cp, 5);
154 r.max.x = cp->iargs[3];
155 r.max.y = cp->iargs[4];
157 r.min.x = cp->iargs[1];
158 r.min.y = cp->iargs[2];
159 if(r.min.x<=0 || r.min.y<=0 || r.max.x<=0 || r.max.y<=0 || r.max.x < r.min.x || r.max.y < r.min.y)
160 ctlerror("%q: bad sizes: %s", b->name, cp->str);
168 createbox(Controlset *cs, char *name)
172 b = (Box *)_createctl(cs, "box", sizeof(Box), name);
173 b->image = _getctlimage("white");
174 b->bordercolor = _getctlimage("black");
175 b->align = Aupperleft;