Merge branch 'besh81-master' into hotfix-1.3

This commit is contained in:
Jinhao 2016-06-10 16:36:13 +08:00
commit a591735a2a
4 changed files with 33 additions and 24 deletions

View File

@ -502,7 +502,7 @@ namespace nana
/// Determines whether expension/shrink of category is blocked /// Determines whether expension/shrink of category is blocked
bool category_change_blocked() const noexcept; bool category_change_blocked() const noexcept;
arg_category(const drawerbase::listbox::cat_proxy&) noexcept; arg_category(const drawerbase::listbox::cat_proxy&) noexcept;
private: private:
mutable bool block_change_; mutable bool block_change_;
}; };

View File

@ -171,7 +171,7 @@ namespace nana
if(editor_) if(editor_)
{ {
editor_->editable(enb); editor_->editable(enb);
editor_->show_caret(enb);
if (!enb) if (!enb)
{ {
editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&) 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() void open_lister_if_push_button_positioned()
{ {
if((nullptr == state_.lister) && !items_.empty() && (parts::push_button == state_.pointer_where)) if(nullptr == state_.lister && !items_.empty())
{ if((parts::push_button == state_.pointer_where && editor_->attr().editable) || !editor_->attr().editable)
module_.items.clear();
std::copy(items_.cbegin(), items_.cend(), std::back_inserter(module_.items));
state_.lister = &form_loader<nana::float_listbox, false>()(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(); module_.items.clear();
}); std::copy(items_.cbegin(), items_.cend(), std::back_inserter(module_.items));
} state_.lister = &form_loader<nana::float_listbox, false>()(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) void scroll_items(bool upwards)
@ -622,8 +623,8 @@ namespace nana
if(drawer_->widget_ptr()->enabled()) if(drawer_->widget_ptr()->enabled())
{ {
auto * editor = drawer_->editor(); auto * editor = drawer_->editor();
if (!editor->mouse_pressed(arg)) editor->mouse_pressed(arg);
drawer_->open_lister_if_push_button_positioned(); drawer_->open_lister_if_push_button_positioned();
drawer_->draw(); drawer_->draw();
if(editor->attr().editable) if(editor->attr().editable)

View File

@ -4360,18 +4360,17 @@ namespace nana
//Implementation of arg_category //Implementation of arg_category
//Contributed by leobackes(pr#97) //Contributed by leobackes(pr#97)
arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat ) noexcept arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat ) noexcept
: category(cat), block_change_(false) : category(cat), block_change_(false)
{ {
} }
void arg_category::block_category_change() const noexcept void arg_category::block_category_change() const noexcept
{ {
block_change_ = true; block_change_ = true;
} }
bool arg_category::category_change_blocked() const noexcept bool arg_category::category_change_blocked() const noexcept
{ {
return block_change_; return block_change_;
} }

View File

@ -1635,11 +1635,14 @@ namespace nana{ namespace widgets
bool text_editor::mouse_move(bool left_button, const point& scrpos) bool text_editor::mouse_move(bool left_button, const point& scrpos)
{ {
cursor cur = cursor::iterm; 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; cur = cursor::arrow;
API::window_cursor(window_, cur); API::window_cursor(window_, cur);
if(!attributes_.editable)
return false;
if(left_button) if(left_button)
{ {
mouse_caret(scrpos); mouse_caret(scrpos);
@ -1655,6 +1658,9 @@ namespace nana{ namespace widgets
bool text_editor::mouse_pressed(const arg_mouse& arg) bool text_editor::mouse_pressed(const arg_mouse& arg)
{ {
if(!attributes_.editable)
return false;
if (event_code::mouse_down == arg.evt_code) if (event_code::mouse_down == arg.evt_code)
{ {
if (!hit_text_area(arg.pos)) if (!hit_text_area(arg.pos))
@ -1790,6 +1796,9 @@ namespace nana{ namespace widgets
reset_caret_pixels(); reset_caret_pixels();
} }
if(!attributes_.editable)
visible = false;
API::caret_visible(window_, visible); API::caret_visible(window_, visible);
if(visible) if(visible)
@ -3078,7 +3087,7 @@ namespace nana{ namespace widgets
graph_.palette(false, scheme_->selection.get_color()); graph_.palette(false, scheme_->selection.get_color());
//The text is not selected or the whole line text is selected //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); bool selected = (a.y < str_pos.y && str_pos.y < b.y);
for (auto & ent : reordered) for (auto & ent : reordered)