optimize generated binary size
This commit is contained in:
@@ -95,9 +95,9 @@ namespace std
|
||||
namespace nana
|
||||
{
|
||||
/// Checks whether a specified text is utf8 encoding
|
||||
bool is_utf8(const char* str, unsigned len);
|
||||
bool is_utf8(const char* str, std::size_t len);
|
||||
void throw_not_utf8(const std::string& text);
|
||||
void throw_not_utf8(const char*, unsigned len);
|
||||
void throw_not_utf8(const char*, std::size_t len);
|
||||
void throw_not_utf8(const char*);
|
||||
|
||||
const std::string& to_utf8(const std::string&);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* A Bedrock 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
|
||||
@@ -78,8 +78,8 @@ namespace detail
|
||||
void define_state_cursor(core_window_t*, nana::cursor, thread_context*);
|
||||
void undefine_state_cursor(core_window_t*, thread_context*);
|
||||
|
||||
widget_colors& get_scheme_template(scheme_factory_base&&);
|
||||
widget_colors* make_scheme(scheme_factory_base&&);
|
||||
widget_colors& get_scheme_template(scheme_factory_interface&&);
|
||||
widget_colors* make_scheme(scheme_factory_interface&&);
|
||||
|
||||
events_operation& evt_operation();
|
||||
window_manager& wd_manager();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Color Schemes
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 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
|
||||
@@ -19,20 +19,21 @@ namespace nana
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
class scheme_factory_base
|
||||
class scheme_factory_interface
|
||||
{
|
||||
public:
|
||||
struct factory_identifier{};
|
||||
virtual ~scheme_factory_base() = default;
|
||||
virtual ~scheme_factory_interface() = default;
|
||||
|
||||
virtual factory_identifier* get_id() const = 0;
|
||||
virtual widget_colors* create() = 0;
|
||||
virtual widget_colors* create(widget_colors&) = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename Scheme>
|
||||
class scheme_factory
|
||||
: public scheme_factory_base
|
||||
: public scheme_factory_interface
|
||||
{
|
||||
private:
|
||||
factory_identifier* get_id() const override
|
||||
@@ -54,7 +55,7 @@ namespace nana
|
||||
};
|
||||
|
||||
template<typename Scheme>
|
||||
scheme_factory_base::factory_identifier scheme_factory<Scheme>::fid_;
|
||||
scheme_factory_interface::factory_identifier scheme_factory<Scheme>::fid_;
|
||||
|
||||
class color_schemes
|
||||
{
|
||||
@@ -69,8 +70,8 @@ namespace nana
|
||||
color_schemes();
|
||||
~color_schemes();
|
||||
|
||||
scheme& scheme_template(scheme_factory_base&&);
|
||||
scheme* create(scheme_factory_base&&);
|
||||
scheme& scheme_template(scheme_factory_interface&&);
|
||||
scheme* create(scheme_factory_interface&&);
|
||||
private:
|
||||
implement * impl_;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <nana/gui/detail/general_events.hpp>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
#if defined(STD_THREAD_NOT_SUPPORTED)
|
||||
#include <nana/std_mutex.hpp>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "internal_scope_guard.hpp"
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace nana
|
||||
@@ -67,7 +66,7 @@ namespace nana
|
||||
protected:
|
||||
//class emit_counter is a RAII helper for emitting count
|
||||
//It is used for avoiding a try{}catch block which is required for some finial works when
|
||||
//event handlers throw exceptions.
|
||||
//event handlers throw exceptions. Precondition event_base.dockers_ != nullptr.
|
||||
class emit_counter
|
||||
{
|
||||
public:
|
||||
@@ -77,12 +76,10 @@ namespace nana
|
||||
event_base * const evt_;
|
||||
};
|
||||
|
||||
//event_handle _m_emplace(::std::unique_ptr<detail::docker_interface>& docker_ptr, bool in_front);
|
||||
event_handle _m_emplace(detail::docker_interface*, bool in_front);
|
||||
protected:
|
||||
unsigned emitting_count_{ 0 };
|
||||
bool deleted_flags_{ false };
|
||||
//std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
|
||||
std::vector<detail::docker_interface*> * dockers_{ nullptr };
|
||||
};
|
||||
}//end namespace detail
|
||||
@@ -172,27 +169,26 @@ namespace nana
|
||||
|
||||
emit_counter ec(this);
|
||||
|
||||
auto& dockers = *dockers_;
|
||||
const auto dockers_len = dockers_->size();
|
||||
|
||||
//The dockers may resize when a new event handler is created by a calling handler.
|
||||
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
||||
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
||||
|
||||
auto i = dockers_->data();
|
||||
auto const end = i + dockers_->size();
|
||||
|
||||
for (; i != end; ++i)
|
||||
{
|
||||
auto docker_ptr = static_cast<docker*>(dockers[pos]);
|
||||
if (docker_ptr->flag_deleted)
|
||||
if (static_cast<docker*>(*i)->flag_deleted)
|
||||
continue;
|
||||
|
||||
docker_ptr->invoke(arg);
|
||||
static_cast<docker*>(*i)->invoke(arg);
|
||||
if (arg.propagation_stopped())
|
||||
{
|
||||
for (++pos; pos < dockers_len; ++pos)
|
||||
for (++i; i != end; ++i)
|
||||
{
|
||||
auto docker_ptr = static_cast<docker*>(dockers[pos]);
|
||||
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
||||
if (!static_cast<docker*>(*i)->unignorable || static_cast<docker*>(*i)->flag_deleted)
|
||||
continue;
|
||||
|
||||
docker_ptr->invoke(arg);
|
||||
static_cast<docker*>(*i)->invoke(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -274,7 +270,7 @@ namespace nana
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Ret, typename Arg2>
|
||||
struct factory < std::function<Ret(Arg2)>, false>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Elements of GUI Gadgets
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 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
|
||||
@@ -88,7 +88,6 @@ namespace nana
|
||||
struct factory_interface
|
||||
: public detail::factory_abstract
|
||||
{
|
||||
virtual ~factory_interface(){}
|
||||
virtual ElementInterface* create() const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace API
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_base&&);
|
||||
::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_interface&&);
|
||||
}
|
||||
|
||||
void effects_edge_nimbus(window, effects::edge_nimbus);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The fundamental widget class 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
|
||||
@@ -132,9 +132,25 @@ namespace nana
|
||||
virtual nana::color _m_bgcolor() const;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
class widget_base
|
||||
: public widget
|
||||
{
|
||||
public:
|
||||
~widget_base();
|
||||
|
||||
window handle() const override;
|
||||
private:
|
||||
void _m_notify_destroy() override final;
|
||||
protected:
|
||||
window handle_{ nullptr };
|
||||
};
|
||||
}
|
||||
|
||||
/// Base class of all the classes defined as a widget window. Defaultly a widget_tag
|
||||
template<typename Category, typename DrawerTrigger, typename Events = ::nana::general_events, typename Scheme = ::nana::widget_colors>
|
||||
class widget_object: public widget
|
||||
class widget_object: public detail::widget_base
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
@@ -147,12 +163,6 @@ namespace nana
|
||||
scheme_{ API::dev::make_scheme<Scheme>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
{
|
||||
if(handle_)
|
||||
API::close_window(handle_);
|
||||
}
|
||||
|
||||
event_type& events() const
|
||||
{
|
||||
return *events_;
|
||||
@@ -179,11 +189,6 @@ namespace nana
|
||||
return (this->empty() == false);
|
||||
}
|
||||
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
widget_object& borderless(bool enable)
|
||||
{
|
||||
API::widget_borderless(handle_, enable);
|
||||
@@ -214,13 +219,7 @@ namespace nana
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
|
||||
void _m_notify_destroy() override final
|
||||
{
|
||||
handle_ = nullptr;
|
||||
}
|
||||
private:
|
||||
window handle_{nullptr};
|
||||
DrawerTrigger trigger_;
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
@@ -228,7 +227,7 @@ namespace nana
|
||||
|
||||
/// Base class of all the classes defined as a non-graphics-buffer widget window. The second template parameter DrawerTrigger is always ignored.\see nana::panel
|
||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||
class widget_object<category::lite_widget_tag, DrawerTrigger, Events, Scheme>: public widget
|
||||
class widget_object<category::lite_widget_tag, DrawerTrigger, Events, Scheme>: public detail::widget_base
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
@@ -240,12 +239,6 @@ namespace nana
|
||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
{
|
||||
if(handle_)
|
||||
API::close_window(handle_);
|
||||
}
|
||||
|
||||
event_type& events() const
|
||||
{
|
||||
return *events_;
|
||||
@@ -269,12 +262,7 @@ namespace nana
|
||||
}
|
||||
return (this->empty() == false);
|
||||
}
|
||||
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
@@ -284,13 +272,7 @@ namespace nana
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
|
||||
void _m_notify_destroy() override final
|
||||
{
|
||||
handle_ = nullptr;
|
||||
}
|
||||
private:
|
||||
window handle_{nullptr};
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object
|
||||
@@ -298,7 +280,7 @@ namespace nana
|
||||
|
||||
/// Base class of all the classes defined as a root window. \see nana::form
|
||||
template<typename DrawerTrigger, typename Events, typename Scheme>
|
||||
class widget_object<category::root_tag, DrawerTrigger, Events, Scheme>: public widget
|
||||
class widget_object<category::root_tag, DrawerTrigger, Events, Scheme>: public detail::widget_base
|
||||
{
|
||||
protected:
|
||||
typedef DrawerTrigger drawer_trigger_t;
|
||||
@@ -324,12 +306,6 @@ namespace nana
|
||||
_m_bind_and_attach();
|
||||
}
|
||||
|
||||
~widget_object()
|
||||
{
|
||||
if(handle_)
|
||||
API::close_window(handle_);
|
||||
}
|
||||
|
||||
event_type& events() const
|
||||
{
|
||||
return *events_;
|
||||
@@ -340,11 +316,6 @@ namespace nana
|
||||
API::activate_window(handle_);
|
||||
}
|
||||
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
native_window_type native_handle() const
|
||||
{
|
||||
return API::root(handle_);
|
||||
@@ -435,13 +406,7 @@ namespace nana
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
|
||||
void _m_notify_destroy() override final
|
||||
{
|
||||
handle_ = nullptr;
|
||||
}
|
||||
private:
|
||||
window handle_;
|
||||
DrawerTrigger trigger_;
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
@@ -453,7 +418,7 @@ namespace nana
|
||||
|
||||
/// Especialization. Base class of all the classes defined as a frame window. \see nana::frame
|
||||
template<typename Events, typename Scheme>
|
||||
class widget_object<category::frame_tag, int, Events, Scheme>: public widget
|
||||
class widget_object<category::frame_tag, int, Events, Scheme>: public detail::widget_base
|
||||
{
|
||||
protected:
|
||||
typedef int drawer_trigger_t;
|
||||
@@ -465,12 +430,6 @@ namespace nana
|
||||
: events_{ std::make_shared<Events>() }, scheme_{ API::dev::make_scheme<scheme_type>() }
|
||||
{}
|
||||
|
||||
~widget_object()
|
||||
{
|
||||
if(handle_)
|
||||
API::close_window(handle_);
|
||||
}
|
||||
|
||||
event_type& events() const
|
||||
{
|
||||
return *events_;
|
||||
@@ -494,11 +453,6 @@ namespace nana
|
||||
return (this->empty() == false);
|
||||
}
|
||||
|
||||
window handle() const override
|
||||
{
|
||||
return handle_;
|
||||
}
|
||||
|
||||
scheme_type& scheme() const
|
||||
{
|
||||
return *scheme_;
|
||||
@@ -513,13 +467,7 @@ namespace nana
|
||||
{
|
||||
return *events_;
|
||||
}
|
||||
|
||||
void _m_notify_destroy() override final
|
||||
{
|
||||
handle_ = nullptr;
|
||||
}
|
||||
private:
|
||||
window handle_{nullptr};
|
||||
std::shared_ptr<Events> events_;
|
||||
std::unique_ptr<scheme_type> scheme_;
|
||||
};//end class widget_object<category::frame_tag>
|
||||
|
||||
Reference in New Issue
Block a user