wxExtend
Additional templates and function helpers for wxWidgets
Loading...
Searching...
No Matches
valhex.h
1/*
2 ​​​SPDX-License-Identifier: GPL-3.0-or-later
3 Copyright © 2015-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
7#pragma once
8
9#include "common.h"
10
11#include <codeanalysis\warnings.h>
12#pragma warning(push)
13#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
14#include <wx/valnum.h>
15#pragma warning(pop)
16
19
24{
25 // Do not use values used by wxNumValidatorStyle flags, since this is the extension.
26 wxNUM_VAL_HEX_LOWERCASE = 0x1000,
27};
28
29
30#ifdef __VISUALC__
31// non dll-interface class 'xxx' used as base for dll-interface class 'yyy'
32#pragma warning (push)
33#pragma warning (disable:4275)
34#endif
35
39class WXEXTEND_API wxHexValidatorBase : public wxIntegerValidatorBase
40{
41protected:
45 wxHexValidatorBase(int style);
46
51
57 bool IsMinusOk(const wxString& val, int pos) const;
58
62 static bool FromString(const wxString& s, long *value);
63
64#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
68 static bool FromString(const wxString &s, wxLongLong_t *value);
69#endif
70
74 wxString ToString(LongestValueType value) const;
75
76protected:
78 void DoSetWidth(unsigned int width) { m_width = width; }
80
81private:
83 virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const;
85
86private:
87 unsigned int m_width;
88};
89
90#ifdef __VISUALC__
91#pragma warning(pop)
92#endif
93
94
98template <typename T>
99class wxHexValidator : public wxPrivate::wxNumValidator<wxHexValidatorBase, T>
100{
101public:
102 typedef wxPrivate::wxNumValidator<wxHexValidatorBase, T> Base;
103
107 wxHexValidator(T *value = NULL, int style = wxNUM_VAL_DEFAULT, unsigned int width = 0) : Base(value, style)
108 {
109 this->DoSetWidth(width);
110 this->DoSetMin(std::numeric_limits<T>::min());
111 this->DoSetMax(std::numeric_limits<T>::max());
112 }
113
117 virtual wxObject *Clone() const { return new wxHexValidator(*this); }
118
119private:
120 wxDECLARE_NO_ASSIGN_CLASS(wxHexValidator);
121};
122
Base class for hexadecimal validator.
Definition valhex.h:40
Validator for hexadecimal entries.
Definition valhex.h:100
wxHexValidator(T *value=NULL, int style=wxNUM_VAL_DEFAULT, unsigned int width=0)
Constructs new hexadecimal validator.
Definition valhex.h:107
wxPrivate::wxNumValidator< wxHexValidatorBase, T > Base
Base class type.
Definition valhex.h:102
virtual wxObject * Clone() const
Clones this validator.
Definition valhex.h:117
wxHexValidatorStyle
Bit masks used for hexadecimal validator styles.
Definition valhex.h:24
#define WXEXTEND_API
Public function calling convention.
Definition common.h:56