diff --git a/ui.h b/ui.h index fed3ab0e..29d9bef6 100644 --- a/ui.h +++ b/ui.h @@ -17,6 +17,10 @@ extern "C" { #define _UI_EXTERN extern #endif +// C++ is really really really really really really dumb about enums, so screw that and just make them anonymous +// This has the advantage of being ABI-able should we ever need an ABI... +#define _UI_ENUM(s) typedef unsigned int s; enum + typedef struct uiInitOptions uiInitOptions; struct uiInitOptions { @@ -308,35 +312,34 @@ typedef struct uiDrawMatrix uiDrawMatrix; typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop; -// ISO C forbids us from forward declaring enums >:( -typedef enum uiDrawBrushType { +_UI_ENUM(uiDrawBrushType) { uiDrawBrushTypeSolid, uiDrawBrushTypeLinearGradient, uiDrawBrushTypeRadialGradient, uiDrawBrushTypeImage, -} uiDrawBrushType; +}; -typedef enum uiDrawLineCap { +_UI_ENUM(uiDrawLineCap) { uiDrawLineCapFlat, uiDrawLineCapRound, uiDrawLineCapSquare, -} uiDrawLineCap; +}; -typedef enum uiDrawLineJoin { +_UI_ENUM(uiDrawLineJoin) { uiDrawLineJoinMiter, uiDrawLineJoinRound, uiDrawLineJoinBevel, -} uiDrawLineJoin; +}; // this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions) // Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value // so we're good to use it too! #define uiDrawDefaultMiterLimit 10.0 -typedef enum uiDrawFillMode { +_UI_ENUM(uiDrawFillMode) { uiDrawFillModeWinding, uiDrawFillModeAlternate, -} uiDrawFillMode; +}; struct uiDrawMatrix { double M11; @@ -458,7 +461,7 @@ typedef struct uiDrawTextFont uiDrawTextFont; typedef struct uiDrawTextFontDescriptor uiDrawTextFontDescriptor; typedef struct uiDrawTextFontMetrics uiDrawTextFontMetrics; -typedef enum uiDrawTextWeight { +_UI_ENUM(uiDrawTextWeight) { uiDrawTextWeightThin, uiDrawTextWeightUltraLight, uiDrawTextWeightLight, @@ -470,15 +473,15 @@ typedef enum uiDrawTextWeight { uiDrawTextWeightUtraBold, uiDrawTextWeightHeavy, uiDrawTextWeightUltraHeavy, -} uiDrawTextWeight; +}; -typedef enum uiDrawTextItalic { +_UI_ENUM(uiDrawTextItalic) { uiDrawTextItalicNormal, uiDrawTextItalicOblique, uiDrawTextItalicItalic, -} uiDrawTextItalic; +}; -typedef enum uiDrawTextStretch { +_UI_ENUM(uiDrawTextStretch) { uiDrawTextStretchUltraCondensed, uiDrawTextStretchExtraCondensed, uiDrawTextStretchCondensed, @@ -488,7 +491,7 @@ typedef enum uiDrawTextStretch { uiDrawTextStretchExpanded, uiDrawTextStretchExtraExpanded, uiDrawTextStretchUltraExpanded, -} uiDrawTextStretch; +}; struct uiDrawTextFontDescriptor { const char *Family; @@ -527,12 +530,12 @@ _UI_EXTERN void uiDrawTextLayoutSetColor(uiDrawTextLayout *layout, intmax_t star _UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, uiDrawTextLayout *layout); -typedef enum uiModifiers { +_UI_ENUM(uiModifiers) { uiModifierCtrl = 1 << 0, uiModifierAlt = 1 << 1, uiModifierShift = 1 << 2, uiModifierSuper = 1 << 3, -} uiModifiers; +}; // TODO document drag captures struct uiAreaMouseEvent { @@ -554,7 +557,7 @@ struct uiAreaMouseEvent { uint64_t Held1To64; }; -typedef enum uiExtKey { +_UI_ENUM(uiExtKey) { uiExtKeyEscape = 1, uiExtKeyInsert, // equivalent to "Help" on Apple keyboards uiExtKeyDelete, @@ -594,7 +597,7 @@ typedef enum uiExtKey { uiExtKeyNSubtract, uiExtKeyNMultiply, uiExtKeyNDivide, -} uiExtKey; +}; struct uiAreaKeyEvent { char Key; diff --git a/windows/box.cpp b/windows/box.cpp index 3d11501d..cdfc06c5 100644 --- a/windows/box.cpp +++ b/windows/box.cpp @@ -124,7 +124,7 @@ static void boxRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t wi intmax_t minimumWidth, minimumHeight; uiWindowsSizing *d; - uiWindowsEnsureMoveWindow(b->hwnd, x, y, width, height); + uiWindowsEnsureMoveWindowDuringResize(b->hwnd, x, y, width, height); if (b->controls->len == 0) return; diff --git a/windows/child.cpp b/windows/child.cpp index 4a5e0c7f..9d7d0b84 100644 --- a/windows/child.cpp +++ b/windows/child.cpp @@ -95,7 +95,7 @@ void childRelayout(struct child *c, intmax_t x, intmax_t y, intmax_t width, intm intmax_t left, top, right, bottom; if (c->tabpage != NULL) { - uiWindowsEnsureMoveWindow(c->tabpage, x, y, width, height); + uiWindowsEnsureMoveWindowDuringResize(c->tabpage, x, y, width, height); x = 0; // and make relative to the client rect of the tab page y = 0; if (c->margined) { diff --git a/windows/container.cpp b/windows/container.cpp index 6db4aea7..89aa70c2 100644 --- a/windows/container.cpp +++ b/windows/container.cpp @@ -60,7 +60,7 @@ ATOM initContainer(HICON hDefaultIcon, HCURSOR hDefaultCursor) void uninitContainer(void) { if (UnregisterClassW(containerClass, hInstance) == 0) - logLastError("error unregistering container window class in uninitContainer()"); + logLastError(L"error unregistering container window class"); } HWND newContainer(void) diff --git a/windows/control.cpp b/windows/control.cpp index 5ed9a036..3a153ee5 100644 --- a/windows/control.cpp +++ b/windows/control.cpp @@ -1,5 +1,5 @@ // 16 august 2015 -#include "uipriv_windows.h" +#include "uipriv_windows.hpp" HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont) { @@ -16,7 +16,7 @@ HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCW 100, 100, utilWindow, NULL, hInstance, lpParam); if (hwnd == NULL) { - logLastError("error creating window"); + logLastError(L"error creating window"); // TODO return a decoy window } if (useStandardControlFont) diff --git a/windows/debug.cpp b/windows/debug.cpp index 7c025152..0091c1a5 100644 --- a/windows/debug.cpp +++ b/windows/debug.cpp @@ -1,5 +1,5 @@ // 25 february 2015 -#include "uipriv_windows.h" +#include "uipriv_windows.hpp" // TODO disable logging and stopping on no-debug builds diff --git a/windows/text.cpp b/windows/text.cpp index 7228e585..785a94a3 100644 --- a/windows/text.cpp +++ b/windows/text.cpp @@ -1,5 +1,5 @@ // 9 april 2015 -#include "uipriv_windows.h" +#include "uipriv_windows.hpp" WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len) { diff --git a/windows/winutil.cpp b/windows/winutil.cpp index 84efc074..52273862 100644 --- a/windows/winutil.cpp +++ b/windows/winutil.cpp @@ -1,5 +1,5 @@ // 6 april 2015 -#include "uipriv_windows.h" +#include "uipriv_windows.hpp" // this is a helper function that takes the logic of determining window classes and puts it all in one place // there are a number of places where we need to know what window class an arbitrary handle has