From f425b580175d3fdf717eae23c15355167a49c2ac Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Tue, 12 May 2009 20:26:19 +0000 Subject: [PATCH] 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. --- aegisub/src/auto4_lua_dialog.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/aegisub/src/auto4_lua_dialog.cpp b/aegisub/src/auto4_lua_dialog.cpp index 4373418f4..aace4d407 100644 --- a/aegisub/src/auto4_lua_dialog.cpp +++ b/aegisub/src/auto4_lua_dialog.cpp @@ -332,6 +332,8 @@ namespace Automation4 { nospin: if (!hasspin) { lua_pop(L, 1); + min = MININT; + max = MAXINT; } } @@ -354,32 +356,17 @@ nospin: value = tmp; } - typedef wxValidator IntTextValidator; // TODO wxControl *Create(wxWindow *parent) { - if (hasspin) { - wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, min, max, value); - scw->SetRange(min, max); - scw->SetValue(value); - cw = scw; - } else { - cw = new wxTextCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, 0); //, IntTextValidator()); - } - cw->SetToolTip(hint); + wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value); + scw->SetToolTip(hint); + cw = scw; return cw; } void ControlReadBack() { - if (hasspin) { - value = ((wxSpinCtrl*)cw)->GetValue(); - } else { - long newval; - text = ((wxTextCtrl*)cw)->GetValue(); - if (text.ToLong(&newval)) { - value = newval; - } - } + value = ((wxSpinCtrl*)cw)->GetValue(); } void LuaReadBack(lua_State *L)