Example #1
0
	void
x_set_edit_place( long index, int x, int y, int nx, int ny )
{
	Widget	horiz_scroll, vert_scroll;
	float	shown_horiz, shown_vert;
	Dimension list_nx, list_ny;
	int	element_dx, element_dy, cx, cy;

	if( dataedit_popup_widget == NULL )
		return;

	XawListHighlight( dataedit_list_widget, index );
	horiz_scroll = XtNameToWidget( dataedit_viewport_widget, "horizontal" );
	vert_scroll  = XtNameToWidget( dataedit_viewport_widget, "vertical"   );
	XtVaGetValues( horiz_scroll, XtNshown,  &shown_horiz, NULL );
	XtVaGetValues( vert_scroll, XtNshown,  &shown_vert, NULL );

	XtVaGetValues( dataedit_list_widget, XtNwidth, &list_nx, XtNheight, &list_ny, NULL );
	element_dx = list_nx / nx;
	element_dy = list_ny / ny;
	cx = (x-2)*element_dx;
	cy = (y-5)*element_dy;

	XawViewportSetCoordinates( dataedit_viewport_widget, cx, cy );
}
Example #2
0
int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
    PIXpoint_t po;
    PIXsize_t ps;
    Dimension width, height;
    int ai;
    XColor c;
    int color;

    RESETARGS;
    for (ai = 0; ai < attrn; ai++) {
        switch (attrp[ai].id) {
        case G_ATTRSIZE:
            GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
            ADD2ARGS (XtNwidth, ps.x);
            ADD2ARGS (XtNheight, ps.y);
            break;
        case G_ATTRBORDERWIDTH:
            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
            break;
        case G_ATTRCHILDCENTER:
            GETORIGIN (attrp[ai].u.p, po);
            ADD2ARGS (XtNwidth, &width);
            ADD2ARGS (XtNheight, &height);
            XtGetValues (widget->w, argp, argn);
            po.x -= width / 2, po.y -= height / 2;
            if (po.x < 0)
                po.x = 0;
            if (po.y < 0)
                po.y = 0;
            XawViewportSetCoordinates (widget->w, po.x, po.y);
            break;
        case G_ATTRMODE:
            if (strcmp ("forcebars", attrp[ai].u.t) == 0)
                ADD2ARGS (XtNforceBars, True);
            else {
                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
                return -1;
            }
            break;
        case G_ATTRCOLOR:
            color = attrp[ai].u.c.index;
            if (color != 0 && color != 1) {
                Gerr (POS, G_ERRBADCOLORINDEX, color);
                return -1;
            }
            c.red = attrp[ai].u.c.r * 257;
            c.green = attrp[ai].u.c.g * 257;
            c.blue = attrp[ai].u.c.b * 257;
            if (XAllocColor (
                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
            )) {
                if (color == 0)
                    ADD2ARGS (XtNbackground, c.pixel);
                else
                    ADD2ARGS (XtNforeground, c.pixel);
	    }
            break;
        case G_ATTRWINDOWID:
            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
            return -1;
        case G_ATTRUSERDATA:
            widget->udata = attrp[ai].u.u;
            break;
        default:
            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
            return -1;
        }
    }
    XtSetValues (widget->w, argp, argn);
    return 0;
}