> I decided to look at what different other "masked edit" implementations
> use for mask syntax. Here are the ones I found, for reference:
> And as much as I'm not supposed to say it, I think Qt syntax is the most
> consistent of all of them so if we really want to have a standard mask edit
> control and not something "advanced" using regex-like syntax I proposed, it
> might be not such a bad idea to copy this syntax (just to be 100% clear,
> I'm speaking about syntax only here, not the code).
Qt syntax seems good. The code... I'm not interested in Qt code. What
I have in head is more ambitious, more featured.
My mask proposal:
# Required digit.
9 Optional digit.
A Required alpha character.
a Optional alpha character.
N Required alphanumeric character (i.e. letter or digit).
n Optional alphanumeric character.
C Required character (any printable).
c Optional character.
X Required hexadecimal character [0-F]
x Optional hexadecimal character [0-F]
{x} The previous character (one of the above) is taken x times. This
is an "expander" #{3} expands into ###, H{4} expands into HHHH.
> Convert all following characters to upper case.
< Convert all following characters to lower case.
^ Switch off upper/lower case conversion
\ Escape the next character.
Note the above specifications are tested using wxIsxxx functions. So
they are locale dependant.
Any other char is a literal. It is shown in the control, but it can
not be edited.
Literals are also used as fields separators.
'|' is a special literal. It's invisible, takes no space, but still
is a fields separator.
Space is not a char (except for C command?). So pressing space-bar in
a required character position does nothing, while in an optional one
moves cursor to next char/field position.
Flags:
L Left alignment
R Right alignment
S String field. Not setting this flag means the field is numeric.
Numeric means that the digits will be joined in each key event. A
string field does not join its characters.
0 Numeric field with padding zeros
Setting S in an IP field would allow '1_2' which is nonsense. But
let's the user decide it.
No setting S for a Name field will join the chars, stripping out all spaces.
Setting R0 changes "__1" into "001"
Setting L0 is dangerous: it will change '12_' into '120'.
When contradictory flags are found, the last is taken:
Setting LR will discards L. The field will be right aligned.
Setting S0 will discard S. The field will be a numeric one.
Setting 0S will discard 0. The field will be a string one.
We can have other mask commands, such as
H Hour. Expands into 9#. Sets R flag. Sets InRange(0, 23) field checker.
T Minute or Second. Expands into 9#. Sets R flag. Sets InRange(0,
59) field checker.
D Day. Expands into 9#. Sets R flag. Sets InRange(1, 31) field checker.
M Month. Means 9# and R. InRange(1,12)
m Month name abbreviation (Jan, Feb, etc). Expands into CCC. But
allows only some values (taken from a choices array).
Y Year. Expands into ####.
y Year. Expands into 99##. So, allows 2-digits year
Regads
Manolo