From d3433a84f0709e8601dcae02f50258cc804da33d Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 24 Feb 2010 21:42:15 +0000 Subject: [PATCH] Ctrl: EditField::Error (red background) git-svn-id: svn://ultimatepp.org/upp/trunk@2147 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/config.h | 6 +++--- uppsrc/CtrlLib/EditCtrl.h | 3 +++ uppsrc/CtrlLib/EditField.cpp | 4 ++-- uppsrc/CtrlLib/src.tpp/EditField$en-us.tpp | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/uppsrc/Core/config.h b/uppsrc/Core/config.h index e0154047c..8fb396126 100644 --- a/uppsrc/Core/config.h +++ b/uppsrc/Core/config.h @@ -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 diff --git a/uppsrc/CtrlLib/EditCtrl.h b/uppsrc/CtrlLib/EditCtrl.h index 188c9ccfd..e05d1325d 100644 --- a/uppsrc/CtrlLib/EditCtrl.h +++ b/uppsrc/CtrlLib/EditCtrl.h @@ -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; } diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index c99e1f429..5627d5e13 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -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()); diff --git a/uppsrc/CtrlLib/src.tpp/EditField$en-us.tpp b/uppsrc/CtrlLib/src.tpp/EditField$en-us.tpp index ecb29f2ed..fbf5bf2a2 100644 --- a/uppsrc/CtrlLib/src.tpp/EditField$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/EditField$en-us.tpp @@ -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