mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22:54 -06:00
CtrlLib: EditField::NullText can now have icon
git-svn-id: svn://ultimatepp.org/upp/trunk@1336 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6970fa5e04
commit
b256eeeba1
2 changed files with 22 additions and 2 deletions
|
|
@ -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; }
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue