multiple display monitors support
Added a new class screen
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -307,16 +307,6 @@ namespace API
|
||||
restrict::window_manager.unregister_shortkey(reinterpret_cast<restrict::core_window_t*>(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,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <nana/gui/tooltip.hpp>
|
||||
#include <nana/gui/widgets/label.hpp>
|
||||
#include <nana/gui/timer.hpp>
|
||||
#include <nana/gui/screen.hpp>
|
||||
#include <memory>
|
||||
|
||||
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<int>(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 });
|
||||
|
||||
|
||||
@@ -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<renderer_interface>(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<int>(scr_area.x + scr_area.width - size.width);
|
||||
|
||||
Reference in New Issue
Block a user