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(); }
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); }
static void RenderText(VG_Text *vt, char *sIn, VG_View *vv) { char sSubst[VG_TEXT_MAX], *s; VG_Vector v1, v2, vMid; int x, y; int su; if (vt->vsObj != NULL) { AG_VariableSubst(vt->vsObj, sIn, sSubst, sizeof(sSubst)); s = sSubst; } else { s = sIn; } AG_PushTextState(); if (vt->fontFace[0] != '\0' && ((agGUI && vt->fontSize != (int)agDefaultFont->spec.size) || (agGUI && vt->fontFlags != agDefaultFont->flags))) { AG_TextFontLookup(vt->fontFace, vt->fontSize, vt->fontFlags); } AG_TextColor(VG_MapColorRGB(VGNODE(vt)->color)); v1 = VG_Pos(vt->p1); v2 = VG_Pos(vt->p2); vMid.x = v1.x + (v2.x - v1.x)/2.0f; vMid.y = v1.y + (v2.y - v1.y)/2.0f; VG_GetViewCoords(vv, vMid, &x, &y); if ((su = AG_TextCacheGet(vv->tCache, s)) != -1) { VG_DrawSurface(vv, x, y, VG_Degrees(VG_Atan2(v1.y-v2.y, v1.x-v2.x)), su); } AG_PopTextState(); }
static void Draw(void *obj) { AG_HSVPal *pal = obj; float cur_h, cur_s, cur_v; Uint8 r, g, b, a; int x, y; if (pal->surface == NULL) { if ((pal->surface = AG_SurfaceStdGL(WIDTH(pal), HEIGHT(pal))) == NULL) { return; } pal->surfaceId = AG_WidgetMapSurface(pal, pal->surface); } if (pal->flags & AG_HSVPAL_DIRTY) { pal->flags &= ~(AG_HSVPAL_DIRTY); RenderPalette(pal); AG_WidgetUpdateSurface(pal, pal->surfaceId); } cur_h = (AG_GetFloat(pal, "hue") / 360.0) * 2*AG_PI; cur_s = AG_GetFloat(pal, "saturation"); cur_v = AG_GetFloat(pal, "value"); a = (Uint8)(AG_GetFloat(pal, "alpha")*255); AG_WidgetBlitFrom(pal, pal, pal->surfaceId, NULL, 0, 0); /* Indicate the current selection. */ AG_DrawCircle(pal, pal->circle.x + (pal->circle.rin + pal->circle.width/2)*Cos(cur_h), pal->circle.y + (pal->circle.rin + pal->circle.width/2)*Sin(cur_h), pal->selcircle_r, AG_ColorRGB(0,0,0)); /* The rendering routine uses (v = 1 - x/h), so (x = -v*h + h). */ y = (int)((1.0 - cur_s) * (float)pal->triangle.h); x = (int)(-(cur_v*(float)pal->triangle.h - (float)pal->triangle.h)); if (x < 0) { x = 0; } if (x > y) { x = y; } AG_DrawCircle(pal, pal->triangle.x + x - y/2, pal->triangle.y + y, pal->selcircle_r, AG_ColorRGB(0,0,0)); x = a*pal->rAlpha.w/255; if (x > pal->rAlpha.w-3) { x = pal->rAlpha.w-3; } AG_HSV2RGB((cur_h*360.0)/(2*AG_PI), cur_s, cur_v, &r, &g, &b); /* Draw the color preview. */ if (!(pal->flags & AG_HSVPAL_NOPREVIEW)) { AG_DrawRectFilled(pal, AG_RECT(pal->rAlpha.x, pal->rAlpha.y, pal->rAlpha.w, 8), AG_ColorRGB(r,g,b)); } /* Draw the transparency color preview. */ if (!(pal->flags & AG_HSVPAL_NOALPHA)) { AG_DrawLineV(pal, pal->rAlpha.x + x, pal->rAlpha.y + 1, pal->rAlpha.y + pal->rAlpha.h, AG_ColorRGBA(0,0,0,0)); AG_DrawLineV(pal, pal->rAlpha.x + x + 1, pal->rAlpha.y + 1, pal->rAlpha.y + pal->rAlpha.h, AG_ColorRGBA(240,240,240,0)); AG_DrawLineV(pal, pal->rAlpha.x + x + 2, pal->rAlpha.y + 1, pal->rAlpha.y + pal->rAlpha.h, AG_ColorRGBA(0,0,0,0)); } /* Display RGB/HSV values */ if (pal->flags & (AG_HSVPAL_SHOW_RGB|AG_HSVPAL_SHOW_HSV)) { AG_Surface *s; /* XXX inefficient */ AG_PushTextState(); AG_TextBGColorRGB(0,0,0); AG_TextColorRGB(255,255,255); if ((pal->flags & AG_HSVPAL_SHOW_RGB) && (pal->flags & AG_HSVPAL_SHOW_HSV)) { s = AG_TextRenderf( "RGB: %u,%u,%u\n" "HSV: %.02f,%.02f,%.02f", r, g, b, (cur_h*360.0)/(2.0*AG_PI), cur_s, cur_v); } else if (pal->flags & AG_HSVPAL_SHOW_RGB) { s = AG_TextRenderf("RGB: %u,%u,%u", r, g, b); } else { s = AG_TextRenderf("HSV: %.01f,%.02f,%.02f", (cur_h*360.0)/(2.0*AG_PI), cur_s, cur_v); } AG_WidgetBlit(pal, s, WIDTH(pal)/2 - s->w/2, pal->rAlpha.y + pal->rAlpha.h/2 - s->h/2); AG_SurfaceFree(s); AG_PopTextState(); } }
static void UpdateFaces(AG_Event *event) { AG_Variable *bFont; AG_Font **pFont; AG_FontSelector *fs = AG_SELF(); char fontPath[AG_SEARCHPATH_MAX], *pFontPath = &fontPath[0]; AG_TlistItem *ti; char *s; int i; const int stdSizes[] = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 22,24,26,28,32,48,64 }; const int nStdSizes = sizeof(stdSizes) / sizeof(stdSizes[0]); bFont = AG_GetVariable(fs, "font", &pFont); AG_PushTextState(); fs->flags &= ~(AG_FONTSELECTOR_UPDATE); for (i = 0; i < agBuiltinFontCount; i++) { AG_StaticFont *font = agBuiltinFonts[i]; ti = AG_TlistAdd(fs->tlFaces, NULL, "_%s", font->name); ti->p1 = font; if (*pFont != NULL && strcmp(ti->text, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CopyCfgString("font-path", fontPath, sizeof(fontPath)); while ((s = AG_Strsep(&pFontPath, ":")) != NULL) { AG_Dir *dir; int i; if ((dir = AG_OpenDir(s)) == NULL) { AG_Verbose(_("Ignoring: %s\n"), AG_GetError()); continue; } for (i = 0; i < dir->nents; i++) { char path[AG_FILENAME_MAX]; AG_FileInfo info; char *file = dir->ents[i], *pExt; if (file[0] == '.' || (pExt = strrchr(file, '.')) == NULL) { continue; } if (strcmp(pExt, ".ttf") != 0 && strcmp(pExt, ".TTF") != 0) continue; Strlcpy(path, s, sizeof(path)); Strlcat(path, AG_PATHSEP, sizeof(path)); Strlcat(path, file, sizeof(path)); if (AG_GetFileInfo(path, &info) == -1 || info.type != AG_FILE_REGULAR) { continue; } ti = AG_TlistAddS(fs->tlFaces, NULL, file); if (*pFont != NULL && strcmp(file, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CloseDir(dir); } /* XXX */ for (i = 0; i < nStdSizes; i++) { ti = AG_TlistAdd(fs->tlSizes, NULL, "%d", stdSizes[i]); if (*pFont != NULL && stdSizes[i] == (*pFont)->size) ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Regular")); if (*pFont != NULL && (*pFont)->flags == 0) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Italic")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_ITALIC) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_BOLD) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold Italic")); if (*pFont != NULL && (*pFont)->flags == (AG_FONT_BOLD|AG_FONT_ITALIC)) { ti->selected++; } UpdatePreview(fs); AG_UnlockVariable(bFont); }