mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Fix a conflict between the backported number validator and formatter
When building for wx3 on Linux, the backported number validators and formatter conflicts with the wx3 version because I never renamed them. Crashes during termination would occur because the wx3 version and our version had different vtables. I was thinking that we would just be able to delete the backported version when upgrading to wx3, but since we've made Audacity specific changes to them we can't simply start using the real wx3 versions anymore. Therefore, I needed to rename then to prevent the crashes.
This commit is contained in:
parent
22d3719db5
commit
4e8b794452
@ -786,7 +786,7 @@ void VSTEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.StartStatic(_("Buffer Size"));
|
||||
{
|
||||
wxIntegerValidator<int> vld(&mBufferSize);
|
||||
IntegerValidator<int> vld(&mBufferSize);
|
||||
vld.SetRange(8, 1048576 * 1);
|
||||
|
||||
S.AddVariableText(wxString() +
|
||||
|
@ -1279,7 +1279,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
{
|
||||
fieldText.Printf(wxT("%d"), (int)(mInputControls[p] + 0.5));
|
||||
|
||||
wxIntegerValidator<float> vld(&mInputControls[p]);
|
||||
IntegerValidator<float> vld(&mInputControls[p]);
|
||||
vld.SetRange(haslo ? lower : INT_MIN,
|
||||
hashi ? upper : INT_MAX);
|
||||
mFields[p]->SetValidator(vld);
|
||||
@ -1289,21 +1289,21 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
|
||||
fieldText = Internat::ToDisplayString(mInputControls[p]);
|
||||
|
||||
// > 12 decimal places can cause rounding errors in display.
|
||||
wxFloatingPointValidator<float> vld(6, &mInputControls[p]);
|
||||
FloatingPointValidator<float> vld(6, &mInputControls[p]);
|
||||
vld.SetRange(lower, upper);
|
||||
|
||||
// Set number of decimal places
|
||||
if (upper - lower < 10.0)
|
||||
{
|
||||
vld.SetStyle(wxNUM_VAL_THREE_TRAILING_ZEROES);
|
||||
vld.SetStyle(NUM_VAL_THREE_TRAILING_ZEROES);
|
||||
}
|
||||
else if (upper - lower < 100.0)
|
||||
{
|
||||
vld.SetStyle(wxNUM_VAL_TWO_TRAILING_ZEROES);
|
||||
vld.SetStyle(NUM_VAL_TWO_TRAILING_ZEROES);
|
||||
}
|
||||
else
|
||||
{
|
||||
vld.SetStyle(wxNUM_VAL_ONE_TRAILING_ZERO);
|
||||
vld.SetStyle(NUM_VAL_ONE_TRAILING_ZERO);
|
||||
}
|
||||
|
||||
mFields[p]->SetValidator(vld);
|
||||
|
@ -1749,20 +1749,20 @@ NyquistDialog::NyquistDialog(wxWindow * parent, wxWindowID id,
|
||||
item->SetName(ctrl->name);
|
||||
if (ctrl->type == NYQ_CTRL_REAL) {
|
||||
// > 12 decimal places can cause rounding errors in display.
|
||||
wxFloatingPointValidator<double> vld(12, &ctrl->val);
|
||||
FloatingPointValidator<double> vld(12, &ctrl->val);
|
||||
vld.SetRange(-FLT_MAX, FLT_MAX);
|
||||
// Set number of decimal places
|
||||
if (ctrl->high - ctrl->low < 10) {
|
||||
vld.SetStyle(wxNUM_VAL_THREE_TRAILING_ZEROES);
|
||||
vld.SetStyle(NUM_VAL_THREE_TRAILING_ZEROES);
|
||||
} else if (ctrl->high - ctrl->low < 100) {
|
||||
vld.SetStyle(wxNUM_VAL_TWO_TRAILING_ZEROES);
|
||||
vld.SetStyle(NUM_VAL_TWO_TRAILING_ZEROES);
|
||||
} else {
|
||||
vld.SetStyle(wxNUM_VAL_ONE_TRAILING_ZERO);
|
||||
vld.SetStyle(NUM_VAL_ONE_TRAILING_ZERO);
|
||||
}
|
||||
item->SetValidator(vld);
|
||||
}
|
||||
else {
|
||||
wxIntegerValidator<double> vld(&ctrl->val);
|
||||
IntegerValidator<double> vld(&ctrl->val);
|
||||
vld.SetRange(INT_MIN, INT_MAX);
|
||||
item->SetValidator(vld);
|
||||
}
|
||||
|
@ -1914,7 +1914,7 @@ void Meter::OnPreferences(wxCommandEvent & WXUNUSED(event))
|
||||
wxString::Format(wxT("%d"), meterRefreshRate),
|
||||
10);
|
||||
rate->SetName(_("Meter refresh rate per second [1-100]"));
|
||||
wxIntegerValidator<long> vld(&mMeterRefreshRate);
|
||||
IntegerValidator<long> vld(&mMeterRefreshRate);
|
||||
vld.SetRange(0, 100);
|
||||
rate->SetValidator(vld);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/numformatter.cpp
|
||||
// Purpose: wxNumberFormatter
|
||||
// Purpose: NumberFormatter
|
||||
// Author: Fulvio Senore, Vadim Zeitlin
|
||||
// Created: 2010-11-06
|
||||
// Copyright: (c) 2010 wxWidgets team
|
||||
@ -16,20 +16,20 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
#include "wx/msw/private.h"
|
||||
#include <wx/msw/private.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "numformatter.h"
|
||||
#include "wx/intl.h"
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include <locale.h> // for setlocale and LC_ALL
|
||||
#include <wx/log.h>
|
||||
@ -110,14 +110,14 @@ private:
|
||||
} // anonymous namespace
|
||||
|
||||
// ============================================================================
|
||||
// wxNumberFormatter implementation
|
||||
// NumberFormatter implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Locale information accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxChar wxNumberFormatter::GetDecimalSeparator()
|
||||
wxChar NumberFormatter::GetDecimalSeparator()
|
||||
{
|
||||
#if wxUSE_INTL
|
||||
// Notice that while using static variable here is not MT-safe, the worst
|
||||
@ -155,7 +155,7 @@ wxChar wxNumberFormatter::GetDecimalSeparator()
|
||||
#endif // wxUSE_INTL/!wxUSE_INTL
|
||||
}
|
||||
|
||||
bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
|
||||
bool NumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
|
||||
{
|
||||
#if wxUSE_INTL
|
||||
static wxChar s_thousandsSeparator = 0;
|
||||
@ -216,7 +216,7 @@ bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
|
||||
// Conversion to string and helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxString wxNumberFormatter::PostProcessIntString(wxString s, int style)
|
||||
wxString NumberFormatter::PostProcessIntString(wxString s, int style)
|
||||
{
|
||||
if ( style & Style_WithThousandsSep )
|
||||
AddThousandsSeparators(s);
|
||||
@ -233,14 +233,14 @@ wxString wxNumberFormatter::PostProcessIntString(wxString s, int style)
|
||||
return s;
|
||||
}
|
||||
|
||||
wxString wxNumberFormatter::ToString(long val, int style)
|
||||
wxString NumberFormatter::ToString(long val, int style)
|
||||
{
|
||||
return PostProcessIntString(wxString::Format(wxT("%ld"), val), style);
|
||||
}
|
||||
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
wxString wxNumberFormatter::ToString(wxLongLong_t val, int style)
|
||||
wxString NumberFormatter::ToString(wxLongLong_t val, int style)
|
||||
{
|
||||
#if wxCHECK_VERSION(3,0,0)
|
||||
return PostProcessIntString(wxString::Format("%" wxLongLongFmtSpec "d", val),
|
||||
@ -251,9 +251,9 @@ wxString wxNumberFormatter::ToString(wxLongLong_t val, int style)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
wxString wxNumberFormatter::ToString(double val, int precision, int style)
|
||||
wxString NumberFormatter::ToString(double val, int precision, int style)
|
||||
{
|
||||
wxString format;
|
||||
if ( precision == -1 )
|
||||
@ -287,7 +287,7 @@ wxString wxNumberFormatter::ToString(double val, int precision, int style)
|
||||
return s;
|
||||
}
|
||||
|
||||
void wxNumberFormatter::AddThousandsSeparators(wxString& s)
|
||||
void NumberFormatter::AddThousandsSeparators(wxString& s)
|
||||
{
|
||||
wxChar thousandsSep;
|
||||
if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
@ -318,7 +318,7 @@ void wxNumberFormatter::AddThousandsSeparators(wxString& s)
|
||||
}
|
||||
}
|
||||
|
||||
void wxNumberFormatter::RemoveTrailingZeroes(wxString& s, size_t retain /* = 0 */)
|
||||
void NumberFormatter::RemoveTrailingZeroes(wxString& s, size_t retain /* = 0 */)
|
||||
{
|
||||
const size_t posDecSep = s.find(GetDecimalSeparator());
|
||||
wxCHECK_RET( posDecSep != wxString::npos,
|
||||
@ -342,7 +342,7 @@ void wxNumberFormatter::RemoveTrailingZeroes(wxString& s, size_t retain /* = 0 *
|
||||
// Conversion from strings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxNumberFormatter::RemoveThousandsSeparators(wxString& s)
|
||||
void NumberFormatter::RemoveThousandsSeparators(wxString& s)
|
||||
{
|
||||
wxChar thousandsSep;
|
||||
if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
@ -351,23 +351,23 @@ void wxNumberFormatter::RemoveThousandsSeparators(wxString& s)
|
||||
s.Replace(wxString(thousandsSep), wxString());
|
||||
}
|
||||
|
||||
bool wxNumberFormatter::FromString(wxString s, long *val)
|
||||
bool NumberFormatter::FromString(wxString s, long *val)
|
||||
{
|
||||
RemoveThousandsSeparators(s);
|
||||
return s.ToLong(val);
|
||||
}
|
||||
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
bool wxNumberFormatter::FromString(wxString s, wxLongLong_t *val)
|
||||
bool NumberFormatter::FromString(wxString s, wxLongLong_t *val)
|
||||
{
|
||||
RemoveThousandsSeparators(s);
|
||||
return s.ToLongLong(val);
|
||||
}
|
||||
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
bool wxNumberFormatter::FromString(wxString s, double *val)
|
||||
bool NumberFormatter::FromString(wxString s, double *val)
|
||||
{
|
||||
RemoveThousandsSeparators(s);
|
||||
return s.ToDouble(val);
|
||||
|
@ -4,23 +4,23 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/numformatter.h
|
||||
// Purpose: wxNumberFormatter class
|
||||
// Purpose: NumberFormatter class
|
||||
// Author: Fulvio Senore, Vadim Zeitlin
|
||||
// Created: 2010-11-06
|
||||
// Copyright: (c) 2010 wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_NUMFORMATTER_H_
|
||||
#define _WX_NUMFORMATTER_H_
|
||||
#ifndef _WIDGETS_NUMFORMATTER_H_
|
||||
#define _WIDGETS_NUMFORMATTER_H_
|
||||
|
||||
#include "wx/string.h"
|
||||
#include <wx/string.h>
|
||||
|
||||
#define wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#define HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
// Helper class for formatting numbers with thousands separators which also
|
||||
// supports parsing the numbers formatted by it.
|
||||
class wxNumberFormatter
|
||||
class NumberFormatter
|
||||
{
|
||||
public:
|
||||
// Bit masks for ToString()
|
||||
@ -39,10 +39,10 @@ public:
|
||||
// precision can also be specified.
|
||||
static wxString ToString(long val,
|
||||
int style = Style_WithThousandsSep);
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
static wxString ToString(wxLongLong_t val,
|
||||
int style = Style_WithThousandsSep);
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
static wxString ToString(double val,
|
||||
int precision,
|
||||
int style = Style_WithThousandsSep);
|
||||
@ -52,9 +52,9 @@ public:
|
||||
// Return true on success and stores the result in the provided location
|
||||
// which must be a valid non-NULL pointer.
|
||||
static bool FromString(wxString s, long *val);
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#ifdef HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
static bool FromString(wxString s, wxLongLong_t *val);
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
#endif // HAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
static bool FromString(wxString s, double *val);
|
||||
|
||||
|
||||
@ -84,4 +84,4 @@ private:
|
||||
static void RemoveThousandsSeparators(wxString& s);
|
||||
};
|
||||
|
||||
#endif // _WX_NUMFORMATTER_H_
|
||||
#endif // _WIDGETS_NUMFORMATTER_H_
|
||||
|
@ -20,7 +20,7 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
@ -29,40 +29,40 @@
|
||||
#if wxUSE_VALIDATORS && wxUSE_TEXTCTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/textctrl.h"
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/textctrl.h>
|
||||
#endif
|
||||
|
||||
#include "valnum.h"
|
||||
#include "numformatter.h"
|
||||
|
||||
// ============================================================================
|
||||
// wxNumValidatorBase implementation
|
||||
// NumValidatorBase implementation
|
||||
// ============================================================================
|
||||
|
||||
BEGIN_EVENT_TABLE(wxNumValidatorBase, wxValidator)
|
||||
EVT_CHAR(wxNumValidatorBase::OnChar)
|
||||
EVT_KILL_FOCUS(wxNumValidatorBase::OnKillFocus)
|
||||
BEGIN_EVENT_TABLE(NumValidatorBase, wxValidator)
|
||||
EVT_CHAR(NumValidatorBase::OnChar)
|
||||
EVT_KILL_FOCUS(NumValidatorBase::OnKillFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
int wxNumValidatorBase::GetFormatFlags() const
|
||||
int NumValidatorBase::GetFormatFlags() const
|
||||
{
|
||||
int flags = wxNumberFormatter::Style_None;
|
||||
if ( m_style & wxNUM_VAL_THOUSANDS_SEPARATOR )
|
||||
flags |= wxNumberFormatter::Style_WithThousandsSep;
|
||||
if ( m_style & wxNUM_VAL_NO_TRAILING_ZEROES )
|
||||
flags |= wxNumberFormatter::Style_NoTrailingZeroes;
|
||||
if ( m_style & wxNUM_VAL_ONE_TRAILING_ZERO )
|
||||
flags |= wxNumberFormatter::Style_OneTrailingZero;
|
||||
if ( m_style & wxNUM_VAL_TWO_TRAILING_ZEROES )
|
||||
flags |= wxNumberFormatter::Style_TwoTrailingZeroes;
|
||||
if ( m_style & wxNUM_VAL_THREE_TRAILING_ZEROES )
|
||||
flags |= wxNumberFormatter::Style_ThreeTrailingZeroes;
|
||||
int flags = NumberFormatter::Style_None;
|
||||
if ( m_style & NUM_VAL_THOUSANDS_SEPARATOR )
|
||||
flags |= NumberFormatter::Style_WithThousandsSep;
|
||||
if ( m_style & NUM_VAL_NO_TRAILING_ZEROES )
|
||||
flags |= NumberFormatter::Style_NoTrailingZeroes;
|
||||
if ( m_style & NUM_VAL_ONE_TRAILING_ZERO )
|
||||
flags |= NumberFormatter::Style_OneTrailingZero;
|
||||
if ( m_style & NUM_VAL_TWO_TRAILING_ZEROES )
|
||||
flags |= NumberFormatter::Style_TwoTrailingZeroes;
|
||||
if ( m_style & NUM_VAL_THREE_TRAILING_ZEROES )
|
||||
flags |= NumberFormatter::Style_ThreeTrailingZeroes;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
wxTextEntry *wxNumValidatorBase::GetTextEntry() const
|
||||
wxTextEntry *NumValidatorBase::GetTextEntry() const
|
||||
{
|
||||
#if wxUSE_TEXTCTRL
|
||||
if ( wxTextCtrl *text = wxDynamicCast(m_validatorWindow, wxTextCtrl) )
|
||||
@ -74,7 +74,7 @@ wxTextEntry *wxNumValidatorBase::GetTextEntry() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool wxNumValidatorBase::Validate(wxWindow *parent)
|
||||
bool NumValidatorBase::Validate(wxWindow *parent)
|
||||
{
|
||||
// If window is disabled, simply return
|
||||
if ( !m_validatorWindow->IsEnabled() )
|
||||
@ -95,7 +95,7 @@ bool wxNumValidatorBase::Validate(wxWindow *parent)
|
||||
}
|
||||
|
||||
void
|
||||
wxNumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val,
|
||||
NumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val,
|
||||
int& pos) const
|
||||
{
|
||||
wxTextEntry * const control = GetTextEntry();
|
||||
@ -126,7 +126,7 @@ wxNumValidatorBase::GetCurrentValueAndInsertionPoint(wxString& val,
|
||||
}
|
||||
}
|
||||
|
||||
bool wxNumValidatorBase::IsMinusOk(const wxString& val, int pos) const
|
||||
bool NumValidatorBase::IsMinusOk(const wxString& val, int pos) const
|
||||
{
|
||||
// Minus is only ever accepted in the beginning of the string.
|
||||
if ( pos != 0 )
|
||||
@ -139,7 +139,7 @@ bool wxNumValidatorBase::IsMinusOk(const wxString& val, int pos) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxNumValidatorBase::OnChar(wxKeyEvent& event)
|
||||
void NumValidatorBase::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
// By default we just validate this key so don't prevent the normal
|
||||
// handling from taking place.
|
||||
@ -190,7 +190,7 @@ void wxNumValidatorBase::OnChar(wxKeyEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
void wxNumValidatorBase::OnKillFocus(wxFocusEvent& event)
|
||||
void NumValidatorBase::OnKillFocus(wxFocusEvent& event)
|
||||
{
|
||||
wxTextEntry * const control = GetTextEntry();
|
||||
if ( !control )
|
||||
@ -216,22 +216,22 @@ void wxNumValidatorBase::OnKillFocus(wxFocusEvent& event)
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxIntegerValidatorBase implementation
|
||||
// IntegerValidatorBase implementation
|
||||
// ============================================================================
|
||||
|
||||
wxString wxIntegerValidatorBase::ToString(LongestValueType value) const
|
||||
wxString IntegerValidatorBase::ToString(LongestValueType value) const
|
||||
{
|
||||
return wxNumberFormatter::ToString(value, GetFormatFlags());
|
||||
return NumberFormatter::ToString(value, GetFormatFlags());
|
||||
}
|
||||
|
||||
bool
|
||||
wxIntegerValidatorBase::FromString(const wxString& s, LongestValueType *value)
|
||||
IntegerValidatorBase::FromString(const wxString& s, LongestValueType *value)
|
||||
{
|
||||
return wxNumberFormatter::FromString(s, value);
|
||||
return NumberFormatter::FromString(s, value);
|
||||
}
|
||||
|
||||
bool
|
||||
wxIntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
|
||||
IntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
|
||||
{
|
||||
// We may accept minus sign if we can represent negative numbers at all.
|
||||
if ( ch == '-' )
|
||||
@ -252,7 +252,7 @@ wxIntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
|
||||
if ( ch < '0' || ch > '9' )
|
||||
{
|
||||
wxChar thousands;
|
||||
if ( wxNumberFormatter::GetThousandsSeparatorIfUsed(&thousands) )
|
||||
if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousands) )
|
||||
{
|
||||
if (ch != thousands)
|
||||
return false;
|
||||
@ -266,7 +266,7 @@ wxIntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxIntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
bool IntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
{
|
||||
wxTextEntry * const control = GetTextEntry();
|
||||
if ( !control )
|
||||
@ -274,13 +274,13 @@ bool wxIntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
|
||||
wxString s(control->GetValue());
|
||||
wxChar thousandsSep;
|
||||
if ( wxNumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
s.Replace(wxString(thousandsSep), wxString());
|
||||
|
||||
if ( s.empty() )
|
||||
{
|
||||
// Is blank, but allowed. Stop here
|
||||
if ( HasFlag(wxNUM_VAL_ZERO_AS_BLANK) )
|
||||
if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -308,23 +308,23 @@ bool wxIntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// wxFloatingPointValidatorBase implementation
|
||||
// FloatingPointValidatorBase implementation
|
||||
// ============================================================================
|
||||
|
||||
wxString wxFloatingPointValidatorBase::ToString(LongestValueType value) const
|
||||
wxString FloatingPointValidatorBase::ToString(LongestValueType value) const
|
||||
{
|
||||
return wxNumberFormatter::ToString(value, m_precision, GetFormatFlags());
|
||||
return NumberFormatter::ToString(value, m_precision, GetFormatFlags());
|
||||
}
|
||||
|
||||
bool
|
||||
wxFloatingPointValidatorBase::FromString(const wxString& s,
|
||||
FloatingPointValidatorBase::FromString(const wxString& s,
|
||||
LongestValueType *value)
|
||||
{
|
||||
return wxNumberFormatter::FromString(s, value);
|
||||
return NumberFormatter::FromString(s, value);
|
||||
}
|
||||
|
||||
bool
|
||||
wxFloatingPointValidatorBase::IsCharOk(const wxString& val,
|
||||
FloatingPointValidatorBase::IsCharOk(const wxString& val,
|
||||
int pos,
|
||||
wxChar ch) const
|
||||
{
|
||||
@ -349,7 +349,7 @@ wxFloatingPointValidatorBase::IsCharOk(const wxString& val,
|
||||
return true;
|
||||
}
|
||||
|
||||
const wxChar separator = wxNumberFormatter::GetDecimalSeparator();
|
||||
const wxChar separator = NumberFormatter::GetDecimalSeparator();
|
||||
if ( ch == separator )
|
||||
{
|
||||
if ( val.find(separator) != wxString::npos )
|
||||
@ -374,7 +374,7 @@ wxFloatingPointValidatorBase::IsCharOk(const wxString& val,
|
||||
if( ( ch < '0' || ch > '9' ) && ch != 'E' && ch != 'e' )
|
||||
{
|
||||
wxChar thousands;
|
||||
if ( wxNumberFormatter::GetThousandsSeparatorIfUsed(&thousands) )
|
||||
if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousands) )
|
||||
{
|
||||
if (ch != thousands)
|
||||
return false;
|
||||
@ -391,7 +391,7 @@ wxFloatingPointValidatorBase::IsCharOk(const wxString& val,
|
||||
return ValidatePrecision(str);
|
||||
}
|
||||
|
||||
bool wxFloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
bool FloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
{
|
||||
wxTextEntry * const control = GetTextEntry();
|
||||
if ( !control )
|
||||
@ -399,12 +399,12 @@ bool wxFloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
|
||||
wxString s(control->GetValue());
|
||||
wxChar thousandsSep;
|
||||
if ( wxNumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
|
||||
s.Replace(wxString(thousandsSep), wxString());
|
||||
|
||||
if ( s.empty() )
|
||||
{
|
||||
if ( HasFlag(wxNUM_VAL_ZERO_AS_BLANK) )
|
||||
if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
|
||||
return true; //Is blank, but allowed. Stop here
|
||||
else
|
||||
{
|
||||
@ -433,9 +433,9 @@ bool wxFloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
|
||||
return res;
|
||||
}
|
||||
|
||||
bool wxFloatingPointValidatorBase::ValidatePrecision(const wxString& s) const
|
||||
bool FloatingPointValidatorBase::ValidatePrecision(const wxString& s) const
|
||||
{
|
||||
size_t posSep = s.find(wxNumberFormatter::GetDecimalSeparator());
|
||||
size_t posSep = s.find(NumberFormatter::GetDecimalSeparator());
|
||||
if ( posSep == wxString::npos )
|
||||
posSep = s.length();
|
||||
|
||||
|
@ -8,36 +8,36 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_VALNUM_H_
|
||||
#define _WX_VALNUM_H_
|
||||
#ifndef _WIDGETS_VALNUM_H_
|
||||
#define _WIDGETS_VALNUM_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include <wx/defs.h>
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
|
||||
#include "wx/validate.h"
|
||||
#include <wx/validate.h>
|
||||
|
||||
#include <limits>
|
||||
|
||||
#define wxTextEntry wxTextCtrl
|
||||
|
||||
// Bit masks used for numeric validator styles.
|
||||
enum wxNumValidatorStyle
|
||||
enum NumValidatorStyle
|
||||
{
|
||||
wxNUM_VAL_DEFAULT = 0x0,
|
||||
wxNUM_VAL_THOUSANDS_SEPARATOR = 0x1,
|
||||
wxNUM_VAL_ZERO_AS_BLANK = 0x2,
|
||||
wxNUM_VAL_NO_TRAILING_ZEROES = 0x4,
|
||||
wxNUM_VAL_ONE_TRAILING_ZERO = 0x8,
|
||||
wxNUM_VAL_TWO_TRAILING_ZEROES = 0x10,
|
||||
wxNUM_VAL_THREE_TRAILING_ZEROES = 0x20
|
||||
NUM_VAL_DEFAULT = 0x0,
|
||||
NUM_VAL_THOUSANDS_SEPARATOR = 0x1,
|
||||
NUM_VAL_ZERO_AS_BLANK = 0x2,
|
||||
NUM_VAL_NO_TRAILING_ZEROES = 0x4,
|
||||
NUM_VAL_ONE_TRAILING_ZERO = 0x8,
|
||||
NUM_VAL_TWO_TRAILING_ZEROES = 0x10,
|
||||
NUM_VAL_THREE_TRAILING_ZEROES = 0x20
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Base class for all numeric validators.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxNumValidatorBase : public wxValidator
|
||||
class NumValidatorBase : public wxValidator
|
||||
{
|
||||
public:
|
||||
// Change the validator style. Usually it's specified during construction.
|
||||
@ -48,17 +48,17 @@ public:
|
||||
virtual bool Validate(wxWindow * parent);
|
||||
|
||||
protected:
|
||||
wxNumValidatorBase(int style)
|
||||
NumValidatorBase(int style)
|
||||
{
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
wxNumValidatorBase(const wxNumValidatorBase& other) : wxValidator()
|
||||
NumValidatorBase(const NumValidatorBase& other) : wxValidator()
|
||||
{
|
||||
m_style = other.m_style;
|
||||
}
|
||||
|
||||
bool HasFlag(wxNumValidatorStyle style) const
|
||||
bool HasFlag(NumValidatorStyle style) const
|
||||
{
|
||||
return (m_style & style) != 0;
|
||||
}
|
||||
@ -68,8 +68,8 @@ protected:
|
||||
// still test the return value for safety.
|
||||
wxTextEntry *GetTextEntry() const;
|
||||
|
||||
// Convert wxNUM_VAL_THOUSANDS_SEPARATOR and wxNUM_VAL_NO_TRAILING_ZEROES
|
||||
// bits of our style to the corresponding wxNumberFormatter::Style values.
|
||||
// Convert NUM_VAL_THOUSANDS_SEPARATOR and NUM_VAL_NO_TRAILING_ZEROES
|
||||
// bits of our style to the corresponding NumberFormatter::Style values.
|
||||
int GetFormatFlags() const;
|
||||
|
||||
// Return true if pressing a '-' key is acceptable for the current control
|
||||
@ -118,24 +118,24 @@ private:
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
DECLARE_NO_ASSIGN_CLASS(wxNumValidatorBase);
|
||||
DECLARE_NO_ASSIGN_CLASS(NumValidatorBase);
|
||||
};
|
||||
|
||||
namespace wxPrivate
|
||||
namespace Private
|
||||
{
|
||||
|
||||
// This is a helper class used by wxIntegerValidator and wxFloatingPointValidator
|
||||
// This is a helper class used by IntegerValidator and FloatingPointValidator
|
||||
// below that implements Transfer{To,From}Window() adapted to the type of the
|
||||
// variable.
|
||||
//
|
||||
// The template argument B is the name of the base class which must derive from
|
||||
// wxNumValidatorBase and define LongestValueType type and {To,As}String()
|
||||
// methods i.e. basically be one of wx{Integer,Number}ValidatorBase classes.
|
||||
// methods i.e. basically be one of {Integer,Number}ValidatorBase classes.
|
||||
//
|
||||
// The template argument T is just the type handled by the validator that will
|
||||
// inherit from this one.
|
||||
template <class B, typename T>
|
||||
class wxNumValidator : public B
|
||||
class NumValidator : public B
|
||||
{
|
||||
public:
|
||||
typedef B BaseValidator;
|
||||
@ -145,7 +145,7 @@ public:
|
||||
|
||||
// FIXME-VC6: This compiler fails to compile the assert below with a
|
||||
// nonsensical error C2248: "'LongestValueType' : cannot access protected
|
||||
// typedef declared in class 'wxIntegerValidatorBase'" so just disable the
|
||||
// typedef declared in class 'IntegerValidatorBase'" so just disable the
|
||||
// check for it.
|
||||
#ifndef __VISUALC6__
|
||||
wxCOMPILE_TIME_ASSERT
|
||||
@ -195,7 +195,7 @@ public:
|
||||
|
||||
const wxString s(control->GetValue());
|
||||
LongestValueType value;
|
||||
if ( s.empty() && BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) )
|
||||
if ( s.empty() && BaseValidator::HasFlag(NUM_VAL_ZERO_AS_BLANK) )
|
||||
value = 0;
|
||||
else if ( !BaseValidator::FromString(s, &value) )
|
||||
return false;
|
||||
@ -210,13 +210,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
wxNumValidator(ValueType *value, int style)
|
||||
NumValidator(ValueType *value, int style)
|
||||
: BaseValidator(style),
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
// Implement wxNumValidatorBase virtual method which is the same for
|
||||
// Implement NumValidatorBase virtual method which is the same for
|
||||
// both integer and floating point numbers.
|
||||
virtual wxString NormalizeString(const wxString& s) const
|
||||
{
|
||||
@ -228,11 +228,11 @@ protected:
|
||||
private:
|
||||
// Just a helper which is a common part of TransferToWindow() and
|
||||
// NormalizeString(): returns string representation of a number honouring
|
||||
// wxNUM_VAL_ZERO_AS_BLANK flag.
|
||||
// NUM_VAL_ZERO_AS_BLANK flag.
|
||||
wxString NormalizeValue(LongestValueType value) const
|
||||
{
|
||||
wxString s;
|
||||
if ( value != 0 || !BaseValidator::HasFlag(wxNUM_VAL_ZERO_AS_BLANK) )
|
||||
if ( value != 0 || !BaseValidator::HasFlag(NUM_VAL_ZERO_AS_BLANK) )
|
||||
s = this->ToString(value);
|
||||
|
||||
return s;
|
||||
@ -241,10 +241,10 @@ private:
|
||||
|
||||
ValueType * const m_value;
|
||||
|
||||
DECLARE_NO_ASSIGN_CLASS(wxNumValidator);
|
||||
DECLARE_NO_ASSIGN_CLASS(NumValidator);
|
||||
};
|
||||
|
||||
} // namespace wxPrivate
|
||||
} // namespace Private
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Validators for integer numbers.
|
||||
@ -253,12 +253,12 @@ private:
|
||||
// Base class for integer numbers validator. This class contains all non
|
||||
// type-dependent code of wxIntegerValidator<> and always works with values of
|
||||
// type LongestValueType. It is not meant to be used directly, please use
|
||||
// wxIntegerValidator<> only instead.
|
||||
class wxIntegerValidatorBase : public wxNumValidatorBase
|
||||
// IntegerValidator<> only instead.
|
||||
class IntegerValidatorBase : public NumValidatorBase
|
||||
{
|
||||
protected:
|
||||
// Define the type we use here, it should be the maximal-sized integer type
|
||||
// we support to make it possible to base wxIntegerValidator<> for any type
|
||||
// we support to make it possible to base IntegerValidator<> for any type
|
||||
// on it.
|
||||
#ifdef wxLongLong_t
|
||||
typedef wxLongLong_t LongestValueType;
|
||||
@ -266,27 +266,27 @@ protected:
|
||||
typedef long LongestValueType;
|
||||
#endif
|
||||
|
||||
wxIntegerValidatorBase(int style)
|
||||
: wxNumValidatorBase(style)
|
||||
IntegerValidatorBase(int style)
|
||||
: NumValidatorBase(style)
|
||||
{
|
||||
wxASSERT_MSG( !(style & wxNUM_VAL_NO_TRAILING_ZEROES),
|
||||
wxASSERT_MSG( !(style & NUM_VAL_NO_TRAILING_ZEROES),
|
||||
wxT("This style doesn't make sense for integers.") );
|
||||
wxASSERT_MSG( !(style & wxNUM_VAL_ONE_TRAILING_ZERO),
|
||||
wxASSERT_MSG( !(style & NUM_VAL_ONE_TRAILING_ZERO),
|
||||
wxT("This style doesn't make sense for integers.") );
|
||||
wxASSERT_MSG( !(style & wxNUM_VAL_TWO_TRAILING_ZEROES),
|
||||
wxASSERT_MSG( !(style & NUM_VAL_TWO_TRAILING_ZEROES),
|
||||
wxT("This style doesn't make sense for integers.") );
|
||||
wxASSERT_MSG( !(style & wxNUM_VAL_THREE_TRAILING_ZEROES),
|
||||
wxASSERT_MSG( !(style & NUM_VAL_THREE_TRAILING_ZEROES),
|
||||
wxT("This style doesn't make sense for integers.") );
|
||||
}
|
||||
|
||||
wxIntegerValidatorBase(const wxIntegerValidatorBase& other)
|
||||
: wxNumValidatorBase(other)
|
||||
IntegerValidatorBase(const IntegerValidatorBase& other)
|
||||
: NumValidatorBase(other)
|
||||
{
|
||||
m_min = other.m_min;
|
||||
m_max = other.m_max;
|
||||
}
|
||||
|
||||
// Provide methods for wxNumValidator use.
|
||||
// Provide methods for NumValidator use.
|
||||
wxString ToString(LongestValueType value) const;
|
||||
static bool FromString(const wxString& s, LongestValueType *value);
|
||||
|
||||
@ -298,7 +298,7 @@ protected:
|
||||
return m_min <= value && value <= m_max;
|
||||
}
|
||||
|
||||
// Implement wxNumValidatorBase pure virtual method.
|
||||
// Implement NumValidatorBase pure virtual method.
|
||||
virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const;
|
||||
virtual bool DoValidateNumber(wxString * errMsg) const;
|
||||
|
||||
@ -306,55 +306,55 @@ private:
|
||||
// Minimal and maximal values accepted (inclusive).
|
||||
LongestValueType m_min, m_max;
|
||||
|
||||
DECLARE_NO_ASSIGN_CLASS(wxIntegerValidatorBase);
|
||||
DECLARE_NO_ASSIGN_CLASS(IntegerValidatorBase);
|
||||
};
|
||||
|
||||
// Validator for integer numbers. It can actually work with any integer type
|
||||
// (short, int or long and long long if supported) and their unsigned versions
|
||||
// as well.
|
||||
template <typename T>
|
||||
class wxIntegerValidator
|
||||
: public wxPrivate::wxNumValidator<wxIntegerValidatorBase, T>
|
||||
class IntegerValidator
|
||||
: public Private::NumValidator<IntegerValidatorBase, T>
|
||||
{
|
||||
public:
|
||||
typedef T ValueType;
|
||||
|
||||
typedef
|
||||
wxPrivate::wxNumValidator<wxIntegerValidatorBase, T> Base;
|
||||
Private::NumValidator<IntegerValidatorBase, T> Base;
|
||||
|
||||
// Ctor for an integer validator.
|
||||
//
|
||||
// Sets the range appropriately for the type, including setting 0 as the
|
||||
// minimal value for the unsigned types.
|
||||
wxIntegerValidator(ValueType *value = NULL, int style = wxNUM_VAL_DEFAULT)
|
||||
IntegerValidator(ValueType *value = NULL, int style = NUM_VAL_DEFAULT)
|
||||
: Base(value, style)
|
||||
{
|
||||
this->DoSetMin(std::numeric_limits<ValueType>::min());
|
||||
this->DoSetMax(std::numeric_limits<ValueType>::max());
|
||||
}
|
||||
|
||||
virtual wxObject *Clone() const { return new wxIntegerValidator(*this); }
|
||||
virtual wxObject *Clone() const { return new IntegerValidator(*this); }
|
||||
|
||||
private:
|
||||
DECLARE_NO_ASSIGN_CLASS(wxIntegerValidator);
|
||||
DECLARE_NO_ASSIGN_CLASS(IntegerValidator);
|
||||
};
|
||||
|
||||
// Helper function for creating integer validators which allows to avoid
|
||||
// explicitly specifying the type as it deduces it from its parameter.
|
||||
template <typename T>
|
||||
inline wxIntegerValidator<T>
|
||||
wxMakeIntegerValidator(T *value, int style = wxNUM_VAL_DEFAULT)
|
||||
inline IntegerValidator<T>
|
||||
MakeIntegerValidator(T *value, int style = NUM_VAL_DEFAULT)
|
||||
{
|
||||
return wxIntegerValidator<T>(value, style);
|
||||
return IntegerValidator<T>(value, style);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Validators for floating point numbers.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Similar to wxIntegerValidatorBase, this class is not meant to be used
|
||||
// directly, only wxFloatingPointValidator<> should be used in the user code.
|
||||
class wxFloatingPointValidatorBase : public wxNumValidatorBase
|
||||
// Similar to IntegerValidatorBase, this class is not meant to be used
|
||||
// directly, only FloatingPointValidator<> should be used in the user code.
|
||||
class FloatingPointValidatorBase : public NumValidatorBase
|
||||
{
|
||||
public:
|
||||
// Set precision i.e. the number of digits shown (and accepted on input)
|
||||
@ -364,17 +364,17 @@ public:
|
||||
|
||||
protected:
|
||||
// Notice that we can't use "long double" here because it's not supported
|
||||
// by wxNumberFormatter yet, so restrict ourselves to just double (and
|
||||
// by NumberFormatter yet, so restrict ourselves to just double (and
|
||||
// float).
|
||||
typedef double LongestValueType;
|
||||
|
||||
wxFloatingPointValidatorBase(int style)
|
||||
: wxNumValidatorBase(style)
|
||||
FloatingPointValidatorBase(int style)
|
||||
: NumValidatorBase(style)
|
||||
{
|
||||
}
|
||||
|
||||
wxFloatingPointValidatorBase(const wxFloatingPointValidatorBase& other)
|
||||
: wxNumValidatorBase(other)
|
||||
FloatingPointValidatorBase(const FloatingPointValidatorBase& other)
|
||||
: NumValidatorBase(other)
|
||||
{
|
||||
m_precision = other.m_precision;
|
||||
|
||||
@ -382,7 +382,7 @@ protected:
|
||||
m_max = other.m_max;
|
||||
}
|
||||
|
||||
// Provide methods for wxNumValidator use.
|
||||
// Provide methods for NumValidator use.
|
||||
wxString ToString(LongestValueType value) const;
|
||||
static bool FromString(const wxString& s, LongestValueType *value);
|
||||
|
||||
@ -394,7 +394,7 @@ protected:
|
||||
return m_min <= value && value <= m_max;
|
||||
}
|
||||
|
||||
// Implement wxNumValidatorBase pure virtual method.
|
||||
// Implement NumValidatorBase pure virtual method.
|
||||
virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const;
|
||||
virtual bool DoValidateNumber(wxString * errMsg) const;
|
||||
|
||||
@ -408,22 +408,22 @@ private:
|
||||
// Minimal and maximal values accepted (inclusive).
|
||||
LongestValueType m_min, m_max;
|
||||
|
||||
DECLARE_NO_ASSIGN_CLASS(wxFloatingPointValidatorBase);
|
||||
DECLARE_NO_ASSIGN_CLASS(FloatingPointValidatorBase);
|
||||
};
|
||||
|
||||
// Validator for floating point numbers. It can be used with float, double or
|
||||
// long double values.
|
||||
template <typename T>
|
||||
class wxFloatingPointValidator
|
||||
: public wxPrivate::wxNumValidator<wxFloatingPointValidatorBase, T>
|
||||
class FloatingPointValidator
|
||||
: public Private::NumValidator<FloatingPointValidatorBase, T>
|
||||
{
|
||||
public:
|
||||
typedef T ValueType;
|
||||
typedef wxPrivate::wxNumValidator<wxFloatingPointValidatorBase, T> Base;
|
||||
typedef Private::NumValidator<FloatingPointValidatorBase, T> Base;
|
||||
|
||||
// Ctor using implicit (maximal) precision for this type.
|
||||
wxFloatingPointValidator(ValueType *value = NULL,
|
||||
int style = wxNUM_VAL_DEFAULT)
|
||||
FloatingPointValidator(ValueType *value = NULL,
|
||||
int style = NUM_VAL_DEFAULT)
|
||||
: Base(value, style)
|
||||
{
|
||||
DoSetMinMax();
|
||||
@ -432,9 +432,9 @@ public:
|
||||
}
|
||||
|
||||
// Ctor specifying an explicit precision.
|
||||
wxFloatingPointValidator(int precision,
|
||||
FloatingPointValidator(int precision,
|
||||
ValueType *value = NULL,
|
||||
int style = wxNUM_VAL_DEFAULT)
|
||||
int style = NUM_VAL_DEFAULT)
|
||||
: Base(value, style)
|
||||
{
|
||||
DoSetMinMax();
|
||||
@ -444,7 +444,7 @@ public:
|
||||
|
||||
virtual wxObject *Clone() const
|
||||
{
|
||||
return new wxFloatingPointValidator(*this);
|
||||
return new FloatingPointValidator(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -458,25 +458,25 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
// Helper similar to wxMakeIntValidator().
|
||||
// Helper similar to MakeIntValidator().
|
||||
//
|
||||
// NB: Unfortunately we can't just have a wxMakeNumericValidator() which would
|
||||
// return either wxIntegerValidator<> or wxFloatingPointValidator<> so we
|
||||
// NB: Unfortunately we can't just have a MakeNumericValidator() which would
|
||||
// return either IntegerValidator<> or FloatingPointValidator<> so we
|
||||
// do need two different functions.
|
||||
template <typename T>
|
||||
inline wxFloatingPointValidator<T>
|
||||
wxMakeFloatingPointValidator(T *value, int style = wxNUM_VAL_DEFAULT)
|
||||
inline FloatingPointValidator<T>
|
||||
MakeFloatingPointValidator(T *value, int style = NUM_VAL_DEFAULT)
|
||||
{
|
||||
return wxFloatingPointValidator<T>(value, style);
|
||||
return FloatingPointValidator<T>(value, style);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline wxFloatingPointValidator<T>
|
||||
wxMakeFloatingPointValidator(int precision, T *value, int style = wxNUM_VAL_DEFAULT)
|
||||
inline FloatingPointValidator<T>
|
||||
MakeFloatingPointValidator(int precision, T *value, int style = NUM_VAL_DEFAULT)
|
||||
{
|
||||
return wxFloatingPointValidator<T>(precision, value, style);
|
||||
return FloatingPointValidator<T>(precision, value, style);
|
||||
}
|
||||
|
||||
#endif // wxUSE_VALIDATORS
|
||||
|
||||
#endif // _WX_VALNUM_H_
|
||||
#endif // _WIDGETS_VALNUM_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user