Merge branch 'hotfix-1.5.4' into develop

This commit is contained in:
Jinhao 2017-08-11 22:43:28 +08:00
commit 752a26e795
7 changed files with 74 additions and 82 deletions

View File

@ -535,7 +535,7 @@ namespace nana
throw std::invalid_argument("invalid listbox model container type"); throw std::invalid_argument("invalid listbox model container type");
if (nullptr == p->pointer()) if (nullptr == p->pointer())
throw std::runtime_error("the modal is immutable"); throw std::runtime_error("the modal is immutable, please declare model_guard with const");
return *static_cast<stlcontainer*>(p->pointer()); return *static_cast<stlcontainer*>(p->pointer());
} }
@ -1250,8 +1250,9 @@ By \a clicking on one header the list get \a reordered, first up, and then down
} }
return false; return false;
} }
listbox.anyobj(0, 0, 10); //the type of customer's object is int. auto cat = listbox.at(0);
listbox.anyobj(0, 0, 20); cat.at(0).value(10); //10 is custom data.
cat.at(1).value(20); //20 is custom data.
5. listbox is a widget_object, with template parameters drawerbase::listbox::trigger and drawerbase::listbox::scheme 5. listbox is a widget_object, with template parameters drawerbase::listbox::trigger and drawerbase::listbox::scheme
amon others. amon others.
That means that listbox have a member trigger_ constructed first and accecible with get_drawer_trigger() and That means that listbox have a member trigger_ constructed first and accecible with get_drawer_trigger() and

View File

@ -114,8 +114,30 @@ namespace nana
return false; return false;
} }
for (auto* parent = wd->parent; parent; parent = parent->parent) for (auto parent = wd->parent; parent; parent = parent->parent)
{ {
if (category::flags::root == parent->other.category)
{
//visual rectangle of wd's parent
rectangle vrt_parent{parent->pos_root, parent->dimension};
point pos_root;
while (parent->parent)
{
pos_root -= native_interface::window_position(parent->root);
if (!overlap(rectangle{ pos_root, parent->parent->root_widget->dimension }, vrt_parent, vrt_parent))
return false;
parent = parent->parent->root_widget;
}
if (!overlap(vrt_parent, visual, visual))
return false;
return true;
}
if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual)) if (!overlap(rectangle{ parent->pos_root, parent->dimension }, visual, visual))
return false; return false;
} }

View File

@ -733,30 +733,6 @@ namespace detail
} }
} }
void sync_child_root_display(window_manager::core_window_t* wd)
{
for (auto & child : wd->children)
{
if (category::flags::root != child->other.category)
{
sync_child_root_display(child);
continue;
}
auto const vs_parents = child->visible_parents();
if (vs_parents != child->visible)
{
native_interface::show_window(child->root, vs_parents, false);
}
else
{
if (child->visible != native_interface::is_window_visible(child->root))
native_interface::show_window(child->root, child->visible, false);
}
}
}
//show //show
//@brief: show or hide a window //@brief: show or hide a window
bool window_manager::show(core_window_t* wd, bool visible) bool window_manager::show(core_window_t* wd, bool visible)
@ -792,15 +768,8 @@ namespace detail
bedrock::instance().event_expose(wd, visible); bedrock::instance().event_expose(wd, visible);
if (nv) if (nv)
{
if (visible && !wd->visible_parents())
return true;
native_interface::show_window(nv, visible, wd->flags.take_active); native_interface::show_window(nv, visible, wd->flags.take_active);
} }
sync_child_root_display(wd);
}
return true; return true;
} }

View File

@ -143,6 +143,7 @@ namespace nana
auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd)); auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd));
editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme); editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme);
_m_text_area(graph.size());
editor_->multi_lines(false); editor_->multi_lines(false);
editable(false); editable(false);
graph_ = &graph; graph_ = &graph;
@ -177,21 +178,6 @@ namespace nana
return any_ptr.get(); return any_ptr.get();
} }
void text_area(const nana::size& s)
{
auto extension = measurer_->extension();
nana::rectangle r(2, 2, s.width > extension.width ? s.width - extension.width : 0, s.height > extension.height ? s.height - extension.height : 0);
if(image_enabled_)
{
unsigned place = image_pixels_ + 2;
r.x += place;
if(r.width > place) r.width -= place;
}
editor_->text_area(r);
editor_->render(state_.focused);
}
widgets::skeletons::text_editor * editor() const widgets::skeletons::text_editor * editor() const
{ {
return editor_; return editor_;
@ -364,12 +350,13 @@ namespace nana
void draw() void draw()
{ {
bool enb = widget_->enabled(); bool enb = widget_->enabled();
if(editor_)
{ _m_text_area(widget_->size());
text_area(widget_->size()); editor_->render(state_.focused);
}
_m_draw_push_button(enb); _m_draw_push_button(enb);
_m_draw_image(); _m_draw_image();
} }
std::size_t the_number_of_options() const std::size_t the_number_of_options() const
@ -496,6 +483,20 @@ namespace nana
return true; return true;
} }
private: private:
void _m_text_area(const nana::size& s)
{
auto extension = measurer_->extension();
nana::rectangle r(2, 2, s.width > extension.width ? s.width - extension.width : 0, s.height > extension.height ? s.height - extension.height : 0);
if (image_enabled_)
{
unsigned place = image_pixels_ + 2;
r.x += place;
if (r.width > place) r.width -= place;
}
editor_->text_area(r);
}
void _m_draw_push_button(bool enabled) void _m_draw_push_button(bool enabled)
{ {
::nana::rectangle r{graph_->size()}; ::nana::rectangle r{graph_->size()};

View File

@ -624,10 +624,14 @@ namespace nana
} }
else if (item_ptr->flags.enabled) else if (item_ptr->flags.enabled)
{ {
//A pointer refers to a menu object which owns the menu window.
//After fn_close_tree_(), *this is an invalid object.
auto owner = menu_->owner;
fn_close_tree_(); fn_close_tree_();
if (item_ptr->event_handler) if (item_ptr->event_handler)
{ {
item_proxy ip{ index, menu_->owner }; item_proxy ip{ index, owner };
item_ptr->event_handler.operator()(ip); item_ptr->event_handler.operator()(ip);
} }
return 1; return 1;
@ -1019,13 +1023,18 @@ namespace nana
close(); close();
break; break;
default: default:
if (2 != send_shortkey(arg.key)) switch (send_shortkey(arg.key))
{ {
if (API::empty_window(*this) == false) case 0:
if (this->empty() == false)
close(); close();
} break;
else case 1: //The menu has been closed
break;
case 2:
this->submenu(true); this->submenu(true);
break;
}
} }
} }

View File

@ -887,6 +887,7 @@ namespace nana{ namespace widgets
return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0); return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0);
} }
private: private:
/// Split a text into multiple sections, a section indicates an english word or a CKJ character
void _m_text_section(const std::wstring& str, std::vector<text_section>& tsec) void _m_text_section(const std::wstring& str, std::vector<text_section>& tsec)
{ {
if (str.empty()) if (str.empty())
@ -1025,14 +1026,14 @@ namespace nana{ namespace widgets
if (pos) if (pos)
{ {
auto chr = text[pos - 1]; auto chr = text[pos - 1];
if ((std::iswalpha(chr) && !std::isspace(chr)) || chr == '_') if ((std::iswalpha(chr) && !std::iswspace(chr)) || chr == '_')
return false; return false;
} }
if (pos + len < text.size()) if (pos + len < text.size())
{ {
auto chr = text[pos + len]; auto chr = text[pos + len];
if ((std::iswalpha(chr) && !std::isspace(chr)) || chr == '_') if ((std::iswalpha(chr) && !std::iswspace(chr)) || chr == '_')
return false; return false;
} }
@ -1596,18 +1597,6 @@ namespace nana{ namespace widgets
if(!attributes_.enable_caret) if(!attributes_.enable_caret)
return false; return false;
auto is_whitespace = [](wchar_t c) {
switch (c) {
case L' ':
case L'\t':
case L'\n':
case L'\r':
return true;
default:
return false;
}
};
// Set caret pos by screen point and get the caret pos. // Set caret pos by screen point and get the caret pos.
mouse_caret(arg.pos, true); mouse_caret(arg.pos, true);
@ -1616,11 +1605,11 @@ namespace nana{ namespace widgets
const auto& line = impl_->textbase.getline(select_.b.y); const auto& line = impl_->textbase.getline(select_.b.y);
// Expand the selection forward to the word's end. // Expand the selection forward to the word's end.
while (select_.b.x < line.size() && !is_whitespace(line[select_.b.x])) while (select_.b.x < line.size() && !std::iswspace(line[select_.b.x]))
++select_.b.x; ++select_.b.x;
// Expand the selection backward to the word's start. // Expand the selection backward to the word's start.
while (select_.a.x > 0 && !is_whitespace(line[select_.a.x - 1])) while (select_.a.x > 0 && !std::iswspace(line[select_.a.x - 1]))
--select_.a.x; --select_.a.x;
select_.mode_selection = selection::mode::method_selected; select_.mode_selection = selection::mode::method_selected;
@ -2876,7 +2865,6 @@ namespace nana{ namespace widgets
return ('0' <= ch && ch <= '9'); return ('0' <= ch && ch <= '9');
} }
::nana::color text_editor::_m_bgcolor() const ::nana::color text_editor::_m_bgcolor() const
{ {
return (!API::window_enabled(window_) ? static_cast<color_rgb>(0xE0E0E0) : API::bgcolor(window_)); return (!API::window_enabled(window_) ? static_cast<color_rgb>(0xE0E0E0) : API::bgcolor(window_));

View File

@ -524,14 +524,16 @@ namespace nana
if((::nana::mouse_action::pressed == slider_state_.mouse_state) && (API::capture_window() == this->other_.wd)) if((::nana::mouse_action::pressed == slider_state_.mouse_state) && (API::capture_window() == this->other_.wd))
return false; return false;
auto state_changed = ((slider_state_.mouse_state != ::nana::mouse_action::normal)
|| (attr_.adorn_pos != attr_.slider.pos));
slider_state_.mouse_state = ::nana::mouse_action::normal; slider_state_.mouse_state = ::nana::mouse_action::normal;
attr_.is_draw_adorn = false; attr_.is_draw_adorn = false;
if(attr_.adorn_pos != attr_.slider.pos)
{
attr_.adorn_pos = attr_.slider.pos; attr_.adorn_pos = attr_.slider.pos;
return true; slider_state_.mouse_state = ::nana::mouse_action::normal;
}
return false; return state_changed;
} }
private: private: