From 344bae4ca482d0b70421fb9455a41081fb28dc89 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 27 Apr 2015 22:25:27 -0400 Subject: [PATCH] Fixed the other build errors and warnings. Removed lifetimes.c. --- new/GNUmakefile | 1 - new/lifetimes.c | 11 ----------- new/windows/init.c | 2 +- new/windows/uipriv_windows.h | 6 +++--- new/windows/window.c | 31 ++++++++++++++++++------------- 5 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 new/lifetimes.c diff --git a/new/GNUmakefile b/new/GNUmakefile index bb3fd6a4..aa01f372 100644 --- a/new/GNUmakefile +++ b/new/GNUmakefile @@ -24,7 +24,6 @@ baseHFILES = \ baseCFILES = \ box.c \ - lifetimes.c \ $(osCFILES) baseMFILES = $(osMFILES) diff --git a/new/lifetimes.c b/new/lifetimes.c deleted file mode 100644 index efeb1f34..00000000 --- a/new/lifetimes.c +++ /dev/null @@ -1,11 +0,0 @@ -// 25 april 2015 -#include "ui.h" -#include "uipriv.h" - -// called by uiParentDestroy() and any container control in its uiControlDestroy() -void properlyDestroyControl(uiControl *c) -{ - uiControlSetOSContainer(c, NULL); - uiControlSetHasParent(c, 0); - uiControlDestroy(c); -} diff --git a/new/windows/init.c b/new/windows/init.c index 48fc6812..acf05771 100644 --- a/new/windows/init.c +++ b/new/windows/init.c @@ -97,7 +97,7 @@ const char *uiInit(uiInitOptions *o) if (hMessageFont == NULL) return loadLastError("loading default messagebox font; this is the default UI font"); - ce = initOSContainer(hDefaultIcon, hDefaultCursor); + ce = initContainer(hDefaultIcon, hDefaultCursor); if (ce != NULL) return loadLastError(ce); diff --git a/new/windows/uipriv_windows.h b/new/windows/uipriv_windows.h index d45a1a16..65733a1d 100644 --- a/new/windows/uipriv_windows.h +++ b/new/windows/uipriv_windows.h @@ -69,9 +69,9 @@ extern const char *initCommonControls(void); // window.c extern ATOM registerWindowClass(HICON, HCURSOR); -// parent.c -extern HWND initialOSContainer; -extern const char *initOSContainer(HICON, HCURSOR); +// container.c +extern HWND initialParent; +extern const char *initContainer(HICON, HCURSOR); // menu.c extern HMENU makeMenubar(void); diff --git a/new/windows/window.c b/new/windows/window.c index c2868e31..c8618d46 100644 --- a/new/windows/window.c +++ b/new/windows/window.c @@ -20,7 +20,7 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam; WINDOWPOS *wp = (WINDOWPOS *) lParam; RECT r; - HWND boxhwnd; + HWND binhwnd; w = (struct window *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); if (w == NULL) { @@ -45,13 +45,13 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA case msgUpdateChild: if (GetClientRect(w->hwnd, &r) == 0) logLastError("error getting window client rect for resize in uiWindowWndProc()"); - boxhwnd = (HWND) uiControlHandle(uiControl(w->box)); - if (MoveWindow(boxhwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0) + binhwnd = (HWND) uiControlHandle(uiControl(w->bin)); + if (MoveWindow(binhwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0) logLastError("error resizing uiWindow box in windowWndProc()"); return 0; case WM_CLOSE: if (!(*(w->onClosing))(uiWindow(w), w->onClosingData)) - uiWindowDestroy(uiWindow(w)); + uiControlDestroy(uiControl(w)); return 0; // we destroyed it already } return DefWindowProcW(hwnd, uMsg, wParam, lParam); @@ -99,7 +99,7 @@ static uintptr_t windowHandle(uiControl *c) return (uintptr_t) (w->hwnd); } -static void windowSetParent(uiControl *c) +static void windowSetParent(uiControl *c, uiContainer *parent) { complain("attempt to give the uiWindow at %p a parent", c); } @@ -121,7 +121,7 @@ static int windowVisible(uiControl *c) return !w->hidden; } -static void windowShow(uiControl *w) +static void windowShow(uiControl *c) { struct window *w = (struct window *) c; @@ -137,7 +137,7 @@ static void windowShow(uiControl *w) w->hidden = 0; } -static void windowHide(uiControl *w) +static void windowHide(uiControl *c) { struct window *w = (struct window *) c; @@ -174,12 +174,12 @@ static char *windowTitle(uiWindow *ww) static void windowSetTitle(uiWindow *ww, const char *title) { struct window *w = (struct window *) ww; - WCHAR *wtext; + WCHAR *wtitle; - wtext = toUTF16(text); - if (SetWindowTextW(w->hwnd, wtext) == 0) + wtitle = toUTF16(title); + if (SetWindowTextW(w->hwnd, wtitle) == 0) logLastError("error setting window title in uiWindowSetTitle()"); - uiFree(wtext); + uiFree(wtitle); } static void windowOnClosing(uiWindow *ww, int (*f)(uiWindow *, void *), void *data) @@ -233,6 +233,9 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) if (hasMenubar) hasMenubarBOOL = TRUE; +#define style WS_OVERLAPPEDWINDOW +#define exstyle 0 + adjust.left = 0; adjust.top = 0; adjust.right = width; @@ -242,9 +245,9 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) logLastError("error getting real window coordinates in uiNewWindow()"); wtitle = toUTF16(title); - w->hwnd = CreateWindowExW(0, + w->hwnd = CreateWindowExW(exstyle, windowClass, wtitle, - WS_OVERLAPPEDWINDOW, + style, CW_USEDEFAULT, CW_USEDEFAULT, adjust.right - adjust.left, adjust.bottom - adjust.top, NULL, NULL, hInstance, w); @@ -261,6 +264,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) logLastError("error giving menu to window in uiNewWindow()"); } + w->onClosing = defaultOnClosing; + uiControl(w)->Destroy = windowDestroy; uiControl(w)->Handle = windowHandle; uiControl(w)->SetParent = windowSetParent;