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
|
|
|
}
|
|
|
|
|
2018-04-16 01:31:24 -05:00
|
|
|
#define uiprivControlSignature 0x7569436F
|
2016-04-24 14:15:36 -05:00
|
|
|
|
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
|
|
|
|
2018-04-15 14:53:27 -05:00
|
|
|
c = (uiControl *) uiprivAlloc(size, typenamestr);
|
2018-04-16 01:31:24 -05:00
|
|
|
c->Signature = uiprivControlSignature;
|
2016-04-24 14:15:36 -05:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (uiControlParent(c) != NULL)
|
2018-04-15 20:46:08 -05:00
|
|
|
uiprivUserBug("You cannot destroy a uiControl while it still has a parent. (control: %p)", c);
|
2018-04-15 14:53:27 -05:00
|
|
|
uiprivFree(c);
|
2016-04-24 18:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiControlVerifySetParent(uiControl *c, uiControl *parent)
|
|
|
|
{
|
|
|
|
uiControl *curParent;
|
|
|
|
|
|
|
|
if (uiControlToplevel(c))
|
2018-04-15 20:46:08 -05:00
|
|
|
uiprivUserBug("You cannot give a toplevel uiControl a parent. (control: %p)", c);
|
2016-04-24 18:22:21 -05:00
|
|
|
curParent = uiControlParent(c);
|
|
|
|
if (parent != NULL && curParent != NULL)
|
2018-04-15 20:46:08 -05:00
|
|
|
uiprivUserBug("You cannot give a uiControl a parent while it already has one. (control: %p; current parent: %p; new parent: %p)", c, curParent, parent);
|
2016-04-24 18:22:21 -05:00
|
|
|
if (parent == NULL && curParent == NULL)
|
2018-04-15 20:46:08 -05:00
|
|
|
uiprivImplBug("attempt to double unparent uiControl %p", c);
|
2016-04-24 18:22:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int uiControlEnabledToUser(uiControl *c)
|
|
|
|
{
|
|
|
|
while (c != NULL) {
|
|
|
|
if (!uiControlEnabled(c))
|
|
|
|
return 0;
|
|
|
|
c = uiControlParent(c);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|