diff --git a/test/main.c b/test/main.c index ca8040c2..e6f0c77b 100644 --- a/test/main.c +++ b/test/main.c @@ -1,6 +1,9 @@ // 22 april 2015 #include "test.h" +// TODOs +// - blank page affects menus negatively on Windows + void die(const char *fmt, ...) { va_list ap; diff --git a/windows/area.c b/windows/area.c index 579c3dc5..88901490 100644 --- a/windows/area.c +++ b/windows/area.c @@ -89,10 +89,11 @@ void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos) xamount = 0; } + // TODO this isn't safe with Direct2D if (ScrollWindowEx(a->hwnd, xamount, yamount, NULL, NULL, NULL, NULL, SW_ERASE | SW_INVALIDATE) == ERROR) -;//TODO logLastError("error scrolling area in scrollto()"); + logLastError("error scrolling area in scrollto()"); *(p->pos) = pos; @@ -513,9 +514,14 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM a->rt = makeHWNDRenderTarget(a->hwnd); if (GetClientRect(a->hwnd, &client) == 0) logLastError("error getting client rect in WM_PAINT in areaWndProc()"); - // TODO really FALSE? - if (GetUpdateRect(a->hwnd, &clip, FALSE) == 0) - logLastError("error getting clip rect in WM_PAINT in areaWndProc()"); + // do not clear the update rect; we do that ourselves in doPaint() + if (GetUpdateRect(a->hwnd, &clip, FALSE) == 0) { + // set a zero clip rect just in case GetUpdateRect() didn't change clip + clip.left = 0; + clip.top = 0; + clip.right = 0; + clip.bottom = 0; + } hr = doPaint(a, (ID2D1RenderTarget *) (a->rt), &client, &clip); switch (hr) { case S_OK: @@ -526,6 +532,7 @@ static LRESULT CALLBACK areaWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM // DON'T validate the rect // instead, simply drop the render target // we'll get another WM_PAINT and make the render target again + // TODO would this require us to invalidate the entire client area? ID2D1HwndRenderTarget_Release(a->rt); a->rt = NULL; break; @@ -632,6 +639,7 @@ static void minimumSize(uiWindowsControl *c, uiWindowsSizing *d, intmax_t *width } // TODO affect visibility properly +// TODO what did this mean void processAreaMessage(HWND active, MSG *msg) { LRESULT handled; diff --git a/windows/draw.c b/windows/draw.c index cf660ec7..2ad16589 100644 --- a/windows/draw.c +++ b/windows/draw.c @@ -77,11 +77,9 @@ uiDrawPath *uiDrawNewPath(uiDrawFillMode fillmode) uiDrawPath *p; HRESULT hr; - // TODO uiNew - p = malloc(sizeof (uiDrawPath)); + p = uiNew(uiDrawPath); hr = ID2D1Factory_CreatePathGeometry(d2dfactory, &(p->path)); - // TODO make sure this is the only success code if (hr != S_OK) logHRESULT("error creating path in uiDrawNewPath()", hr); hr = ID2D1PathGeometry_Open(p->path, @@ -111,8 +109,7 @@ void uiDrawFreePath(uiDrawPath *p) // TODO close sink first? ID2D1GeometrySink_Release(p->sink); ID2D1PathGeometry_Release(p->path); - // TODO uiFree - free(p); + uiFree(p); } void uiDrawPathNewFigure(uiDrawPath *p, double x, double y) @@ -260,8 +257,7 @@ uiDrawContext *newContext(ID2D1RenderTarget *rt) { uiDrawContext *c; - // TODO use uiNew - c = (uiDrawContext *) malloc(sizeof (uiDrawContext)); + c = uiNew(uiDrawContext); c->rt = rt; return c; } @@ -293,8 +289,7 @@ static ID2D1GradientStopCollection *mkstops(uiDrawBrush *b, ID2D1RenderTarget *r size_t i; HRESULT hr; - // TODO uiAlloc - stops = malloc(b->NumStops * sizeof (D2D1_GRADIENT_STOP)); + stops = uiAlloc(b->NumStops * sizeof (D2D1_GRADIENT_STOP), "D2D1_GRADIENT_STOP[]"); for (i = 0; i < b->NumStops; i++) { stops[i].position = b->Stops[i].Pos; stops[i].color.r = b->Stops[i].R; @@ -315,8 +310,7 @@ static ID2D1GradientStopCollection *mkstops(uiDrawBrush *b, ID2D1RenderTarget *r if (hr != S_OK) logHRESULT("error creating stop collection in mkstops()", hr); - // TODO uiFree - free(stops); + uiFree(stops); return s; } @@ -398,7 +392,7 @@ static ID2D1Brush *makeBrush(uiDrawBrush *b, ID2D1RenderTarget *rt) // TODO } -//TODO complain("invalid brush type %d in makeBrush()", b->Type); + complain("invalid brush type %d in makeBrush()", b->Type); return NULL; // make compiler happy }