Merge branch 'develop' of https://github.com/cnjinhao/nana into develop
This commit is contained in:
commit
ff198063ce
@ -15,13 +15,12 @@
|
|||||||
#include "drawer.hpp"
|
#include "drawer.hpp"
|
||||||
#include "events_holder.hpp"
|
#include "events_holder.hpp"
|
||||||
#include "widget_colors.hpp"
|
#include "widget_colors.hpp"
|
||||||
|
#include "widget_notifier_interface.hpp"
|
||||||
#include <nana/basic_types.hpp>
|
#include <nana/basic_types.hpp>
|
||||||
#include <nana/system/platform.hpp>
|
#include <nana/system/platform.hpp>
|
||||||
#include <nana/gui/effects.hpp>
|
#include <nana/gui/effects.hpp>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace nana{
|
namespace nana{
|
||||||
class widget; //declaration of nana/widgets/widget.hpp
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct basic_window;
|
struct basic_window;
|
||||||
@ -89,11 +88,11 @@ namespace detail
|
|||||||
|
|
||||||
//basic_window
|
//basic_window
|
||||||
//@brief: constructor for the root window
|
//@brief: constructor for the root window
|
||||||
basic_window(basic_window* owner, widget*, category::root_tag**);
|
basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&&, category::root_tag**);
|
||||||
|
|
||||||
template<typename Category>
|
template<typename Category>
|
||||||
basic_window(basic_window* parent, const rectangle& r, widget* wdg, Category**)
|
basic_window(basic_window* parent, std::unique_ptr<widget_notifier_interface>&& wdg_notifier, const rectangle& r, Category**)
|
||||||
: widget_ptr(wdg), other(Category::value)
|
: widget_notifier(std::move(wdg_notifier)), other(Category::value)
|
||||||
{
|
{
|
||||||
drawer.bind(this);
|
drawer.bind(this);
|
||||||
if(parent)
|
if(parent)
|
||||||
@ -146,7 +145,7 @@ namespace detail
|
|||||||
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
basic_window* root_widget; //A pointer refers to the root basic window, if the window is a root, the pointer refers to itself.
|
||||||
paint::graphics* root_graph; //Refer to the root buffer graphics
|
paint::graphics* root_graph; //Refer to the root buffer graphics
|
||||||
cursor predef_cursor;
|
cursor predef_cursor;
|
||||||
widget* const widget_ptr;
|
std::unique_ptr<widget_notifier_interface> widget_notifier;
|
||||||
|
|
||||||
struct flags_type
|
struct flags_type
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Inner Forward Declaration
|
* Inner Forward Declaration
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -19,37 +19,6 @@
|
|||||||
namespace nana{
|
namespace nana{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
struct signals
|
|
||||||
{
|
|
||||||
enum class code
|
|
||||||
{
|
|
||||||
caption,
|
|
||||||
read_caption,
|
|
||||||
destroy,
|
|
||||||
size,
|
|
||||||
end
|
|
||||||
};
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
const nana::char_t* caption;
|
|
||||||
nana::string * str;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned width;
|
|
||||||
unsigned height;
|
|
||||||
}size;
|
|
||||||
}info;
|
|
||||||
};
|
|
||||||
|
|
||||||
class signal_invoker_interface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~signal_invoker_interface()
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual void call_signal(signals::code, const signals&) = 0;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif //NANA_GUI_INNER_FWD_HPP
|
#endif //NANA_GUI_INNER_FWD_HPP
|
||||||
|
|||||||
@ -170,34 +170,6 @@ namespace nana{
|
|||||||
|
|
||||||
std::map<native_window_type, root_misc> table_;
|
std::map<native_window_type, root_misc> table_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class signal_manager
|
|
||||||
{
|
|
||||||
typedef basic_window core_window_t;
|
|
||||||
public:
|
|
||||||
void make(core_window_t* wd, signal_invoker_interface* si)
|
|
||||||
{
|
|
||||||
if (si)
|
|
||||||
table_[wd].reset(si);
|
|
||||||
else
|
|
||||||
table_.erase(wd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void umake(core_window_t * wd)
|
|
||||||
{
|
|
||||||
table_.erase(wd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void call_signal(core_window_t * wd, signals::code code, const signals& s)
|
|
||||||
{
|
|
||||||
auto i = table_.find(wd);
|
|
||||||
if (i != table_.end())
|
|
||||||
i->second->call_signal(code, s);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::map<core_window_t*, std::unique_ptr<signal_invoker_interface>> table_;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif //NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
#endif //NANA_GUI_INNER_FWD_IMPLEMENT_HPP
|
||||||
|
|||||||
@ -42,24 +42,7 @@ namespace nana
|
|||||||
namespace nana{
|
namespace nana{
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<typename T>
|
class widget_notifier_interface; //forward declaration
|
||||||
class signal_invoker_mf
|
|
||||||
: public signal_invoker_interface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
signal_invoker_mf(T& obj, void(T::*mf)(signals::code, const signals&))
|
|
||||||
: obj_(obj),
|
|
||||||
mf_(mf)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void call_signal(signals::code code, const signals& s) override
|
|
||||||
{
|
|
||||||
(obj_.*mf_)(code, s);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
T& obj_;
|
|
||||||
void(T::*mf_)(signals::code, const signals&);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct root_misc;
|
struct root_misc;
|
||||||
|
|
||||||
@ -103,14 +86,6 @@ namespace detail
|
|||||||
mutex_type & internal_lock() const;
|
mutex_type & internal_lock() const;
|
||||||
void all_handles(std::vector<core_window_t*>&) const;
|
void all_handles(std::vector<core_window_t*>&) const;
|
||||||
|
|
||||||
template<typename T, typename Concept>
|
|
||||||
void attach_signal(core_window_t* wd, T& obj, void(Concept::*mf)(signals::code, const signals&))
|
|
||||||
{
|
|
||||||
return _m_attach_signal(wd, new signal_invoker_mf<Concept>(obj, mf));
|
|
||||||
}
|
|
||||||
|
|
||||||
void signal_fire_caption(core_window_t*, const nana::char_t*);
|
|
||||||
nana::string signal_fire_caption(core_window_t*);
|
|
||||||
void event_filter(core_window_t*, bool is_make, event_code);
|
void event_filter(core_window_t*, bool is_make, event_code);
|
||||||
|
|
||||||
bool available(core_window_t*);
|
bool available(core_window_t*);
|
||||||
@ -120,6 +95,7 @@ namespace detail
|
|||||||
core_window_t* create_root(core_window_t*, bool nested, rectangle, const appearance&, widget*);
|
core_window_t* create_root(core_window_t*, bool nested, rectangle, const appearance&, widget*);
|
||||||
core_window_t* create_widget(core_window_t*, const rectangle&, bool is_lite, widget*);
|
core_window_t* create_widget(core_window_t*, const rectangle&, bool is_lite, widget*);
|
||||||
core_window_t* create_frame(core_window_t*, const rectangle&, widget*);
|
core_window_t* create_frame(core_window_t*, const rectangle&, widget*);
|
||||||
|
|
||||||
bool insert_frame(core_window_t* frame, native_window);
|
bool insert_frame(core_window_t* frame, native_window);
|
||||||
bool insert_frame(core_window_t* frame, core_window_t*);
|
bool insert_frame(core_window_t* frame, core_window_t*);
|
||||||
void close(core_window_t*);
|
void close(core_window_t*);
|
||||||
@ -190,7 +166,6 @@ namespace detail
|
|||||||
|
|
||||||
core_window_t* find_shortkey(native_window_type, unsigned long key);
|
core_window_t* find_shortkey(native_window_type, unsigned long key);
|
||||||
private:
|
private:
|
||||||
void _m_attach_signal(core_window_t*, signal_invoker_interface*);
|
|
||||||
void _m_disengage(core_window_t*, core_window_t* for_new);
|
void _m_disengage(core_window_t*, core_window_t* for_new);
|
||||||
void _m_destroy(core_window_t*);
|
void _m_destroy(core_window_t*);
|
||||||
void _m_move_core(core_window_t*, const point& delta);
|
void _m_move_core(core_window_t*, const point& delta);
|
||||||
@ -202,8 +177,6 @@ namespace detail
|
|||||||
struct wdm_private_impl;
|
struct wdm_private_impl;
|
||||||
wdm_private_impl * const impl_;
|
wdm_private_impl * const impl_;
|
||||||
|
|
||||||
signals signals_;
|
|
||||||
|
|
||||||
struct attribute
|
struct attribute
|
||||||
{
|
{
|
||||||
struct captured
|
struct captured
|
||||||
|
|||||||
@ -48,13 +48,6 @@ namespace API
|
|||||||
//@brief: The interfaces defined in namespace dev are used for developing the nana.gui
|
//@brief: The interfaces defined in namespace dev are used for developing the nana.gui
|
||||||
namespace dev
|
namespace dev
|
||||||
{
|
{
|
||||||
template<typename Object, typename Concept>
|
|
||||||
void attach_signal(window wd, Object& object, void (Concept::*f)(::nana::detail::signals::code, const ::nana::detail::signals&))
|
|
||||||
{
|
|
||||||
using namespace ::nana::detail;
|
|
||||||
bedrock::instance().wd_manager.attach_signal(reinterpret_cast<bedrock::core_window_t*>(wd), object, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool set_events(window, const std::shared_ptr<general_events>&);
|
bool set_events(window, const std::shared_ptr<general_events>&);
|
||||||
|
|
||||||
template<typename Scheme>
|
template<typename Scheme>
|
||||||
|
|||||||
@ -22,10 +22,18 @@
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
//Forward declaration of widget_notifier_interface
|
||||||
|
class widget_notifier_interface;
|
||||||
|
}
|
||||||
|
|
||||||
/// Abstract class for defining the capacity interface.
|
/// Abstract class for defining the capacity interface.
|
||||||
class widget
|
class widget
|
||||||
: nana::noncopyable, nana::nonmovable
|
: nana::noncopyable, nana::nonmovable
|
||||||
{
|
{
|
||||||
|
friend class detail::widget_notifier_interface;
|
||||||
|
class notifier;
|
||||||
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
|
||||||
public:
|
public:
|
||||||
virtual ~widget() = default;
|
virtual ~widget() = default;
|
||||||
@ -88,6 +96,11 @@ namespace nana
|
|||||||
|
|
||||||
operator dummy_bool_type() const;
|
operator dummy_bool_type() const;
|
||||||
operator window() const;
|
operator window() const;
|
||||||
|
protected:
|
||||||
|
std::unique_ptr<::nana::detail::widget_notifier_interface> _m_wdg_notifier();
|
||||||
|
private:
|
||||||
|
virtual void _m_notify_destroy() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//protected members, a derived class must call this implementation if it overrides an implementation
|
//protected members, a derived class must call this implementation if it overrides an implementation
|
||||||
virtual void _m_complete_creation();
|
virtual void _m_complete_creation();
|
||||||
@ -152,7 +165,6 @@ namespace nana
|
|||||||
handle_ = API::dev::create_widget(parent_wd, r, this);
|
handle_ = API::dev::create_widget(parent_wd, r, this);
|
||||||
API::dev::set_events(handle_, events_);
|
API::dev::set_events(handle_, events_);
|
||||||
API::dev::set_scheme(handle_, scheme_.get());
|
API::dev::set_scheme(handle_, scheme_.get());
|
||||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
|
||||||
API::dev::attach_drawer(*this, trigger_);
|
API::dev::attach_drawer(*this, trigger_);
|
||||||
if(visible)
|
if(visible)
|
||||||
API::show_window(handle_, true);
|
API::show_window(handle_, true);
|
||||||
@ -193,29 +205,15 @@ namespace nana
|
|||||||
return trigger_;
|
return trigger_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void signal(detail::signals::code code, const detail::signals& sig)
|
|
||||||
{
|
|
||||||
typedef detail::signals::code codes;
|
|
||||||
switch(code)
|
|
||||||
{
|
|
||||||
case codes::caption:
|
|
||||||
this->_m_caption(sig.info.caption);
|
|
||||||
break;
|
|
||||||
case codes::read_caption:
|
|
||||||
*sig.info.str = this->_m_caption();
|
|
||||||
break;
|
|
||||||
case codes::destroy:
|
|
||||||
handle_ = nullptr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
general_events& _m_get_general_events() const override
|
general_events& _m_get_general_events() const override
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _m_notify_destroy() override final
|
||||||
|
{
|
||||||
|
handle_ = nullptr;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
window handle_{nullptr};
|
||||||
DrawerTrigger trigger_;
|
DrawerTrigger trigger_;
|
||||||
@ -276,29 +274,15 @@ namespace nana
|
|||||||
return *scheme_;
|
return *scheme_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void signal(detail::signals::code code, const detail::signals& sig)
|
|
||||||
{
|
|
||||||
typedef detail::signals::code codes;
|
|
||||||
switch(code)
|
|
||||||
{
|
|
||||||
case codes::caption:
|
|
||||||
this->_m_caption(sig.info.caption);
|
|
||||||
break;
|
|
||||||
case codes::read_caption:
|
|
||||||
*sig.info.str = this->_m_caption();
|
|
||||||
break;
|
|
||||||
case codes::destroy:
|
|
||||||
handle_ = nullptr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
general_events& _m_get_general_events() const override
|
general_events& _m_get_general_events() const override
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _m_notify_destroy() override final
|
||||||
|
{
|
||||||
|
handle_ = nullptr;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
window handle_{nullptr};
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
@ -430,25 +414,6 @@ namespace nana
|
|||||||
return trigger_;
|
return trigger_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void signal(detail::signals::code code, const detail::signals& sig)
|
|
||||||
{
|
|
||||||
typedef detail::signals::code codes;
|
|
||||||
switch(code)
|
|
||||||
{
|
|
||||||
case codes::caption:
|
|
||||||
this->_m_caption(sig.info.caption);
|
|
||||||
break;
|
|
||||||
case codes::read_caption:
|
|
||||||
*sig.info.str = this->_m_caption();
|
|
||||||
break;
|
|
||||||
case codes::destroy:
|
|
||||||
handle_ = nullptr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _m_bind_and_attach()
|
void _m_bind_and_attach()
|
||||||
{
|
{
|
||||||
events_ = std::make_shared<Events>();
|
events_ = std::make_shared<Events>();
|
||||||
@ -456,7 +421,6 @@ namespace nana
|
|||||||
|
|
||||||
scheme_ = API::dev::make_scheme<scheme_type>();
|
scheme_ = API::dev::make_scheme<scheme_type>();
|
||||||
API::dev::set_scheme(handle_, scheme_.get());
|
API::dev::set_scheme(handle_, scheme_.get());
|
||||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
|
||||||
API::dev::attach_drawer(*this, trigger_);
|
API::dev::attach_drawer(*this, trigger_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +428,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _m_notify_destroy() override final
|
||||||
|
{
|
||||||
|
handle_ = nullptr;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
window handle_;
|
window handle_;
|
||||||
DrawerTrigger trigger_;
|
DrawerTrigger trigger_;
|
||||||
@ -511,7 +480,6 @@ namespace nana
|
|||||||
handle_ = API::dev::create_frame(parent_wd, r, this);
|
handle_ = API::dev::create_frame(parent_wd, r, this);
|
||||||
API::dev::set_events(handle_, events_);
|
API::dev::set_events(handle_, events_);
|
||||||
API::dev::set_scheme(handle_, scheme_.get());
|
API::dev::set_scheme(handle_, scheme_.get());
|
||||||
API::dev::attach_signal(handle_, *this, &widget_object::signal);
|
|
||||||
API::show_window(handle_, visible);
|
API::show_window(handle_, visible);
|
||||||
this->_m_complete_creation();
|
this->_m_complete_creation();
|
||||||
}
|
}
|
||||||
@ -533,29 +501,15 @@ namespace nana
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal(detail::signals::code code, const detail::signals& sig)
|
|
||||||
{
|
|
||||||
typedef detail::signals::code codes;
|
|
||||||
switch(code)
|
|
||||||
{
|
|
||||||
case codes::caption:
|
|
||||||
this->_m_caption(sig.info.caption);
|
|
||||||
break;
|
|
||||||
case codes::read_caption:
|
|
||||||
*sig.info.str = this->_m_caption();
|
|
||||||
break;
|
|
||||||
case codes::destroy:
|
|
||||||
handle_ = nullptr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
general_events& _m_get_general_events() const override
|
general_events& _m_get_general_events() const override
|
||||||
{
|
{
|
||||||
return *events_;
|
return *events_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _m_notify_destroy() override final
|
||||||
|
{
|
||||||
|
handle_ = nullptr;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
window handle_{nullptr};
|
window handle_{nullptr};
|
||||||
std::shared_ptr<Events> events_;
|
std::shared_ptr<Events> events_;
|
||||||
|
|||||||
@ -221,8 +221,8 @@ namespace nana
|
|||||||
|
|
||||||
//basic_window
|
//basic_window
|
||||||
//@brief: constructor for the root window
|
//@brief: constructor for the root window
|
||||||
basic_window::basic_window(basic_window* owner, widget* wdg, category::root_tag**)
|
basic_window::basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&& wdg_notifier, category::root_tag**)
|
||||||
: widget_ptr(wdg), other(category::root_tag::value)
|
: widget_notifier(std::move(wdg_notifier)), other(category::root_tag::value)
|
||||||
{
|
{
|
||||||
drawer.bind(this);
|
drawer.bind(this);
|
||||||
_m_init_pos_and_size(nullptr, rectangle());
|
_m_init_pos_and_size(nullptr, rectangle());
|
||||||
|
|||||||
@ -26,6 +26,18 @@
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
|
//class internal_scope_guard
|
||||||
|
internal_scope_guard::internal_scope_guard()
|
||||||
|
{
|
||||||
|
detail::bedrock::instance().wd_manager.internal_lock().lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal_scope_guard::~internal_scope_guard()
|
||||||
|
{
|
||||||
|
detail::bedrock::instance().wd_manager.internal_lock().unlock();
|
||||||
|
}
|
||||||
|
//end class internal_scope_guard
|
||||||
|
|
||||||
//class event_arg
|
//class event_arg
|
||||||
event_arg::~event_arg(){}
|
event_arg::~event_arg(){}
|
||||||
|
|
||||||
|
|||||||
@ -23,16 +23,6 @@
|
|||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
//class internal_scope_guard
|
|
||||||
internal_scope_guard::internal_scope_guard()
|
|
||||||
{
|
|
||||||
detail::bedrock::instance().wd_manager.internal_lock().lock();
|
|
||||||
}
|
|
||||||
internal_scope_guard::~internal_scope_guard()
|
|
||||||
{
|
|
||||||
detail::bedrock::instance().wd_manager.internal_lock().unlock();
|
|
||||||
}
|
|
||||||
//end class internal_scope_guard
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
@ -138,11 +128,6 @@ namespace detail
|
|||||||
//here is the definition of this object
|
//here is the definition of this object
|
||||||
bedrock bedrock::bedrock_object;
|
bedrock bedrock::bedrock_object;
|
||||||
|
|
||||||
inline window mycast(bedrock::core_window_t* wd)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<window>(wd);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window event_window(const XEvent& event)
|
Window event_window(const XEvent& event)
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
|
|||||||
@ -41,16 +41,6 @@ namespace nana
|
|||||||
{
|
{
|
||||||
void notifications_window_proc(HWND wd, WPARAM wparam, LPARAM lparam); //Defined in notifier.cpp
|
void notifications_window_proc(HWND wd, WPARAM wparam, LPARAM lparam); //Defined in notifier.cpp
|
||||||
|
|
||||||
//class internal_scope_guard
|
|
||||||
internal_scope_guard::internal_scope_guard()
|
|
||||||
{
|
|
||||||
detail::bedrock::instance().wd_manager.internal_lock().lock();
|
|
||||||
}
|
|
||||||
internal_scope_guard::~internal_scope_guard()
|
|
||||||
{
|
|
||||||
detail::bedrock::instance().wd_manager.internal_lock().unlock();
|
|
||||||
}
|
|
||||||
//end class internal_scope_guard
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
namespace restrict
|
namespace restrict
|
||||||
@ -985,14 +975,12 @@ namespace detail
|
|||||||
nana::arg_mouse arg;
|
nana::arg_mouse arg;
|
||||||
assign_arg(arg, msgwnd, message, pmdec);
|
assign_arg(arg, msgwnd, message, pmdec);
|
||||||
|
|
||||||
const bool hit = msgwnd->dimension.is_hit(arg.pos);
|
|
||||||
|
|
||||||
bool fire_click = false;
|
bool fire_click = false;
|
||||||
if(msgwnd == pressed_wd)
|
if (msgwnd->dimension.is_hit(arg.pos))
|
||||||
{
|
|
||||||
if(msgwnd->flags.enabled && hit)
|
|
||||||
{
|
{
|
||||||
msgwnd->flags.action = mouse_action::over;
|
msgwnd->flags.action = mouse_action::over;
|
||||||
|
if ((msgwnd == pressed_wd) && msgwnd->flags.enabled)
|
||||||
|
{
|
||||||
arg.evt_code = event_code::click;
|
arg.evt_code = event_code::click;
|
||||||
emit_drawer(&drawer::click, msgwnd, arg, &context);
|
emit_drawer(&drawer::click, msgwnd, arg, &context);
|
||||||
fire_click = true;
|
fire_click = true;
|
||||||
@ -1002,9 +990,6 @@ namespace detail
|
|||||||
//Do mouse_up, this handle may be closed by click handler.
|
//Do mouse_up, this handle may be closed by click handler.
|
||||||
if(brock.wd_manager.available(msgwnd) && msgwnd->flags.enabled)
|
if(brock.wd_manager.available(msgwnd) && msgwnd->flags.enabled)
|
||||||
{
|
{
|
||||||
if(hit)
|
|
||||||
msgwnd->flags.action = mouse_action::over;
|
|
||||||
|
|
||||||
arg.evt_code = event_code::mouse_up;
|
arg.evt_code = event_code::mouse_up;
|
||||||
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
||||||
|
|
||||||
@ -1521,15 +1506,10 @@ namespace detail
|
|||||||
return ::DefWindowProc(root_window, message, wParam, lParam);
|
return ::DefWindowProc(root_window, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::category::flags bedrock::category(core_window_t* wd)
|
::nana::category::flags bedrock::category(core_window_t* wd)
|
||||||
{
|
{
|
||||||
if(wd)
|
internal_scope_guard lock;
|
||||||
{
|
return (wd_manager.available(wd) ? wd->other.category : ::nana::category::flags::super);
|
||||||
internal_scope_guard isg;
|
|
||||||
if(wd_manager.available(wd))
|
|
||||||
return wd->other.category;
|
|
||||||
}
|
|
||||||
return nana::category::flags::super;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bedrock::focus() ->core_window_t*
|
auto bedrock::focus() ->core_window_t*
|
||||||
@ -1540,13 +1520,8 @@ namespace detail
|
|||||||
|
|
||||||
native_window_type bedrock::root(core_window_t* wd)
|
native_window_type bedrock::root(core_window_t* wd)
|
||||||
{
|
{
|
||||||
if(wd)
|
internal_scope_guard lock;
|
||||||
{
|
return (wd_manager.available(wd) ? wd->root : nullptr);
|
||||||
internal_scope_guard isg;
|
|
||||||
if(wd_manager.available(wd))
|
|
||||||
return wd->root;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bedrock::set_menubar_taken(core_window_t* wd)
|
void bedrock::set_menubar_taken(core_window_t* wd)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Window Manager Implementation
|
* Window Manager Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -42,7 +42,6 @@ namespace detail
|
|||||||
{
|
{
|
||||||
root_register misc_register;
|
root_register misc_register;
|
||||||
handle_manager<core_window_t*, window_manager, window_handle_deleter> wd_register;
|
handle_manager<core_window_t*, window_manager, window_handle_deleter> wd_register;
|
||||||
signal_manager signal;
|
|
||||||
paint::image default_icon_big;
|
paint::image default_icon_big;
|
||||||
paint::image default_icon_small;
|
paint::image default_icon_small;
|
||||||
};
|
};
|
||||||
@ -172,22 +171,6 @@ namespace detail
|
|||||||
impl_->wd_register.all(v);
|
impl_->wd_register.all(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_manager::signal_fire_caption(core_window_t* wd, const nana::char_t* str)
|
|
||||||
{
|
|
||||||
detail::signals sig;
|
|
||||||
sig.info.caption = str;
|
|
||||||
impl_->signal.call_signal(wd, signals::code::caption, sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
nana::string window_manager::signal_fire_caption(core_window_t* wd)
|
|
||||||
{
|
|
||||||
nana::string str;
|
|
||||||
detail::signals sig;
|
|
||||||
sig.info.str = &str;
|
|
||||||
impl_->signal.call_signal(wd, signals::code::read_caption, sig);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void window_manager::event_filter(core_window_t* wd, bool is_make, event_code evtid)
|
void window_manager::event_filter(core_window_t* wd, bool is_make, event_code evtid)
|
||||||
{
|
{
|
||||||
switch(evtid)
|
switch(evtid)
|
||||||
@ -220,10 +203,10 @@ namespace detail
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_manager::core_window_t* window_manager::create_root(core_window_t* owner, bool nested, rectangle r, const appearance& app, widget * wdg)
|
window_manager::core_window_t* window_manager::create_root(core_window_t* owner, bool nested, rectangle r, const appearance& app, widget* wdg)
|
||||||
{
|
{
|
||||||
native_window_type native = nullptr;
|
native_window_type native = nullptr;
|
||||||
if(owner)
|
if (owner)
|
||||||
{
|
{
|
||||||
//Thread-Safe Required!
|
//Thread-Safe Required!
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
@ -240,9 +223,9 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto result = native_interface::create_window(native, nested, r, app);
|
auto result = native_interface::create_window(native, nested, r, app);
|
||||||
if(result.native_handle)
|
if (result.native_handle)
|
||||||
{
|
{
|
||||||
core_window_t* wd = new core_window_t(owner, wdg, (category::root_tag**)nullptr);
|
core_window_t* wd = new core_window_t(owner, widget_notifier_interface::get_notifier(wdg), (category::root_tag**)nullptr);
|
||||||
wd->flags.take_active = !app.no_activate;
|
wd->flags.take_active = !app.no_activate;
|
||||||
wd->title = native_interface::window_caption(result.native_handle);
|
wd->title = native_interface::window_caption(result.native_handle);
|
||||||
|
|
||||||
@ -256,7 +239,7 @@ namespace detail
|
|||||||
wd->bind_native_window(result.native_handle, result.width, result.height, result.extra_width, result.extra_height, value->root_graph);
|
wd->bind_native_window(result.native_handle, result.width, result.height, result.extra_width, result.extra_height, value->root_graph);
|
||||||
impl_->wd_register.insert(wd, wd->thread_id);
|
impl_->wd_register.insert(wd, wd->thread_id);
|
||||||
|
|
||||||
if(owner && owner->other.category == category::frame_tag::value)
|
if (owner && owner->other.category == category::frame_tag::value)
|
||||||
insert_frame(owner, wd);
|
insert_frame(owner, wd);
|
||||||
|
|
||||||
bedrock::inc_window(wd->thread_id);
|
bedrock::inc_window(wd->thread_id);
|
||||||
@ -273,7 +256,7 @@ namespace detail
|
|||||||
|
|
||||||
if (impl_->wd_register.available(parent) == false) return nullptr;
|
if (impl_->wd_register.available(parent) == false) return nullptr;
|
||||||
|
|
||||||
core_window_t * wd = new core_window_t(parent, r, wdg, (category::frame_tag**)nullptr);
|
core_window_t * wd = new core_window_t(parent, widget_notifier_interface::get_notifier(wdg), r, (category::frame_tag**)nullptr);
|
||||||
wd->frame_window(native_interface::create_child_window(parent->root, rectangle(wd->pos_root.x, wd->pos_root.y, r.width, r.height)));
|
wd->frame_window(native_interface::create_child_window(parent->root, rectangle(wd->pos_root.x, wd->pos_root.y, r.width, r.height)));
|
||||||
impl_->wd_register.insert(wd, wd->thread_id);
|
impl_->wd_register.insert(wd, wd->thread_id);
|
||||||
|
|
||||||
@ -320,11 +303,13 @@ namespace detail
|
|||||||
if (impl_->wd_register.available(parent) == false)
|
if (impl_->wd_register.available(parent) == false)
|
||||||
throw std::invalid_argument("invalid parent/owner handle");
|
throw std::invalid_argument("invalid parent/owner handle");
|
||||||
|
|
||||||
|
auto wdg_notifier = widget_notifier_interface::get_notifier(wdg);
|
||||||
|
|
||||||
core_window_t * wd;
|
core_window_t * wd;
|
||||||
if(is_lite)
|
if (is_lite)
|
||||||
wd = new core_window_t(parent, r, wdg, (category::lite_widget_tag**)nullptr);
|
wd = new core_window_t(parent, std::move(wdg_notifier), r, (category::lite_widget_tag**)nullptr);
|
||||||
else
|
else
|
||||||
wd = new core_window_t(parent, r, wdg, (category::widget_tag**)nullptr);
|
wd = new core_window_t(parent, std::move(wdg_notifier), r, (category::widget_tag**)nullptr);
|
||||||
impl_->wd_register.insert(wd, wd->thread_id);
|
impl_->wd_register.insert(wd, wd->thread_id);
|
||||||
return wd;
|
return wd;
|
||||||
}
|
}
|
||||||
@ -354,8 +339,8 @@ namespace detail
|
|||||||
//before the window_manager destroyes the window, and then, window_manager detaches the
|
//before the window_manager destroyes the window, and then, window_manager detaches the
|
||||||
//non-existing drawer_trigger which is destroyed by destruction of widget. Crash!
|
//non-existing drawer_trigger which is destroyed by destruction of widget. Crash!
|
||||||
wd->drawer.detached();
|
wd->drawer.detached();
|
||||||
impl_->signal.call_signal(wd, signals::code::destroy, signals_);
|
|
||||||
impl_->signal.umake(wd);
|
wd->widget_notifier->destroy();
|
||||||
|
|
||||||
native_interface::close_window(wd->root);
|
native_interface::close_window(wd->root);
|
||||||
}
|
}
|
||||||
@ -814,7 +799,7 @@ namespace detail
|
|||||||
::nana::widget* window_manager::get_widget(core_window_t* wd) const
|
::nana::widget* window_manager::get_widget(core_window_t* wd) const
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
return (impl_->wd_register.available(wd) ? wd->widget_ptr : nullptr);
|
return (impl_->wd_register.available(wd) ? wd->widget_notifier->widget_ptr() : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<window_manager::core_window_t*> window_manager::get_children(core_window_t* wd) const
|
std::vector<window_manager::core_window_t*> window_manager::get_children(core_window_t* wd) const
|
||||||
@ -1172,11 +1157,6 @@ namespace detail
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_manager::_m_attach_signal(core_window_t* wd, signal_invoker_interface* si)
|
|
||||||
{
|
|
||||||
impl_->signal.make(wd, si);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool check_tree(basic_window* wd, basic_window* const cond)
|
bool check_tree(basic_window* wd, basic_window* const cond)
|
||||||
{
|
{
|
||||||
if (wd == cond) return true;
|
if (wd == cond) return true;
|
||||||
@ -1387,8 +1367,7 @@ namespace detail
|
|||||||
wndlayout_type::enable_effects_bground(wd, false);
|
wndlayout_type::enable_effects_bground(wd, false);
|
||||||
|
|
||||||
wd->drawer.detached();
|
wd->drawer.detached();
|
||||||
impl_->signal.call_signal(wd, signals::code::destroy, signals_);
|
wd->widget_notifier->destroy();
|
||||||
impl_->signal.umake(wd);
|
|
||||||
|
|
||||||
if(wd->other.category == category::frame_tag::value)
|
if(wd->other.category == category::frame_tag::value)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -780,16 +780,16 @@ namespace API
|
|||||||
{
|
{
|
||||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if(restrict::window_manager.available(iwd))
|
if (restrict::window_manager.available(iwd))
|
||||||
restrict::window_manager.signal_fire_caption(iwd, title.c_str());
|
iwd->widget_notifier->caption(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
nana::string window_caption(window wd)
|
nana::string window_caption(window wd)
|
||||||
{
|
{
|
||||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if(restrict::window_manager.available(iwd))
|
if (restrict::window_manager.available(iwd))
|
||||||
return restrict::window_manager.signal_fire_caption(iwd);
|
return iwd->widget_notifier->caption();
|
||||||
|
|
||||||
return{};
|
return{};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* The fundamental widget class implementation
|
* The fundamental widget class implementation
|
||||||
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <nana/gui/widgets/widget.hpp>
|
#include <nana/gui/widgets/widget.hpp>
|
||||||
#include <nana/gui/tooltip.hpp>
|
#include <nana/gui/tooltip.hpp>
|
||||||
|
#include <nana/gui/detail/widget_notifier_interface.hpp>
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
@ -18,8 +19,41 @@ namespace nana
|
|||||||
{
|
{
|
||||||
void set_eval(window, i18n_eval&&);
|
void set_eval(window, i18n_eval&&);
|
||||||
}
|
}
|
||||||
|
|
||||||
//class widget
|
//class widget
|
||||||
//@brief:The definition of class widget
|
//@brief:The definition of class widget
|
||||||
|
class widget::notifier: public detail::widget_notifier_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
notifier(widget& wdg)
|
||||||
|
: wdg_(wdg)
|
||||||
|
{}
|
||||||
|
|
||||||
|
private:
|
||||||
|
//implementation of widget_notifier_interface
|
||||||
|
widget* widget_ptr() const override
|
||||||
|
{
|
||||||
|
return &wdg_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy() override
|
||||||
|
{
|
||||||
|
wdg_._m_notify_destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring caption() override
|
||||||
|
{
|
||||||
|
return wdg_._m_caption();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void caption(std::wstring text)
|
||||||
|
{
|
||||||
|
wdg_._m_caption(std::move(text));
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
widget& wdg_;
|
||||||
|
};
|
||||||
|
|
||||||
nana::string widget::caption() const
|
nana::string widget::caption() const
|
||||||
{
|
{
|
||||||
return this->_m_caption();
|
return this->_m_caption();
|
||||||
@ -205,6 +239,11 @@ namespace nana
|
|||||||
return handle();
|
return handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<::nana::detail::widget_notifier_interface> widget::_m_wdg_notifier()
|
||||||
|
{
|
||||||
|
return std::unique_ptr<::nana::detail::widget_notifier_interface>(new notifier(*this));
|
||||||
|
}
|
||||||
|
|
||||||
void widget::_m_complete_creation()
|
void widget::_m_complete_creation()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -298,7 +337,14 @@ namespace nana
|
|||||||
{
|
{
|
||||||
return API::bgcolor(handle());
|
return API::bgcolor(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
//end class widget
|
//end class widget
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
std::unique_ptr<widget_notifier_interface> widget_notifier_interface::get_notifier(widget* wdg)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<widget_notifier_interface>(new widget::notifier(*wdg));
|
||||||
|
}
|
||||||
|
}
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user