summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--new/newcontrol_windows.c8
-rw-r--r--new/parent_windows.c39
-rw-r--r--new/tab_windows.c3
-rw-r--r--new/ui.h2
-rw-r--r--new/window_windows.c9
5 files changed, 34 insertions, 27 deletions
diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c
index 4d61832..b4e5d0e 100644
--- a/new/newcontrol_windows.c
+++ b/new/newcontrol_windows.c
@@ -78,7 +78,7 @@ static void singleShow(uiControl *c)
if (!s->containerHid) {
ShowWindow(s->hwnd, SW_SHOW);
if (s->parent != NULL)
- uiUpdateParent(s->parent);
+ uiParentUpdate(s->parent);
}
}
@@ -89,7 +89,7 @@ static void singleHide(uiControl *c)
s->userHid = TRUE;
ShowWindow(s->hwnd, SW_HIDE);
if (s->parent != NULL)
- uiUpdateParent(s->parent);
+ uiParentUpdate(s->parent);
}
static void singleContainerShow(uiControl *c)
@@ -100,7 +100,7 @@ static void singleContainerShow(uiControl *c)
if (!s->userHid) {
ShowWindow(s->hwnd, SW_SHOW);
if (s->parent != NULL)
- uiUpdateParent(s->parent);
+ uiParentUpdate(s->parent);
}
}
@@ -111,7 +111,7 @@ static void singleContainerHide(uiControl *c)
s->containerHid = TRUE;
ShowWindow(s->hwnd, SW_HIDE);
if (s->parent != NULL)
- uiUpdateParent(s->parent);
+ uiParentUpdate(s->parent);
}
static void singleEnable(uiControl *c)
diff --git a/new/parent_windows.c b/new/parent_windows.c
index 2963e0f..55957e5 100644
--- a/new/parent_windows.c
+++ b/new/parent_windows.c
@@ -4,7 +4,7 @@
// All controls in package ui are children of a window of this class.
// This keeps everything together, makes hiding controls en masse (tab page switching, for instance) easy, and makes the overall design cleaner.
// In addition, controls that are first created or don't have a parent are considered children of the "initial parent", which is also of this class.
-// This paxxxxxxxxxxxxxxxxxrent is invisible, disabled, and should not be interacted with.
+// This parent is invisible, disabled, and should not be interacted with.
// TODOs
// - wiith CTLCOLOR handler: [12:24] <ZeroOne> There's flickering between tabs
@@ -98,10 +98,10 @@ static void resize(uiControl *control, HWND parent, RECT r, RECT margin)
struct parent {
HWND hwnd;
uiControl *child;
- intmax_t leftMargin;
- intmax_t topMargin;
- intmax_t rightMargin;
- intmax_t bottomMargin;
+ intmax_t marginLeft;
+ intmax_t marginTop;
+ intmax_t marginRight;
+ intmax_t marginBottom;
};
static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -111,6 +111,7 @@ static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
HWND control;
NMHDR *nm = (NMHDR *) lParam;
+ WINDOWPOS *wp = (WINDOWPOS *) lParam;
RECT r, margin;
p = (uiParent *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
@@ -151,7 +152,7 @@ static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
if (textfieldReadOnly((HWND) lParam))
break; // fall through to DefWindowProcW()
*/ if (SetBkMode((HDC) wParam, TRANSPARENT) == 0)
- logLastError("error setting transparent background mode to controls in sharedWndProc()");
+ logLastError("error setting transparent background mode to controls in parentWndProc()");
paintControlBackground((HWND) lParam, (HDC) wParam);
return (LRESULT) hollowBrush;
case WM_WINDOWPOSCHANGED:
@@ -161,7 +162,7 @@ static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
case msgUpdateChild:
if (pp->child == NULL)
break;
- if (GetClientRect(p->hwnd, &r) == 0)
+ if (GetClientRect(pp->hwnd, &r) == 0)
logLastError("error getting client rect for resize in parentWndProc()");
margin.left = pp->marginLeft;
margin.top = pp->marginTop;
@@ -179,8 +180,8 @@ const char *initParent(HICON hDefaultIcon, HCURSOR hDefaultCursor)
WNDCLASSW wc;
ZeroMemory(&wc, sizeof (WNDCLASSW));
- wc.lpszClassName = uiInitialParentClass;
- wc.lpfnWndProc = initialParentWndProc;
+ wc.lpszClassName = uiParentClass;
+ wc.lpfnWndProc = parentWndProc;
wc.hInstance = hInstance;
wc.hIcon = hDefaultIcon;
wc.hCursor = hDefaultCursor;
@@ -207,12 +208,12 @@ static uintptr_t parentHandle(uiParent *p)
{
struct parent *pp = (struct parent *) (p->Internal);
- return (uintptr_t) (p->hwnd);
+ return (uintptr_t) (pp->hwnd);
}
-static void parentSetChild(uiParent *p, uiChild *child)
+static void parentSetChild(uiParent *p, uiControl *child)
{
- struct parent *pp = (struct parent *) (p->internal);
+ struct parent *pp = (struct parent *) (p->Internal);
pp->child = child;
if (pp->child != NULL)
@@ -221,7 +222,7 @@ static void parentSetChild(uiParent *p, uiChild *child)
static void parentSetMargins(uiParent *p, intmax_t left, intmax_t top, intmax_t right, intmax_t bottom)
{
- struct parent *pp = (struct parent *) (p->internal);
+ struct parent *pp = (struct parent *) (p->Internal);
pp->marginLeft = left;
pp->marginTop = top;
@@ -231,7 +232,7 @@ static void parentSetMargins(uiParent *p, intmax_t left, intmax_t top, intmax_t
static void parentUpdate(uiParent *p)
{
- struct parent *pp = (struct parent *) (p->internal);
+ struct parent *pp = (struct parent *) (p->Internal);
SendMessageW(pp->hwnd, msgUpdateChild, 0, 0);
}
@@ -239,17 +240,19 @@ static void parentUpdate(uiParent *p)
uiParent *uiNewParent(uintptr_t osParent)
{
uiParent *p;
+ struct parent *pp;
p = uiNew(uiParent);
- p->Internal = uiNew(struct parent);
- p->hwnd = CreateWindowExW(0,
- xxxxxxx, L"",
+ pp = uiNew(struct parent);
+ pp->hwnd = CreateWindowExW(0,
+ uiParentClass, L"",
WS_CHILD | WS_VISIBLE,
0, 0,
0, 0,
(HWND) osParent, NULL, hInstance, p);
- if (p->hwnd == NULL)
+ if (pp->hwnd == NULL)
logLastError("error creating uiParent window in uiNewParent()");
+ p->Internal = pp;
p->Handle = parentHandle;
p->SetChild = parentSetChild;
p->SetMargins = parentSetMargins;
diff --git a/new/tab_windows.c b/new/tab_windows.c
index 5fd4989..854e5e8 100644
--- a/new/tab_windows.c
+++ b/new/tab_windows.c
@@ -78,7 +78,7 @@ static void resizeTab(uiControl *c, LONG width, LONG height)
// convert to the display rectangle
SendMessageW(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) (&r));
- if (MoveWindow((HWND) uiParentHandle(t->pages[n].content), r.leftm r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0)
+ if (MoveWindow((HWND) uiParentHandle(t->pages[n].content), r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0)
logLastError("error resizing current tab page in resizeTab()");
}
@@ -87,6 +87,7 @@ static LRESULT CALLBACK tabSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
{
uiControl *c = (uiControl *) dwRefData;
WINDOWPOS *wp = (WINDOWPOS *) lParam;
+ LRESULT lResult;
switch (uMsg) {
case WM_WINDOWPOSCHANGED:
diff --git a/new/ui.h b/new/ui.h
index 16e6be4..3120d6d 100644
--- a/new/ui.h
+++ b/new/ui.h
@@ -32,7 +32,7 @@ struct uiSizing {
uiSizingSys *sys;
};
-typedef strut uiContainer uiContainer;
+typedef struct uiParent uiParent;
typedef struct uiControl uiControl;
struct uiControl {
diff --git a/new/window_windows.c b/new/window_windows.c
index a54fd30..a52debf 100644
--- a/new/window_windows.c
+++ b/new/window_windows.c
@@ -17,6 +17,8 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
uiWindow *w;
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
WINDOWPOS *wp = (WINDOWPOS *) lParam;
+ RECT r;
+ HWND contenthwnd;
w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (w == NULL) {
@@ -27,9 +29,11 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
}
switch (uMsg) {
case WM_WINDOWPOSCHANGED:
+ if ((wp->flags & SWP_NOSIZE) != 0)
+ break;
if (GetClientRect(w->hwnd, &r) == 0)
logLastError("error getting window client rect for resize in uiWindowWndProc()");
- contenthwnd = (HWND) uiParentHandle(content);
+ contenthwnd = (HWND) uiParentHandle(w->content);
if (MoveWindow(contenthwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE) == 0)
logLastError("error resizing window content parent in uiWindowWndProc()");
return 0;
@@ -38,8 +42,7 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
return 0;
break; // fall through to DefWindowProcW()
case WM_DESTROY:
- if (w->child != NULL)
- uiControlDestroy(w->child);
+ // no need to free the child ourselves; it'll destroy itself after we leave this handler
uiFree(w);
break; // fall through to DefWindowProcW()
}