diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libprefab/box.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libprefab/box.c')
| -rw-r--r-- | libprefab/box.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/libprefab/box.c b/libprefab/box.c new file mode 100644 index 00000000..a64d791f --- /dev/null +++ b/libprefab/box.c @@ -0,0 +1,80 @@ +#include <lib9.h> +#include <draw.h> +#include <interp.h> +#include <isa.h> +#include "../libinterp/runt.h" +#include <drawif.h> +#include <prefab.h> + +PCompound* +box(Prefab_Environ *e, Draw_Point p, Prefab_Element *title, Prefab_Element *list) +{ + Draw_Rect er, r, lr; + PCompound *pc; + Prefab_Compound *c; + Image *disp; + Draw_Image *ddisp; + Screen *screen; + Heap *h; + Point pt; + int w; + + if(list == H) + return H; + screen = lookupscreen(e->screen); + if(screen == nil) + return H; + h = heapz(TCompound); + if(h == H) + return H; + pc = H2D(PCompound*, h); + c = &pc->c; + + gchalt++; + r = list->r; + if(title != H){ + w = 2+1+3+Dx(title->r)+1; + if(w > Dx(r)) + r.max.x = r.min.x + w; + r.max.y += 2+1+Dy(title->r)+1; + } + + er = edgerect(e, p, &r); + + disp = allocwindow(screen, IRECT(er), Refbackup /*refreshcompound*/, DWhite); + if(disp == nil){ + Err: + destroy(c); + gchalt--; + return H; + } + if((ddisp=mkdrawimage(disp, e->screen, e->screen->display, nil)) == H){ + freeimage(disp); + goto Err; + } + + lr = r; + if(title != H){ + pt.x = r.min.x+3; + pt.y = r.min.y+3; + translateelement(title, pt); + lr.min.y = title->r.max.y+1; + } + translateelement(list, subpt(IPOINT(lr.min), IPOINT(list->r.min))); + + c->r = r; + c->image = ddisp; + c->environ = e; + D2H(e)->ref++; + if(title != H){ + c->title = title; + D2H(title)->ref++; + } + if(list != H){ + c->contents = (Prefab_Element*)list; + D2H(list)->ref++; + } + pc->display = screen->display; + gchalt--; + return pc; +} |
