More TODO resolution. uiGroup API finished.

This commit is contained in:
Pietro Gagliardi 2015-06-05 17:31:15 -04:00
parent a12326f586
commit f0483f294d
7 changed files with 64 additions and 3 deletions

View File

@ -82,10 +82,12 @@ int main(int argc, char *argv[])
mainTab = newTab(); mainTab = newTab();
uiBoxAppend(mainBox, uiControl(mainTab), 1); uiBoxAppend(mainBox, uiControl(mainTab), 1);
// page 1 uses page 2's uiGroup
page2 = makePage2();
makePage1(w); makePage1(w);
uiTabAppend(mainTab, "Page 1", uiControl(page1)); uiTabAppend(mainTab, "Page 1", uiControl(page1));
page2 = makePage2();
uiTabAppend(mainTab, "Page 2", uiControl(page2)); uiTabAppend(mainTab, "Page 2", uiControl(page2));
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox())); uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));

View File

@ -23,6 +23,7 @@ TEXT(Window, uiWindow, uiWindowTitle, uiWindowSetTitle)
TEXT(Button, uiButton, uiButtonText, uiButtonSetText) TEXT(Button, uiButton, uiButtonText, uiButtonSetText)
TEXT(Checkbox, uiCheckbox, uiCheckboxText, uiCheckboxSetText) TEXT(Checkbox, uiCheckbox, uiCheckboxText, uiCheckboxSetText)
TEXT(Label, uiLabel, uiLabelText, uiLabelSetText) TEXT(Label, uiLabel, uiLabelText, uiLabelSetText)
TEXT(Group, uiGroup, uiGroupTitle, uiGroupSetTitle)
static void onChanged(uiEntry *e, void *data) static void onChanged(uiEntry *e, void *data)
{ {
@ -112,6 +113,15 @@ void makePage1(uiWindow *w)
uiBoxAppend(hbox, uiControl(setButton), 1); uiBoxAppend(hbox, uiControl(setButton), 1);
uiBoxAppend(page1, uiControl(hbox), 0); uiBoxAppend(page1, uiControl(hbox), 0);
hbox = newHorizontalBox();
getButton = uiNewButton("Get Group Text");
uiButtonOnClicked(getButton, getGroupText, page2group);
setButton = uiNewButton("Set Group Text");
uiButtonOnClicked(setButton, setGroupText, page2group);
uiBoxAppend(hbox, uiControl(getButton), 1);
uiBoxAppend(hbox, uiControl(setButton), 1);
uiBoxAppend(page1, uiControl(hbox), 0);
hbox = newHorizontalBox(); hbox = newHorizontalBox();
uiBoxAppend(hbox, uiControl(spaced), 1); uiBoxAppend(hbox, uiControl(spaced), 1);
getButton = uiNewButton("On"); getButton = uiNewButton("On");

View File

@ -1,6 +1,8 @@
// 29 april 2015 // 29 april 2015
#include "test.h" #include "test.h"
uiGroup *page2group;
static uiLabel *movingLabel; static uiLabel *movingLabel;
static uiBox *movingBoxes[2]; static uiBox *movingBoxes[2];
static int movingCurrent; static int movingCurrent;
@ -88,6 +90,7 @@ uiBox *makePage2(void)
page2 = newVerticalBox(); page2 = newVerticalBox();
group = newGroup("Moving Label"); group = newGroup("Moving Label");
page2group = group;
uiBoxAppend(page2, uiControl(group), 0); uiBoxAppend(page2, uiControl(group), 0);
vbox = newVerticalBox(); vbox = newVerticalBox();
uiGroupSetChild(group, uiControl(vbox)); uiGroupSetChild(group, uiControl(vbox));

View File

@ -53,6 +53,9 @@ void setSpaced(int spaced)
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
uiTabSetMargined(uiTab(p), j, spaced); uiTabSetMargined(uiTab(p), j, spaced);
break; break;
case group:
uiGroupSetMargined(uiGroup(p), spaced);
break;
} }
} }
} }
@ -80,6 +83,11 @@ void querySpaced(char out[12]) // more than enough
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
if (uiTabMargined(uiTab(pp), j)) if (uiTabMargined(uiTab(pp), j))
m++; m++;
break;
case group:
if (uiGroupMargined(uiGroup(pp)))
m++;
break;
} }
} }

View File

@ -31,6 +31,7 @@ extern uiBox *page1;
extern void makePage1(uiWindow *); extern void makePage1(uiWindow *);
// page2.c // page2.c
extern uiGroup *page2group;
extern uiBox *makePage2(void); extern uiBox *makePage2(void);
// page3.c // page3.c

View File

@ -149,9 +149,11 @@ interface Tab from Control {
func NewTab(void) *Tab; func NewTab(void) *Tab;
interface Group from Control { interface Group from Control {
// TODO text and settext func Title(void) *char;
func SetTitle(title *const char);
func SetChild(c *Control); func SetChild(c *Control);
// TODO margined and setmargined func Margined(void) int;
func SetMargined(margined int);
}; };
func NewGroup(text *const char) *Group; func NewGroup(text *const char) *Group;

View File

@ -94,6 +94,22 @@ static void groupContainerUpdateState(uiControl *c)
uiControlUpdateState(g->child); uiControlUpdateState(g->child);
} }
static char *groupTitle(uiGroup *gg)
{
struct group *g = (struct group *) gg;
return uiWindowsUtilText(g->hwnd);
}
static void groupSetTitle(uiGroup *gg, const char *text)
{
struct group *g = (struct group *) gg;
uiWindowsUtilSetText(g->hwnd, text);
// changing the text might necessitate a change in the groupbox's size
uiControlQueueResize(uiControl(g));
}
static void groupSetChild(uiGroup *gg, uiControl *child) static void groupSetChild(uiGroup *gg, uiControl *child)
{ {
struct group *g = (struct group *) gg; struct group *g = (struct group *) gg;
@ -107,6 +123,21 @@ static void groupSetChild(uiGroup *gg, uiControl *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) uiGroup *uiNewGroup(const char *text)
{ {
struct group *g; struct group *g;
@ -130,7 +161,11 @@ uiGroup *uiNewGroup(const char *text)
uiControl(g)->CommitDestroy = groupCommitDestroy; uiControl(g)->CommitDestroy = groupCommitDestroy;
uiControl(g)->ContainerUpdateState = groupContainerUpdateState; uiControl(g)->ContainerUpdateState = groupContainerUpdateState;
uiGroup(g)->Title = groupTitle;
uiGroup(g)->SetTitle = groupSetTitle;
uiGroup(g)->SetChild = groupSetChild; uiGroup(g)->SetChild = groupSetChild;
uiGroup(g)->Margined = groupMargined;
uiGroup(g)->SetMargined = groupSetMargined;
return uiGroup(g); return uiGroup(g);
} }