diff --git a/benchmarks/sizeof_gui/main.cpp b/benchmarks/sizeof_gui/main.cpp index bca87bbef..56e8344b8 100644 --- a/benchmarks/sizeof_gui/main.cpp +++ b/benchmarks/sizeof_gui/main.cpp @@ -20,6 +20,7 @@ GUI_APP_MAIN RDUMP(sizeof(EditField)); RDUMP(sizeof(EditString)); RDUMP(sizeof(EditIntSpin)); + RDUMP(sizeof(EditDoubleSpin)); RDUMP(sizeof(DropList)); RDUMP(sizeof(ArrayCtrl)); RDUMP(sizeof(TreeCtrl)); diff --git a/uppsrc/CtrlLib/Button.cpp b/uppsrc/CtrlLib/Button.cpp index 064d22409..48ee172da 100644 --- a/uppsrc/CtrlLib/Button.cpp +++ b/uppsrc/CtrlLib/Button.cpp @@ -339,32 +339,38 @@ const Button::Style *Button::St() const return st; } -void Button::Paint(Draw& w) +void Button::PaintButton(Draw& w, const Rect& r, const Button::Style& st, int visualstate, bool focus, + const String& label, Font font, const Image& img, + bool monoimg, int accesskey, bool visibleaccesskeys, bool disabled) { - const Style *st = St(); - Size sz = GetSize(); - bool ds = !IsShowEnabled(); DrawLabel dl; dl.text = label; - dl.font = Nvl(font, st->font); + dl.font = Nvl(font, st.font); dl.limg = img; - dl.disabled = ds; + dl.disabled = disabled; dl.lspc = !label.IsEmpty() && !img.IsEmpty() ? 4 : 0; if(*label == '\1') dl.align = ALIGN_LEFT; - if(VisibleAccessKeys()) + if(visibleaccesskeys) dl.accesskey = accesskey; if(monoimg) dl.lcolor = SColorText; - int i = GetVisualState(); - ChPaint(w, sz, st->look[i]); - dl.ink = st->textcolor[i]; + ChPaint(w, r, st.look[visualstate]); + dl.ink = st.textcolor[visualstate]; if(monoimg) - dl.lcolor = st->monocolor[i]; - dl.Paint(w, 3 + IsPush() * st->pressoffset.x, 3 + IsPush() * st->pressoffset.y, - sz.cx - 6, sz.cy - 6); - if(HasFocus()) - DrawFocus(w, Rect(sz).Deflated(st->focusmargin)); + dl.lcolor = st.monocolor[visualstate]; + bool push = visualstate == CTRL_PRESSED; + dl.Paint(w, r.left + 3 + push * st.pressoffset.x, r.top + 3 + push * st.pressoffset.y, + r.GetWidth() - 6, r.GetHeight() - 6); + if(focus) + DrawFocus(w, r.Deflated(st.focusmargin)); +} + +void Button::Paint(Draw& w) +{ + PaintButton(w, GetSize(), *St(), GetVisualState(), HasFocus(), + label, font, img, + monoimg, accesskey, VisibleAccessKeys(), !IsShowEnabled()); } void Button::MouseEnter(Point, dword) diff --git a/uppsrc/CtrlLib/EditCtrl.h b/uppsrc/CtrlLib/EditCtrl.h index 27a593982..ead644cb2 100644 --- a/uppsrc/CtrlLib/EditCtrl.h +++ b/uppsrc/CtrlLib/EditCtrl.h @@ -94,7 +94,7 @@ protected: WString text; WString undotext; - WString nulltext; + String nulltext; Rect dropcaret; const Style *style; diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index c6facf0fe..6d92a3103 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -297,14 +297,15 @@ void EditField::Paint(Draw& w) int x = -sc; w.DrawRect(0, 0, sz.cx, fcy, paper); if(IsNull(text) && (!IsNull(nulltext) || !IsNull(nullicon))) { - const wchar *txt = nulltext; + WString nt = nulltext.ToWString(); + const wchar *txt = nt; if(!IsNull(nullicon)) { int icx = nullicon.GetWidth(); w.DrawRect(x, 0, icx + 4, fcy, paper); w.DrawImage(x, (fcy - nullicon.GetHeight()) / 2, nullicon); x += icx + 4; } - Paints(w, x, fcy, txt, nullink, paper, nulltext.GetLength(), false, nullfont, Null, false); + Paints(w, x, fcy, txt, nullink, paper, nt.GetLength(), false, nullfont, Null, false); } else { const wchar *txt = text; diff --git a/uppsrc/CtrlLib/LabelBase.h b/uppsrc/CtrlLib/LabelBase.h index bb14a7481..6efde0646 100644 --- a/uppsrc/CtrlLib/LabelBase.h +++ b/uppsrc/CtrlLib/LabelBase.h @@ -137,13 +137,13 @@ public: virtual void FrameAddSize(Size& sz); private: + Value coloredge; const Value *edge; const Ctrl *ctrl; - Value coloredge; - Color color; - bool mousein = false; - bool push = false; - bool button = false; + Color color; + bool mousein:1; + bool push:1; + bool button:1; public: void Set(const Ctrl *ctrl, const Value *edge, bool active); @@ -151,5 +151,5 @@ public: void Push(bool b) { button = true; push = b; } void SetColor(const Value& ce, Color c) { coloredge = ce; color = c; } - ActiveEdgeFrame() { edge = NULL; mousein = false; } + ActiveEdgeFrame() { edge = NULL; mousein = push = button = false; } }; diff --git a/uppsrc/CtrlLib/PushCtrl.h b/uppsrc/CtrlLib/PushCtrl.h index 2fea2b225..c7763668c 100644 --- a/uppsrc/CtrlLib/PushCtrl.h +++ b/uppsrc/CtrlLib/PushCtrl.h @@ -106,6 +106,10 @@ public: static const Style& StyleScroll(); static const Style& StyleNaked(); + static void PaintButton(Draw& w, const Rect& r, const Button::Style& st, int visualstate, bool focus, + const String& label, Font font, const Image& img, + bool monoimg, int accesskey, bool visibaleaccesskeys, bool disabled); + Button& SetStyle(const Style& s); Button& AutoStyle();