Example #1
0
static void FileMenu_BootMode(AG_Event *event)
{
	AG_Menu *self = (AG_Menu *)AG_SELF();
	AG_MenuItem *item = (AG_MenuItem *)AG_SENDER();
	AG_Window *w;
	AG_Button   *btn[3];
	AG_Box *box;
	AG_Box *box2;
	char *label;
	AG_Label *lbl;

	w = AG_WindowNew(AG_WINDOW_NOMINIMIZE | AG_WINDOW_NOMAXIMIZE | FILEDIALOG_WINDOW_DEFAULT);
	AG_WindowSetMinSize(w, 230, 80);
	label = gettext("Select mode (Notice: If select , reboot.)");
	AG_WindowSetMinSize(w, 230, 80);
	box = AG_BoxNewHorizNS(w, AG_BOX_HFILL);
	AG_WidgetSetSize(box, 230, 32);
	lbl = AG_LabelNew(AGWIDGET(box), AG_LABEL_EXPAND, "%s", label);
	box = AG_BoxNewVert(w, AG_BOX_HFILL);
	AG_WidgetSetSize(box, 230, 32);

	box2 = AG_BoxNewHoriz(box, 0);
	btn[0] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("BASIC"), SetBootMode, "%i", FALSE);
	box2 = AG_BoxNewVert(box, 0);
	btn[1] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("DOS"), SetBootMode, "%i", TRUE);
	box2 = AG_BoxNewVert(box, 0);
	btn[2] = AG_ButtonNewFn (AGWIDGET(box2), 0, gettext("Cancel"), OnPushCancel, NULL);
    AG_ActionFn(AGWIDGET(w), "window-close", OnPushCancel, NULL);
	AG_WindowSetCaption(w, gettext("Boot Mode"));
	AG_WindowShow(w);

}
Example #2
0
/* Edition routine. */
static void *
Edit(void *obj)
{
	Mammal *mammal = obj;
	AG_Window *win, *winSuper;
	AG_HSVPal *pal;
	AG_ObjectClass *super;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Mammal: %s", AGOBJECT(mammal)->name);

	/* Invoke the "edit" operation of the superclass. */
	super = AG_ObjectSuperclass(mammal);
	if (super->edit != NULL) {
		winSuper = super->edit(mammal);
		AG_WindowSetPosition(winSuper, AG_WINDOW_UPPER_CENTER, 0);
		AG_WindowShow(winSuper);
	}

	/* Allow user to edit paramters specific to this class. */
	AG_LabelNew(win, 0, "Hair color:");
	pal = AG_HSVPalNew(win, AG_HSVPAL_EXPAND);
	AG_BindFloat(pal, "hue", &mammal->hairColor.h);
	AG_BindFloat(pal, "saturation", &mammal->hairColor.s);
	AG_BindFloat(pal, "value", &mammal->hairColor.v);

	return (win);
}
Example #3
0
File: ucombo.c Project: adsr/agar
static void
Expand(AG_Event *event)
{
	AG_UCombo *com = AG_PTR(1);
	AG_Driver *drv = WIDGET(com)->drv;
	int expand = AG_INT(2);
	AG_SizeReq rList;
	int x, y, w, h;
	Uint wView, hView;

	AG_ObjectLock(com);
	if (expand) {
		com->panel = AG_WindowNew(AG_WINDOW_POPUP|AG_WINDOW_MODAL|
		                          AG_WINDOW_NOTITLE);
		AG_ObjectSetName(com->panel, "_UComboPopup");
		AG_WindowSetPadding(com->panel, 0,0,0,0);
		AG_ObjectAttach(com->panel, com->list);
		if (WIDGET(com)->window != NULL)
			AG_WindowAttach(WIDGET(com)->window, com->panel);
	
		if (com->wSaved > 0) {
			w = com->wSaved;
			h = com->hSaved;
		} else {
			if (com->wPreList != -1 && com->hPreList != -1) {
				AG_TlistSizeHintPixels(com->list,
				    com->wPreList, com->hPreList);
			}
			AG_WidgetSizeReq(com->list, &rList);
			w = rList.w + com->panel->wBorderSide*2;
			h = rList.h + com->panel->wBorderBot;
		}
		x = WIDGET(com)->rView.x2 - w;
		y = WIDGET(com)->rView.y1;
		
		AG_GetDisplaySize(WIDGET(com)->drv, &wView, &hView);
		if (x+w > wView) { w = wView - x; }
		if (y+h > hView) { h = hView - y; }
		
		if (AGDRIVER_CLASS(drv)->wm == AG_WM_MULTIPLE &&
		    WIDGET(com)->window != NULL) {
			x += WIDGET(WIDGET(com)->window)->x;
			y += WIDGET(WIDGET(com)->window)->y;
		}
		if (x < 0) { x = 0; }
		if (y < 0) { y = 0; }
		if (w < 4 || h < 4) {
			Collapse(com);
			return;
		}
		AG_SetEvent(com->panel, "window-modal-close",
		    ModalClose, "%p", com);
		AG_WindowSetGeometry(com->panel, x,y, w,h);
		AG_WindowShow(com->panel);
	} else {
		Collapse(com);
	}
	AG_ObjectUnlock(com);
}
Example #4
0
File: osd.c Project: FrMo/gravit
AG_Window *osdNewWindow(const char *title) {
    AG_Window *w = AG_WindowNew(AG_WINDOW_NOMAXIMIZE | AG_WINDOW_NOMINIMIZE | AG_WINDOW_NORESIZE);
    AG_WindowSetCaptionS(w, title);
    AG_WindowSetPadding(w, 8, 8, 8, 8);
    AG_WindowSetSideBorders(w, 1);
    AG_WindowSetBottomBorder(w, 1);
    return w;
}
Example #5
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);

}
Example #6
0
File: unitconv.c Project: adsr/agar
static void
CreateUI(void)
{
	const struct {
		const char *name;
		const AG_Unit *p;
	} units[] = {
		{ "Len", agLengthUnits },
		{ "Ang", agAngleUnits },
		{ "Mass", agMassUnits },
		{ "Area", agAreaUnits },
		{ "Vol", agVolumeUnits },
		{ "Spd", agSpeedUnits },
		{ "Time", agTimeUnits },
		{ "Temp", agTemperatureUnits },
		{ "Pwr", agPowerUnits },
		{ "Press", agPressureUnits },
		{ "Vac", agVacuumUnits },
		{ "Met", agMetabolicExpenditureUnits },
	};
	int i;
	AG_Window *win;
	AG_Toolbar *tb;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Unit Converter");
	AG_WindowSetPadding(win, 10, 10, 10, 10);

	tb = AG_ToolbarNew(win, AG_TOOLBAR_HORIZ, 2, AG_TOOLBAR_HOMOGENOUS|
	                                             AG_TOOLBAR_STICKY|
						     AG_TOOLBAR_HFILL);

	for (i = 0; i < sizeof(units)/sizeof(units[0]); i++) {
		if (i == 6) {
			AG_ToolbarRow(tb, 1);
		}
		AG_ToolbarButton(tb, units[i].name, (i == 0),
		    SelectCategory, "%p", units[i].p);
	}

	AG_SeparatorNewHoriz(win);

	n1 = AG_NumericalNewS(win, AG_NUMERICAL_HFILL, "in", "Value: ");
	n2 = AG_NumericalNewS(win, AG_NUMERICAL_HFILL, "mm", "Value: ");
	AG_BindDouble(n1, "value", &value);
	AG_BindDouble(n2, "value", &value);
	AG_NumericalSizeHint(n1, "0000.00");
	AG_NumericalSizeHint(n2, "0000.00");
	AG_NumericalSetPrecision(n1, "g", 6);
	AG_NumericalSetPrecision(n2, "g", 6);

	AG_WindowShow(win);
}
Example #7
0
	void TestState::enter()
	{
	    int screenWidth = graphicsEngine->getScreenWidth();
		int screenHeight = graphicsEngine->getScreenHeight();

		AG_Window *chatWindow = AG_WindowNewNamed(AG_WINDOW_NOBUTTONS, "ChatWindow");
		AG_WindowSetCaption(chatWindow, "Chat");
		AG_WindowSetSpacing(chatWindow, 5);
		AG_WindowSetGeometry(chatWindow, 10, screenHeight - 185, 400, 175);
		AG_WindowShow(chatWindow);

        AG_Notebook *book = AG_NotebookNew(chatWindow, AG_NOTEBOOK_EXPAND);
        AG_ObjectSetName(book, "ChannelsFolder");
        AG_NotebookTab *nbTab = AG_NotebookAddTab(book, "Global Chat", AG_BOX_VERT);
        AG_ObjectSetName(nbTab, "GlobalChat");

        AG_Console *console = AG_ConsoleNew(nbTab, AG_CONSOLE_EXPAND|AG_CONSOLE_AUTOSCROLL);
        AG_ObjectSetName(console, "Chat");

		AG_Textbox *chatInput = AG_TextboxNewS(chatWindow, AG_TEXTBOX_CATCH_TAB, "");
		AG_TextboxSizeHint(chatInput, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
		AG_SetEvent(chatInput, "textbox-return", submit_chat, "%p%p%p", chatServer, chatInput, console);

		// add elements to interface manager
		interfaceManager->addWindow(chatWindow);

		popUp = AG_WindowNew(AG_WINDOW_NOBUTTONS);
		AG_WindowSetCaption(popUp, "Exit Game");
		AG_WindowSetGeometry(popUp, screenWidth / 2 - 75, screenHeight / 2 - 40, 150, 80);
		AG_WindowHide(popUp);

		AG_Button *logOut = AG_ButtonNewFn(popUp, 0, "Log Out", handle_logout, 0);
		AG_ButtonJustify(logOut, AG_TEXT_CENTER);

		AG_Button *exitGame = AG_ButtonNewFn(popUp, 0, "Exit to Desktop", handle_exit, 0);
		AG_ButtonJustify(exitGame, AG_TEXT_CENTER);

		interfaceManager->addWindow(popUp);

		std::string nick = player->getSelectedCharacter()->getName();
		std::string host = "neo.us.whatnet.org";
		chatServer->setNick(nick);

#ifndef WITHOUT_CHAT
        chatServer->connect(host);
#endif

        // add listener
        interfaceManager->addMouseListener(&handle_mouse);
	}
Example #8
0
static void
SaveColorSchemeDlg(AG_Event *event)
{
	AG_Window *win;
	AG_FileDlg *fd;

	win = AG_WindowNew(0);
	AG_WindowSetCaptionS(win, _("Load color scheme..."));
	fd = AG_FileDlgNewMRU(win, "dev.mru.color-schemes",
	    AG_FILEDLG_CLOSEWIN|AG_FILEDLG_EXPAND);
	AG_FileDlgAddType(fd, _("Agar Color Scheme"), "*.acs",
	    SaveColorSchemeToACS, NULL);
	AG_WindowShow(win);
}
Example #9
0
AGOL_About::AGOL_About()
{
	AboutDialog = AG_WindowNew(AG_WINDOW_MODAL | AG_WINDOW_DIALOG);
	AG_WindowSetCaptionS(AboutDialog, "About The Odamex Launcher");
	AG_WindowSetGeometryAligned(AboutDialog, AG_WINDOW_MC, 350, 400);

	TopBox = CreateTopBox(AboutDialog);
	DevBox = CreateDevBox(AboutDialog);
	LicenseBox = CreateLicenseBox(AboutDialog);
	OKButton = CreateOKButton(AboutDialog);

	CloseEventHandler = NULL;

	AG_WindowShow(AboutDialog);
}
Example #10
0
File: fill.c Project: adsr/agar
AG_Window *
RG_FillEdit(void *p, RG_Tileview *tv)
{
	struct rg_fill_feature *f = p;
	AG_Window *win;
	AG_Box *box;

	win = AG_WindowNew(0);
	AG_WindowSetCaptionS(win, _("Fill/gradient"));

	{
		static const char *modes[] = {
			N_("Solid"),
			N_("Horizontal gradient"),
			N_("Vertical gradient"),
			N_("Circular gradient"),
			N_("Pixmap pattern"),
			NULL
		};
		AG_RadioNewUint(win, AG_RADIO_HFILL, modes, &f->type);
	}

	box = AG_BoxNew(win, AG_BOX_VERT, AG_BOX_HFILL|AG_BOX_VFILL);
	{
		AG_HSVPal *hsv1, *hsv2;
		AG_Numerical *num;
		AG_Notebook *nb;
		AG_NotebookTab *ntab;

		nb = AG_NotebookNew(box, AG_NOTEBOOK_HFILL|AG_NOTEBOOK_VFILL);
		ntab = AG_NotebookAddTab(nb, _("Color A"), AG_BOX_VERT);
		{
			hsv1 = AG_HSVPalNew(ntab, AG_HSVPAL_EXPAND);
			AG_BindUint8(hsv1, "RGBAv", (Uint8 *)&f->f_gradient.c1);
		}

		ntab = AG_NotebookAddTab(nb, _("Color B"), AG_BOX_VERT);
		{
			hsv2 = AG_HSVPalNew(ntab, AG_HSVPAL_EXPAND);
			AG_BindUint8(hsv2, "RGBAv", (Uint8 *)&f->f_gradient.c2);
		}
		
		num = AG_NumericalNewUint8R(box, 0, NULL,
		    _("Overall alpha: "), &f->alpha, 0, 255);
		AG_NumericalSetIncrement(num, 5);
	}
	return (win);
}
Example #11
0
static void
Expand(AG_Event *event)
{
    AG_FileSelector *fs = AG_PTR(1);
    AG_Driver *drv = WIDGET(fs)->drv;
    int expand = AG_INT(2);
    AG_SizeReq rFileDlg;
    int x, y, w, h;
    Uint wView, hView;

    if (expand) {						/* Expand */
        fs->panel = AG_WindowNew(AG_WINDOW_MODAL|AG_WINDOW_NOTITLE);
        AG_WindowSetPadding(fs->panel, 0, 0, 0, 0);
        AG_ObjectAttach(fs->panel, fs->filedlg);

        if (fs->wSaved > 0) {
            w = fs->wSaved;
            h = fs->hSaved;
        } else {
            AG_WidgetSizeReq(fs->filedlg, &rFileDlg);
            w = rFileDlg.w + fs->panel->wBorderSide*2;
            h = rFileDlg.h + fs->panel->wBorderBot;
        }
        x = WIDGET(fs)->rView.x2 - w;
        y = WIDGET(fs)->rView.y1;

        if (AGDRIVER_SINGLE(drv) &&
                AG_GetDisplaySize(drv, &wView, &hView) == 0) {
            if (x+w > wView) {
                w = wView - x;
            }
            if (y+h > hView) {
                h = hView - y;
            }
        }
        if (w < 4 || h < 4) {
            Collapse(fs);
            return;
        }
        AG_SetEvent(fs->panel, "window-modal-close",
                    ModalClose, "%p", fs);
        AG_WindowSetGeometry(fs->panel, x, y, w, h);
        AG_WindowShow(fs->panel);
    } else {
        Collapse(fs);
    }
}
Example #12
0
static void
Fadein(AG_Event *event)
{
	char path[AG_PATHNAME_MAX];
	AG_Window *win;

	win = AG_WindowNew(AG_WINDOW_FADEIN);
	AG_WindowSetFadeIn(win, 1.0f, 0.1f);

	if (!AG_ConfigFile("load-path", "agar", "bmp", path, sizeof(path))) {
		AG_PixmapFromBMP(win, 0, path);
	}
	AG_LabelNew(win, 0, "Testing AG_WINDOW_FADEIN");

	AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Close window", AGWINDETACH(win));
	AG_WindowShow(win);
}
Example #13
0
File: animal.c Project: adsr/agar
/*
 * Edit routine. This is a generic operation that returns a generic pointer,
 * and is not dependent on any particular user interface.
 *
 * This program uses Agar-GUI, so we will return an Agar window.
 */
static void *
Edit(void *obj)
{
	Animal *animal = obj;
	AG_Window *win;
	AG_Numerical *num;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Animal: %s", AGOBJECT(animal)->name);

	num = AG_NumericalNewFlt(win, AG_NUMERICAL_HFILL, "sec",
	    "Age: ", &animal->age);
	num = AG_NumericalNewInt(win, AG_NUMERICAL_HFILL, NULL,
	    "Cell count: ", &animal->cellCount);

	return (win);
}
Example #14
0
static void ErrorPopup(char *message)
{
   AG_Window *win;
   win = AG_WindowNew(0);
   if(win == NULL) {
        if(message == NULL) return;
        XM7_DebugLog(XM7_LOG_INFO, "Error: %s.", message);
        return;
   } else {
      AG_VBox *vb;
      AG_Textbox *tb;
        XM7_DebugLog(XM7_LOG_INFO, "Error: %s.", message);
        vb = AG_VBoxNew(AGWIDGET(win), AG_HBOX_HFILL);
        if(message != NULL) tb = AG_TextboxNew(vb, AG_TEXTBOX_MULTILINE, "%s", message);
        AG_ButtonNewFn(AGWIDGET(vb), 0, gettext("Close"), OnPushCancel, NULL);
        AG_WindowShow(win);
   }
   
}
Example #15
0
static void
SelectPath(AG_Event *event)
{
	char path[AG_PATHNAME_MAX];
	AG_Window *win;
	AG_DirDlg *dd;
	char *key = AG_STRING(1);
	AG_Textbox *tbox = AG_PTR(2);

	win = AG_WindowNew(0);
	dd = AG_DirDlgNew(win, AG_DIRDLG_EXPAND|AG_DIRDLG_CLOSEWIN);
	AG_GetString(agConfig, key, path, sizeof(path));
	if (AG_DirDlgSetDirectoryS(dd, path) == -1) {
		AG_MkPath(path);
		(void)AG_DirDlgSetDirectoryS(dd, path);
	}
	AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 30, 30);
	AG_WindowSetCaption(win, _("Select %s directory"), key);
	AG_DirDlgOkAction(dd, SelectPathOK, "%s,%p,%p", key, tbox, win);
	AG_WindowShow(win);
}
Example #16
0
static void
SelectFontDlg(AG_Event *event)
{
	VG_Text *vt = AG_PTR(1);
	VG_View *vv = AG_PTR(2);
	AG_Window *win, *winParent;
	AG_FontSelector *fs;
	AG_Box *hBox;

	win = AG_WindowNew(0);
	AG_WindowSetCaptionS(win, _("Font selection"));

	fs = AG_FontSelectorNew(win, AG_FONTSELECTOR_EXPAND);

	hBox = AG_BoxNewHoriz(win, AG_BOX_HFILL|AG_BOX_HOMOGENOUS);
	AG_ButtonNewFn(hBox, 0, _("OK"), SelectFont, "%p,%p,%p", vt, win, fs);
	AG_ButtonNewFn(hBox, 0, _("Close"), AG_WindowCloseGenEv, "%p", win);

	AG_WindowShow(win);
	if ((winParent = AG_ParentWindow(vv)) != NULL)
		AG_WindowAttach(winParent, win);
}
Example #17
0
AGOL_Settings::AGOL_Settings() :
	DirSel(NULL), CloseEventHandler(NULL)
{
	SettingsDialog = AG_WindowNew(AG_WINDOW_MODAL);
	AG_WindowSetCaptionS(SettingsDialog, "Configure Settings");

	TopOptionsBox = CreateTopOptionsBox(SettingsDialog);
	SrvOptionsBox = CreateSrvOptionsBox(TopOptionsBox);
	GuiOptionsBox = CreateGuiOptionsBox(TopOptionsBox);
#ifndef GCONSOLE
	OdamexPathBox = CreateOdamexPathBox(SettingsDialog);
	OdamexPathLabel = CreateOdamexPathLabel(OdamexPathBox);
#endif
	WadDirConfigBox = CreateWadDirConfigBox(SettingsDialog);
	WadDirList = CreateWadDirList(WadDirConfigBox);
	WadDirButtonBox = CreateWadDirButtonBox(WadDirConfigBox);
	ExtraCmdParamsBox = CreateExtraCmdParamsBox(SettingsDialog);
	ExtraCmdParamsEntry = CreateExtraCmdParamsEntry(ExtraCmdParamsBox);
	MainButtonBox = CreateMainButtonBox(SettingsDialog);

	AG_WindowShow(SettingsDialog);
}
Example #18
0
static void
CreateTestWindow(AG_Event *event)
{
	MyTestInstance *ti = AG_PTR(1);
	AG_Window *winParent = AG_PTR(2);
	AG_Window *win;

	if ((win = AG_WindowNew(ti->testFlags)) == NULL) {
		TestMsg(ti, "AG_WindowNew() failed: %s", AG_GetError());
		return;
	}
	AG_WindowSetCaption(win, "Test window");
	AG_LabelNewS(win, 0, "This is a test window");
	AG_LabelNew(win, 0, "Flags = 0x%x", ti->testFlags);
	AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Close this window", AGWINDETACH(win));
	AG_WindowAttach(winParent, win);

	if (ti->makeTransient)
		AG_WindowMakeTransient(winParent, win);
	if (ti->makePinned)
		AG_WindowPin(winParent, win);

	AG_WindowShow(win);
}
Example #19
0
static void
SaveToFileDlg(AG_Event *event)
{
	struct test_ops *test = AG_PTR(1);
	AG_Table *t = AG_PTR(2);
	AG_Window *win;
	AG_FileDlg *dlg;
	FILE *f;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Save benchmark results");
	dlg = AG_FileDlgNewMRU(win, "agar-bench.mru.results",
	    AG_FILEDLG_CLOSEWIN);
	AG_FileDlgSetFilename(dlg, "%s.txt", test->name);

	AG_FileDlgAddType(dlg, "ASCII File (comma-separated)", "*.txt",
	    SaveToCSV, "%p,%p,%c", test, t, ':');
	AG_FileDlgAddType(dlg, "ASCII File (tab-separated)", "*.txt",
	    SaveToCSV, "%p,%p,%c", test, t, '\t');
	AG_FileDlgAddType(dlg, "ASCII File (space-separated)", "*.txt",
	    SaveToCSV, "%p,%p,%c", test, t, ' ');
	
	AG_WindowShow(win);
}
Example #20
0
static void
CreateWindow(void)
{
	AG_Window *win;
	AG_Label *lbl;
	AG_Console *cons;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Agar keyboard events demo");
	lbl = AG_LabelNew(win, AG_LABEL_HFILL, "Agar keyboard events demo");
	AG_LabelJustify(lbl, AG_TEXT_CENTER);
	AG_SeparatorNewHoriz(win);

	cons = AG_ConsoleNew(win, AG_CONSOLE_EXPAND);
	AG_ConsoleMsg(cons, "Press any key...");

	/*
	 * Attach our event handler function to both keydown and keyup
	 * events of the Window object. Note that we could have used
	 * any other object derived from the Widget class.
	 */
	AG_SetEvent(win, "key-down", MyKeyboardHandler, "%p", cons);
	AG_SetEvent(win, "key-up", MyKeyboardHandler, "%p", cons);
	
	/*
	 * Enable reception of keydown/keyup events by the window, regardless
	 * of whether it is currently focused or not.
	 */
	AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYUP;
	AGWIDGET(win)->flags |= AG_WIDGET_UNFOCUSED_KEYDOWN;

	AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Quit", Quit, NULL);

	AG_WindowShow(win);
	AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 30, 30);
}
Example #21
0
static void
TestDesktopAlign(AG_Event *event)
{
	AG_Window *winParent = AG_PTR(1);
	AG_Window *win;
	int i;
	
	for (i = 0; i < 2; i++) {
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "Auto%d", i);
			AG_LabelNew(win, 0, "Autopositioned #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_ALIGNMENT_NONE)");
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "TL%d", i);
			AG_LabelNew(win, 0, "Top Left #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_TL)");
			AG_WindowSetPosition(win, AG_WINDOW_TL, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "TC%d", i);
			AG_LabelNew(win, 0, "Top Center #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_TC)");
			AG_WindowSetPosition(win, AG_WINDOW_TC, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "TR%d", i);
			AG_LabelNew(win, 0, "Top Right #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_TR)");
			AG_WindowSetPosition(win, AG_WINDOW_TR, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "MC%d", i);
			AG_LabelNew(win, 0, "Center #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_MC)");
			AG_WindowSetPosition(win, AG_WINDOW_MC, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "BL%d", i);
			AG_LabelNew(win, 0, "Bottom Left #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_BL)");
			AG_WindowSetPosition(win, AG_WINDOW_BL, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "BR%d", i);
			AG_LabelNew(win, 0, "Bottom Right #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_BR)");
			AG_WindowSetPosition(win, AG_WINDOW_BR, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
		if ((win = AG_WindowNew(0))) {
			AG_WindowSetCaption(win, "BC%d", i);
			AG_LabelNew(win, 0, "Bottom Center #%d", i);
			AG_LabelNewS(win, 0, "(AG_WINDOW_BC)");
			AG_WindowSetPosition(win, AG_WINDOW_BC, 1);
			AG_WindowAttach(winParent, win);
			AG_WindowMakeTransient(winParent, win);
			AG_WindowShow(win);
		}
	}
	
	AG_LabelNewS(winParent, 0, "OK");
}
Example #22
0
    void OptionsState::enter()
    {
        int screenWidth = graphicsEngine->getScreenWidth();
		int screenHeight = graphicsEngine->getScreenHeight();
		int halfScreenWidth = screenWidth / 2;
		int halfScreenHeight = screenHeight / 2;

        AG_Window *win = AG_WindowNew(AG_WINDOW_PLAIN|AG_WINDOW_DENYFOCUS);
		AG_WindowShow(win);
		AG_WindowMaximize(win);

		interfaceManager->addWindow(win);

		// create options window
		AG_Window *optionWindow = AG_WindowNewNamed(AG_WINDOW_NOBUTTONS, "OptionWindow");
		AG_WindowSetCaption(optionWindow, "Options");
		AG_WindowSetGeometry(optionWindow, halfScreenWidth - 85, halfScreenHeight - 85, 170, 170);

		// alignment
		AG_VBox *box = AG_VBoxNew(optionWindow, 0);

		// create list of resolutions
		Point pt;
		pt.x = 1024;
		pt.y = 768;
		mRes.push_back(pt);
		pt.x = 800;
		pt.y = 600;
		mRes.push_back(pt);
		pt.x = 1280;
		pt.y = 1024;
		mRes.push_back(pt);
		pt.x = 1440;
		pt.y = 900;
		mRes.push_back(pt);

		// add selection box for resolution
        selectionBox = AG_UComboNew(box, 0);
        AG_ExpandHoriz(selectionBox);
        AG_UComboSizeHint(selectionBox, "Resolution", mRes.size());

        // loop through all the resolutions
        for (unsigned int i = 0; i < mRes.size(); ++i)
        {
            std::stringstream str;
            str << mRes[i].x << " x " << mRes[i].y;
            AG_TlistAddPtr(selectionBox->list, NULL, str.str().c_str(), &mRes[i]);
        }

        AG_TlistSelect(selectionBox->list, AG_TlistFirstItem(selectionBox->list));
        AG_SetEvent(selectionBox, "ucombo-selected", selected_resolution, NULL);

        std::stringstream fs;
        fs << "Fullscreen: " << mFullscreen;
        logger->logDebug(fs.str());

		// add checkbox for fullscreen
        AG_CheckboxNewInt(box, 0, "Fullscreen", &mFullscreen);

        // add checkbox for hardware acceleration
        AG_CheckboxNewInt(box, 0, "OpenGL", &mOpenGL);

        // add radio for languages
        const char *languages[] = { "English", "Portugues", "Espa\xc3\xb1ol", NULL};
        AG_RadioNewInt(box, 0, languages, &mLangs);

        AG_HBox *hbox = AG_HBoxNew(box, 0);
		// add button to apply
		AG_ButtonNewFn(hbox, 0, "Apply", apply_options, "%p%p%p", &mOpenGL, &mFullscreen, &mLangs);

		// add button to cancel
        AG_ButtonNewFn(hbox, 0, "Cancel", cancel_options, 0);

        AG_WindowShow(optionWindow);
        interfaceManager->addWindow(optionWindow);
    }
void OnConfigDisplayMenu(AG_Event *event)
{
	AG_MenuItem *self = (AG_MenuItem *)AG_SELF();
	AG_Window *win;
	AG_Notebook *note;
	AG_Notebook *note2;

	AG_NotebookTab *tab;
	AG_NotebookTab *tab2;
	AG_Box *box;
	AG_Button *btn;
        struct gui_disp *cfg;
	int i, num;
   
        cfg = (struct gui_disp *)malloc(sizeof(struct gui_disp));
        if(cfg == NULL) return;
	{
	  LockVM();
	  cfg->nDrawFPS = configdat.nDrawFPS;
	  cfg->nEmuFPS = configdat.nEmuFPS;
	  cfg->nBrightness = configdat.nBrightness;
	  cfg->nRenderMethod = configdat.nRenderMethod;
	  cfg->uWidth = configdat.uWidth;
	  cfg->uHeight = configdat.uHeight;
	  cfg->bFullScan = configdat.bFullScan;
	  cfg->bFullScanFS = configdat.bFullScanFS;
	  cfg->bSmoosing = configdat.bSmoosing;
	  cfg->bUseSIMD = configdat.bUseSIMD; 
#ifdef _USE_OPENCL
	  cfg->bUseOpenCL = configdat.bUseOpenCL;
	  cfg->nCLGlobalWorkThreads = configdat.nCLGlobalWorkThreads;
	  cfg->bCLSparse = configdat.bCLSparse;
	  cfg->nCLDeviceNum = configdat.nCLDeviceNum;
	  cfg->nCLPlatformNum = configdat.nCLPlatformNum;
	  cfg->bCLInteropGL = configdat.bCLInteropGL;
	  for(i = 0; i <= 8; i++) cfg->sDeviceName[i] = NULL;
	  if(cldraw == NULL) {
	    num = 8;
	  } else {
	    num = cldraw->GetDevices();
	  }
	  if(num >= 8) num = 8;
	  if(num <= 0) num = 0;
	  for(i = 0; i < num; i++) {
	    cfg->sDeviceName[i] = malloc(96 * sizeof(char));
	    cfg->sDeviceName[i][0] = '\0';
	    if(cldraw == NULL) {
	      snprintf(cfg->sDeviceName[i], 94, "Processor #%d", i);
	    } else {
	      char sName[64];
	      char sType[16];
	      cldraw->GetDeviceName(sName, 64, i);
	      cldraw->GetDeviceType(sType, 16, i);
	      snprintf(cfg->sDeviceName[i], 94, "%s(%s)", sType, sName);
	    }
	  }
	  cfg->sDeviceName[8] = NULL;
#endif
	  UnlockVM();
	}

	win= AG_WindowNew(DIALOG_WINDOW_DEFAULT);
        note = AG_NotebookNew(AGWIDGET(win), AG_NOTEBOOK_HFILL);

        {
    	tab = AG_NotebookAddTab(note, gettext("Screen"), AG_BOX_HORIZ);
    	OnConfigMenuScreen(cfg, tab);
#ifdef USE_OPENGL
    	tab = AG_NotebookAddTab(note, gettext("Display"), AG_BOX_HORIZ);
    	ConfigMenuBright(cfg, tab);
#endif /* USE_OPENGL */

#ifdef _USE_OPENCL
    	tab = AG_NotebookAddTab(note, gettext("OpenCL"), AG_BOX_HORIZ);
    	ConfigMenuOpenCL(cfg, tab);
#endif /* USE_OPENGL */
    }
    box = AG_BoxNewHoriz(AGWIDGET(win), AG_BOX_HFILL);
    AG_WidgetSetSize(AGWIDGET(box), 320, 24);
    {
    	AG_Box *vbox;
        vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
    	btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("OK"), OnConfigApplyDisp, "%p", cfg);
        vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
        AG_WidgetSetSize(AGWIDGET(vbox), 80, 24);
        vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
    	btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("Cancel"), OnPushCancel2, "%p", cfg);
    }
    AG_SetEvent(win, "window-close", OnPushCancel2, "%p", cfg);
    AG_WindowSetCaption(win, gettext("Display"));
    AG_WindowShow(win);
}
Example #24
0
File: sdl.c Project: adsr/agar
int
main(int argc, char *argv[])
{
#ifdef HAVE_SDL
	AG_Window *win;
	SDL_Surface *screen, *bmp, *tex1, *tex2, *avatar;
	AG_Surface *agbmp, *agavatar;
	int c, useGL = 0;
	Uint32 sdlFlags = 0;
	char *optArg;
	Uint32 rmask, gmask, bmask, amask;

	if (AG_InitCore("agar-sdl-demo", 0) == -1) {
		fprintf(stderr, "AG_InitCore: %s\n", AG_GetError());
		goto fail;
	}
	while ((c = AG_Getopt(argc, argv, "?g", &optArg, NULL)) != -1) {
		switch (c) {
		case 'g':
			useGL = 1;
			break;
		default:
			printf("Usage: %s [-g]\n", agProgName);
			break;
		}
	}

	/* Set up SDL */
	if (SDL_Init(SDL_INIT_VIDEO) == -1) {
		fprintf(stderr, "SDL_Init: %s\n", SDL_GetError());
		return (1);
	}
	if (useGL) {
		sdlFlags = SDL_RESIZABLE|SDL_OPENGL;
	} else {
		sdlFlags = SDL_RESIZABLE|SDL_SWSURFACE;
	}
	if ((screen = SDL_SetVideoMode(320, 240, 32, sdlFlags)) == NULL) {
		fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError());
		goto fail;
	}

	if (useGL) {
		/* Set up OpenGL viewport and projection. */
		AG_GL_InitContext(AG_RECT(0,0,320,240));
	}

	/* Initialize Agar-GUI to reuse display */
	if (AG_InitVideoSDL(screen, 0) == -1) {
		fprintf(stderr, "%s\n", AG_GetError());
		AG_Destroy();
		goto fail;
	}
	AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_QuitGUI);

	/* Display some test widgets. */
	win = AG_WindowNew(AG_WINDOW_PLAIN);
	AG_LabelNew(win, 0, "Attached to existing %s display",
	    useGL ? "SDL/OpenGL" : "SDL");

	/* Test conversion from SDL_Surface to AG_Surface. */
	if ((bmp = SDL_LoadBMP("agar.bmp")) != NULL) {
		if ((agbmp = AG_SurfaceFromSDL(bmp)) != NULL) {
			AG_PixmapFromSurface(win, 0, agbmp);
		} else {
			AG_LabelNewS(win, 0, AG_GetError());
		}
	}
#ifdef HAVE_SDL_IMAGE
	if ((tex1 = IMG_Load("test1.png")) == NULL ||
	    (tex2 = IMG_Load("test2.png")) == NULL) {
		fprintf(stderr, "IMG_Load() failed\n");
		goto fail;
	}
# if SDL_BYTEORDER == SDL_BIG_ENDIAN
        rmask = 0xff000000;
        gmask = 0x00ff0000;
        bmask = 0x0000ff00;
        amask = 0x000000ff;
# else
        rmask = 0x000000ff;
        gmask = 0x0000ff00;
        bmask = 0x00ff0000;
        amask = 0xff000000;
# endif
	avatar = SDL_CreateRGBSurface(SDL_SWSURFACE|SDL_SRCALPHA, 64, 128,
                tex1->format->BitsPerPixel, rmask, gmask, bmask, amask);
	SDL_SetAlpha(tex1, 0, 0);
        SDL_BlitSurface(tex1, NULL, avatar, NULL);
	SDL_SetAlpha(tex2, SDL_SRCALPHA, 0);
        SDL_BlitSurface(tex2, NULL, avatar, NULL);
	if ((agavatar = AG_SurfaceFromSDL(avatar)) != NULL) {
		AG_PixmapFromSurface(win, 0, agavatar);
	} else {
		AG_LabelNewS(win, 0, AG_GetError());
	}
#endif /* HAVE_SDL_IMAGE */

	AG_WindowShow(win);

	AG_EventLoop();
	AG_Destroy();

	SDL_Quit();
	return (0);
fail:
	SDL_Quit();
	return (1);
#else
	fprintf(stderr, "Agar was compiled without SDL support\n");
	return (1);
#endif /* HAVE_SDL */
}
Example #25
0
void OnConfigSoundMenu(AG_Event *event)
{
	AG_MenuItem *self = (AG_MenuItem *)AG_SELF();
	AG_Window *win;
	AG_Notebook *note;
	AG_Notebook *note2;

	AG_NotebookTab *tab;
	AG_NotebookTab *tab2;
	AG_Box *box;
	AG_Button *btn;
	struct gui_sound *cfg;
	
	cfg = malloc(sizeof(struct gui_sound));
	if(cfg == NULL) return;
	{
	  cfg->iTotalVolume = configdat.iTotalVolume;
	  cfg->nFMVolume = configdat.nFMVolume;
	  cfg->nPSGVolume = configdat.nPSGVolume;
	  cfg->nBeepVolume = configdat.nBeepVolume;
	  cfg->nCMTVolume = configdat.nCMTVolume;
	  cfg->nWaveVolume = configdat.nWaveVolume;
	  cfg->uChSeparation = configdat.uChSeparation;
	  cfg->nSampleRate = configdat.nSampleRate;
	  cfg->nSoundBuffer = configdat.nSoundBuffer;
	  cfg->nBeepFreq = configdat.nBeepFreq;
	  cfg->bFMHQmode = configdat.bFMHQmode;
	  cfg->nStereoOut = configdat.nStereoOut;
	  cfg->bTapeMon = configdat.bTapeMon;
	  cfg->bOPNEnable = configdat.bOPNEnable;
	  cfg->bWHGEnable = configdat.bWHGEnable;
	  cfg->bTHGEnable = configdat.bTHGEnable;
#ifdef FDDSND
	  cfg->bFddSound = configdat.bFddSound;
#endif
	}

	win= AG_WindowNew(DIALOG_WINDOW_DEFAULT);

	note = AG_NotebookNew(AGWIDGET(win), AG_NOTEBOOK_HFILL);
	{
	  tab = AG_NotebookAddTab(note, gettext("Volume"), AG_BOX_VERT);
	  VolumeMenu(tab, cfg);
	  tab = AG_NotebookAddTab(note, gettext("Rendering"), AG_BOX_HORIZ);
	  SoundMenu(tab, cfg);
	  tab = AG_NotebookAddTab(note, gettext("Misc"), AG_BOX_HORIZ);
	  SoundMenu2(tab, cfg);
	}
	box = AG_BoxNewHoriz(AGWIDGET(win), AG_BOX_HFILL);
	AG_WidgetSetSize(AGWIDGET(box), 320, 24);
	{
	  AG_Box *vbox;
	  vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
	  btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("OK"), OnConfigApplySound, "%p", cfg);
	  vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
	  AG_WidgetSetSize(AGWIDGET(vbox), 80, 24);
	  vbox = AG_BoxNewVert(AGWIDGET(box), AG_BOX_VFILL);
	  btn = AG_ButtonNewFn(AGWIDGET(box), 0, gettext("Cancel"), OnPushCancel2, "%p", cfg);
	}
	AG_SetEvent(win, "window-close", OnPushCancel2, "%p", cfg);
	AG_WindowSetCaption(win, gettext("Sound Preferences"));
	AG_WindowShow(win);
}
Example #26
0
/* Callback routine for AG_FileDlg. */
static int
LoadImage(AG_Event *event)
{
/*	AG_FileDlg *fd = AG_SELF(); */
	AG_Window *winParent = AG_PTR(1);
	char *file = AG_STRING(2);
	AG_FileType *ft = AG_PTR(3);
	AG_Surface *s;
	AG_Window *win;
	AG_Scrollview *sv;
	Uint8 *pSrc;
	Uint i;

	if (strcmp(ft->exts[0], "*.bmp") == 0) {
		s = AG_SurfaceFromBMP(file);
	} else if (strcmp(ft->exts[0], "*.jpg") == 0) {
		s = AG_SurfaceFromJPEG(file);
	} else if (strcmp(ft->exts[0], "*.png") == 0) {
		s = AG_SurfaceFromPNG(file);
	} else {
		AG_SetError("Unrecognized format: %s", ft->exts[0]);
		return (-1);
	}
	if (s == NULL)
		return (-1);

	if ((win = AG_WindowNew(0)) == NULL) {
		AG_SurfaceFree(s);
		return (-1);
	}
	AG_WindowSetCaption(win, "Image <%s>", AG_ShortFilename(file));

	/* We use AG_FileOptionFoo() to retrieve per-type options. */
	if (AG_FileOptionBool(ft,"invert")) {
		pSrc = (Uint8 *)s->pixels;
		for (i = 0; i < s->w*s->h; i++) {
			Uint8 r, g, b;

			AG_GetPixelRGB(AG_GET_PIXEL(s,pSrc), s->format,
			    &r,&g,&b);
			r = 255 - r;
			g = 255 - g;
			b = 255 - b;
			AG_PUT_PIXEL(s, pSrc,
			    AG_MapPixelRGB(s->format, r,g,b));
			pSrc += s->format->BytesPerPixel;
		}
	}

	/*
	 * Place an AG_Pixmap(3) widget inside of an AG_Scrollview(3) so
	 * the user can pan the view.
	 */
	sv = AG_ScrollviewNew(win, AG_SCROLLVIEW_BY_MOUSE|AG_SCROLLVIEW_EXPAND);
	AG_PixmapFromSurfaceScaled(sv, 0, s, s->w, s->h);
	AG_SurfaceFree(s);

	AG_WindowSetGeometry(win, -1, -1, 320, 240);
	AG_WindowAttach(winParent, win);
	AG_WindowShow(win);

	return (0);
}