mirror of
https://github.com/Immediate-Mode-UI/Nuklear.git
synced 2026-11-30 16:48:10 +01:00
Add Numpad Enter support for windows backends...
This commit is contained in:
@@ -232,6 +232,7 @@ nk_d3d11_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&d3d11.ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -364,6 +364,7 @@ nk_d3d12_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&d3d12.ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -292,6 +292,7 @@ nk_d3d9_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&d3d9.ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
|
||||
+16
-15
@@ -76,7 +76,7 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
|
||||
image->region[1] = 0;
|
||||
image->region[2] = width;
|
||||
image->region[3] = height;
|
||||
|
||||
|
||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.bmiHeader.biWidth = width;
|
||||
bi.bmiHeader.biHeight = height;
|
||||
@@ -84,9 +84,9 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
|
||||
bi.bmiHeader.biBitCount = 24;
|
||||
bi.bmiHeader.biCompression = BI_RGB;
|
||||
bi.bmiHeader.biSizeImage = row * height;
|
||||
|
||||
|
||||
hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
|
||||
|
||||
|
||||
pb = lpBuf + row * height;
|
||||
for (v = 0; v < height; v++)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
|
||||
pb[i + 2] = src[2];
|
||||
src += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
SetDIBits(NULL, hbm, 0, height, lpBuf, &bi, DIB_RGB_COLORS);
|
||||
image->handle.ptr = hbm;
|
||||
}
|
||||
@@ -122,10 +122,10 @@ nk_gdi_draw_image(short x, short y, unsigned short w, unsigned short h,
|
||||
HBITMAP hbm = (HBITMAP)img.handle.ptr;
|
||||
HDC hDCBits;
|
||||
BITMAP bitmap;
|
||||
|
||||
|
||||
if (!gdi.memory_dc || !hbm)
|
||||
return;
|
||||
|
||||
|
||||
hDCBits = CreateCompatibleDC(gdi.memory_dc);
|
||||
GetObject(hbm, sizeof(BITMAP), (LPSTR)&bitmap);
|
||||
SelectObject(hDCBits, hbm);
|
||||
@@ -192,7 +192,7 @@ nk_gdi_stroke_rect(HDC dc, short x, short y, unsigned short w,
|
||||
}
|
||||
SelectObject(dc, br);
|
||||
|
||||
if (pen) {
|
||||
if (pen) {
|
||||
SelectObject(dc, GetStockObject(DC_PEN));
|
||||
DeleteObject(pen);
|
||||
}
|
||||
@@ -470,7 +470,7 @@ nk_gdi_stroke_circle(HDC dc, short x, short y, unsigned short w,
|
||||
pen = CreatePen(PS_SOLID, line_thickness, color);
|
||||
SelectObject(dc, pen);
|
||||
}
|
||||
|
||||
|
||||
HGDIOBJ br = SelectObject(dc, GetStockObject(NULL_BRUSH));
|
||||
SetDCBrushColor(dc, OPAQUE);
|
||||
Ellipse(dc, x, y, x + w, y + h);
|
||||
@@ -524,7 +524,7 @@ nk_gdi_draw_text(HDC dc, short x, short y, unsigned short w, unsigned short h,
|
||||
wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
|
||||
wstr = (WCHAR*)_alloca(wsize * sizeof(wchar_t));
|
||||
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
|
||||
|
||||
|
||||
SetBkMode(dc, TRANSPARENT); /* Transparent Text Background */
|
||||
SetBkColor(dc, convert_color(cbg));
|
||||
SetTextColor(dc, convert_color(cfg));
|
||||
@@ -599,14 +599,14 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
|
||||
(void)usr;
|
||||
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL))
|
||||
{
|
||||
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
|
||||
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
|
||||
if (mem)
|
||||
{
|
||||
SIZE_T size = GlobalSize(mem) - 1;
|
||||
if (size)
|
||||
{
|
||||
LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
|
||||
if (wstr)
|
||||
if (wstr)
|
||||
{
|
||||
int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)(size / sizeof(wchar_t)), NULL, 0, NULL, NULL);
|
||||
if (utf8size)
|
||||
@@ -619,7 +619,7 @@ nk_gdi_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
|
||||
free(utf8);
|
||||
}
|
||||
}
|
||||
GlobalUnlock(mem);
|
||||
GlobalUnlock(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -643,9 +643,9 @@ nk_gdi_clipboard_copy(nk_handle usr, const char *text, int len)
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, text, len, wstr, wsize);
|
||||
wstr[wsize] = 0;
|
||||
GlobalUnlock(mem);
|
||||
GlobalUnlock(mem);
|
||||
|
||||
SetClipboardData(CF_UNICODETEXT, mem);
|
||||
SetClipboardData(CF_UNICODETEXT, mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -734,6 +734,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&gdi.ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
@@ -776,7 +777,7 @@ nk_gdi_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
case VK_PRIOR:
|
||||
nk_input_key(&gdi.ctx, NK_KEY_SCROLL_UP, down);
|
||||
return 1;
|
||||
|
||||
|
||||
case 'A':
|
||||
if (ctrl) {
|
||||
nk_input_key(&gdi.ctx, NK_KEY_TEXT_SELECT_ALL, down);
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
* Nuklear - 1.32.0 - public domain
|
||||
* no warrenty implied; use at your own risk.
|
||||
* authored from 2015-2016 by Micha Mettke
|
||||
*
|
||||
*
|
||||
* Modified GDI backend 2022
|
||||
* Now based on a context that is required for each API function call.
|
||||
* Removes the global state --> you can have multiple windows :-)
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* ==============================================================
|
||||
@@ -698,6 +698,7 @@ nk_gdi_handle_event(nk_gdi_ctx gdi, HWND wnd, UINT msg, WPARAM wparam, LPARAM lp
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&gdi->ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
|
||||
+17
-16
@@ -92,7 +92,7 @@ typedef enum {
|
||||
StringFormatFlagsMeasureTrailingSpaces = 0x00000800,
|
||||
StringFormatFlagsNoWrap = 0x00001000,
|
||||
StringFormatFlagsLineLimit = 0x00002000,
|
||||
StringFormatFlagsNoClip = 0x00004000
|
||||
StringFormatFlagsNoClip = 0x00004000
|
||||
} StringFormatFlags;
|
||||
|
||||
typedef enum
|
||||
@@ -272,25 +272,25 @@ GdipSetStringFormatFlags(GpStringFormat *format, INT flags);
|
||||
GpStatus WINGDIPAPI
|
||||
GdipDeleteStringFormat(GpStringFormat *format);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
|
||||
GpStatus WINGDIPAPI
|
||||
GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
|
||||
GDIPCONST void* memory, INT length);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GdipPrivateAddFontFile(GpFontCollection* fontCollection,
|
||||
GpStatus WINGDIPAPI
|
||||
GdipPrivateAddFontFile(GpFontCollection* fontCollection,
|
||||
GDIPCONST WCHAR* filename);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GpStatus WINGDIPAPI
|
||||
GdipNewPrivateFontCollection(GpFontCollection** fontCollection);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GpStatus WINGDIPAPI
|
||||
GdipDeletePrivateFontCollection(GpFontCollection** fontCollection);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection,
|
||||
GpStatus WINGDIPAPI
|
||||
GdipGetFontCollectionFamilyList(GpFontCollection* fontCollection,
|
||||
INT numSought, GpFontFamily* gpfamilies[], INT* numFound);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GpStatus WINGDIPAPI
|
||||
GdipGetFontCollectionFamilyCount(GpFontCollection* fontCollection, INT* numFound);
|
||||
|
||||
|
||||
@@ -374,8 +374,8 @@ GdipGraphicsClear(GpGraphics *graphics, ARGB color);
|
||||
GpStatus WINGDIPAPI
|
||||
GdipDrawImageI(GpGraphics *graphics, GpImage *image, INT x, INT y);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y,
|
||||
GpStatus WINGDIPAPI
|
||||
GdipDrawImageRectI(GpGraphics *graphics, GpImage *image, INT x, INT y,
|
||||
INT width, INT height);
|
||||
|
||||
GpStatus WINGDIPAPI
|
||||
@@ -673,7 +673,7 @@ nk_gdip_load_image_from_memory(const void *membuf, nk_uint membufSize)
|
||||
IStream *stream = SHCreateMemStream((const BYTE*)membuf, membufSize);
|
||||
if (!stream)
|
||||
return nk_image_id(0);
|
||||
|
||||
|
||||
status = GdipLoadImageFromStream(stream, &image);
|
||||
stream->lpVtbl->Release(stream);
|
||||
|
||||
@@ -709,7 +709,7 @@ nk_gdipfont_create(const char *name, int size)
|
||||
return font;
|
||||
}
|
||||
|
||||
GpFontCollection*
|
||||
GpFontCollection*
|
||||
nk_gdip_getCurFontCollection(){
|
||||
return gdip.fontCollection[gdip.curFontCollection];
|
||||
}
|
||||
@@ -744,7 +744,7 @@ nk_gdipfont_create_from_file(const WCHAR* filename, int size)
|
||||
{
|
||||
if( !nk_gdip_getCurFontCollection() )
|
||||
if( GdipNewPrivateFontCollection(&gdip.fontCollection[gdip.curFontCollection]) ) return NULL;
|
||||
if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;
|
||||
if( GdipPrivateAddFontFile(nk_gdip_getCurFontCollection(), filename) ) return NULL;
|
||||
return nk_gdipfont_create_from_collection(size);
|
||||
}
|
||||
|
||||
@@ -849,7 +849,7 @@ nk_gdip_init(HWND hwnd, unsigned int width, unsigned int height)
|
||||
GdipCreatePen1(0, 1.0f, UnitPixel, &gdip.pen);
|
||||
GdipCreateSolidFill(0, &gdip.brush);
|
||||
GdipStringFormatGetGenericTypographic(&gdip.format);
|
||||
GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox |
|
||||
GdipSetStringFormatFlags(gdip.format, StringFormatFlagsNoFitBlackBox |
|
||||
StringFormatFlagsMeasureTrailingSpaces | StringFormatFlagsNoWrap |
|
||||
StringFormatFlagsNoClip);
|
||||
|
||||
@@ -924,6 +924,7 @@ nk_gdip_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
||||
return 1;
|
||||
|
||||
case VK_RETURN:
|
||||
case VK_SEPARATOR:
|
||||
nk_input_key(&gdip.ctx, NK_KEY_ENTER, down);
|
||||
return 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user