Beispiel #1
0
static void borderWindowOpen(uiButton *b, void *data)
{
	uiWindow *w;
	uiArea *a;

	if (!borderAHInit) {
		borderAH.Draw = handlerDraw;
		borderAH.MouseEvent = handlerMouseEvent;
		borderAH.MouseCrossed = handlerMouseCrossed;
		borderAH.DragBroken = handlerDragBroken;
		borderAH.KeyEvent = handlerKeyEvent;
		borderAHInit = 1;
	}

	w = uiNewWindow("Border Resize Test", 300, 500, 0);
	uiWindowSetBorderless(w, 1);

	a = uiNewArea(&borderAH);
//	uiWindowSetChild(w, uiControl(a));
{uiBox *b;
b=uiNewHorizontalBox();
uiBoxAppend(b,uiControl(a),1);
uiWindowSetChild(w,uiControl(b));}
//TODO why is this hack needed? GTK+ issue

	uiControlShow(uiControl(w));
}
Beispiel #2
0
static Janet janet_ui_horizontal_box(int32_t argc, Janet *argv) {
    janet_fixarity(argc, 0);
    (void) argv;
    assert_inited();
    uiBox *box = uiNewHorizontalBox();
    return janet_ui_handle_to_control(box, &box_td);
}
Beispiel #3
0
static int new_hbox( lua_State* L )
{
	uiBox* b = uiNewHorizontalBox();
	object_create( L, b, uiBoxSignature, control_common, box_functions, 0 );
	if( lua_isboolean( L, 1 ) )
	{
		uiBoxSetPadded( b, lua_toboolean( L, 1 ) );
	}
	return 1;
}
Window::Window(string title)
: title{title},
  mainLayout{uiNewHorizontalBox()},
  histogram(handler, datapoints, color)
{
    mainwin = uiNewWindow(title.c_str(), 640, 480, 0);
	uiWindowSetMargined(mainwin, 1);

	uiBoxSetPadded(mainLayout, 1);
	uiWindowSetChild(mainwin, uiControl(mainLayout));

	typedef void (*callback_handlerdraw_t)(uiAreaHandler*, uiArea*, uiAreaDrawParams*);
    Callback<void(uiAreaHandler*, uiArea*, uiAreaDrawParams*)>::func = std::bind(&Window::handlerDraw, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
    callback_handlerdraw_t handlerDrawFunction = static_cast<callback_handlerdraw_t>(Callback<void(uiAreaHandler*, uiArea*, uiAreaDrawParams*)>::callback);      

	typedef void (*callback_handlermouseevent_t)(uiAreaHandler*, uiArea*, uiAreaMouseEvent*);
    Callback<void(uiAreaHandler*, uiArea*, uiAreaMouseEvent*)>::func = std::bind(&Window::handlerMouseEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
    callback_handlermouseevent_t handlerMouseeventFunction = static_cast<callback_handlermouseevent_t>(Callback<void(uiAreaHandler*, uiArea*, uiAreaMouseEvent*)>::callback);      

    // only draw and mouseEvent are implemented for now
    // they are "filled" by the widgets
	handler.Draw = handlerDrawFunction;
	handler.MouseEvent = handlerMouseeventFunction;
	handler.MouseCrossed = [] (uiAreaHandler *ha, uiArea *a, int left) {};
	handler.DragBroken = [] (uiAreaHandler *ah, uiArea *a) {};
	handler.KeyEvent = [] (uiAreaHandler *ah, uiArea *a, uiAreaKeyEvent *e) {return 0;}; // reject all keys

    // todo: the data should be stored in the histogramm application,
    // not in the window
    // TODO: the datapoints and color are not passed correctly by reference!
    toolbox.attach(mainLayout);

    histogram.attachToolboxController(toolbox);
    histogram.attachHandlerController(this);
    histogram.attach(mainLayout);

    uiWindowOnClosing(mainwin, [](uiWindow *w, void *data) {uiControlDestroy(uiControl(w)); uiQuit(); return 0;}, NULL);

	typedef int (*callback_quitfunction_t)(void*);
    Callback<int(void*)>::func = std::bind(&Window::onQuit, this, std::placeholders::_1);
    callback_quitfunction_t quitFunction = static_cast<callback_quitfunction_t>(Callback<int(void*)>::callback);      
    uiOnShouldQuit(quitFunction, NULL);
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	uiInitOptions o;
	int i;
	const char *err;
	uiWindow *w;
	uiBox *page2, *page3, *page4, *page5;
	uiBox *page6, *page7, *page8, *page9, *page10;
	uiBox *page11, *page12, *page13;
	uiTab *page14;
	uiBox *page15;
	uiBox *page16;
	uiTab *outerTab;
	uiTab *innerTab;
	int nomenus = 0;
	int startspaced = 0;
	int steps = 0;

	newhbox = uiNewHorizontalBox;
	newvbox = uiNewVerticalBox;

	memset(&o, 0, sizeof (uiInitOptions));
	for (i = 1; i < argc; i++)
		if (strcmp(argv[i], "nomenus") == 0)
			nomenus = 1;
		else if (strcmp(argv[i], "startspaced") == 0)
			startspaced = 1;
		else if (strcmp(argv[i], "swaphv") == 0) {
			newhbox = uiNewVerticalBox;
			newvbox = uiNewHorizontalBox;
		} else if (strcmp(argv[i], "steps") == 0)
			steps = 1;
		else {
			fprintf(stderr, "%s: unrecognized option %s\n", argv[0], argv[i]);
			return 1;
		}

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

	if (!nomenus)
		initMenus();

	w = newWindow("Main Window", 320, 240, 1);
	uiWindowOnClosing(w, onClosing, NULL);
	printf("main window %p\n", (void *) w);

	uiOnShouldQuit(onShouldQuit, w);

	mainBox = newHorizontalBox();
	uiWindowSetChild(w, uiControl(mainBox));

	outerTab = newTab();
	uiBoxAppend(mainBox, uiControl(outerTab), 1);

	mainTab = newTab();
	uiTabAppend(outerTab, "Pages 1-5", uiControl(mainTab));

	// page 1 uses page 2's uiGroup
	page2 = makePage2();

	makePage1(w);
	uiTabAppend(mainTab, "Page 1", uiControl(page1));

	uiTabAppend(mainTab, "Page 2", uiControl(page2));

	uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));

	page3 = makePage3();
	uiTabAppend(mainTab, "Page 3", uiControl(page3));

	page4 = makePage4();
	uiTabAppend(mainTab, "Page 4", uiControl(page4));

	page5 = makePage5(w);
	uiTabAppend(mainTab, "Page 5", uiControl(page5));

	innerTab = newTab();
	uiTabAppend(outerTab, "Pages 6-10", uiControl(innerTab));

	page6 = makePage6();
	uiTabAppend(innerTab, "Page 6", uiControl(page6));

	page7 = makePage7();
	uiTabAppend(innerTab, "Page 7", uiControl(page7));

/*	page8 = makePage8();
	uiTabAppend(innerTab, "Page 8", uiControl(page8));

	page9 = makePage9();
	uiTabAppend(innerTab, "Page 9", uiControl(page9));

	page10 = makePage10();
	uiTabAppend(innerTab, "Page 10", uiControl(page10));
*/
	innerTab = newTab();
	uiTabAppend(outerTab, "Pages 11-15", uiControl(innerTab));

//	page11 = makePage11();
//	uiTabAppend(innerTab, "Page 11", uiControl(page11));

	page12 = makePage12();
	uiTabAppend(innerTab, "Page 12", uiControl(page12));

	page13 = makePage13();
	uiTabAppend(innerTab, "Page 13", uiControl(page13));

	page14 = makePage14();
	uiTabAppend(innerTab, "Page 14", uiControl(page14));

	page15 = makePage15(w);
	uiTabAppend(innerTab, "Page 15", uiControl(page15));

	innerTab = newTab();
	uiTabAppend(outerTab, "Pages 16-?", uiControl(innerTab));

	page16 = makePage16();
	uiTabAppend(innerTab, "Page 16", uiControl(page16));

	if (startspaced)
		setSpaced(1);

	uiControlShow(uiControl(w));
	if (!steps)
		uiMain();
	else {
		uiMainSteps();
		while (uiMainStep(1))
			;
	}
	printf("after uiMain()\n");
	freePage16();
	uiUninit();
	printf("after uiUninit()\n");
	return 0;
}
Beispiel #6
0
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;
}
Beispiel #7
0
int main(int argc, char *argv[])
{
	uiInitOptions o;
	int i;
	const char *err;
	uiWindow *w;
	uiBox *page2, *page3, *page4, *page5;
	int nomenus = 0;
	int startspaced = 0;

	newhbox = uiNewHorizontalBox;
	newvbox = uiNewVerticalBox;

	memset(&o, 0, sizeof (uiInitOptions));
	for (i = 1; i < argc; i++)
		if (strcmp(argv[i], "nomenus") == 0)
			nomenus = 1;
		else if (strcmp(argv[i], "startspaced") == 0)
			startspaced = 1;
		else if (strcmp(argv[i], "swaphv") == 0) {
			newhbox = uiNewVerticalBox;
			newvbox = uiNewHorizontalBox;
		} else {
			fprintf(stderr, "%s: unrecognized option %s\n", argv[0], argv[i]);
			return 1;
		}

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

	if (!nomenus)
		initMenus();

	w = newWindow("Main Window", 320, 240, 1);
	uiWindowOnClosing(w, onClosing, NULL);
	printf("main window %p\n", w);

	uiOnShouldQuit(onShouldQuit, w);

	mainBox = newHorizontalBox();
	uiWindowSetChild(w, uiControl(mainBox));

	mainTab = newTab();
	uiBoxAppend(mainBox, uiControl(mainTab), 1);

	// page 1 uses page 2's uiGroup
	page2 = makePage2();

	makePage1(w);
	uiTabAppend(mainTab, "Page 1", uiControl(page1));

	uiTabAppend(mainTab, "Page 2", uiControl(page2));

	uiTabAppend(mainTab, "Empty Page", uiControl(uiNewHorizontalBox()));

	page3 = makePage3();
	uiTabAppend(mainTab, "Page 3", uiControl(page3));

	page4 = makePage4();
	uiTabAppend(mainTab, "Page 4", uiControl(page4));

	page5 = makePage5();
	uiTabAppend(mainTab, "Page 5", uiControl(page5));

	if (startspaced)
		setSpaced(1);

	uiControlShow(uiControl(w));
	uiMain();
	printf("after uiMain()\n");
	uiUninit();
	printf("after uiUninit()\n");
	return 0;
}