void DumpObject::PutCharScreen(BYTE c)
{
    Uint32 ucs[2];
    AG_Surface *r = NULL;

    if(Sym2UCS4(c, ucs) && (c != 0x20)) {
        if(pDbgDialogSymFont != NULL) {
            AG_PushTextState();
            AG_TextFont(pDbgDialogSymFont);
            AG_TextColor(fgColor);
            AG_TextBGColor(bgColor);
            AG_TextValign(AG_TEXT_MIDDLE);
            r = AG_TextRenderUCS4((const Uint32 *)ucs);
            AG_PopTextState();
        }
    } else if(Txt2UCS4(c, ucs) && (c != 0x20)) {
        if(pDbgDialogTextFont != NULL) {
            AG_PushTextState();
            AG_TextFont(pDbgDialogTextFont);
            AG_TextColor(fgColor);
            AG_TextBGColor(bgColor);
            AG_TextValign(AG_TEXT_MIDDLE);
            r = AG_TextRenderUCS4((const Uint32 *)ucs);
            AG_PopTextState();
        }
    }
    {   // Clear Cursor position 20130122 (-_-;
        AG_Rect rect;
        rect.x = X * CHRW;
        rect.y = Y * CHRH;
        rect.w = CHRW;
        rect.h = CHRH;
        AG_FillRect(Screen, &rect, bgColor);
    }
    if(r != NULL) {
        if(Screen != NULL) {
            AG_SurfaceBlit(r, NULL, Screen, X * CHRW, Y * CHRH);
        }
        AG_SurfaceFree(r);
    }

}
void DumpObject::InitFont(void)
{
    char c[2];
    AG_Surface *dummy;

    AG_PushTextState();
    pDbgDialogTextFont = AG_TextFontLookup(&DebuggerTextFont[0], DBG_TEXT_PT, 0);
    c[0] = '0';
    c[1] = '\0';
    if(pDbgDialogTextFont != NULL) {
        AG_TextFont(pDbgDialogTextFont);
    }
    AG_TextSize(c ,&CHRW, &CHRH);

    pDbgDialogSymFont = AG_TextFontLookup(DebuggerSymFont, DBG_TEXT_PT, 0);
    AG_PopTextState();
}
示例#3
0
文件: font_selector.c 项目: adsr/agar
static void
UpdatePreview(AG_FontSelector *fs)
{
	AG_Variable *bFont;
	AG_Font **pFont;
	AG_Surface *s;
	
	bFont = AG_GetVariable(fs, "font", &pFont);
	AG_PushTextState();

	if (*pFont != NULL) {
		AG_TextFont(*pFont);
	}
	s = AG_TextRender(_("The Quick Brown Fox Jumps Over The Lazy Dog"));
	if (fs->sPreview == -1) {
		fs->sPreview = AG_WidgetMapSurfaceNODUP(fs, s);
	} else {
		AG_WidgetReplaceSurfaceNODUP(fs, fs->sPreview, s);
	}

	AG_PopTextState();
	AG_UnlockVariable(bFont);
}
示例#4
0
/*
 * This function requests a minimal geometry for displaying the widget.
 * It is expected to return the width and height in pixels into r.
 *
 * Note: Some widgets will provide FooSizeHint() functions to allow the
 * programmer to request an initial size in pixels or some other metric
 * FooSizeHint() typically sets some structure variable, which are then
 * used here.
 */
static void
SizeRequest(void *p, AG_SizeReq *r)
{
	formaText *my = (formaText*)p;

	if (my->mySurface == -1) {
		/*
		 * We can use AG_TextSize() to return the dimensions of rendered
		 * text, without rendering it.
		 */
		AG_TextFont(AG_FetchFont(NULL, 24, 0));
		AG_TextSize("Custom widget!", &r->w, &r->h);

	} else {
		/*
		 * We can use the geometry of the rendered surface. The
		 * AGWIDGET_SURFACE() macro returns the AG_Surface given a
		 * Widget surface handle.
		 */
		r->w = AGWIDGET_SURFACE(my,my->mySurface)->w;
		r->h = AGWIDGET_SURFACE(my,my->mySurface)->h;
		//r->w=(min(r->w,600));
	}
}