From 5d24b07b507ca37f41ec310cc172ea59ed344026 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 18 Jun 2007 18:20:45 +0000 Subject: [PATCH] Added a copy constructor to the numeric validator, to hopefully fix the issues that xat had with it on Linux. Also, made it enforce stricter standards (that is, not allowing you to type numbers before the sign) Originally committed to SVN as r1252. --- aegisub/validators.cpp | 24 +++++++++++++++++++----- aegisub/validators.h | 3 ++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/aegisub/validators.cpp b/aegisub/validators.cpp index 24cf16e6c..cb9ae355d 100644 --- a/aegisub/validators.cpp +++ b/aegisub/validators.cpp @@ -61,6 +61,16 @@ NumValidator::NumValidator(wxString* _valPtr,bool isfloat,bool issigned) { } +//////////////////// +// Copy constructor +NumValidator::NumValidator(const NumValidator &from) { + valPtr = from.valPtr; + isFloat = from.isFloat; + isSigned = from.isSigned; + SetWindow(from.GetWindow()); +} + + /////////////// // Event table BEGIN_EVENT_TABLE(NumValidator, wxValidator) @@ -91,7 +101,7 @@ bool NumValidator::Validate(wxWindow* parent) { // Check each character bool gotDecimal = false; for (size_t i=0;i 0; - bool canSign = from == 0 && signs == 0; + bool isFirst = from == 0; + bool canSign = signs == 0; // Check character - if (!CheckCharacter(chr,canSign,gotDecimal)) { + if (!CheckCharacter(chr,isFirst,canSign,gotDecimal)) { if (!wxValidator::IsSilent()) wxBell(); return; } diff --git a/aegisub/validators.h b/aegisub/validators.h index 3b4ccf052..fe7cf497a 100644 --- a/aegisub/validators.h +++ b/aegisub/validators.h @@ -58,12 +58,13 @@ private: bool TransferToWindow(); bool TransferFromWindow(); - bool CheckCharacter(int chr,bool isFirst,bool &gotDecimal); + bool CheckCharacter(int chr,bool isFirst,bool canSign,bool &gotDecimal); void OnChar(wxKeyEvent& event); public: NumValidator(wxString* valPtr = NULL,bool isfloat=false,bool issigned=false); + NumValidator(const NumValidator& from); DECLARE_EVENT_TABLE(); };