Exemplo n.º 1
0
static void drawslider(gl_slider *sl) {
    Int32 lw = getlwidth();
    Int32 cl = getcolor();
    Int32 oriwin = winget();
    long co;
    int i;
    Screencoord x, y;
    Int32 xo, yo;
    
    winset(sl->win);
    linewidth(1);
   
    update_slider_value(sl);
    locate_slider(sl);
    
    if (sl->txbg == -1) {
	/* first time, get bg color */
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	getcpos(&x, &y);
	getorigin(&xo, &yo);
	x -= xo;
	y -= yo;
	i = lrectread(x, y, x, y, &co);
	sl->txbg = co;
#ifdef DEBUG
	printf("textbg = %d, bytes = %d x %d (soll %g) y %d (soll %g)\n",
	       co,i,x,sl->x + sl->len + sl->thick,
	       y,sl->y);	
#endif
    }
    color(sl->bg);
    rectf(sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    color(sl->fg);
    rect (sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    rectf(sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min),
	  sl->y,
	  sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min) + sl->thick,
	  sl->y + sl->height);
    if (sl->buf != NULL) {
	color(sl->txbg);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
	color(sl->fg);
	sprintf(sl->buf + 1, sl->format, sl->value);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
    }
    
    winset(oriwin);
    color(cl);
    linewidth(lw);
    
    sleep(0);
}
Exemplo n.º 2
0
void GE_SliderSetProc(
Widget	slider,
String	value)
{
    Widget	scale, text;

    if( (scale = XtNameToWidget(slider, ".scale")) == NULL )
	return;

    if( (text = XtNameToWidget(slider, ".text")) == NULL )
	return;

    XtVaSetValues(text, XmNvalue, value, NULL);
    update_slider_value(text, scale, NULL);

    return;
}
Exemplo n.º 3
0
static int updateslider(int x, int y, gl_slider *sl) {
    Int32 xo, yo;
    Int16 xx, yy;
    double orival;
    Int32  oriwin = winget();
    int dev;
    
    orival = sl->value;
    update_slider_value(sl);
    winset(sl->win);

    getorigin(&xo, &yo);
    x -= xo;
    y -= yo;

#ifdef DEBUG
    printf("updateslider: slider label %s - ", sl->buf);
#endif    
    locate_slider(sl);
    
    if (x < sl->scx0 || y > sl->scy0 ||
	x > sl->scx1 + sl->sc_thick  ||	y < sl->scy1) {
	winset(oriwin);
	if (orival != sl->value) {
	    /* This is used when the click is not for this slider, but
	       update_slider_value() has changed the value... */
	    if (sl->callback != NULL) sl->callback(sl, sl->value);
#ifdef DEBUG
	    puts("return(-1)");
#endif
	    return(-1);
	} else {
#ifdef DEBUG
	    puts("return(FALSE)");
#endif
	    return(FALSE);
	}
    }
	
    while (qtest() == 0 || (dev = qread(&xx)) != LEFTMOUSE) {
	/* getorigin(&xo, &yo); */
	setslider(getvaluator(MOUSEX) - xo, sl);
	usleep(100000);
    } 
#ifdef DEBUG
    printf("updateslider: got an event, dev = %d val = %d\n", dev, (int)xx);
    if (qtest()) {
	int dev; 
	dev = qread(&xx);
	printf("updateslider: qtest() for x is true. dev = %d, val = %d\n",
	       dev, (int)xx);
    } else {
	xx = getvaluator(MOUSEX);
	printf("updateslider: qtest() for x is FALSE!. x = %d\n", (int)xx);
    }
    if (qtest()) {
	int dev; 
	dev = qread(&yy);
	printf("updateslider: qtest() for y is true. dev = %d, val = %d\n",
	       dev, (int)yy);
    } else {
	yy = getvaluator(MOUSEY);
	printf("updateslider: qtest() for y is FALSE!. y = %d\n", (int)yy);
    }
    setslider((int)(xx-xo), sl);
#else
    if (qtest()) qread(&xx);
    if (qtest()) {
	qread(&yy);
	setslider((int)(xx-xo), sl);
    } else 
      fprintf(stderr, 
	      "updateslider: This should not happen, tie() seems to fail.\n");
#endif
    winset(oriwin);
    if (sl->value != orival) {
	if (sl->callback != NULL) sl->callback(sl, sl->value);
	return(TRUE);
#ifdef DEBUG
	puts("return(TRUE)");
#endif
    } else {
#ifdef DEBUG
	puts("return(FALSE)");
#endif
	return(FALSE);
    }
}
Exemplo n.º 4
0
void create_slider(GuiObject * slid)
{
	GuiWindow *win;
	int x, y, length, XPos, YPos;
	
	check_object(slid, "slid", "create_slider");
	win = slid->win;
	check_window(win, "create_slider");

	if (slid->hide);
	else if (slid->type == HOR_SLIDER) {	/* horizontal slider */
		win_fillbox(win, slid->x, slid->y, slid->slider_length, dimension, slid->bg_col2);
		win_fillbox(win, slid->x + slid->position, slid->y, slid->length, dimension, slid->fg_col);
		win_3dbox(win, UP_FRAME, slid->x + slid->position, slid->y, slid->length, dimension);
	} else if (slid->type == VERT_SLIDER) {		/* vertical slider */
		win_fillbox(win, slid->x, slid->y, dimension, slid->slider_length, slid->bg_col2);
		win_fillbox(win, slid->x, slid->y + slid->slider_length - slid->position -
		       slid->length, dimension, slid->length, slid->fg_col);
		win_3dbox(win, UP_FRAME, slid->x, slid->y + slid->slider_length - slid->position -
			  slid->length, dimension, slid->length);
	} else if (slid->type == NICE_HOR_SLIDER) {	/* nice horizontal slider */
		win_fillbox(win, slid->x - 4, slid->y, slid->slider_length + 9, slid_width, slid->bg_col1);
		/* Draw a grid lines */
		for (x = 0;x <= slid->slider_length;x += 10) {
			if (x % 50 == 0)
				length = 3;
			else
				length = 1;
			XPos = slid->x + x;
			win_line(win, XPos, slid->y + 4, XPos, slid->y - length + 4, BLACK, FALSE);
			win_line(win, XPos, slid->y + 12, XPos, slid->y + 12 + length, BLACK, FALSE);
		}
		/* Draw the slider */
		win_box(win, slid->x, slid->y + slid_width / 2, slid->slider_length, 1, BLACK);
		win_3dbox(win, DOWN_FRAME, slid->x - 1, slid->y + slid_width / 2 - 2, slid->slider_length + 2, 5);
		if (slid->middle)
			win_box(win, slid->x + (slid->slider_length) / 2, slid->y + slid_width / 2 - 2, 0, 6, RED);
		win_fillbox(win, slid->x + slid->position - 4, slid->y, 8, slid_width, slid->bg_col2);
		win_3dbox(win, UP_FRAME, slid->x + slid->position - 4, slid->y, 8, slid_width);
		win_box(win, slid->x + slid->position, slid->y + 3, 0, slid_width - 6, slid->fg_col);
	} else if (slid->type == NICE_VERT_SLIDER ||
		   slid->type == NICE_VALUE_SLIDER) {	/* nice vertical slider */
		/* Draw a grid lines */
		win_fillbox(win, slid->x, slid->y - 4, slid_width, slid->slider_length + 9, slid->bg_col1);
		for (y = 0;y <= slid->slider_length;y += 10) {
			if (y % 50 == 0)
				length = 3;
			else
				length = 1;
			YPos = slid->y + slid->slider_length - y - 1;
			win_line(win, slid->x + 12, YPos, slid->x + 12 + length, YPos, BLACK, FALSE);
			win_line(win, slid->x + 3 - length, YPos, slid->x + 3, YPos, BLACK, FALSE);
		}
		/* Draw the slider */
		win_box(win, slid->x + slid_width / 2, slid->y, 1, slid->slider_length, BLACK);
		win_3dbox(win, DOWN_FRAME, slid->x + slid_width / 2 - 2, slid->y - 1, 5, slid->slider_length + 2);
		if (slid->middle)
			win_box(win, slid->x + slid_width / 2 - 2, (slid->slider_length) / 2 + slid->y, 6, 0, RED);
		win_fillbox(win, slid->x, slid->slider_length - slid->position + slid->y - 4, slid_width, 8, slid->bg_col2);
		win_3dbox(win, UP_FRAME, slid->x, slid->slider_length - slid->position + slid->y - 4, slid_width, 8);
		win_box(win, slid->x + 3, slid->slider_length - slid->position + slid->y, slid_width - 6, 0, slid->fg_col);
	}
	if (slid->type == NICE_VALUE_SLIDER)
		update_slider_value(slid);
}