Merge branch 'hotfix-1.3' into develop

This commit is contained in:
Jinhao
2016-04-18 15:16:03 +08:00
116 changed files with 2343 additions and 1004 deletions

View File

@@ -1,4 +1,4 @@
/*
/**
* A Bedrock Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
@@ -7,7 +7,8 @@
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/detail/win32/bedrock.cpp
* @file nana/gui/detail/win32/bedrock.cpp
* @brief A Bedrock Implementation
* @contributors: Ariel Vina-Rodriguez
*/
@@ -25,6 +26,8 @@
#include <nana/gui/detail/element_store.hpp>
#include <nana/gui/detail/color_schemes.hpp>
#include <iostream>
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
@@ -232,6 +235,7 @@ namespace detail
if(wd_manager().number_of_core_window())
{
std::string msg = "Nana.GUI detects a memory leaks in window_manager, " + std::to_string(wd_manager().number_of_core_window()) + " window(s) are not uninstalled.";
std::cerr << msg; /// \todo add list of cations of open windows and if aut testin GUI do auto Ok after 2 sec.
::MessageBoxA(0, msg.c_str(), ("Nana C++ Library"), MB_OK);
}
@@ -239,8 +243,8 @@ namespace detail
delete pi_data_;
}
//inc_window
//@brief: increament the number of windows
/// @brief increament the number of windows in the thread id
int bedrock::inc_window(unsigned tid)
{
//impl refers to the object of private_impl, the object is created when bedrock is creating.
@@ -453,6 +457,7 @@ namespace detail
{
(msgbox(modal_window, "An exception during message pumping!").icon(msgbox::icon_information)
<<"An uncaptured non-std exception during message pumping!"
<< "\n in form: " << API::window_caption(modal_window)
).show();
internal_scope_guard lock;
_m_except_handler();
@@ -650,6 +655,14 @@ namespace detail
case nana::detail::messages::tray:
notifications_window_proc(wd, wParam, lParam);
return true;
case nana::detail::messages::affinity_execute:
if (wParam)
{
auto arg = reinterpret_cast<detail::messages::arg_affinity_execute*>(wParam);
if (arg->function_ptr)
(*arg->function_ptr)();
}
break;
default:
break;
}
@@ -772,7 +785,9 @@ 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 & wd_manager = brock.wd_manager();
auto* root_runtime = wd_manager.root_runtime(native_window);
if(root_runtime)
{
@@ -817,7 +832,7 @@ namespace detail
bool take_over = false;
auto mmi = reinterpret_cast<MINMAXINFO*>(lParam);
if(msgwnd->min_track_size.width && msgwnd->min_track_size.height)
if(!msgwnd->min_track_size.empty())
{
mmi->ptMinTrackSize.x = static_cast<LONG>(msgwnd->min_track_size.width + msgwnd->extra_width);
mmi->ptMinTrackSize.y = static_cast<LONG>(msgwnd->min_track_size.height + msgwnd->extra_height);
@@ -878,14 +893,14 @@ namespace detail
break;
pressed_wd = nullptr;
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = 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, arg_focus::reason::mouse_press);
if (killed != msgwnd)
brock.wd_manager().do_lazy_refresh(killed, false);
wd_manager.do_lazy_refresh(killed, false);
}
arg_mouse arg;
@@ -903,7 +918,7 @@ namespace detail
if (pressed_wd_space)
break;
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if ((nullptr == msgwnd) || (pressed_wd && (msgwnd != pressed_wd)))
break;
@@ -924,7 +939,7 @@ namespace detail
{
auto kill_focus = brock.wd_manager().set_focus(new_focus, false, arg_focus::reason::mouse_press);
if (kill_focus != new_focus)
brock.wd_manager().do_lazy_refresh(kill_focus, false);
wd_manager.do_lazy_refresh(kill_focus, false);
}
}
@@ -941,14 +956,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 != 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;
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
wd_manager.do_lazy_refresh(msgwnd, false);
}
}
}
@@ -964,7 +979,7 @@ namespace detail
if (pressed_wd_space)
break;
msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
msgwnd = wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if(nullptr == msgwnd)
break;
@@ -993,7 +1008,7 @@ namespace detail
}
//Do mouse_up, this handle may be closed by click handler.
if(brock.wd_manager().available(msgwnd) && msgwnd->flags.enabled)
if(wd_manager.available(msgwnd) && msgwnd->flags.enabled)
{
arg.evt_code = event_code::mouse_up;
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
@@ -1001,7 +1016,7 @@ namespace detail
if (click_arg.window_handle)
retain->click.emit(click_arg, reinterpret_cast<window>(msgwnd));
if (brock.wd_manager().available(msgwnd))
if (wd_manager.available(msgwnd))
{
arg.evt_code = event_code::mouse_up;
retain->mouse_up.emit(arg, reinterpret_cast<window>(msgwnd));
@@ -1010,7 +1025,7 @@ namespace detail
else if (click_arg.window_handle)
retain->click.emit(click_arg, reinterpret_cast<window>(msgwnd));
brock.wd_manager().do_lazy_refresh(msgwnd, false);
wd_manager.do_lazy_refresh(msgwnd, false);
}
pressed_wd = nullptr;
break;
@@ -1019,8 +1034,8 @@ namespace detail
if (pressed_wd_space)
break;
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 = wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y);
if (wd_manager.available(hovered_wd) && (msgwnd != hovered_wd))
{
brock.event_msleave(hovered_wd);
hovered_wd->flags.action = mouse_action::normal;
@@ -1028,7 +1043,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 = wd_manager.capture_redirect(msgwnd);
if(wd)
msgwnd = wd;
}
@@ -1036,7 +1051,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(wd_manager.capture_window_entered(pmdec.mouse.x, pmdec.mouse.y, prev_captured_inside))
{
event_code evt_code;
if(prev_captured_inside)
@@ -1084,7 +1099,7 @@ namespace detail
track.hwndTrack = native_window;
restrict::track_mouse_event(&track);
}
if (!brock.wd_manager().available(hovered_wd))
if (!wd_manager.available(hovered_wd))
hovered_wd = nullptr;
break;
case WM_MOUSELEAVE:
@@ -1100,7 +1115,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 = 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;
@@ -1110,7 +1125,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);
wd_manager.calc_window_point(evt_wd, mspos);
arg_wheel arg;
arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical);
@@ -1124,14 +1139,14 @@ 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);
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);
draw_invoker(&drawer::mouse_wheel, scrolled_wd, arg, &context);
brock.wd_manager().do_lazy_refresh(scrolled_wd, false);
wd_manager.do_lazy_refresh(scrolled_wd, false);
}
}
else
@@ -1149,7 +1164,7 @@ namespace detail
POINT pos;
::DragQueryPoint(drop, &pos);
msgwnd = brock.wd_manager().find_window(native_window, pos.x, pos.y);
msgwnd = wd_manager.find_window(native_window, pos.x, pos.y);
if(msgwnd)
{
arg_dropfiles dropfiles;
@@ -1180,11 +1195,11 @@ namespace detail
dropfiles.pos.x = pos.x;
dropfiles.pos.y = pos.y;
brock.wd_manager().calc_window_point(msgwnd, dropfiles.pos);
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));
brock.wd_manager().do_lazy_refresh(msgwnd, false);
wd_manager.do_lazy_refresh(msgwnd, false);
}
}
@@ -1272,7 +1287,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);
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));
@@ -1298,7 +1313,7 @@ namespace detail
case WM_SYSCHAR:
def_window_proc = true;
brock.shortkey_occurred(true);
msgwnd = brock.wd_manager().find_shortkey(native_window, static_cast<unsigned long>(wParam));
msgwnd = wd_manager.find_shortkey(native_window, static_cast<unsigned long>(wParam));
if(msgwnd)
{
arg_keyboard arg;
@@ -1345,7 +1360,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, arg_focus::reason::general);
wd_manager.set_focus(msgwnd, false, arg_focus::reason::general);
arg_keyboard arg;
arg.evt_code = event_code::key_release;
@@ -1375,9 +1390,7 @@ namespace detail
if(msgwnd)
{
auto & wd_manager = brock.wd_manager();
if ((VK_TAB == wParam) && (!msgwnd->visible || (false == (msgwnd->flags.tab & tab_type::eating)))) //Tab
if((VK_TAB == wParam) && (!msgwnd->visible || (false == (msgwnd->flags.tab & tab_type::eating)))) //Tab
{
bool is_forward = (::GetKeyState(VK_SHIFT) >= 0);
@@ -1498,7 +1511,7 @@ namespace detail
arg.window_handle = reinterpret_cast<window>(msgwnd);
draw_invoker(&drawer::mouse_up, msgwnd, arg, &context);
brock.wd_manager().do_lazy_refresh(msgwnd, false);
wd_manager.do_lazy_refresh(msgwnd, false);
}
pressed_wd_space = nullptr;
}
@@ -1544,12 +1557,12 @@ namespace detail
brock.erase_menu(false);
brock.delay_restore(3); //Restores if delay_restore not decleared
}
brock.wd_manager().destroy(msgwnd);
wd_manager.destroy(msgwnd);
nana::detail::platform_spec::instance().release_window_icon(msgwnd->root);
break;
case WM_NCDESTROY:
brock.manage_form_loader(msgwnd, false);
brock.wd_manager().destroy_handle(msgwnd);
wd_manager.destroy_handle(msgwnd);
if(--context.window_count <= 0)
{
@@ -1561,7 +1574,7 @@ namespace detail
def_window_proc = true;
}
root_runtime = brock.wd_manager().root_runtime(native_window);
root_runtime = wd_manager.root_runtime(native_window);
if(root_runtime)
{
root_runtime->condition.pressed = pressed_wd;