Example #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);
}
Example #2
0
/*
 * Set up main window, draw it.
 */
void ui_main() {

	mainwin = AG_WindowNew(AG_WINDOW_PLAIN);

	plpane = AG_PaneNew(mainwin, AG_PANE_VERT, 0);
	AG_Expand(plpane);

	{
		AG_LabelNew(plpane->div[0], 0, "Playlist");
		playlisttable = AG_TableNewPolled(plpane->div[0], AG_TABLE_EXPAND, update_playlisttable, NULL);
		AG_TableSizeHint(playlisttable, 200, 15);
		AG_SetInt(playlisttable->hbar, "max", 0); /* HURR jak wylaczyc scrollbar?
		//AG_TableAddCol(playlisttable, "id", "<foo>", NULL); */
		AG_TableAddCol(playlisttable, "Artist", "<some lengthy artist name>", NULL);
		AG_TableAddCol(playlisttable, "Title", NULL, NULL);
		AG_TableAddCol(playlisttable, "Length", "<9999:99>", NULL);

		/*AG_TableSetRowDblClickFn(playlisttable, handle_ui_events, "%i,%p", 
			UI_CMD_PLAY_ID, playlisttable ); */
 
		AG_TableSetRowDblClickFn(playlisttable, handle_ui_events, "%i", 
			UI_CMD_PLAY_ID );
		//jak to samo klawiatura osiagnac?*/
		//AG_SetEvent(playlisttable, "window-keydown", keyboard_handler, NULL);

	}	

	{
		AG_LabelNew(plpane->div[1], 0, "Library");
		librarytable = AG_TableNewPolled(plpane->div[1], AG_TABLE_EXPAND, update_librarytable, NULL);		
		AG_SetInt(librarytable->hbar, "max", 0); /* HURR jak wylaczyc scrollbar? */
		AG_TableAddCol(librarytable, "Artist", "<some lengthy artist name>", NULL);
		AG_TableAddCol(librarytable, "Title", NULL, NULL);
		AG_TableAddCol(librarytable, "Length", "<9999:99>", NULL);

		AG_TableSetRowDblClickFn(librarytable, handle_ui_events, "%i", 
			UI_CMD_PLAYLIST_ADD );
	}	

	artistlbl = AG_LabelNewPolled(mainwin, 0, "Artist: %s", &artistBuf);
	titlelbl = AG_LabelNewPolled(mainwin, 0, "Title: %s", &titleBuf);

	buttonbox = AG_BoxNew(mainwin, AG_BOX_HORIZ, 0);
	AG_ExpandHoriz(buttonbox);
	{
		prevbutton = AG_ButtonNewFn(buttonbox, 0, "|<", handle_ui_events, "%i", UI_CMD_PREV);
		stopbutton = AG_ButtonNewFn(buttonbox, 0, "[]", handle_ui_events, "%i", UI_CMD_STOP);
		pausebutton = AG_ButtonNewFn(buttonbox, 0, "||", handle_ui_events, "%i", UI_CMD_PAUSE);
		playbutton = AG_ButtonNewFn(buttonbox, 0, ">", handle_ui_events, "%i", UI_CMD_PLAY);
		nextbutton = AG_ButtonNewFn(buttonbox, 0, ">|", handle_ui_events, "%i", UI_CMD_NEXT);
	}

	statuslbl = AG_LabelNewPolled(mainwin, 0, "Status: %s", &statusBuf);

	AG_WindowMaximize(mainwin);
	AG_WindowShow(mainwin);

}