-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanAll_Validate.cpp
99 lines (99 loc) · 2.16 KB
/
cleanAll_Validate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "G.h"
xStr lGetName( xStr &text )
{
xStr txt;
xStr safe = wxT( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+- _()" );
text.UpperCase();
wxChar c;
s32 i = 0;
while ( ( c = text[ i ] ) )
{
if ( safe.Contains( c ) ) txt += text[ i ];
++i;
}
return txt;
}
xStr lGetFile( xStr &text )
{
xStr txt;
xStr safe = wxT( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+- _()[]." );
text.UpperCase();
wxChar c;
s32 i = 0;
while ( ( c = text[ i ] ) )
{
if ( safe.Contains( c ) ) txt += text[ i ];
++i;
}
return txt;
}
xStr lGetPath( xStr &text )
{
xStr txt;
xStr safe = wxT( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+- _()[]/\\" );
text.UpperCase();
wxChar c;
s32 i = 0;
while ( ( c = text[ i ] ) )
{
if ( safe.Contains( c ) ) txt += text[ i ];
++i;
}
return txt;
}
void doChange( wxCommandEvent& event, s32 mode, s32 theSize )
{
wxTextCtrl* obj = ( wxTextCtrl* )event.GetEventObject();
u64 pos = obj->GetInsertionPoint();
u64 value;
u8 size;
switch ( theSize )
{
case 1: size = 2u; break;
case 2: size = 4u; break;
case 3: size = 8u; break;
default: size = 1u;
}
xStr text, tmp = obj->GetValue();
switch ( mode )
{
case VAL_HEX:
value = GetHex( tmp, size );
text.Printf( hexVLL, value );
break;
case VAL_UINT:
value = GetHexFromU64( tmp, size );
text.Printf( wxT( "%01llu" ), value );
break;
case VAL_SINT:
value = GetHexFromS64( tmp, size );
text.Printf( wxT( "%01lli" ), value );
break;
case VAL_SFLT:
if
(
tmp.EndsWith( wxT( "." ) ) ||
tmp.EndsWith( wxT( "e" ) ) ||
tmp.EndsWith( wxT( "E" ) )
)
return;
value = GetHexFromF64( tmp, size );
if ( size == 4u )
{
f32 v32 = gHexToF32( value );
text.Printf( wxT("%01g"), v32 );
}
else if ( size == 8u )
{
text.Printf( wxT("%01lg"), value );
}
break;
case VAL_NAME: text = lGetName( tmp ); break;
case VAL_PATH: text = lGetPath( tmp ); break;
case VAL_FILE: text = lGetFile( tmp ); break;
default: text = tmp;
}
obj->ChangeValue( text );
pos = ( pos > text.length() ) ? text.length() : pos;
obj->SetInsertionPoint( pos );
}