summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--new/singlehandle_windows.c22
-rw-r--r--new/ui_windows.h3
-rw-r--r--new/uipriv.h2
3 files changed, 17 insertions, 10 deletions
diff --git a/new/singlehandle_windows.c b/new/singlehandle_windows.c
index a6e3960..74dee5f 100644
--- a/new/singlehandle_windows.c
+++ b/new/singlehandle_windows.c
@@ -4,30 +4,36 @@
// Common code for controls with a single window handle.
// The only method NOT defined is preferredSize(); this differs between controls.
+#define S(c) ((uiSingleHWNDControl *) (c))
+
static uintptr_t singleHandle(uiControl *c)
{
- return (uintptr_t) (c->hwnd);
+ return (uintptr_t) (S(c)->hwnd);
}
-//TODO void (*setParent)(uiControl *, uintptr_t);
+void singleSetParent(uiControl *c, uintptr_t parentHWND)
+{
+ if (SetParent(S(c)->hwnd, (HWND) parentHWND) == NULL)
+ logLastError("error changing control parent in singleSetParent()");
+}
static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d)
{
- if (MoveWindow(c->hwnd, x, y, width, height, TRUE) == 0)
+ if (MoveWindow(S(c)->hwnd, x, y, width, height, TRUE) == 0)
logLastError("error moving control in singleResize()");
}
static void singleContainerShow(uiControl *c)
{
- ShowWindow(c->hwnd, SW_SHOW);
+ ShowWindow(S(c)->hwnd, SW_SHOW);
}
static void singleContainerHide(uiControl *c)
{
- ShowWindow(c->hwnd, SW_HIDE);
+ ShowWindow(S(c)->hwnd, SW_HIDE);
}
-uiSingleHWNDControl *newSingleHWNDControl(DWORD exstyle, const WCHAR *class, DWORD style, HWND parent, HINSTANCE hInstance)
+uiSingleHWNDControl *newSingleHWNDControl(DWORD exstyle, const WCHAR *class, DWORD style, HINSTANCE hInstance)
{
uiSingleHWNDControl *c;
@@ -38,12 +44,12 @@ uiSingleHWNDControl *newSingleHWNDControl(DWORD exstyle, const WCHAR *class, DWO
0, 0,
100, 100,
// TODO specify control IDs properly
- parent, NULL, hInstance, NULL);
+ initialParent, NULL, hInstance, NULL);
if (c->hwnd == NULL)
logLastError("error creating control in newSingleHWNDControl()");
c->control.handle = singleHandle;
-//TODO c->control.setParent = singleSetParent;
+ c->control.setParent = singleSetParent;
c->control.resize = singleResize;
c->control.containerShow = singleContainerShow;
c->control.containerHide = singleContainerHide;
diff --git a/new/ui_windows.h b/new/ui_windows.h
index 00a14c8..896762f 100644
--- a/new/ui_windows.h
+++ b/new/ui_windows.h
@@ -47,6 +47,7 @@ extern HRESULT logMemoryExhausted(const char *);
extern HINSTANCE hInstance;
extern int nCmdShow;
extern HFONT hMessageFont;
+extern HWND initialParent;
// util_windows.c
extern WCHAR *toUTF16(const char *);
@@ -62,6 +63,6 @@ struct uiSingleHWNDControl {
void (*voidEvent)(uiControl *, void *);
void *voidEventData;
};
-extern uiSingleHWNDControl *newSingleHWNDControl(DWORD, const WCHAR *, DWORD, HWND, HINSTANCE);
+extern uiSingleHWNDControl *newSingleHWNDControl(DWORD, const WCHAR *, DWORD, HINSTANCE);
#endif
diff --git a/new/uipriv.h b/new/uipriv.h
index 002adf0..02aa72b 100644
--- a/new/uipriv.h
+++ b/new/uipriv.h
@@ -12,7 +12,7 @@ struct uiSize {
// TODO handle destruction
struct uiControl {
uintptr_t (*handle)(uiControl *);
-//TODO void (*setParent)(uiControl *, uintptr_t);
+ void (*setParent)(uiControl *, uintptr_t);
uiSize (*preferredSize)(uiControl *, uiSizing *);
void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *);
void (*containerShow)(uiControl *);