Ctrl: EditField::Error (red background)

git-svn-id: svn://ultimatepp.org/upp/trunk@2147 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-02-24 21:42:15 +00:00
parent e7d1bca43f
commit d3433a84f0
4 changed files with 23 additions and 6 deletions

View file

@ -7,7 +7,7 @@
#define PLATFORM_WIN32
#endif
#if __unix || __unix__
#if __unix || __unix__ || __APPLE__
#define PLATFORM_POSIX 1
#ifdef flagGUI
@ -30,10 +30,10 @@
#endif
#elif __sun
#define PLATFORM_SOLARIS 1
#else
#error Unknown OS
#endif
#endif
#else
#error Unknown OS
#endif
#if __x86_64

View file

@ -130,6 +130,7 @@ protected:
bool clickselect:1;
bool nobg:1;
bool alignright:1;
bool errorbg:1;
bool FrameIsEdge();
void SetEdge(int i);
@ -195,6 +196,8 @@ public:
void Clear();
void Reset();
void Error(bool error = true) { errorbg = error; }
EditField& Password(bool pwd = true) { password = pwd; Finish(); return *this; }
EditField& SetFilter(int (*f)(int)) { filter = f; return *this; }

View file

@ -276,7 +276,7 @@ void EditField::Paint(Draw& w)
if(nobg)
paper = Null;
Color ink = enabled ? st->text : st->textdisabled;
if(convert && enabled && convert->Scan(text).IsError())
if(enabled && (convert && convert->Scan(text).IsError() || errorbg))
paper = st->invalid;
int fcy = font.Info().GetHeight();
int yy = GetTy();
@ -956,7 +956,7 @@ void EditField::Reset()
maxlen = INT_MAX;
autosize = false;
keep_selection = false;
nobg = false;
errorbg = nobg = false;
charset = CHARSET_UNICODE;
alignright = false;
SetStyle(StyleDefault());

View file

@ -188,6 +188,11 @@ _[@(0.0.255) const]&]
[s2; Resets EditField to default state.&]
[s3; &]
[s4; &]
[s5;:EditField`:`:Error`(bool`): [@(0.0.255) void]_[* Error]([@(0.0.255) bool]_[*@3 error])&]
[s2;%% If [%-*@3 error] is true, paints the content as if it was invalid
(the same way as when assigned Convert returns ErrorValue).&]
[s3;%% &]
[s4; &]
[s5;:EditField`:`:Password`(bool`): [_^EditField^ EditField][@(0.0.255) `&]_[* Password]([@(0.0.255) b
ool]_[*@3 pwd]_`=_[@(0.0.255) true])&]
[s2;%% Sets the password mode. In password mode all characters are
@ -255,6 +260,14 @@ ool]_[*@3 b]_`=_[@(0.0.255) true])&]
Returns `*this.&]
[s3; &]
[s4; &]
[s5;:EditField`:`:NullText`(const Image`&`,const char`*`,Color`): [_^EditField^ EditFie
ld][@(0.0.255) `&]_[* NullText]([@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 icon],
[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text]_`=_t`_(`"([@(0.0.255) default])`"),
[_^Color^ Color]_[*@3 ink]_`=_SColorDisabled)&]
[s5;:EditField`:`:NullText`(const Image`&`,const char`*`,Font`,Color`): [_^EditField^ E
ditField][@(0.0.255) `&]_[* NullText]([@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 i
con], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text], [_^Font^ Font]_[*@3 fnt],
[_^Color^ Color]_[*@3 ink])&]
[s5;:EditField`:`:NullText`(const char`*`,Color`): [_^EditField^ EditField][@(0.0.255) `&
]_[* NullText]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text]_`=_t`_(`"([@(0.0.255) defa
ult])`"), [_^Color^ Color]_[*@3 ink]_`=_SColorDisabled)&]
@ -262,7 +275,8 @@ ult])`"), [_^Color^ Color]_[*@3 ink]_`=_SColorDisabled)&]
]_[* NullText]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 text], [_^Font^ Font]_[*@3 fnt],
[_^Color^ Color]_[*@3 ink])&]
[s2; In NullText mode, empty EditField displays[%% ][*@3 text][%% using
][*@3 ink][%% color and ][%%*@3 fnt][%% as a font.] Returns `*this.&]
][*@3 ink][%% color and ][%%*@3 fnt][%% as a font, with ][*@3 icon][%% .]
Returns `*this.&]
[s3; &]
[s4; &]
[s5;:EditField`:`:MaxChars`(int`): [_^EditField^ EditField][@(0.0.255) `&]_[* MaxChars]([@(0.0.255) i