/* * 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); }
AG_Slider * AG_SliderNewIntR(void *parent, enum ag_slider_type type, Uint flags, int *val, int min, int max) { AG_Slider *sl = AG_SliderNew(parent, type, flags); if (val != NULL) { AG_BindInt(sl, "value", val); } AG_SetInt(sl, "min", min); AG_SetInt(sl, "max", max); return (sl); }
static void Init(void *obj) { AG_DbMySQL *db = obj; AG_SetString(db, "host", NULL); AG_SetInt(db, "port", 0); AG_SetString(db, "database", NULL); AG_SetString(db, "user", NULL); AG_SetString(db, "password", NULL); AG_SetString(db, "unix-socket", NULL); AG_SetInt(db, "compress", 0); AG_SetInt(db, "local-files", -1); AG_SetInt(db, "ssl", -1); AG_SetInt(db, "ssl-verify-cert", -1); AG_SetInt(db, "secure-auth", -1); AG_SetString(db, "cnf-file", NULL); AG_SetString(db, "cnf-group", NULL); AG_SetString(db, "protocol", "default"); AG_SetUint(db, "read-timeout", 0); AG_SetInt(db, "write-timeout", -1); AG_SetInt(db, "reconnect", 1); AG_SetString(db, "charset", NULL); AG_SetString(db, "charset-dir", NULL); AG_SetString(db, "init-cmd", NULL); AG_SetString(db, "get-cmd", "SELECT my_field FROM my_table " "WHERE my_field = '%s'"); AG_SetString(db, "put-cmd", "INSERT INTO my_table VALUES('%s')"); }
void AG_SliderSetIntIncrement(AG_Slider *sl, int inc) { AG_ObjectLock(sl); AG_SetInt(sl, "inc", inc); AG_ObjectUnlock(sl); }
static void SoundMenu(AG_NotebookTab *parent, struct gui_sound *cfg) { AG_Radio *radio; AG_Checkbox *check; AG_Numerical *num; AG_Label *lbl; AG_Box *box; AG_Box *box2; int i; for(i = 0; i < 6 ; i++) { if(cfg->nSampleRate == SampleRates[i]) break; } if(i > 6) i = 6; box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_VFILL); { lbl = AG_LabelNew(AGWIDGET(box), 0, "%s", gettext("Sample Rate")); radio = AG_RadioNewFn(AGWIDGET(box), 0, SampleRateName, OnChangeSampleRate, "%p", cfg); AG_SetInt(radio, "value", i); box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("HQ Rendering"), &(cfg->bFMHQmode)); } box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_VFILL); { num = AG_NumericalNewInt(AGWIDGET(box), AG_NUMERICAL_HFILL, gettext("Per Second") ,gettext("Sound Buffer"), &(cfg->nSoundBuffer)); AG_NumericalSetRangeInt(num, 30, 2000); AG_NumericalSetIncrement(num, 10.0); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("Force Stereo"), &(cfg->nStereoOut)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("FDD Seek & Motor"), &(cfg->bFddSound)); check = AG_CheckboxNewInt(AGWIDGET(box), AG_CHECKBOX_HFILL, gettext("CMT Monitor"), &(cfg->bTapeMon)); } }
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); }
int AG_ConfigInit(AG_Config *cfg, Uint flags) { char path[AG_PATHNAME_MAX], *s; AG_User *sysUser; AG_ObjectInit(cfg, &agConfigClass); AG_ObjectSetName(cfg, "config"); OBJECT(cfg)->save_pfx = NULL; AG_SetInt(cfg, "initial-run", 1); AG_SetInt(cfg, "no-confirm-quit", 0); if (agProgName != NULL && (sysUser = AG_GetRealUser()) != NULL) { AG_SetString(cfg, "home", sysUser->home); AG_SetString(cfg, "tmp-path", sysUser->tmp); Strlcpy(path, sysUser->home, sizeof(path)); Strlcat(path, AG_PATHSEP, sizeof(path)); Strlcat(path, ".", sizeof(path)); Strlcat(path, agProgName, sizeof(path)); AG_SetString(cfg, "save-path", path); if (strcmp(DATADIR, "NONE") != 0) { AG_PrtString(cfg, "load-path", "%s%s%s", path, AG_PATHSEPMULTI, DATADIR); } else { AG_SetString(cfg, "load-path", path); } AG_UserFree(sysUser); } else { AG_SetString(cfg, "home", ""); s = (strcmp(DATADIR,"NONE") != 0) ? DATADIR : "."; AG_SetString(cfg, "load-path", s); AG_SetString(cfg, "save-path", s); AG_SetString(cfg, "tmp-path", "tmp"); } if ((flags & AG_CREATE_DATADIR) && AG_CreateDataDir() == -1) { return (-1); } return (0); }
/* The UCombo must be locked. */ static void Collapse(AG_UCombo *com) { if (com->panel == NULL) { return; } com->wSaved = WIDTH(com->panel); com->hSaved = HEIGHT(com->panel); AG_ObjectDetach(com->list); AG_ObjectDetach(com->panel); com->panel = NULL; AG_SetInt(com->button, "state", 0); }
static void Collapse(AG_FileSelector *fs) { if (fs->panel == NULL) { return; } fs->wSaved = WIDTH(fs->panel); fs->hSaved = HEIGHT(fs->panel); AG_WindowHide(fs->panel); AG_ObjectDetach(fs->filedlg); AG_ObjectDetach(fs->panel); fs->panel = NULL; AG_SetInt(fs->button, "state", 0); }
static int Save(void *obj, AG_DataSource *ds) { AG_Config *cfg = obj; char buf[30]; AG_SetInt(cfg, "initial-run", 0); #ifdef AG_DEBUG AG_WriteUint8(ds, (Uint8)agDebugLvl); #else AG_WriteUint8(ds, 0); #endif /* For backward compatibility with <9.5 (pre-1.4.2) saves. */ memset(buf, 0, sizeof(buf)); AG_Write(ds, buf, sizeof(buf)); AG_WriteString(ds, ""); /* agRcsHostname */ AG_WriteUint16(ds, 0); /* agRcsPort */ AG_WriteString(ds, ""); /* agRcsUsername */ AG_WriteString(ds, ""); /* agRcsPassword */ return (0); }
static void OnShow(AG_Event *event) { AG_Slider *sl = AG_SELF(); AG_Variable *V; if ((V = AG_GetVariable(sl, "value", NULL)) == NULL) { V = AG_SetInt(sl, "value", 0); AG_LockVariable(V); } switch (AG_VARIABLE_TYPE(V)) { case AG_VARIABLE_FLOAT: SET_DEF(AG_SetFloat, 0.0f, 1.0f, 0.1f); break; case AG_VARIABLE_DOUBLE: SET_DEF(AG_SetDouble, 0.0, 1.0, 0.1); break; #ifdef HAVE_LONG_DOUBLE case AG_VARIABLE_LONG_DOUBLE: SET_DEF(AG_SetLongDouble, 0.0l, 1.0l, 0.1l); break; #endif case AG_VARIABLE_INT: SET_DEF(AG_SetInt, AG_INT_MIN+1, AG_INT_MAX-1, 1); break; case AG_VARIABLE_UINT: SET_DEF(AG_SetUint, 0U, AG_UINT_MAX-1, 1U); break; case AG_VARIABLE_UINT8: SET_DEF(AG_SetUint8, 0U, 0xffU, 1U); break; case AG_VARIABLE_SINT8: SET_DEF(AG_SetSint8, -0x7f, 0x7f, 1); break; case AG_VARIABLE_UINT16: SET_DEF(AG_SetUint16, 0U, 0xffffU, 1U); break; case AG_VARIABLE_SINT16: SET_DEF(AG_SetSint16, -0x7fff, 0x7fff, 1); break; case AG_VARIABLE_UINT32: SET_DEF(AG_SetUint32, 0UL, 0xffffffffUL, 1UL); break; case AG_VARIABLE_SINT32: SET_DEF(AG_SetSint32, -0x7fffffffL, 0x7fffffffL, 1L); break; #ifdef HAVE_64BIT case AG_VARIABLE_UINT64: SET_DEF(AG_SetUint64, 0ULL, 0xffffffffffffffffULL, 1ULL); break; case AG_VARIABLE_SINT64: SET_DEF(AG_SetSint64, -0x7fffffffffffffffLL, 0x7fffffffffffffffLL, 1LL); break; #endif default: break; } AG_UnlockVariable(V); if ((sl->flags & AG_SLIDER_EXCL) == 0) { AG_RedrawOnChange(sl, 100, "value"); AG_RedrawOnChange(sl, 1000, "min"); AG_RedrawOnChange(sl, 1000, "max"); } }
void MainLoop(int argc, char *argv[]) { int c; char *drivers = NULL; char *optArg; char strbuf[2048]; char homedir[2048]; const SDL_VideoInfo *inf; BOOL flag; SDL_Surface *s; // mtrace(); if(AG_GetVariable(agConfig, "font.size", NULL) == NULL) { AG_SetInt(agConfig, "font.size", UI_PT); } while ((c = AG_Getopt(argc, argv, "?fWd:w:h:T:t:c:T:F:S:o:O:l:s:i:", &optArg, NULL)) != -1) { switch (c) { case 'd': drivers = optArg; break; case 'f': /* Force full screen */ AG_SetBool(agConfig, "view.full-screen", 1); break; case 'W': /* Force Window */ AG_SetBool(agConfig, "view.full-screen", 0); break; case 'T': /* Set an alternate font directory */ AG_SetString(agConfig, "font-path", optArg); break; case 'F': /* Set an alternate font face */ AG_SetString(agConfig, "font.face", optArg); break; case 'S': /* Set an alternate font face */ AG_SetInt(agConfig, "font.size", atoi(optArg)); break; case 'o': /* Set an alternate font face */ AG_SetString(agConfig, "osdfont.face", optArg); break; case 'O': /* Set an alternate font face */ AG_SetInt(agConfig, "osdfont.size", atoi(optArg)); break; case 'l': /* Set an alternate font face */ AG_SetString(agConfig, "load-path", optArg); break; case 's': /* Set an alternate font face */ AG_SetString(agConfig, "save-path", optArg); break; case 'i': /* Set an alternate font face */ AG_SetString(agConfig, "save-path", optArg); AG_SetString(agConfig, "load-path", optArg); break; case 't': /* Change the default font */ AG_TextParseFontSpec(optArg); break; case '?': default: printf("%s [-v] [-f|-W] [-d driver] [-r fps] [-t fontspec] " "[-w width] [-h height] " "[-F font.face] [-S font.size]" "[-o osd-font.face] [-O osd-font.size]" "[-s SavePath] [-l LoadPath] " "[-T font-path]\n\n" "Usage:\n" "-f : FullScreen\n-W:Window Mode\n", agProgName); exit(0); } } if(SDL_getenv("HOME") != NULL) { strcpy(homedir, SDL_getenv("HOME")); } else { strcpy(homedir, "."); } XM7_DebugLog(XM7_LOG_DEBUG, "HOME = %s", homedir); #ifdef _WINDOWS AG_PrtString(agConfig, "font-path", "%s:%s/xm7:%s:.", homedir, homedir, FONTPATH); #else flag = FALSE; if(AG_GetString(agConfig, "font-path", strbuf, 2047) != NULL) { if((strlen(strbuf) <= 0) || (strncmp(strbuf, "_agFontVera", 11) == 0)){ flag = TRUE; } } else { flag = TRUE; } if(flag) AG_PrtString(agConfig, "font-path", "%s/.fonts:%s:%s/.xm7:%s:.", homedir, homedir, homedir, FONTPATH); flag = FALSE; XM7_DebugLog(XM7_LOG_DEBUG, "font-path = %s", strbuf); #endif /* _WINDOWS */ flag = FALSE; if(AG_GetString(agConfig, "font.face", strbuf, 511) != NULL) { if((strlen(strbuf) <= 0) || (strncmp(strbuf, "_agFontVera", 11) == 0)){ flag = TRUE; } } else { flag = TRUE; } if(flag) AG_SetString(agConfig, "font.face", UI_FONT); flag = FALSE; XM7_DebugLog(XM7_LOG_DEBUG, "font.face = %s", strbuf); stopreq_flag = FALSE; run_flag = TRUE; // Debug #ifdef _XM7_FB_DEBUG // Force FB. drivers = "sdlfb:width=1280:height=880:depth=32"; #endif /* * Agar のメインループに入る */ if(drivers == NULL) { #ifdef USE_OPENGL if(AG_InitGraphics(NULL) == -1){ fprintf(stderr, "%s\n", AG_GetError()); return; } #else if(AG_InitGraphics("cocoa,sdlfb") == -1){ fprintf(stderr, "%s\n", AG_GetError()); return; } #endif } else { if (AG_InitGraphics(drivers) == -1) { fprintf(stderr, "%s\n", AG_GetError()); return; } } OnCreate((AG_Widget *)NULL); // AG_AtExitFunc(OnDestroy); XM7_DebugLog(XM7_LOG_DEBUG, "Widget creation OK."); XM7_DebugLog(XM7_LOG_INFO, "Emulate version:%d", fm7_ver); SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); XM7_DebugLog(XM7_LOG_DEBUG, "Audio and JOYSTICK subsystem was initialised."); InitInstance(); XM7_DebugLog(XM7_LOG_DEBUG, "InitInstance() OK."); if(agDriverSw && AG_UsingSDL(NULL)) { SDL_Init(SDL_INIT_VIDEO); XM7_DebugLog(XM7_LOG_INFO, "Start Single WM with SDL."); switch(fm7_ver) { case 1: // FM7/77 if(!(LoadGlobalIconPng(NULL, "tamori.png"))) { LoadGlobalIconPng(NULL, "xm7.png"); } break; case 2: // FM77AV if(!(LoadGlobalIconPng(NULL, "fujitsu.png"))) { LoadGlobalIconPng(NULL, "xm7.png"); } break; case 3: // FM77AV20/40/EX/SX if(!(LoadGlobalIconPng(NULL, "fujitsu2.png"))) { LoadGlobalIconPng(NULL, "xm7.png"); } break; default: LoadGlobalIconPng(NULL, "xm7.png"); break; } } else { // WM function is managed by SDL, load and set icon for WM. SDL_Init(SDL_INIT_VIDEO); XM7_DebugLog(XM7_LOG_INFO, "Start multi window mode."); } stopreq_flag = FALSE; run_flag = TRUE; AG_DrawInitsub(); inf = SDL_GetVideoInfo(); if(inf != NULL) { RootVideoWidth = inf->current_w; RootVideoHeight = inf->current_h; } else { RootVideoWidth = 640; RootVideoHeight = 400; } newResize = FALSE; nDrawTick1D = XM7_timeGetTime(); nDrawTick1E = nDrawTick1D; ResizeWindow_Agar2(nDrawWidth, nDrawHeight); XM7_DebugLog(XM7_LOG_DEBUG, "Screen is %d x %d.", nDrawWidth, nDrawHeight); switch(nErrorCode) { case 0: break; case 1: ErrorPopup(gettext("Error init VM.\nPlease check ROMS and system-memory.\n")); break; case 2: ErrorPopup(gettext("Error init Emulator.\nPlease check window system, display and more.\n")); break; default: ErrorPopup(gettext("Unknown error on setup.\nPlease email to author.")); break; } #if 0 mtrace(); #endif if(DrawArea != NULL) { AG_RedrawOnTick(DrawArea, 1000 / nDrawFPS); XM7_DebugLog(XM7_LOG_INFO, "Direct draw mode."); } else if(GLDrawArea != NULL) { AG_RedrawOnTick(GLDrawArea, 1000 / nDrawFPS); XM7_DebugLog(XM7_LOG_INFO, "OpenGL mode."); } bEventRunFlag == TRUE; AGDrawTaskEvent(TRUE); // muntrace(); XM7_DebugLog(XM7_LOG_INFO, "All End."); }
static void OnConfigMenuScreen(struct gui_disp *cfg, AG_NotebookTab *parent) { AG_Radio *radio; AG_Checkbox *check; AG_Numerical *fps; AG_Box *box; AG_Box *box2; AG_Combo *combo; AG_TlistItem *TlistItem[RENDERING_END]; int i; int limit; box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_VFILL); { radio = AG_RadioNewFn(AGWIDGET(box), 0, ScreenSizeName, OnChangeScreenReso, "%p", cfg); limit = sizeof(ScreenSizeHeight) / sizeof(WORD); for(i = 0; i <= limit; i++){ if((ScreenSizeWidth[i] == cfg->uWidth) && (ScreenSizeHeight[i] == cfg->uHeight)) break; } if(i >= limit) i = 2; AG_SetInt(radio, "value", i); box = AG_BoxNewVert(AGWIDGET(parent), AG_BOX_HFILL); fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Display rate")); AG_BindUint16(fps, "value", &(cfg->nDrawFPS)); { AG_SetInt(fps, "min", 2); AG_SetInt(fps, "max", 75); AG_SetInt(fps, "inc", 1); } fps = AG_NumericalNewS(AGWIDGET(box), AG_NUMERICAL_HFILL, NULL ,gettext("Emulation rate")); AG_BindUint16(fps, "value", &(cfg->nEmuFPS)); { AG_SetInt(fps, "min", 2); AG_SetInt(fps, "max", 75); AG_SetInt(fps, "inc", 1); } box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); combo = AG_ComboNewS(AGWIDGET(box2), AG_COMBO_SCROLLTOSEL | AG_COMBO_HFILL, gettext("Rendering Method")); AG_ComboSizeHint(combo, "XXXXXXXXXXXXXX", RENDERING_END); TlistItem[0] = AG_TlistAddPtrHead(combo->list, NULL, gettext("Full Draw"), (void *)&RenderMethodsList[0]); TlistItem[1] = AG_TlistAddPtr(combo->list, NULL, gettext("Diff Block"), (void *)&RenderMethodsList[1]); TlistItem[2] = AG_TlistAddPtr(combo->list, NULL, gettext("Diff Raster"), (void *)&RenderMethodsList[2]); for(i = RENDERING_FULL; i < RENDERING_END; i++) { if(i == cfg->nRenderMethod) { AG_ComboSelect(combo, TlistItem[i]); } } AG_SetEvent(combo, "combo-selected", RenderMethodSelected, "%p", cfg); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Full Scan (15KHz)"), &(cfg->bFullScan)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("SMOOSING"), &(cfg->bSmoosing)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use OpenCL(Need REBOOT)"), &(cfg->bUseOpenCL)); box2 = AG_BoxNewHoriz(AGWIDGET(box), AG_BOX_HFILL); check = AG_CheckboxNewInt(AGWIDGET(box2), AG_CHECKBOX_HFILL, gettext("Use SIMD instructions(Need REBOOT)"), &(cfg->bUseSIMD)); } }
void agar_gui_widget_set_integer (AG_Widget *w, const char *binding, int val) { AG_SetInt (w, binding, val); }