More TODO resolution. uiGroup API finished.
This commit is contained in:
parent
a12326f586
commit
f0483f294d
|
@ -82,10 +82,12 @@ int main(int argc, char *argv[])
|
|||
mainTab = newTab();
|
||||
uiBoxAppend(mainBox, uiControl(mainTab), 1);
|
||||
|
||||
// page 1 uses page 2's uiGroup
|
||||
page2 = makePage2();
|
||||
|
||||
makePage1(w);
|
||||
uiTabAppend(mainTab, "Page 1", uiControl(page1));
|
||||
|
||||
page2 = makePage2();
|
||||
uiTabAppend(mainTab, "Page 2", uiControl(page2));
|
||||
|
||||
uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));
|
||||
|
|
|
@ -23,6 +23,7 @@ TEXT(Window, uiWindow, uiWindowTitle, uiWindowSetTitle)
|
|||
TEXT(Button, uiButton, uiButtonText, uiButtonSetText)
|
||||
TEXT(Checkbox, uiCheckbox, uiCheckboxText, uiCheckboxSetText)
|
||||
TEXT(Label, uiLabel, uiLabelText, uiLabelSetText)
|
||||
TEXT(Group, uiGroup, uiGroupTitle, uiGroupSetTitle)
|
||||
|
||||
static void onChanged(uiEntry *e, void *data)
|
||||
{
|
||||
|
@ -112,6 +113,15 @@ void makePage1(uiWindow *w)
|
|||
uiBoxAppend(hbox, uiControl(setButton), 1);
|
||||
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();
|
||||
uiBoxAppend(hbox, uiControl(spaced), 1);
|
||||
getButton = uiNewButton("On");
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// 29 april 2015
|
||||
#include "test.h"
|
||||
|
||||
uiGroup *page2group;
|
||||
|
||||
static uiLabel *movingLabel;
|
||||
static uiBox *movingBoxes[2];
|
||||
static int movingCurrent;
|
||||
|
@ -88,6 +90,7 @@ uiBox *makePage2(void)
|
|||
page2 = newVerticalBox();
|
||||
|
||||
group = newGroup("Moving Label");
|
||||
page2group = group;
|
||||
uiBoxAppend(page2, uiControl(group), 0);
|
||||
vbox = newVerticalBox();
|
||||
uiGroupSetChild(group, uiControl(vbox));
|
||||
|
|
|
@ -53,6 +53,9 @@ void setSpaced(int spaced)
|
|||
for (j = 0; j < n; j++)
|
||||
uiTabSetMargined(uiTab(p), j, spaced);
|
||||
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++)
|
||||
if (uiTabMargined(uiTab(pp), j))
|
||||
m++;
|
||||
break;
|
||||
case group:
|
||||
if (uiGroupMargined(uiGroup(pp)))
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ extern uiBox *page1;
|
|||
extern void makePage1(uiWindow *);
|
||||
|
||||
// page2.c
|
||||
extern uiGroup *page2group;
|
||||
extern uiBox *makePage2(void);
|
||||
|
||||
// page3.c
|
||||
|
|
|
@ -149,9 +149,11 @@ interface Tab from Control {
|
|||
func NewTab(void) *Tab;
|
||||
|
||||
interface Group from Control {
|
||||
// TODO text and settext
|
||||
func Title(void) *char;
|
||||
func SetTitle(title *const char);
|
||||
func SetChild(c *Control);
|
||||
// TODO margined and setmargined
|
||||
func Margined(void) int;
|
||||
func SetMargined(margined int);
|
||||
};
|
||||
func NewGroup(text *const char) *Group;
|
||||
|
||||
|
|
|
@ -94,6 +94,22 @@ static void groupContainerUpdateState(uiControl *c)
|
|||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
struct group *g;
|
||||
|
@ -130,7 +161,11 @@ uiGroup *uiNewGroup(const char *text)
|
|||
uiControl(g)->CommitDestroy = groupCommitDestroy;
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue