Exemple #1
0
/* Save a database-bound object's state. Overwrite data if it exists. */
int
AG_DbObjectSave(void *pDbo, AG_Db *db)
{
	AG_DbObject *dbo = pDbo;
	AG_DataSource *ds;
	AG_DbEntry dbe;

	if ((ds = AG_OpenAutoCore()) == NULL)
		return (-1);
	if (AG_ObjectSerialize(dbo, ds) == -1)
		goto fail;

	dbe.key = AGOBJECT(dbo)->name;
	dbe.keySize = strlen(AGOBJECT(dbo)->name)+1;
	dbe.data = AG_CORE_SOURCE(ds)->data;
	dbe.dataSize = AG_CORE_SOURCE(ds)->size;

	if (AG_DbPut(db, &dbe) == -1 ||
	    AG_DbSync(db) == -1) {
		goto fail;
	}
	AG_CloseAutoCore(ds);
	return (0);
fail:
	AG_CloseAutoCore(ds);
	return (-1);
}
void Create_AGMainBar(AG_Widget *Parent)
{
	AG_MenuItem *item;

//	MenuBar = AG_MenuNew(Parent, AG_MENU_HFILL);
//	MenuBar = AG_MenuNewGlobal(AG_MENU_HFILL);
	if(!MenuBar) return;

	AG_LockVFS(AGOBJECT(MenuBar));
	item = AG_MenuNode(MenuBar->root , gettext("File"), NULL);
	Create_FileMenu(item);

	item = AG_MenuNode(MenuBar->root, gettext("Drive 1"), NULL);
	Create_Drive1Menu(item);

	item = AG_MenuNode(MenuBar->root, gettext("Drive 0"), NULL);
	Create_Drive0Menu(item);

 	item = AG_MenuNode(MenuBar->root, gettext("Tape"), NULL);
	Create_TapeMenu(item);
 	item = AG_MenuNode(MenuBar->root, gettext("Debug"), NULL);
        Create_DebugMenu(item);
 	item = AG_MenuNode(MenuBar->root, gettext("Tools"), NULL);
 	Create_ToolsMenu(item);
 	item = AG_MenuNode(MenuBar->root, gettext("Help"), NULL);
	Create_HelpMenu(item);
 	item = AG_MenuNode(MenuBar->root, gettext("About"), NULL);
 	Create_AboutMenu(item);
	AG_UnlockVFS(AGOBJECT(MenuBar));
	// F12 -> Menu 閉じる
	AG_ActionFn(AGWIDGET(MenuBar), "close-menu", UnraiseMenu, NULL);
    AG_ActionOnKeyDown(AGWIDGET(MenuBar), AG_KEY_F12, AG_KEYMOD_NONE, "close-menu");

}
Exemple #3
0
/* Insert a new object to the database, fail if key is taken. */
int
AG_DbObjectInsert(AG_Db *db, void *pDbo)
{
	AG_DbObject *dbo = pDbo;

	if (AG_DbExists(db, AGOBJECT(dbo)->name)) {
		AG_SetError("Existing db object: %s", AGOBJECT(dbo)->name);
		return (-1);
	}
	return AG_DbObjectSave(dbo, db);
}
/* 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);
}
Exemple #5
0
/*
 * Example of an event handler function. Event handlers use a stack of
 * arguments. Both AG_SetEvent() and AG_PostEvent() can push arguments
 * onto this stack.
 */
static void
Die(AG_Event *event)
{
	Animal *animal = AG_SELF();
	AG_Object *killer = AG_SENDER();

	printf("%s: killed by %s!\n", AGOBJECT(animal)->name, killer->name);
}
Exemple #6
0
/*
 * 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);
}
static void ConfigMenuBright(struct gui_disp *cfg, AG_NotebookTab *parent)
{
	AG_Slider *slider;
	AG_Box *box;
	AG_Box *vbox;
	AG_Label *lbl;

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Bright"));
//	slider = AG_SliderNewFltR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &fBright0, 0.0f, 1.0f);
	slider = AG_SliderNew(AGWIDGET(parent), AG_SLIDER_HORIZ, AG_SLIDER_HFILL);
        AG_SetUint16(slider, "value", cfg->nBrightness);
        AG_SetUint16(slider, "min", 0);
        AG_SetUint16(slider, "max", 255);
#ifdef USE_OPENGL
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeBright, "%p", cfg);
#endif /* USE_OPENGL */
	box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_HFILL);
}
static void VolumeMenu(AG_NotebookTab *parent, struct gui_sound *cfg)
{
	AG_Slider *slider;
	AG_Box *box;
	AG_Box *vbox;
	AG_Label *lbl;

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Main Volume"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->iTotalVolume), 0, 128);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeTotalVolume, "%p", cfg);

	box = AG_BoxNewHoriz(AGWIDGET(parent), AG_BOX_HFILL);
	AG_WidgetSetSize(AGWIDGET(box), 320, 12);
	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("PSG"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nPSGVolume), -40, 12);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("FM"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nFMVolume), -40, 12);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("BEEP"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nBeepVolume), -35, 12);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("CMT"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nCMTVolume), -35, 6);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("SFX"));
	slider = AG_SliderNewIntR(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->nWaveVolume), -35, 12);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

	lbl = AG_LabelNew(AGWIDGET(parent), 0, "%s", gettext("Channel Separation"));
	slider = AG_SliderNewUint32R(AGWIDGET(parent),AG_SLIDER_HORIZ, AG_SLIDER_HFILL, &(cfg->uChSeparation), 0, 16);
	AG_SetEvent(AGOBJECT(slider), "slider-changed", OnChangeVolume, "%p", cfg);

}