Example #1
0
File: ebind.c Project: 8l/inferno
/* our dirty little secret */
static void
focusdirty(Tk *tk)
{
	if(tk->highlightwidth > 0){
		tk->dirty = tkrect(tk, 1);
		tkdirty(tk);
	}
}
Example #2
0
static void
autoselect(Tk *tk, void *v, int cancelled)
{
	TkEntry *tke = TKobj(TkEntry, tk);
	Rectangle hitr;
	char buf[32];
	Point p;

	USED(v);

	if (cancelled)
		return;

	p = tkscrn2local(tk, Pt(tke->oldx, 0));
	p.y = 0;
	if (tkvisiblerect(tk, &hitr) && ptinrect(p, hitr))
		return;

	snprint(buf, sizeof(buf), "to @%d", p.x);
	tkentryselect(tk, buf, nil);
	tkdirty(tk);
	tkupdate(tk->env->top);
}
Example #3
0
static int
tkpacker(Tk *master)
{
	Tk *slave;
	TkGeom frame, cavity, pos;
	int maxwidth, maxheight, tmp, slave2BW;

	pos.width = 0;
	pos.height = 0;
	maxwidth = 0;
	maxheight = 0;

	master->flag |= Tkrefresh;

	for (slave = master->slave; slave != nil; slave = slave->next) {
		slave2BW = slave->borderwidth*2;
		if(slave->flag & (Tktop|Tkbottom)) {
	    		tmp = slave->req.width + slave2BW +
		    		slave->pad.x + slave->ipad.x + pos.width;
			if(tmp > maxwidth)
				maxwidth = tmp;
	    		pos.height += slave->req.height + slave2BW +
		    		slave->pad.y + slave->ipad.y;
		}
		else {
	    		tmp = slave->req.height + slave2BW +
		    		slave->pad.y + slave->ipad.y + pos.height;
	    		if(tmp > maxheight)
				maxheight = tmp;
	    		pos.width += slave->req.width + slave2BW +
		    		+ slave->pad.x + slave->ipad.x;
		}
	}
	if(pos.width > maxwidth)
		maxwidth = pos.width;
	if(pos.height > maxheight)
		maxheight = pos.height;

	if(maxwidth != master->req.width || maxheight != master->req.height)
	if((master->flag & Tknoprop) == 0) {
		if(master->geom != nil) {
			master->geom(master, master->act.x, master->act.y, 
					maxwidth, maxheight);
		} else {
			master->req.width = maxwidth;
			master->req.height = maxheight;
			tkpackqit(master->master);
		}
		return 0;
    	}

    	cavity.x = 0;
	cavity.y = 0;
	pos.x = 0;
	pos.y = 0;
	cavity.width = master->act.width;
	cavity.height = master->act.height;

	for(slave = master->slave; slave != nil; slave = slave->next) {
		slave2BW = slave->borderwidth*2;
		if(slave->flag & (Tktop|Tkbottom)) {
	    		frame.width = cavity.width;
	    		frame.height = slave->req.height + slave2BW +
		    			slave->pad.y + slave->ipad.y;
	    		if(slave->flag & Tkexpand)
				frame.height += tkexpandy(slave, cavity.height);
	    		cavity.height -= frame.height;
	    		if(cavity.height < 0) {
				frame.height += cavity.height;
				cavity.height = 0;
	    		}
	    		frame.x = cavity.x;
	    		if(slave->flag & Tktop) {
				frame.y = cavity.y;
				cavity.y += frame.height;
	    		}
			else
				frame.y = cavity.y + cavity.height;
		}
		else {
	    		frame.height = cavity.height;
	    		frame.width = slave->req.width + slave2BW + 
					slave->pad.x + slave->ipad.x;
	    		if(slave->flag & Tkexpand)
				frame.width += tkexpandx(slave, cavity.width);
	    		cavity.width -= frame.width;
	    		if(cavity.width < 0) {
				frame.width += cavity.width;
				cavity.width = 0;
	    		}
	    		frame.y = cavity.y;
	    		if(slave->flag & Tkleft) {
				frame.x = cavity.x;
				cavity.x += frame.width;
	    		}
			else
				frame.x = cavity.x + cavity.width;
		}

		tksetslavereq(slave, frame);
	}

	master->dirty = tkrect(master, 1);
	tkdirty(master);
	return 1;
}