From 269853edf8816e44c1e4ae0de3c3255b42657673 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 10 Feb 2010 21:18:04 +0000 Subject: [PATCH] CtrlLib: TabCtrl::NoAccept git-svn-id: svn://ultimatepp.org/upp/trunk@2049 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/FindReplace.cpp | 3 ++- uppsrc/CtrlLib/TabCtrl.cpp | 4 ++-- uppsrc/CtrlLib/TabCtrl.h | 3 ++- uppsrc/CtrlLib/src.tpp/TabCtrl$en-us.tpp | 11 +++++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/uppsrc/CodeEditor/FindReplace.cpp b/uppsrc/CodeEditor/FindReplace.cpp index 634f5123c..28d57e250 100644 --- a/uppsrc/CodeEditor/FindReplace.cpp +++ b/uppsrc/CodeEditor/FindReplace.cpp @@ -408,7 +408,8 @@ void CodeEditor::FindReplace(bool pick_selection, bool pick_text, bool replace) find_text = Get(l, h - l).ToWString(); find_pos = h; } - findreplace.find <<= find_text; + if(find_text.GetCount()) + findreplace.find <<= find_text; } if(IsSelection() && replace) { findreplace.itext = GetI(); diff --git a/uppsrc/CtrlLib/TabCtrl.cpp b/uppsrc/CtrlLib/TabCtrl.cpp index cebf6ab6a..42e1f9352 100644 --- a/uppsrc/CtrlLib/TabCtrl.cpp +++ b/uppsrc/CtrlLib/TabCtrl.cpp @@ -461,7 +461,7 @@ bool TabCtrl::HotKey(dword key) bool TabCtrl::Accept() { - if(tab.GetCount() == 0) + if(tab.GetCount() == 0 || no_accept) return true; int ii = Get(); if(accept_current) @@ -498,7 +498,7 @@ TabCtrl::TabCtrl() hot = -1; sel = -1; x0 = 0; - accept_current = false; + no_accept = accept_current = false; Ctrl::Add(tabs); Ctrl::Add(pane); tabs.BackPaint().IgnoreMouse(); diff --git a/uppsrc/CtrlLib/TabCtrl.h b/uppsrc/CtrlLib/TabCtrl.h index e5c643289..14cadb328 100644 --- a/uppsrc/CtrlLib/TabCtrl.h +++ b/uppsrc/CtrlLib/TabCtrl.h @@ -79,7 +79,7 @@ private: Tabs tabs; Button left, right; ParentCtrl pane; - bool accept_current; + bool accept_current, no_accept; const Style *style; @@ -130,6 +130,7 @@ public: static const Style& StyleDefault(); + TabCtrl& NoAccept(bool ac = true) { no_accept = ac; return *this; } TabCtrl& AcceptCurrent(bool ac = true) { accept_current = ac; return *this; } TabCtrl& AcceptAll() { return AcceptCurrent(false); } TabCtrl& SetStyle(const Style& s) { style = &s; Refresh(); return *this; } diff --git a/uppsrc/CtrlLib/src.tpp/TabCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/TabCtrl$en-us.tpp index 0e3e0368c..ad425a82d 100644 --- a/uppsrc/CtrlLib/src.tpp/TabCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/TabCtrl$en-us.tpp @@ -366,6 +366,11 @@ nt]_[*@3 i])&] [s2; Sets tab [*@3 i ]as active. You can also use SetData (or operator<<`=).&] [s3; &] [s4;%- &] +[s5;:TabCtrl`:`:Set`(Ctrl`&`):%- [@(0.0.255) void]_[* Set]([_^Ctrl^ Ctrl][@(0.0.255) `&]_[*@3 s +lave])&] +[s2; Sets tab with [%-*@3 slave] widget as active.&] +[s3; &] +[s4;%- &] [s5;:TabCtrl`:`:Get`(`)const:%- [@(0.0.255) int]_[* Get]()_[@(0.0.255) const]&] [s2; Returns the index of active tab. You can also use GetData (or operator`~).&] @@ -399,6 +404,12 @@ them.&] [s2; Same as Add([%-*@3 c]). Returns `*this.&] [s3; &] [s4;%- &] +[s5;:TabCtrl`:`:NoAccept`(bool`):%- [_^TabCtrl^ TabCtrl][@(0.0.255) `&]_[* NoAccept]([@(0.0.255) b +ool]_[*@3 ac]_`=_[@(0.0.255) true])&] +[s2; If active, TabCtrl Accept method does not call any of slave +widgets Accept.&] +[s3; &] +[s4;%- &] [s5;:TabCtrl`:`:AcceptCurrent`(bool`):%- [_^TabCtrl^ TabCtrl][@(0.0.255) `&]_[* AcceptCurre nt]([@(0.0.255) bool]_[*@3 ac]_`=_[@(0.0.255) true])&] [s2; If AcceptCurrent is active (default is not active), TabCtrl