diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-12 18:34:54 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-12 18:34:54 -0400 |
| commit | 74e4238fe73c40473b219409ad80e819528b947e (patch) | |
| tree | ecd79130b301506f1fe731c638da59a4447592b6 /new/ui.h | |
| parent | 425ede5288b50d140049f4e9e62d23189cd7d970 (diff) | |
Set up a unified system for containers, now called parents.
Diffstat (limited to 'new/ui.h')
| -rw-r--r-- | new/ui.h | 42 |
1 files changed, 40 insertions, 2 deletions
@@ -32,13 +32,15 @@ struct uiSizing { uiSizingSys *sys; }; +typedef strut uiContainer uiContainer; + typedef struct uiControl uiControl; struct uiControl { void *data; // for use by implementations only void *internal; // for use by ui only void (*destroy)(uiControl *); uintptr_t (*handle)(uiControl *); - void (*setParent)(uiControl *, uintptr_t); + void (*setParent)(uiControl *, uiContainer *); void (*removeParent)(uiControl *); void (*preferredSize)(uiControl *, uiSizing *, intmax_t *, intmax_t *); void (*resize)(uiControl *, intmax_t, intmax_t, intmax_t, intmax_t, uiSizing *); @@ -54,7 +56,7 @@ struct uiControl { }; void uiControlDestroy(uiControl *); uintptr_t uiControlHandle(uiControl *); -void uiControlSetParent(uiControl *, uintptr_t); +void uiControlSetParent(uiControl *, uiContainer *); 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 *); @@ -68,6 +70,42 @@ void uiControlDisable(uiControl *); void uiControlContainerEnable(uiControl *); void uiControlContainerDisable(uiControl *); +// uiParent represents an OS control that hosts other OS controls. +// It is used internally by package ui and by implementations. +// uiWindow, uiTab, and uiGroup all use uiParents to store their controls. +struct uiParent { + // Internal points to internal data. + // Do not access or alter this field. + void *Internal; + + // Handle returns the window handle of the uiParent. + // On Windows, this is a HWND. + // On GTK+, this is a GtkContainer. + // On Mac OS X, this is a NSView. + uintptr_t (*Handle)(uiParent *p); +#define uiParentHandle(p) ((*((p)->Handle))((p))) + + // SetChild sets the uiControl that this uiParent relegates. + // It calls uiControl.SetParent(). + void (*SetChild)(uiParent *p, uiControl *child); +#define uiParentSetChild(p, child) ((*((p)->SetChild))((p), (child))) + + // SetMargins sets the margins of the uiParent to the given margins. + // It then updates the uiParent to make the margins take effect. + // The units of the margins are backend-defined. + // The initial margins are all 0. + void (*SetMargins)(uiParent *p, intmax_t left, intmax_t top, intmax_t right, intmax_t bottom); +#define uiParentSetMargins(p, left, top, right, bottom) ((*((p)->SetMargins))((p), (left), (top), (right), (bottom))) + + // TODO Resize? + + // Update tells the uiParent to re-layout its children immediately. + // It is called when a widget is shown or hidden or when a control is added or removed from a container such as uiStack. + void (*Update)(uiParent *p); +#define uiParentUpdate(p) ((*((p)->Update))((p))) +}; +uiParent *uiNewParent(uintptr_t); + typedef struct uiWindow uiWindow; uiWindow *uiNewWindow(char *, int, int); void uiWindowDestroy(uiWindow *); |
