예제 #1
0
static void
MainWindow(void)
{
	AG_Window *win;
	AG_Table *t;
	AG_Button *btn;
	AG_Notebook *nb;
	AG_NotebookTab *ntab;
	AG_HBox *hbox;
	int i, j;

	win = AG_WindowNewNamedS(0, "agar-benchmarks");
	AG_WindowSetCaption(win, "Agar Benchmarks");

	nb = AG_NotebookNew(win, AG_NOTEBOOK_HFILL|AG_NOTEBOOK_VFILL);
	for (i = 0; i < ntests; i++) {
		struct test_ops *test = tests[i];

		ntab = AG_NotebookAddTab(nb, test->name, AG_BOX_VERT);
		t = AG_TableNewPolled(ntab, AG_TABLE_MULTI|AG_TABLE_EXPAND,
		    poll_test, "%i", i);

		AG_TableAddCol(t, "Test", "70%", NULL);
		AG_TableAddCol(t, "Min", "10%", NULL);
		AG_TableAddCol(t, "Avg", "10%", NULL);
		AG_TableAddCol(t, "Max", "10%", NULL);
		AG_TableAddCol(t, NULL, NULL, NULL);
	
		hbox = AG_HBoxNew(ntab, AG_HBOX_HOMOGENOUS|AG_HBOX_HFILL);
		{
			btn = AG_ButtonNewS(hbox, 0, "Run tests");
			AG_SetEvent(btn, "button-pushed", RunTests,
			    "%p,%p", test, t);
	
			btn = AG_ButtonNewS(hbox, 0, "Save results");
			AG_SetEvent(btn, "button-pushed", SaveToFileDlg,
			    "%p,%p", test, t);
	
			btn = AG_ButtonNewS(hbox, 0, "Quit");
			AG_SetEvent(btn, "button-pushed", QuitApp, NULL);
		}
	
		for (j = 0; j < test->nfuncs; j++) {
			struct testfn_ops *fn = &test->funcs[j];

			fn->clksMin = 0;
			fn->clksAvg = 0;
			fn->clksMax = 0;
		}
	}

	AG_WindowSetGeometryAligned(win, AG_WINDOW_MC,
	    agView->w-20, agView->h-20);
	AG_WindowShow(win);
}
예제 #2
0
파일: button.c 프로젝트: varialus/agar
AG_Button *
AG_ButtonNewUint8(void *parent, Uint flags, const char *caption, Uint8 *v)
{
	AG_Button *bu = AG_ButtonNewS(parent, flags, caption);
	AG_BindUint8(bu, "state", v);
	return (bu);
}
예제 #3
0
static void
Init(void *obj)
{
    AG_FileSelector *fs = obj;

    fs->flags = 0;
    fs->panel = NULL;
    fs->wSaved = 0;
    fs->hSaved = 0;
    fs->inTxt[0] = '\0';

    /* XXX TODO: Check for UTF-8 support in filesystem. */
    fs->tbox = AG_TextboxNewS(fs, AG_TEXTBOX_COMBO|AG_TEXTBOX_EXCL, NULL);
    AG_TextboxBindUTF8(fs->tbox, fs->inTxt, sizeof(fs->inTxt));

    fs->button = AG_ButtonNewS(fs, AG_BUTTON_STICKY, _("Browse..."));
    AG_ButtonSetPadding(fs->button, 1,1,1,1);
    AG_WidgetSetFocusable(fs->button, 0);

    fs->filedlg = Malloc(sizeof(AG_FileDlg));
    AG_ObjectInit(fs->filedlg, &agFileDlgClass);
    AG_Expand(fs->filedlg);

    AG_SetEvent(fs->button, "button-pushed", Expand, "%p", fs);
    AG_SetEvent(fs->filedlg, "file-chosen", FileChosen, "%p", fs);
    AG_SetEvent(fs->tbox, "textbox-return", Return, "%p", fs);
}
예제 #4
0
파일: button.c 프로젝트: varialus/agar
AG_Button *
AG_ButtonNewFlag32(void *parent, Uint flags, const char *caption,
    Uint32 *p, Uint32 bitmask)
{
	AG_Button *bu = AG_ButtonNewS(parent, flags, caption);
	AG_BindFlag32(bu, "state", p, bitmask);
	return (bu);
}
예제 #5
0
파일: titlebar.c 프로젝트: varialus/agar
static void
CreateCloseButton(AG_Titlebar *tbar)
{
	tbar->close_btn = AG_ButtonNewS(tbar, 0, NULL);
	AG_ButtonJustify(tbar->close_btn, AG_TEXT_LEFT);
	AG_ButtonSetFocusable(tbar->close_btn, 0);
	AG_ButtonSurfaceNODUP(tbar->close_btn, agIconWinClose.s);
	AG_ButtonSetPadding(tbar->close_btn, 0,0,0,0);
	AG_SetEvent(tbar->close_btn, "button-pushed",
	    CloseWindow, "%p", tbar);
}
예제 #6
0
파일: button.c 프로젝트: varialus/agar
AG_Button *
AG_ButtonNewFn(void *parent, Uint flags, const char *caption, AG_EventFn fn,
    const char *fmt, ...)
{
	AG_Button *bu;
	AG_Event *ev;

	if (!(flags & AG_BUTTON_NOEXCL)) { flags |= AG_BUTTON_EXCL;  }
	bu = AG_ButtonNewS(parent, flags, caption);
	ev = AG_SetEvent(bu, "button-pushed", fn, NULL);
	AG_EVENT_GET_ARGS(ev, fmt);
	return (bu);
}
예제 #7
0
파일: button.c 프로젝트: varialus/agar
AG_Button *
AG_ButtonNew(void *parent, Uint flags, const char *fmt, ...)
{
	va_list ap;
	char *s;
	
	if (fmt != NULL) {
		va_start(ap, fmt);
		Vasprintf(&s, fmt, ap);
		va_end(ap);
	} else {
		s = NULL;
	}
	return AG_ButtonNewS(parent, flags, s);
}
예제 #8
0
파일: ucombo.c 프로젝트: adsr/agar
static void
Init(void *obj)
{
	AG_UCombo *com = obj;

	WIDGET(com)->flags |= AG_WIDGET_UNFOCUSED_BUTTONUP|
	                      AG_WIDGET_TABLE_EMBEDDABLE;

	com->flags = 0;
	com->panel = NULL;
	com->wSaved = 0;
	com->hSaved = 0;
	com->wPreList = -1;
	com->hPreList = -1;

	com->button = AG_ButtonNewS(com, AG_BUTTON_STICKY, _("..."));
	AG_ButtonSetPadding(com->button, 0,0,0,0);
	AG_LabelSetPadding(com->button->lbl, 0,0,0,0);
	AG_WidgetSetFocusable(com->button, 0);
	
	com->list = Malloc(sizeof(AG_Tlist));
	AG_ObjectInit(com->list, &agTlistClass);
	AG_Expand(com->list);
	AG_WidgetForwardFocus(com, com->button);
	
	AG_SetEvent(com, "detached", OnDetach, NULL);
	AG_SetEvent(com->button, "button-pushed", Expand, "%p", com);
	AG_SetEvent(com->list, "tlist-changed", SelectedItem, "%p", com);

#ifdef AG_DEBUG
	AG_BindUint(com, "flags", &com->flags);
	AG_BindPointer(com, "list", (void *)&com->list);
	AG_BindPointer(com, "panel", (void *)&com->panel);
	AG_BindInt(com, "wSaved", &com->wSaved);
	AG_BindInt(com, "hSaved", &com->hSaved);
	AG_BindInt(com, "wPreList", &com->wPreList);
	AG_BindInt(com, "hPreList", &com->hPreList);
#endif
}