Integer-edits in Auto 4 Lua config dialogues now always get spin buttons. If no min/max is specified, minint/maxint are assumed.

Originally committed to SVN as r2916.
This commit is contained in:
Niels Martin Hansen 2009-05-12 20:26:19 +00:00
parent 0b4ecb9797
commit 55d5b668fa

View file

@ -332,6 +332,8 @@ namespace Automation4 {
nospin: nospin:
if (!hasspin) { if (!hasspin) {
lua_pop(L, 1); lua_pop(L, 1);
min = MININT;
max = MAXINT;
} }
} }
@ -354,32 +356,17 @@ nospin:
value = tmp; value = tmp;
} }
typedef wxValidator IntTextValidator; // TODO
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
if (hasspin) { wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value);
wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, min, max, value); scw->SetToolTip(hint);
scw->SetRange(min, max); cw = scw;
scw->SetValue(value);
cw = scw;
} else {
cw = new wxTextCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, 0); //, IntTextValidator());
}
cw->SetToolTip(hint);
return cw; return cw;
} }
void ControlReadBack() void ControlReadBack()
{ {
if (hasspin) { value = ((wxSpinCtrl*)cw)->GetValue();
value = ((wxSpinCtrl*)cw)->GetValue();
} else {
long newval;
text = ((wxTextCtrl*)cw)->GetValue();
if (text.ToLong(&newval)) {
value = newval;
}
}
} }
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)