diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index 1877dd51..a2fb04bb 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -178,6 +178,16 @@ namespace nana struct implementation; std::unique_ptr impl_; }; + + class draw + { + public: + draw(graphics& graph); + + void corner(const rectangle& r, unsigned pixels); + private: + graphics& graph_; + }; }//end namespace paint } //end namespace nana #endif diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index bae7ab51..05c428ce 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -114,19 +114,15 @@ namespace nana void item(graph_reference graph, const nana::rectangle& r, const attr& at) { + if (!at.enabled) + return; + if(at.item_state == state::active) { graph.rectangle(r, false, static_cast(0xa8d8eb)); - nana::point points[4] = { - nana::point(r.x, r.y), - nana::point(r.x + r.width - 1, r.y), - nana::point(r.x, r.y + r.height - 1), - nana::point(r.x + r.width - 1, r.y + r.height - 1) - }; graph.palette(false, static_cast(0xc0ddfc)); - for(int i = 0; i < 4; ++i) - graph.set_pixel(points[i].x, points[i].y); + paint::draw(graph).corner(r, 1); if(at.enabled) graph.gradual_rectangle(nana::rectangle(r).pare_off(1), static_cast(0xE8F0F4), static_cast(0xDBECF4), true); @@ -480,7 +476,7 @@ namespace nana --pos; } - if(! menu_->items.at(pos).flags.splitter) + if(! menu_->items.at(pos).flags.splitter && menu_->items.at(pos).flags.enabled) break; } @@ -786,9 +782,8 @@ namespace nana { if (event_code::mouse_down == arg.evt_code) _m_open_sub(0); //Try to open submenu immediately - else if (event_code::mouse_up == arg.evt_code) - if (arg.button == ::nana::mouse::left_button) - pick(); + else if ((event_code::mouse_up == arg.evt_code) && (mouse::left_button == arg.button)) + pick(); }; events.mouse_down.connect_unignorable(fn); @@ -886,48 +881,45 @@ namespace nana return; menu_item_type & item = menu->items.at(active); - if (item.flags.splitter == false && item.sub_menu == nullptr) + + if ((!item.flags.enabled) || item.flags.splitter || item.sub_menu) + return; + + if (checks::highlight == item.style) { - //There is a situation that menu will not call functor if the item style is check_option - //and it is checked before clicking. - bool call_functor = true; - - if (checks::highlight == item.style) + item.flags.checked = !item.flags.checked; + } + else if (checks::option == item.style) + { + //Forward Looks for a splitter + auto pos = active; + while (pos) { - item.flags.checked = !item.flags.checked; - } - else if (checks::option == item.style) - { - //Forward Looks for a splitter - auto pos = active; - while (pos) - { - if (menu->items.at(--pos).flags.splitter) - break; - } - - for (; pos < menu->items.size(); ++pos) - { - menu_item_type & im = menu->items.at(pos); - if (im.flags.splitter) break; - - if ((checks::option == im.style) && im.flags.checked) - im.flags.checked = false; - } - - item.flags.checked = true; + if (menu->items.at(--pos).flags.splitter) + break; } - this->_m_close_all(); //means deleting this; - //The deleting operation has moved here, because item.functor.operator()(ip) - //may create a window, which make a killing focus for menu window, if so the close_all - //operation preformences after item.functor.operator()(ip), that would be deleting this object twice! - - if (call_functor && item.flags.enabled && item.functor) + for (; pos < menu->items.size(); ++pos) { - item_type::item_proxy ip(active, item); - item.functor.operator()(ip); + menu_item_type & im = menu->items.at(pos); + if (im.flags.splitter) break; + + if ((checks::option == im.style) && im.flags.checked) + im.flags.checked = false; } + + item.flags.checked = true; + } + + this->_m_close_all(); //means deleting this; + //The deleting operation has moved here, because item.functor.operator()(ip) + //may create a window, which make a killing focus for menu window, if so the close_all + //operation preformences after item.functor.operator()(ip), that would be deleting this object twice! + + if (item.functor) + { + item_type::item_proxy ip(active, item); + item.functor.operator()(ip); } } private: diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index d650c59d..01cac45c 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2453,6 +2453,8 @@ namespace nana{ namespace widgets } else { + undo_ptr->set_removed(this->_m_make_select_string()); + undo_ptr->set_selected_text(); points_.caret = _m_erase_select(); undo_ptr->set_caret_pos(); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 2496a295..6cbfe571 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -1267,5 +1267,40 @@ namespace paint } //end class graphics + //class draw + draw::draw(graphics& graph) + : graph_(graph) + {} + + void draw::corner(const rectangle& r, unsigned pixels) + { + if (1 == pixels) + { + graph_.set_pixel(r.x, r.y); + graph_.set_pixel(r.right() - 1, r.y); + + graph_.set_pixel(r.x, r.bottom() - 1); + graph_.set_pixel(r.right() - 1, r.bottom() - 1); + return; + } + else if (1 < pixels) + { + graph_.line(r.position(), point(r.x + pixels, r.y)); + graph_.line(r.position(), point(r.x, r.y + pixels)); + + int right = r.right() - 1; + graph_.line(point(right, r.y), point(right - pixels, r.y)); + graph_.line(point(right, r.y), point(right, r.y - pixels)); + + int bottom = r.bottom() - 1; + graph_.line(point(r.x, bottom), point(r.x + pixels, bottom)); + graph_.line(point(r.x, bottom), point(r.x, bottom - pixels)); + + graph_.line(point(right, bottom), point(right - pixels, bottom)); + graph_.line(point(right, bottom), point(right, bottom - pixels)); + } + } + //end class draw + }//end namespace paint }//end namespace nana