Exemple #1
0
static void redraw_sliders() {
    gl_slider *sl = firstslider;
    while (sl != NULL) {
	drawslider(sl);
	sl = sl->nextp;
    }
}
Exemple #2
0
void destroy_gl_slider(gl_slider *sld) {
    gl_slider *sl = firstslider, *osl, *np;

    osl = sl;
    while (sl != NULL) {
#ifdef DEBUG
	printf("dest_sl: format = %s ", sl->format);
#endif
	np = sl->nextp;
	if (sl == sld) {
#ifdef DEBUG
	    printf("destroying\n");
#endif
	    osl->nextp = sl->nextp;
	    if (firstslider == sl) firstslider = sl->nextp;
	    sl->fg = sl->bg;
	    drawslider(sl);
	    if (sl->buf != NULL) free(sl->buf);
	    free(sl);
	    np = NULL;
	}
#ifdef DEBUG
	puts("");
#endif
	osl = sl;
	sl = np;
    }
#ifdef DEBUG
    sl = firstslider;
    while (sl!=NULL) {
	printf("after destroy slider: %s\n", sl->format);
	sl=sl->nextp;
    }
#endif
}
Exemple #3
0
static void setslider(int x, gl_slider *sl) {
    sl->value = sl->min + 
      (sl->max - sl->min) * (x - sl->scx0 - sl->sc_thick/2) / 
	(1.0 * sl->scx1 - 1.0 * sl->scx0);
    sl->value = sl->step * floor(0.5 + sl->value / sl->step);
    if (sl->value < sl->min) sl->value = sl->min;
    if (sl->value > sl->max) sl->value = sl->max;
    if (sl->valuep != NULL) *(sl->valuep) = sl->value;
    drawslider(sl);
}
Exemple #4
0
gl_slider *create_gl_slider(double x, double y, double len, double height, double thick,
			    int fg, int bg,
			    double min, double max, double step, double initvalue,
			    double *valuep, char *format, 
			    void (*callback)(gl_slider *, double)) {

    gl_slider *newslider;
    
    if ((newslider = (gl_slider *)malloc(sizeof(gl_slider))) == NULL) 
      return(NULL);
    
    if (firstslider == NULL) {
	/* initialization */
	check_vers();
	qdevice(LEFTMOUSE);
	tie(LEFTMOUSE, MOUSEX, MOUSEY);
	firstslider = actslider = newslider;
    } 
	
    actslider->nextp = newslider;
    actslider = newslider;
    
    actslider->nextp  = NULL;
    actslider->win    = winget();
    actslider->x      = x;
    actslider->y      = y;
    actslider->len    = len;
    actslider->height = height;
    actslider->thick  = thick;
    actslider->fg     = fg;
    actslider->bg     = bg;
    actslider->txbg   = -1;
    actslider->min    = min;
    actslider->max    = max;
    actslider->step   = step;
    actslider->value  = initvalue;
    actslider->valuep = valuep;
    if (valuep != NULL) *valuep = initvalue;
    actslider->format = format;
    if (actslider->format != NULL) {
	actslider->buf    = (char *)malloc(strlen(format) + 51);
	*(actslider->buf) = ' ';
	*(actslider->buf + 1) = 0;
    }
    actslider->callback = callback;

    drawslider(actslider);
    
    return(actslider);
}
Exemple #5
0
static void
tkhscroll(Tk *tk, TkScroll *tks, Image *i, Point size)
{
	TkEnv *e;
	Point p[3], o;
	int bo, w, h, triangle;

	e = tk->env;

	triangle = tk->act.height - Elembw;

	bo = tk->borderwidth + Elembw;
	p[0].x = bo;
	p[0].y = size.y/2;
	p[1].x = p[0].x + triangle;
	p[1].y = p[0].y - triangle/2 + 1;
	p[2].x = p[0].x + triangle;
	p[2].y = p[0].y + triangle/2 - 2;
	drawarrow(tks, i, p, e, ActiveA1, ButtonA1);

	tks->a1 = p[2].x;
	w = p[2].x + Elembw;

	p[0].x = size.x - bo - 1;
	p[1].x = p[0].x - triangle;
	p[2].x = p[0].x - triangle;
	drawarrow(tks, i, p, e, ActiveA2, ButtonA2);

	tks->a2 = p[2].x;

	o.x = bo + triangle + 2*Elembw;
	o.y = tk->borderwidth;
	w = p[2].x - 2*Elembw - w - 2*tk->borderwidth;
	h = size.y - 2*bo;

	o.x += TKF2I(tks->top*w);
	w *= tks->bot - tks->top;
	w = TKF2I(w);

	tks->t1 = o.x - Elembw;
	tks->t2 = o.x + w + Elembw;

	drawslider(tks, i, o, w, h, e);
}
Exemple #6
0
static void
tkvscroll(Tk *tk, TkScroll *tks, Image *i, Point size)
{
	TkEnv *e;
	Point p[3], o;
	int bo, w, h, triangle;

	e = tk->env;

	triangle = tk->act.width - Elembw;

	bo = tk->borderwidth + Elembw;
	p[0].x = size.x/2;
	p[0].y = bo;
	p[1].x = p[0].x - triangle/2;
	p[1].y = p[0].y + triangle;
	p[2].x = p[0].x + triangle/2;
	p[2].y = p[0].y + triangle;
	drawarrow(tks, i, p, e, ActiveA1, ButtonA1);

	tks->a1 = p[2].y;
	h = p[2].y + Elembw;

	p[0].y = size.y - bo - 1;
	p[1].y = p[0].y - triangle;
	p[2].y = p[0].y - triangle;
	drawarrow(tks, i, p, e, ActiveA2, ButtonA2);

	tks->a2 = p[2].y;

	o.x = tk->borderwidth ;
	o.y = bo + triangle + 2*Elembw;
	w = size.x - 2*bo;
	h = p[2].y - 2*Elembw - h - 2*tk->borderwidth;

	o.y += TKF2I(tks->top*h);
	h *= tks->bot - tks->top;
	h = TKF2I(h);

	tks->t1 = o.y - Elembw;
	tks->t2 = o.y + h + Elembw;

	drawslider(tks, i, o, w, h, e);
}