From c11228de5f2d3bfe529d924e015355748ad3f46d Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 23 Sep 2014 12:57:55 +0000 Subject: [PATCH] CtrlLib: Fixed issue with DropChoince::Dropping, TopWindow: Default action, if no breaker defined, is now IDCANCEL (not IDYES which requires accept) git-svn-id: svn://ultimatepp.org/upp/trunk@7721 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/TopWindow.cpp | 6 +++--- uppsrc/CtrlLib/DropChoice.h | 2 +- uppsrc/CtrlLib/MultiButton.cpp | 18 +++++++++++++++--- uppsrc/CtrlLib/MultiButton.h | 2 ++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/uppsrc/CtrlCore/TopWindow.cpp b/uppsrc/CtrlCore/TopWindow.cpp index d21acfe04..1cc05c993 100644 --- a/uppsrc/CtrlCore/TopWindow.cpp +++ b/uppsrc/CtrlCore/TopWindow.cpp @@ -68,9 +68,6 @@ bool TopWindow::IsShowEnabled() const void TopWindow::DefaultBreak() { - if(FindAction(IDCANCEL)) - RejectBreak(IDCANCEL); - else if(FindAction(IDNO)) RejectBreak(IDNO); else @@ -80,7 +77,10 @@ void TopWindow::DefaultBreak() if(FindAction(IDYES)) AcceptBreak(IDYES); else + if(FindAction(IDCANCEL)) AcceptBreak(IDOK); + else + RejectBreak(IDCANCEL); } void TopWindow::Close() diff --git a/uppsrc/CtrlLib/DropChoice.h b/uppsrc/CtrlLib/DropChoice.h index edb4e67fa..faf6eea27 100644 --- a/uppsrc/CtrlLib/DropChoice.h +++ b/uppsrc/CtrlLib/DropChoice.h @@ -253,7 +253,7 @@ public: const MultiButton::Style& StyleDefault() { return select.StyleFrame(); } WithDropChoice& SetStyle(const MultiButton::Style& s) { select.SetStyle(s); return *this; } - WithDropChoice& Dropping(bool b = true) { select.Show(b); return *this; } + WithDropChoice& Dropping(bool b = true) { select.MainButton().Show(b); return *this; } WithDropChoice& NoDropping() { return Dropping(false); } WithDropChoice& NoDropFocus() { select.NoDropFocus(); return *this; } WithDropChoice& Appending(const String& s = ", ") { appends = s; select.Appending(); return *this; } diff --git a/uppsrc/CtrlLib/MultiButton.cpp b/uppsrc/CtrlLib/MultiButton.cpp index e0d8c15ba..6fe13a93c 100644 --- a/uppsrc/CtrlLib/MultiButton.cpp +++ b/uppsrc/CtrlLib/MultiButton.cpp @@ -38,6 +38,7 @@ MultiButton::SubButton::SubButton() monoimg = false; enabled = true; main = false; + visible = true; } void MultiButton::SubButton::Refresh() @@ -99,6 +100,13 @@ MultiButton::SubButton& MultiButton::SubButton::Enable(bool b) return *this; } +MultiButton::SubButton& MultiButton::SubButton::Show(bool b) +{ + visible = b; + Refresh(); + return *this; +} + MultiButton::SubButton& MultiButton::AddButton() { SubButton& b = button.Add(); @@ -222,9 +230,13 @@ int MultiButton::FindButton(int px) bool MultiButton::GetPos(SubButton& b, int& lx, int& rx, int& x, int& cx, int px) { Size tsz = GetTextSize(b.label, StdFont()); - cx = Nvl(b.cx, style->stdwidth + tsz.cx); - if(IsNull(b.cx) && tsz.cx > 0 && !IsNull(b.img)) - cx += LB_IMAGE + LB_MARGIN; + if(b.visible) { + cx = Nvl(b.cx, style->stdwidth + tsz.cx); + if(IsNull(b.cx) && tsz.cx > 0 && !IsNull(b.img)) + cx += LB_IMAGE + LB_MARGIN; + } + else + cx = 0; if(b.left) { x = lx; lx += cx; diff --git a/uppsrc/CtrlLib/MultiButton.h b/uppsrc/CtrlLib/MultiButton.h index 3840d4df8..c0684747b 100644 --- a/uppsrc/CtrlLib/MultiButton.h +++ b/uppsrc/CtrlLib/MultiButton.h @@ -53,6 +53,7 @@ public: bool left; bool monoimg; bool enabled; + bool visible; String label; @@ -69,6 +70,7 @@ public: SubButton& Left(bool b = true); SubButton& Width(int w); SubButton& Enable(bool b); + SubButton& Show(bool b); SubButton& Tip(const char *s) { tip = s; return *this; } SubButton& Main(bool b = true);