some improvements, deprecated frame widget

This commit is contained in:
Jinhao
2016-06-24 00:25:26 +08:00
parent 0cd9be4641
commit 880d0becf3
24 changed files with 603 additions and 435 deletions

View File

@@ -17,188 +17,194 @@ namespace nana
{
namespace detail
{
//class caret_descriptor
caret_descriptor::caret_descriptor(core_window_t* wd, unsigned width, unsigned height)
:wd_(wd), size_(width, height), visible_state_(visible_state::invisible), out_of_range_(false)
//class caret
caret::caret(basic_window* owner, const size& size):
owner_(owner),
size_(size)
{}
caret_descriptor::~caret_descriptor()
caret::~caret()
{
if(wd_) native_interface::caret_destroy(wd_->root);
if (owner_)
native_interface::caret_destroy(owner_->root);
}
void caret_descriptor::set_active(bool active)
void caret::activate(bool activity)
{
if(wd_)
if (owner_)
{
if(active)
if (activity)
{
native_interface::caret_create(wd_->root, size_);
native_interface::caret_create(owner_->root, size_);
visible_state_ = visible_state::invisible;
this->position(point_.x, point_.y);
visibility_ = visible_state::invisible;
this->position(position_);
}
else
native_interface::caret_destroy(wd_->root);
native_interface::caret_destroy(owner_->root);
wd_->root_widget->other.attribute.root->ime_enabled = active;
owner_->root_widget->other.attribute.root->ime_enabled = activity;
}
}
auto caret_descriptor::window() const ->core_window_t*
basic_window* caret::owner() const noexcept
{
return wd_;
return owner_;
}
void caret_descriptor::position(int x, int y)
void caret::update()
{
point_.x = x;
point_.y = y;
auto pos = position_;
auto size = size_;
update();
}
void caret_descriptor::effective_range(nana::rectangle rect)
{
//Chech rect
if (rect.width && rect.height && rect.right() > 0 && rect.bottom() > 0)
{
if(rect.x < 0)
{
rect.width += rect.x;
rect.x = 0;
}
if(rect.y < 0)
{
rect.height += rect.y;
rect.y = 0;
}
if(effective_range_ != rect)
{
effective_range_ = rect;
update();
}
}
}
nana::point caret_descriptor::position() const
{
return point_;
}
void caret_descriptor::visible(bool is_show)
{
auto pre_displayed = (visible_state::displayed == visible_state_);
if (is_show)
{
visible_state_ = visible_state::visible;
if (wd_->displayed() && (! out_of_range_))
visible_state_ = visible_state::displayed;
}
else
visible_state_ = visible_state::invisible;
if (pre_displayed != (visible_state::displayed == visible_state_))
native_interface::caret_visible(wd_->root, !pre_displayed);
}
bool caret_descriptor::visible() const
{
return (visible_state::invisible != visible_state_);
}
nana::size caret_descriptor::size() const
{
return size_;
}
void caret_descriptor::size(const nana::size& s)
{
size_ = s;
update();
if (visible_state::invisible != visible_state_)
visible(true);
}
void caret_descriptor::update()
{
nana::point pos = point_;
nana::size size = size_;
nana::rectangle rect = effective_range_;
if(0 == effective_range_.width || 0 == effective_range_.height)
auto rect = effect_range_;
if (0 == effect_range_.width || 0 == effect_range_.height)
{
rect.x = rect.y = 0;
rect = wd_->dimension;
rect = owner_->dimension;
}
else
{
pos.x += effective_range_.x;
pos.y += effective_range_.y;
pos += effect_range_.position();
}
if( (pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
if ((pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
(pos.y + static_cast<int>(size.height) <= rect.y) || (pos.y >= rect.bottom())
)
{//Out of Range without overlap
if(false == out_of_range_)
if (false == out_of_range_)
{
out_of_range_ = true;
if (visible_state::invisible != visible_state_)
if (visible_state::invisible != visibility_)
visible(false);
}
}
else
{
if(pos.x < rect.x)
if (pos.x < rect.x)
{
size.width -= (rect.x - pos.x);
pos.x = rect.x;
}
else if(pos.x + static_cast<int>(size.width) > rect.right())
else if (pos.x + static_cast<int>(size.width) > rect.right())
{
size.width -= pos.x + size.width - rect.right();
}
if(pos.y < rect.y)
if (pos.y < rect.y)
{
size.width -= (rect.y - pos.y);
pos.y = rect.y;
}
else if(pos.y + static_cast<int>(size.height) > rect.bottom())
else if (pos.y + static_cast<int>(size.height) > rect.bottom())
size.height -= pos.y + size.height - rect.bottom();
if(out_of_range_)
if (out_of_range_)
{
if (paint_size_ == size)
if (visual_size_ == size)
visible(true);
out_of_range_ = false;
}
if(paint_size_ != size)
if (visual_size_ != size)
{
bool vs = (visible_state::invisible != visible_state_);
native_interface::caret_destroy(wd_->root);
native_interface::caret_create(wd_->root, size);
bool vs = (visible_state::invisible != visibility_);
native_interface::caret_destroy(owner_->root);
native_interface::caret_create(owner_->root, size);
visible_state_ = visible_state::invisible;
visibility_ = visible_state::invisible;
if (vs)
visible(true);
paint_size_ = size;
visual_size_ = size;
}
native_interface::caret_pos(wd_->root, wd_->pos_root + pos);
native_interface::caret_pos(owner_->root, owner_->pos_root + pos);
}
}
//end class caret_descriptor
//Implement caret_interface functions
void caret::disable_throw() noexcept
{
//This function is useless for class caret, see caret_proxy.
}
void caret::effective_range(const rectangle& r)
{
auto range = r;
//Chech rect
if (range.width && range.height && range.right() > 0 && range.bottom() > 0)
{
if (range.x < 0)
{
range.width += range.x;
range.x = 0;
}
if (range.y < 0)
{
range.height += range.y;
range.y = 0;
}
if (effect_range_ != range)
{
effect_range_ = range;
update();
}
}
}
void caret::position(const point& pos)
{
position_ = pos;
update();
}
point caret::position() const
{
return position_;
}
size caret::dimension() const
{
return size_;
}
void caret::dimension(const size& s)
{
size_ = s;
update();
if (visible_state::invisible != visibility_)
visible(true);
}
void caret::visible(bool visibility)
{
auto pre_displayed = (visible_state::displayed == visibility_);
if (visibility)
{
visibility_ = visible_state::visible;
if (owner_->displayed() && (!out_of_range_))
visibility_ = visible_state::displayed;
}
else
visibility_ = visible_state::invisible;
if (pre_displayed != (visible_state::displayed == visibility_))
native_interface::caret_visible(owner_->root, !pre_displayed);
}
bool caret::visible() const
{
return (visible_state::invisible != visibility_);
}
//end class caret
//struct basic_window
//struct basic_window::other_tag
@@ -210,9 +216,11 @@ namespace nana
case category::flags::root:
attribute.root = new attr_root_tag;
break;
#ifndef WIDGET_FRAME_DEPRECATED
case category::flags::frame:
attribute.frame = new attr_frame_tag;
break;
#endif
default:
attribute.root = nullptr;
}
@@ -220,6 +228,7 @@ namespace nana
basic_window::other_tag::~other_tag()
{
#ifndef WIDGET_FRAME_DEPRECATED
switch(category)
{
case category::flags::root:
@@ -230,6 +239,9 @@ namespace nana
break;
default: break;
}
#endif
if (category::flags::root == category)
delete attribute.root;
}
//end struct basic_window::other_tag
@@ -245,8 +257,8 @@ namespace nana
basic_window::~basic_window()
{
delete together.caret;
together.caret = nullptr;
delete annex.caret_ptr;
annex.caret_ptr = nullptr;
delete effect.bground;
effect.bground = nullptr;
@@ -268,11 +280,13 @@ namespace nana
}
}
#ifndef WIDGET_FRAME_DEPRECATED
void basic_window::frame_window(native_window_type wd)
{
if(category::flags::frame == this->other.category)
other.attribute.frame->container = wd;
}
#endif
bool basic_window::is_ancestor_of(const basic_window* wd) const
{
@@ -312,7 +326,7 @@ namespace nana
const basic_window* get_child_caret(const basic_window* wd, bool this_is_a_child)
{
if (this_is_a_child && wd->together.caret)
if (this_is_a_child && wd->annex.caret_ptr)
return wd;
for (auto child : wd->children)
@@ -412,8 +426,6 @@ namespace nana
effect.bground = nullptr;
effect.bground_fade_rate = 0;
together.caret = nullptr;
extra_width = extra_height = 0;
//The window must keep its thread_id same as its parent if it is a child.
@@ -425,15 +437,15 @@ namespace nana
bool basic_window::set_events(const std::shared_ptr<general_events>& p)
{
if (together.events_ptr)
if (annex.events_ptr)
return false;
together.events_ptr = p;
annex.events_ptr = p;
return true;
}
general_events * basic_window::get_events() const
{
return together.events_ptr.get();
return annex.events_ptr.get();
}
//end struct basic_window
}//end namespace detail

View File

@@ -129,16 +129,16 @@ namespace nana
arg.window_handle = reinterpret_cast<window>(wd);
if (emit(event_code::expose, wd, arg, false, get_thread_context()))
{
const core_window_t * caret_wd = (wd->together.caret ? wd : wd->child_caret());
const core_window_t * caret_wd = (wd->annex.caret_ptr ? wd : wd->child_caret());
if (caret_wd)
{
if (exposed)
{
if (wd->root_widget->other.attribute.root->focus == caret_wd)
caret_wd->together.caret->visible(true);
caret_wd->annex.caret_ptr->visible(true);
}
else
caret_wd->together.caret->visible(false);
caret_wd->annex.caret_ptr->visible(false);
}
if (!exposed)
@@ -148,8 +148,10 @@ namespace nana
//find an ancestor until it is not a lite_widget
wd = wd->seek_non_lite_widget_ancestor();
}
#ifndef WIDGET_FRAME_DEPRECATED
else if (category::flags::frame == wd->other.category)
wd = wd_manager().find_window(wd->root, wd->pos_root.x, wd->pos_root.y);
#endif
}
wd_manager().refresh_tree(wd);
@@ -201,24 +203,21 @@ namespace nana
{
if (root_wd->flags.enabled && root_wd->flags.take_active)
{
if (focused && focused->together.caret)
focused->together.caret->set_active(true);
if (focused && focused->annex.caret_ptr)
focused->annex.caret_ptr->activate(true);
if (!emit(event_code::focus, focused, arg, true, get_thread_context()))
this->wd_manager().set_focus(root_wd, true, arg_focus::reason::general);
}
}
else
else if (root_wd->other.attribute.root->focus)
{
if (root_wd->other.attribute.root->focus)
if (emit(event_code::focus, focused, arg, true, get_thread_context()))
{
if (emit(event_code::focus, focused, arg, true, get_thread_context()))
{
if (focused->together.caret)
focused->together.caret->set_active(false);
}
close_menu_if_focus_other_window(receiver);
if (focused->annex.caret_ptr)
focused->annex.caret_ptr->activate(false);
}
close_menu_if_focus_other_window(receiver);
}
}
@@ -353,19 +352,14 @@ namespace nana
return pi_data_->shortkey_occurred;
}
widget_geometrics& bedrock::get_scheme_template(scheme_factory_interface&& factory)
color_schemes& bedrock::scheme()
{
return pi_data_->scheme.scheme_template(std::move(factory));
}
widget_geometrics* bedrock::make_scheme(scheme_factory_interface&& factory)
{
return pi_data_->scheme.create(std::move(factory));
return pi_data_->scheme;
}
void bedrock::_m_emit_core(event_code evt_code, core_window_t* wd, bool draw_only, const ::nana::event_arg& event_arg)
{
auto retain = wd->together.events_ptr;
auto retain = wd->annex.events_ptr;
auto evts_ptr = retain.get();
switch (evt_code)

View File

@@ -385,7 +385,7 @@ namespace detail
delete msg.u.mouse_drop.files;
arg.pos.x = msg.u.mouse_drop.x - msgwd->pos_root.x;
arg.pos.y = msg.u.mouse_drop.y - msgwd->pos_root.y;
msgwd->together.events_ptr->mouse_dropfiles.emit(arg, reinterpret_cast<window>(msgwd));
msgwd->annex.events_ptr->mouse_dropfiles.emit(arg, reinterpret_cast<window>(msgwd));
brock.wd_manager().do_lazy_refresh(msgwd, false);
}
break;
@@ -594,7 +594,7 @@ namespace detail
}
}
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
context.event_window = msgwnd;
pressed_wd = nullptr;
@@ -632,7 +632,7 @@ namespace detail
nana::point mspos{xevent.xbutton.x, xevent.xbutton.y};
while(msgwnd)
{
if(msgwnd->together.events_ptr->mouse_wheel.length() != 0)
if(msgwnd->annex.events_ptr->mouse_wheel.length() != 0)
{
mspos -= msgwnd->pos_root;
arg_wheel arg;
@@ -653,7 +653,7 @@ namespace detail
msgwnd->set_action(mouse_action::normal);
if(msgwnd->flags.enabled)
{
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
::nana::arg_mouse arg;
assign_arg(arg, msgwnd, message, xevent);
@@ -682,7 +682,7 @@ namespace detail
if(hit)
msgwnd->set_action(mouse_action::hovered);
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
auto evt_ptr = retain.get();
arg.evt_code = event_code::mouse_up;
@@ -698,7 +698,7 @@ namespace detail
}
}
else if(click_arg.window_handle)
msgwnd->together.events_ptr->click.emit(click_arg, reinterpret_cast<window>(msgwnd));
msgwnd->annex.events_ptr->click.emit(click_arg, reinterpret_cast<window>(msgwnd));
wd_manager.do_lazy_refresh(msgwnd, false);
}
@@ -895,7 +895,7 @@ namespace detail
msgwnd->set_action(mouse_action::pressed);
pressed_wd_space = msgwnd;
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
draw_invoker(&drawer::mouse_down, msgwnd, arg, &context);
wd_manager.do_lazy_refresh(msgwnd, false);
@@ -987,7 +987,7 @@ namespace detail
arg.evt_code = event_code::key_char;
arg.window_handle = reinterpret_cast<window>(msgwnd);
brock.get_key_state(arg);
msgwnd->together.events_ptr->key_char.emit(arg, reinterpret_cast<window>(msgwnd));
msgwnd->annex.events_ptr->key_char.emit(arg, reinterpret_cast<window>(msgwnd));
if(arg.ignore == false && wd_manager.available(msgwnd))
draw_invoker(&drawer::key_char, msgwnd, arg, &context);
}
@@ -1031,7 +1031,7 @@ namespace detail
click_arg.mouse_args = nullptr;
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
{
arg_mouse arg;

View File

@@ -947,7 +947,7 @@ namespace detail
assign_arg(arg, msgwnd, message, pmdec);
msgwnd->set_action(mouse_action::pressed);
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
if (brock.emit(event_code::mouse_down, msgwnd, arg, true, &context))
{
//If a root_window is created during the mouse_down event, Nana.GUI will ignore the mouse_up event.
@@ -986,7 +986,7 @@ namespace detail
msgwnd->set_action(mouse_action::normal);
if(msgwnd->flags.enabled)
{
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
::nana::arg_mouse arg;
assign_arg(arg, msgwnd, message, pmdec);
@@ -1121,7 +1121,7 @@ namespace detail
auto evt_wd = scrolled_wd;
while (evt_wd)
{
if (evt_wd->together.events_ptr->mouse_wheel.length() != 0)
if (evt_wd->annex.events_ptr->mouse_wheel.length() != 0)
{
def_window_proc = false;
nana::point mspos{ scr_pos.x, scr_pos.y };
@@ -1198,7 +1198,7 @@ namespace detail
wd_manager.calc_window_point(msgwnd, dropfiles.pos);
dropfiles.window_handle = reinterpret_cast<window>(msgwnd);
msgwnd->together.events_ptr->mouse_dropfiles.emit(dropfiles, reinterpret_cast<window>(msgwnd));
msgwnd->annex.events_ptr->mouse_dropfiles.emit(dropfiles, reinterpret_cast<window>(msgwnd));
wd_manager.do_lazy_refresh(msgwnd, false);
}
}
@@ -1422,7 +1422,7 @@ namespace detail
msgwnd->set_action(mouse_action::pressed);
pressed_wd_space = msgwnd;
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
draw_invoker(&drawer::mouse_down, msgwnd, arg, &context);
wd_manager.do_lazy_refresh(msgwnd, false);
@@ -1468,7 +1468,7 @@ namespace detail
brock.get_key_state(arg);
arg.ignore = false;
msgwnd->together.events_ptr->key_char.emit(arg, reinterpret_cast<window>(msgwnd));
msgwnd->annex.events_ptr->key_char.emit(arg, reinterpret_cast<window>(msgwnd));
if ((false == arg.ignore) && wd_manager.available(msgwnd))
draw_invoker(&drawer::key_char, msgwnd, arg, &context);
@@ -1496,7 +1496,7 @@ namespace detail
click_arg.mouse_args = nullptr;
click_arg.window_handle = reinterpret_cast<window>(msgwnd);
auto retain = msgwnd->together.events_ptr;
auto retain = msgwnd->annex.events_ptr;
if (brock.emit(event_code::click, msgwnd, click_arg, true, &context))
{
arg_mouse arg;

View File

@@ -26,7 +26,6 @@ namespace nana
typedef detail::edge_nimbus_renderer<detail::bedrock::core_window_t> edge_nimbus_renderer_t;
//class drawer_trigger
drawer_trigger::~drawer_trigger(){}
void drawer_trigger::attached(widget_reference, graph_reference){}
void drawer_trigger::detached(){} //none-const
void drawer_trigger::typeface_changed(graph_reference){}
@@ -136,23 +135,43 @@ namespace nana
typedef bedrock bedrock_type;
//class drawer
enum{
event_size = static_cast<int>(event_code::end)
};
struct drawer::data_implement
{
bool refreshing{ false };
basic_window* window_handle{ nullptr };
drawer_trigger* realizer{ nullptr };
method_state mth_state[event_size];
std::vector<dynamic_drawing::object*> draws;
};
drawer::drawer()
: data_impl_{ new data_implement }
{}
drawer::~drawer()
{
for(auto p : dynamic_drawing_objects_)
for(auto p : data_impl_->draws)
{
delete p;
}
delete data_impl_;
}
void drawer::bind(basic_window* cw)
{
core_window_ = cw;
data_impl_->window_handle = cw;
}
void drawer::typeface_changed()
{
if(realizer_)
realizer_->typeface_changed(graphics);
if(data_impl_->realizer)
data_impl_->realizer->typeface_changed(graphics);
}
void drawer::click(const arg_click& arg)
@@ -245,7 +264,7 @@ namespace nana
if(wd)
{
auto iwd = reinterpret_cast<bedrock_type::core_window_t*>(wd);
bool owns_caret = (iwd->together.caret) && (iwd->together.caret->visible());
bool owns_caret = (iwd->annex.caret_ptr) && (iwd->annex.caret_ptr->visible());
//The caret in X11 is implemented by Nana, it is different from Windows'
//the caret in X11 is asynchronous, it is hard to hide and show the caret
@@ -254,7 +273,7 @@ namespace nana
if(owns_caret)
{
#ifndef NANA_X11
iwd->together.caret->visible(false);
iwd->annex.caret_ptr->visible(false);
#else
owns_caret = nana::detail::platform_spec::instance().caret_update(iwd->root, *iwd->root_graph, false);
#endif
@@ -265,7 +284,7 @@ namespace nana
if(owns_caret)
{
#ifndef NANA_X11
iwd->together.caret->visible(true);
iwd->annex.caret_ptr->visible(true);
#else
nana::detail::platform_spec::instance().caret_update(iwd->root, *iwd->root_graph, true);
#endif
@@ -275,39 +294,39 @@ namespace nana
void drawer::refresh()
{
if(realizer_ && (refreshing_ == false))
if (data_impl_->realizer && !data_impl_->refreshing)
{
refreshing_ = true;
data_impl_->refreshing = true;
_m_bground_pre();
realizer_->refresh(graphics);
data_impl_->realizer->refresh(graphics);
_m_draw_dynamic_drawing_object();
_m_bground_end();
graphics.flush();
refreshing_ = false;
data_impl_->refreshing = false;
}
}
drawer_trigger* drawer::realizer() const
{
return realizer_;
return data_impl_->realizer;
}
void drawer::attached(widget& wd, drawer_trigger& realizer)
{
for (auto i = std::begin(mth_state_), end = std::end(mth_state_); i != end; ++i)
for (auto i = std::begin(data_impl_->mth_state), end = std::end(data_impl_->mth_state); i != end; ++i)
*i = method_state::pending;
realizer_ = &realizer;
data_impl_->realizer = &realizer;
realizer._m_reset_overrided();
realizer.attached(wd, graphics);
}
drawer_trigger* drawer::detached()
{
if(realizer_)
if (data_impl_->realizer)
{
auto rmp = realizer_;
realizer_ = nullptr;
auto rmp = data_impl_->realizer;
data_impl_->realizer = nullptr;
rmp->detached();
return rmp;
}
@@ -317,7 +336,7 @@ namespace nana
void drawer::clear()
{
std::vector<dynamic_drawing::object*> then;
for(auto p : dynamic_drawing_objects_)
for (auto p : data_impl_->draws)
{
if(p->diehard())
then.push_back(p);
@@ -325,7 +344,7 @@ namespace nana
delete p;
}
then.swap(dynamic_drawing_objects_);
then.swap(data_impl_->draws);
}
void* drawer::draw(std::function<void(paint::graphics&)> && f, bool diehard)
@@ -333,7 +352,7 @@ namespace nana
if(f)
{
auto p = new dynamic_drawing::user_draw_function(std::move(f), diehard);
dynamic_drawing_objects_.push_back(p);
data_impl_->draws.push_back(p);
return (diehard ? p : nullptr);
}
return nullptr;
@@ -343,11 +362,11 @@ namespace nana
{
if(p)
{
for (auto i = dynamic_drawing_objects_.begin(); i != dynamic_drawing_objects_.end(); ++i)
for (auto i = data_impl_->draws.begin(); i != data_impl_->draws.end(); ++i)
if (*i == p)
{
delete (*i);
dynamic_drawing_objects_.erase(i);
data_impl_->draws.erase(i);
break;
}
}
@@ -355,25 +374,25 @@ namespace nana
void drawer::_m_bground_pre()
{
if(core_window_->effect.bground && core_window_->effect.bground_fade_rate < 0.01)
core_window_->other.glass_buffer.paste(graphics, 0, 0);
if (data_impl_->window_handle->effect.bground && data_impl_->window_handle->effect.bground_fade_rate < 0.01)
data_impl_->window_handle->other.glass_buffer.paste(graphics, 0, 0);
}
void drawer::_m_bground_end()
{
if(core_window_->effect.bground && core_window_->effect.bground_fade_rate >= 0.01)
core_window_->other.glass_buffer.blend(::nana::rectangle{ core_window_->other.glass_buffer.size() }, graphics, nana::point(), core_window_->effect.bground_fade_rate);
if (data_impl_->window_handle->effect.bground && data_impl_->window_handle->effect.bground_fade_rate >= 0.01)
data_impl_->window_handle->other.glass_buffer.blend(::nana::rectangle{ data_impl_->window_handle->other.glass_buffer.size() }, graphics, nana::point(), data_impl_->window_handle->effect.bground_fade_rate);
}
void drawer::_m_draw_dynamic_drawing_object()
{
for(auto * dw : dynamic_drawing_objects_)
for (auto * dw : data_impl_->draws)
dw->draw(graphics);
}
bool drawer::_m_lazy_decleared() const
{
return (basic_window::update_state::refresh == core_window_->other.upd_state);
return (basic_window::update_state::refresh == data_impl_->window_handle->other.upd_state);
}
}//end namespace detail
}//end namespace nana

View File

@@ -66,6 +66,7 @@ namespace nana
nana::point p_src;
for (auto & el : blocks)
{
#ifndef WIDGET_FRAME_DEPRECATED
if (category::flags::frame == el.window->other.category)
{
native_window_type container = el.window->other.attribute.frame->container;
@@ -73,6 +74,7 @@ namespace nana
graph.bitblt(el.r, container);
}
else
#endif
{
p_src.x = el.r.x - el.window->pos_root.x;
p_src.y = el.r.y - el.window->pos_root.y;

View File

@@ -237,7 +237,7 @@ namespace detail
switch(evtid)
{
case event_code::mouse_drop:
wd->flags.dropable = (is_make || (0 != wd->together.events_ptr->mouse_dropfiles.length()));
wd->flags.dropable = (is_make || (0 != wd->annex.events_ptr->mouse_dropfiles.length()));
break;
default:
break;
@@ -277,8 +277,12 @@ namespace detail
if (owner->flags.destroying)
throw std::runtime_error("the specified owner is destory");
#ifndef WIDGET_FRAME_DEPRECATED
native = (category::flags::frame == owner->other.category ?
owner->other.attribute.frame->container : owner->root_widget->root);
#else
native = owner->root_widget->root;
#endif
r.x += owner->pos_root.x;
r.y += owner->pos_root.y;
}
@@ -311,8 +315,10 @@ 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);
#ifndef WIDGET_FRAME_DEPRECATED
if (owner && (category::flags::frame == owner->other.category))
insert_frame(owner, wd);
#endif
bedrock::inc_window(wd->thread_id);
this->icon(wd, impl_->default_icon_small, impl_->default_icon_big);
@@ -321,6 +327,7 @@ namespace detail
return nullptr;
}
#ifndef WIDGET_FRAME_DEPRECATED
window_manager::core_window_t* window_manager::create_frame(core_window_t* parent, const rectangle& r, widget* wdg)
{
//Thread-Safe Required!
@@ -337,6 +344,7 @@ namespace detail
return (wd);
}
bool window_manager::insert_frame(core_window_t* frame, native_window wd)
{
if(frame)
@@ -367,6 +375,7 @@ namespace detail
}
return false;
}
#endif
window_manager::core_window_t* window_manager::create_widget(core_window_t* parent, const rectangle& r, bool is_lite, widget* wdg)
{
@@ -461,7 +470,11 @@ namespace detail
std::lock_guard<decltype(mutex_)> lock(mutex_);
if (impl_->wd_register.available(wd) == false) return;
#ifndef WIDGET_FRAME_DEPRECATED
if((category::flags::root == wd->other.category) || (category::flags::frame != wd->other.category))
#else
if (category::flags::root == wd->other.category)
#endif
{
impl_->misc_register.erase(wd->root);
impl_->wd_register.remove(wd);
@@ -498,6 +511,7 @@ namespace detail
if(visible != wd->visible)
{
#ifndef WIDGET_FRAME_DEPRECATED
native_window_type nv = nullptr;
switch(wd->other.category)
{
@@ -508,6 +522,9 @@ namespace detail
default: //category::widget_tag, category::lite_widget_tag
break;
}
#else
auto nv = (category::flags::root == wd->other.category ? wd->root : nullptr);
#endif
if(visible && wd->effect.bground)
window_layer::make_bground(wd);
@@ -717,12 +734,14 @@ namespace detail
if(false == passive)
native_interface::window_size(wd->root, sz + nana::size(wd->extra_width, wd->extra_height));
}
#ifndef WIDGET_FRAME_DEPRECATED
else if(category::flags::frame == wd->other.category)
{
native_interface::window_size(wd->other.attribute.frame->container, sz);
for(auto natwd : wd->other.attribute.frame->attach)
native_interface::window_size(natwd, sz);
}
#endif
else
{
//update the bground buffer of glass window.
@@ -943,8 +962,8 @@ namespace detail
if (impl_->wd_register.available(prev_focus))
{
if(prev_focus->together.caret)
prev_focus->together.caret->set_active(false);
if(prev_focus->annex.caret_ptr)
prev_focus->annex.caret_ptr->activate(false);
arg.getting = false;
arg.window_handle = reinterpret_cast<window>(prev_focus);
@@ -961,8 +980,8 @@ namespace detail
return prev_focus; //no new focus_window
if(wd->together.caret)
wd->together.caret->set_active(true);
if(wd->annex.caret_ptr)
wd->annex.caret_ptr->activate(true);
arg.window_handle = reinterpret_cast<window>(wd);
arg.getting = true;
@@ -1446,6 +1465,7 @@ namespace detail
}
}
#ifndef WIDGET_FRAME_DEPRECATED
if (category::flags::frame == wd->other.category)
{
//remove the frame handle from the WM frames manager.
@@ -1454,6 +1474,7 @@ namespace detail
if (established)
pa_root_attr->frames.push_back(wd);
}
#endif
if (established)
{
@@ -1507,11 +1528,11 @@ namespace detail
wd->flags.destroying = true;
if(wd->together.caret)
if(wd->annex.caret_ptr)
{
//The deletion of caret wants to know whether the window is destroyed under SOME platform. Such as X11
delete wd->together.caret;
wd->together.caret = nullptr;
delete wd->annex.caret_ptr;
wd->annex.caret_ptr = nullptr;
}
arg_destroy arg;
@@ -1552,6 +1573,7 @@ namespace detail
wd->drawer.detached();
wd->widget_notifier->destroy();
#ifndef WIDGET_FRAME_DEPRECATED
if(category::flags::frame == wd->other.category)
{
//The frame widget does not have an owner, and close their element windows without activating owner.
@@ -1561,6 +1583,7 @@ namespace detail
native_interface::close_window(wd->other.attribute.frame->container);
}
#endif
if(wd->other.category != category::flags::root) //Not a root window
impl_->wd_register.remove(wd);
@@ -1571,13 +1594,18 @@ namespace detail
if(category::flags::root != wd->other.category) //A root widget always starts at (0, 0) and its childs are not to be changed
{
wd->pos_root += delta;
#ifndef WIDGET_FRAME_DEPRECATED
if (category::flags::frame != wd->other.category)
{
if (wd->together.caret && wd->together.caret->visible())
wd->together.caret->update();
if (wd->annex.caret_ptr && wd->annex.caret_ptr->visible())
wd->annex.caret_ptr->update();
}
else
native_interface::move_window(wd->other.attribute.frame->container, wd->pos_root.x, wd->pos_root.y);
#else
if (wd->annex.caret_ptr && wd->annex.caret_ptr->visible())
wd->annex.caret_ptr->update();
#endif
if (wd->displayed() && wd->effect.bground)
window_layer::make_bground(wd);