Started building stubs of the controls so new backends can be added more easily.

This commit is contained in:
Pietro Gagliardi 2015-06-10 23:01:26 -04:00
parent 8d9e229183
commit a019dab679
2 changed files with 149 additions and 0 deletions

66
redo/stubs/button.c Normal file
View File

@ -0,0 +1,66 @@
// 10 june 2015
#include "uipriv_OSHERE.h"
struct button {
uiButton b;
OSTYPE OSHANDLE;
void (*onClicked)(uiButton *, void *);
void *onClickedData;
};
uiDefineControlType(uiButton, uiTypeButton, struct button)
static uintptr_t buttonHandle(uiControl *c)
{
struct button *b = (struct button *) c;
return (uintptr_t) (b->OSHANDLE);
}
static void defaultOnClicked(uiButton *b, void *data)
{
// do nothing
}
static char *buttonText(uiButton *bb)
{
struct button *b = (struct button *) bb;
return PUT_CODE_HERE;
}
static void buttonSetText(uiButton *bb, const char *text)
{
struct button *b = (struct button *) bb;
PUT_CODE_HERE;
// changing the text might necessitate a change in the button's size
uiControlQueueResize(uiControl(b));
}
static void buttonOnClicked(uiButton *bb, void (*f)(uiButton *, void *), void *data)
{
struct button *b = (struct button *) bb;
b->onClicked = f;
b->onClickedData = data;
}
uiButton *uiNewButton(const char *text)
{
struct button *b;
b = (struct button *) MAKE_CONTROL_INSTANCE(uiTypeButton());
PUT_CODE_HERE;
b->onClicked = defaultOnClicked;
uiControl(b)->Handle = buttonHandle;
uiButton(b)->Text = buttonText;
uiButton(b)->SetText = buttonSetText;
uiButton(b)->OnClicked = buttonOnClicked;
return uiButton(b);
}

83
redo/stubs/checkbox.c Normal file
View File

@ -0,0 +1,83 @@
// 10 june 2015
#include "uipriv_OSHERE.h"
struct checkbox {
uiCheckbox c;
OSTYPE OSHANDLE;
void (*onToggled)(uiCheckbox *, void *);
void *onToggledData;
};
uiDefineControlType(uiCheckbox, uiTypeCheckbox, struct checkbox)
static uintptr_t checkboxHandle(uiControl *cc)
{
struct checkbox *c = (struct checkbox *) cc;
return (uintptr_t) (c->OSHANDLE);
}
static void defaultOnToggled(uiCheckbox *c, void *data)
{
// do nothing
}
static char *checkboxText(uiCheckbox *cc)
{
struct checkbox *c = (struct checkbox *) cc;
return PUT_CODE_HERE;
}
static void checkboxSetText(uiCheckbox *cc, const char *text)
{
struct checkbox *c = (struct checkbox *) cc;
PUT_CODE_HERE;
// changing the text might necessitate a change in the checkbox's size
uiControlQueueResize(uiControl(c));
}
static void checkboxOnToggled(uiCheckbox *cc, void (*f)(uiCheckbox *, void *), void *data)
{
struct checkbox *c = (struct checkbox *) cc;
c->onToggled = f;
c->onToggledData = data;
}
static int checkboxChecked(uiCheckbox *cc)
{
struct checkbox *c = (struct checkbox *) cc;
return PUT_CODE_HERE;
}
static void checkboxSetChecked(uiCheckbox *cc, int checked)
{
struct checkbox *c = (struct checkbox *) cc;
PUT_CODE_HERE;
}
uiCheckbox *uiNewCheckbox(const char *text)
{
struct checkbox *c;
WCHAR *wtext;
c = (struct checkbox *) MAKE_CONTROL_INSTANCE(uiTypeCheckbox());
PUT_CODE_HERE;
c->onToggled = defaultOnToggled;
uiControl(c)->Handle = checkboxHandle;
uiCheckbox(c)->Text = checkboxText;
uiCheckbox(c)->SetText = checkboxSetText;
uiCheckbox(c)->OnToggled = checkboxOnToggled;
uiCheckbox(c)->Checked = checkboxChecked;
uiCheckbox(c)->SetChecked = checkboxSetChecked;
return uiCheckbox(c);
}