From dcf581eb14de1b64607bbcee16150d0099941e93 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 12 Apr 2015 20:08:32 -0400 Subject: [PATCH] Some more uiParent migration. --- new/control.c | 2 +- new/newcontrol_darwin.m | 4 ++-- new/newcontrol_unix.c | 4 ++-- new/newcontrol_windows.c | 24 ++++++++++++++---------- new/stack.c | 30 ++++++++++++++++++------------ new/ui.h | 4 ++-- new/uipriv.h | 2 -- 7 files changed, 39 insertions(+), 31 deletions(-) diff --git a/new/control.c b/new/control.c index 5c56f0a..c7cd928 100644 --- a/new/control.c +++ b/new/control.c @@ -11,7 +11,7 @@ uintptr_t uiControlHandle(uiControl *c) return (*(c->handle))(c); } -void uiControlSetParent(uiControl *c, uintptr_t parent) +void uiControlSetParent(uiControl *c, uiParent *parent) { (*(c->setParent))(c, parent); } diff --git a/new/newcontrol_darwin.m b/new/newcontrol_darwin.m index b2bcdd5..56a9f7b 100644 --- a/new/newcontrol_darwin.m +++ b/new/newcontrol_darwin.m @@ -42,10 +42,10 @@ static void singleSetParent(uiControl *c, uintptr_t parent) static void singleRemoveParent(uiControl *c) { singleView *s = (singleView *) (c->internal); - uintptr_t oldparent; + uiParent *oldparent; oldparent = s->parent; - s->parent = 0; + s->parent = NULL; [s->immediate removeFromSuperview]; updateParent(oldparent); } diff --git a/new/newcontrol_unix.c b/new/newcontrol_unix.c index feedafe..5779af2 100644 --- a/new/newcontrol_unix.c +++ b/new/newcontrol_unix.c @@ -40,10 +40,10 @@ static void singleSetParent(uiControl *c, uintptr_t parent) static void singleRemoveParent(uiControl *c) { singleWidget *s = (singleWidget *) (c->internal); - uintptr_t oldparent; + uiParent *oldparent; oldparent = s->parent; - s->parent = 0; + s->parent = NULL; gtk_container_remove(GTK_CONTAINER(oldparent), s->immediate); updateParent(oldparent); } diff --git a/new/newcontrol_windows.c b/new/newcontrol_windows.c index eb06d94..4d61832 100644 --- a/new/newcontrol_windows.c +++ b/new/newcontrol_windows.c @@ -8,7 +8,7 @@ struct singleHWND { BOOL (*onWM_COMMAND)(uiControl *, WORD, LRESULT *); BOOL (*onWM_NOTIFY)(uiControl *, NMHDR *, LRESULT *); void (*onWM_DESTROY)(uiControl *); - uintptr_t parent; + uiParent *parent; BOOL userHid; BOOL containerHid; BOOL userDisabled; @@ -31,26 +31,26 @@ static uintptr_t singleHandle(uiControl *c) return (uintptr_t) (s->hwnd); } -static void singleSetParent(uiControl *c, uintptr_t parent) +static void singleSetParent(uiControl *c, uiParent *parent) { singleHWND *s = (singleHWND *) (c->internal); s->parent = parent; if (SetParent(s->hwnd, (HWND) (s->parent)) == NULL) logLastError("error setting control parent in singleSetParent()"); - updateParent(s->parent); + uiParentUpdate(s->parent); } static void singleRemoveParent(uiControl *c) { singleHWND *s = (singleHWND *) (c->internal); - uintptr_t oldparent; + uiParent *oldparent; oldparent = s->parent; - s->parent = 0; + s->parent = NULL; if (SetParent(s->hwnd, initialParent) == NULL) logLastError("error removing control parent in singleSetParent()"); - updateParent(oldparent); + uiParentUpdate(oldparent); } static void singleResize(uiControl *c, intmax_t x, intmax_t y, intmax_t width, intmax_t height, uiSizing *d) @@ -77,7 +77,8 @@ static void singleShow(uiControl *c) s->userHid = FALSE; if (!s->containerHid) { ShowWindow(s->hwnd, SW_SHOW); - updateParent(s->parent); + if (s->parent != NULL) + uiUpdateParent(s->parent); } } @@ -87,7 +88,8 @@ static void singleHide(uiControl *c) s->userHid = TRUE; ShowWindow(s->hwnd, SW_HIDE); - updateParent(s->parent); + if (s->parent != NULL) + uiUpdateParent(s->parent); } static void singleContainerShow(uiControl *c) @@ -97,7 +99,8 @@ static void singleContainerShow(uiControl *c) s->containerHid = FALSE; if (!s->userHid) { ShowWindow(s->hwnd, SW_SHOW); - updateParent(s->parent); + if (s->parent != NULL) + uiUpdateParent(s->parent); } } @@ -107,7 +110,8 @@ static void singleContainerHide(uiControl *c) s->containerHid = TRUE; ShowWindow(s->hwnd, SW_HIDE); - updateParent(s->parent); + if (s->parent != NULL) + uiUpdateParent(s->parent); } static void singleEnable(uiControl *c) diff --git a/new/stack.c b/new/stack.c index cb9aa6d..1a08ee0 100644 --- a/new/stack.c +++ b/new/stack.c @@ -9,7 +9,7 @@ struct stack { uintmax_t len; uintmax_t cap; int vertical; - uintptr_t parent; + uiParent *parent; int padded; int userHid; int containerHid; @@ -41,7 +41,7 @@ static uintptr_t stackHandle(uiControl *c) return 0; } -static void stackSetParent(uiControl *c, uintptr_t parent) +static void stackSetParent(uiControl *c, uiParent *parent) { stack *s = (stack *) (c->data); uintmax_t i; @@ -49,20 +49,20 @@ static void stackSetParent(uiControl *c, uintptr_t parent) s->parent = parent; for (i = 0; i < s->len; i++) uiControlSetParent(s->controls[i].c, s->parent); - updateParent(s->parent); + uiParentUpdate(s->parent); } static void stackRemoveParent(uiControl *c) { stack *s = (stack *) (c->data); uintmax_t i; - uintptr_t oldparent; + uiParent *oldparent; oldparent = s->parent; - s->parent = 0; + s->parent = NULL; for (i = 0; i < s->len; i++) uiControlRemoveParent(s->controls[i].c); - updateParent(oldparent); + uiParentUpdate(oldparent); } static void stackPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height) @@ -224,7 +224,8 @@ static void stackShow(uiControl *c) if (!s->containerHid) { for (i = 0; i < s->len; i++) uiControlContainerShow(s->controls[i].c); - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } } @@ -236,7 +237,8 @@ static void stackHide(uiControl *c) s->userHid = 1; for (i = 0; i < s->len; i++) uiControlContainerHide(s->controls[i].c); - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } static void stackContainerShow(uiControl *c) @@ -248,7 +250,8 @@ static void stackContainerShow(uiControl *c) if (!s->userHid) { for (i = 0; i < s->len; i++) uiControlContainerShow(s->controls[i].c); - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } } @@ -260,7 +263,8 @@ static void stackContainerHide(uiControl *c) s->containerHid = 1; for (i = 0; i < s->len; i++) uiControlContainerHide(s->controls[i].c); - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } static void stackEnable(uiControl *c) @@ -359,7 +363,8 @@ void uiStackAdd(uiControl *st, uiControl *c, int stretchy) if (s->parent != 0) uiControlSetParent(s->controls[s->len].c, s->parent); s->len++; - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } int uiStackPadded(uiControl *c) @@ -374,5 +379,6 @@ void uiStackSetPadded(uiControl *c, int padded) stack *s = (stack *) (c->data); s->padded = padded; - updateParent(s->parent); + if (s->parent != NULL) + uiParentUpdate(s->parent); } diff --git a/new/ui.h b/new/ui.h index 0a35231..16e6be4 100644 --- a/new/ui.h +++ b/new/ui.h @@ -40,7 +40,7 @@ struct uiControl { void *internal; // for use by ui only void (*destroy)(uiControl *); uintptr_t (*handle)(uiControl *); - void (*setParent)(uiControl *, uiContainer *); + void (*setParent)(uiControl *, uiParent *); void (*removeParent)(uiControl *); void (*preferredSize)(uiControl *, uiSizing *, intmax_t *, intmax_t *); void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); @@ -56,7 +56,7 @@ struct uiControl { }; void uiControlDestroy(uiControl *); uintptr_t uiControlHandle(uiControl *); -void uiControlSetParent(uiControl *, uiContainer *); +void uiControlSetParent(uiControl *, uiParent *); void uiControlRemoveParent(uiControl *); void uiControlPreferredSize(uiControl *, uiSizing *, intmax_t *width, intmax_t *height); void uiControlResize(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); diff --git a/new/uipriv.h b/new/uipriv.h index f028590..7cc1795 100644 --- a/new/uipriv.h +++ b/new/uipriv.h @@ -8,5 +8,3 @@ extern void *uiAlloc(size_t, const char *); #define uiNew(T) ((T *) uiAlloc(sizeof (T), #T )) extern void *uiRealloc(void *, size_t, const char *); extern void uiFree(void *); - -extern void updateParent(uintptr_t);