コード例 #1
0
ファイル: teststate.cpp プロジェクト: suprafun/smalltowns
	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);
	}
コード例 #2
0
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);

}
コード例 #3
0
ファイル: objsystem_mammal.c プロジェクト: LiberatorUSA/GUCEF
/* 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);
}
コード例 #4
0
ファイル: agar-bench.c プロジェクト: LiberatorUSA/GUCEF
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);
}
コード例 #5
0
ファイル: unitconv.c プロジェクト: adsr/agar
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);
}
コード例 #6
0
ファイル: animal.c プロジェクト: adsr/agar
/*
 * Edit routine. This is a generic operation that returns a generic pointer,
 * and is not dependent on any particular user interface.
 *
 * This program uses Agar-GUI, so we will return an Agar window.
 */
static void *
Edit(void *obj)
{
	Animal *animal = obj;
	AG_Window *win;
	AG_Numerical *num;

	win = AG_WindowNew(0);
	AG_WindowSetCaption(win, "Animal: %s", AGOBJECT(animal)->name);

	num = AG_NumericalNewFlt(win, AG_NUMERICAL_HFILL, "sec",
	    "Age: ", &animal->age);
	num = AG_NumericalNewInt(win, AG_NUMERICAL_HFILL, NULL,
	    "Cell count: ", &animal->cellCount);

	return (win);
}
コード例 #7
0
ファイル: config.c プロジェクト: LiberatorUSA/GUCEF
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);
}
コード例 #8
0
ファイル: windows.c プロジェクト: LiberatorUSA/GUCEF
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);
}
コード例 #9
0
ファイル: keyevents.c プロジェクト: adsr/agar
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);
}
コード例 #10
0
ファイル: agar-bench.c プロジェクト: LiberatorUSA/GUCEF
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);
}
コード例 #11
0
ファイル: hsvpal.c プロジェクト: LiberatorUSA/GUCEF
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);
}
コード例 #12
0
ファイル: windows.c プロジェクト: LiberatorUSA/GUCEF
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");
}
コード例 #13
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);
}
コード例 #14
0
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);
}
コード例 #15
0
ファイル: optionsstate.cpp プロジェクト: suprafun/smalltowns
    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);
    }
コード例 #16
0
ファイル: loader.c プロジェクト: LiberatorUSA/GUCEF
/* Callback routine for AG_FileDlg. */
static int
LoadImage(AG_Event *event)
{
/*	AG_FileDlg *fd = AG_SELF(); */
	AG_Window *winParent = AG_PTR(1);
	char *file = AG_STRING(2);
	AG_FileType *ft = AG_PTR(3);
	AG_Surface *s;
	AG_Window *win;
	AG_Scrollview *sv;
	Uint8 *pSrc;
	Uint i;

	if (strcmp(ft->exts[0], "*.bmp") == 0) {
		s = AG_SurfaceFromBMP(file);
	} else if (strcmp(ft->exts[0], "*.jpg") == 0) {
		s = AG_SurfaceFromJPEG(file);
	} else if (strcmp(ft->exts[0], "*.png") == 0) {
		s = AG_SurfaceFromPNG(file);
	} else {
		AG_SetError("Unrecognized format: %s", ft->exts[0]);
		return (-1);
	}
	if (s == NULL)
		return (-1);

	if ((win = AG_WindowNew(0)) == NULL) {
		AG_SurfaceFree(s);
		return (-1);
	}
	AG_WindowSetCaption(win, "Image <%s>", AG_ShortFilename(file));

	/* We use AG_FileOptionFoo() to retrieve per-type options. */
	if (AG_FileOptionBool(ft,"invert")) {
		pSrc = (Uint8 *)s->pixels;
		for (i = 0; i < s->w*s->h; i++) {
			Uint8 r, g, b;

			AG_GetPixelRGB(AG_GET_PIXEL(s,pSrc), s->format,
			    &r,&g,&b);
			r = 255 - r;
			g = 255 - g;
			b = 255 - b;
			AG_PUT_PIXEL(s, pSrc,
			    AG_MapPixelRGB(s->format, r,g,b));
			pSrc += s->format->BytesPerPixel;
		}
	}

	/*
	 * Place an AG_Pixmap(3) widget inside of an AG_Scrollview(3) so
	 * the user can pan the view.
	 */
	sv = AG_ScrollviewNew(win, AG_SCROLLVIEW_BY_MOUSE|AG_SCROLLVIEW_EXPAND);
	AG_PixmapFromSurfaceScaled(sv, 0, s, s->w, s->h);
	AG_SurfaceFree(s);

	AG_WindowSetGeometry(win, -1, -1, 320, 240);
	AG_WindowAttach(winParent, win);
	AG_WindowShow(win);

	return (0);
}