Fixed the other compiler and linker errors. We have a build! But does it work? If it does it's time to really tune this rewrite down.
This commit is contained in:
parent
c53e1c0b7d
commit
d258ac1d1d
|
@ -79,7 +79,6 @@ ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor)
|
||||||
|
|
||||||
void unregisterArea(void)
|
void unregisterArea(void)
|
||||||
{
|
{
|
||||||
unregisterAreaFilter();
|
|
||||||
if (UnregisterClassW(areaClass, hInstance) == 0)
|
if (UnregisterClassW(areaClass, hInstance) == 0)
|
||||||
logLastError(L"error unregistering uiArea window class");
|
logLastError(L"error unregistering uiArea window class");
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ extern void areaUpdateScroll(uiArea *a);
|
||||||
|
|
||||||
// areaevents.cpp
|
// areaevents.cpp
|
||||||
extern BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
extern BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
||||||
extern void unregisterAreaFilter(void);
|
|
||||||
|
|
||||||
// areautil.cpp
|
// areautil.cpp
|
||||||
extern void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *height);
|
extern void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *height);
|
||||||
|
|
|
@ -395,7 +395,7 @@ BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *l
|
||||||
|
|
||||||
// TODO affect visibility properly
|
// TODO affect visibility properly
|
||||||
// TODO what did this mean
|
// TODO what did this mean
|
||||||
static BOOL areaFilter(MSG *msg)
|
BOOL areaFilter(MSG *msg)
|
||||||
{
|
{
|
||||||
LRESULT handled;
|
LRESULT handled;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
// 25 february 2015
|
// 25 february 2015
|
||||||
#include "uipriv_windows.hpp"
|
#include "uipriv_windows.hpp"
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
void complain(const char *format, ...)
|
||||||
|
{
|
||||||
|
OutputDebugStringA(format);
|
||||||
|
DebugBreak();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO disable logging and stopping on no-debug builds
|
// TODO disable logging and stopping on no-debug builds
|
||||||
|
|
||||||
// TODO are the newlines needed?
|
// TODO are the newlines needed?
|
||||||
|
|
|
@ -9,15 +9,15 @@ static HBRUSH parentBrush = NULL;
|
||||||
static HWND parentWithBackground(HWND hwnd)
|
static HWND parentWithBackground(HWND hwnd)
|
||||||
{
|
{
|
||||||
HWND parent;
|
HWND parent;
|
||||||
int class;
|
int cls;
|
||||||
|
|
||||||
parent = hwnd;
|
parent = hwnd;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
parent = parentOf(parent);
|
parent = parentOf(parent);
|
||||||
// skip groupboxes; they're (supposed to be) transparent
|
// skip groupboxes; they're (supposed to be) transparent
|
||||||
// skip uiContainers; they don't draw anything
|
// skip uiContainers; they don't draw anything
|
||||||
class = windowClassOf(parent, L"button", containerClass, NULL);
|
cls = windowClassOf(parent, L"button", containerClass, NULL);
|
||||||
if (class != 0 && class != 1)
|
if (cls != 0 && cls != 1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return parent;
|
return parent;
|
||||||
|
@ -41,7 +41,7 @@ static HRESULT parentDraw(HDC dc, HWND parent, struct parentDraw *pd)
|
||||||
pd->bitmap = CreateCompatibleBitmap(dc, r.right - r.left, r.bottom - r.top);
|
pd->bitmap = CreateCompatibleBitmap(dc, r.right - r.left, r.bottom - r.top);
|
||||||
if (pd->bitmap == NULL)
|
if (pd->bitmap == NULL)
|
||||||
return logLastError(L"error creating compatible bitmap");
|
return logLastError(L"error creating compatible bitmap");
|
||||||
pd->prevbitmap = SelectObject(pd->cdc, pd->bitmap);
|
pd->prevbitmap = (HBITMAP) SelectObject(pd->cdc, pd->bitmap);
|
||||||
if (pd->prevbitmap == NULL)
|
if (pd->prevbitmap == NULL)
|
||||||
return logLastError(L"error selecting bitmap into compatible DC");
|
return logLastError(L"error selecting bitmap into compatible DC");
|
||||||
SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) (pd->cdc), PRF_CLIENT);
|
SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) (pd->cdc), PRF_CLIENT);
|
||||||
|
@ -52,7 +52,7 @@ static void endParentDraw(struct parentDraw *pd)
|
||||||
{
|
{
|
||||||
// continue in case of any error
|
// continue in case of any error
|
||||||
if (pd->prevbitmap != NULL)
|
if (pd->prevbitmap != NULL)
|
||||||
if (SelectObject(pd->cdc, pd->prevbitmap) != pd->bitmap)
|
if (((HBITMAP) SelectObject(pd->cdc, pd->prevbitmap)) != pd->bitmap)
|
||||||
logLastError(L"error selecting previous bitmap back into compatible DC");
|
logLastError(L"error selecting previous bitmap back into compatible DC");
|
||||||
if (pd->bitmap != NULL)
|
if (pd->bitmap != NULL)
|
||||||
if (DeleteObject(pd->bitmap) == 0)
|
if (DeleteObject(pd->bitmap) == 0)
|
||||||
|
@ -69,6 +69,7 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
|
||||||
RECT hwndScreenRect;
|
RECT hwndScreenRect;
|
||||||
struct parentDraw pd;
|
struct parentDraw pd;
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
parent = parentWithBackground(hwnd);
|
parent = parentWithBackground(hwnd);
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect)
|
||||||
parent = parentWithBackground(hwnd);
|
parent = parentWithBackground(hwnd);
|
||||||
hr = parentDraw(dc, parent, &pd);
|
hr = parentDraw(dc, parent, &pd);
|
||||||
if (hr != S_OK) // we couldn't get it; draw nothing
|
if (hr != S_OK) // we couldn't get it; draw nothing
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
paintRectParent = *paintRect;
|
paintRectParent = *paintRect;
|
||||||
mapWindowRect(hwnd, parent, &paintRectParent);
|
mapWindowRect(hwnd, parent, &paintRectParent);
|
||||||
|
|
|
@ -27,11 +27,10 @@ static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult
|
||||||
uiRadioButtons *r = uiRadioButtons(c);
|
uiRadioButtons *r = uiRadioButtons(c);
|
||||||
WPARAM check;
|
WPARAM check;
|
||||||
uintmax_t i;
|
uintmax_t i;
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
if (code != BN_CLICKED)
|
if (code != BN_CLICKED)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for (hwnd : *(r->hwnds)) {
|
for (const HWND &hwnd : *(r->hwnds)) {
|
||||||
check = BST_UNCHECKED;
|
check = BST_UNCHECKED;
|
||||||
if (clicked == hwnd)
|
if (clicked == hwnd)
|
||||||
check = BST_CHECKED;
|
check = BST_CHECKED;
|
||||||
|
@ -43,9 +42,7 @@ static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult
|
||||||
|
|
||||||
static void onDestroy(uiRadioButtons *r)
|
static void onDestroy(uiRadioButtons *r)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
for (const HWND &hwnd : *(r->hwnds)) {
|
||||||
|
|
||||||
for (hwnd : *(r->hwnds)) {
|
|
||||||
uiWindowsUnregisterWM_COMMANDHandler(hwnd);
|
uiWindowsUnregisterWM_COMMANDHandler(hwnd);
|
||||||
uiWindowsEnsureDestroyWindow(hwnd);
|
uiWindowsEnsureDestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +66,7 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width
|
||||||
maxwid = wid;
|
maxwid = wid;
|
||||||
}
|
}
|
||||||
*width = uiWindowsDlgUnitsToX(radiobuttonXFromLeftOfBoxToLeftOfLabel, d->BaseX) + maxwid;
|
*width = uiWindowsDlgUnitsToX(radiobuttonXFromLeftOfBoxToLeftOfLabel, d->BaseX) + maxwid;
|
||||||
*height = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY) * r->hwnds->len;
|
*height = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY) * r->hwnds->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height)
|
||||||
|
@ -78,7 +75,6 @@ static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, in
|
||||||
uiWindowsSizing *d;
|
uiWindowsSizing *d;
|
||||||
intmax_t height1;
|
intmax_t height1;
|
||||||
intmax_t h;
|
intmax_t h;
|
||||||
HWND hwnd;
|
|
||||||
|
|
||||||
uiWindowsEnsureMoveWindowDuringResize(r->hwnd, x, y, width, height);
|
uiWindowsEnsureMoveWindowDuringResize(r->hwnd, x, y, width, height);
|
||||||
|
|
||||||
|
@ -87,7 +83,7 @@ static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, in
|
||||||
d = uiWindowsNewSizing(r->hwnd);
|
d = uiWindowsNewSizing(r->hwnd);
|
||||||
height1 = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY);
|
height1 = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY);
|
||||||
uiWindowsFreeSizing(d);
|
uiWindowsFreeSizing(d);
|
||||||
for (hwnd : *(r->hwnds)) {
|
for (const HWND &hwnd : *(r->hwnds)) {
|
||||||
h = height1;
|
h = height1;
|
||||||
if (h > height) // clip to height
|
if (h > height) // clip to height
|
||||||
h = height;
|
h = height;
|
||||||
|
@ -105,13 +101,12 @@ static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, in
|
||||||
|
|
||||||
static void redoControlIDsZOrder(uiRadioButtons *r)
|
static void redoControlIDsZOrder(uiRadioButtons *r)
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
|
||||||
LONG_PTR controlID;
|
LONG_PTR controlID;
|
||||||
HWND insertAfter;
|
HWND insertAfter;
|
||||||
|
|
||||||
controlID = 100;
|
controlID = 100;
|
||||||
insertAfter = NULL;
|
insertAfter = NULL;
|
||||||
for (hwnd : *(r->hwnds)) {
|
for (const HWND &hwnd : *(r->hwnds)) {
|
||||||
uiWindowsEnsureAssignControlIDZOrder(hwnd, controlID, insertAfter);
|
uiWindowsEnsureAssignControlIDZOrder(hwnd, controlID, insertAfter);
|
||||||
controlID++;
|
controlID++;
|
||||||
insertAfter = hwnd;
|
insertAfter = hwnd;
|
||||||
|
|
|
@ -67,7 +67,7 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd)
|
||||||
goto noTextOrError;
|
goto noTextOrError;
|
||||||
}
|
}
|
||||||
if (GetTextExtentPoint32W(dc, text, len, &size) == 0) {
|
if (GetTextExtentPoint32W(dc, text, len, &size) == 0) {
|
||||||
logLastError("error getting text extent point");
|
logLastError(L"error getting text extent point");
|
||||||
// continue anyway, assuming size is 0
|
// continue anyway, assuming size is 0
|
||||||
size.cx = 0;
|
size.cx = 0;
|
||||||
size.cy = 0;
|
size.cy = 0;
|
||||||
|
|
|
@ -62,7 +62,7 @@ WCHAR *utf16dup(const WCHAR *orig)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if recursing is TRUE, do NOT recursively call wstrf() in logHRESULT()
|
// if recursing is TRUE, do NOT recursively call wstrf() in logHRESULT()
|
||||||
static WCHAR *strfcore(BOOL recursing, WCHAR *format, va_list ap)
|
static WCHAR *strfcore(BOOL recursing, const WCHAR *format, va_list ap)
|
||||||
{
|
{
|
||||||
va_list ap2;
|
va_list ap2;
|
||||||
WCHAR *buf;
|
WCHAR *buf;
|
||||||
|
@ -73,13 +73,13 @@ static WCHAR *strfcore(BOOL recursing, WCHAR *format, va_list ap)
|
||||||
return emptyUTF16();
|
return emptyUTF16();
|
||||||
|
|
||||||
va_copy(ap2, ap);
|
va_copy(ap2, ap);
|
||||||
hr = SafeCchVPrintfEx(NULL, 0,
|
hr = StringCchVPrintfExW(NULL, 0,
|
||||||
NULL, &n,
|
NULL, &n,
|
||||||
STRSAFE_IGNORE_NULLS,
|
STRSAFE_IGNORE_NULLS,
|
||||||
format, ap2);
|
format, ap2);
|
||||||
va_end(ap2);
|
va_end(ap2);
|
||||||
if (hr != S_OK && hr != STRSAFE_E_INSUFFICIENT_BUFFER) {
|
if (hr != S_OK && hr != STRSAFE_E_INSUFFICIENT_BUFFER) {
|
||||||
if (!failing)
|
if (!recursing)
|
||||||
logHRESULT(L"error determining needed buffer size", hr);
|
logHRESULT(L"error determining needed buffer size", hr);
|
||||||
return emptyUTF16();
|
return emptyUTF16();
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ static WCHAR *strfcore(BOOL recursing, WCHAR *format, va_list ap)
|
||||||
// n includes the terminating L'\0'
|
// n includes the terminating L'\0'
|
||||||
buf = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
|
buf = (WCHAR *) uiAlloc(n * sizeof (WCHAR), "WCHAR[]");
|
||||||
|
|
||||||
hr = SafeCchVPrintfEx(buf, n, // TODO what about this?
|
hr = StringCchVPrintfExW(buf, n, // TODO what about this?
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
0,
|
0,
|
||||||
format, ap);
|
format, ap);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
if (!failing)
|
if (!recursing)
|
||||||
logLastError(L"error formatting string", hr);
|
logLastError(L"error formatting string", hr);
|
||||||
// and return an empty string
|
// and return an empty string
|
||||||
*buf = L'\0';
|
*buf = L'\0';
|
||||||
|
@ -117,7 +117,7 @@ WCHAR *vstrf(const WCHAR *format, va_list ap)
|
||||||
return strfcore(FALSE, format, ap);
|
return strfcore(FALSE, format, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
WCHAR *debugstrf(const WCHAR *format, ..)
|
WCHAR *debugstrf(const WCHAR *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
WCHAR *str;
|
WCHAR *str;
|
||||||
|
@ -141,7 +141,7 @@ char *LFtoCRLF(const char *lfonly)
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
len = strlen(lfonly);
|
len = strlen(lfonly);
|
||||||
crlf = (char *) uiAlloc((only * 2 + 1) * sizeof (char), "char[]");
|
crlf = (char *) uiAlloc((len * 2 + 1) * sizeof (char), "char[]");
|
||||||
out = crlf;
|
out = crlf;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (*lfonly == '\n')
|
if (*lfonly == '\n')
|
||||||
|
@ -160,7 +160,7 @@ void CRLFtoLF(char *s)
|
||||||
// be sure to preserve \rs that are genuinely there
|
// be sure to preserve \rs that are genuinely there
|
||||||
if (*s == '\r' && *(s + 1) == '\n')
|
if (*s == '\r' && *(s + 1) == '\n')
|
||||||
continue;
|
continue;
|
||||||
*t++ = s;
|
*t++ = *s;
|
||||||
}
|
}
|
||||||
*t = '\0';
|
*t = '\0';
|
||||||
// TODO null pad t to s?
|
// TODO null pad t to s?
|
||||||
|
|
|
@ -29,10 +29,12 @@
|
||||||
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
|
||||||
#ifndef RC_INVOKED
|
#ifndef RC_INVOKED
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <uxtheme.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
#include <d2d1.h>
|
#include <d2d1.h>
|
||||||
#include <dwrite.h>
|
#include <dwrite.h>
|
||||||
|
#include <strsafe.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -106,7 +106,7 @@ void clientSizeToWindowSize(HWND hwnd, intmax_t *width, intmax_t *height, BOOL h
|
||||||
window.right = *width;
|
window.right = *width;
|
||||||
window.bottom = *height;
|
window.bottom = *height;
|
||||||
if (AdjustWindowRectEx(&window, getStyle(hwnd), hasMenubar, getExStyle(hwnd)) == 0) {
|
if (AdjustWindowRectEx(&window, getStyle(hwnd), hasMenubar, getExStyle(hwnd)) == 0) {
|
||||||
logLastError("error getting adjusted window rect");
|
logLastError(L"error getting adjusted window rect");
|
||||||
// on error, don't give up; the window will be smaller but whatever
|
// on error, don't give up; the window will be smaller but whatever
|
||||||
window.left = 0;
|
window.left = 0;
|
||||||
window.top = 0;
|
window.top = 0;
|
||||||
|
|
Loading…
Reference in New Issue