Пример #1
0
static void
Draw(void *p)
{
	AG_Button *bu = p;
	AG_Variable *binding;
	void *pState;
	int pressed;
	
	binding = AG_GetVariable(bu, "state", &pState);
	pressed = GetState(bu, binding, pState);
	AG_UnlockVariable(binding);

	if (AG_WidgetEnabled(bu)) {
		AG_DrawBox(bu,
		    AG_RECT(0, 0, WIDTH(bu), HEIGHT(bu)),
		    pressed ? -1 : 1,
		    WCOLOR(bu,0));
	} else {
		AG_DrawBoxDisabled(bu,
		    AG_RECT(0, 0, WIDTH(bu), HEIGHT(bu)),
		    pressed ? -1 : 1,
		    WCOLOR_DEF(bu,0),
		    WCOLOR_DIS(bu,0));
	}

	if (bu->lbl != NULL) {
		AG_WidgetDraw(bu->lbl);
	} else if (bu->surface != -1) {
		int w = WSURFACE(bu,bu->surface)->w;
		int h = WSURFACE(bu,bu->surface)->h;
		int x = 0, y = 0;

		switch (bu->justify) {
		case AG_TEXT_LEFT:	x = bu->lPad;			break;
		case AG_TEXT_CENTER:	x = WIDTH(bu)/2 - w/2;		break;
		case AG_TEXT_RIGHT:	x = WIDTH(bu) - w - bu->rPad;	break;
		}
		switch (bu->valign) {
		case AG_TEXT_TOP:	y = bu->tPad;			break;
		case AG_TEXT_MIDDLE:	y = HEIGHT(bu)/2 - h/2;		break;
		case AG_TEXT_BOTTOM:	y = HEIGHT(bu) - h - bu->bPad;	break;
		}
		if (pressed) {
			x++;
			y++;
		}
		AG_WidgetBlitSurface(bu, bu->surface, x, y);
	}
}
Пример #2
0
static void
Draw(void *obj)
{
	AG_FontSelector *fs = obj;
	AG_Widget *chld;

	WIDGET_FOREACH_CHILD(chld, obj)
		AG_WidgetDraw(chld);
	
	AG_DrawBox(fs, fs->rPreview, -1, agColors[FIXED_BOX_COLOR]);
	if (fs->sPreview != -1) {
		AG_Surface *su = WSURFACE(fs,fs->sPreview);

		AG_WidgetBlitSurface(fs, fs->sPreview,
		    fs->rPreview.x + fs->rPreview.w/2 - su->w/2,
		    fs->rPreview.y + fs->rPreview.h/2 - su->h/2);
	}
}
Пример #3
0
/*
 * Draw function. Invoked from GUI rendering context to draw the widget
 * at its current location. All primitive and surface operations operate
 * on widget coordinates.
 */
static void
Draw(void *p)
{
	formaText *my = (formaText*)p;


	/*
	 * Render some text into a new surface. In OpenGL mode, the
	 * AG_WidgetMapSurface() call involves a texture upload.
	 */
	if (my->mySurface == -1) {
		my->mySurface = AG_WidgetMapSurface(my,
		    surf1);
	};


  //AG_WidgetUpdateSurface(my,my->mySurface);
	/* Blit the mapped surface at [0,0]. */
	AG_WidgetBlitSurface(my, my->mySurface, 0, 0);
}
Пример #4
0
void
agar_widget_blit_surface (AG_Widget *widget, int surface_id, int x, int y)
{
  AG_WidgetBlitSurface (widget, surface_id, x, y);
}