Some more uiParent migration.

This commit is contained in:
Pietro Gagliardi 2015-04-12 20:08:32 -04:00
parent 7892757479
commit f7b3e06147
7 changed files with 39 additions and 31 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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)

30
stack.c
View File

@ -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);
}

4
ui.h
View File

@ -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 *);

View File

@ -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);