optimize generated binary size
This commit is contained in:
parent
d3120cbf35
commit
a839cf8deb
@ -231,11 +231,6 @@ namespace nana
|
||||
};
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference))
|
||||
{
|
||||
return std::move(fn);
|
||||
}
|
||||
|
||||
template<typename Tfn, typename Ret>
|
||||
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)()const)
|
||||
{
|
||||
@ -245,11 +240,36 @@ namespace nana
|
||||
};
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference))
|
||||
{
|
||||
return std::move(fn);
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(fn_type&& fn, void(fn_type::*)(arg_reference) const)
|
||||
{
|
||||
return std::move(fn);
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference))
|
||||
{
|
||||
return fn;
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(fn_type& fn, void(fn_type::*)(arg_reference) const)
|
||||
{
|
||||
return fn;
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference))
|
||||
{
|
||||
return fn;
|
||||
}
|
||||
|
||||
static std::function<void(arg_reference)> build_second(const fn_type& fn, void(fn_type::*)(arg_reference) const)
|
||||
{
|
||||
return fn;
|
||||
}
|
||||
|
||||
template<typename Tfn, typename Ret, typename Arg2>
|
||||
static std::function<void(arg_reference)> build_second(Tfn&& fn, Ret(fn_type::*)(Arg2))
|
||||
{
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@ -86,26 +85,12 @@ namespace nana{ namespace widgets{ namespace skeletons
|
||||
|
||||
std::pair<unsigned, unsigned> binary_number() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<static_cast<std::string>(nana::charset(binary_.first))<<' '<<static_cast<std::string>(nana::charset(binary_.second));
|
||||
|
||||
std::pair<unsigned, unsigned> r;
|
||||
ss>>r.first>>r.second;
|
||||
return r;
|
||||
return{ std::stoul(binary_.first), std::stoul(binary_.second) };
|
||||
}
|
||||
|
||||
int number() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<static_cast<std::string>(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)
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <nana/gui/detail/bedrock_pi_data.hpp>
|
||||
#include <nana/gui/detail/event_code.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <sstream>
|
||||
#include <nana/system/timepiece.hpp>
|
||||
#include <nana/gui.hpp>
|
||||
#include <nana/gui/detail/inner_fwd_implement.hpp>
|
||||
@ -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, "<<static_cast<unsigned>(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_;
|
||||
|
@ -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<widget&>(impl->combox) : static_cast<widget&>(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)
|
||||
{
|
||||
if (arg.window_handle == impl->wdg_day.handle())
|
||||
{
|
||||
impl->day = impl->wdg_day.to_int();
|
||||
impl->month = static_cast<int>(impl->wdg_month.option()) + 1;
|
||||
});
|
||||
|
||||
impl->wdg_year.events().destroy.connect_unignorable([impl]
|
||||
{
|
||||
}
|
||||
else if(arg.window_handle == impl->wdg_year.handle())
|
||||
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<int>(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();
|
||||
});
|
||||
|
@ -304,9 +304,7 @@ namespace nana
|
||||
|
||||
void _m_throw_error(const std::string& err)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "place: " << err << " at " << static_cast<unsigned>(sp_ - divstr_);
|
||||
throw std::runtime_error(ss.str());
|
||||
throw std::runtime_error("nana::place: " + err + " at " + std::to_string(static_cast<unsigned>(sp_ - divstr_)));
|
||||
}
|
||||
|
||||
void _m_attr_number_value()
|
||||
|
@ -203,7 +203,6 @@ namespace nana
|
||||
destroy_dockarea = (0 == tabbar_->length());
|
||||
}
|
||||
|
||||
|
||||
if (destroy_dockarea)
|
||||
notifier_->request_close();
|
||||
});
|
||||
@ -225,7 +224,6 @@ namespace nana
|
||||
r.height = arg.height - 20;
|
||||
}
|
||||
|
||||
|
||||
for (auto & pn : panels_)
|
||||
{
|
||||
if (pn.widget_ptr)
|
||||
@ -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 });
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -571,7 +571,7 @@ namespace nana
|
||||
style_.listbox = &(form_loader<nana::float_listbox>()(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;
|
||||
|
@ -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()};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <nana/gui/widgets/textbox.hpp>
|
||||
#include <nana/gui/widgets/skeletons/text_editor.hpp>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user