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); }
/* 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); }
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(); }
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); }
static void OpenGuiDebugger(AG_Event *event) { AG_Window *win; if ((win = AG_GuiDebugger(NULL)) != NULL) AG_WindowShow(win); }
/* * 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); }
static void AGOL_StartDebugger(void) { AG_Window *win; if((win = AG_GuiDebugger(agWindowFocused)) != NULL) { AG_WindowShow(win); } }
static void SelectTool(AG_Event *event) { const struct dev_tool_ent *ent = AG_PTR(1); AG_Window *win; if ((win = (ent->fn)()) != NULL) AG_WindowShow(win); }
bool TestState::update() { if (timeToExit) { chatServer->quit(); return false; } // check if the map has been loaded then tell the game server we're ready if (!mLoaded && mapEngine->mapLoaded()) { Packet *packet = new Packet(PGMSG_MAP_LOADED); networkManager->sendPacket(packet); mLoaded = true; Texture *texture = graphicsEngine->getTexture(resourceManager->getDataPath("glowtile_red.png")); interfaceManager->getMouse()->cursor = new Node("Cursor", texture); mapEngine->getLayer(mapEngine->getLayers() - 1)->addNode(interfaceManager->getMouse()->cursor); } // Check for input, if escape pressed, exit if (inputManager->getKey(AG_KEY_ESCAPE)) { // bring up menu to choose whether to log off or quit if (AG_WindowIsVisible(popUp)) AG_WindowHide(popUp); else AG_WindowShow(popUp); } // number of milliseconds since last frame ms = SDL_GetTicks() - lastframe; lastframe = SDL_GetTicks(); mTime += ms; if (mTime > 1000) { graphicsEngine->saveFrames(); mTime = 0; } if (networkManager->isConnected()) { // pass the number of milliseconds to logic beingManager->logic(ms); player->getSelectedCharacter()->logic(ms); player->logic(ms); graphicsEngine->getCamera()->logic(ms); chatServer->process(); } SDL_Delay(0); return true; }
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); }
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); }
void DEV_ConfigShow(void) { AG_Window *win; /* Avoid clobbering modal windows */ if (agDriverSw != NULL && agDriverSw->Lmodal->n > 0) return; if ((win = DEV_ConfigWindow(agConfig)) != NULL) AG_WindowShow(win); }
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); }
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); }
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); }
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); } }
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); }
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); }
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 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); }
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); }
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); }
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 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 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); }
/* Show the performance monitor graph. */ AG_Window * AG_PerfMonShow(void) { AG_WindowShow(agPerfWindow); return (agPerfWindow); }
static void EditNumValues(AG_Event *event) { AG_HSVPal *pal = AG_PTR(1); AG_Window *pwin; AG_Window *win; AG_Numerical *num; AG_Variable *b1, *b2; float v; if ((pwin = AG_ParentWindow(pal)) == NULL) return; if ((win = AG_WindowNewNamed(AG_WINDOW_NOMAXIMIZE, "hsvpal-%p-numedit", pal)) == NULL) { return; } AG_WindowSetCaption(win, _("Color values")); AG_WindowSetPosition(win, AG_WINDOW_LOWER_LEFT, 0); AG_WindowSetCloseAction(win, AG_WINDOW_DETACH); { AG_Variable *bAlpha; void *pAlpha; num = AG_NumericalNew(win, 0, NULL, _("Hue: ")); AG_NumericalSizeHint(num, "000"); AG_WidgetCopyBinding(num, "value", pal, "hue"); AG_NumericalSetRange(num, 0.0, 359.0); AG_NumericalSetIncrement(num, 1); AG_NumericalSetPrecision(num, "f", 0); num = AG_NumericalNew(win, 0, NULL, _("Saturation: ")); AG_NumericalSizeHint(num, "00.00"); AG_WidgetCopyBinding(num, "value", pal, "saturation"); AG_NumericalSetRange(num, 0.0, 1.0); AG_NumericalSetIncrement(num, 0.01); AG_NumericalSetPrecision(num, "f", 2); num = AG_NumericalNew(win, 0, NULL, _("Value: ")); AG_NumericalSizeHint(num, "00.00"); AG_WidgetCopyBinding(num, "value", pal, "value"); AG_NumericalSetRange(num, 0.0, 1.0); AG_NumericalSetIncrement(num, 0.01); AG_NumericalSetPrecision(num, "f", 2); num = AG_NumericalNew(win, 0, NULL, _("Alpha: ")); AG_NumericalSizeHint(num, "0.000"); AG_WidgetCopyBinding(num, "value", pal, "alpha"); bAlpha = AG_GetVariable(pal, "alpha", &pAlpha); switch (AG_VARIABLE_TYPE(bAlpha)) { case AG_VARIABLE_FLOAT: case AG_VARIABLE_DOUBLE: AG_NumericalSetRange(num, 0.0, 1.0); AG_NumericalSetIncrement(num, 0.005); AG_NumericalSetPrecision(num, "f", 3); break; case AG_VARIABLE_INT: case AG_VARIABLE_UINT: case AG_VARIABLE_UINT8: AG_NumericalSetRange(num, 0.0, 255.0); AG_NumericalSetIncrement(num, 1.0); AG_NumericalSetPrecision(num, "f", 0); break; default: break; } AG_UnlockVariable(bAlpha); } AG_WindowAttach(pwin, win); AG_WindowShow(win); }
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"); }
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); }
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); }