code reviews

This commit is contained in:
Jinhao
2015-10-13 01:38:53 +08:00
parent 500aa030ae
commit 1b5aed2e5f
41 changed files with 830 additions and 1001 deletions

View File

@@ -18,6 +18,7 @@
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED)

View File

@@ -29,12 +29,12 @@ namespace nana
//class internal_scope_guard
internal_scope_guard::internal_scope_guard()
{
detail::bedrock::instance().wd_manager.internal_lock().lock();
detail::bedrock::instance().wd_manager().internal_lock().lock();
}
internal_scope_guard::~internal_scope_guard()
{
detail::bedrock::instance().wd_manager.internal_lock().unlock();
detail::bedrock::instance().wd_manager().internal_lock().unlock();
}
//end class internal_scope_guard
@@ -54,12 +54,12 @@ namespace nana
{
void events_operation_register(event_handle evt)
{
bedrock::instance().evt_operation.register_evt(evt);
bedrock::instance().evt_operation().register_evt(evt);
}
void events_operation_cancel(event_handle evt)
{
bedrock::instance().evt_operation.cancel(evt);
bedrock::instance().evt_operation().cancel(evt);
}
class bedrock::flag_guard
@@ -73,7 +73,7 @@ namespace nana
~flag_guard()
{
if (brock_->wd_manager.available((wd_)))
if (brock_->wd_manager().available((wd_)))
wd_->flags.refreshing = false;
}
private:
@@ -82,6 +82,31 @@ namespace nana
};
events_operation& bedrock::evt_operation()
{
return pi_data_->evt_operation;
}
window_manager& bedrock::wd_manager()
{
return pi_data_->wd_manager;
}
void bedrock::manage_form_loader(core_window_t* wd, bool insert_or_remove)
{
if (insert_or_remove)
{
pi_data_->auto_form_set.insert(wd);
return;
}
if (pi_data_->auto_form_set.erase(wd))
{
auto p = wd->widget_notifier->widget_ptr();
delete p;
}
}
void bedrock::event_expose(core_window_t * wd, bool exposed)
{
if (nullptr == wd) return;
@@ -113,11 +138,11 @@ namespace nana
wd = wd->seek_non_lite_widget_ancestor();
}
else if (category::flags::frame == wd->other.category)
wd = wd_manager.find_window(wd->root, wd->pos_root.x, wd->pos_root.y);
wd = wd_manager().find_window(wd->root, wd->pos_root.x, wd->pos_root.y);
}
wd_manager.refresh_tree(wd);
wd_manager.map(wd, false);
wd_manager().refresh_tree(wd);
wd_manager().map(wd, false);
}
}
@@ -130,13 +155,13 @@ namespace nana
arg.x = x;
arg.y = y;
if (emit(event_code::move, wd, arg, false, get_thread_context()))
wd_manager.update(wd, false, true);
wd_manager().update(wd, false, true);
}
}
bool bedrock::event_msleave(core_window_t* hovered)
{
if (wd_manager.available(hovered) && hovered->flags.enabled)
if (wd_manager().available(hovered) && hovered->flags.enabled)
{
hovered->flags.action = mouse_action::normal;
@@ -155,7 +180,7 @@ namespace nana
void bedrock::update_cursor(core_window_t * wd)
{
internal_scope_guard isg;
if (wd_manager.available(wd))
if (wd_manager().available(wd))
{
auto * thrd = get_thread_context(wd->thread_id);
if (nullptr == thrd)
@@ -167,7 +192,7 @@ namespace nana
return;
native_interface::calc_window_point(native_handle, pos);
if (wd != wd_manager.find_window(native_handle, pos.x, pos.y))
if (wd != wd_manager().find_window(native_handle, pos.x, pos.y))
return;
set_cursor(wd, wd->predef_cursor, thrd);
@@ -179,7 +204,7 @@ namespace nana
return pi_data_->scheme.scheme_template(std::move(factory));
}
std::unique_ptr<widget_colors> bedrock::make_scheme(scheme_factory_base&& factory)
widget_colors* bedrock::make_scheme(scheme_factory_base&& factory)
{
return pi_data_->scheme.create(std::move(factory));
}
@@ -415,7 +440,7 @@ namespace nana
void bedrock::_m_except_handler()
{
std::vector<core_window_t*> v;
wd_manager.all_handles(v);
wd_manager().all_handles(v);
if (v.size())
{
std::vector<native_window_type> roots;
@@ -432,7 +457,7 @@ namespace nana
}
for (auto i : roots)
interface_type::close_window(i);
native_interface::close_window(i);
}
}
}//end namespace detail

View File

@@ -76,12 +76,12 @@ namespace nana
//Creates a scheme template if no template
if (!tmpl_scheme)
factory.create().swap(tmpl_scheme);
tmpl_scheme.reset(factory.create());
return *tmpl_scheme.get();
}
std::unique_ptr<widget_colors> color_schemes::create(scheme_factory_base&& factory)
widget_colors* color_schemes::create(scheme_factory_base&& factory)
{
return factory.create(scheme_template(std::move(factory)));
}

View File

@@ -5,7 +5,7 @@ namespace nana
namespace detail
{
//class events_operation
typedef std::lock_guard<std::recursive_mutex> lock_guard;
using lock_guard = std::lock_guard<std::recursive_mutex>;
void events_operation::make(window wd, const std::shared_ptr<general_events>& sp)
{
@@ -22,21 +22,21 @@ namespace nana
void events_operation::register_evt(event_handle evt)
{
lock_guard lock(mutex_);
register_.insert(evt);
handles_.insert(evt);
}
void events_operation::cancel(event_handle evt)
{
lock_guard lock(mutex_);
register_.erase(evt);
handles_.erase(evt);
}
void events_operation::erase(event_handle evt)
{
lock_guard lock(mutex_);
auto i = register_.find(evt);
if (i != register_.end())
auto i = handles_.find(evt);
if (i != handles_.end())
{
reinterpret_cast<detail::docker_interface*>(evt)->get_event()->remove(evt);
}

View File

@@ -233,7 +233,7 @@ namespace detail
if(wd)
{
internal_scope_guard isg;
if(wd_manager.available(wd))
if(wd_manager().available(wd))
return wd->other.category;
}
return category::flags::super;
@@ -241,21 +241,10 @@ namespace detail
bedrock::core_window_t* bedrock::focus()
{
core_window_t* wd = wd_manager.root(native_interface::get_focus_window());
core_window_t* wd = wd_manager().root(native_interface::get_focus_window());
return (wd ? wd->other.attribute.root->focus : 0);
}
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;
}
void bedrock::set_menubar_taken(core_window_t* wd)
{
auto pre = impl_->menu.taken_window;
@@ -265,8 +254,8 @@ namespace detail
if ((!wd) && pre)
{
internal_scope_guard lock;
wd_manager.set_focus(pre, false);
wd_manager.update(pre, true, false);
wd_manager().set_focus(pre, false);
wd_manager().update(pre, true, false);
}
}
@@ -381,17 +370,9 @@ namespace detail
//No implementation for Linux
}
bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd)
{
if(evt_code != arg.evt_code)
throw std::runtime_error("Nana.bedrock: Invalid event arg.");
return emit(evt_code, wd, static_cast<const ::nana::event_arg&>(arg), ask_update, thrd);
}
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd)
{
if(wd_manager.available(wd) == false)
if(wd_manager().available(wd) == false)
return false;
core_window_t * prev_wd;
@@ -408,7 +389,7 @@ namespace detail
_m_emit_core(evt_code, wd, false, arg);
if(ask_update)
wd_manager.do_lazy_refresh(wd, false);
wd_manager().do_lazy_refresh(wd, false);
else
wd->other.upd_state = core_window_t::update_state::none;
@@ -418,7 +399,7 @@ namespace detail
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd)
{
if(wd_manager.available(wd) == false)
if(wd_manager().available(wd) == false)
return false;
core_window_t * prev_wd;
@@ -541,7 +522,7 @@ namespace detail
static auto& brock = detail::bedrock::instance();
auto native_window = reinterpret_cast<native_window_type>(msg.u.packet_window);
auto root_runtime = brock.wd_manager.root_runtime(native_window);
auto root_runtime = brock.wd_manager().root_runtime(native_window);
if(root_runtime)
{
@@ -550,7 +531,7 @@ namespace detail
switch(msg.kind)
{
case nana::detail::msg_packet_tag::kind_mouse_drop:
msgwd = brock.wd_manager.find_window(native_window, msg.u.mouse_drop.x, msg.u.mouse_drop.y);
msgwd = brock.wd_manager().find_window(native_window, msg.u.mouse_drop.x, msg.u.mouse_drop.y);
if(msgwd)
{
arg_dropfiles arg;
@@ -560,7 +541,7 @@ namespace detail
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);
brock.wd_manager.do_lazy_refresh(msgwd, false);
brock.wd_manager().do_lazy_refresh(msgwd, false);
}
break;
default:
@@ -572,7 +553,7 @@ namespace detail
template<typename Arg>
void emit_drawer(void(::nana::detail::drawer::*event_ptr)(const Arg&), basic_window* wd, const Arg& arg, bedrock::thread_context* thrd)
{
if(bedrock::instance().wd_manager.available(wd) == false)
if(bedrock::instance().wd_manager().available(wd) == false)
return;
basic_window * pre_wd;
if(thrd)
@@ -597,7 +578,7 @@ namespace detail
static core_window_t* last_mouse_down_window;
auto native_window = reinterpret_cast<native_window_type>(event_window(xevent));
auto root_runtime = brock.wd_manager.root_runtime(native_window);
auto root_runtime = brock.wd_manager().root_runtime(native_window);
if(root_runtime)
{
@@ -612,7 +593,7 @@ namespace detail
switch(xevent.type)
{
case EnterNotify:
msgwnd = brock.wd_manager.find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y);
msgwnd = brock.wd_manager().find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y);
if(msgwnd)
{
if (mouse_action::pressed != msgwnd->flags.action)
@@ -626,7 +607,7 @@ namespace detail
arg.evt_code = event_code::mouse_move;
brock.emit(event_code::mouse_move, msgwnd, arg, true, &context);
if (!brock.wd_manager.available(hovered_wd))
if (!brock.wd_manager().available(hovered_wd))
hovered_wd = nullptr;
}
break;
@@ -646,7 +627,7 @@ namespace detail
arg.receiver = native_window;
arg.getting = true;
if(!brock.emit(event_code::focus, focus, arg, true, &context))
brock.wd_manager.set_focus(msgwnd, true);
brock.wd_manager().set_focus(msgwnd, true);
}
break;
case FocusOut:
@@ -672,7 +653,7 @@ namespace detail
if(msgwnd->dimension.width != static_cast<unsigned>(xevent.xconfigure.width) || msgwnd->dimension.height != static_cast<unsigned>(xevent.xconfigure.height))
{
auto & cf = xevent.xconfigure;
brock.wd_manager.size(msgwnd, nana::size{static_cast<unsigned>(cf.width), static_cast<unsigned>(cf.height)}, true, true);
brock.wd_manager().size(msgwnd, nana::size{static_cast<unsigned>(cf.width), static_cast<unsigned>(cf.height)}, true, true);
}
if(msgwnd->pos_native.x != xevent.xconfigure.x || msgwnd->pos_native.y != xevent.xconfigure.y)
@@ -686,7 +667,7 @@ namespace detail
if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5)
break;
msgwnd = brock.wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y);
msgwnd = brock.wd_manager().find_window(native_window, xevent.xbutton.x, xevent.xbutton.y);
if(nullptr == msgwnd) break;
if ((msgwnd == msgwnd->root_widget->other.attribute.root->menubar) && brock.get_menu(msgwnd->root, true))
@@ -706,9 +687,9 @@ namespace detail
if (new_focus && !new_focus->flags.ignore_mouse_focus)
{
context.event_window = new_focus;
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
auto kill_focus = brock.wd_manager().set_focus(new_focus, false);
if (kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
brock.wd_manager().do_lazy_refresh(kill_focus, false);
}
}
@@ -722,7 +703,7 @@ namespace detail
arg.evt_code = dbl_click ? event_code::dbl_click : event_code::mouse_down;
if(brock.emit(arg.evt_code, msgwnd, arg, true, &context))
{
if (brock.wd_manager.available(msgwnd))
if (brock.wd_manager().available(msgwnd))
{
pressed_wd = msgwnd;
//If a root window is created during the mouse_down event, Nana.GUI will ignore the mouse_up event.
@@ -731,7 +712,7 @@ namespace detail
//call the drawer mouse up event for restoring the surface graphics
msgwnd->flags.action = mouse_action::normal;
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
}
}
@@ -758,7 +739,7 @@ namespace detail
}
else
{
msgwnd = brock.wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y);
msgwnd = brock.wd_manager().find_window(native_window, xevent.xbutton.x, xevent.xbutton.y);
if(nullptr == msgwnd)
break;
@@ -786,7 +767,7 @@ namespace detail
}
//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;
@@ -805,7 +786,7 @@ namespace detail
evt_ptr->click.emit(arg);
}
if (brock.wd_manager.available(msgwnd))
if (brock.wd_manager().available(msgwnd))
{
arg.evt_code = event_code::mouse_up;
evt_ptr->mouse_up.emit(arg);
@@ -818,7 +799,7 @@ namespace detail
arg.by_mouse = true;
msgwnd->together.events_ptr->click.emit(arg);
}
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
pressed_wd = nullptr;
}
@@ -826,7 +807,7 @@ namespace detail
case DestroyNotify:
{
auto & spec = nana::detail::platform_spec::instance();
if(brock.wd_manager.available(msgwnd))
if(brock.wd_manager().available(msgwnd))
{
//The msgwnd may be destroyed if the window is destroyed by calling native interface of close_window().
if (msgwnd->root == brock.get_menu())
@@ -836,10 +817,10 @@ namespace detail
}
spec.remove(native_window);
brock.wd_manager.destroy(msgwnd);
brock.wd_manager().destroy(msgwnd);
brock.rt_manager.remove_if_exists(msgwnd);
brock.wd_manager.destroy_handle(msgwnd);
brock.manage_form_loader(msgwnd, false);
brock.wd_manager().destroy_handle(msgwnd);
}
}
break;
@@ -854,8 +835,8 @@ namespace detail
else
break;
msgwnd = brock.wd_manager.find_window(native_window, xevent.xmotion.x, xevent.xmotion.y);
if (brock.wd_manager.available(hovered_wd) && (msgwnd != hovered_wd))
msgwnd = brock.wd_manager().find_window(native_window, xevent.xmotion.x, xevent.xmotion.y);
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
{
brock.event_msleave(hovered_wd);
hovered_wd->flags.action = mouse_action::normal;
@@ -863,14 +844,14 @@ namespace detail
//if msgwnd is neither a captured window nor a child of captured window,
//redirect the msgwnd to the captured window.
auto cap_wd = brock.wd_manager.capture_redirect(msgwnd);
auto cap_wd = brock.wd_manager().capture_redirect(msgwnd);
if(cap_wd)
msgwnd = cap_wd;
}
else if(msgwnd)
{
bool prev_captured_inside;
if(brock.wd_manager.capture_window_entered(xevent.xmotion.x, xevent.xmotion.y, prev_captured_inside))
if(brock.wd_manager().capture_window_entered(xevent.xmotion.x, xevent.xmotion.y, prev_captured_inside))
{
event_code evt_code;
if(prev_captured_inside)
@@ -909,7 +890,7 @@ namespace detail
arg.evt_code = event_code::mouse_move;
brock.emit(event_code::mouse_move, msgwnd, arg, true, &context);
}
if (!brock.wd_manager.available(hovered_wd))
if (!brock.wd_manager().available(hovered_wd))
hovered_wd = nullptr;
break;
case MapNotify:
@@ -1010,11 +991,11 @@ namespace detail
{
arg_keyboard argkey;
brock.get_key_state(argkey);
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, !argkey.shift);
auto tstop_wd = brock.wd_manager().tabstop(msgwnd, !argkey.shift);
if (tstop_wd)
{
brock.wd_manager.set_focus(tstop_wd, false);
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
brock.wd_manager().set_focus(tstop_wd, false);
brock.wd_manager().do_lazy_refresh(tstop_wd, true);
}
}
else if(keyboard::alt == keychar)
@@ -1050,7 +1031,7 @@ namespace detail
arg.window_handle = reinterpret_cast<window>(msgwnd);
brock.emit(event_code::key_press, msgwnd, arg, true, &context);
if((XLookupKeySym == status) && (brock.wd_manager.available(msgwnd)))
if((XLookupKeySym == status) && (brock.wd_manager().available(msgwnd)))
{
//call key_char event if status is XLookupKeySym to avaid calling key_char
//twice, because the status would be equal to XLookupChars if the input method is
@@ -1069,7 +1050,7 @@ namespace detail
if(XLookupKeySym == status)
{
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
break;
}
case XLookupChars:
@@ -1099,7 +1080,7 @@ namespace detail
arg.ctrl = arg.shift = false;
arg.evt_code = event_code::shortkey;
brock.set_keyboard_shortkey(true);
auto shr_wd = brock.wd_manager.find_shortkey(native_window, arg.key);
auto shr_wd = brock.wd_manager().find_shortkey(native_window, arg.key);
if(shr_wd)
{
arg.window_handle = reinterpret_cast<window>(shr_wd);
@@ -1112,7 +1093,7 @@ namespace detail
brock.get_key_state(arg);
msgwnd->together.events_ptr->key_char.emit(arg);
if(arg.ignore == false && brock.wd_manager.available(msgwnd))
if(arg.ignore == false && brock.wd_manager().available(msgwnd))
brock.emit_drawer(event_code::key_char, msgwnd, arg, &context);
}
@@ -1121,7 +1102,7 @@ namespace detail
}
break;
}
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
if(keybuf != fixbuf)
delete [] keybuf;
}
@@ -1156,7 +1137,7 @@ namespace detail
{
bool set_focus = (brock.focus() != msgwnd) && (!msgwnd->root_widget->flags.ignore_menubar_focus);
if (set_focus)
brock.wd_manager.set_focus(msgwnd, false);
brock.wd_manager().set_focus(msgwnd, false);
arg_keyboard arg;
arg.evt_code = event_code::key_release;
@@ -1194,7 +1175,7 @@ namespace detail
}
}
root_runtime = brock.wd_manager.root_runtime(native_window);
root_runtime = brock.wd_manager().root_runtime(native_window);
if(root_runtime)
{
context.event_window = pre_event_window;
@@ -1207,11 +1188,11 @@ namespace detail
if(context) context->event_window = pre_event_window;
}
auto thread_id = ::nana::system::this_thread_id()
brock.wd_manager.call_safe_place(thread_id);
auto thread_id = ::nana::system::this_thread_id();
brock.wd_manager().call_safe_place(thread_id);
if(msgwnd)
brock.wd_manager.remove_trash_handle(thread_id);
brock.wd_manager().remove_trash_handle(thread_id);
}
}
@@ -1226,18 +1207,18 @@ namespace detail
}
++(context->event_pump_ref_count);
wd_manager.internal_lock().revert();
wd_manager().internal_lock().revert();
native_window_type owner_native = 0;
core_window_t * owner = 0;
if(modal_window)
{
native_window_type modal = root(reinterpret_cast<core_window_t*>(modal_window));
native_window_type modal = reinterpret_cast<core_window_t*>(modal_window)->root;
owner_native = native_interface::get_owner_window(modal);
if(owner_native)
{
native_interface::enable_window(owner_native, false);
owner = wd_manager.root(owner_native);
owner = wd_manager().root(owner_native);
if(owner)
owner->flags.enabled = false;
}
@@ -1252,7 +1233,7 @@ namespace detail
native_interface::enable_window(owner_native, true);
}
wd_manager.internal_lock().forward();
wd_manager().internal_lock().forward();
if(0 == --(context->event_pump_ref_count))
{
if(0 == modal_window || 0 == context->window_count)
@@ -1338,7 +1319,7 @@ namespace detail
void bedrock::undefine_state_cursor(core_window_t * wd, thread_context* thrd)
{
if (!wd_manager.available(wd))
if (!wd_manager().available(wd))
return;
wd->root_widget->other.attribute.root->state_cursor = nana::cursor::arrow;
@@ -1350,7 +1331,7 @@ namespace detail
return;
native_interface::calc_window_point(native_handle, pos);
auto rev_wd = wd_manager.find_window(native_handle, pos.x, pos.y);
auto rev_wd = wd_manager().find_window(native_handle, pos.x, pos.y);
if (rev_wd)
set_cursor(rev_wd, rev_wd->predef_cursor, thrd);
}

View File

@@ -1,7 +1,7 @@
/*
* Platform 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
@@ -25,6 +25,7 @@
#elif defined(NANA_X11)
#include <nana/system/platform.hpp>
#include <nana/gui/detail/bedrock.hpp>
#include <nana/gui/detail/window_manager.hpp>
#endif
namespace nana{
@@ -595,7 +596,7 @@ namespace nana{
Display* disp = restrict::spec.open_display();
restrict::spec.remove(wd);
auto iwd = brock.wd_manager.root(wd);
auto iwd = brock.wd_manager().root(wd);
if(iwd)
{
{
@@ -607,9 +608,9 @@ namespace nana{
::XFlush(disp);
restrict::spec.rev_error_handler();
}
brock.wd_manager.destroy(iwd);
brock.rt_manager.remove_if_exists(iwd);
brock.wd_manager.destroy_handle(iwd);
brock.wd_manager().destroy(iwd);
brock.manage_form_loader(iwd, false);
brock.wd_manager().destroy_handle(iwd);
}
nana::detail::platform_scope_guard psg;

View File

@@ -251,10 +251,10 @@ namespace detail
bedrock::~bedrock()
{
if(wd_manager.number_of_core_window())
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.";
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);
}
@@ -364,7 +364,7 @@ namespace detail
++(context->event_pump_ref_count);
auto & intr_locker = wd_manager.internal_lock();
auto & intr_locker = wd_manager().internal_lock();
intr_locker.revert();
try
@@ -372,8 +372,7 @@ namespace detail
MSG msg;
if(modal_window)
{
HWND native_handle = reinterpret_cast<HWND>(
root(reinterpret_cast<core_window_t*>(modal_window)));
HWND native_handle = reinterpret_cast<HWND>(reinterpret_cast<core_window_t*>(modal_window)->root);
if (is_modal)
{
HWND owner = ::GetWindow(native_handle, GW_OWNER);
@@ -395,7 +394,7 @@ namespace detail
::TranslateMessage(&msg);
::DispatchMessage(&msg);
wd_manager.remove_trash_handle(tid);
wd_manager().remove_trash_handle(tid);
}
}
}
@@ -413,8 +412,8 @@ namespace detail
::DispatchMessage(&msg);
}
wd_manager.call_safe_place(tid);
wd_manager.remove_trash_handle(tid);
wd_manager().call_safe_place(tid);
wd_manager().remove_trash_handle(tid);
if (msg.message == WM_DESTROY && msg.hwnd == native_handle)
break;
}//end while
@@ -433,8 +432,8 @@ namespace detail
::DispatchMessage(&msg);
}
wd_manager.call_safe_place(tid);
wd_manager.remove_trash_handle(tid);
wd_manager().call_safe_place(tid);
wd_manager().remove_trash_handle(tid);
}//end while
//Empty these rest messages, there is not a window to process these messages.
@@ -607,7 +606,7 @@ namespace detail
case nana::detail::messages::map_thread_root_buffer:
{
auto stru = reinterpret_cast<detail::messages::map_thread*>(lParam);
bedrock.wd_manager.map(reinterpret_cast<bedrock::core_window_t*>(wParam), stru->forced, (stru->ignore_update_area ? nullptr : &stru->update_area));
bedrock.wd_manager().map(reinterpret_cast<bedrock::core_window_t*>(wParam), stru->forced, (stru->ignore_update_area ? nullptr : &stru->update_area));
::UpdateWindow(wd);
::HeapFree(::GetProcessHeap(), 0, stru);
}
@@ -760,7 +759,7 @@ namespace detail
template<typename Arg>
void emit_drawer(void (::nana::detail::drawer::*event_ptr)(const Arg&), basic_window* wd, const Arg& arg, bedrock::thread_context* thrd)
{
if (bedrock::instance().wd_manager.available(wd) == false)
if (bedrock::instance().wd_manager().available(wd) == false)
return;
basic_window* prev_event_wd;
@@ -788,7 +787,7 @@ namespace detail
static restrict::TRACKMOUSEEVENT track = {sizeof track, 0x00000002};
auto native_window = reinterpret_cast<native_window_type>(root_window);
auto* root_runtime = brock.wd_manager.root_runtime(native_window);
auto* root_runtime = brock.wd_manager().root_runtime(native_window);
if(root_runtime)
{
@@ -884,7 +883,7 @@ namespace detail
arg_focus arg;
assign_arg(arg, focus, native_window, true);
if (!brock.emit(event_code::focus, focus, arg, true, &context))
brock.wd_manager.set_focus(msgwnd, true);
brock.wd_manager().set_focus(msgwnd, true);
}
def_window_proc = true;
break;
@@ -915,21 +914,21 @@ namespace detail
break;
case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK:
pressed_wd = nullptr;
msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if(msgwnd && msgwnd->flags.enabled)
{
if (msgwnd->flags.take_active && !msgwnd->flags.ignore_mouse_focus)
{
auto killed = brock.wd_manager.set_focus(msgwnd, false);
auto killed = brock.wd_manager().set_focus(msgwnd, false);
if (killed != msgwnd)
brock.wd_manager.do_lazy_refresh(killed, false);
brock.wd_manager().do_lazy_refresh(killed, false);
}
arg_mouse arg;
assign_arg(arg, msgwnd, message, pmdec);
if (brock.emit(arg.evt_code, msgwnd, arg, true, &context))
{
if (brock.wd_manager.available(msgwnd))
if (brock.wd_manager().available(msgwnd))
pressed_wd = msgwnd;
}
}
@@ -939,7 +938,7 @@ namespace detail
def_window_proc = true;
break;
case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN:
msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if(nullptr == msgwnd) break;
//if event on the menubar, just remove the menu if it is not associating with the menubar
@@ -957,9 +956,9 @@ namespace detail
auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window);
if (new_focus && (!new_focus->flags.ignore_mouse_focus))
{
auto kill_focus = brock.wd_manager.set_focus(new_focus, false);
auto kill_focus = brock.wd_manager().set_focus(new_focus, false);
if (kill_focus != new_focus)
brock.wd_manager.do_lazy_refresh(kill_focus, false);
brock.wd_manager().do_lazy_refresh(kill_focus, false);
}
}
@@ -976,14 +975,14 @@ namespace detail
auto pos = native_interface::cursor_position();
auto rootwd = native_interface::find_window(pos.x, pos.y);
native_interface::calc_window_point(rootwd, pos);
if(msgwnd != brock.wd_manager.find_window(rootwd, pos.x, pos.y))
if(msgwnd != brock.wd_manager().find_window(rootwd, pos.x, pos.y))
{
//call the drawer mouse up event for restoring the surface graphics
msgwnd->flags.action = mouse_action::normal;
arg.evt_code = event_code::mouse_up;
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
}
}
@@ -995,7 +994,7 @@ namespace detail
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if(nullptr == msgwnd)
break;
@@ -1022,7 +1021,7 @@ namespace detail
}
//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)
{
arg.evt_code = event_code::mouse_up;
emit_drawer(&drawer::mouse_up, msgwnd, arg, &context);
@@ -1035,7 +1034,7 @@ namespace detail
retain->click.emit(arg);
}
if (brock.wd_manager.available(msgwnd))
if (brock.wd_manager().available(msgwnd))
{
arg.evt_code = event_code::mouse_up;
retain->mouse_up.emit(arg);
@@ -1048,13 +1047,13 @@ namespace detail
arg.by_mouse = true;
retain->click.emit(arg);
}
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
pressed_wd = nullptr;
break;
case WM_MOUSEMOVE:
msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if (brock.wd_manager.available(hovered_wd) && (msgwnd != hovered_wd))
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd))
{
brock.event_msleave(hovered_wd);
hovered_wd->flags.action = mouse_action::normal;
@@ -1062,7 +1061,7 @@ namespace detail
//if msgwnd is neither captured window nor the child of captured window,
//redirect the msgwnd to the captured window.
auto wd = brock.wd_manager.capture_redirect(msgwnd);
auto wd = brock.wd_manager().capture_redirect(msgwnd);
if(wd)
msgwnd = wd;
}
@@ -1070,7 +1069,7 @@ namespace detail
else if(msgwnd)
{
bool prev_captured_inside;
if(brock.wd_manager.capture_window_entered(pmdec.mouse.x, pmdec.mouse.y, prev_captured_inside))
if(brock.wd_manager().capture_window_entered(pmdec.mouse.x, pmdec.mouse.y, prev_captured_inside))
{
event_code evt_code;
if(prev_captured_inside)
@@ -1115,7 +1114,7 @@ namespace detail
track.hwndTrack = native_window;
restrict::track_mouse_event(&track);
}
if (!brock.wd_manager.available(hovered_wd))
if (!brock.wd_manager().available(hovered_wd))
hovered_wd = nullptr;
break;
case WM_MOUSELEAVE:
@@ -1131,7 +1130,7 @@ namespace detail
if (pointer_wd == root_window)
{
::ScreenToClient(pointer_wd, &scr_pos);
auto scrolled_wd = brock.wd_manager.find_window(reinterpret_cast<native_window_type>(pointer_wd), scr_pos.x, scr_pos.y);
auto scrolled_wd = brock.wd_manager().find_window(reinterpret_cast<native_window_type>(pointer_wd), scr_pos.x, scr_pos.y);
def_window_proc = true;
auto evt_wd = scrolled_wd;
@@ -1141,7 +1140,7 @@ namespace detail
{
def_window_proc = false;
nana::point mspos{ scr_pos.x, scr_pos.y };
brock.wd_manager.calc_window_point(evt_wd, mspos);
brock.wd_manager().calc_window_point(evt_wd, mspos);
arg_wheel arg;
arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical);
@@ -1155,13 +1154,13 @@ namespace detail
if (scrolled_wd && (nullptr == evt_wd))
{
nana::point mspos{ scr_pos.x, scr_pos.y };
brock.wd_manager.calc_window_point(scrolled_wd, mspos);
brock.wd_manager().calc_window_point(scrolled_wd, mspos);
arg_wheel arg;
arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical);
assign_arg(arg, scrolled_wd, pmdec);
brock.emit_drawer(event_code::mouse_wheel, scrolled_wd, arg, &context);
brock.wd_manager.do_lazy_refresh(scrolled_wd, false);
brock.wd_manager().do_lazy_refresh(scrolled_wd, false);
}
}
else
@@ -1179,7 +1178,7 @@ namespace detail
POINT pos;
::DragQueryPoint(drop, &pos);
msgwnd = brock.wd_manager.find_window(native_window, pos.x, pos.y);
msgwnd = brock.wd_manager().find_window(native_window, pos.x, pos.y);
if(msgwnd)
{
arg_dropfiles dropfiles;
@@ -1209,11 +1208,11 @@ namespace detail
dropfiles.pos.x = pos.x;
dropfiles.pos.y = pos.y;
brock.wd_manager.calc_window_point(msgwnd, dropfiles.pos);
brock.wd_manager().calc_window_point(msgwnd, dropfiles.pos);
dropfiles.window_handle = reinterpret_cast<window>(msgwnd);
msgwnd->together.events_ptr->mouse_dropfiles.emit(dropfiles);
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
}
@@ -1301,7 +1300,7 @@ namespace detail
break;
case WM_SIZE:
if(wParam != SIZE_MINIMIZED)
brock.wd_manager.size(msgwnd, size(pmdec.size.width, pmdec.size.height), true, true);
brock.wd_manager().size(msgwnd, size(pmdec.size.width, pmdec.size.height), true, true);
break;
case WM_MOVE:
brock.event_move(msgwnd, (int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam));
@@ -1327,7 +1326,7 @@ namespace detail
case WM_SYSCHAR:
def_window_proc = true;
brock.set_keyboard_shortkey(true);
msgwnd = brock.wd_manager.find_shortkey(native_window, static_cast<unsigned long>(wParam));
msgwnd = brock.wd_manager().find_shortkey(native_window, static_cast<unsigned long>(wParam));
if(msgwnd)
{
arg_keyboard arg;
@@ -1374,7 +1373,7 @@ namespace detail
bool set_focus = (brock.focus() != msgwnd) && (!msgwnd->root_widget->flags.ignore_menubar_focus);
if (set_focus)
brock.wd_manager.set_focus(msgwnd, false);
brock.wd_manager().set_focus(msgwnd, false);
arg_keyboard arg;
arg.evt_code = event_code::key_release;
@@ -1408,12 +1407,12 @@ namespace detail
{
bool is_forward = (::GetKeyState(VK_SHIFT) >= 0);
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward);
auto tstop_wd = brock.wd_manager().tabstop(msgwnd, is_forward);
if (tstop_wd)
{
brock.wd_manager.set_focus(tstop_wd, false);
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
brock.wd_manager().set_focus(tstop_wd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(tstop_wd, true);
}
}
else
@@ -1455,10 +1454,10 @@ namespace detail
arg.ignore = false;
msgwnd->together.events_ptr->key_char.emit(arg);
if ((false == arg.ignore) && brock.wd_manager.available(msgwnd))
if ((false == arg.ignore) && brock.wd_manager().available(msgwnd))
brock.emit_drawer(event_code::key_char, msgwnd, arg, &context);
brock.wd_manager.do_lazy_refresh(msgwnd, false);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
}
}
return 0;
@@ -1506,12 +1505,12 @@ namespace detail
brock.erase_menu(false);
brock.delay_restore(3); //Restores if delay_restore not decleared
}
brock.wd_manager.destroy(msgwnd);
brock.wd_manager().destroy(msgwnd);
nana::detail::platform_spec::instance().release_window_icon(msgwnd->root);
break;
case WM_NCDESTROY:
brock.rt_manager.remove_if_exists(msgwnd);
brock.wd_manager.destroy_handle(msgwnd);
brock.manage_form_loader(msgwnd, false);
brock.wd_manager().destroy_handle(msgwnd);
if(--context.window_count <= 0)
{
@@ -1523,7 +1522,7 @@ namespace detail
def_window_proc = true;
}
root_runtime = brock.wd_manager.root_runtime(native_window);
root_runtime = brock.wd_manager().root_runtime(native_window);
if(root_runtime)
{
root_runtime->condition.pressed = pressed_wd;
@@ -1540,21 +1539,15 @@ namespace detail
::nana::category::flags bedrock::category(core_window_t* wd)
{
internal_scope_guard lock;
return (wd_manager.available(wd) ? wd->other.category : ::nana::category::flags::super);
return (wd_manager().available(wd) ? wd->other.category : ::nana::category::flags::super);
}
auto bedrock::focus() ->core_window_t*
{
core_window_t* wd = wd_manager.root(native_interface::get_focus_window());
core_window_t* wd = wd_manager().root(native_interface::get_focus_window());
return (wd ? wd->other.attribute.root->focus : nullptr);
}
native_window_type bedrock::root(core_window_t* wd)
{
internal_scope_guard lock;
return (wd_manager.available(wd) ? wd->root : nullptr);
}
void bedrock::set_menubar_taken(core_window_t* wd)
{
auto pre = impl_->menu.taken_window;
@@ -1565,8 +1558,8 @@ namespace detail
if ((!wd) && pre && (pre->root != get_menu()))
{
internal_scope_guard lock;
wd_manager.set_focus(pre, false);
wd_manager.update(pre, true, false);
wd_manager().set_focus(pre, false);
wd_manager().update(pre, true, false);
}
}
@@ -1694,17 +1687,9 @@ namespace detail
#endif
}
bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd)
{
if (evt_code != arg.evt_code)
throw std::runtime_error("Nana.bedrock: invalid event arg.");
return emit(evt_code, wd, static_cast<const ::nana::event_arg&>(arg), ask_update, thrd);
}
bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd)
{
if (wd_manager.available(wd) == false)
if (wd_manager().available(wd) == false)
return false;
basic_window* prev_event_wd;
@@ -1721,8 +1706,8 @@ namespace detail
_m_emit_core(evt_code, wd, false, arg);
if (ask_update)
wd_manager.do_lazy_refresh(wd, false);
else if (wd_manager.available(wd))
wd_manager().do_lazy_refresh(wd, false);
else if (wd_manager().available(wd))
wd->other.upd_state = basic_window::update_state::none;
if (thrd) thrd->event_window = prev_event_wd;
@@ -1731,7 +1716,7 @@ namespace detail
bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd)
{
if (bedrock_object.wd_manager.available(wd) == false)
if (bedrock_object.wd_manager().available(wd) == false)
return false;
core_window_t* prev_event_wd;
@@ -1856,7 +1841,7 @@ namespace detail
thrd = get_thread_context(wd->thread_id);
HCURSOR rev_handle = ::LoadCursor(nullptr, IDC_ARROW);
if (!wd_manager.available(wd))
if (!wd_manager().available(wd))
{
::ShowCursor(FALSE);
::SetCursor(rev_handle);
@@ -1877,7 +1862,7 @@ namespace detail
}
native_interface::calc_window_point(native_handle, pos);
auto rev_wd = wd_manager.find_window(native_handle, pos.x, pos.y);
auto rev_wd = wd_manager().find_window(native_handle, pos.x, pos.y);
if (rev_wd)
{
set_cursor(rev_wd, rev_wd->predef_cursor, thrd);

View File

@@ -8,12 +8,12 @@
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/detail/window_manager.cpp
* @author: Jinhao
* @contributors: Katsuhisa Yuasa
*/
#include <nana/config.hpp>
#include <nana/gui/detail/bedrock.hpp>
#include <nana/gui/detail/events_operation.hpp>
#include <nana/gui/detail/handle_manager.hpp>
#include <nana/gui/detail/window_manager.hpp>
#include <nana/gui/detail/native_window_interface.hpp>
@@ -33,7 +33,7 @@ namespace detail
{
void operator()(basic_window* wd) const
{
bedrock::instance().evt_operation.umake(reinterpret_cast<window>(wd));
bedrock::instance().evt_operation().umake(reinterpret_cast<window>(wd));
delete wd;
}
};
@@ -788,12 +788,6 @@ namespace detail
false);
}
::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_notifier->widget_ptr() : nullptr);
}
std::vector<window_manager::core_window_t*> window_manager::get_children(core_window_t* wd) const
{
std::lock_guard<decltype(mutex_)> lock(mutex_);

View File

@@ -22,7 +22,7 @@ namespace nana
{
namespace
{
using core_window_t = detail::bedrock::core_window_t;
using core_window_t = detail::basic_window;
inline detail::drawer& get_drawer(window wd)
{

View File

@@ -241,11 +241,15 @@ namespace nana
}
#endif
typedef ::nana::detail::bedrock bedrock;
//class notifier
notifier::notifier(window wd)
: impl_(new implement)
{
impl_->handle = wd;
impl_->native_handle = API::root(wd);
if (!impl_->native_handle)
throw std::invalid_argument("Invalid window handle");
impl_->ani_timer.elapse([this]
{
#if defined(NANA_WINDOWS)
@@ -257,9 +261,6 @@ namespace nana
#endif
});
auto & brock = bedrock::instance();
impl_->handle = wd;
impl_->native_handle = brock.root(reinterpret_cast<bedrock::core_window_t*>(wd));
impl_->evt_destroy = API::events(wd).destroy([this]
{
close();

View File

@@ -1074,7 +1074,6 @@ namespace nana
}
block_px = lowest;
if (blocks > min_count)
rest_px -= (lowest-level_px) * (blocks - min_count);
@@ -1141,7 +1140,6 @@ namespace nana
void collocate(window wd) override
{
if (!field || !(visible && display))
return;
@@ -1797,14 +1795,16 @@ namespace nana
if (arg.button != ::nana::mouse::left_button)
return;
bool is_vert = _m_is_vert(dir_);
API::capture_window(this->handle(), true);
auto basepos = API::cursor_position();
base_pos_.x = (_m_is_vert(dir_) ? basepos.y : basepos.x);
base_pos_.x = (is_vert ? basepos.y : basepos.x);
basepos = this->pos();
base_pos_.y = (_m_is_vert(dir_) ? basepos.y : basepos.x);
base_pos_.y = (is_vert ? basepos.y : basepos.x);
base_px_ = (_m_is_vert(dir_) ? pane_dv_->field_area.height : pane_dv_->field_area.width);
base_px_ = (is_vert ? pane_dv_->field_area.height : pane_dv_->field_area.width);
});
this->events().mouse_up([this]
@@ -1855,6 +1855,8 @@ namespace nana
else
px -= static_cast<unsigned>(delta);
break;
default:
break;
}
auto dock_px = (_m_is_vert(dir_) ? dock_dv_->field_area.height : dock_dv_->field_area.width);
@@ -1880,21 +1882,17 @@ namespace nana
};
public:
div_dock(std::string && name, implement* impl)
: division(kind::dock, std::move(name)), impl_(impl)
{}
division* front() const
{
auto i = children.cbegin();
for (auto i = children.cbegin(); i != children.cend(); ++i)
{
if (i->get()->display)
return i->get();
}
return nullptr;
}
@@ -1912,8 +1910,6 @@ namespace nana
if (!child->display)
continue;
auto child_dv = dynamic_cast<div_dockpane*>(child.get());
const auto is_vert = _m_is_vert(child->dir);
if (is_first)
{
@@ -1930,16 +1926,13 @@ namespace nana
prev_attr = is_vert;
}
if (0 == vert_count)
++vert_count;
vert_count = 1;
if (0 == horz_count)
++horz_count;
horz_count = 1;
//room indicates the size without splitters
::nana::size room(area.width - splitter_px * (horz_count - 1), area.height - splitter_px * (vert_count - 1));
//double auto_horz_w = double(area.width - splitter_px * (horz_count - 1))/ horz_count;
//double auto_vert_w = double(area.height - splitter_px * (vert_count - 1)) / vert_count;
double left = area.x;
double right = area.right();
double top = area.y;
@@ -2049,7 +2042,6 @@ namespace nana
if (split_range_begin > -0.5)
split->range(static_cast<int>(split_range_begin), static_cast<int>(split_range_end));
if (is_vert)
{
room.height -= child_r.height;

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,7 @@
#include <nana/gui/state_cursor.hpp>
#include <nana/gui/detail/bedrock.hpp>
#include <nana/gui/detail/basic_window.hpp>
#include <nana/gui/detail/window_manager.hpp>
namespace nana
{
@@ -20,7 +21,7 @@ namespace nana
{
auto & brock = detail::bedrock::instance();
auto wd = reinterpret_cast<detail::basic_window*>(handle);
if (brock.wd_manager.available(wd))
if (brock.wd_manager().available(wd))
brock.define_state_cursor(wd, cur, nullptr);
else
handle_ = nullptr;
@@ -40,7 +41,7 @@ namespace nana
{
auto & brock = detail::bedrock::instance();
auto wd = reinterpret_cast<detail::basic_window*>(handle_);
if (brock.wd_manager.available(wd))
if (brock.wd_manager().available(wd))
brock.undefine_state_cursor(wd, nullptr);
}
handle_ = rhs.handle_;
@@ -55,7 +56,7 @@ namespace nana
{
auto & brock = detail::bedrock::instance();
auto wd = reinterpret_cast<detail::basic_window*>(handle_);
if (brock.wd_manager.available(wd))
if (brock.wd_manager().available(wd))
brock.undefine_state_cursor(wd, nullptr);
}
}

View File

@@ -297,7 +297,7 @@ namespace nana
return *this;
}
iresolver::iresolver(const std::vector<cell>& cl)
: cells_(cl)
{}
@@ -317,7 +317,7 @@ namespace nana
//end class iresolver/oresolver
/// Essence of the columns Header
class es_header
class es_header
{
public:
@@ -339,10 +339,10 @@ namespace nana
export_options::columns_indexs all_headers(bool only_visibles) const
{
export_options::columns_indexs idx;
export_options::columns_indexs idx;
for(const auto &header : cont())
{
if(header.visible || !only_visibles)
if(header.visible || !only_visibles)
idx.push_back(header.index);
}
return idx;
@@ -350,13 +350,13 @@ namespace nana
nana::string to_string(const export_options& exp_opt) const
{
nana::string head_str;
nana::string head_str;
bool first{true};
for( size_type idx{}; idx<exp_opt.columns_order.size(); ++idx)
{
if(first)
first=false;
else
else
head_str += exp_opt.sep;
head_str += column_ref(exp_opt.columns_order[idx]).text;
@@ -668,7 +668,7 @@ namespace nana
category_t(nana::string str)
:text(std::move(str))
{}
bool selected() const
{
for (auto & m : items)
@@ -723,7 +723,7 @@ namespace nana
return nullptr;
}
nana::string to_string(const export_options& exp_opt) const;
/// each sort() ivalidate any existing reference from display position to absolute item, that is after sort() display offset point to different items
void sort()
{
@@ -872,7 +872,7 @@ namespace nana
list_.back().key_ptr = ptr;
return &list_.back();
}
/// add a new cat created at "pos" and return a ref to it
/// add a new cat created at "pos" and return a ref to it
category_t* create_cat(std::size_t pos, nana::string&& text)
{
return &(*list_.emplace(this->get(pos), std::move(text)));
@@ -917,7 +917,7 @@ namespace nana
for (size_type i=0; i<catobj.sorted.size();++i)
if (pos==catobj.sorted[i])
return i;
return npos ;
}
@@ -966,7 +966,7 @@ namespace nana
index_pair advance(index_pair from, size_type offset) // <------------- index
{
index_pair dpos{npos, npos};
if(from.cat >= size_categ() || (from.item != npos && from.item >= size_item(from.cat)))
if(from.cat >= size_categ() || (from.item != npos && from.item >= size_item(from.cat)))
return dpos;
dpos = from;
@@ -1293,7 +1293,7 @@ namespace nana
for(auto & cat : list_)
{
id.item = 0;
for(auto & m : cat.items)
for(auto & m : cat.items)
{
if(m.flags.selected)
vec.push_back(id); // absolute positions, no relative to display
@@ -1302,14 +1302,14 @@ namespace nana
++id.cat;
}
}
index_pair find_first_selected()
{
index_pair id;
for(auto & cat : list_)
{
id.item = 0;
for(auto & m : cat.items)
for(auto & m : cat.items)
{
if(m.flags.selected)
return id; // absolute positions, no relative to display
@@ -1659,7 +1659,7 @@ namespace nana
///Translate relative position (position in display) into absolute position (original data order)
size_type absolute(const index_pair& display_pos) const
{
if(sorted_index_ == npos || display_pos.item == npos)
if(sorted_index_ == npos || display_pos.item == npos)
return display_pos.item ;
auto & catobj = *get(display_pos.cat);
@@ -1674,11 +1674,11 @@ namespace nana
auto item_pos = absolute(display_pos);
return {item_pos != npos ? display_pos.cat : npos, item_pos};
}
///Translate absolute position (original data order) into relative position (position in display)
size_type relative(const index_pair& pos) const
{
if (sorted_index_ == npos)
if (sorted_index_ == npos)
return pos.item ;
auto& catobj = *get(pos.cat);
@@ -1686,7 +1686,7 @@ namespace nana
for (size_type i=0; i<catobj.sorted.size();++i)
if (pos.item == catobj.sorted[i])
return i;
if (catobj.items.empty() && (pos == index_pair{ 0, 0 }))
return 0;
@@ -1698,7 +1698,7 @@ namespace nana
auto item_pos = relative(pos);
return {(item_pos != npos ? pos.cat : npos), item_pos};
}
/// all arg are relative to display order, or all are absolute, but not mixed
bool forward(index_pair from, size_type offs, index_pair& item) const
{
@@ -1781,7 +1781,7 @@ namespace nana
}
return false;
}
/// categories iterator
container::iterator get(size_type pos)
{
@@ -1792,7 +1792,7 @@ namespace nana
std::advance(i, pos);
return i;
}
container::const_iterator get(size_type pos) const
{
if (pos >= list_.size())
@@ -1841,12 +1841,6 @@ namespace nana
::nana::listbox::export_options def_exp_options;
::nana::listbox::export_options& def_export_options()
{
return def_exp_options;
}
es_header header;
es_lister lister; // we have at least one emty cat. the #0
@@ -1925,7 +1919,7 @@ namespace nana
scroll_y_dpl_refresh() ;
}
/// directly set a tested relative display pos
/// directly set a tested relative display pos
void set_scroll_y_dpl(const index_pair& pos_dpl)
{
scroll.offset_y_dpl = pos_dpl;
@@ -1950,7 +1944,7 @@ namespace nana
{
if( dpl_pos.cat < scroll.offset_y_dpl.cat // in prevoious cat ---------------- up ----> we need to move
|| ((dpl_pos.cat == scroll.offset_y_dpl.cat) && ( scroll.offset_y_dpl.item != npos) // is our cat, where we are an item
&& (dpl_pos.item == npos || dpl_pos.item < scroll.offset_y_dpl.item)))
&& (dpl_pos.item == npos || dpl_pos.item < scroll.offset_y_dpl.item)))
// problem!!!!!!
{
if(lister.expand(dpl_pos.cat) == false)
@@ -1960,7 +1954,7 @@ namespace nana
else
lister.expand(dpl_pos.cat, true);
}
set_scroll_y_dpl(dpl_pos); // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs
set_scroll_y_dpl(dpl_pos); // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs
}
else
{
@@ -1969,7 +1963,7 @@ namespace nana
if(numbers > off) return;
index_pair n_off = lister.advance(scroll.offset_y_dpl, (off - numbers) + 1);
if(n_off.cat != npos) // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs
if(n_off.cat != npos) // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs
set_scroll_y_dpl(n_off);
}
@@ -1978,7 +1972,7 @@ namespace nana
void trace_item_abs( index_pair abs_pos )
{
if(abs_pos.item == npos && abs_pos.cat == scroll.offset_y_abs.cat
if(abs_pos.item == npos && abs_pos.cat == scroll.offset_y_abs.cat
&& scroll.offset_y_abs.item == npos ) // if item==off y and is a cat
return;
@@ -2020,7 +2014,7 @@ namespace nana
scroll.v.value(off);
}
}
void adjust_scroll_life() // at end call adjust_scroll_value();
{
internal_scope_guard lock;
@@ -2252,7 +2246,7 @@ namespace nana
if (target == scroll.offset_y_dpl)
return false;
set_scroll_y_dpl ( target );
return true;
}
@@ -2465,10 +2459,10 @@ namespace nana
if (good(next_selected_dpl))
{
if (unselect_previous && !single_selection_ )
if (unselect_previous && !single_selection_ )
select_for_all(false);
/// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected
/// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected
item_proxy::from_display(ess_, next_selected_dpl).select(true);
if (trace_selected)
@@ -2482,7 +2476,7 @@ namespace nana
nana::string es_lister::to_string(const export_options& exp_opt) const
{
nana::string list_str;
nana::string list_str;
bool first{true};
for(auto & cat: cat_container())
{
@@ -2509,8 +2503,7 @@ namespace nana
if (it.selected() != sel)
it.select(sel);
}
last_selected_abs = last_selected_dpl = index_pair {cat, npos};
last_selected_abs = last_selected_dpl = index_pair{cat, npos};
}
class drawer_header_impl
@@ -2586,9 +2579,9 @@ namespace nana
const auto& item = essence_->header.column(item_spliter_);
//Resize the item specified by item_spliter_.
auto new_w = orig_item_width_ - (ref_xpos_ - pos.x);
if(static_cast<int>(item.pixels) != new_w)
if(item.pixels != new_w)
{
essence_->header.item_width(item_spliter_, (new_w < static_cast<int>(essence_->suspension_width + 20) ? essence_->suspension_width + 20 : new_w));
essence_->header.item_width(item_spliter_, (new_w < (essence_->suspension_width + 20) ? essence_->suspension_width + 20 : new_w));
new_w = essence_->header.pixels();
if(new_w < (rect.width + essence_->scroll.offset_x))
essence_->scroll.offset_x = (new_w > rect.width ? new_w - rect.width : 0);
@@ -2749,8 +2742,8 @@ namespace nana
unsigned header_w = essence_->header.pixels();
essence_->graph->set_color(bgcolor);
if(header_w - essence_->scroll.offset_x < rect.width)
essence_->graph->rectangle(rectangle{ point(rect.x + static_cast<int>(header_w)-essence_->scroll.offset_x, rect.y),
size(static_cast<int>(rect.width) + essence_->scroll.offset_x - static_cast<int>(header_w), rect.height) },
essence_->graph->rectangle(rectangle{ point(rect.x + static_cast<int>(header_w)-essence_->scroll.offset_x, rect.y),
size(static_cast<int>(rect.width) + essence_->scroll.offset_x - static_cast<int>(header_w), rect.height) },
true);
es_lister & lister = essence_->lister;
@@ -2801,7 +2794,7 @@ namespace nana
_m_draw_item(*i_categ, item_index, x, y, txtoff, header_w, rect, subitems, bgcolor,fgcolor, state);
y += essence_->item_size;
}
++i_categ;
++idx.cat;
}
@@ -2857,7 +2850,7 @@ namespace nana
facade<element::arrow> arrow("double");
arrow.direction(categ.expand ? ::nana::direction::north : ::nana::direction::south);
arrow.draw( *graph, {}, txt_color,
arrow.draw( *graph, {}, txt_color,
{ x + 5, y + static_cast<int>(essence_->item_size - 16) / 2, 16, 16 },
element_state::normal);
@@ -2890,7 +2883,7 @@ namespace nana
{
auto & item = cat.items[item_pos.item];
if (item.flags.selected) // fetch the "def" colors
if (item.flags.selected) // fetch the "def" colors
bgcolor = essence_->scheme_ptr->item_selected;
else if (!item.bgcolor.invisible())
bgcolor = item.bgcolor;
@@ -3043,7 +3036,7 @@ namespace nana
//The text is painted over the next subitem // here beging the ...
int xpos = item_xpos + static_cast<int>(header.pixels) - static_cast<int>(essence_->suspension_width);
graph->set_color(it_bgcolor); // litter rect with the item bg end ...
graph->set_color(it_bgcolor); // litter rect with the item bg end ...
graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true);
graph->string(point{ xpos, y + 2 }, STR("..."));
@@ -3315,7 +3308,7 @@ namespace nana
if (arg.shift)
lister.select_display_range(lister.last_selected_abs , item_pos, sel);
else if (arg.ctrl)
sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();
sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected();
else
lister.select_for_all(false); //cancel all selections
}
@@ -3325,7 +3318,7 @@ namespace nana
if(item_ptr)
{
item_ptr->flags.selected = sel;
index_pair last_selected(item_pos.cat, lister.absolute(item_pos));
index_pair last_selected(item_pos.cat, lister.absolute(item_pos));
arg_listbox arg{item_proxy{essence_, last_selected}, sel};
lister.wd_ptr()->events().selected.emit(arg);
@@ -3334,7 +3327,7 @@ namespace nana
{
lister.cancel_others_if_single_enabled(true, last_selected);
essence_->lister.last_selected_abs = last_selected;
}
else if (essence_->lister.last_selected_abs == last_selected)
essence_->lister.last_selected_abs.set_both(npos);
@@ -3424,7 +3417,7 @@ namespace nana
void trigger::dbl_click(graph_reference graph, const arg_mouse&)
{
if (essence_->pointer_where.first == essence_t::parts::header)
if (cursor::size_we == essence_->lister.wd_ptr()->cursor())
if (cursor::size_we == essence_->lister.wd_ptr()->cursor())
{
if (essence(). auto_width(drawer_header_->item_spliter() )) // ? in order
essence().update();
@@ -3471,7 +3464,7 @@ namespace nana
bool up = false;
if (essence_->lister.size_categ()==1 && essence_->lister.size_item(0)==0)
return ;
return ;
switch(arg.key)
{
@@ -3494,7 +3487,7 @@ namespace nana
case keyboard::os_pagedown:
{
auto& scrl = essence_->scroll.v;
if (! scrl.make_page_scroll(!up))
if (! scrl.make_page_scroll(!up))
return;
essence_->lister.select_for_all(false);
@@ -3504,7 +3497,7 @@ namespace nana
if (idx.is_item())
item_proxy::from_display(essence_, idx).select(true);
else
else
if(!essence_->lister.single_selection())
essence_->lister.categ_selected(idx.cat, true);
@@ -3519,7 +3512,7 @@ namespace nana
index_pair frst{essence_->lister.first()};
if (frst.is_item())
item_proxy::from_display(essence_, frst).select(true);
else
else
if(!essence_->lister.single_selection())
essence_->lister.categ_selected(frst.cat, true);
@@ -3545,13 +3538,13 @@ namespace nana
{
case keyboard::copy:
{
export_options exp_opt {essence_->def_export_options()};
export_options exp_opt {essence_->def_exp_options};
exp_opt.columns_order = essence_->header.all_headers(true);
exp_opt.only_selected_items = true;
::nana::system::dataexch().set(essence_->to_string(exp_opt));
return;
}
case keyboard::select_all :
case keyboard::select_all :
essence_->lister.select_for_all(true);
refresh(graph);
API::lazy_refresh();
@@ -3581,7 +3574,7 @@ namespace nana
}
/// the main porpose of this it to make obvious that item_proxy operate with absolute positions, and dont get moved during sort()
item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative)
item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative)
{
return item_proxy{ess, ess->lister.absolute_pair(relative)};
}
@@ -3619,7 +3612,7 @@ namespace nana
return cat_->items.at(pos_.item).flags.checked;
}
/// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected
/// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected
item_proxy & item_proxy::select(bool s)
{
auto & m = cat_->items.at(pos_.item); // a ref to the real item // what is pos is a cat?
@@ -3638,7 +3631,7 @@ namespace nana
ess_->lister.last_selected_abs.set_both(npos);
ess_->update();
ess_->update();
return *this;
}
@@ -3719,7 +3712,7 @@ namespace nana
bool item_proxy::operator==(const char * s) const
{
return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s)));
}
bool item_proxy::operator==(const wchar_t * s) const
@@ -4257,8 +4250,8 @@ namespace nana
// from current display position
// move to the cat self if not in first cat
// move to first item ?? if in first cat
ess.scroll_y_abs(ess.scroll_y_abs());
ess.scroll_y_abs(ess.scroll_y_abs());
ess.update();
}
@@ -4271,8 +4264,8 @@ namespace nana
// from current display position
// move to the cat self if not in first cat
// move to first item ?? if in first cat
ess.scroll_y_abs(ess.scroll_y_abs());
ess.scroll_y_abs(ess.scroll_y_abs());
ess.update();
}
@@ -4300,7 +4293,7 @@ namespace nana
{
auto & ess = _m_ess();
ess.lister.erase();
ess.scroll_y_abs(index_pair());
ess.scroll_y_abs(index_pair());
ess.update();
}
@@ -4432,7 +4425,7 @@ namespace nana
listbox::export_options& listbox::def_export_options()
{
return _m_ess().def_export_options();
return _m_ess().def_exp_options;
}
drawerbase::listbox::essence_t & listbox::_m_ess() const

View File

@@ -1222,12 +1222,11 @@ namespace nana{ namespace widgets
auto ki = kwptr->schemes.find(ds.scheme);
if (ki != kwptr->schemes.end() && ki->second)
{
schemes_.emplace(ds.scheme, ki->second);
entities.emplace_back();
auto & last = entities.back();
last.begin = text.data() + pos;
last.end = last.begin + ds.text.size();
last.scheme = ki->second.get();
entities.emplace_back();
auto & last = entities.back();
last.begin = text.data() + pos;
last.end = last.begin + ds.text.size();
last.scheme = ki->second.get();
}
}
}
@@ -1259,7 +1258,6 @@ namespace nana{ namespace widgets
}
private:
std::vector<entity> entities_;
std::map<std::string, std::shared_ptr<keyword_scheme>> schemes_;
};
//class text_editor

View File

@@ -1,6 +1,6 @@
/*
* Nana GUI Library Definition
* 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
@@ -12,9 +12,17 @@
*/
#include <nana/gui/wvl.hpp>
#include <nana/gui/detail/bedrock.hpp>
namespace nana
{
namespace detail
{
void form_loader_private::insert_form(::nana::widget* p)
{
bedrock::instance().manage_form_loader(reinterpret_cast<basic_window*>(p->handle()), true);
}
}
void exec()
{
detail::bedrock::instance().pump_event(nullptr, false);