Exemplo n.º 1
0
void uiControlVerifySetParent(uiControl *c, uiControl *parent)
{
	uiControl *curParent;

	if (uiControlToplevel(c))
		userbug("You cannot give a toplevel uiControl a parent. (control: %p)", c);
	curParent = uiControlParent(c);
	if (parent != NULL && curParent != NULL)
		userbug("You cannot give a uiControl a parent while it already has one. (control: %p; current parent: %p; new parent: %p)", c, curParent, parent);
	if (parent == NULL && curParent == NULL)
		implbug("attempt to double unparent uiControl %p", c);
}
Exemplo n.º 2
0
void uiMenuItemOnClicked(uiMenuItem *i, void (*f)(uiMenuItem *, uiWindow *, void *), void *data)
{
	if (i->type == typeQuit)
		userbug("You can not call uiMenuItemOnClicked() on a Quit item; use uiOnShouldQuit() instead.");
	i->onClicked = f;
	i->onClickedData = data;
}
Exemplo n.º 3
0
uiMenuItem *uiMenuAppendSubmenu(uiMenu *m, uiMenu* child)
{
	uiMenuItem *item;

	if (menusFinalized)
		userbug("You cannot create a new menu item after menus have been finalized.");

	item = uiNew(uiMenuItem);

	g_array_append_val(m->items, item);

	item->type = typeSubmenu;
	item->name = child->name;

	uiMenuItemOnClicked(item, defaultOnClicked, NULL);

    // checkme
	item->gtype = GTK_TYPE_MENU_ITEM;

	item->windows = g_hash_table_new(g_direct_hash, g_direct_equal);
	item->popupchild = child;
	child->ischild = TRUE;

	return item;
}
Exemplo n.º 4
0
uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m)
{
	if (hasPreferences)
		userbug("You can not have multiple Preferences menu items in a program.");
	hasPreferences = TRUE;
	newItem(m, typeSeparator, NULL);
	return newItem(m, typePreferences, NULL);
}
Exemplo n.º 5
0
uiMenuItem *uiMenuAppendQuitItem(uiMenu *m)
{
	if (hasQuit)
		userbug("You can not have multiple Quit menu items in a program.");
	hasQuit = TRUE;
	newItem(m, typeSeparator, NULL);
	return newItem(m, typeQuit, NULL);
}
Exemplo n.º 6
0
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
{
	if (hasAbout)
		userbug("You cannot have multiple About menu items in the same program.");
	hasAbout = TRUE;
	newItem(m, typeSeparator, NULL);
	return newItem(m, typeAbout, NULL);
}
Exemplo n.º 7
0
uiMenuItem *uiMenuAppendAboutItem(uiMenu *m)
{
	if (hasAbout)
		// TODO place these userbug strings in a header
		userbug("You can not have multiple About menu items in a program.");
	hasAbout = TRUE;
	newItem(m, typeSeparator, NULL);
	return newItem(m, typeAbout, NULL);
}
Exemplo n.º 8
0
static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
{
	uiMenuItem *item;

	if (menusFinalized)
		userbug("You cannot create a new menu item after menus have been finalized.");

	item = uiNew(uiMenuItem);

	g_array_append_val(m->items, item);

	item->type = type;
	switch (item->type) {
	case typeQuit:
		item->name = g_strdup("Quit");
		break;
	case typePreferences:
		item->name = g_strdup("Preferences...");
		break;
	case typeAbout:
		item->name = g_strdup("About");
		break;
	case typeSeparator:
		break;
	default:
		item->name = g_strdup(name);
		break;
	}

	if (item->type == typeQuit) {
		// can't call uiMenuItemOnClicked() here
		item->onClicked = onQuitClicked;
		item->onClickedData = NULL;
	} else
		uiMenuItemOnClicked(item, defaultOnClicked, NULL);

	switch (item->type) {
	case typeCheckbox:
		item->gtype = GTK_TYPE_CHECK_MENU_ITEM;
		break;
	case typeSeparator:
		item->gtype = GTK_TYPE_SEPARATOR_MENU_ITEM;
		break;
	default:
		item->gtype = GTK_TYPE_MENU_ITEM;
		break;
	}

	item->windows = g_hash_table_new(g_direct_hash, g_direct_equal);
	item->popupchild = NULL;

	return item;
}
Exemplo n.º 9
0
static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
{
	uiMenuItem *item;

	if (menusFinalized)
		userbug("You can not create a new menu item after menus have been finalized.");

	if (m->len >= m->cap) {
		m->cap += grow;
		m->items = (uiMenuItem **) uiRealloc(m->items, m->cap * sizeof (uiMenuItem *), "uiMenuitem *[]");
	}

	item = uiNew(uiMenuItem);

	m->items[m->len] = item;
	m->len++;

	item->type = type;
	switch (item->type) {
	case typeQuit:
		item->name = toUTF16("Quit");
		break;
	case typePreferences:
		item->name = toUTF16("Preferences...");
		break;
	case typeAbout:
		item->name = toUTF16("About");
		break;
	case typeSeparator:
		break;
	default:
		item->name = toUTF16(name);
		break;
	}

	if (item->type != typeSeparator) {
		item->id = curID;
		curID++;
	}

	if (item->type == typeQuit) {
		// can't call uiMenuItemOnClicked() here
		item->onClicked = onQuitClicked;
		item->onClickedData = NULL;
	} else
		uiMenuItemOnClicked(item, defaultOnClicked, NULL);

	return item;
}
Exemplo n.º 10
0
uiMenu *uiNewMenu(const char *name)
{
	uiMenu *m;

	if (menusFinalized)
		userbug("You can not create a new menu after menus have been finalized.");
	if (len >= cap) {
		cap += grow;
		menus = (uiMenu **) uiRealloc(menus, cap * sizeof (uiMenu *), "uiMenu *[]");
	}

	m = uiNew(uiMenu);

	menus[len] = m;
	len++;

	m->name = toUTF16(name);

	return m;
}
Exemplo n.º 11
0
uiMenu *uiNewMenu(const char *name)
{
	uiMenu *m;

	if (menusFinalized)
		userbug("You cannot create a new menu after menus have been finalized.");
	if (menus == NULL)
		menus = g_array_new(FALSE, TRUE, sizeof (uiMenu *));

	m = uiNew(uiMenu);

	g_array_append_val(menus, m);
	m->id = nmenus;
	nmenus++;

	m->name = g_strdup(name);
	m->items = g_array_new(FALSE, TRUE, sizeof (uiMenuItem *));
	m->ischild = FALSE;

	return m;
}
Exemplo n.º 12
0
void uiFreeControl(uiControl *c)
{
	if (uiControlParent(c) != NULL)
		userbug("You cannot destroy a uiControl while it still has a parent. (control: %p)", c);
	uiFree(c);
}