Migrated the container stuff.
This commit is contained in:
parent
8f4678a1f0
commit
dd1d5c871e
|
@ -5,16 +5,38 @@
|
||||||
// - uiBox
|
// - uiBox
|
||||||
// - uiRadioButtons
|
// - uiRadioButtons
|
||||||
|
|
||||||
|
struct containerInit {
|
||||||
|
void (*onResize)(void *data);
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
|
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
|
||||||
|
WINDOWPOS *wp = (WINDOWPOS *) lParam;
|
||||||
|
struct containerInit *init;
|
||||||
|
void (*onResize)(void *);
|
||||||
|
void *data;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
|
|
||||||
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
|
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
|
||||||
return lResult;
|
return lResult;
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
|
case WM_CREATE:
|
||||||
|
init = (struct containerInit *) (cs->lpParam);
|
||||||
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (init->onResize));
|
||||||
|
SetWindowLongPtrW(hwnd, 0, (LONG_PTR) (init->data));
|
||||||
|
break; // defer to DefWindowProc()
|
||||||
|
case WM_WINDOWPOSCHANGED:
|
||||||
|
if ((wp->flags & SWP_NOSIZE) != 0)
|
||||||
|
break; // defer to DefWindowProc();
|
||||||
|
onResize = (void (*)(void *)) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
|
data = (void *) GetWindowLongPtrW(hwnd, 0);
|
||||||
|
(*(onResize))(data);
|
||||||
|
return 0;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
dc = BeginPaint(hwnd, &ps);
|
dc = BeginPaint(hwnd, &ps);
|
||||||
if (dc == NULL) {
|
if (dc == NULL) {
|
||||||
|
@ -54,6 +76,7 @@ ATOM initContainer(HICON hDefaultIcon, HCURSOR hDefaultCursor)
|
||||||
wc.hIcon = hDefaultIcon;
|
wc.hIcon = hDefaultIcon;
|
||||||
wc.hCursor = hDefaultCursor;
|
wc.hCursor = hDefaultCursor;
|
||||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||||
|
wc.cbWndExtra = sizeof (void *);
|
||||||
return RegisterClassW(&wc);
|
return RegisterClassW(&wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +86,16 @@ void uninitContainer(void)
|
||||||
logLastError(L"error unregistering container window class");
|
logLastError(L"error unregistering container window class");
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND newContainer(void)
|
HWND uiWindowsMakeContainer(void (*onResize)(void *data), void *data)
|
||||||
{
|
{
|
||||||
|
struct containerInit init;
|
||||||
|
|
||||||
|
// TODO onResize cannot be NULL
|
||||||
|
init.onResize = onResize;
|
||||||
|
init.data = data;
|
||||||
return uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT,
|
return uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT,
|
||||||
containerClass, L"",
|
containerClass, L"",
|
||||||
0,
|
0,
|
||||||
hInstance, NULL,
|
hInstance, (LPVOID) (&init),
|
||||||
FALSE);
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,6 @@ extern void ensureMinimumWindowSize(uiWindow *);
|
||||||
#define containerClass L"libui_uiContainerClass"
|
#define containerClass L"libui_uiContainerClass"
|
||||||
extern ATOM initContainer(HICON, HCURSOR);
|
extern ATOM initContainer(HICON, HCURSOR);
|
||||||
extern void uninitContainer(void);
|
extern void uninitContainer(void);
|
||||||
extern HWND newContainer(void);
|
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
Loading…
Reference in New Issue