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:
Pietro Gagliardi 2016-04-24 00:33:42 -04:00
parent c53e1c0b7d
commit d258ac1d1d
10 changed files with 33 additions and 29 deletions

View File

@ -79,7 +79,6 @@ ATOM registerAreaClass(HICON hDefaultIcon, HCURSOR hDefaultCursor)
void unregisterArea(void)
{
unregisterAreaFilter();
if (UnregisterClassW(areaClass, hInstance) == 0)
logLastError(L"error unregistering uiArea window class");
}

View File

@ -38,7 +38,6 @@ extern void areaUpdateScroll(uiArea *a);
// areaevents.cpp
extern BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
extern void unregisterAreaFilter(void);
// areautil.cpp
extern void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *height);

View File

@ -395,7 +395,7 @@ BOOL areaDoEvents(uiArea *a, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *l
// TODO affect visibility properly
// TODO what did this mean
static BOOL areaFilter(MSG *msg)
BOOL areaFilter(MSG *msg)
{
LRESULT handled;

View File

@ -1,6 +1,14 @@
// 25 february 2015
#include "uipriv_windows.hpp"
// TODO
void complain(const char *format, ...)
{
OutputDebugStringA(format);
DebugBreak();
abort();
}
// TODO disable logging and stopping on no-debug builds
// TODO are the newlines needed?

View File

@ -9,15 +9,15 @@ static HBRUSH parentBrush = NULL;
static HWND parentWithBackground(HWND hwnd)
{
HWND parent;
int class;
int cls;
parent = hwnd;
for (;;) {
parent = parentOf(parent);
// skip groupboxes; they're (supposed to be) transparent
// skip uiContainers; they don't draw anything
class = windowClassOf(parent, L"button", containerClass, NULL);
if (class != 0 && class != 1)
cls = windowClassOf(parent, L"button", containerClass, NULL);
if (cls != 0 && cls != 1)
break;
}
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);
if (pd->bitmap == NULL)
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)
return logLastError(L"error selecting bitmap into compatible DC");
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
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");
if (pd->bitmap != NULL)
if (DeleteObject(pd->bitmap) == 0)
@ -69,6 +69,7 @@ static HBRUSH getControlBackgroundBrush(HWND hwnd, HDC dc)
RECT hwndScreenRect;
struct parentDraw pd;
HBRUSH brush;
HRESULT hr;
parent = parentWithBackground(hwnd);
@ -107,7 +108,7 @@ void paintContainerBackground(HWND hwnd, HDC dc, RECT *paintRect)
parent = parentWithBackground(hwnd);
hr = parentDraw(dc, parent, &pd);
if (hr != S_OK) // we couldn't get it; draw nothing
return NULL;
return;
paintRectParent = *paintRect;
mapWindowRect(hwnd, parent, &paintRectParent);

View File

@ -27,11 +27,10 @@ static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult
uiRadioButtons *r = uiRadioButtons(c);
WPARAM check;
uintmax_t i;
HWND hwnd;
if (code != BN_CLICKED)
return FALSE;
for (hwnd : *(r->hwnds)) {
for (const HWND &hwnd : *(r->hwnds)) {
check = BST_UNCHECKED;
if (clicked == hwnd)
check = BST_CHECKED;
@ -43,9 +42,7 @@ static BOOL onWM_COMMAND(uiControl *c, HWND clicked, WORD code, LRESULT *lResult
static void onDestroy(uiRadioButtons *r)
{
HWND hwnd;
for (hwnd : *(r->hwnds)) {
for (const HWND &hwnd : *(r->hwnds)) {
uiWindowsUnregisterWM_COMMANDHandler(hwnd);
uiWindowsEnsureDestroyWindow(hwnd);
}
@ -69,7 +66,7 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width
maxwid = wid;
}
*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)
@ -78,7 +75,6 @@ static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, in
uiWindowsSizing *d;
intmax_t height1;
intmax_t h;
HWND hwnd;
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);
height1 = uiWindowsDlgUnitsToY(radiobuttonHeight, d->BaseY);
uiWindowsFreeSizing(d);
for (hwnd : *(r->hwnds)) {
for (const HWND &hwnd : *(r->hwnds)) {
h = height1;
if (h > height) // clip to height
h = height;
@ -105,13 +101,12 @@ static void radiobuttonsRelayout(uiWindowsControl *c, intmax_t x, intmax_t y, in
static void redoControlIDsZOrder(uiRadioButtons *r)
{
HWND hwnd;
LONG_PTR controlID;
HWND insertAfter;
controlID = 100;
insertAfter = NULL;
for (hwnd : *(r->hwnds)) {
for (const HWND &hwnd : *(r->hwnds)) {
uiWindowsEnsureAssignControlIDZOrder(hwnd, controlID, insertAfter);
controlID++;
insertAfter = hwnd;

View File

@ -67,7 +67,7 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd)
goto noTextOrError;
}
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
size.cx = 0;
size.cy = 0;

View File

@ -62,7 +62,7 @@ WCHAR *utf16dup(const WCHAR *orig)
}
// 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;
WCHAR *buf;
@ -73,13 +73,13 @@ static WCHAR *strfcore(BOOL recursing, WCHAR *format, va_list ap)
return emptyUTF16();
va_copy(ap2, ap);
hr = SafeCchVPrintfEx(NULL, 0,
hr = StringCchVPrintfExW(NULL, 0,
NULL, &n,
STRSAFE_IGNORE_NULLS,
format, ap2);
va_end(ap2);
if (hr != S_OK && hr != STRSAFE_E_INSUFFICIENT_BUFFER) {
if (!failing)
if (!recursing)
logHRESULT(L"error determining needed buffer size", hr);
return emptyUTF16();
}
@ -87,12 +87,12 @@ static WCHAR *strfcore(BOOL recursing, WCHAR *format, va_list ap)
// n includes the terminating L'\0'
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,
0,
format, ap);
if (hr != S_OK) {
if (!failing)
if (!recursing)
logLastError(L"error formatting string", hr);
// and return an empty string
*buf = L'\0';
@ -117,7 +117,7 @@ WCHAR *vstrf(const WCHAR *format, va_list ap)
return strfcore(FALSE, format, ap);
}
WCHAR *debugstrf(const WCHAR *format, ..)
WCHAR *debugstrf(const WCHAR *format, ...)
{
va_list ap;
WCHAR *str;
@ -141,7 +141,7 @@ char *LFtoCRLF(const char *lfonly)
char *out;
len = strlen(lfonly);
crlf = (char *) uiAlloc((only * 2 + 1) * sizeof (char), "char[]");
crlf = (char *) uiAlloc((len * 2 + 1) * sizeof (char), "char[]");
out = crlf;
for (i = 0; i < len; i++) {
if (*lfonly == '\n')
@ -160,7 +160,7 @@ void CRLFtoLF(char *s)
// be sure to preserve \rs that are genuinely there
if (*s == '\r' && *(s + 1) == '\n')
continue;
*t++ = s;
*t++ = *s;
}
*t = '\0';
// TODO null pad t to s?

View File

@ -29,10 +29,12 @@
// Microsoft's resource compiler will segfault if we feed it headers it was not designed to handle
#ifndef RC_INVOKED
#include <commctrl.h>
#include <uxtheme.h>
#include <windowsx.h>
#include <shobjidl.h>
#include <d2d1.h>
#include <dwrite.h>
#include <strsafe.h>
#include <stdint.h>
#include <string.h>

View File

@ -106,7 +106,7 @@ void clientSizeToWindowSize(HWND hwnd, intmax_t *width, intmax_t *height, BOOL h
window.right = *width;
window.bottom = *height;
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
window.left = 0;
window.top = 0;