static void FindWindows(AG_Tlist *tl, AG_Window *win, int depth) { char text[AG_TLIST_LABEL_MAX]; AG_Window *wSub; AG_Widget *wChild; AG_TlistItem *it; if (strncmp(OBJECT(win)->name, "_Popup-", sizeof("_Popup-")) == 0) return; Strlcpy(text, win->caption, sizeof(text)); if (strcmp(OBJECT(win)->name, "generic") == 0) { it = AG_TlistAddS(tl, NULL, win->caption[0] != '\0' ? win->caption : _("Untitled")); } else { it = AG_TlistAdd(tl, NULL, "%s (<%s>)", win->caption[0] != '\0' ? win->caption : _("Untitled"), OBJECT(win)->name); } it->p1 = win; it->depth = depth; it->cat = "window"; if (!TAILQ_EMPTY(&OBJECT(win)->children) || !TAILQ_EMPTY(&win->subwins)) { it->flags |= AG_TLIST_HAS_CHILDREN; } if ((it->flags & AG_TLIST_HAS_CHILDREN) && AG_TlistVisibleChildren(tl, it)) { TAILQ_FOREACH(wSub, &win->subwins, swins) FindWindows(tl, wSub, depth+1); OBJECT_FOREACH_CHILD(wChild, win, ag_widget) FindWidgets(wChild, tl, depth+1); } }
ODA_GuiOptionsBox *AGOL_Settings::CreateGuiOptionsBox(void *parent) { char drvList[128]; AG_Box *vdbox; ODA_GuiOptionsBox *gbox = new ODA_GuiOptionsBox; gbox->optionsBox = AG_BoxNewVert(parent, AG_BOX_FRAME); AG_LabelNewS(gbox->optionsBox, 0, "Gui Options"); gbox->optionsBox = AG_BoxNewVert(gbox->optionsBox, AG_BOX_EXPAND); AG_BoxSetPadding(gbox->optionsBox, 5); AG_BoxSetSpacing(gbox->optionsBox, 5); // Video Driver Option vdbox = AG_BoxNewHoriz(gbox->optionsBox, AG_BOX_HFILL); AG_BoxSetPadding(vdbox, 0); AG_BoxSetSpacing(vdbox, 0); gbox->driverLabel = AG_LabelNewS(vdbox, 0, "Video Driver: "); gbox->driverCombo = AG_UComboNew(vdbox, AG_UCOMBO_HFILL); AG_UComboSizeHint(gbox->driverCombo, "XXXXXXXXXXXX", 3); AG_ListDriverNames(drvList, 128); if(strlen(drvList) > 0) { size_t oldpos = 0; size_t pos = 0; while(pos != string::npos) { AG_TlistItem *item; pos = string(drvList).find(' ', oldpos); item = AG_TlistAdd(gbox->driverCombo->list, NULL, string(drvList).substr(oldpos, pos - oldpos).c_str()); if(string(item->text) == string(agDriverOps->name)) AG_ButtonTextS(gbox->driverCombo->button, item->text); oldpos = pos + 1; } } // End - Video Driver Option return gbox; }
static void UpdateFaces(AG_Event *event) { AG_Variable *bFont; AG_Font **pFont; AG_FontSelector *fs = AG_SELF(); char fontPath[AG_SEARCHPATH_MAX], *pFontPath = &fontPath[0]; AG_TlistItem *ti; char *s; int i; const int stdSizes[] = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 22,24,26,28,32,48,64 }; const int nStdSizes = sizeof(stdSizes) / sizeof(stdSizes[0]); bFont = AG_GetVariable(fs, "font", &pFont); AG_PushTextState(); fs->flags &= ~(AG_FONTSELECTOR_UPDATE); for (i = 0; i < agBuiltinFontCount; i++) { AG_StaticFont *font = agBuiltinFonts[i]; ti = AG_TlistAdd(fs->tlFaces, NULL, "_%s", font->name); ti->p1 = font; if (*pFont != NULL && strcmp(ti->text, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CopyCfgString("font-path", fontPath, sizeof(fontPath)); while ((s = AG_Strsep(&pFontPath, ":")) != NULL) { AG_Dir *dir; int i; if ((dir = AG_OpenDir(s)) == NULL) { AG_Verbose(_("Ignoring: %s\n"), AG_GetError()); continue; } for (i = 0; i < dir->nents; i++) { char path[AG_FILENAME_MAX]; AG_FileInfo info; char *file = dir->ents[i], *pExt; if (file[0] == '.' || (pExt = strrchr(file, '.')) == NULL) { continue; } if (strcmp(pExt, ".ttf") != 0 && strcmp(pExt, ".TTF") != 0) continue; Strlcpy(path, s, sizeof(path)); Strlcat(path, AG_PATHSEP, sizeof(path)); Strlcat(path, file, sizeof(path)); if (AG_GetFileInfo(path, &info) == -1 || info.type != AG_FILE_REGULAR) { continue; } ti = AG_TlistAddS(fs->tlFaces, NULL, file); if (*pFont != NULL && strcmp(file, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CloseDir(dir); } /* XXX */ for (i = 0; i < nStdSizes; i++) { ti = AG_TlistAdd(fs->tlSizes, NULL, "%d", stdSizes[i]); if (*pFont != NULL && stdSizes[i] == (*pFont)->size) ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Regular")); if (*pFont != NULL && (*pFont)->flags == 0) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Italic")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_ITALIC) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_BOLD) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold Italic")); if (*pFont != NULL && (*pFont)->flags == (AG_FONT_BOLD|AG_FONT_ITALIC)) { ti->selected++; } UpdatePreview(fs); AG_UnlockVariable(bFont); }
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); }