CtrlLib: LabelBox visually supports Disabled state, LabelBase has got disabledink

git-svn-id: svn://ultimatepp.org/upp/trunk@2936 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-12-27 12:22:09 +00:00
parent 8604672652
commit a2eb601c2c
3 changed files with 10 additions and 7 deletions

View file

@ -120,7 +120,7 @@ DrawLabel::DrawLabel()
lspc = rspc = 0;
limg_never_hide = false;
rimg_never_hide = false;
ink = Null;
ink = disabledink = Null;
align = valign = ALIGN_CENTER;
accesskey = 0;
accesspos = -1;
@ -209,7 +209,7 @@ Size DrawLabel::Paint(Draw& w, const Rect& r, bool visibleaccesskey) const
else
if(valign == ALIGN_CENTER)
p.y = (r.bottom + r.top - txtsz.cy) / 2;
Color color = ink;
Color color = disabled && !IsNull(disabledink) ? disabledink : ink;
if(IsNull(color))
color = disabled ? SColorDisabled : SColorLabel; /////////
int ix;
@ -293,9 +293,10 @@ LabelBase& LabelBase::SetFont(Font font) {
return *this;
}
LabelBase& LabelBase::SetInk(Color ink) {
if(lbl.ink != ink) {
LabelBase& LabelBase::SetInk(Color ink, Color disabledink) {
if(lbl.ink != ink || lbl.disabledink != disabledink) {
lbl.ink = ink;
lbl.disabledink = disabledink;
LabelUpdate();
}
return *this;

View file

@ -40,7 +40,7 @@ struct DrawLabel {
int lspc;
String text;
Font font;
Color ink;
Color ink, disabledink;
Image rimg;
Color rcolor;
int rspc;
@ -71,7 +71,8 @@ public:
LabelBase& SetPaintRect(const PaintRect& pr);
LabelBase& SetText(const char *text);
LabelBase& SetFont(Font font);
LabelBase& SetInk(Color color);
LabelBase& SetInk(Color color, Color disabledink);
LabelBase& SetInk(Color color) { return SetInk(color, color); }
LabelBase& SetRightImage(const Image& bmp2, int spc = 0, bool never_hide = false);
LabelBase& SetAlign(int align);
LabelBase& SetVAlign(int align);

View file

@ -80,11 +80,12 @@ Label::Label() {
Label::~Label() {}
CH_COLOR(LabelBoxTextColor, LtBlue());
CH_COLOR(LabelBoxDisabledTextColor, SColorDisabled());
CH_COLOR(LabelBoxColor, SColorShadow());
LabelBox::LabelBox()
{
SetInk(LabelBoxTextColor);
LabelBase::SetInk(LabelBoxTextColor, LabelBoxDisabledTextColor);
SetVAlign(ALIGN_TOP);
}