Version: 2.9.4
Public Types | Public Member Functions
wxFloatingPointValidator< T > Class Template Reference

#include </home/zeitlin/src/wx/github/interface/wx/valnum.h>

Inheritance diagram for wxFloatingPointValidator< T >:

Detailed Description

template<typename T>
class wxFloatingPointValidator< T >

浮動小数点を入力するテキスト項目に使用するバリデータ。

This validator can be used with wxTextCtrl or wxComboBox (and potentially any other class implementing wxTextEntry interface) to check that only valid floating point values can be entered into them. Currently only fixed format is supported on input, i.e. scientific format with mantissa and exponent is not supported.

This template class can be instantiated for either float or double, long double values are not currently supported.

Similarly to wxIntegerValidator<>, the range for the accepted values is by default set appropriately for the type. Additionally, this validator allows to specify the maximum number of digits that can be entered after the decimal separator. By default this is also set appropriately for the type used, e.g. 6 for float and 15 for double on a typical IEEE-754-based implementation. As with the range, the precision can be restricted after the validator creation if necessary.

When the validator displays numbers with decimal or thousands separators, the characters used for the separators (usually "." or ",") depend on the locale set with wxLocale (note that you shouldn't change locale with setlocale() as this can result in a mismatch between the separators used by wxLocale and the one used by the run-time library).

A simple example of using this class:

        class MyDialog : public wxDialog
        {
        public:
            MyDialog()
            {
                ...
                // Allow floating point numbers from 0 to 100 with 2 decimal
                // digits only and handle empty string as 0 by default.
                wxFloatingPointValidator<float>
                    val(2, &m_value, wxNUM_VAL_ZERO_AS_BLANK);
                val.SetRange(0, 100);

                // Associate it with the text control:
                new wxTextCtrl(this, ..., val);
            }

        private:
            float m_value;
        };

For more information, please see wxValidator Overview.

Library:  wxCore
Category:  Validators
参照:
wxValidator Overview, wxValidator, wxGenericValidator, wxTextValidator, wxMakeIntegerValidator()
Since:
2.9.2

Public Types

typedef T ValueType
 Type of the values this validator is used with.

Public Member Functions

void SetPrecision (unsigned precision)
 Set precision.
 wxFloatingPointValidator (ValueType *value=NULL, int style=wxNUM_VAL_DEFAULT)
 Validator constructor.
 wxFloatingPointValidator (int precision, ValueType *value=NULL, int style=wxNUM_VAL_DEFAULT)
 Validator constructor.

List of all members.


Member Typedef Documentation

template<typename T>
typedef T wxFloatingPointValidator< T >::ValueType

Type of the values this validator is used with.

Reimplemented from wxNumValidator< T >.


Constructor & Destructor Documentation

template<typename T>
wxFloatingPointValidator< T >::wxFloatingPointValidator ( ValueType value = NULL,
int  style = wxNUM_VAL_DEFAULT 
)

Validator constructor.

Parameters:
valueA pointer to the variable associated with the validator. If non NULL, this variable should have a lifetime equal to or longer than the validator lifetime (which is usually determined by the lifetime of the window).
styleA combination of wxNumValidatorStyle enum values.
precisionThe number of decimal digits after the decimal separator to show and accept.
template<typename T>
wxFloatingPointValidator< T >::wxFloatingPointValidator ( int  precision,
ValueType value = NULL,
int  style = wxNUM_VAL_DEFAULT 
)

Validator constructor.

Parameters:
valueA pointer to the variable associated with the validator. If non NULL, this variable should have a lifetime equal to or longer than the validator lifetime (which is usually determined by the lifetime of the window).
styleA combination of wxNumValidatorStyle enum values.
precisionThe number of decimal digits after the decimal separator to show and accept.

Member Function Documentation

template<typename T>
void wxFloatingPointValidator< T >::SetPrecision ( unsigned  precision)

Set precision.

Precision is the number of digits shown (and accepted on input) after the decimal point. By default this is set to the maximal precision supported by the type handled by the validator in its constructor.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines