Lines Matching refs:g

55 groupinit(Group *g)  in groupinit()  argument
57 g->bordercolor = _getctlimage("black"); in groupinit()
58 g->image = _getctlimage("white"); in groupinit()
59 g->border = 0; in groupinit()
60 g->mansize = 0; in groupinit()
61 g->separation = 0; in groupinit()
62 g->selected = -1; in groupinit()
63 g->lastkid = -1; in groupinit()
64 g->kids = nil; in groupinit()
65 g->separators = nil; in groupinit()
66 g->nkids = 0; in groupinit()
67 g->nseparators = 0; in groupinit()
68 g->ctl = groupctl; in groupinit()
69 g->mouse = groupmouse; in groupinit()
70 g->exit = groupfree; in groupinit()
79 Group *g; in groupctl() local
81 g = (Group*)c; in groupctl()
88 ctlerror("%q: no such control: %s", g->name, cp->args[i]); in groupctl()
89 _ctladdgroup(g, c); in groupctl()
91 if (g->setsize) in groupctl()
92 g->setsize((Control*)g); in groupctl()
95 _ctlargcount(g, cp, 2); in groupctl()
97 ctlerror("%q: bad border: %c", g->name, cp->str); in groupctl()
98 g->border = cp->iargs[1]; in groupctl()
101 _ctlargcount(g, cp, 2); in groupctl()
102 _setctlimage(g, &g->bordercolor, cp->args[1]); in groupctl()
108 _ctlargcount(g, cp, 1); in groupctl()
109 for (i = 0; i < g->nkids; i++) in groupctl()
110 if (g->kids[i]->ctl) in groupctl()
111 _ctlprint(g->kids[i], "hide"); in groupctl()
112 g->hidden = 1; in groupctl()
115 _ctlargcount(g, cp, 2); in groupctl()
116 _setctlimage(g, &g->image, cp->args[1]); in groupctl()
119 _ctlargcount(g, cp, 5); in groupctl()
125 ctlerror("%q: bad rectangle: %s", g->name, cp->str); in groupctl()
126 g->rect = r; in groupctl()
127 r = insetrect(r, g->border); in groupctl()
128 if (g->nkids == 0) in groupctl()
130 switch(g->type){ in groupctl()
132 boxboxresize(g, r); in groupctl()
135 columnresize(g, r); in groupctl()
138 rowresize(g, r); in groupctl()
141 stackresize(g, r); in groupctl()
146 _ctlargcount(g, cp, 2); in groupctl()
147 for (n = 0; n < g->nkids; n++) in groupctl()
148 if (strcmp(cp->args[1], g->kids[n]->name) == 0) in groupctl()
150 if (n == g->nkids) in groupctl()
151 ctlerror("%s: remove nonexistent control: %q", g->name, cp->args[1]); in groupctl()
152 removegroup(g, n); in groupctl()
153 if (g->setsize) in groupctl()
154 g->setsize((Control*)g); in groupctl()
157 g->hidden = 0; in groupctl()
158 if (debugr) fprint(2, "reveal %s\n", g->name); in groupctl()
159 if (g->type == Ctlstack){ in groupctl()
161 if (cp->iargs[1] < 0 || cp->iargs[1] >= g->nkids) in groupctl()
162 ctlerror("%s: control out of range: %q", g->name, cp->str); in groupctl()
163 g->selected = cp->iargs[1]; in groupctl()
165 _ctlargcount(g, cp, 1); in groupctl()
166 for (i = 0; i < g->nkids; i++) in groupctl()
167 if (g->kids[i]->ctl){ in groupctl()
168 if (g->selected == i){ in groupctl()
169 if (debugr) fprint(2, "reveal %s: reveal kid %s\n", g->name, g->kids[i]->name); in groupctl()
170 _ctlprint(g->kids[i], "reveal"); in groupctl()
172 if (debugr) fprint(2, "reveal %s: hide kid %s\n", g->name, g->kids[i]->name); in groupctl()
173 _ctlprint(g->kids[i], "hide"); in groupctl()
178 _ctlargcount(g, cp, 1); in groupctl()
179 if (debug) fprint(2, "reveal %s: border %R/%d\n", g->name, g->rect, g->border); in groupctl()
180 border(g->screen, g->rect, g->border, g->bordercolor->image, g->bordercolor->image->r.min); in groupctl()
181 r = insetrect(g->rect, g->border); in groupctl()
182 if (debug) fprint(2, "reveal %s: draw %R\n", g->name, r); in groupctl()
183 draw(g->screen, r, g->image->image, nil, g->image->image->r.min); in groupctl()
184 for (i = 0; i < g->nkids; i++) in groupctl()
185 if (g->kids[i]->ctl) in groupctl()
186 _ctlprint(g->kids[i], "reveal"); in groupctl()
189 _ctlargcount(g, cp, 1); in groupctl()
190 if (g->hidden) in groupctl()
193 if (debug) fprint(2, "show %s: border %R/%d\n", g->name, g->rect, g->border); in groupctl()
194 border(g->screen, g->rect, g->border, g->bordercolor->image, g->bordercolor->image->r.min); in groupctl()
195 r = insetrect(g->rect, g->border); in groupctl()
196 if (debug) fprint(2, "show %s: draw %R\n", g->name, r); in groupctl()
197 draw(g->screen, r, g->image->image, nil, g->image->image->r.min); in groupctl()
198 for (i = 0; i < g->nkids; i++) in groupctl()
199 if (g->kids[i]->ctl){ in groupctl()
200 if (debug) fprint(2, "show %s: kid %s: %q\n", g->name, g->kids[i]->name, cp->str); in groupctl()
201 _ctlprint(g->kids[i], "show"); in groupctl()
207 if (g->type == Ctlboxbox) in groupctl()
208 _ctlargcount(g, cp, 5); in groupctl()
211 ctlerror("%s: args of %q", g->name, cp->str); in groupctl()
214 g->mansize = 0; in groupctl()
215 if (g->setsize) in groupctl()
216 g->setsize((Control*)g); in groupctl()
219 _ctlargcount(g, cp, 5); in groupctl()
227 ctlerror("%q: bad sizes: %s", g->name, cp->str); in groupctl()
228 g->size = r; in groupctl()
229 g->mansize = 1; in groupctl()
234 if (g->type != Ctlstack){ in groupctl()
235 _ctlargcount(g, cp, 2); in groupctl()
237 ctlerror("%q: illegal value: %c", g->name, cp->str); in groupctl()
238 g->separation = cp->iargs[1]; in groupctl()
243 ctlerror("%q: unrecognized message '%s'", g->name, cp->str); in groupctl()
251 Group *g; in groupfree() local
253 g = (Group*)c; in groupfree()
254 _putctlimage(g->bordercolor); in groupfree()
255 free(g->kids); in groupfree()
261 Group *g; in groupmouse() local
264 g = (Group*)c; in groupmouse()
265 if (g->type == Ctlstack){ in groupmouse()
266 i = g->selected; in groupmouse()
267 if (i >= 0 && g->kids[i]->mouse && in groupmouse()
268 ( ( ((m->buttons == 0) || (g->lastbut == 0)) && in groupmouse()
269 ptinrect(m->xy, g->kids[i]->rect) ) || in groupmouse()
270 ( ((m->buttons != 0) || (g->lastbut != 0)) && in groupmouse()
271 (g->lastkid == i) ) ) ) { in groupmouse()
273 g->name, g->kids[i]->name, i, g->lastkid, m->buttons, g->lastbut, in groupmouse()
274 ptinrect(m->xy, g->kids[i]->rect) ? 1 : 0); in groupmouse()
275 (g->kids[i]->mouse)(g->kids[i], m); in groupmouse()
276 g->lastkid = i; in groupmouse()
277 g->lastbut = m->buttons; in groupmouse()
280 g->name, g->kids[i]->name, i, g->lastkid, m->buttons, g->lastbut, in groupmouse()
281 ptinrect(m->xy, g->kids[i]->rect) ? 1 : 0); in groupmouse()
287 for(i=0; i<g->nkids; i++) { in groupmouse()
288 if(g->kids[i]->mouse && in groupmouse()
289 ( ( ((m->buttons == 0) || (g->lastbut == 0)) && in groupmouse()
290 ptinrect(m->xy, g->kids[i]->rect) ) || in groupmouse()
291 ( ((m->buttons != 0) || (g->lastbut != 0)) && in groupmouse()
292 (g->lastkid == i) ) ) ) { in groupmouse()
294 g->name, g->kids[i]->name, i, g->lastkid, m->buttons, g->lastbut, in groupmouse()
295 ptinrect(m->xy, g->kids[i]->rect) ? 1 : 0); in groupmouse()
296 (g->kids[i]->mouse)(g->kids[i], m); in groupmouse()
300 g->name, g->kids[i]->name, i, g->lastkid, m->buttons, g->lastbut, in groupmouse()
301 ptinrect(m->xy, g->kids[i]->rect) ? 1 : 0); in groupmouse()
304 g->lastkid = lastkid; in groupmouse()
305 g->lastbut = m->buttons; in groupmouse()
310 g->lastbut = 0; in groupmouse()
313 if(g->lastbut == 0 && m->buttons != 0){ in groupmouse()
315 switch(g->stacking){ in groupmouse()
320 p0 = Pt(g->r.min.x, m->xy.y); in groupmouse()
321 p1 = Pt(g->r.max.x, m->xy.y); in groupmouse()
325 p0 = Pt(m->xy.x, g->r.min.y); in groupmouse()
326 p1 = Pt(m->xy.x, g->r.max.y); in groupmouse()
331 } else if (g->lastbut != 0 && s->m.buttons != 0){ in groupmouse()
346 } else if (g->lastbut != 0 && s->m.buttons == 0){ in groupmouse()
349 g->lastbut = s->m.buttons; in groupmouse()
357 Group *g; in activategroup() local
359 g = (Group*)c; in activategroup()
360 for (i = 0; i < g->nkids; i++) in activategroup()
362 activate(g->kids[i]); in activategroup()
364 deactivate(g->kids[i]); in activategroup()
412 Group *g = (Group*)c; in _ctladdgroup() local
414 g->kids = ctlrealloc(g->kids, sizeof(Group*)*(g->nkids+1)); in _ctladdgroup()
415 g->kids[g->nkids++] = q; in _ctladdgroup()
419 removegroup(Group *g, int n) in removegroup() argument
423 if (g->selected == n) in removegroup()
424 g->selected = -1; in removegroup()
425 else if (g->selected > n) in removegroup()
426 g->selected--; in removegroup()
428 for (i = n+1; i < g->nkids; i++) in removegroup()
429 g->kids[i-1] = g->kids[i]; in removegroup()
430 g->nkids--; in removegroup()
439 Group *g; in groupsize() local
441 g = (Group*)c; in groupsize()
442 assert(g->type == Ctlcolumn || g->type == Ctlrow || g->type == Ctlstack); in groupsize()
443 if (g->mansize) return; in groupsize()
445 if (debug) fprint(2, "groupsize %q\n", g->name); in groupsize()
446 for (i = 0; i < g->nkids; i++){ in groupsize()
447 q = g->kids[i]; in groupsize()
452 if (debug) fprint(2, "groupsize %q: [%d %q]: %R\n", g->name, i, q->name, q->size); in groupsize()
453 switch(g->type){ in groupsize()
456 r.min.x += q->size.min.x + g->border; in groupsize()
460 r.max.x += q->size.max.x + g->border; in groupsize()
470 r.min.y += q->size.min.y + g->border; in groupsize()
474 r.max.y += q->size.max.y + g->border; in groupsize()
486 g->size = rectaddpt(r, Pt(g->border, g->border)); in groupsize()
487 if (debug) fprint(2, "groupsize %q: %R\n", g->name, g->size); in groupsize()
491 boxboxresize(Group *g, Rectangle r) in boxboxresize() argument
496 … "boxboxresize %q %R (%d×%d) min/max %R separation %d\n", g->name, r, Dx(r), Dy(r), g->size, g->se… in boxboxresize()
498 for(i=0; i<g->nkids; i++){ in boxboxresize()
499 if (g->kids[i]->size.min.y > ht) in boxboxresize()
500 ht = g->kids[i]->size.min.y; in boxboxresize()
504 rows = Dy(r) / (ht+g->separation); in boxboxresize()
505 hpad = (Dy(r) % (ht+g->separation)) / g->nkids; in boxboxresize()
506 cols = (g->nkids+rows-1)/rows; in boxboxresize()
507 wid = Dx(r) / cols - g->separation; in boxboxresize()
508 for(i=0; i<g->nkids; i++){ in boxboxresize()
509 if (g->kids[i]->size.max.x < wid) in boxboxresize()
510 wid = g->kids[i]->size.max.x; in boxboxresize()
512 for(i=0; i<g->nkids; i++){ in boxboxresize()
513 if (g->kids[i]->size.min.x > wid) in boxboxresize()
514 wid = g->kids[i]->size.min.x; in boxboxresize()
518 wpad = (Dx(r) % (wid+g->separation)) / g->nkids; in boxboxresize()
519 rr = rectaddpt(Rect(0,0,wid, ht), addpt(r.min, Pt(g->separation/2, g->separation/2))); in boxboxresize()
521 for(i=0; i<g->nkids; i++){ in boxboxresize()
522 if(debug) fprint(2, " %d %q: %R (%d×%d)\n", i, g->kids[i]->name, rr, Dx(rr), Dy(rr)); in boxboxresize()
523 _ctlprint(g->kids[i], "rect %R", in boxboxresize()
524 rectaddpt(rr, Pt((wpad+wid+g->separation)*(i/rows), (hpad+ht+g->separation)*(i%rows)))); in boxboxresize()
526 g->nseparators = rows + cols - 2; in boxboxresize()
527 g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle)); in boxboxresize()
529 rr.max.y = rr.min.y + g->separation+hpad; in boxboxresize()
531 g->separators[i-1] = rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation-hpad)); in boxboxresize()
532 …ow separation %d [%d]: %R\n", i, i-1, rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation)… in boxboxresize()
535 rr.max.x = rr.min.x + g->separation+wpad; in boxboxresize()
537 g->separators[i+rows-2] = rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation-wpad, 0)); in boxboxresize()
538 …separation %d [%d]: %R\n", i, i+rows-2, rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation,… in boxboxresize()
543 columnresize(Group *g, Rectangle r) in columnresize() argument
551 … "columnresize %q %R (%d×%d) min/max %R separation %d\n", g->name, r, Dx(r), Dy(r), g->size, g->se… in columnresize()
552 if (x < g->size.min.x) { in columnresize()
553 werrstr("resize %s: too narrow: need %d, have %d", g->name, g->size.min.x, x); in columnresize()
554 r.max.x = r.min.x + g->size.min.x; in columnresize()
556 if (y < g->size.min.y) { in columnresize()
557 werrstr("resize %s: too short: need %d, have %d", g->name, g->size.min.y, y); in columnresize()
558 r.max.y = r.min.y + g->size.min.y; in columnresize()
561 d = ctlmalloc(g->nkids*sizeof(int)); in columnresize()
562 p = ctlmalloc(g->nkids*sizeof(int)); in columnresize()
564 for (i = 0; i < g->nkids; i++) { in columnresize()
565 q = g->kids[i]; in columnresize()
572 y -= (g->nkids-1) * g->separation; in columnresize()
577 if (y >= g->size.max.y - g->size.min.y) { in columnresize()
579 for (i = 0; i < g->nkids; i++) in columnresize()
581 y -= g->size.max.y - g->size.min.y; in columnresize()
585 for (i = 0; i < g->nkids; i++) { in columnresize()
586 t = p[i] * y/(g->size.max.y - g->size.min.y); in columnresize()
593 g->nseparators = g->nkids-1; in columnresize()
594 g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle)); in columnresize()
597 for (i = 0; i < g->nkids; i++) { in columnresize()
598 q = g->kids[i]; in columnresize()
599 if (i < g->nkids - 1){ in columnresize()
600 g->separators[i].min.x = r.min.x; in columnresize()
601 g->separators[i].max.x = r.max.x; in columnresize()
603 t = y / (g->nkids - i); in columnresize()
608 g->separators[i-1].max.y = rr.min.y; in columnresize()
611 if (i < g->nkids - 1) in columnresize()
612 g->separators[i].min.y = rr.max.y; in columnresize()
613 j += g->separation + t - t/2; in columnresize()
622 rowresize(Group *g, Rectangle r) in rowresize() argument
630 …if(debug) fprint(2, "rowresize %q %R (%d×%d), separation %d\n", g->name, r, Dx(r), Dy(r), g->separ… in rowresize()
631 if (x < g->size.min.x) { in rowresize()
632 werrstr("resize %s: too narrow: need %d, have %d", g->name, g->size.min.x, x); in rowresize()
633 r.max.x = r.min.x + g->size.min.x; in rowresize()
636 if (y < g->size.min.y) { in rowresize()
637 werrstr("resize %s: too short: need %d, have %d", g->name, g->size.min.y, y); in rowresize()
638 r.max.y = r.min.y + g->size.min.y; in rowresize()
640 d = ctlmalloc(g->nkids*sizeof(int)); in rowresize()
641 p = ctlmalloc(g->nkids*sizeof(int)); in rowresize()
643 for (i = 0; i < g->nkids; i++) { in rowresize()
644 q = g->kids[i]; in rowresize()
651 x -= (g->nkids-1) * g->separation; in rowresize()
656 if (x >= g->size.max.x - g->size.min.x) { in rowresize()
657 if (debug) fprint(2, "max: %d > %d - %d", x, g->size.max.x, g->size.min.x); in rowresize()
659 for (i = 0; i < g->nkids; i++) in rowresize()
661 x -= g->size.max.x - g->size.min.x; in rowresize()
663 if (debug) fprint(2, "divvie up: %d < %d - %d", x, g->size.max.x, g->size.min.x); in rowresize()
666 for (i = 0; i < g->nkids; i++) { in rowresize()
667 t = p[i] * x/(g->size.max.x - g->size.min.x); in rowresize()
675 g->nseparators = g->nkids-1; in rowresize()
676 g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle)); in rowresize()
678 for (i = 0; i < g->nkids; i++) { in rowresize()
679 q = g->kids[i]; in rowresize()
680 if (i < g->nkids - 1){ in rowresize()
681 g->separators[i].min.y = r.min.y; in rowresize()
682 g->separators[i].max.y = r.max.y; in rowresize()
684 t = x / (g->nkids - i); in rowresize()
689 g->separators[i-1].max.x = rr.min.x; in rowresize()
692 if (i < g->nkids - 1) in rowresize()
693 g->separators[i].min.x = rr.max.x; in rowresize()
694 j += g->separation + t - t/2; in rowresize()
703 stackresize(Group *g, Rectangle r) in stackresize() argument
710 if(debug) fprint(2, "stackresize %q %R (%d×%d)\n", g->name, r, Dx(r), Dy(r)); in stackresize()
711 if (x < g->size.min.x){ in stackresize()
712 werrstr("resize %s: too narrow: need %d, have %d", g->name, g->size.min.x, x); in stackresize()
715 if (y < g->size.min.y){ in stackresize()
716 werrstr("resize %s: too short: need %d, have %d", g->name, g->size.min.y, y); in stackresize()
719 if (x > g->size.max.x) { in stackresize()
720 x = (x - g->size.max.x)/2; in stackresize()
724 if (y > g->size.max.y) { in stackresize()
725 y = (y - g->size.max.y)/2; in stackresize()
729 for (i = 0; i < g->nkids; i++){ in stackresize()
730 q = g->kids[i]; in stackresize()
733 for (i = 0; i < g->nkids; i++){ in stackresize()
734 q = g->kids[i]; in stackresize()