From 7aa9d9e37344492181cd9bda124543c657e92c4c Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 15 Feb 2016 01:15:40 +0800 Subject: [PATCH 1/2] arg_category is renamed arg_listbox_category --- include/nana/gui/widgets/listbox.hpp | 6 +++--- source/gui/widgets/listbox.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 42ac9123..58f02ef0 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -478,7 +478,7 @@ namespace nana }; /// The event argument type for listbox's category_dbl_click - struct arg_category + struct arg_listbox_category : public event_arg { drawerbase::listbox::cat_proxy category; @@ -489,7 +489,7 @@ namespace nana /// Determines whether expension/shrink of category is blocked bool category_change_blocked() const noexcept; - arg_category(const drawerbase::listbox::cat_proxy&) noexcept; + arg_listbox_category(const drawerbase::listbox::cat_proxy&) noexcept; private: mutable bool block_change_; }; @@ -505,7 +505,7 @@ namespace nana basic_event selected; /// An event occurs when a listbox category is double clicking. - basic_event category_dbl_click; + basic_event category_dbl_click; }; struct scheme diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 3e214531..5dc59321 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -3571,10 +3571,10 @@ namespace nana if (!item_pos.is_category()) //being the npos of item.second is a category return; - arg_category ai(cat_proxy(essence_, item_pos.cat)); - lister.wd_ptr()->events().category_dbl_click.emit(ai); + arg_listbox_category arg_cat(cat_proxy(essence_, item_pos.cat)); + lister.wd_ptr()->events().category_dbl_click.emit(arg_cat); - if(!ai.category_change_blocked()){ + if (!arg_cat.category_change_blocked()){ bool do_expand = (lister.expand(item_pos.cat) == false); lister.expand(item_pos.cat, do_expand); @@ -4299,17 +4299,17 @@ namespace nana //Implementation of arg_category //Contributed by leobackes(pr#97) - arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat ) noexcept + arg_listbox_category::arg_listbox_category(const nana::drawerbase::listbox::cat_proxy& cat) noexcept : category(cat), block_change_(false) { } - void arg_category::block_category_change() const noexcept + void arg_listbox_category::block_category_change() const noexcept { block_change_ = true; } - bool arg_category::category_change_blocked() const noexcept + bool arg_listbox_category::category_change_blocked() const noexcept { return block_change_; } From 3069d998f04f0b84794f751ef7749d0b8765a307 Mon Sep 17 00:00:00 2001 From: Besh81 Date: Tue, 10 May 2016 18:10:53 +0200 Subject: [PATCH 2/2] textbox and combox behaviours textbox: when uneditable the caret is hide combox: when uneditable (default) - inherit the textbox behaviour - open the lister clicking the textbox area also --- source/gui/widgets/combox.cpp | 37 ++++++++++---------- source/gui/widgets/skeletons/text_editor.cpp | 13 +++++-- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index c5df35f8..aec594ca 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -171,7 +171,7 @@ namespace nana if(editor_) { editor_->editable(enb); - + editor_->show_caret(enb); if (!enb) { editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&) @@ -245,22 +245,23 @@ namespace nana void open_lister_if_push_button_positioned() { - if((nullptr == state_.lister) && !items_.empty() && (parts::push_button == state_.pointer_where)) - { - module_.items.clear(); - std::copy(items_.cbegin(), items_.cend(), std::back_inserter(module_.items)); - state_.lister = &form_loader()(widget_->handle(), nana::rectangle(0, widget_->size().height, widget_->size().width, 10), true); - state_.lister->renderer(item_renderer_); - state_.lister->set_module(module_, image_pixels_); - state_.item_index_before_selection = module_.index; - //The lister window closes by itself. I just take care about the destroy event. - //The event should be destroy rather than unload. Because the unload event is invoked while - //the lister is not closed, if popuping a message box, the lister will cover the message box. - state_.lister->events().destroy.connect_unignorable([this] + if(nullptr == state_.lister && !items_.empty()) + if((parts::push_button == state_.pointer_where && editor_->attr().editable) || !editor_->attr().editable) { - _m_lister_close_sig(); - }); - } + module_.items.clear(); + std::copy(items_.cbegin(), items_.cend(), std::back_inserter(module_.items)); + state_.lister = &form_loader()(widget_->handle(), nana::rectangle(0, widget_->size().height, widget_->size().width, 10), true); + state_.lister->renderer(item_renderer_); + state_.lister->set_module(module_, image_pixels_); + state_.item_index_before_selection = module_.index; + //The lister window closes by itself. I just take care about the destroy event. + //The event should be destroy rather than unload. Because the unload event is invoked while + //the lister is not closed, if popuping a message box, the lister will cover the message box. + state_.lister->events().destroy.connect_unignorable([this] + { + _m_lister_close_sig(); + }); + } } void scroll_items(bool upwards) @@ -622,8 +623,8 @@ namespace nana if(drawer_->widget_ptr()->enabled()) { auto * editor = drawer_->editor(); - if (!editor->mouse_pressed(arg)) - drawer_->open_lister_if_push_button_positioned(); + editor->mouse_pressed(arg); + drawer_->open_lister_if_push_button_positioned(); drawer_->draw(); if(editor->attr().editable) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index fc6086cc..21fa8cdc 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1639,11 +1639,14 @@ namespace nana{ namespace widgets bool text_editor::mouse_move(bool left_button, const point& scrpos) { cursor cur = cursor::iterm; - if ((!hit_text_area(scrpos)) && (!text_area_.captured)) + if(((!hit_text_area(scrpos)) && (!text_area_.captured)) || !attributes_.editable || !API::window_enabled(window_)) cur = cursor::arrow; API::window_cursor(window_, cur); + if(!attributes_.editable) + return false; + if(left_button) { auto caret_pos_before = caret(); @@ -1662,6 +1665,9 @@ namespace nana{ namespace widgets bool text_editor::mouse_pressed(const arg_mouse& arg) { + if(!attributes_.editable) + return false; + if (event_code::mouse_down == arg.evt_code) { if (!hit_text_area(arg.pos)) @@ -1790,6 +1796,9 @@ namespace nana{ namespace widgets reset_caret_pixels(); } + if(!attributes_.editable) + visible = false; + API::caret_visible(window_, visible); if(visible) @@ -3065,7 +3074,7 @@ namespace nana{ namespace widgets graph_.palette(false, scheme_->selection.get_color()); //The text is not selected or the whole line text is selected - if (!focused || (!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y)) + if(!focused || (!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y) || !attributes_.editable) { bool selected = (a.y < str_pos.y && str_pos.y < b.y); for (auto & ent : reordered)