Merge branch 'develop' of https://github.com/cnjinhao/nana into develop
This commit is contained in:
@@ -221,8 +221,8 @@ namespace nana
|
||||
|
||||
//basic_window
|
||||
//@brief: constructor for the root window
|
||||
basic_window::basic_window(basic_window* owner, widget* wdg, category::root_tag**)
|
||||
: widget_ptr(wdg), other(category::root_tag::value)
|
||||
basic_window::basic_window(basic_window* owner, std::unique_ptr<widget_notifier_interface>&& wdg_notifier, category::root_tag**)
|
||||
: widget_notifier(std::move(wdg_notifier)), other(category::root_tag::value)
|
||||
{
|
||||
drawer.bind(this);
|
||||
_m_init_pos_and_size(nullptr, rectangle());
|
||||
|
||||
@@ -26,6 +26,18 @@
|
||||
|
||||
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
|
||||
event_arg::~event_arg(){}
|
||||
|
||||
|
||||
@@ -23,16 +23,6 @@
|
||||
|
||||
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
|
||||
{
|
||||
#pragma pack(1)
|
||||
@@ -138,11 +128,6 @@ namespace detail
|
||||
//here is the definition of this object
|
||||
bedrock bedrock::bedrock_object;
|
||||
|
||||
inline window mycast(bedrock::core_window_t* wd)
|
||||
{
|
||||
return reinterpret_cast<window>(wd);
|
||||
}
|
||||
|
||||
Window event_window(const XEvent& event)
|
||||
{
|
||||
switch(event.type)
|
||||
|
||||
@@ -41,16 +41,6 @@ namespace nana
|
||||
{
|
||||
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 restrict
|
||||
@@ -985,14 +975,12 @@ namespace detail
|
||||
nana::arg_mouse arg;
|
||||
assign_arg(arg, msgwnd, message, pmdec);
|
||||
|
||||
const bool hit = msgwnd->dimension.is_hit(arg.pos);
|
||||
|
||||
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;
|
||||
if ((msgwnd == pressed_wd) && msgwnd->flags.enabled)
|
||||
{
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
arg.evt_code = event_code::click;
|
||||
emit_drawer(&drawer::click, msgwnd, arg, &context);
|
||||
fire_click = true;
|
||||
@@ -1002,9 +990,6 @@ namespace detail
|
||||
//Do mouse_up, this handle may be closed by click handler.
|
||||
if(brock.wd_manager.available(msgwnd) && msgwnd->flags.enabled)
|
||||
{
|
||||
if(hit)
|
||||
msgwnd->flags.action = mouse_action::over;
|
||||
|
||||
arg.evt_code = event_code::mouse_up;
|
||||
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
|
||||
|
||||
@@ -1521,15 +1506,10 @@ namespace detail
|
||||
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 isg;
|
||||
if(wd_manager.available(wd))
|
||||
return wd->other.category;
|
||||
}
|
||||
return nana::category::flags::super;
|
||||
internal_scope_guard lock;
|
||||
return (wd_manager.available(wd) ? wd->other.category : ::nana::category::flags::super);
|
||||
}
|
||||
|
||||
auto bedrock::focus() ->core_window_t*
|
||||
@@ -1540,13 +1520,8 @@ namespace detail
|
||||
|
||||
native_window_type bedrock::root(core_window_t* wd)
|
||||
{
|
||||
if(wd)
|
||||
{
|
||||
internal_scope_guard isg;
|
||||
if(wd_manager.available(wd))
|
||||
return wd->root;
|
||||
}
|
||||
return nullptr;
|
||||
internal_scope_guard lock;
|
||||
return (wd_manager.available(wd) ? wd->root : nullptr);
|
||||
}
|
||||
|
||||
void bedrock::set_menubar_taken(core_window_t* wd)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Window Manager Implementation
|
||||
* 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.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -42,7 +42,6 @@ namespace detail
|
||||
{
|
||||
root_register misc_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_small;
|
||||
};
|
||||
@@ -172,22 +171,6 @@ namespace detail
|
||||
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)
|
||||
{
|
||||
switch(evtid)
|
||||
@@ -220,10 +203,10 @@ namespace detail
|
||||
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;
|
||||
if(owner)
|
||||
if (owner)
|
||||
{
|
||||
//Thread-Safe Required!
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
@@ -240,9 +223,9 @@ namespace detail
|
||||
}
|
||||
|
||||
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->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);
|
||||
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);
|
||||
|
||||
bedrock::inc_window(wd->thread_id);
|
||||
@@ -273,7 +256,7 @@ namespace detail
|
||||
|
||||
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)));
|
||||
impl_->wd_register.insert(wd, wd->thread_id);
|
||||
|
||||
@@ -320,11 +303,13 @@ namespace detail
|
||||
if (impl_->wd_register.available(parent) == false)
|
||||
throw std::invalid_argument("invalid parent/owner handle");
|
||||
|
||||
auto wdg_notifier = widget_notifier_interface::get_notifier(wdg);
|
||||
|
||||
core_window_t * wd;
|
||||
if(is_lite)
|
||||
wd = new core_window_t(parent, r, wdg, (category::lite_widget_tag**)nullptr);
|
||||
if (is_lite)
|
||||
wd = new core_window_t(parent, std::move(wdg_notifier), r, (category::lite_widget_tag**)nullptr);
|
||||
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);
|
||||
return wd;
|
||||
}
|
||||
@@ -354,8 +339,8 @@ namespace detail
|
||||
//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!
|
||||
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);
|
||||
}
|
||||
@@ -814,7 +799,7 @@ namespace detail
|
||||
::nana::widget* window_manager::get_widget(core_window_t* wd) const
|
||||
{
|
||||
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
|
||||
@@ -1172,11 +1157,6 @@ namespace detail
|
||||
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)
|
||||
{
|
||||
if (wd == cond) return true;
|
||||
@@ -1387,8 +1367,7 @@ namespace detail
|
||||
wndlayout_type::enable_effects_bground(wd, false);
|
||||
|
||||
wd->drawer.detached();
|
||||
impl_->signal.call_signal(wd, signals::code::destroy, signals_);
|
||||
impl_->signal.umake(wd);
|
||||
wd->widget_notifier->destroy();
|
||||
|
||||
if(wd->other.category == category::frame_tag::value)
|
||||
{
|
||||
|
||||
@@ -780,16 +780,16 @@ namespace API
|
||||
{
|
||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
restrict::window_manager.signal_fire_caption(iwd, title.c_str());
|
||||
if (restrict::window_manager.available(iwd))
|
||||
iwd->widget_notifier->caption(title);
|
||||
}
|
||||
|
||||
nana::string window_caption(window wd)
|
||||
{
|
||||
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);
|
||||
internal_scope_guard lock;
|
||||
if(restrict::window_manager.available(iwd))
|
||||
return restrict::window_manager.signal_fire_caption(iwd);
|
||||
if (restrict::window_manager.available(iwd))
|
||||
return iwd->widget_notifier->caption();
|
||||
|
||||
return{};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* 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.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <nana/gui/widgets/widget.hpp>
|
||||
#include <nana/gui/tooltip.hpp>
|
||||
#include <nana/gui/detail/widget_notifier_interface.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@@ -18,8 +19,41 @@ namespace nana
|
||||
{
|
||||
void set_eval(window, i18n_eval&&);
|
||||
}
|
||||
|
||||
//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
|
||||
{
|
||||
return this->_m_caption();
|
||||
@@ -205,6 +239,11 @@ namespace nana
|
||||
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()
|
||||
{}
|
||||
|
||||
@@ -298,7 +337,14 @@ namespace nana
|
||||
{
|
||||
return API::bgcolor(handle());
|
||||
}
|
||||
|
||||
//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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user