From d040bca07e157eceb03488d715f91785a5552e85 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 2 Jun 2019 18:49:16 -0400 Subject: [PATCH] Started layout out the uiControl stuff. I forgot to write tests for uiFreeEvent() errors :| --- doc/controls.md | 12 +++++++++--- ui.h | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/controls.md b/doc/controls.md index 2ef5734b..7fbe19ce 100644 --- a/doc/controls.md +++ b/doc/controls.md @@ -8,10 +8,16 @@ TODO ## Reference -### `xxx` +### `uiControl` ```c -TODO +typedef struct uiControl uiControl; +uint32_t uiControlType(void); +#define uiControl(obj) ((uiControl *) uiCheckControlType((obj), uiControlType())) ``` -TODO +`uiControl` is an opaque type that describes a control. + +`uiControl()` is a conversion macro for casting a pointer of a specific control type (or a `void *`) to `uiControl` while also checking for errors. + +`uiControlType()` is the type identifier of a `uiControl` as passed to `uiControlCheckType()`. You rarely need to call this directly; the `uiControl()` conversion macro does this for you. diff --git a/ui.h b/ui.h index 23c02427..276dd358 100644 --- a/ui.h +++ b/ui.h @@ -61,6 +61,11 @@ uiprivExtern void uiEventFire(uiEvent *e, void *sender, void *args); uiprivExtern bool uiEventHandlerBlocked(const uiEvent *e, int id); uiprivExtern void uiEventSetHandlerBlocked(uiEvent *e, int id, bool blocked); +typedef struct uiControl uiControl; + +uiprivExtern uint32_t uiControlType(void); +#define uiControl(obj) ((uiControl *) uiCheckControlType((obj), uiControlType())) + #ifdef __cplusplus } #endif