Currently these values can only be read from/written to wxTextCtrl but support
for other controls (e.g. wxSpinCtrlDouble for float/double) could be added in
the future.
Closes #13304.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68217
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
2.9.3:
------
+All (GUI):
+
+- Support float, double and file name values in wxGenericValidator (troelsk).
+
GTK:
- Generate events for two auxiliary mouse buttons in wxGTK (Marcin Wojdyr).
#if wxUSE_VALIDATORS
class WXDLLIMPEXP_FWD_BASE wxDateTime;
+class WXDLLIMPEXP_FWD_BASE wxFileName;
// ----------------------------------------------------------------------------
// wxGenericValidator performs data transfer between many standard controls and
// wxDatePickerCtrl
wxGenericValidator(wxDateTime* val);
#endif // wxUSE_DATETIME
+ // wxTextCtrl
+ wxGenericValidator(wxFileName* val);
+ // wxTextCtrl
+ wxGenericValidator(float* val);
+ // wxTextCtrl
+ wxGenericValidator(double* val);
+
wxGenericValidator(const wxGenericValidator& copyFrom);
virtual ~wxGenericValidator(){}
#if wxUSE_DATETIME
wxDateTime* m_pDateTime;
#endif // wxUSE_DATETIME
+ wxFileName* m_pFileName;
+ float* m_pFloat;
+ double* m_pDouble;
private:
DECLARE_CLASS(wxGenericValidator)
window).
*/
wxGenericValidator(wxDateTime* valPtr);
+ /**
+ Constructor taking a wxFileName pointer. This will be used for
+ wxTextCtrl.
+
+ @param valPtr
+ A pointer to a variable that contains the value. This variable
+ should have a lifetime equal to or longer than the validator
+ lifetime (which is usually determined by the lifetime of the
+ window).
+ @since 2.9.3
+ */
+ wxGenericValidator(wxFileName* valPtr);
+ /**
+ Constructor taking a float pointer. This will be used for
+ wxTextCtrl.
+
+ @param valPtr
+ A pointer to a variable that contains the value. This variable
+ should have a lifetime equal to or longer than the validator
+ lifetime (which is usually determined by the lifetime of the
+ window).
+ @since 2.9.3
+ */
+ wxGenericValidator(float* valPtr);
+ /**
+ Constructor taking a double pointer. This will be used for
+ wxTextCtrl.
+
+ @param valPtr
+ A pointer to a variable that contains the value. This variable
+ should have a lifetime equal to or longer than the validator
+ lifetime (which is usually determined by the lifetime of the
+ window).
+ @since 2.9.3
+ */
+ wxGenericValidator(double* valPtr);
/**
Destructor.
#if wxUSE_TOGGLEBTN
#include "wx/tglbtn.h"
#endif
+#include "wx/filename.h"
#include "wx/valgen.h"
m_pDateTime = val;
}
+wxGenericValidator::wxGenericValidator(wxFileName *val)
+{
+ Initialize();
+ m_pFileName = val;
+}
+
+wxGenericValidator::wxGenericValidator(float *val)
+{
+ Initialize();
+ m_pFloat = val;
+}
+
+wxGenericValidator::wxGenericValidator(double *val)
+{
+ Initialize();
+ m_pDouble = val;
+}
+
#endif // wxUSE_DATETIME
wxGenericValidator::wxGenericValidator(const wxGenericValidator& val)
pControl->SetValue(str);
return true;
}
+ else if (m_pFileName)
+ {
+ pControl->SetValue(m_pFileName->GetFullPath());
+ return true;
+ }
+ else if (m_pFloat)
+ {
+ pControl->SetValue(wxString::Format(wxT("%g"), *m_pFloat));
+ return true;
+ }
+ else if (m_pDouble)
+ {
+ pControl->SetValue(wxString::Format(wxT("%g"), *m_pDouble));
+ return true;
+ }
} else
#endif
*m_pInt = wxAtoi(pControl->GetValue());
return true;
}
+ else if (m_pFileName)
+ {
+ m_pFileName->Assign(pControl->GetValue());
+ return true;
+ }
+ else if (m_pFloat)
+ {
+ *m_pFloat = (float)wxAtof(pControl->GetValue());
+ return true;
+ }
+ else if (m_pDouble)
+ {
+ *m_pDouble = wxAtof(pControl->GetValue());
+ return true;
+ }
} else
#endif
#if wxUSE_DATETIME
m_pDateTime = NULL;
#endif // wxUSE_DATETIME
+ m_pFileName = NULL;
+ m_pFloat = NULL;
+ m_pDouble = NULL;
}
#endif // wxUSE_VALIDATORS