diff --git a/source/gui/tooltip.cpp b/source/gui/tooltip.cpp index 45656d01..04e6f258 100644 --- a/source/gui/tooltip.cpp +++ b/source/gui/tooltip.cpp @@ -1,6 +1,7 @@ /* * A Tooltip 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 @@ -35,13 +36,13 @@ namespace nana nana::point pos_by_screen(nana::point pos, const nana::size& sz, bool overlap_allowed) { auto scr_area = screen().from_point(pos).workarea(); - 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 + static_cast(sz.width) > scr_area.right()) + pos.x = scr_area.right() - static_cast(sz.width); if (pos.x < scr_area.x) pos.x = scr_area.x; - if (pos.y + sz.height >= scr_area.y + scr_area.height) - pos.y = static_cast(scr_area.y + scr_area.height - sz.height); + if (pos.y + static_cast(sz.height) >= scr_area.bottom()) + pos.y = scr_area.bottom() - static_cast(sz.height); else if (!overlap_allowed) pos.y += 20; //Add some pixels to avoid overlapping between cursor and tip window. diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index 2b25810b..d8445c0d 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -661,11 +661,11 @@ namespace nana //get the screen coordinates of the widget pos. auto scr_area = screen().from_point(detail_.monitor_pos).workarea(); - if(pos.x + size.width > scr_area.x + scr_area.width) + if(pos.x + static_cast(size.width) > scr_area.right()) pos.x = static_cast(scr_area.x + scr_area.width - size.width); if(pos.x < scr_area.x) pos.x = scr_area.x; - if(pos.y + size.height > scr_area.y + scr_area.height) + if(pos.y + static_cast(size.height) > scr_area.bottom()) pos.y = static_cast(scr_area.y + scr_area.height - size.height); if(pos.y < scr_area.y) pos.y = scr_area.y; diff --git a/source/gui/widgets/menubar.cpp b/source/gui/widgets/menubar.cpp index 3c584a9e..e6d34cb5 100644 --- a/source/gui/widgets/menubar.cpp +++ b/source/gui/widgets/menubar.cpp @@ -1,7 +1,7 @@ /* * A Menubar implementation * Nana C++ Library(http://www.nanapro.org) -* Copyright(C) 2009-2014 Jinhao(cnjinhao@hotmail.com) +* Copyright(C) 2009-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -30,21 +30,21 @@ namespace nana { struct item_type { - item_type(const nana::string& text, unsigned long shortkey) + item_type(const ::nana::string& text, unsigned long shortkey) : text(text), shortkey(shortkey) {} - nana::string text; + ::nana::string text; unsigned long shortkey; - nana::menu menu_obj; - nana::point pos; - nana::size size; + ::nana::menu menu_obj; + ::nana::point pos; + ::nana::size size; }; class trigger::itembase { public: - typedef std::vector container; + using container = std::vector; ~itembase() { @@ -52,7 +52,7 @@ namespace nana delete i; } - void append(const nana::string& text, unsigned long shortkey) + void append(const ::nana::string& text, unsigned long shortkey) { if(shortkey && shortkey < 0x61) shortkey += (0x61 - 0x41); cont_.push_back(new item_type(text, shortkey)); @@ -122,11 +122,13 @@ namespace nana nana::rectangle r(pos, size); graph_.rectangle(r, false, border); + int right = pos.x + static_cast(size.width) - 1; + int bottom = pos.y + static_cast(size.height) - 1; graph_.set_color(corner); graph_.set_pixel(pos.x, pos.y); - graph_.set_pixel(pos.x + size.width - 1, pos.y); - graph_.set_pixel(pos.x, pos.y + size.height - 1); - graph_.set_pixel(pos.x + size.width - 1, pos.y + size.height - 1); + graph_.set_pixel(right, pos.y); + graph_.set_pixel(pos.x, bottom); + graph_.set_pixel(right, bottom); graph_.rectangle(r.pare_off(1), true, body); } @@ -146,9 +148,9 @@ namespace nana delete items_; } - nana::menu* trigger::push_back(const nana::string& text) + nana::menu* trigger::push_back(const ::nana::string& text) { - nana::string::value_type shkey; + ::nana::string::value_type shkey; API::transform_shortkey_text(text, shkey, nullptr); if(shkey) @@ -157,6 +159,7 @@ namespace nana auto i = items_->cont().size(); items_->append(text, shkey); _m_draw(); + API::update_window(*widget_); return items_->get_menu(i); }