void ZLWin32ApplicationWindow::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	Toolbar &tb = toolbar(type(button));
	if (tb.hwnd == 0) {
		return;
	}

	PostMessage(tb.hwnd, TB_CHECKBUTTON, tb.ActionCodeById[button.actionId()], button.isPressed());
}
Ejemplo n.º 2
0
void ZLToolbarCreator::startElementHandler(const char *tag, const char **attributes) {
	static const std::string BUTTON = "button";
	static const std::string MENU_BUTTON = "menuButton";
	static const std::string TOGGLE_BUTTON = "toggleButton";
	static const std::string TEXT_FIELD = "textField";
	static const std::string COMBO_BOX = "comboBox";
	static const std::string SEARCH_FIELD = "searchField";
	static const std::string SEPARATOR = "separator";
	static const std::string FILL_SEPARATOR = "fillSeparator";

	const char *id = attributeValue(attributes, "id");

	if (SEPARATOR == tag) {
		new ZLToolbar::SeparatorItem(myToolbar, ZLToolbar::Item::SEPARATOR);
	} else if (FILL_SEPARATOR == tag) {
		new ZLToolbar::SeparatorItem(myToolbar, ZLToolbar::Item::FILL_SEPARATOR);
	} else if (id == 0) {
		return;
	} else if (BUTTON == tag) {
		new ZLToolbar::PlainButtonItem(myToolbar, id);
	} else if (MENU_BUTTON == tag) {
		new ZLToolbar::MenuButtonItem(myToolbar, id);
	} else if (TOGGLE_BUTTON == tag) {
		const char *groupId = attributeValue(attributes, "group");
		const char *isDefault = attributeValue(attributes, "default");
		if (groupId != 0) {
			ZLToolbar::ButtonGroup &group = myToolbar.getButtonGroup(groupId);
			ZLToolbar::ToggleButtonItem *button = new ZLToolbar::ToggleButtonItem(myToolbar, id, group);
			if (isDefault != 0) {
				group.setDefaultAction(id);
			}
			if (group.defaultAction() == id) {
				button->press();
			}
		}
	} else if (TEXT_FIELD == tag || COMBO_BOX == tag || SEARCH_FIELD == tag) {
		const char *parameterId = attributeValue(attributes, "parameterId");
		const char *maxWidth = attributeValue(attributes, "maxWidth");
		if (parameterId != 0 && maxWidth != 0) {
			int nMaxWidth = atoi(maxWidth);
			if (nMaxWidth > 0) {
				ZLToolbar::Item::Type type = ZLToolbar::Item::TEXT_FIELD;
				if (COMBO_BOX == tag) {
					type = ZLToolbar::Item::COMBO_BOX;
				} else if (SEARCH_FIELD == tag) {
					type = ZLToolbar::Item::SEARCH_FIELD;
				}
				ZLToolbar::ParameterItem *item = new ZLToolbar::ParameterItem(
					myToolbar, type, id, parameterId, nMaxWidth
				);
				const char *symbolSet = attributeValue(attributes, "symbols");
				if (symbolSet != 0 && std::string(symbolSet) == "digits") {
					item->setSymbolSet(ZLToolbar::ParameterItem::SET_DIGITS);
				}
			}
		}
	}
}
void MyMenuBar::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	const std::string &actionId = button.actionId();
	ToolBarButton *tbButton = myButtons[actionId];
	if ((tbButton != 0) && (tbButton->toggle())) {
		changeItem(myActionIndices[actionId], tbButton->pixmap());
	}
}
void ZLGtkApplicationWindow::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	GtkToggleToolButton *gtkButton =
		GTK_TOGGLE_TOOL_BUTTON(myAbstractToGtk[&(ZLToolbar::Item&)button]);
	const bool isPressed = button.isPressed();
	if (gtk_toggle_tool_button_get_active(gtkButton) != isPressed) {
		gtk_toggle_tool_button_set_active(gtkButton, isPressed);
	}
}
void ZLQtApplicationWindow::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	((QToolButton*)myItemToWidgetMap[&button])->setOn(button.isPressed());
}
void ZLbadaApplicationWindow::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	AppLog("setToggleButtonState %s",button.actionId().c_str());

	//myActions[&button]->setChecked(button.isPressed());
}
void ZLQtApplicationWindow::setToggleButtonState(const ZLToolbar::ToggleButtonItem &button) {
	myActions[&button]->setChecked(button.isPressed());
}