ZLWin32ApplicationWindow::TextEditParameter::TextEditParameter(ZLApplication &application, HWND mainWindow, HWND toolbar, int idCommand, const ZLToolbar::ParameterItem &item) : myApplication(application), myMainWindow(mainWindow), myParameterItem(item) {
	const int index = SendMessage(toolbar, TB_COMMANDTOINDEX, idCommand, 0);
	RECT rect;
	SendMessage(toolbar, TB_GETITEMRECT, index, (LPARAM)&rect);
	DWORD style = WS_CHILD | WS_VISIBLE | WS_BORDER;
	if (item.type() == ZLToolbar::Item::COMBO_BOX) {
		style |= CBS_DROPDOWN | WS_VSCROLL;
	}
	myComboBox = CreateWindow(WC_COMBOBOX, 0, style, rect.left + 5, rect.top + 8, rect.right - rect.left - 10, rect.bottom - rect.top - 14, toolbar, (HMENU)idCommand, GetModuleHandle(0), 0);
	HWND textItem = getTextItem(myComboBox);
	DWORD textItemStyle = GetWindowLong(textItem, GWL_STYLE);
	textItemStyle |= ES_CENTER | ES_NOHIDESEL;
	if (item.symbolSet() == ZLToolbar::ParameterItem::SET_DIGITS) {
		textItemStyle |= ES_NUMBER;
	}
	SetWindowLong(textItem, GWL_STYLE, textItemStyle);

	addTooltipToWindow(myComboBox, item.tooltip());
	addTooltipToWindow(getTextItem(myComboBox), item.tooltip());

	myOriginalComboBoxCallback = (WndProc)SetWindowLong(myComboBox, GWL_WNDPROC, (LONG)ComboBoxCallback);
	SetWindowLong(myComboBox, GWL_USERDATA, (LONG)this);

	HWND textEdit = getTextItem(myComboBox);
	myOriginalTextEditCallback = (WndProc)SetWindowLong(textEdit, GWL_WNDPROC, (LONG)TextEditCallback);
	SetWindowLong(textEdit, GWL_USERDATA, (LONG)this);
}
ZLQtApplicationWindow::LineEditParameter::LineEditParameter(QToolBar *toolbar, ZLQtApplicationWindow &window, const ZLToolbar::ParameterItem &textFieldItem) : QLineEdit(toolbar), myWindow(window), myActionId(textFieldItem.actionId()) {
	setAlignment(Qt::AlignHCenter);
	setFocusPolicy(ClickFocus);
	setMaxLength(textFieldItem.maxWidth());
	setMaximumWidth(textFieldItem.maxWidth() * 12 + 12);
	QToolTip::add(this, QString::fromUtf8(textFieldItem.tooltip().c_str()));
	myWindow.addVisualParameter(textFieldItem.parameterId(), this);
}
Esempio n. 3
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);
				}
			}
		}
	}
}
Esempio n. 4
0
ZLGtkApplicationWindow::GtkEntryParameter::GtkEntryParameter(ZLGtkApplicationWindow &window, const ZLToolbar::ParameterItem &item) : myWindow(window), myItem(item) {
	if (item.type() == ZLToolbar::Item::COMBO_BOX) {
		myWidget = gtk_combo_box_entry_new_text();
		myEntry = GTK_ENTRY(GTK_BIN(myWidget)->child);
		ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myEntry), "changed", GTK_SIGNAL_FUNC(::onValueChanged), this);
	} else {
		myWidget = gtk_entry_new();
		myEntry = GTK_ENTRY(myWidget);
	}
	gtk_entry_set_alignment(myEntry, 0.5);
	gtk_entry_set_width_chars(myEntry, item.maxWidth());
	gtk_entry_set_max_length(myEntry, item.maxWidth());
	if (item.symbolSet() == ZLToolbar::ParameterItem::SET_DIGITS) {
		hildon_gtk_entry_set_input_mode(myEntry, HILDON_GTK_INPUT_MODE_NUMERIC);
	} else {
		hildon_gtk_entry_set_input_mode(myEntry, HILDON_GTK_INPUT_MODE_FULL);
	}
	ZLGtkSignalUtil::connectSignal(GTK_OBJECT(myEntry), "key_press_event", GTK_SIGNAL_FUNC(::onKeyPressed), this);
}