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/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 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;