Merge branch 'mmozeiko-master'
This commit is contained in:
commit
e8936c8111
|
@ -225,7 +225,6 @@ GdipCreateFont(
|
||||||
INT style,
|
INT style,
|
||||||
Unit unit,
|
Unit unit,
|
||||||
GpFont **font
|
GpFont **font
|
||||||
struct nk_user_font handle;
|
|
||||||
);
|
);
|
||||||
|
|
||||||
GpStatus WINGDIPAPI
|
GpStatus WINGDIPAPI
|
||||||
|
@ -343,6 +342,11 @@ GdipMeasureString(
|
||||||
GpStatus WINGDIPAPI
|
GpStatus WINGDIPAPI
|
||||||
GdipSetTextRenderingHint(GpGraphics *graphics, TextRenderingHint mode);
|
GdipSetTextRenderingHint(GpGraphics *graphics, TextRenderingHint mode);
|
||||||
|
|
||||||
|
struct GdipFont
|
||||||
|
{
|
||||||
|
struct nk_user_font nk;
|
||||||
|
GpFont* handle;
|
||||||
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
ULONG_PTR token;
|
ULONG_PTR token;
|
||||||
|
@ -531,7 +535,7 @@ nk_gdip_draw_text(short x, short y, unsigned short w, unsigned short h,
|
||||||
GdipSetSolidFillColor(gdip.brush, convert_color(cbg));
|
GdipSetSolidFillColor(gdip.brush, convert_color(cbg));
|
||||||
GdipFillRectangleI(gdip.memory, gdip.brush, x, y, w, h);
|
GdipFillRectangleI(gdip.memory, gdip.brush, x, y, w, h);
|
||||||
GdipSetSolidFillColor(gdip.brush, convert_color(cfg));
|
GdipSetSolidFillColor(gdip.brush, convert_color(cfg));
|
||||||
GdipDrawString(gdip.memory, wstr, wsize, (GpFont *)font, &layout, gdip.format, gdip.brush);
|
GdipDrawString(gdip.memory, wstr, wsize, font->handle, &layout, gdip.format, gdip.brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -549,7 +553,7 @@ nk_gdip_blit(GpGraphics *graphics)
|
||||||
GdipFont*
|
GdipFont*
|
||||||
nk_gdipfont_create(const char *name, int size)
|
nk_gdipfont_create(const char *name, int size)
|
||||||
{
|
{
|
||||||
GpFont* font;
|
GdipFont *font = (GdipFont*)calloc(1, sizeof(GdipFont));
|
||||||
GpFontFamily *family;
|
GpFontFamily *family;
|
||||||
|
|
||||||
int wsize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0);
|
int wsize = MultiByteToWideChar(CP_UTF8, 0, name, -1, NULL, 0);
|
||||||
|
@ -558,16 +562,16 @@ nk_gdipfont_create(const char *name, int size)
|
||||||
wname[wsize] = 0;
|
wname[wsize] = 0;
|
||||||
|
|
||||||
GdipCreateFontFamilyFromName(wname, NULL, &family);
|
GdipCreateFontFamilyFromName(wname, NULL, &family);
|
||||||
GdipCreateFont(family, (REAL)size, FontStyleRegular, UnitPixel, &font);
|
GdipCreateFont(family, (REAL)size, FontStyleRegular, UnitPixel, &font->handle);
|
||||||
GdipDeleteFontFamily(family);
|
GdipDeleteFontFamily(family);
|
||||||
|
|
||||||
return (GdipFont *)font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float
|
static float
|
||||||
nk_gdipfont_get_text_width(nk_handle handle, float height, const char *text, int len)
|
nk_gdipfont_get_text_width(nk_handle handle, float height, const char *text, int len)
|
||||||
{
|
{
|
||||||
GpFont *font = (GpFont *)handle.ptr;
|
GdipFont *font = (GdipFont *)handle.ptr;
|
||||||
RectF layout = { 0.0f, 0.0f, 65536.0f, 65536.0f };
|
RectF layout = { 0.0f, 0.0f, 65536.0f, 65536.0f };
|
||||||
RectF bbox;
|
RectF bbox;
|
||||||
int wsize;
|
int wsize;
|
||||||
|
@ -580,7 +584,7 @@ nk_gdipfont_get_text_width(nk_handle handle, float height, const char *text, int
|
||||||
wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
|
wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
|
||||||
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
|
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
|
||||||
|
|
||||||
GdipMeasureString(gdip.memory, wstr, wsize, font, &layout, gdip.format, &bbox, NULL, NULL);
|
GdipMeasureString(gdip.memory, wstr, wsize, font->handle, &layout, gdip.format, &bbox, NULL, NULL);
|
||||||
return bbox.Width;
|
return bbox.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +592,8 @@ void
|
||||||
nk_gdipfont_del(GdipFont *font)
|
nk_gdipfont_del(GdipFont *font)
|
||||||
{
|
{
|
||||||
if(!font) return;
|
if(!font) return;
|
||||||
GdipDeleteFont((GpFont *)font);
|
GdipDeleteFont(font->handle);
|
||||||
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -706,9 +711,9 @@ nk_gdip_init(HWND hwnd, unsigned int width, unsigned int height)
|
||||||
NK_API void
|
NK_API void
|
||||||
nk_gdip_set_font(GdipFont *gdipfont)
|
nk_gdip_set_font(GdipFont *gdipfont)
|
||||||
{
|
{
|
||||||
struct nk_user_font *font = &gdipfont->handle;
|
struct nk_user_font *font = &gdipfont->nk;
|
||||||
font->userdata = nk_handle_ptr(gdipfont);
|
font->userdata = nk_handle_ptr(gdipfont);
|
||||||
GdipGetFontSize((GpFont *)gdipfont, &font->height);
|
GdipGetFontSize(gdipfont->handle, &font->height);
|
||||||
font->width = nk_gdipfont_get_text_width;
|
font->width = nk_gdipfont_get_text_width;
|
||||||
nk_style_set_font(&gdip.ctx, font);
|
nk_style_set_font(&gdip.ctx, font);
|
||||||
}
|
}
|
||||||
|
@ -796,7 +801,7 @@ nk_gdip_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case VK_END:
|
case VK_END:
|
||||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_END, down);
|
nk_input_key(&gdip.ctx, NK_KEY_TEXT_END, down);
|
||||||
nk_input_key(&gdip.ctx, NK_KEY_SCROLL_END, down);
|
nk_input_key(&gdip.ctx, NK_KEY_SCROLL_END, down);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue