- wxHexValidator template added
- Translation file now suffixed with version to allow side by side installation of different wxExtend versions - Version set to 1.1 (API Level 11)
This commit is contained in:
parent
4055f49f03
commit
3d873f060b
@ -40,13 +40,13 @@ Component ComponentId Directory_ Attributes Condition KeyPath
|
||||
s$(MSIBUILD_LENGTH_ID) S38 s$(MSIBUILD_LENGTH_ID) i2 S255 S$(MSIBUILD_LENGTH_ID)
|
||||
Component Component
|
||||
!IF "$(PLAT)" == "Win32"
|
||||
compwxExtend.dll.Win32 {CF0DA67E-4D98-4059-9ECA-CB0DE44E92EB} $(WXEXTEND_BIN_DIR) 0 filewxExtend.dll.Win32
|
||||
compwxExtend.dll.Win32 {239F2FF9-E998-4F81-85A8-DA2C0A5F860B} $(WXEXTEND_BIN_DIR) 0 filewxExtend.dll.Win32
|
||||
!ENDIF
|
||||
!IF "$(PLAT)" == "x64"
|
||||
compwxExtend.dll.x64 {02F1022D-AA80-4FCA-A6F2-C576C405E1B2} $(WXEXTEND_BIN_DIR) 256 filewxExtend.dll.x64
|
||||
compwxExtend.dll.x64 {AA798500-8E4F-4554-8611-F2C225046606} $(WXEXTEND_BIN_DIR) 256 filewxExtend.dll.x64
|
||||
!ENDIF
|
||||
!IF "$(LANG)" == "Sl"
|
||||
compwxExtend.mo.sl_SI {60770F71-A7B4-4B20-9535-726049A5D412} WXEXTENDLOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.sl_SI
|
||||
compwxExtend.mo.sl_SI {026F2E74-4190-4B49-820B-94141F32F04B} WXEXTENDLOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxExtend.mo.sl_SI
|
||||
!ENDIF
|
||||
<<NOKEEP
|
||||
|
||||
@ -79,22 +79,22 @@ s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID) l255 i4 S$(MSIBUILD_LENGTH_ID) S20
|
||||
File File
|
||||
!IF "$(PLAT)" == "Win32"
|
||||
!IF "$(CFG)" == "Release"
|
||||
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~2.DLL|wxExtend10u_vc100.dll 0 0 1536 1
|
||||
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~2.DLL|wxExtend11u_vc100.dll 0 0 1536 1
|
||||
!ENDIF
|
||||
!IF "$(CFG)" == "Debug"
|
||||
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~4.DLL|wxExtend10ud_vc100.dll 0 0 1536 1
|
||||
filewxExtend.dll.Win32 compwxExtend.dll.Win32 WXEXTE~4.DLL|wxExtend11ud_vc100.dll 0 0 1536 1
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
!IF "$(PLAT)" == "x64"
|
||||
!IF "$(CFG)" == "Release"
|
||||
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~6.DLL|wxExtend10u_vc100_x64.dll 0 0 1536 1
|
||||
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~6.DLL|wxExtend11u_vc100_x64.dll 0 0 1536 1
|
||||
!ENDIF
|
||||
!IF "$(CFG)" == "Debug"
|
||||
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~8.DLL|wxExtend10ud_vc100_x64.dll 0 0 1536 1
|
||||
filewxExtend.dll.x64 compwxExtend.dll.x64 WXEXTE~8.DLL|wxExtend11ud_vc100_x64.dll 0 0 1536 1
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
!IF "$(LANG)" == "Sl"
|
||||
filewxExtend.mo.sl_SI compwxExtend.mo.sl_SI WXEXTE~1.MO|wxExtend.mo 0 1060 0 1
|
||||
filewxExtend.mo.sl_SI compwxExtend.mo.sl_SI WXEXTE~1.MO|wxExtend11.mo 0 1060 0 1
|
||||
!ENDIF
|
||||
<<NOKEEP
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros">
|
||||
<wxExtendVersion>10</wxExtendVersion>
|
||||
<wxExtendVersion>11</wxExtendVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OutDir>..\..\..\output\$(Platform).$(Configuration)\</OutDir>
|
||||
@ -11,6 +11,9 @@
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WXEXTEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<POCompile>
|
||||
<OutputFile>$(OutDir)..\locale\%(Filename)\$(ProjectName)$(wxExtendVersion).mo</OutputFile>
|
||||
</POCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<BuildMacro Include="wxExtendVersion">
|
||||
|
@ -29,6 +29,7 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\valhex.cpp" />
|
||||
<ClCompile Include="..\src\xml.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -39,6 +40,7 @@
|
||||
<ClInclude Include="..\include\wxex\hex.h" />
|
||||
<ClInclude Include="..\include\wxex\persist\auimanager.h" />
|
||||
<ClInclude Include="..\include\wxex\persist\dialog.h" />
|
||||
<ClInclude Include="..\include\wxex\valhex.h" />
|
||||
<ClInclude Include="..\include\wxex\xml.h" />
|
||||
<ClInclude Include="..\src\stdafx.h" />
|
||||
</ItemGroup>
|
||||
|
@ -40,6 +40,9 @@
|
||||
<ClCompile Include="..\src\hex.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\valhex.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\stdafx.h">
|
||||
@ -69,6 +72,9 @@
|
||||
<ClInclude Include="..\include\wxex\persist\dialog.h">
|
||||
<Filter>Header Files\persist</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\include\wxex\valhex.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\locale\wxExtend.pot">
|
||||
|
@ -23,16 +23,18 @@
|
||||
///
|
||||
/// wxExtend Version
|
||||
///
|
||||
#define wxEXTEND_VERSION 0x01000100
|
||||
#define wxEXTEND_VERSION 0x01010000
|
||||
|
||||
#define wxEXTEND_VERSION_MAJ 1
|
||||
#define wxEXTEND_VERSION_MIN 0
|
||||
#define wxEXTEND_VERSION_REV 1
|
||||
#define wxEXTEND_VERSION_MIN 1
|
||||
#define wxEXTEND_VERSION_REV 0
|
||||
#define wxEXTEND_VERSION_BUILD 0
|
||||
|
||||
#define wxEXTEND_VERSION_STR "1.0.1"
|
||||
#define wxEXTEND_VERSION_STR "1.1"
|
||||
#define wxEXTEND_BUILD_YEAR_STR "2016"
|
||||
|
||||
#define wxExtendVersion "11"
|
||||
|
||||
|
||||
#if !defined(RC_INVOKED) && !defined(MIDL_PASS)
|
||||
|
||||
|
78
include/wxex/valhex.h
Normal file
78
include/wxex/valhex.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
|
||||
This file is part of wxExtend.
|
||||
|
||||
wxExtend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
wxExtend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <wx/valnum.h>
|
||||
|
||||
|
||||
///
|
||||
/// Bit masks used for hexadecimal validator styles.
|
||||
///
|
||||
enum wxHexValidatorStyle
|
||||
{
|
||||
// Do not use values used by wxNumValidatorStyle flags, since this is the extension.
|
||||
wxNUM_VAL_HEX_LOWERCASE = 0x1000,
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Base class for hexadecimal validator
|
||||
///
|
||||
class WXEXTEND_API wxHexValidatorBase : public wxIntegerValidatorBase
|
||||
{
|
||||
protected:
|
||||
wxHexValidatorBase(int style);
|
||||
wxHexValidatorBase(const wxHexValidatorBase& other);
|
||||
|
||||
bool IsMinusOk(const wxString& val, int pos) const;
|
||||
|
||||
static bool FromString(const wxString& s, long *value);
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
static bool FromString(const wxString &s, wxLongLong_t *value);
|
||||
#endif
|
||||
wxString ToString(LongestValueType value) const;
|
||||
|
||||
private:
|
||||
virtual bool IsCharOk(const wxString& val, int pos, wxChar ch) const;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Validator for hexadecimal entries
|
||||
///
|
||||
template <typename T>
|
||||
class wxHexValidator : public wxPrivate::wxNumValidator<wxHexValidatorBase, T>
|
||||
{
|
||||
public:
|
||||
typedef wxPrivate::wxNumValidator<wxHexValidatorBase, T> Base;
|
||||
|
||||
wxHexValidator(ValueType *value = NULL, int style = wxNUM_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 wxHexValidator(*this); }
|
||||
|
||||
private:
|
||||
wxDECLARE_NO_ASSIGN_CLASS(wxHexValidator);
|
||||
};
|
@ -27,6 +27,7 @@
|
||||
#include "../include/wxex/comutils.h"
|
||||
#include "../include/wxex/crypto.h"
|
||||
#include "../include/wxex/hex.h"
|
||||
#include "../include/wxex/valhex.h"
|
||||
#include "../include/wxex/xml.h"
|
||||
|
||||
#include "../include/wxex/common.h"
|
||||
|
98
src/valhex.cpp
Normal file
98
src/valhex.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
Copyright 2015-2016 Amebis
|
||||
|
||||
This file is part of wxExtend.
|
||||
|
||||
wxExtend is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
wxExtend is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with wxExtend. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// wxHexValidatorBase
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxHexValidatorBase::wxHexValidatorBase(int style) : wxIntegerValidatorBase(style)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
wxHexValidatorBase::wxHexValidatorBase(const wxHexValidatorBase& other) : wxIntegerValidatorBase(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool wxHexValidatorBase::IsMinusOk(const wxString& val, int pos) const
|
||||
{
|
||||
// Minus is never OK with hexadecimal numbers.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool wxHexValidatorBase::FromString(const wxString& s, long *value)
|
||||
{
|
||||
return s.ToLong(value, 16);
|
||||
}
|
||||
|
||||
|
||||
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
bool wxHexValidatorBase::FromString(const wxString &s, wxLongLong_t *value)
|
||||
{
|
||||
return s.ToLongLong(value, 16);
|
||||
}
|
||||
|
||||
#endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
||||
|
||||
wxString wxHexValidatorBase::ToString(LongestValueType value) const
|
||||
{
|
||||
const wxStringCharType hexa = (HasFlag((wxNumValidatorStyle)wxNUM_VAL_HEX_LOWERCASE) ? wxT('a') : wxT('A')) - 0xa;
|
||||
int offset = sizeof(LongestValueType)*8 - 4;
|
||||
wxULongLong_t m = ((wxULongLong_t)0xf) << offset;
|
||||
unsigned int x = 0;
|
||||
|
||||
// Skip leading zeros.
|
||||
while (m && !x) {
|
||||
x = (int)((m & (wxULongLong_t)value) >> offset);
|
||||
m >>= 4, offset -= 4;
|
||||
}
|
||||
|
||||
// First digit.
|
||||
wxString str(1, (wxStringCharType)((x < 0xa ? wxT('0') : hexa) + x));
|
||||
|
||||
// Rest of the digits.
|
||||
while (m) {
|
||||
x = (int)((m & (wxULongLong_t)value) >> offset);
|
||||
m >>= 4, offset -= 4;
|
||||
str += (wxStringCharType)((x < 0xa ? wxT('0') : hexa) + x);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
bool wxHexValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
|
||||
{
|
||||
// We only accept hexadecimal digits here.
|
||||
if ((ch < '0' || ch > '9') && (ch < 'A' || ch > 'F') && (ch < 'a' || ch > 'f'))
|
||||
return false;
|
||||
|
||||
// And the value after insertion needs to be in the defined range.
|
||||
LongestValueType value;
|
||||
if (!FromString(GetValueAfterInsertingChar(val, pos, ch), &value))
|
||||
return false;
|
||||
|
||||
return IsInRange(value);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user