From 80c17ebf715f2a8fd1d3ad0517637ca36c88bae3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 11 Apr 2015 21:53:49 -0400 Subject: [PATCH] Set up the foundation for uiLabel. --- test.c | 33 +++++++++++++++++++++++++++++++++ ui.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/test.c b/test.c index 643d52cb..8cf14d41 100644 --- a/test.c +++ b/test.c @@ -130,12 +130,31 @@ static void disableControl(uiControl *c, void *data) uiControlDisable((uiControl *) data); } +static void getLabelText(uiControl *b, void *data) +{ + char *text; + + text = uiLabelText((uiControl *) data); + uiEntrySetText(e, text); + uiFreeText(text); +} + +static void setLabelText(uiControl *b, void *data) +{ + char *text; + + text = uiEntryText(e); + uiLabelSetText((uiControl *) data, text); + uiFreeText(text); +} + int main(int argc, char *argv[]) { uiInitOptions o; int i; const char *err; uiControl *getButton, *setButton; + uiControl *label; memset(&o, 0, sizeof (uiInitOptions)); for (i = 1; i < argc; i++) @@ -193,6 +212,18 @@ int main(int argc, char *argv[]) uiStackAdd(stacks[3], setButton, 1); uiStackAdd(stacks[0], stacks[3], 0); + label = uiNewLabel("Label"); +/* + stacks[i] = uiNewHorizontalStack(); + getButton = uiNewButton("Get Label Text"); + uiButtonOnClicked(getButton, getLabelText, label); + setButton = uiNewButton("Set Label Text"); + uiButtonOnClicked(setButton, setLabelText, label); + uiStackAdd(stacks[i], getButton, 1); + uiStackAdd(stacks[i], setButton, 1); + uiStackAdd(stacks[0], stacks[i], 0); + i++; +*/ stacks[4] = uiNewHorizontalStack(); uiStackAdd(stacks[4], spaced, 1); getButton = uiNewButton("On"); @@ -238,6 +269,8 @@ int main(int argc, char *argv[]) uiStackAdd(stacks[6], setButton, 1); uiStackAdd(stacks[0], stacks[6], 0); + uiStackAdd(stacks[0], label, 0); + uiWindowShow(w); uiMain(); printf("after uiMain()\n"); diff --git a/ui.h b/ui.h index fb803c49..d856a655 100644 --- a/ui.h +++ b/ui.h @@ -103,4 +103,8 @@ void uiCheckboxOnToggled(uiControl *, void (*)(uiControl *, void *), void *); int uiCheckboxChecked(uiControl *); void uiCheckboxSetChecked(uiControl *, int); +uiControl *uiNewLabel(const char *); +char *uiLabelText(uiControl *); +void uiLabelSetText(uiControl *, const char *); + #endif