Started reimplementing the old dialog helper stuff. Now that we're C++ on Windows, we can do this directly in window.cpp and save time.

This commit is contained in:
Pietro Gagliardi 2016-05-15 19:22:15 -04:00
parent c82942a81b
commit 1d08521cb7
2 changed files with 26 additions and 0 deletions

View File

@ -106,6 +106,8 @@ extern BOOL areaFilter(MSG *);
extern ATOM registerWindowClass(HICON, HCURSOR);
extern void unregisterWindowClass(void);
extern void ensureMinimumWindowSize(uiWindow *);
extern void disableAllWindowsExcept(uiWindow *which);
extern void enableAllWindowsExcept(uiWindow *which);
// container.cpp
#define containerClass L"libui_uiContainerClass"

View File

@ -138,6 +138,8 @@ static int defaultOnClosing(uiWindow *w, void *data)
return 0;
}
static std::map<uiWindow *, bool> windows;
static void uiWindowDestroy(uiControl *c)
{
uiWindow *w = uiWindow(c);
@ -154,6 +156,7 @@ static void uiWindowDestroy(uiControl *c)
if (w->menubar != NULL)
freeMenubar(w->menubar);
// and finally free ourselves
windows.erase(w);
uiWindowsEnsureDestroyWindow(w->hwnd);
uiFreeControl(uiControl(w));
}
@ -361,6 +364,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
uiWindowOnClosing(w, defaultOnClosing, NULL);
windows[w] = true;
return w;
}
@ -380,3 +384,23 @@ void ensureMinimumWindowSize(uiWindow *w)
if (SetWindowPos(w->hwnd, NULL, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER) == 0)
logLastError(L"error resizing window");
}
void disableAllWindowsExcept(uiWindow *which)
{
for (auto &w : windows) {
if (w.first == which)
continue;
EnableWindow(w.first->hwnd, FALSE);
}
}
void enableAllWindowsExcept(uiWindow *which)
{
for (auto &w : windows) {
if (w.first == which)
continue;
if (!uiControlEnabled(uiControl(w.first))
continue;
EnableWindow(w.first->hwnd, TRUE);
}
}