From b827e0aa82bce27d5353dd683e1c4877a746337f Mon Sep 17 00:00:00 2001 From: cnjinhao Date: Fri, 2 Jan 2015 13:25:46 +0800 Subject: [PATCH] multiple display monitors support Added a new class screen --- build/codeblocks/nana.cbp | 1 + build/codeblocks/nana.layout | 140 +++++++++--------- build/vc2013/nana.v12.suo | Bin 24576 -> 0 bytes build/vc2013/nana.vcxproj | 1 + build/vc2013/nana.vcxproj.filters | 3 + include/nana/basic_types.hpp | 7 +- .../gui/detail/native_window_interface.hpp | 5 +- include/nana/gui/programming_interface.hpp | 2 - include/nana/gui/wvl.hpp | 4 +- source/basic_types.cpp | 2 +- source/gui/detail/native_window_interface.cpp | 7 +- source/gui/programming_interface.cpp | 12 +- source/gui/tooltip.cpp | 5 +- source/gui/widgets/menu.cpp | 4 +- 14 files changed, 94 insertions(+), 99 deletions(-) delete mode 100644 build/vc2013/nana.v12.suo diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index b2a80a96..973b633f 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -69,6 +69,7 @@ + diff --git a/build/codeblocks/nana.layout b/build/codeblocks/nana.layout index f332844d..f410278c 100644 --- a/build/codeblocks/nana.layout +++ b/build/codeblocks/nana.layout @@ -1,76 +1,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - @@ -81,11 +46,6 @@ - - - - - @@ -101,26 +61,21 @@ - - - - - - - - - - + + + + + @@ -136,6 +91,11 @@ + + + + + @@ -151,4 +111,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc2013/nana.v12.suo b/build/vc2013/nana.v12.suo deleted file mode 100644 index 55c501acb1a18747293b1bf747fff8e22b81c8e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 zcmeHPd2Ce28J`U$!6k&7P?At{pX;pGW)BDfY~u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xX~iE+EA{$fdhFg4 z_nzKA`1C^M2h^R+*p0XuW6mGHXYPq0gx3+W>vV3~j9Nch8`|~xDQ8B627hPl)pvK% zEumZ2jH^+}&#af*SCpF2_i-hyCjx8N{52)N>CGhh~u4>8OC=zfpn|BU>Boct#y zw&-2{XYHQIs@dMnMgAvzhJ5AM-jrDLk^jxoXm4U;m7lZA|4M$&cl-q0ZijfcfD(rt}0(Ps<|K#z%zLNUO{%gNH Uc-Q + diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters index 5d2bb2ae..c4738ee4 100644 --- a/build/vc2013/nana.vcxproj.filters +++ b/build/vc2013/nana.vcxproj.filters @@ -294,5 +294,8 @@ Source Files\nana\gui\detail + + Source Files\nana\gui + \ No newline at end of file diff --git a/include/nana/basic_types.hpp b/include/nana/basic_types.hpp index 074da654..177baf4a 100644 --- a/include/nana/basic_types.hpp +++ b/include/nana/basic_types.hpp @@ -378,8 +378,9 @@ namespace nana struct size { + using value_type = unsigned; size(); - size(unsigned width, unsigned height); + size(value_type width, value_type height); size(const rectangle&); size& operator=(const rectangle&); @@ -390,8 +391,8 @@ namespace nana bool operator!=(const size& rhs) const; size operator+(const size&) const; - unsigned width; - unsigned height; + value_type width; + value_type height; }; struct rectangle diff --git a/include/nana/gui/detail/native_window_interface.hpp b/include/nana/gui/detail/native_window_interface.hpp index 6dc86b68..39cd7c49 100644 --- a/include/nana/gui/detail/native_window_interface.hpp +++ b/include/nana/gui/detail/native_window_interface.hpp @@ -1,6 +1,7 @@ /* * Platform Implementation - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Nana C++ Library(http://www.nanapro.org) + * 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 @@ -33,7 +34,7 @@ namespace detail unsigned extra_height; //extra border size, it is useful in Windows, ignore in X11 always 0 }; - static nana::size screen_size(); + static nana::size primary_monitor_size(); static rectangle screen_area_from_point(const point&); static window_result create_window(native_window_type, bool nested, const rectangle&, const appearance&); static native_window_type create_child_window(native_window_type, const rectangle&); diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index b55e4c40..9bcf2842 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -87,8 +87,6 @@ namespace API bool register_shortkey(window, unsigned long); void unregister_shortkey(window); - nana::size screen_size(); - rectangle screen_area_from_point(const point&); nana::point cursor_position(); rectangle make_center(unsigned width, unsigned height); ///< Retrieves a rectangle which is in the center of the screen. rectangle make_center(window, unsigned width, unsigned height); ///< Retrieves a rectangle which is in the center of the window diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index a69f350a..e9855208 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -1,6 +1,7 @@ /* * Nana GUI Library Definition - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Nana C++ Library(http://www.nanapro.org) + * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -15,6 +16,7 @@ #define NANA_GUI_WVL_HPP #include "programming_interface.hpp" +#include "screen.hpp" #include "widgets/form.hpp" #include "drawing.hpp" #include "msgbox.hpp" diff --git a/source/basic_types.cpp b/source/basic_types.cpp index b2b17a42..c7c5cbd4 100644 --- a/source/basic_types.cpp +++ b/source/basic_types.cpp @@ -323,7 +323,7 @@ namespace nana //struct size size::size():width(0), height(0){} - size::size(unsigned width, unsigned height):width(width), height(height){} + size::size(value_type width, value_type height) : width(width), height(height){} size::size(const rectangle& r) : width(r.width), height(r.height) {} diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 0e7a46bf..2a20fd78 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -146,7 +146,7 @@ namespace nana{ #endif //struct native_interface - nana::size native_interface::screen_size() + nana::size native_interface::primary_monitor_size() { #if defined(NANA_WINDOWS) return nana::size(::GetSystemMetrics(SM_CXSCREEN), ::GetSystemMetrics(SM_CYSCREEN)); @@ -176,13 +176,10 @@ namespace nana{ mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top); } } -#elif defined(NANA_X11) #endif - return screen_size(); + return primary_monitor_size(); } - - //platform-dependent native_interface::window_result native_interface::create_window(native_window_type owner, bool nested, const rectangle& r, const appearance& app) { diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 797df632..286aafc1 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -307,16 +307,6 @@ namespace API restrict::window_manager.unregister_shortkey(reinterpret_cast(wd), false); } - nana::size screen_size() - { - return restrict::interface_type::screen_size(); - } - - rectangle screen_area_from_point(const point& pos) - { - return restrict::interface_type::screen_area_from_point(pos); - } - nana::point cursor_position() { return restrict::interface_type::cursor_position(); @@ -324,7 +314,7 @@ namespace API nana::rectangle make_center(unsigned width, unsigned height) { - nana::size screen = restrict::interface_type::screen_size(); + nana::size screen = restrict::interface_type::primary_monitor_size(); nana::rectangle result( width > screen.width? 0: (screen.width - width)>>1, height > screen.height? 0: (screen.height - height)>> 1, diff --git a/source/gui/tooltip.cpp b/source/gui/tooltip.cpp index 47ff28c3..02eae44d 100644 --- a/source/gui/tooltip.cpp +++ b/source/gui/tooltip.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace nana @@ -33,7 +34,7 @@ namespace nana nana::point pos_by_screen(nana::point pos, const nana::size& sz, bool overlap_allowed) { - auto scr_area = API::screen_area_from_point(pos); + auto scr_area = screen::from_point(pos)->area(); if (pos.x + sz.width > scr_area.x + scr_area.width) pos.x = static_cast(scr_area.x + scr_area.width - sz.width); if (pos.x < scr_area.x) @@ -76,7 +77,7 @@ namespace nana void tooltip_text(const nana::string& text) override { label_.caption(text); - auto text_s = label_.measure(API::screen_size().width * 2 / 3); + auto text_s = label_.measure(screen::from_window(label_)->area().width * 2 / 3); this->size(nana::size{ text_s.width + 10, text_s.height + 10 }); label_.move(rectangle{ 5, 5, text_s.width, text_s.height }); diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index ed7b72c5..02dfa28a 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -177,7 +177,7 @@ namespace nana menu_builder() { - root_.max_pixels = API::screen_size().width * 2 / 3; + root_.max_pixels = screen::primary_monitor_size().width * 2 / 3; root_.item_pixels = 24; renderer_ = pat::cloneable(internal_renderer()); } @@ -657,7 +657,7 @@ namespace nana API::calc_screen_point(*widget_, pos); //get the screen coordinates of the widget pos. - auto scr_area = API::screen_area_from_point(detail_.monitor_pos); + auto scr_area = screen::from_point(detail_.monitor_pos)->area(); if(pos.x + size.width > scr_area.x + scr_area.width) pos.x = static_cast(scr_area.x + scr_area.width - size.width);