2015-05-29 13:56:11 -05:00
|
|
|
// 26 may 2015
|
2015-10-16 17:31:14 -05:00
|
|
|
#include "../ui.h"
|
2015-05-18 21:32:22 -05:00
|
|
|
#include "uipriv.h"
|
2015-05-18 21:02:37 -05:00
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
void uiControlDestroy(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->Destroy))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
uintptr_t uiControlHandle(uiControl *c)
|
|
|
|
{
|
|
|
|
return (*(c->Handle))(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiControl *uiControlParent(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return (*(c->Parent))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 18:22:21 -05:00
|
|
|
void uiControlSetParent(uiControl *c, uiControl *parent)
|
2015-08-27 11:05:11 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->SetParent))(c, parent);
|
2015-08-27 11:05:11 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 18:22:21 -05:00
|
|
|
int uiControlToplevel(uiControl *c)
|
2015-09-01 15:44:09 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return (*(c->Toplevel))(c);
|
2015-09-01 15:44:09 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 18:22:21 -05:00
|
|
|
int uiControlVisible(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return (*(c->Visible))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
void uiControlShow(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->Show))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
void uiControlHide(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->Hide))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 18:22:21 -05:00
|
|
|
int uiControlEnabled(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
return (*(c->Enabled))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
void uiControlEnable(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->Enable))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2015-08-27 11:05:11 -05:00
|
|
|
void uiControlDisable(uiControl *c)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2016-04-24 18:22:21 -05:00
|
|
|
(*(c->Disable))(c);
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
|
|
|
|
2016-04-24 14:15:36 -05:00
|
|
|
#define uiControlSignature 0x7569436F
|
|
|
|
|
2016-04-24 18:22:21 -05:00
|
|
|
uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const char *typenamestr)
|
2015-05-18 21:02:37 -05:00
|
|
|
{
|
2015-05-29 13:56:11 -05:00
|
|
|
uiControl *c;
|
2015-05-18 21:02:37 -05:00
|
|
|
|
2016-04-24 16:38:48 -05:00
|
|
|
c = (uiControl *) uiAlloc(size, typenamestr);
|
2016-04-24 14:15:36 -05:00
|
|
|
c->Signature = uiControlSignature;
|
|
|
|
c->OSSignature = OSsig;
|
|
|
|
c->TypeSignature = typesig;
|
2015-08-27 11:05:11 -05:00
|
|
|
return c;
|
2015-05-18 21:02:37 -05:00
|
|
|
}
|
2016-04-24 18:22:21 -05:00
|
|
|
|
|
|
|
void uiFreeControl(uiControl *c)
|
|
|
|
{
|
|
|
|
uiFree(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO except where noted, replace complain() with userbug()
|
|
|
|
|
|
|
|
void uiControlVerifyDestroy(uiControl *c)
|
|
|
|
{
|
|
|
|
if (uiControlParent(c) != NULL)
|
|
|
|
complain("attempt to destroy uiControl %p while it has a parent", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void uiControlVerifySetParent(uiControl *c, uiControl *parent)
|
|
|
|
{
|
|
|
|
uiControl *curParent;
|
|
|
|
|
|
|
|
if (uiControlToplevel(c))
|
|
|
|
complain("cannot set a parent on a toplevel (uiWindow)");
|
|
|
|
curParent = uiControlParent(c);
|
|
|
|
if (parent != NULL && curParent != NULL)
|
|
|
|
complain("attempt to reparent uiControl %p (has parent %p, attempt to give parent %p)", c, curParent, parent);
|
|
|
|
if (parent == NULL && curParent == NULL)
|
|
|
|
// TODO implbug()
|
|
|
|
complain("attempt to double unparent uiControl %p — likely an implementation bug ", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
int uiControlEnabledToUser(uiControl *c)
|
|
|
|
{
|
|
|
|
while (c != NULL) {
|
|
|
|
if (!uiControlEnabled(c))
|
|
|
|
return 0;
|
|
|
|
c = uiControlParent(c);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|