wxWidgets: wxNumValidator< T > Class Template Reference

| Version: 3.1.5

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
wxNumValidator< T > Class Template Reference
Class List by Category » Validators

`#include </cygdrive/c/Users/Hamis/Cygwin-packaging/wxWidgets3.1/wxWidgets3.1-3.1.5-4.x86_64/src/wxWidgets-3.1.5/interface/wx/valnum.h>`

Inheritance diagram for wxNumValidator< T >:
[legend]

## Detailed Description

template<typename T>
class wxNumValidator< T >

wxNumValidator is the common base class for numeric validator classes.

This class is never used directly, but only as a base class for wxIntegerValidator and wxFloatingPointValidator.

Template Parameters

  T | Type of the values used with this validator.

<>< =''>:</>&;&;< =''>\ </></>

Since
  2.9.2

## Public Types
typedef T | ValueType
| Type of the values this validator is used with.

## Public Member Functions
void | SetMin (ValueType min)
| Sets the minimal value accepted by the validator.
ValueType | GetMin () const
| Gets the minimal value accepted by the validator.
void | SetMax (ValueType max)
| Sets the maximal value accepted by the validator.
ValueType | GetMax () const
| Gets the maximum value accepted by the validator.
void | SetRange (ValueType min, ValueType max)
| Sets both minimal and maximal values accepted by the validator.
void | GetRange (ValueType &min, ValueType &max) const
| Gets both minimal and maximal values accepted by the validator.
void | SetStyle (int style)
| Change the validator style.
virtual bool | TransferToWindow ()
| Override base class method to format the control contents.
virtual bool | TransferFromWindow ()
| Override base class method to validate the control contents.
Public Member Functions inherited from wxValidator
| wxValidator ()
| Constructor.
virtual | ~wxValidator ()
| Destructor.
virtual wxObject * | Clone () const
| All validator classes must implement the Clone() function, which returns an identical copy of itself.
wxWindow * | GetWindow () const
| Returns the window associated with the validator.
virtual void | SetWindow (wxWindow *window)
| Associates a window with the validator.
virtual bool | Validate (wxWindow *parent)
| This overridable function is called when the value in the associated window must be validated.
Public Member Functions inherited from wxEvtHandler
| wxEvtHandler ()
| Constructor.
virtual | ~wxEvtHandler ()
| Destructor.
virtual void | QueueEvent (wxEvent *event)
| Queue event for a later processing.
virtual void | AddPendingEvent (const wxEvent &event)
| Post an event to be processed later.
template<typename T, typename T1, ...>
void | CallAfter (void(T::*method)(T1,...), T1 x1,...)
| Asynchronously call the given method.
template<typename T>
void | CallAfter (const T &functor)
| Asynchronously call the given functor.
virtual bool | ProcessEvent (wxEvent &event)
| Processes an event, searching event tables and calling zero or more suitable event handler function(s).
bool | ProcessEventLocally (wxEvent &event)
| Try to process the event in this handler and all those chained to it.
bool | SafelyProcessEvent (wxEvent &event)
| Processes an event by calling ProcessEvent() and handles any exceptions that occur in the process.
void | ProcessPendingEvents ()
| Processes the pending events previously queued using QueueEvent() or AddPendingEvent(); you must call this function only if you are sure there are pending events for this handler, otherwise a `wxCHECK` will fail.
void | DeletePendingEvents ()
| Deletes all events queued on this event handler using QueueEvent() or AddPendingEvent().
void | Connect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| Connects the given function dynamically with the event handler, id and event type.
void | Connect (int id, wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
void | Connect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Connect(int, int, wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
bool | Disconnect (wxEventType eventType, wxObjectEventFunction function, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| Disconnects the given function dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed.
bool | Disconnect (int id=wxID_ANY, wxEventType eventType=wxEVT_NULL, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
bool | Disconnect (int id, int lastId, wxEventType eventType, wxObjectEventFunction function=NULL, wxObject *userData=NULL, wxEvtHandler *eventSink=NULL)
| See the Disconnect(wxEventType, wxObjectEventFunction, wxObject*, wxEvtHandler*) overload for more info.
template<typename EventTag, typename Functor>
void | Bind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| Binds the given function, functor or method dynamically with the event.
template<typename EventTag, typename Class, typename EventArg, typename EventHandler>
void | Bind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| See the Bind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info.
template<typename EventTag, typename Functor>
bool | Unbind (const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| Unbinds the given function, functor or method dynamically from the event handler, using the specified parameters as search criteria and returning true if a matching function has been found and removed.
template<typename EventTag, typename Class, typename EventArg, typename EventHandler>
bool | Unbind (const EventTag &eventType, void(Class::*method)(EventArg &), EventHandler *handler, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
| See the Unbind<>(const EventTag&, Functor, int, int, wxObject*) overload for more info.
void * | GetClientData () const
| Returns user-supplied client data.
wxClientData * | GetClientObject () const
| Returns a pointer to the user-supplied client data object.
void | SetClientData (void *data)
| Sets user-supplied client data.
void | SetClientObject (wxClientData *data)
| Set the client data object.
bool | GetEvtHandlerEnabled () const
| Returns true if the event handler is enabled, false otherwise.
wxEvtHandler * | GetNextHandler () const
| Returns the pointer to the next handler in the chain.
wxEvtHandler * | GetPreviousHandler () const
| Returns the pointer to the previous handler in the chain.
void | SetEvtHandlerEnabled (bool enabled)
| Enables or disables the event handler.
virtual void | SetNextHandler (wxEvtHandler *handler)
| Sets the pointer to the next handler.
virtual void | SetPreviousHandler (wxEvtHandler *handler)
| Sets the pointer to the previous handler.
void | Unlink ()
| Unlinks this event handler from the chain it's part of (if any); then links the "previous" event handler to the "next" one (so that the chain won't be interrupted).
bool | IsUnlinked () const
| Returns true if the next and the previous handler pointers of this event handler instance are NULL.
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data.
| wxObject (const wxObject &other)
| Copy ctor.
virtual | ~wxObject ()
| Destructor.
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class.
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj.
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone.
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer.
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data.
void | UnShare ()
| This is the same of AllocExclusive() but this method is public.
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `__WXDEBUG__` is defined.

## Protected Attributes
ValueType *const | m_value
| Pointer to the value associated with this validator.
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data.

## Additional Inherited Members
Static Public Member Functions inherited from wxValidator
static void | SuppressBellOnError (bool suppress=true)
| This functions switches on or turns off the error sound produced by the validators if an invalid key is pressed.
static bool | IsSilent ()
| Returns if the error sound is currently disabled.
static void | AddFilter (wxEventFilter *filter)
| Add an event filter whose FilterEvent() method will be called for each and every event processed by wxWidgets.
static void | RemoveFilter (wxEventFilter *filter)
| Remove a filter previously installed with AddFilter().
virtual bool | TryBefore (wxEvent &event)
| Method called by ProcessEvent() before examining this object event tables.
virtual bool | TryAfter (wxEvent &event)
| Method called by ProcessEvent() as last resort.
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object.
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.

## Member Typedef Documentation

## ◆ ValueType

template<typename T>

typedef T wxNumValidator< T >::ValueType

Type of the values this validator is used with.

## Member Function Documentation

## ◆ GetMax()

template<typename T>

ValueType wxNumValidator< T >::GetMax | ( |  | ) | const

Gets the maximum value accepted by the validator.

Since
  3.1.3

## ◆ GetMin()

template<typename T>

ValueType wxNumValidator< T >::GetMin | ( |  | ) | const

Gets the minimal value accepted by the validator.

Since
  3.1.3

## ◆ GetRange()

template<typename T>

void wxNumValidator< T >::GetRange | ( | ValueType & | min,
|  | ValueType & | max ) const

Gets both minimal and maximal values accepted by the validator.

Since
  3.1.3

## ◆ SetMax()

template<typename T>

void wxNumValidator< T >::SetMax | ( | ValueType | max | ) |

Sets the maximal value accepted by the validator.

This value is inclusive, i.e. the value equal to max is accepted.

## ◆ SetMin()

template<typename T>

void wxNumValidator< T >::SetMin | ( | ValueType | min | ) |

Sets the minimal value accepted by the validator.

This value is inclusive, i.e. the value equal to min is accepted.

## ◆ SetRange()

template<typename T>

void wxNumValidator< T >::SetRange | ( | ValueType | min,
|  | ValueType | max )

Sets both minimal and maximal values accepted by the validator.

Calling this is equivalent to calling both SetMin() and SetMax().

## ◆ SetStyle()

template<typename T>

void wxNumValidator< T >::SetStyle | ( | int | style | ) |

Change the validator style.

Can be used to change the style of the validator after its creation. The style parameter must be a combination of the values from wxNumValidatorStyle enum.

## ◆ TransferFromWindow()

template<typename T>

virtual bool wxNumValidator< T >::TransferFromWindow | ( |  | ) |
| virtual

Override base class method to validate the control contents.

This method is called to check the correctness of user input and fill the associated variable with the controls numeric value. It returns false if it is not a number in the configured range or if the control contents is empty for a validator without wxNUM_VAL_ZERO_AS_BLANK style.

It does nothing if there is no associated variable.

Reimplemented from wxValidator.

## ◆ TransferToWindow()

template<typename T>

virtual bool wxNumValidator< T >::TransferToWindow | ( |  | ) |
| virtual

Override base class method to format the control contents.

This method is called when the associated window is shown and it fills it with the contents of the associated variable, if any, formatted according to the validator style.

It does nothing if there is no associated variable.

Reimplemented from wxValidator.

## Member Data Documentation

## ◆ m_value

template<typename T>

ValueType* const wxNumValidator< T >::m_value
| protected

Pointer to the value associated with this validator.

This is the same pointer which is passed to the validator class ctor, so please note that it can be null.

This field can be useful for the derived classes overriding the base class TransferToWindow() and/or TransferFromWindow() methods, for example here is a class which treats the absent value as `1` (similarly to how using wxNUM_VAL_ZERO_AS_BLANK would treat it as `0`):

class MyMultiplierValidator : public wxFloatingPointValidator<double>
{
public:
explicit MyMultiplierValidator(double& value)
: wxFloatingPointValidator(&value)
{
SetMin(0); // Multiplier is always positive.
}
bool TransferFromWindow() override
{
if ( GetTextEntry()->IsEmpty() )
{
*m_value = 1.0;
return true;
}
if ( !wxFloatingPointValidator<double>::TransferFromWindow() )
return false;
// Multiplier must be strictly positive.
if ( *m_value == 0 )
return false;
return true;
}
wxObject* Clone() const override
{
return new MyMultiplierValidator(*this);
}
};
wxFloatingPointValidator
Validator for text entries used for floating point numbers entry.
Definition valnum.h:373
wxNumValidator::TransferFromWindow
virtual bool TransferFromWindow()
Override base class method to validate the control contents.
wxNumValidator::m_value
ValueType *const m_value
Pointer to the value associated with this validator.
Definition valnum.h:210
wxNumValidator::SetMin
void SetMin(ValueType min)
Sets the minimal value accepted by the validator.
wxObject::wxObject
wxObject()
Default ctor; initializes to NULL the internal reference data.
wxValidator::Clone
virtual wxObject * Clone() const
All validator classes must implement the Clone() function, which returns an identical copy of itself.
wxValidator::TransferFromWindow
virtual bool TransferFromWindow()
This overridable function is called when the value in the window must be transferred to the validator...

Since
  3.1.5