Fixed build issues. Now to fix runtime issues...

This commit is contained in:
Pietro Gagliardi 2015-04-12 22:57:05 -04:00
parent 9a4bd6e79d
commit 524a8c88bb
5 changed files with 34 additions and 27 deletions

View File

@ -78,7 +78,7 @@ static void singleShow(uiControl *c)
if (!s->containerHid) { if (!s->containerHid) {
ShowWindow(s->hwnd, SW_SHOW); ShowWindow(s->hwnd, SW_SHOW);
if (s->parent != NULL) if (s->parent != NULL)
uiUpdateParent(s->parent); uiParentUpdate(s->parent);
} }
} }
@ -89,7 +89,7 @@ static void singleHide(uiControl *c)
s->userHid = TRUE; s->userHid = TRUE;
ShowWindow(s->hwnd, SW_HIDE); ShowWindow(s->hwnd, SW_HIDE);
if (s->parent != NULL) if (s->parent != NULL)
uiUpdateParent(s->parent); uiParentUpdate(s->parent);
} }
static void singleContainerShow(uiControl *c) static void singleContainerShow(uiControl *c)
@ -100,7 +100,7 @@ static void singleContainerShow(uiControl *c)
if (!s->userHid) { if (!s->userHid) {
ShowWindow(s->hwnd, SW_SHOW); ShowWindow(s->hwnd, SW_SHOW);
if (s->parent != NULL) if (s->parent != NULL)
uiUpdateParent(s->parent); uiParentUpdate(s->parent);
} }
} }
@ -111,7 +111,7 @@ static void singleContainerHide(uiControl *c)
s->containerHid = TRUE; s->containerHid = TRUE;
ShowWindow(s->hwnd, SW_HIDE); ShowWindow(s->hwnd, SW_HIDE);
if (s->parent != NULL) if (s->parent != NULL)
uiUpdateParent(s->parent); uiParentUpdate(s->parent);
} }
static void singleEnable(uiControl *c) static void singleEnable(uiControl *c)

View File

@ -4,7 +4,7 @@
// All controls in package ui are children of a window of this class. // 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. // 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. // 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 // TODOs
// - wiith CTLCOLOR handler: [12:24] <ZeroOne> There's flickering between tabs // - 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 { struct parent {
HWND hwnd; HWND hwnd;
uiControl *child; uiControl *child;
intmax_t leftMargin; intmax_t marginLeft;
intmax_t topMargin; intmax_t marginTop;
intmax_t rightMargin; intmax_t marginRight;
intmax_t bottomMargin; intmax_t marginBottom;
}; };
static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 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; CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
HWND control; HWND control;
NMHDR *nm = (NMHDR *) lParam; NMHDR *nm = (NMHDR *) lParam;
WINDOWPOS *wp = (WINDOWPOS *) lParam;
RECT r, margin; RECT r, margin;
p = (uiParent *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); 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)) if (textfieldReadOnly((HWND) lParam))
break; // fall through to DefWindowProcW() break; // fall through to DefWindowProcW()
*/ if (SetBkMode((HDC) wParam, TRANSPARENT) == 0) */ 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); paintControlBackground((HWND) lParam, (HDC) wParam);
return (LRESULT) hollowBrush; return (LRESULT) hollowBrush;
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
@ -161,7 +162,7 @@ static LRESULT CALLBACK parentWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
case msgUpdateChild: case msgUpdateChild:
if (pp->child == NULL) if (pp->child == NULL)
break; break;
if (GetClientRect(p->hwnd, &r) == 0) if (GetClientRect(pp->hwnd, &r) == 0)
logLastError("error getting client rect for resize in parentWndProc()"); logLastError("error getting client rect for resize in parentWndProc()");
margin.left = pp->marginLeft; margin.left = pp->marginLeft;
margin.top = pp->marginTop; margin.top = pp->marginTop;
@ -179,8 +180,8 @@ const char *initParent(HICON hDefaultIcon, HCURSOR hDefaultCursor)
WNDCLASSW wc; WNDCLASSW wc;
ZeroMemory(&wc, sizeof (WNDCLASSW)); ZeroMemory(&wc, sizeof (WNDCLASSW));
wc.lpszClassName = uiInitialParentClass; wc.lpszClassName = uiParentClass;
wc.lpfnWndProc = initialParentWndProc; wc.lpfnWndProc = parentWndProc;
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = hDefaultIcon; wc.hIcon = hDefaultIcon;
wc.hCursor = hDefaultCursor; wc.hCursor = hDefaultCursor;
@ -207,12 +208,12 @@ static uintptr_t parentHandle(uiParent *p)
{ {
struct parent *pp = (struct parent *) (p->Internal); 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; pp->child = child;
if (pp->child != NULL) 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) 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->marginLeft = left;
pp->marginTop = top; 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) 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); SendMessageW(pp->hwnd, msgUpdateChild, 0, 0);
} }
@ -239,17 +240,19 @@ static void parentUpdate(uiParent *p)
uiParent *uiNewParent(uintptr_t osParent) uiParent *uiNewParent(uintptr_t osParent)
{ {
uiParent *p; uiParent *p;
struct parent *pp;
p = uiNew(uiParent); p = uiNew(uiParent);
p->Internal = uiNew(struct parent); pp = uiNew(struct parent);
p->hwnd = CreateWindowExW(0, pp->hwnd = CreateWindowExW(0,
xxxxxxx, L"", uiParentClass, L"",
WS_CHILD | WS_VISIBLE, WS_CHILD | WS_VISIBLE,
0, 0, 0, 0,
0, 0, 0, 0,
(HWND) osParent, NULL, hInstance, p); (HWND) osParent, NULL, hInstance, p);
if (p->hwnd == NULL) if (pp->hwnd == NULL)
logLastError("error creating uiParent window in uiNewParent()"); logLastError("error creating uiParent window in uiNewParent()");
p->Internal = pp;
p->Handle = parentHandle; p->Handle = parentHandle;
p->SetChild = parentSetChild; p->SetChild = parentSetChild;
p->SetMargins = parentSetMargins; p->SetMargins = parentSetMargins;

View File

@ -78,7 +78,7 @@ static void resizeTab(uiControl *c, LONG width, LONG height)
// convert to the display rectangle // convert to the display rectangle
SendMessageW(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM) (&r)); 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()"); 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; uiControl *c = (uiControl *) dwRefData;
WINDOWPOS *wp = (WINDOWPOS *) lParam; WINDOWPOS *wp = (WINDOWPOS *) lParam;
LRESULT lResult;
switch (uMsg) { switch (uMsg) {
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:

2
ui.h
View File

@ -32,7 +32,7 @@ struct uiSizing {
uiSizingSys *sys; uiSizingSys *sys;
}; };
typedef strut uiContainer uiContainer; typedef struct uiParent uiParent;
typedef struct uiControl uiControl; typedef struct uiControl uiControl;
struct uiControl { struct uiControl {

View File

@ -17,6 +17,8 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
uiWindow *w; uiWindow *w;
CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam; CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
WINDOWPOS *wp = (WINDOWPOS *) lParam; WINDOWPOS *wp = (WINDOWPOS *) lParam;
RECT r;
HWND contenthwnd;
w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
if (w == NULL) { if (w == NULL) {
@ -27,9 +29,11 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
} }
switch (uMsg) { switch (uMsg) {
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
if ((wp->flags & SWP_NOSIZE) != 0)
break;
if (GetClientRect(w->hwnd, &r) == 0) if (GetClientRect(w->hwnd, &r) == 0)
logLastError("error getting window client rect for resize in uiWindowWndProc()"); 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) 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()"); logLastError("error resizing window content parent in uiWindowWndProc()");
return 0; return 0;
@ -38,8 +42,7 @@ static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
return 0; return 0;
break; // fall through to DefWindowProcW() break; // fall through to DefWindowProcW()
case WM_DESTROY: case WM_DESTROY:
if (w->child != NULL) // no need to free the child ourselves; it'll destroy itself after we leave this handler
uiControlDestroy(w->child);
uiFree(w); uiFree(w);
break; // fall through to DefWindowProcW() break; // fall through to DefWindowProcW()
} }