diff --git a/include/nana/gui/detail/general_events.hpp b/include/nana/gui/detail/general_events.hpp index e801dba5..0ff84083 100644 --- a/include/nana/gui/detail/general_events.hpp +++ b/include/nana/gui/detail/general_events.hpp @@ -231,11 +231,6 @@ namespace nana }; } - static std::function build_second(fn_type&& fn, void(fn_type::*)(arg_reference)) - { - return std::move(fn); - } - template static std::function build_second(Tfn&& fn, Ret(fn_type::*)()const) { @@ -245,11 +240,36 @@ namespace nana }; } + static std::function build_second(fn_type&& fn, void(fn_type::*)(arg_reference)) + { + return std::move(fn); + } + static std::function build_second(fn_type&& fn, void(fn_type::*)(arg_reference) const) { return std::move(fn); } + static std::function build_second(fn_type& fn, void(fn_type::*)(arg_reference)) + { + return fn; + } + + static std::function build_second(fn_type& fn, void(fn_type::*)(arg_reference) const) + { + return fn; + } + + static std::function build_second(const fn_type& fn, void(fn_type::*)(arg_reference)) + { + return fn; + } + + static std::function build_second(const fn_type& fn, void(fn_type::*)(arg_reference) const) + { + return fn; + } + template static std::function build_second(Tfn&& fn, Ret(fn_type::*)(Arg2)) { @@ -259,7 +279,7 @@ namespace nana fn(arg); }; } - + template static std::function build_second(Tfn&& fn, Ret(fn_type::*)(Arg2)const) { diff --git a/include/nana/gui/widgets/skeletons/text_token_stream.hpp b/include/nana/gui/widgets/skeletons/text_token_stream.hpp index 7fbd3801..f529299b 100644 --- a/include/nana/gui/widgets/skeletons/text_token_stream.hpp +++ b/include/nana/gui/widgets/skeletons/text_token_stream.hpp @@ -15,7 +15,6 @@ #include -#include #include #include #include @@ -86,26 +85,12 @@ namespace nana{ namespace widgets{ namespace skeletons std::pair binary_number() const { - std::stringstream ss; - ss<(nana::charset(binary_.first))<<' '<(nana::charset(binary_.second)); - - std::pair r; - ss>>r.first>>r.second; - return r; + return{ std::stoul(binary_.first), std::stoul(binary_.second) }; } int number() const { - std::stringstream ss; - ss<(nana::charset(idstr_)); - - //It's a hex number. - if(idstr_.size() > 2 && idstr_[0] == '0' && (idstr_[1] == 'x' || idstr_[1] == 'X')) - ss>>std::hex; - - int n; - ss>>n; - return n; + return std::stoi(idstr_, nullptr, 0); } private: static bool _m_unicode_word_breakable(wchar_t ch) diff --git a/source/gui/detail/bedrock_windows.cpp b/source/gui/detail/bedrock_windows.cpp index 2915ec1c..1f557bca 100644 --- a/source/gui/detail/bedrock_windows.cpp +++ b/source/gui/detail/bedrock_windows.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -252,9 +251,8 @@ namespace detail { if(wd_manager().number_of_core_window()) { - std::stringstream ss; - ss<<"Nana.GUI detects a memory leaks in window_manager, "<(wd_manager().number_of_core_window())<<" window(s) are not uninstalled."; - ::MessageBoxA(0, ss.str().c_str(), ("Nana C++ Library"), MB_OK); + std::string msg = "Nana.GUI detects a memory leaks in window_manager, " + std::to_string(wd_manager().number_of_core_window()) + " window(s) are not uninstalled."; + ::MessageBoxA(0, msg.c_str(), ("Nana C++ Library"), MB_OK); } delete impl_; diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index dd20cf6e..4b5cb5f3 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -708,7 +708,7 @@ namespace nana impl->spinbox.size({ value_px, 24 }); }); - impl->spinbox.events().destroy.connect_unignorable([impl] + impl->spinbox.events().destroy.connect_unignorable([impl](const arg_destroy&) { impl->value = impl->spinbox.to_int(); }); @@ -786,7 +786,7 @@ namespace nana impl->spinbox.size(::nana::size{ value_px, 24 }); }); - impl->spinbox.events().destroy.connect_unignorable([impl] + impl->spinbox.events().destroy.connect_unignorable([impl](const arg_destroy&) { impl->value = impl->spinbox.to_double(); }); @@ -913,7 +913,7 @@ namespace nana }); auto & wdg = (value_px ? static_cast(impl->combox) : static_cast(impl->textbox)); - wdg.events().destroy.connect_unignorable([&wdg, impl] + wdg.events().destroy.connect_unignorable([&wdg, impl](const arg_destroy&) { impl->value = wdg.caption(); }); @@ -1028,16 +1028,19 @@ namespace nana impl->wdg_year.size(sz); }); - impl->wdg_day.events().destroy.connect_unignorable([impl] + auto destroy_fn = [impl](const arg_destroy& arg) { - impl->day = impl->wdg_day.to_int(); - impl->month = static_cast(impl->wdg_month.option()) + 1; - }); + if (arg.window_handle == impl->wdg_day.handle()) + { + impl->day = impl->wdg_day.to_int(); + impl->month = static_cast(impl->wdg_month.option()) + 1; + } + else if(arg.window_handle == impl->wdg_year.handle()) + impl->year = impl->wdg_year.to_int(); + }; - impl->wdg_year.events().destroy.connect_unignorable([impl] - { - impl->year = impl->wdg_year.to_int(); - }); + impl->wdg_day.events().destroy.connect_unignorable(destroy_fn); + impl->wdg_year.events().destroy.connect_unignorable(destroy_fn); auto make_days = [impl] { @@ -1123,7 +1126,7 @@ namespace nana impl->browse.create(impl->dock); impl->browse.i18n(i18n_eval("Browse")); - impl->browse.events().click([wd, impl] + impl->browse.events().click([wd, impl](const arg_click&) { impl->fbox.owner(wd); if (impl->fbox.show()) @@ -1140,7 +1143,7 @@ namespace nana impl->browse.move({static_cast(arg.width - 60), 0, 60, arg.height}); }); - impl->path_edit.events().destroy.connect_unignorable([impl] + impl->path_edit.events().destroy.connect_unignorable([impl](const arg_destroy&) { impl->value = impl->path_edit.caption(); }); diff --git a/source/gui/place.cpp b/source/gui/place.cpp index b7fadf7f..d0796c90 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -304,9 +304,7 @@ namespace nana void _m_throw_error(const std::string& err) { - std::stringstream ss; - ss << "place: " << err << " at " << static_cast(sp_ - divstr_); - throw std::runtime_error(ss.str()); + throw std::runtime_error("nana::place: " + err + " at " + std::to_string(static_cast(sp_ - divstr_))); } void _m_attr_number_value() diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 1832d74a..1d21d600 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -203,7 +203,6 @@ namespace nana destroy_dockarea = (0 == tabbar_->length()); } - if (destroy_dockarea) notifier_->request_close(); }); @@ -224,7 +223,6 @@ namespace nana else r.height = arg.height - 20; } - for (auto & pn : panels_) { @@ -313,7 +311,7 @@ namespace nana std::size_t pos = 0; for (auto & pn : panels_) { - tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); + tabbar_->push_back(pn.widget_ptr->caption()); tabbar_->attach(pos++, *pn.widget_ptr); } } @@ -330,9 +328,7 @@ namespace nana } if (panels_.empty()) - { caption_.caption(wdg->caption()); - } panels_.emplace_back(); panels_.back().widget_ptr.swap(wdg); @@ -359,8 +355,6 @@ namespace nana graph.rectangle(false, colors::coral); }); - - API::set_parent_window(handle(), container_->handle()); this->move({ 1, 1 }); diff --git a/source/gui/widgets/button.cpp b/source/gui/widgets/button.cpp index 301c07c7..1b7aa835 100644 --- a/source/gui/widgets/button.cpp +++ b/source/gui/widgets/button.cpp @@ -479,7 +479,7 @@ namespace nana{ namespace drawerbase void button::_m_complete_creation() { - events().shortkey.connect_unignorable([this] + events().shortkey.connect_unignorable([this](const arg_keyboard&) { get_drawer_trigger().emit_click(); }); diff --git a/source/gui/widgets/categorize.cpp b/source/gui/widgets/categorize.cpp index 3c10b41f..230369c8 100644 --- a/source/gui/widgets/categorize.cpp +++ b/source/gui/widgets/categorize.cpp @@ -571,7 +571,7 @@ namespace nana style_.listbox = &(form_loader()(window_, r, true)); style_.listbox->set_module(style_.module, 16); - style_.listbox->events().destroy.connect_unignorable([this] + style_.listbox->events().destroy.connect_unignorable([this](const arg_destroy&) { //Close list when listbox is destoryed style_.mode = mode::normal; diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index c5df35f8..6d803e18 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -1,7 +1,7 @@ /* * A Combox Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -253,12 +253,25 @@ namespace nana state_.lister->renderer(item_renderer_); state_.lister->set_module(module_, image_pixels_); state_.item_index_before_selection = module_.index; + //The lister window closes by itself. I just take care about the destroy event. //The event should be destroy rather than unload. Because the unload event is invoked while //the lister is not closed, if popuping a message box, the lister will cover the message box. - state_.lister->events().destroy.connect_unignorable([this] + state_.lister->events().destroy.connect_unignorable([this](const arg_destroy&) { - _m_lister_close_sig(); + state_.lister = nullptr; //The lister closes by itself. + if ((module_.index != nana::npos) && (module_.index != state_.item_index_before_selection)) + { + option(module_.index, true); + API::update_window(*widget_); + } + else + { + //Redraw the widget even though the index has not been changed, + //because the push button should be updated due to the state + //changed from pressed to normal/hovered. + API::refresh_window(*widget_); + } }); } } @@ -432,23 +445,6 @@ namespace nana return true; } private: - void _m_lister_close_sig() - { - state_.lister = nullptr; //The lister closes by itself. - if ((module_.index != nana::npos) && (module_.index != state_.item_index_before_selection)) - { - option(module_.index, true); - API::update_window(*widget_); - } - else - { - //Redraw the widget even though the index has not been changed, - //because the push button should be updated due to the state - //changed from pressed to normal/hovered. - API::refresh_window(*widget_); - } - } - void _m_draw_push_button(bool enabled) { ::nana::rectangle r{graph_->size()}; diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 5dc59321..96b423e3 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -3770,8 +3770,6 @@ namespace nana else if (ess_->lister.last_selected_abs == pos_) ess_->lister.last_selected_abs.set_both(npos); - ess_->update(); - ess_->update(); return *this; } diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index a4d4d499..fe140e41 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -13,7 +13,6 @@ #include #include #include -#include namespace nana { @@ -495,11 +494,7 @@ namespace drawerbase { auto s = _m_caption(); if (s.empty()) return 0; - std::stringstream ss; - int value; - ss << to_utf8(s); - ss >> value; - return value; + return std::stoi(s, nullptr, 0); } double textbox::to_double() const @@ -507,11 +502,7 @@ namespace drawerbase { auto s = _m_caption(); if (s.empty()) return 0; - std::stringstream ss; - double value; - ss << to_utf8(s); - ss >> value; - return value; + return std::stod(s); } textbox& textbox::from(int n)