From 905c58362166dfa4ef6ad9ba304165e963034b99 Mon Sep 17 00:00:00 2001 From: besh81 Date: Fri, 5 Oct 2018 11:45:09 +0200 Subject: [PATCH 1/2] fix folderbox init_path fix folderbox init_path --- source/gui/filebox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index fcaba515..7feda8bd 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -1257,7 +1257,7 @@ namespace nana IShellItem *init_path{ nullptr }; hr = SHCreateItemFromParsingName(impl_->init_path.wstring().c_str(), nullptr, IID_PPV_ARGS(&init_path)); if (SUCCEEDED(hr)) - fd->SetDefaultFolder(init_path); + fd->SetFolder(init_path); fd->SetOptions(FOS_PICKFOLDERS); fd->Show(reinterpret_cast(API::root(impl_->owner))); // the native handle of the parent nana form goes here From bde0d162432a6e76805670300eeb92073e022635 Mon Sep 17 00:00:00 2001 From: besh81 Date: Fri, 26 Oct 2018 17:12:22 +0200 Subject: [PATCH 2/2] Added tabbar adding event Fired when the add button of the tabbar is pressed. Changing the value of arg.add to false the action can be vetoed. The value arg.where indicates the position of the new item. --- include/nana/gui/widgets/tabbar.hpp | 22 ++++++++++++++++++++++ source/gui/widgets/tabbar.cpp | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 17a57411..0266ba20 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -35,6 +35,19 @@ namespace nana {} }; + template + struct arg_tabbar_adding + : public event_arg + { + arg_tabbar_adding(tabbar& wdg, std::size_t pos) + : widget(wdg), where(pos) + {} + + tabbar & widget; + mutable bool add = true; ///< determines whether to add the item + std::size_t where; ///< position where to add the item + }; + template struct arg_tabbar_removed : public arg_tabbar { @@ -56,6 +69,7 @@ namespace nana { using value_type = T; + basic_event> adding; basic_event> added; basic_event> activated; basic_event> removed; @@ -65,6 +79,7 @@ namespace nana { public: virtual ~event_agent_interface() = default; + virtual bool adding(std::size_t) = 0; virtual void added(std::size_t) = 0; virtual void activated(std::size_t) = 0; virtual bool removed(std::size_t, bool & close_attached) = 0; @@ -107,6 +122,13 @@ namespace nana : tabbar_(tb), drawer_trigger_(dtr) {} + bool adding(std::size_t pos) override + { + ::nana::arg_tabbar_adding arg(tabbar_, pos); + tabbar_.events().adding.emit(arg, tabbar_); + return arg.add; + } + void added(std::size_t pos) override { if(pos != npos) diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 8970089b..d5a05907 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -751,15 +751,27 @@ namespace nana if((pos == npos) || (pos >= list_.size())) { pos = list_.size(); + + if(evt_agent_) + if(!evt_agent_->adding(pos)) + return false; + this->list_.emplace_back(); } else + { + if(evt_agent_) + if(!evt_agent_->adding(pos)) + return false; + list_.emplace(iterator_at(pos)); + } basis_.active = pos; if(evt_agent_) { evt_agent_->added(pos); + erase(pos); evt_agent_->activated(pos); } return true;