diff --git a/uppsrc/CtrlLib/EditCtrl.h b/uppsrc/CtrlLib/EditCtrl.h index b459cd092..87154de67 100644 --- a/uppsrc/CtrlLib/EditCtrl.h +++ b/uppsrc/CtrlLib/EditCtrl.h @@ -113,6 +113,7 @@ protected: WString nulltext; Color nullink; Font nullfont; + Image nullicon; int maxlen; int autosize; byte charset; @@ -202,6 +203,8 @@ public: EditField& SetFont(Font _font); EditField& ClickSelect(bool b = true) { clickselect = b; return *this; } EditField& InitCaps(bool b = true) { initcaps = b; return *this; } + EditField& NullText(const Image& icon, const char *text = t_("(default)"), Color ink = SColorDisabled); + EditField& NullText(const Image& icon, const char *text, Font fnt, Color ink); EditField& NullText(const char *text = t_("(default)"), Color ink = SColorDisabled); EditField& NullText(const char *text, Font fnt, Color ink); EditField& MaxChars(int mc) { maxlen = mc; return *this; } diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index 2e5137835..abbe4678a 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -277,8 +277,14 @@ void EditField::Paint(Draw& w) w.Clipoff(2, yy, sz.cx - 4, fcy); int x = -sc; bool ar = alignright && !HasFocus(); - if(IsNull(text) && !IsNull(nulltext)) { + if(IsNull(text) && (!IsNull(nulltext) || !IsNull(nullicon))) { const wchar *txt = nulltext; + if(!IsNull(nullicon)) { + int icx = nullicon.GetWidth(); + w.DrawRect(x, 0, icx, fcy, paper); + w.DrawImage(x, (fcy - nullicon.GetHeight()) / 2, nullicon); + x += icx + 4; + } Paints(w, x, fcy, txt, nullink, paper, nulltext.GetLength(), false, nullfont); } else { @@ -963,8 +969,9 @@ EditField& EditField::SetFont(Font _font) return *this; } -EditField& EditField::NullText(const char *text, Font fnt, Color ink) +EditField& EditField::NullText(const Image& icon, const char *text, Font fnt, Color ink) { + nullicon = icon; nulltext = text; nulltext << " "; nullink = ink; @@ -973,6 +980,16 @@ EditField& EditField::NullText(const char *text, Font fnt, Color ink) return *this; } +EditField& EditField::NullText(const Image& icon, const char *text, Color ink) +{ + return NullText(icon, text, GetFont().Italic(), ink); +} + +EditField& EditField::NullText(const char *text, Font fnt, Color ink) +{ + return NullText(Null, text, fnt, ink); +} + EditField& EditField::NullText(const char *text, Color ink) { return NullText(text, GetFont().Italic(), ink);