Support float, double and file name values in wxGenericValidator.
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
This commit is contained in:
@@ -437,6 +437,10 @@ Major new features in this release
|
|||||||
2.9.3:
|
2.9.3:
|
||||||
------
|
------
|
||||||
|
|
||||||
|
All (GUI):
|
||||||
|
|
||||||
|
- Support float, double and file name values in wxGenericValidator (troelsk).
|
||||||
|
|
||||||
GTK:
|
GTK:
|
||||||
|
|
||||||
- Generate events for two auxiliary mouse buttons in wxGTK (Marcin Wojdyr).
|
- Generate events for two auxiliary mouse buttons in wxGTK (Marcin Wojdyr).
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_BASE wxDateTime;
|
class WXDLLIMPEXP_FWD_BASE wxDateTime;
|
||||||
|
class WXDLLIMPEXP_FWD_BASE wxFileName;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxGenericValidator performs data transfer between many standard controls and
|
// wxGenericValidator performs data transfer between many standard controls and
|
||||||
@@ -42,6 +43,13 @@ public:
|
|||||||
// wxDatePickerCtrl
|
// wxDatePickerCtrl
|
||||||
wxGenericValidator(wxDateTime* val);
|
wxGenericValidator(wxDateTime* val);
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
// wxTextCtrl
|
||||||
|
wxGenericValidator(wxFileName* val);
|
||||||
|
// wxTextCtrl
|
||||||
|
wxGenericValidator(float* val);
|
||||||
|
// wxTextCtrl
|
||||||
|
wxGenericValidator(double* val);
|
||||||
|
|
||||||
wxGenericValidator(const wxGenericValidator& copyFrom);
|
wxGenericValidator(const wxGenericValidator& copyFrom);
|
||||||
|
|
||||||
virtual ~wxGenericValidator(){}
|
virtual ~wxGenericValidator(){}
|
||||||
@@ -73,6 +81,9 @@ protected:
|
|||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
wxDateTime* m_pDateTime;
|
wxDateTime* m_pDateTime;
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
wxFileName* m_pFileName;
|
||||||
|
float* m_pFloat;
|
||||||
|
double* m_pDouble;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_CLASS(wxGenericValidator)
|
DECLARE_CLASS(wxGenericValidator)
|
||||||
|
@@ -96,6 +96,42 @@ public:
|
|||||||
window).
|
window).
|
||||||
*/
|
*/
|
||||||
wxGenericValidator(wxDateTime* valPtr);
|
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.
|
Destructor.
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#if wxUSE_TOGGLEBTN
|
#if wxUSE_TOGGLEBTN
|
||||||
#include "wx/tglbtn.h"
|
#include "wx/tglbtn.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
#include "wx/valgen.h"
|
#include "wx/valgen.h"
|
||||||
|
|
||||||
@@ -83,6 +84,24 @@ wxGenericValidator::wxGenericValidator(wxDateTime *val)
|
|||||||
m_pDateTime = val;
|
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
|
#endif // wxUSE_DATETIME
|
||||||
|
|
||||||
wxGenericValidator::wxGenericValidator(const wxGenericValidator& val)
|
wxGenericValidator::wxGenericValidator(const wxGenericValidator& val)
|
||||||
@@ -321,6 +340,21 @@ bool wxGenericValidator::TransferToWindow(void)
|
|||||||
pControl->SetValue(str);
|
pControl->SetValue(str);
|
||||||
return true;
|
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
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -582,6 +616,21 @@ bool wxGenericValidator::TransferFromWindow(void)
|
|||||||
*m_pInt = wxAtoi(pControl->GetValue());
|
*m_pInt = wxAtoi(pControl->GetValue());
|
||||||
return true;
|
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
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -652,6 +701,9 @@ void wxGenericValidator::Initialize()
|
|||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
m_pDateTime = NULL;
|
m_pDateTime = NULL;
|
||||||
#endif // wxUSE_DATETIME
|
#endif // wxUSE_DATETIME
|
||||||
|
m_pFileName = NULL;
|
||||||
|
m_pFloat = NULL;
|
||||||
|
m_pDouble = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_VALIDATORS
|
#endif // wxUSE_VALIDATORS
|
||||||
|
Reference in New Issue
Block a user