AG_Box *AGOL_Settings::CreateWadDirButtonBox(void *parent) { AG_Box *bbox; bbox = AG_BoxNewVert(parent, AG_BOX_VFILL); AG_ButtonNewFn(bbox, AG_BUTTON_HFILL, "Add", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnAddWadDir)); AG_ButtonNewFn(bbox, AG_BUTTON_HFILL, "Replace", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnReplaceWadDir)); AG_ButtonNewFn(bbox, AG_BUTTON_HFILL, "Delete", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnDeleteWadDir)); AG_SeparatorNewHoriz(bbox); AG_ButtonNewFn(bbox, AG_BUTTON_HFILL, "Move Up", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnMoveWadDirUp)); AG_ButtonNewFn(bbox, AG_BUTTON_HFILL, "Move Down", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnMoveWadDirDown)); #ifndef GCONSOLE AG_SeparatorNewHoriz(bbox); AG_ButtonNew(bbox, AG_BUTTON_HFILL, "Get Environment"); #endif return bbox; }
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); }
static int TestGUI(void *obj, AG_Window *win) { char path[AG_PATHNAME_MAX]; AG_TestInstance *ti = obj; AG_Box *box; AG_Textbox *tb; someString[0] = '\0'; AG_GetString(agConfig, "load-path", path, sizeof(path)); AG_LabelNew(win, 0, "load-path: %s", path); AG_GetString(agConfig, "save-path", path, sizeof(path)); AG_LabelNew(win, 0, "save-path: %s", path); /* Tie some globals to the config settings */ AG_BindInt(agConfig, "some-int", &someInt); AG_BindInt(agConfig, "some-bool", &someBool); AG_BindString(agConfig, "some-string", someString, sizeof(someString)); AG_SetInt(agConfig, "some-int", 2345); /* Create some widgets */ AG_NumericalNewInt(win, 0, NULL, "Some int: ", &someInt); AG_CheckboxNewInt(win, 0, "Some bool", &someBool); tb = AG_TextboxNew(win, AG_TEXTBOX_HFILL, "Some string: "); AG_TextboxBindUTF8(tb, someString, sizeof(someString)); box = AG_BoxNewHoriz(win, AG_BOX_EXPAND); { AG_ButtonNewFn(box, 0, "Load configuration", LoadConfig, "%p", ti); AG_ButtonNewFn(box, 0, "Save configuration", SaveConfig, "%p", ti); } return (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); }
void osdInitPlaybackWindow() { AG_Box *box; view.playbackWindow = osdNewWindow("Quick Controls"); box = AG_BoxNewHoriz(view.playbackWindow, AG_BOX_EXPAND); // The labels for Record and Pause are the "longest legnth" versions of the // state of the button, so that no button resizing is necessary. AG_ButtonNewFn(box, 0, "Respawn", osdHandleRespawn, 0); AG_SpacerNewVert(box); view.recordButton = AG_ButtonNewFn(box, 0, "Record", osdHandleRecord, 0); AG_ButtonNewFn(box, 0, "<<", osdHandleFirst, 0); AG_ButtonNewFn(box, AG_BUTTON_REPEAT, "<", osdHandlePrev, 0); view.playButton = AG_ButtonNewFn(box, 0, "Pause", osdHandlePlay, 0); AG_ButtonNewFn(box, AG_BUTTON_REPEAT, ">", osdHandleNext, 0); AG_ButtonNewFn(box, 0, ">>", osdHandleLast, 0); AG_SpacerNewVert(box); AG_ButtonNewFn(box, 0, "Quit", osdHandleQuit, 0); AG_WindowSetPosition(view.playbackWindow, AG_WINDOW_TR, 0); AG_WindowShow(view.playbackWindow); osdUpdate(); }
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); }
AG_Box *AGOL_Settings::CreateMainButtonBox(void *parent) { AG_Box *bbox; bbox = AG_BoxNewHoriz(parent, AG_BOX_HFILL); // This empty box positions the buttons to the right AG_BoxNewHoriz(bbox, AG_BOX_HFILL); AG_ButtonNewFn(bbox, 0, "Cancel", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnCancel)); AG_ButtonNewFn(bbox, 0, " OK ", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnOK)); return bbox; }
static void * Edit(void *p, VG_View *vv) { VG_Text *vt = p; AG_Box *box = AG_BoxNewVert(NULL, AG_BOX_EXPAND); AG_Pane *vPane; AG_Textbox *tb; AG_Box *bAl, *bAlv; vPane = AG_PaneNewVert(box, AG_PANE_EXPAND); AG_LabelNew(vPane->div[0], 0, _("Text: ")); tb = AG_TextboxNewS(vPane->div[0], AG_TEXTBOX_MULTILINE|AG_TEXTBOX_EXPAND, NULL); AG_TextboxBindUTF8(tb, vt->text, sizeof(vt->text)); bAlv = AG_BoxNewVertNS(vPane->div[1], AG_BOX_HFILL|AG_BOX_FRAME); AG_LabelNew(bAlv, 0, _("Alignment: ")); bAl = AG_BoxNewHorizNS(bAlv, AG_BOX_HFILL|AG_BOX_HOMOGENOUS); AG_ButtonNewFn(bAl, 0, _("TL"), SetAlign, "%p,%i", vt, VG_ALIGN_TL); AG_ButtonNewFn(bAl, 0, _("TC"), SetAlign, "%p,%i", vt, VG_ALIGN_TC); AG_ButtonNewFn(bAl, 0, _("TR"), SetAlign, "%p,%i", vt, VG_ALIGN_TR); bAl = AG_BoxNewHorizNS(bAlv, AG_BOX_HFILL|AG_BOX_HOMOGENOUS); AG_ButtonNewFn(bAl, 0, _("ML"), SetAlign, "%p,%i", vt, VG_ALIGN_ML); AG_ButtonNewFn(bAl, 0, _("MC"), SetAlign, "%p,%i", vt, VG_ALIGN_MC); AG_ButtonNewFn(bAl, 0, _("MR"), SetAlign, "%p,%i", vt, VG_ALIGN_MR); bAl = AG_BoxNewHorizNS(bAlv, AG_BOX_HFILL|AG_BOX_HOMOGENOUS); AG_ButtonNewFn(bAl, 0, _("BL"), SetAlign, "%p,%i", vt, VG_ALIGN_BL); AG_ButtonNewFn(bAl, 0, _("BC"), SetAlign, "%p,%i", vt, VG_ALIGN_BC); AG_ButtonNewFn(bAl, 0, _("BR"), SetAlign, "%p,%i", vt, VG_ALIGN_BR); AG_ButtonNewFn(vPane->div[1], AG_BUTTON_HFILL, _("Select font"), SelectFontDlg, "%p,%p", vt, vv); AG_CheckboxNewFlag(vPane->div[1], 0, _("Underline"), &vt->fontFlags, VG_TEXT_UNDERLINE); AG_CheckboxNewFlag(vPane->div[1], 0, _("Scale to view"), &vt->fontFlags, VG_TEXT_SCALED); return (box); }
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); }
static int TestGUI(void *obj, AG_Window *win) { MyTestInstance *ti = obj; if (AG_ObjectLoad(&ti->vfsRoot) == 0) { AG_LabelNewS(win, 0, "Test VFS loaded"); } else { AG_LabelNewS(win, 0, "New test VFS"); } AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Start VFS browser", StartBrowser, "%p,%p", ti, win); return (0); }
AG_Button *AGOL_About::CreateOKButton(void *parent) { AG_Box *bbox; AG_Button *button; bbox = AG_BoxNewHoriz(parent, AG_BOX_HFILL); // This empty box positions the button to the right AG_BoxNewHoriz(bbox, AG_BOX_HFILL); button = AG_ButtonNewFn(bbox, 0, " OK ", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_About::OnOK)); return button; }
static int TestGUI(void *obj, AG_Window *win) { MyTestInstance *ti = obj; AG_FlagDescr winFlags[] = { { AG_WINDOW_MODAL, "MODAL", 1 }, { AG_WINDOW_KEEPABOVE, "KEEPABOVE", 1 }, { AG_WINDOW_KEEPBELOW, "KEEPBELOW", 1 }, { AG_WINDOW_NOTITLE, "NOTITLE", 1 }, { AG_WINDOW_NOBORDERS, "NOBORDERS", 1 }, { AG_WINDOW_NOHRESIZE, "NOHRESIZE", 1 }, { AG_WINDOW_NOVRESIZE, "NOVRESIZE", 1 }, { AG_WINDOW_NOCLOSE, "NOCLOSE", 1 }, { AG_WINDOW_NOMINIMIZE, "NOMINIMIZE", 1 }, { AG_WINDOW_NOMAXIMIZE, "NOMAXIMIZE", 1 }, { AG_WINDOW_NOBACKGROUND, "NOBACKGROUND", 1 }, { AG_WINDOW_NOMOVE, "NOMOVE", 1 }, { AG_WINDOW_DENYFOCUS, "DENYFOCUS", 1 }, { 0, NULL, 0 } }; ti->testFlags = 0; ti->makeTransient = 0; ti->makePinned = 0; AG_LabelNewS(win, 0, "Create test window with flags:"); AG_CheckboxSetFromFlags(win, 0, &ti->testFlags, winFlags); AG_CheckboxNewInt(win, 0, "Make transient", &ti->makeTransient); AG_CheckboxNewInt(win, 0, "Make pinned", &ti->makePinned); AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Create Test Window", CreateTestWindow, "%p,%p", ti, win); AG_SeparatorNewHoriz(win); AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Test Desktop Alignment", TestDesktopAlign, "%p", win); return (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); }
void osdInitIntroWindow() { AG_Window *w = osdNewWindow("Welcome to Gravit!"); AG_Box *vBox = AG_BoxNewVert(w, 0); AG_Box *hBox = AG_BoxNewHoriz(w, 0); AG_Label *text; AG_BoxSetSpacing(vBox, 10); text = AG_LabelNew(vBox, 0, 0); AG_LabelText(text, "Gravit is a free, visually stunning gravity simulator, where you can spend endless\ntime experimenting with various configurations of simulated universes.\n\nQuick Start:\n\n - Click on RESPAWN to start a new simulation.\n - Click on PLAY to replay a recording\n - Click on RECORD to resume recording\n - Hold down a mouse button and move it around to change your perspective.\n - Use the A and Z keys, or the scroll wheel to zoom in and out.\n"); AG_WidgetSetSize(text, 200, 100); // AG_Checkbox *showAgain = AG_CheckboxNew(vBox, AG_CHECKBOX_SET, "Show this window on startup"); AG_ButtonNewFn(hBox, 0, " OK ", AG_WindowCloseGenEv, "%p", w); AG_WindowShow(w); }
AG_Label *AGOL_Settings::CreateOdamexPathLabel(void *parent) { AG_Label *oplabel; string oppath; oplabel = AG_LabelNewS(parent, AG_LABEL_FRAME | AG_LABEL_EXPAND, ""); AG_LabelValign(oplabel, AG_TEXT_MIDDLE); GuiConfig::Read("OdamexPath", oppath); if(oppath.size()) AG_LabelTextS(oplabel, oppath.c_str()); AG_ButtonNewFn(parent, 0, "Browse", EventReceiver, "%p", RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::OnBrowseOdamexPath)); return oplabel; }
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); } }
static int TestGUI(void *obj, AG_Window *win) { char path[AG_PATHNAME_MAX]; AG_Slider *sl; AG_Box *hb; hb = AG_BoxNewHoriz(win, AG_BOX_HFILL); if (!AG_ConfigFile("load-path", "agar", "bmp", path, sizeof(path))) { AG_PixmapFromBMP(hb, 0, path); AG_PixmapFromBMP(hb, 0, path); AG_PixmapFromBMP(hb, 0, path); } hb = AG_BoxNewHoriz(win, AG_BOX_HFILL); { AG_LabelNew(hb, 0, "Window Opacity: "); sl = AG_SliderNewFlt(hb, AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &opval, &opmin, &opmax); AG_SetEvent(sl, "slider-changed", Changed, "%p", win); } AG_ButtonNewFn(win, AG_BUTTON_HFILL, "Test AG_WINDOW_FADEIN", Fadein, NULL); return (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); }
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); }
static AG_Window * DEV_ConfigWindow(AG_Config *cfg) { char path[AG_PATHNAME_MAX]; AG_Window *win; AG_Box *hb; AG_Textbox *tbox; /* AG_Checkbox *cb; */ AG_Notebook *nb; AG_NotebookTab *tab; if ((win = AG_WindowNewNamedS(0, "DEV_Config")) == NULL) { return (NULL); } AG_WindowSetCaptionS(win, _("Agar settings")); AG_WindowSetCloseAction(win, AG_WINDOW_DETACH); nb = AG_NotebookNew(win, AG_NOTEBOOK_HFILL|AG_NOTEBOOK_VFILL); tab = AG_NotebookAdd(nb, _("Video"), AG_BOX_VERT); { AG_NumericalNewIntR(tab, 0, "%", _("Screenshot quality: "), &agScreenshotQuality, 1, 100); } tab = AG_NotebookAdd(nb, _("GUI"), AG_BOX_VERT); { AG_CheckboxNewInt(tab, 0, _("Built-in key composition"), &agTextComposition); AG_CheckboxNewInt(tab, 0, _("Bidirectional"), &agTextBidi); AG_SeparatorNewHoriz(tab); AG_LabelNewS(tab, 0, _("Timer settings (milliseconds):")); AG_NumericalNewIntR(tab, 0, NULL, _("Double click delay: "), &agMouseDblclickDelay, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Cursor spin delay: "), &agMouseSpinDelay, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Cursor spin interval: "), &agMouseSpinIval, 1, 10000); AG_NumericalNewIntR(tab, 0, NULL, _("Key repeat delay: "), &agKbdDelay, 1, 1000); AG_NumericalNewIntR(tab, 0, NULL, _("Key repeat interval: "), &agKbdRepeat, 1, 500); } tab = AG_NotebookAdd(nb, _("Directories"), AG_BOX_VERT); { hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Temporary file directory: ")); AG_GetString(agConfig, "tmp-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "tmp-path"); AG_TextboxSizeHint(tbox, "XXXXXXXXXXXXXXXXXXXX"); AG_ButtonNewFn(hb, 0, "...", SelectPath, "%s,%p", "tmp-path", tbox); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Dataset save directory: ")); AG_GetString(agConfig, "save-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "save-path"); AG_ButtonNewFn(hb, 0, "...", SelectPath, "%s,%p", "save-path", tbox); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Dataset search path: ")); AG_GetString(agConfig, "load-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "load-path"); hb = AG_BoxNewHoriz(tab, AG_BOX_HFILL); tbox = AG_TextboxNewS(hb, AG_TEXTBOX_HFILL, _("Font search path: ")); AG_GetString(agConfig, "font-path", path, sizeof(path)); AG_TextboxSetString(tbox, path); AG_SetEvent(tbox, "textbox-return", SetPath, "%s", "font-path"); } #if 0 tab = AG_NotebookAdd(nb, _("Colors"), AG_BOX_VERT); { AG_Pane *hPane; AG_HSVPal *hsv; AG_Tlist *tl; AG_TlistItem *it; AG_Label *lbl; int i; hPane = AG_PaneNew(tab, AG_PANE_HORIZ, AG_PANE_EXPAND); { tl = AG_TlistNew(hPane->div[0], AG_TLIST_EXPAND); AG_TlistSizeHint(tl, "Tileview text background", 10); for (i = 0; i < LAST_COLOR; i++) { it = AG_TlistAdd(tl, NULL, _(agColorNames[i])); it->p1 = &agColors[i]; } hsv = AG_HSVPalNew(hPane->div[1], AG_HSVPAL_EXPAND); AG_SetEvent(hsv, "h-changed", SetColor, "%p", tl); AG_SetEvent(hsv, "sv-changed", SetColor, "%p", tl); AG_SetEvent(tl, "tlist-selected", BindSelectedColor, "%p", hsv); } lbl = AG_LabelNew(tab, 0, _("Warning: Some color changes will not " "take effect until %s is restarted."), agProgName); AG_LabelSetPaddingLeft(lbl, 10); AG_LabelSetPaddingRight(lbl, 10); hb = AG_BoxNewHoriz(tab, AG_BOX_HOMOGENOUS|AG_BOX_HFILL); { AG_ButtonNewFn(hb, 0, _("Load scheme"), LoadColorSchemeDlg, NULL); AG_ButtonNewFn(hb, 0, _("Save scheme"), SaveColorSchemeDlg, NULL); } } #endif #ifdef AG_DEBUG tab = AG_NotebookAdd(nb, _("Debug"), AG_BOX_VERT); { AG_NumericalNewIntR(tab, 0, NULL, _("Debug level: "), &agDebugLvl, 0, 255); } #endif hb = AG_BoxNewHoriz(win, AG_BOX_HOMOGENOUS|AG_BOX_HFILL); { AG_ButtonNewFn(hb, 0, _("Close"), AGWINDETACH(win)); AG_ButtonNewFn(hb, 0, _("Save"), SaveConfig, NULL); } return (win); }
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 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); }
static int TestGUI(void *obj, AG_Window *win) { M_Plotter *plt; AG_Pane *pane; AG_Numerical *num; AG_Box *box; int i; pane = AG_PaneNew(win, AG_PANE_HORIZ, AG_PANE_EXPAND); { /* Create our plotter widget */ plt = M_PlotterNew(pane->div[1], M_PLOTTER_EXPAND); /* * Create the velocity plot item. This is what our algorithm * computes. */ plVel = M_PlotNew(plt, M_PLOT_LINEAR); M_PlotSetLabel(plVel, "m/s"); M_PlotSetYoffs(plVel, -45); M_PlotSetScale(plVel, 0.0, 50.0); /* Create a label we will use to show the "case". */ plblCase = M_PlotLabelNew(plVel, M_LABEL_OVERLAY, 0, 16, "-"); /* Plot the derivative of the velocity (the acceleration). */ plAcc = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plVel); M_PlotSetLabel(plAcc, "m/s^2"); M_PlotSetScale(plAcc, 0.0, 3000.0); /* Plot the derivative of the acceleration (the jerk). */ plJerk = M_PlotFromDerivative(plt, M_PLOT_LINEAR, plAcc); M_PlotSetLabel(plJerk, "m/s^3"); M_PlotSetScale(plJerk, 0.0, 100.0); M_PlotSetScale(plJerk, 0.0, 150000.0); M_PlotSetYoffs(plJerk, 70); } /* Allow the user to play with the parameters. */ box = AG_BoxNew(pane->div[0], AG_BOX_VERT, AG_BOX_EXPAND); { struct { const char *name; M_Real *f; double incr; } param[7] = { { "Jmax: ", &Jmax, 0.00001 }, { "Amax: ", &Amax, 0.0005 }, { "F: ", &F, 0.01 }, { "L: ", &L, 10.0 }, { "Ts tweak: ", &uTs, 1.0 }, { "Ta tweak: ", &uTa, 1.0 }, { "To tweak: ", &uTo, 1.0 }, }; for (i = 0; i < 7; i++) { num = AG_NumericalNewS(box, AG_NUMERICAL_HFILL, NULL, param[i].name); AG_BindDouble(num, "value", param[i].f); AG_SetDouble(num, "inc", param[i].incr); AG_SetEvent(num, "numerical-changed", GeneratePlot, "%p", plt); } AG_SeparatorNewHoriz(box); AG_LabelNewPolled(box, AG_LABEL_HFILL, "Aref: %lf", &Aref); AG_LabelNewPolled(box, AG_LABEL_HFILL, "v1: %lf", &v1); AG_LabelNewPolled(box, AG_LABEL_HFILL, "v2: %lf", &v2); AG_LabelNewPolled(box, AG_LABEL_HFILL, "v3: %lf", &v3); AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ts: %lf", &Ts); AG_LabelNewPolled(box, AG_LABEL_HFILL, "Ta: %lf", &Ta); AG_LabelNewPolled(box, AG_LABEL_HFILL, "To: %lf", &To); AG_ButtonNewFn(box, AG_BUTTON_HFILL, "Generate", GeneratePlot, "%p", plt); } AG_SetEvent(win, "window-shown", GeneratePlot, "%p", plt); AG_WindowSetGeometryAlignedPct(win, AG_WINDOW_MC, 50, 30); return (0); }
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); }