Example #1
0
void
pageclose(Page *p)
{
	Page *c, *nc;

	if(p == selpage)
		selpage = nil;
	pageabort(p);
	closeimages(p);
	urlfree(p->url);
	p->url = nil;
	if(p->doc){
		freedocinfo(p->doc);
		p->doc = nil;
	}
	layfree(p->lay);
	p->lay = nil;
	freeitems(p->items);
	p->items = nil;
	for(c=p->child; c!=nil; c=nc){
		nc = c->next;
		pageclose(c);
		free(c);
	}
	p->child = nil;
	closerunestr(&p->title);
	closerunestr(&p->refresh.rs);
	p->refresh.t = 0;
	p->pos = ZP;
	p->top = ZP;
	p->bot = ZP;
	p->loading = p->aborting = FALSE;
}
Example #2
0
File: tabs.c Project: 99years/plan9
static
int
tableheight(Table *t, int sep)
{
	Tablecell *c;
	Lay *lay;
	int i, h, toth;

	for(i=0; i<t->nrow; i++){
		h = 0;
		for(c=t->rows[i].cells; c!=nil; c=c->nextinrow){
			if(c->rowspan != 1)
				continue;
			lay = layitems(c->content, Rect(0, 0, cellwidth(t, c, sep), 0), FALSE);
			h = max(h, max(Dy(lay->r), c->hspec));
			layfree(lay);
		}
		t->rows[i].height = h;
	}
	fixrows(t, sep);
	toth = 0;
	for(i=0; i<t->nrow; i++)
		toth += t->rows[i].height;

	return toth;
}
Example #3
0
File: tabs.c Project: 99years/plan9
static
void
settable(Table *t)
{
	Tablecell *c;
	Lay *lay;

	for(c=t->cells; c!=nil; c=c->next){
		lay = layitems(c->content, Rect(0,0,0,0), FALSE);
		c->minw = Dx(lay->r);
		layfree(lay);
		if(dimenkind(c->wspec) == Dnone){
			lay = layitems(c->content, Rect(0,0,Tablemax,0), FALSE);
			c->maxw = Dx(lay->r);
			layfree(lay);
		}
	}
}
Example #4
0
File: tabs.c Project: 99years/plan9
static
void
fixrows(Table *t, int sep)
{
	Tablecell *c;
	Lay *lay;
	int h, ah, i, d, n, rem;

	for(c=t->cells; c!=nil; c=c->next){
		if(c->rowspan == 1)
			continue;
		n = c->rowspan;
		if(n==0 || c->row+n>t->nrow)
			n = t->nrow - c->row;

		lay = layitems(c->content, Rect(0,0,cellwidth(t, c, sep),0), FALSE);
		h = max(Dy(lay->r), c->hspec);
		layfree(lay);
		h -= t->cellspacing*(n-1) + n*sep;
		ah = 0;
		for(i=c->row; i<c->row+n; i++)
			ah += t->rows[i].height;

		rem = h-ah;
		if(rem <= 0)
			continue;

		for(i=c->row; i<c->row+n; i++){
			if(ah > 0){
				d = t->rows[i].height*100/ah;
				d = d*rem/100;
			}else
				d = rem/n;

			t->rows[i].height += d;
		}
	}
}