static int TestGUI(void *obj, AG_Window *win) { AG_FileDlg *fd; AG_DirDlg *dd; AG_FileType *ft[3]; AG_Box *box; AG_Notebook *nb; AG_NotebookTab *ntab; int i; nb = AG_NotebookNew(win, AG_NOTEBOOK_EXPAND); ntab = AG_NotebookAdd(nb, "Load file", AG_BOX_VERT); { /* Create the file loader widget. */ fd = AG_FileDlgNew(ntab, AG_FILEDLG_EXPAND); /* Set some default directory. */ if (strcmp(DATADIR, "NONE") != 0) { AG_FileDlgSetDirectoryMRU(fd, "images-dir", DATADIR); } else { AG_FileDlgSetDirectoryMRU(fd, "images-dir", "."); } /* Set some default filename. */ AG_FileDlgSetFilenameS(fd, "agar.bmp"); /* * Register the loader functions. We can assign a set of user * specified options to specific types as well. */ ft[0] = AG_FileDlgAddType(fd, "Windows Bitmap", "*.bmp", LoadImage, "%p", win); ft[1] = AG_FileDlgAddType(fd, "JPEG image", "*.jpg,*.jpeg", LoadImage, "%p", win); ft[2] = AG_FileDlgAddType(fd, "Portable Network Graphics", "*.png", LoadImage, "%p", win); for (i = 0; i < 3; i++) AG_FileOptionNewBool(ft[i], "Inverted", "invert", 0); /* * As different file types are selected, FileDlg may create * widgets for type specific options. We specify where those * widgets will be created here. */ box = AG_BoxNewVert(ntab, AG_BOX_HFILL|AG_BOX_FRAME); AG_BoxSetPadding(box, 10); AG_FileDlgSetOptionContainer(fd, box); } ntab = AG_NotebookAdd(nb, "Select directory", AG_BOX_VERT); { /* Create the directory selector widget. */ dd = AG_DirDlgNew(ntab, AG_DIRDLG_EXPAND); /* Set some default directory. */ AG_DirDlgSetDirectoryMRU(dd, "images-dir", "./Images"); } AG_WindowSetPosition(win, AG_WINDOW_MIDDLE_LEFT, 0); return (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); }
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); }
MenuDeathmatchMaps::MenuDeathmatchMaps(){ AG_WindowMaximize(win); AG_WindowSetPadding(win, MENU_OFFSET, MENU_OFFSET, MENU_OFFSET, MENU_OFFSET); // nadpis createHeading("Deathmatch maps"); file_dlg_ = AG_FileDlgNew(win, AG_FILEDLG_LOAD); AG_Expand(file_dlg_); AG_FileDlgSetDirectory(file_dlg_, map_path); AG_FileDlgAddType(file_dlg_, "Bombic map XML", TIXML_FILE_EXTENSION, handlerCheckMap, 0); AG_FileDlgCancelAction(file_dlg_, handlerBack, 0); AG_SpacerNewHoriz(win); }