From 45cb2890f26fa1114b2a2a0b3feb78da6ae16628 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 11 Jun 2015 16:53:52 -0400 Subject: [PATCH] More stub controls. This just leaves stub uiWindow. --- redo/stubs/datetimepicker.c | 44 ++++++++++++++++++ redo/stubs/entry.c | 82 +++++++++++++++++++++++++++++++++ redo/stubs/group.c | 90 +++++++++++++++++++++++++++++++++++++ redo/stubs/label.c | 48 ++++++++++++++++++++ redo/stubs/progressbar.c | 40 +++++++++++++++++ redo/stubs/radiobuttons.c | 36 +++++++++++++++ redo/stubs/separator.c | 29 ++++++++++++ redo/stubs/slider.c | 64 ++++++++++++++++++++++++++ redo/stubs/spinbox.c | 64 ++++++++++++++++++++++++++ redo/stubs/tab.c | 78 ++++++++++++++++++++++++++++++++ 10 files changed, 575 insertions(+) create mode 100644 redo/stubs/datetimepicker.c create mode 100644 redo/stubs/entry.c create mode 100644 redo/stubs/group.c create mode 100644 redo/stubs/label.c create mode 100644 redo/stubs/progressbar.c create mode 100644 redo/stubs/radiobuttons.c create mode 100644 redo/stubs/separator.c create mode 100644 redo/stubs/slider.c create mode 100644 redo/stubs/spinbox.c create mode 100644 redo/stubs/tab.c diff --git a/redo/stubs/datetimepicker.c b/redo/stubs/datetimepicker.c new file mode 100644 index 00000000..829e0e5d --- /dev/null +++ b/redo/stubs/datetimepicker.c @@ -0,0 +1,44 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct datetimepicker { + uiDateTimePicker d; + OSTYPE OSHANDLE; +}; + +uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker) + +static uintptr_t datetimepickerHandle(uiControl *c) +{ + struct datetimepicker *d = (struct datetimepicker *) c; + + return (uintptr_t) (d->OSHANDLE); +} + +uiDateTimePicker *finishNewDateTimePicker(OSTHING OSARG) +{ + struct datetimepicker *d; + + d = (struct datetimepicker *) MAKE_CONTROL_INSTANCE(uiTypeDateTimePicker()); + + PUT_CODE_HERE; + + uiControl(d)->Handle = datetimepickerHandle; + + return uiDateTimePicker(d); +} + +uiDateTimePicker *uiNewDateTimePicker(void) +{ + return finishNewDateTimePicker(OSARGDATETIME); +} + +uiDateTimePicker *uiNewDatePicker(void) +{ + return finishNewDateTimePicker(OSARGDATEONLY); +} + +uiDateTimePicker *uiNewTimePicker(void) +{ + return finishNewDateTimePicker(OSARGTIMEONLY); +} diff --git a/redo/stubs/entry.c b/redo/stubs/entry.c new file mode 100644 index 00000000..15284161 --- /dev/null +++ b/redo/stubs/entry.c @@ -0,0 +1,82 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct entry { + uiEntry e; + OSTYPE OSHANDLE; + void (*onChanged)(uiEntry *, void *); + void *onChangedData; +}; + +uiDefineControlType(uiEntry, uiTypeEntry, struct entry) + +static uintptr_t entryHandle(uiControl *c) +{ + struct entry *e = (struct entry *) c; + + return (uintptr_t) (e->OSHANDLE); +} + +static void defaultOnChanged(uiEntry *e, void *data) +{ + // do nothing +} + +static char *entryText(uiEntry *ee) +{ + struct entry *e = (struct entry *) ee; + + return PUT_CODE_HERE; +} + +static void entrySetText(uiEntry *ee, const char *text) +{ + struct entry *e = (struct entry *) ee; + + PUT_CODE_HERE; + // don't queue the control for resize; entry sizes are independent of their contents +} + +static void entryOnChanged(uiEntry *ee, void (*f)(uiEntry *, void *), void *data) +{ + struct entry *e = (struct entry *) ee; + + e->onChanged = f; + e->onChangedData = data; +} + +static int entryReadOnly(uiEntry *ee) +{ + struct entry *e = (struct entry *) ee; + + return PUT_CODE_HERE; +} + +static void entrySetReadOnly(uiEntry *ee, int readonly) +{ + struct entry *e = (struct entry *) ee; + WPARAM ro; + + PUT_CODE_HERE; +} + +uiEntry *uiNewEntry(void) +{ + struct entry *e; + + e = (struct entry *) MAKE_CONTROL_INSTANCE(uiTypeEntry()); + + PUT_CODE_HERE; + + e->onChanged = defaultOnChanged; + + uiControl(e)->Handle = entryHandle; + + uiEntry(e)->Text = entryText; + uiEntry(e)->SetText = entrySetText; + uiEntry(e)->OnChanged = entryOnChanged; + uiEntry(e)->ReadOnly = entryReadOnly; + uiEntry(e)->SetReadOnly = entrySetReadOnly; + + return uiEntry(e); +} diff --git a/redo/stubs/group.c b/redo/stubs/group.c new file mode 100644 index 00000000..75a86d18 --- /dev/null +++ b/redo/stubs/group.c @@ -0,0 +1,90 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct group { + uiGroup g; + OSTYPE OSHANDLE; + uiControl *child; + int margined; +}; + +uiDefineControlType(uiGroup, uiTypeGroup, struct group) + +static uintptr_t groupHandle(uiControl *c) +{ + struct group *g = (struct group *) c; + + return (uintptr_t) (g->OSHANDLE); +} + +static void groupContainerUpdateState(uiControl *c) +{ + struct group *g = (struct group *) c; + + if (g->child != NULL) + uiControlUpdateState(g->child); +} + +static char *groupTitle(uiGroup *gg) +{ + struct group *g = (struct group *) gg; + + return PUT_CODE_HERE; +} + +static void groupSetTitle(uiGroup *gg, const char *text) +{ + struct group *g = (struct group *) gg; + + PUT_CODE_HERE; + // changing the text might necessitate a change in the groupbox's size + uiControlQueueResize(uiControl(g)); +} + +static void groupSetChild(uiGroup *gg, uiControl *child) +{ + struct group *g = (struct group *) gg; + + if (g->child != NULL) + uiControlSetParent(g->child, NULL); + g->child = child; + if (g->child != NULL) { + uiControlSetParent(g->child, uiControl(g)); + uiControlQueueResize(g->child); + } +} + +static int groupMargined(uiGroup *gg) +{ + struct group *g = (struct group *) gg; + + return g->margined; +} + +static void groupSetMargined(uiGroup *gg, int margined) +{ + struct group *g = (struct group *) gg; + + g->margined = margined; + uiControlQueueResize(uiControl(g)); +} + +uiGroup *uiNewGroup(const char *text) +{ + struct group *g; + + g = (struct group *) MAKE_CONTROL_INSTANCE(uiTypeGroup()); + + PUT_CODE_HERE; + + uiControl(g)->Handle = groupHandle; + uiControl(g)->ContainerUpdateState = groupContainerUpdateState; + + uiGroup(g)->Title = groupTitle; + uiGroup(g)->SetTitle = groupSetTitle; + uiGroup(g)->SetChild = groupSetChild; + uiGroup(g)->Margined = groupMargined; + uiGroup(g)->SetMargined = groupSetMargined; + + return uiGroup(g); +} diff --git a/redo/stubs/label.c b/redo/stubs/label.c new file mode 100644 index 00000000..04cb0111 --- /dev/null +++ b/redo/stubs/label.c @@ -0,0 +1,48 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct label { + uiLabel l; + OSTYPE OSHANDLE; +}; + +uiDefineControlType(uiLabel, uiTypeLabel, struct label) + +static uintptr_t labelHandle(uiControl *c) +{ + struct label *l = (struct label *) c; + + return (uintptr_t) (l->OSHANDLE); +} + +static char *labelText(uiLabel *ll) +{ + struct label *l = (struct label *) ll; + + return PUT_CODE_HERE; +} + +static void labelSetText(uiLabel *ll, const char *text) +{ + struct label *l = (struct label *) ll; + + PUT_CODE_HERE; + // changing the text might necessitate a change in the label's size + uiControlQueueResize(uiControl(l)); +} + +uiLabel *uiNewLabel(const char *text) +{ + struct label *l; + + l = (struct label *) MAKE_CONTROL_INSTANCE(uiTypeLabel()); + + PUT_CODE_HERE; + + uiControl(l)->Handle = labelHandle; + + uiLabel(l)->Text = labelText; + uiLabel(l)->SetText = labelSetText; + + return uiLabel(l); +} diff --git a/redo/stubs/progressbar.c b/redo/stubs/progressbar.c new file mode 100644 index 00000000..3f6592aa --- /dev/null +++ b/redo/stubs/progressbar.c @@ -0,0 +1,40 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct progressbar { + uiProgressBar p; + OSTYPE OSHANDLE; +}; + +uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar) + +static uintptr_t progressbarHandle(uiControl *c) +{ + struct progressbar *p = (struct progressbar *) c; + + return (uintptr_t) (p->OSHANDLE); +} + +static void progressbarSetValue(uiProgressBar *pp, int value) +{ + struct progressbar *p = (struct progressbar *) pp; + + if (value < 0 || value > 100) + complain("value %d out of range in progressbarSetValue()", value); + PUT_CODE_HERE; +} + +uiProgressBar *uiNewProgressBar(void) +{ + struct progressbar *p; + + p = (struct progressbar *) MAKE_CONTROL_INSTANCE(uiTypeProgressBar()); + + PUT_CODE_HERE; + + uiControl(p)->Handle = progressbarHandle; + + uiProgressBar(p)->SetValue = progressbarSetValue; + + return uiProgressBar(p); +} diff --git a/redo/stubs/radiobuttons.c b/redo/stubs/radiobuttons.c new file mode 100644 index 00000000..57c88337 --- /dev/null +++ b/redo/stubs/radiobuttons.c @@ -0,0 +1,36 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct radiobuttons { + uiRadioButtons r; +}; + +uiDefineControlType(uiRadioButtons, uiTypeRadioButtons, struct radiobuttons) + +static uintptr_t radiobuttonsHandle(uiControl *c) +{ + return 0; +} + +static void radiobuttonsAppend(uiRadioButtons *rr, const char *text) +{ + struct radiobuttons *r = (struct radiobuttons *) rr; + + PUT_CODE_HERE; + uiControlQueueResize(uiControl(r)); +} + +uiRadioButtons *uiNewRadioButtons(void) +{ + struct radiobuttons *r; + + r = (struct radiobuttons *) MAKE_CONTROL_INSTANCE(uiTypeRadioButtons()); + + PUT_CODE_HERE; + + uiControl(r)->Handle = radiobuttonsHandle; + + uiRadioButtons(r)->Append = radiobuttonsAppend; + + return uiRadioButtons(r); +} diff --git a/redo/stubs/separator.c b/redo/stubs/separator.c new file mode 100644 index 00000000..041edecb --- /dev/null +++ b/redo/stubs/separator.c @@ -0,0 +1,29 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct separator { + uiSeparator s; + OSTYPE OSHANDLE; +}; + +uiDefineControlType(uiSeparator, uiTypeSeparator, struct separator) + +static uintptr_t separatorHandle(uiControl *c) +{ + struct separator *s = (struct separator *) c; + + return (uintptr_t) (s->OSHANDLE); +} + +uiSeparator *uiNewHorizontalSeparator(void) +{ + struct separator *s; + + s = (struct separator *) MAKE_CONTROL_INSTANCE(uiTypeSeparator()); + + PUT_CODE_HERE; + + uiControl(s)->Handle = separatorHandle; + + return uiSeparator(s); +} diff --git a/redo/stubs/slider.c b/redo/stubs/slider.c new file mode 100644 index 00000000..e07c9a3e --- /dev/null +++ b/redo/stubs/slider.c @@ -0,0 +1,64 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct slider { + uiSlider s; + OSTYPE OSHANDLE; + void (*onChanged)(uiSlider *, void *); + void *onChangedData; +}; + +uiDefineControlType(uiSlider, uiTypeSlider, struct slider) + +static uintptr_t sliderHandle(uiControl *c) +{ + struct slider *s = (struct slider *) c; + + return (uintptr_t) (s->OSHANDLE); +} + +static void defaultOnChanged(uiSlider *s, void *data) +{ + // do nothing +} + +static intmax_t sliderValue(uiSlider *ss) +{ + struct slider *s = (struct slider *) ss; + + return PUT_CODE_HERE; +} + +static void sliderSetValue(uiSlider *ss, intmax_t value) +{ + struct slider *s = (struct slider *) ss; + + PUT_CODE_HERE; +} + +static void sliderOnChanged(uiSlider *ss, void (*f)(uiSlider *, void *), void *data) +{ + struct slider *s = (struct slider *) ss; + + s->onChanged = f; + s->onChangedData = data; +} + +uiSlider *uiNewSlider(intmax_t min, intmax_t max) +{ + struct slider *s; + + s = (struct slider *) MAKE_CONTROL_INSTANCE(uiTypeSlider()); + + PUT_CODE_HERE; + + s->onChanged = defaultOnChanged; + + uiControl(s)->Handle = sliderHandle; + + uiSlider(s)->Value = sliderValue; + uiSlider(s)->SetValue = sliderSetValue; + uiSlider(s)->OnChanged = sliderOnChanged; + + return uiSlider(s); +} diff --git a/redo/stubs/spinbox.c b/redo/stubs/spinbox.c new file mode 100644 index 00000000..2263c9bd --- /dev/null +++ b/redo/stubs/spinbox.c @@ -0,0 +1,64 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct spinbox { + uiSpinbox s; +}; + +uiDefineControlType(uiSpinbox, uiTypeSpinbox, struct spinbox) + +static uintptr_t spinboxHandle(uiControl *c) +{ + struct spinbox *s = (struct spinbox *) c; + + return PUT_CODE_HERE; +} + +static void defaultOnChanged(uiSpinbox *s, void *data) +{ + // do nothing +} + +static intmax_t spinboxValue(uiSpinbox *ss) +{ + struct spinbox *s = (struct spinbox *) ss; + + return PUT_CODE_HERE; +} + +static void spinboxSetValue(uiSpinbox *ss, intmax_t value) +{ + struct spinbox *s = (struct spinbox *) ss; + + PUT_CODE_HERE; +} + +static void spinboxOnChanged(uiSpinbox *ss, void (*f)(uiSpinbox *, void *), void *data) +{ + struct spinbox *s = (struct spinbox *) ss; + + s->onChanged = f; + s->onChangedData = data; +} + +uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) +{ + struct spinbox *s; + + if (min >= max) + complain("error: min >= max in uiNewSpinbox()"); + + s = (struct spinbox *) MAKE_CONTROL_INSTANCE(uiTypeSpinbox()); + + PUT_CODE_HERE; + + s->onChanged = defaultOnChanged; + + uiControl(s)->Handle = spinboxHandle; + + uiSpinbox(s)->Value = spinboxValue; + uiSpinbox(s)->SetValue = spinboxSetValue; + uiSpinbox(s)->OnChanged = spinboxOnChanged; + + return uiSpinbox(s); +} diff --git a/redo/stubs/tab.c b/redo/stubs/tab.c new file mode 100644 index 00000000..d82cdf25 --- /dev/null +++ b/redo/stubs/tab.c @@ -0,0 +1,78 @@ +// 11 june 2015 +#include "uipriv_OSHERE.h" + +struct tab { + uiTab t; + OSTYPE OSHANDLE; +}; + +uiDefineControlType(uiTab, uiTypeTab, struct tab) + +static uintptr_t tabHandle(uiControl *c) +{ + struct tab *t = (struct tab *) c; + + return (uintptr_t) (t->OSHANDLE); +} + +static void tabAppend(uiTab *tt, const char *name, uiControl *child) +{ + struct tab *t = (struct tab *) tt; + + uiTabInsertAt(tt, name, PUT_CODE_HERE, child); +} + +static void tabInsertAt(uiTab *tt, const char *name, uintmax_t n, uiControl *child) +{ + struct tab *t = (struct tab *) tt; + + PUT_CODE_HERE; +} + +static void tabDelete(uiTab *tt, uintmax_t n) +{ + struct tab *t = (struct tab *) tt; + + PUT_CODE_HERE; +} + +static uintmax_t tabNumPages(uiTab *tt) +{ + struct tab *t = (struct tab *) tt; + + return PUT_CODE_HERE; +} + +static int tabMargined(uiTab *tt, uintmax_t n) +{ + struct tab *t = (struct tab *) tt; + + return PUT_CODE_HERE; +} + +static void tabSetMargined(uiTab *tt, uintmax_t n, int margined) +{ + struct tab *t = (struct tab *) tt; + + PUT_CODE_HERE; +} + +uiTab *uiNewTab(void) +{ + struct tab *t; + + t = (struct tab *) MAKE_CONTROL_INSTANCE(uiTypeTab()); + + PUT_CODE_HERE; + + uiControl(t)->Handle = tabHandle; + + uiTab(t)->Append = tabAppend; + uiTab(t)->InsertAt = tabInsertAt; + uiTab(t)->Delete = tabDelete; + uiTab(t)->NumPages = tabNumPages; + uiTab(t)->Margined = tabMargined; + uiTab(t)->SetMargined = tabSetMargined; + + return uiTab(t); +}