aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl/libui/common/control.c
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-09-09 02:30:51 +0200
committerStapleButter <thetotalworm@gmail.com>2017-09-09 02:30:51 +0200
commit70e4841d311d68689724768157cc9cbfbde7a9fc (patch)
treeba9499f77d1258530a7e60aa6e1732c41d98161c /src/libui_sdl/libui/common/control.c
parent81747d6c34eb159481a6ca3f283d065fa3568617 (diff)
another UI attempt, I guess.
sorry.
Diffstat (limited to 'src/libui_sdl/libui/common/control.c')
-rw-r--r--src/libui_sdl/libui/common/control.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/src/libui_sdl/libui/common/control.c b/src/libui_sdl/libui/common/control.c
new file mode 100644
index 0000000..2806646
--- /dev/null
+++ b/src/libui_sdl/libui/common/control.c
@@ -0,0 +1,101 @@
+// 26 may 2015
+#include "../ui.h"
+#include "uipriv.h"
+
+void uiControlDestroy(uiControl *c)
+{
+ (*(c->Destroy))(c);
+}
+
+uintptr_t uiControlHandle(uiControl *c)
+{
+ return (*(c->Handle))(c);
+}
+
+uiControl *uiControlParent(uiControl *c)
+{
+ return (*(c->Parent))(c);
+}
+
+void uiControlSetParent(uiControl *c, uiControl *parent)
+{
+ (*(c->SetParent))(c, parent);
+}
+
+int uiControlToplevel(uiControl *c)
+{
+ return (*(c->Toplevel))(c);
+}
+
+int uiControlVisible(uiControl *c)
+{
+ return (*(c->Visible))(c);
+}
+
+void uiControlShow(uiControl *c)
+{
+ (*(c->Show))(c);
+}
+
+void uiControlHide(uiControl *c)
+{
+ (*(c->Hide))(c);
+}
+
+int uiControlEnabled(uiControl *c)
+{
+ return (*(c->Enabled))(c);
+}
+
+void uiControlEnable(uiControl *c)
+{
+ (*(c->Enable))(c);
+}
+
+void uiControlDisable(uiControl *c)
+{
+ (*(c->Disable))(c);
+}
+
+#define uiControlSignature 0x7569436F
+
+uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr)
+{
+ uiControl *c;
+
+ c = (uiControl *) uiAlloc(size, typenamestr);
+ c->Signature = uiControlSignature;
+ c->OSSignature = OSsig;
+ c->TypeSignature = typesig;
+ return c;
+}
+
+void uiFreeControl(uiControl *c)
+{
+ if (uiControlParent(c) != NULL)
+ userbug("You cannot destroy a uiControl while it still has a parent. (control: %p)", c);
+ uiFree(c);
+}
+
+void uiControlVerifySetParent(uiControl *c, uiControl *parent)
+{
+ uiControl *curParent;
+
+ if (uiControlToplevel(c))
+ userbug("You cannot give a toplevel uiControl a parent. (control: %p)", c);
+ curParent = uiControlParent(c);
+ if (parent != NULL && curParent != NULL)
+ userbug("You cannot give a uiControl a parent while it already has one. (control: %p; current parent: %p; new parent: %p)", c, curParent, parent);
+ if (parent == NULL && curParent == NULL)
+ implbug("attempt to double unparent uiControl %p", c);
+}
+
+int uiControlEnabledToUser(uiControl *c)
+{
+ while (c != NULL) {
+ if (!uiControlEnabled(c))
+ return 0;
+ c = uiControlParent(c);
+ }
+ return 1;
+}