Example #1
0
uiBox *makePage10(void)
{
	uiBox *page10;
	uiBox *vbox;
	uiBox *hbox;

	page10 = newVerticalBox();
	vbox = page10;

	hbox = newHorizontalBox();
	uiBoxAppend(vbox, uiControl(hbox), 0);

	textString = uiNewEntry();
	// TODO make it placeholder
	uiEntrySetText(textString, "Enter text here");
	uiBoxAppend(hbox, uiControl(textString), 1);

	textFontButton = uiNewFontButton();
	uiFontButtonOnChanged(textFontButton, onFontChanged, NULL);
	uiBoxAppend(hbox, uiControl(textFontButton), 1);

	textColorButton = uiNewColorButton();
	uiColorButtonOnChanged(textColorButton, onColorChanged, NULL);
	uiBoxAppend(hbox, uiControl(textColorButton), 1);

	hbox = newHorizontalBox();
	uiBoxAppend(vbox, uiControl(hbox), 0);

	textApply = uiNewButton("Apply");
	uiBoxAppend(hbox, uiControl(textApply), 1);

	textWidth = uiNewEntry();
	uiEntrySetText(textWidth, "-1");
	uiBoxAppend(hbox, uiControl(textWidth), 1);

	noZ = uiNewCheckbox("No Z Color");
	uiCheckboxOnToggled(noZ, onNoZ, NULL);
	uiBoxAppend(hbox, uiControl(noZ), 0);

	textAreaHandler.Draw = handlerDraw;
	textAreaHandler.MouseEvent = handlerMouseEvent;
	textAreaHandler.MouseCrossed = handlerMouseCrossed;
	textAreaHandler.DragBroken = handlerDragBroken;
	textAreaHandler.KeyEvent = handlerKeyEvent;
	textArea = uiNewArea(&textAreaHandler);
	uiBoxAppend(vbox, uiControl(textArea), 1);

	// dummy objects to test single-activation
	hbox = newHorizontalBox();
	uiBoxAppend(vbox, uiControl(hbox), 0);
	uiBoxAppend(hbox, uiControl(uiNewFontButton()), 1);
	uiBoxAppend(hbox, uiControl(uiNewColorButton()), 1);

	return page10;
}
Example #2
0
static uiControl *testControl(const char *label, int color)
{
	uiColorButton *b;

	b = uiNewColorButton();
	uiColorButtonSetColor(b, colors[color].r, colors[color].g, colors[color].b, 1.0);
	return uiControl(b);
}
Example #3
0
static void openTestWindow(uiBox *(*mkf)(void))
{
	uiWindow *w;
	uiBox *b;
	uiCombobox *c;
	uiEditableCombobox *e;
	uiRadioButtons *r;

	w = uiNewWindow("Test", 100, 100, 0);
	uiWindowOnClosing(w, winClose, NULL);
	uiWindowSetMargined(w, 1);
	b = (*mkf)();
	uiWindowSetChild(w, uiControl(b));

#define BA(x) uiBoxAppend(b, uiControl(x), 0)
	BA(uiNewButton(""));
	BA(uiNewCheckbox(""));
	BA(uiNewEntry());
	BA(uiNewLabel(""));
	BA(uiNewSpinbox(0, 100));
	BA(uiNewProgressBar());
	BA(uiNewSlider(0, 100));
	BA(uiNewHorizontalSeparator());
	c = uiNewCombobox();
	uiComboboxAppend(c, "");
	BA(c);
	e = uiNewEditableCombobox();
	uiEditableComboboxAppend(e, "");
	BA(e);
	r = uiNewRadioButtons();
	uiRadioButtonsAppend(r, "");
	BA(r);
	BA(uiNewDateTimePicker());
	BA(uiNewDatePicker());
	BA(uiNewTimePicker());
	BA(uiNewMultilineEntry());
	// TODO nonscrolling and scrolling areas?
	BA(uiNewFontButton());
	BA(uiNewColorButton());
	BA(uiNewPasswordEntry());
	BA(uiNewSearchEntry());
	BA(uiNewVerticalSeparator());

	uiControlShow(uiControl(w));
}
Example #4
0
File: main.c Project: CUGLSF/libui
int main(void)
{
	uiInitOptions o;
	const char *err;
	uiMenu *menu;
	uiMenuItem *item;
	uiBox *box;
	uiBox *hbox;
	uiGroup *group;
	uiBox *inner;
	uiBox *inner2;
	uiEntry *entry;
	uiCombobox *cbox;
	uiRadioButtons *rb;
	uiTab *tab;

	memset(&o, 0, sizeof (uiInitOptions));
	err = uiInit(&o);
	if (err != NULL) {
		fprintf(stderr, "error initializing ui: %s\n", err);
		uiFreeInitError(err);
		return 1;
	}

	menu = uiNewMenu("File");
	item = uiMenuAppendItem(menu, "Open");
	uiMenuItemOnClicked(item, openClicked, NULL);
	item = uiMenuAppendItem(menu, "Save");
	uiMenuItemOnClicked(item, saveClicked, NULL);
	item = uiMenuAppendQuitItem(menu);
	uiOnShouldQuit(shouldQuit, NULL);

	menu = uiNewMenu("Edit");
	item = uiMenuAppendCheckItem(menu, "Checkable Item");
	uiMenuAppendSeparator(menu);
	item = uiMenuAppendItem(menu, "Disabled Item");
	uiMenuItemDisable(item);
	item = uiMenuAppendPreferencesItem(menu);

	menu = uiNewMenu("Help");
	item = uiMenuAppendItem(menu, "Help");
	item = uiMenuAppendAboutItem(menu);

	mainwin = uiNewWindow("libui Control Gallery", 640, 480, 1);
	uiWindowSetMargined(mainwin, 1);
	uiWindowOnClosing(mainwin, onClosing, NULL);

	box = uiNewVerticalBox();
	uiBoxSetPadded(box, 1);
	uiWindowSetChild(mainwin, uiControl(box));

	hbox = uiNewHorizontalBox();
	uiBoxSetPadded(hbox, 1);
	uiBoxAppend(box, uiControl(hbox), 1);

	group = uiNewGroup("Basic Controls");
	uiGroupSetMargined(group, 1);
	uiBoxAppend(hbox, uiControl(group), 0);

	inner = uiNewVerticalBox();
	uiBoxSetPadded(inner, 1);
	uiGroupSetChild(group, uiControl(inner));

	uiBoxAppend(inner,
		uiControl(uiNewButton("Button")),
		0);
	uiBoxAppend(inner,
		uiControl(uiNewCheckbox("Checkbox")),
		0);
	entry = uiNewEntry();
	uiEntrySetText(entry, "Entry");
	uiBoxAppend(inner,
		uiControl(entry),
		0);
	uiBoxAppend(inner,
		uiControl(uiNewLabel("Label")),
		0);

	uiBoxAppend(inner,
		uiControl(uiNewHorizontalSeparator()),
		0);

	uiBoxAppend(inner,
		uiControl(uiNewDatePicker()),
		0);
	uiBoxAppend(inner,
		uiControl(uiNewTimePicker()),
		0);
	uiBoxAppend(inner,
		uiControl(uiNewDateTimePicker()),
		0);

	uiBoxAppend(inner,
		uiControl(uiNewFontButton()),
		0);

	uiBoxAppend(inner,
		uiControl(uiNewColorButton()),
		0);

	inner2 = uiNewVerticalBox();
	uiBoxSetPadded(inner2, 1);
	uiBoxAppend(hbox, uiControl(inner2), 1);

	group = uiNewGroup("Numbers");
	uiGroupSetMargined(group, 1);
	uiBoxAppend(inner2, uiControl(group), 0);

	inner = uiNewVerticalBox();
	uiBoxSetPadded(inner, 1);
	uiGroupSetChild(group, uiControl(inner));

	spinbox = uiNewSpinbox(0, 100);
	uiSpinboxOnChanged(spinbox, onSpinboxChanged, NULL);
	uiBoxAppend(inner, uiControl(spinbox), 0);

	slider = uiNewSlider(0, 100);
	uiSliderOnChanged(slider, onSliderChanged, NULL);
	uiBoxAppend(inner, uiControl(slider), 0);

	progressbar = uiNewProgressBar();
	uiBoxAppend(inner, uiControl(progressbar), 0);

	group = uiNewGroup("Lists");
	uiGroupSetMargined(group, 1);
	uiBoxAppend(inner2, uiControl(group), 0);

	inner = uiNewVerticalBox();
	uiBoxSetPadded(inner, 1);
	uiGroupSetChild(group, uiControl(inner));

	cbox = uiNewCombobox();
	uiComboboxAppend(cbox, "Combobox Item 1");
	uiComboboxAppend(cbox, "Combobox Item 2");
	uiComboboxAppend(cbox, "Combobox Item 3");
	uiBoxAppend(inner, uiControl(cbox), 0);

	cbox = uiNewEditableCombobox();
	uiComboboxAppend(cbox, "Editable Item 1");
	uiComboboxAppend(cbox, "Editable Item 2");
	uiComboboxAppend(cbox, "Editable Item 3");
	uiBoxAppend(inner, uiControl(cbox), 0);

	rb = uiNewRadioButtons();
	uiRadioButtonsAppend(rb, "Radio Button 1");
	uiRadioButtonsAppend(rb, "Radio Button 2");
	uiRadioButtonsAppend(rb, "Radio Button 3");
	uiBoxAppend(inner, uiControl(rb), 1);

	tab = uiNewTab();
	uiTabAppend(tab, "Page 1", uiControl(uiNewHorizontalBox()));
	uiTabAppend(tab, "Page 2", uiControl(uiNewHorizontalBox()));
	uiTabAppend(tab, "Page 3", uiControl(uiNewHorizontalBox()));
	uiBoxAppend(inner2, uiControl(tab), 1);

	uiControlShow(uiControl(mainwin));
	uiMain();
	uiUninit();
	return 0;
}
Example #5
0
static int new_colorbutton( lua_State* L )
{
	object_create( L, uiNewColorButton(), uiColorButtonSignature, control_common, colorbutton_functions, 0 );
	return 1;
}
Example #6
0
static uiControl *assorted(void)
{
	uiGrid *outergrid;
	uiGrid *innergrid;
	uiButton *b;

	outergrid = newGrid();

	innergrid = newGrid();
	one = uiNewButton("Test");
	uiGridAppend(innergrid, uiControl(one),
		1, 1, 1, 1,
		0, uiAlignFill, 0, uiAlignFill);
	hideOne = uiNewButton("Hide One");
	uiButtonOnClicked(hideOne, onHideOne, NULL);
	uiGridAppend(innergrid, uiControl(hideOne),
		0, 1, 1, 1,
		0, uiAlignFill, 0, uiAlignFill);
	showOne = uiNewButton("Show One");
	uiButtonOnClicked(showOne, onShowOne, NULL);
	uiGridAppend(innergrid, uiControl(showOne),
		2, 1, 1, 1,
		0, uiAlignFill, 0, uiAlignFill);
	b = uiNewButton("Hide All");
	uiButtonOnClicked(b, onHideAll, NULL);
	uiGridAppend(innergrid, uiControl(b),
		1, 0, 1, 1,
		0, uiAlignFill, 0, uiAlignFill);
	b = uiNewButton("Show All");
	uiButtonOnClicked(b, onShowAll, NULL);
	uiGridAppend(innergrid, uiControl(b),
		1, 2, 1, 1,
		0, uiAlignFill, 0, uiAlignFill);
	uiGridAppend(outergrid, uiControl(innergrid),
		0, 0, 1, 1,
		1, uiAlignFill, 1, uiAlignFill);

	innergrid = newGrid();
	b = uiNewButton("Insert Trailing");
	uiButtonOnClicked(b, onInsertTrailing, innergrid);
	uiGridAppend(innergrid, uiControl(b),
		0, 0, 1, 1,
		1, uiAlignFill, 0, uiAlignFill);
	b = uiNewButton("Insert Bottom");
	uiButtonOnClicked(b, onInsertBottom, innergrid);
	uiGridAppend(innergrid, uiControl(b),
		1, 0, 1, 1,
		1, uiAlignFill, 0, uiAlignFill);
	b = uiNewButton("Insert Leading");
	uiButtonOnClicked(b, onInsertLeading, innergrid);
	uiGridAppend(innergrid, uiControl(b),
		1, 1, 1, 1,
		1, uiAlignFill, 0, uiAlignFill);
	b = uiNewButton("Insert Top");
	uiButtonOnClicked(b, onInsertTop, innergrid);
	uiGridAppend(innergrid, uiControl(b),
		0, 1, 1, 1,
		1, uiAlignFill, 0, uiAlignFill);
	uiGridAppend(outergrid, uiControl(innergrid),
		1, 0, 1, 1,
		1, uiAlignFill, 1, uiAlignFill);

	innergrid = newGrid();
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		0, 0, 1, 1,
		1, uiAlignFill, 0, uiAlignFill);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		0, 1, 1, 1,
		1, uiAlignStart, 0, uiAlignFill);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		0, 2, 1, 1,
		1, uiAlignCenter, 0, uiAlignFill);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		0, 3, 1, 1,
		1, uiAlignEnd, 0, uiAlignFill);
	uiGridAppend(outergrid, uiControl(innergrid),
		0, 1, 1, 1,
		1, uiAlignFill, 1, uiAlignFill);

	// TODO with only this, wrong size on OS X — expand sizing thing?
	innergrid = newGrid();
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		0, 0, 1, 1,
		0, uiAlignFill, 1, uiAlignFill);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		1, 0, 1, 1,
		0, uiAlignFill, 1, uiAlignStart);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		2, 0, 1, 1,
		0, uiAlignFill, 1, uiAlignCenter);
	uiGridAppend(innergrid, uiControl(uiNewColorButton()),
		3, 0, 1, 1,
		0, uiAlignFill, 1, uiAlignEnd);
	uiGridAppend(outergrid, uiControl(innergrid),
		1, 1, 1, 1,
		1, uiAlignFill, 1, uiAlignFill);

	return uiControl(outergrid);
}