2015-05-22 18:14:25 -05:00
|
|
|
// 22 may 2015
|
|
|
|
#include "test.h"
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
static uiWindow *parent;
|
|
|
|
|
2015-05-22 18:14:25 -05:00
|
|
|
static void openFile(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
char *fn;
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
fn = uiOpenFile(parent);
|
2015-05-22 18:14:25 -05:00
|
|
|
if (fn == NULL)
|
|
|
|
uiLabelSetText(uiLabel(data), "(cancelled)");
|
|
|
|
else {
|
|
|
|
uiLabelSetText(uiLabel(data), fn);
|
|
|
|
uiFreeText(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 20:59:32 -05:00
|
|
|
static void saveFile(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
char *fn;
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
fn = uiSaveFile(parent);
|
2015-05-22 20:59:32 -05:00
|
|
|
if (fn == NULL)
|
|
|
|
uiLabelSetText(uiLabel(data), "(cancelled)");
|
|
|
|
else {
|
|
|
|
uiLabelSetText(uiLabel(data), fn);
|
|
|
|
uiFreeText(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 14:07:16 -05:00
|
|
|
static uiEntry *title, *description;
|
|
|
|
|
|
|
|
static void msgBox(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
char *t, *d;
|
|
|
|
|
|
|
|
t = uiEntryText(title);
|
|
|
|
d = uiEntryText(description);
|
2015-11-27 22:23:54 -06:00
|
|
|
uiMsgBox(parent, t, d);
|
2015-05-23 14:07:16 -05:00
|
|
|
uiFreeText(d);
|
|
|
|
uiFreeText(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void msgBoxError(uiButton *b, void *data)
|
|
|
|
{
|
|
|
|
char *t, *d;
|
|
|
|
|
|
|
|
t = uiEntryText(title);
|
|
|
|
d = uiEntryText(description);
|
2015-11-27 22:23:54 -06:00
|
|
|
uiMsgBoxError(parent, t, d);
|
2015-05-23 14:07:16 -05:00
|
|
|
uiFreeText(d);
|
|
|
|
uiFreeText(t);
|
|
|
|
}
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
uiBox *makePage5(uiWindow *pw)
|
2015-05-22 18:14:25 -05:00
|
|
|
{
|
|
|
|
uiBox *page5;
|
|
|
|
uiBox *hbox;
|
|
|
|
uiButton *button;
|
|
|
|
uiLabel *label;
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
parent = pw;
|
|
|
|
|
2015-05-22 18:14:25 -05:00
|
|
|
page5 = newVerticalBox();
|
|
|
|
|
|
|
|
#define D(n, f) \
|
|
|
|
hbox = newHorizontalBox(); \
|
|
|
|
button = uiNewButton(n); \
|
|
|
|
label = uiNewLabel(""); \
|
|
|
|
uiButtonOnClicked(button, f, label); \
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0); \
|
2015-06-03 14:19:37 -05:00
|
|
|
uiBoxAppend(hbox, uiControl(label), 0); \
|
2015-05-22 18:14:25 -05:00
|
|
|
uiBoxAppend(page5, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
D("Open File", openFile);
|
2015-05-22 20:59:32 -05:00
|
|
|
D("Save File", saveFile);
|
2015-05-22 18:14:25 -05:00
|
|
|
|
2015-05-23 14:07:16 -05:00
|
|
|
title = uiNewEntry();
|
|
|
|
uiEntrySetText(title, "Title");
|
|
|
|
description = uiNewEntry();
|
|
|
|
uiEntrySetText(description, "Description");
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton("Message Box");
|
|
|
|
uiButtonOnClicked(button, msgBox, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
uiBoxAppend(hbox, uiControl(title), 0);
|
|
|
|
uiBoxAppend(page5, uiControl(hbox), 0);
|
|
|
|
|
|
|
|
hbox = newHorizontalBox();
|
|
|
|
button = uiNewButton("Error Box");
|
|
|
|
uiButtonOnClicked(button, msgBoxError, NULL);
|
|
|
|
uiBoxAppend(hbox, uiControl(button), 0);
|
|
|
|
uiBoxAppend(hbox, uiControl(description), 0);
|
|
|
|
uiBoxAppend(page5, uiControl(hbox), 0);
|
|
|
|
|
2015-05-22 18:14:25 -05:00
|
|
|
return page5;
|
|
|
|
}
|