Oops forgot to commit this before midnight: started work on uiWindow children.
This commit is contained in:
parent
8b3e2665ed
commit
69dbafe6f2
|
@ -86,6 +86,8 @@ extern uint32_t uiprivSysWindowType(void);
|
|||
extern uiWindow *uiprivSysNewWindow(void);
|
||||
extern const char *uiprivSysWindowTitle(uiWindow *w);
|
||||
extern void uiprivSysWindowSetTitle(uiWindow *w, const char *title);
|
||||
extern uiControl *uiprivSysWindowChild(uiWindow *w);
|
||||
extern void uiprivSysWindowSetChild(uiWindow *w, uiControl *child);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -40,3 +40,25 @@ void uiWindowSetTitle(uiWindow *w, const char *title)
|
|||
}
|
||||
uiprivSysWindowSetTitle(w, title);
|
||||
}
|
||||
|
||||
uiControl *uiWindowChild(uiWindow *w)
|
||||
{
|
||||
if (!uiprivCheckInitializedAndThread())
|
||||
return NULL;
|
||||
if (w == NULL) {
|
||||
uiprivProgrammerErrorNullPointer("uiWindow", uiprivFunc);
|
||||
return NULL;
|
||||
}
|
||||
return uiprivSysWindowChild(w);
|
||||
}
|
||||
|
||||
void uiWindowSetChild(uiWindow *w, uiControl *child)
|
||||
{
|
||||
if (!uiprivCheckInitializedAndThread())
|
||||
return;
|
||||
if (w == NULL) {
|
||||
uiprivProgrammerErrorNullPointer("uiWindow", uiprivFunc);
|
||||
return;
|
||||
}
|
||||
uiprivSysWindowSetChild(w, child);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
struct windowImplData {
|
||||
NSWindow *window;
|
||||
char *title;
|
||||
#if 0
|
||||
uiControl *child;
|
||||
#if 0
|
||||
int margined;
|
||||
int (*onClosing)(uiWindow *, void *);
|
||||
void *onClosingData;
|
||||
|
@ -377,7 +377,7 @@ static bool windowInit(uiControl *c, void *implData, void *initData)
|
|||
[wi->window setTitle:@""];
|
||||
|
||||
// do NOT release when closed
|
||||
// we manually do this in uiWindowDestroy() above
|
||||
// we manually do this in Free() below
|
||||
[wi->window setReleasedWhenClosed:NO];
|
||||
|
||||
#if 0
|
||||
|
@ -393,10 +393,25 @@ static bool windowInit(uiControl *c, void *implData, void *initData)
|
|||
return true;
|
||||
}
|
||||
|
||||
static void connectChild(struct windowImplData *wi)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void disconnectChild(struct winodwImplData *wi)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void windowFree(uiControl *c, void *implData)
|
||||
{
|
||||
struct windowImplData *wi = (struct windowImplData *) implData;
|
||||
|
||||
if (wi->child != NULL) {
|
||||
disconnectChild(wi);
|
||||
uiControlFree(wi->child);
|
||||
wi->child = NULL;
|
||||
}
|
||||
if (wi->title != NULL) {
|
||||
uiprivFreeUTF8(wi->title);
|
||||
wi->title = NULL;
|
||||
|
@ -469,6 +484,24 @@ void uiprivSysWindowSetTitle(uiWindow *w, const char *title)
|
|||
[wi->window setTitle:[NSString stringWithUTF8String:wi->title]];
|
||||
}
|
||||
|
||||
uiControl *uiprivSysWindowChild(uiWindow *w)
|
||||
{
|
||||
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
||||
|
||||
return wi->child;
|
||||
}
|
||||
|
||||
void uiprivSysWindowSetChild(uiWindow *w, uiControl *child)
|
||||
{
|
||||
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
|
||||
|
||||
if (wi->child != NULL)
|
||||
disconnectChild(wi);
|
||||
wi->child = child;
|
||||
if (wi->child != NULL)
|
||||
connectChild(wi);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
// utility function for menus
|
||||
|
|
|
@ -56,4 +56,26 @@ void uiWindowSetTitle(uiWindow *w, const char *title);
|
|||
|
||||
It is a programmer error to pass `NULL` for `title`. If `title` is not valid UTF-8, `U+FFFD` characters will be used to sanitize the string.
|
||||
|
||||
It is a programmer error to pass `NULL` for `w`.
|
||||
It is a programmer error to pass `NULL` for `w`.
|
||||
|
||||
### `uiWindowChild()`
|
||||
|
||||
```c
|
||||
uiprivExtern uiControl *uiWindowChild(uiWindow *w);
|
||||
```
|
||||
|
||||
`uiWindowChild()` returns the current child of `w`, or `NULL` if there is none.
|
||||
|
||||
It is a programmer error to pass `NULL` for `w`.
|
||||
|
||||
### `uiWindowSetChild()`
|
||||
|
||||
```c
|
||||
uiprivExtern void uiWindowSetChild(uiWindow *w, uiControl *child);
|
||||
```
|
||||
|
||||
`uiWindowSetChild()` sets the child control of `w` to `child`. If `child` is `NULL`, `w` will have its child removed, and the window will be empty. If `w` already has a child, then the child is seamlessly swapped out, and the current child will be free to add to another parent.
|
||||
|
||||
A window can only have one child control at a time, and that child will be given the entire area of the window. Multiple controls within a window are handled using the other container control types.
|
||||
|
||||
It is a programmer error to pass `NULL` for `w`. It is also a programmer error to pass a control for `child` that is already the child of some other control.
|
||||
|
|
2
ui.h
2
ui.h
|
@ -74,6 +74,8 @@ uiprivExtern uint32_t uiWindowType(void);
|
|||
uiprivExtern uiWindow *uiNewWindow(void);
|
||||
uiprivExtern const char *uiWindowTitle(uiWindow *w);
|
||||
uiprivExtern void uiWindowSetTitle(uiWindow *w, const char *title);
|
||||
uiprivExtern uiControl *uiWindowChild(uiWindow *w);
|
||||
uiprivExtern void uiWindowSetChild(uiWindow *w, uiControl *child);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue