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);
}
Exemplo n.º 2
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);
}