Skip to content

Commit ae0e4c7

Browse files
committed
Move SetTextControlValidator in the utilites file.
1 parent 8189fe9 commit ae0e4c7

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

Sources/wxWidgetsAppSupport/WXAS_ControlUtilities.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ NUIE::Key GetKeyFromEvent (wxKeyEvent& evt)
8888
return NUIE::InvalidKey;
8989
}
9090

91+
void SetTextControlValidator (wxTextCtrl* textCtrl, const std::wstring& validChars)
92+
{
93+
wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
94+
wxArrayString includeList;
95+
96+
for (const wchar_t& character : validChars) {
97+
includeList.Add (character);
98+
}
99+
100+
validator.SetIncludes (includeList);
101+
textCtrl->SetValidator (validator);
102+
}
103+
91104
NUIE::MenuCommandPtr SelectCommandFromContextMenu (wxPanel* panel, const NUIE::Point& position, const NUIE::MenuCommandStructure& commands)
92105
{
93106
if (commands.IsEmpty ()) {

Sources/wxWidgetsAppSupport/WXAS_ControlUtilities.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class BusyCursorGuard
3333
NUIE::ModifierKeys GetModiferKeysFromEvent (wxKeyboardState& evt);
3434
NUIE::Key GetKeyFromEvent (wxKeyEvent& evt);
3535

36+
void SetTextControlValidator (wxTextCtrl* textCtrl, const std::wstring& validChars);
3637
NUIE::MenuCommandPtr SelectCommandFromContextMenu (wxPanel* panel, const NUIE::Point& position, const NUIE::MenuCommandStructure& commands);
3738

3839
}

Sources/wxWidgetsAppSupport/WXAS_ParameterDialog.cpp

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "WXAS_ParameterDialog.hpp"
2+
#include "WXAS_ControlUtilities.hpp"
23
#include "NUIE_NodeParameters.hpp"
34
#include "NE_SingleValues.hpp"
45
#include "NE_Debug.hpp"
@@ -18,19 +19,6 @@ static size_t ControlIdToParamId (wxWindowID controlId)
1819
return (size_t) controlId - FirstControlId;
1920
}
2021

21-
static void SetTextValidator (wxTextCtrl* textCtrl, const std::wstring& validChars)
22-
{
23-
wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
24-
wxArrayString includeList;
25-
26-
for (const wchar_t& character : validChars) {
27-
includeList.Add (character);
28-
}
29-
30-
validator.SetIncludes (includeList);
31-
textCtrl->SetValidator (validator);
32-
}
33-
3422
ParameterDialog::ParameterDialog (wxWindow* parent, NUIE::ParameterInterfacePtr& paramInterface) :
3523
wxDialog (parent, wxID_ANY, L"Set Parameters", wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
3624
paramInterface (paramInterface),
@@ -56,19 +44,19 @@ ParameterDialog::ParameterDialog (wxWindow* parent, NUIE::ParameterInterfacePtr&
5644
} else if (type == NUIE::ParameterType::Integer) {
5745
if (DBGVERIFY (NE::Value::IsType<NE::IntValue> (value))) {
5846
wxTextCtrl* textControl = new wxTextCtrl (this, controlId, NUIE::ParameterValueToString (value, type));
59-
SetTextValidator (textControl, L"0123456789-");
47+
SetTextControlValidator (textControl, L"0123456789-");
6048
control = textControl;
6149
}
6250
} else if (type == NUIE::ParameterType::Float) {
6351
if (DBGVERIFY (NE::Value::IsType<NE::FloatValue> (value))) {
6452
wxTextCtrl* textControl = new wxTextCtrl (this, controlId, NUIE::ParameterValueToString (value, type));
65-
SetTextValidator (textControl, L"0123456789.-");
53+
SetTextControlValidator (textControl, L"0123456789.-");
6654
control = textControl;
6755
}
6856
} else if (type == NUIE::ParameterType::Double) {
6957
if (DBGVERIFY (NE::Value::IsType<NE::DoubleValue> (value))) {
7058
wxTextCtrl* textControl = new wxTextCtrl (this, controlId, NUIE::ParameterValueToString (value, type));
71-
SetTextValidator (textControl, L"0123456789.-");
59+
SetTextControlValidator (textControl, L"0123456789.-");
7260
control = textControl;
7361
}
7462
} else if (type == NUIE::ParameterType::String) {

0 commit comments

Comments
 (0)