place::modify() now correctly updates the place::div_text.
This commit is contained in:
parent
830839ae27
commit
3c2b36ead8
@ -118,10 +118,10 @@ namespace nana
|
|||||||
|
|
||||||
field_reference field(const char* name);///< Returns a field with the specified name.
|
field_reference field(const char* name);///< Returns a field with the specified name.
|
||||||
|
|
||||||
void field_visible(const char* field_name, bool visible); ///<<Shows/Hides an existing field.
|
void field_visible(const char* field_name, bool visible) const; ///<<Shows/Hides an existing field.
|
||||||
bool field_visible(const char* field_name) const; ///<Determines whether the specified field is visible.
|
bool field_visible(const char* field_name) const; ///<Determines whether the specified field is visible.
|
||||||
|
|
||||||
void field_display(const char* field_name, bool display); ///<Displays/Discards an existing field.
|
void field_display(const char* field_name, bool display) const; ///<Displays/Discards an existing field.
|
||||||
bool field_display(const char* field_name) const; ///<Determines whether the specified field is displayed.
|
bool field_display(const char* field_name) const; ///<Determines whether the specified field is displayed.
|
||||||
|
|
||||||
void collocate(); ///< Layouts the widgets.
|
void collocate(); ///< Layouts the widgets.
|
||||||
|
|||||||
@ -1890,7 +1890,7 @@ namespace nana
|
|||||||
unsigned vert_count = 0, horz_count = 0;
|
unsigned vert_count = 0, horz_count = 0;
|
||||||
|
|
||||||
bool is_first = true;
|
bool is_first = true;
|
||||||
bool prev_attr;
|
bool prev_attr = false;
|
||||||
|
|
||||||
for (auto & child : children)
|
for (auto & child : children)
|
||||||
{
|
{
|
||||||
@ -1967,7 +1967,7 @@ namespace nana
|
|||||||
child_dv->splitter.reset();
|
child_dv->splitter.reset();
|
||||||
|
|
||||||
::nana::rectangle child_r;
|
::nana::rectangle child_r;
|
||||||
double split_range_begin = -1, split_range_end;
|
double split_range_begin = -1, split_range_end = 0;
|
||||||
switch (child->dir)
|
switch (child->dir)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -2622,6 +2622,10 @@ namespace nana
|
|||||||
return impl_->div_text;
|
return impl_->div_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum div_type { erase = 0, insert, replace };
|
||||||
|
|
||||||
|
void update_div(std::string& div, const char* field, const char* attr, div_type insertion);
|
||||||
|
|
||||||
void place::modify(const char* name, const char* div_text)
|
void place::modify(const char* name, const char* div_text)
|
||||||
{
|
{
|
||||||
if (nullptr == div_text)
|
if (nullptr == div_text)
|
||||||
@ -2676,6 +2680,7 @@ namespace nana
|
|||||||
impl_->check_unique(impl_->root_division.get());
|
impl_->check_unique(impl_->root_division.get());
|
||||||
impl_->connect(impl_->root_division.get());
|
impl_->connect(impl_->root_division.get());
|
||||||
impl_->tmp_replaced.reset();
|
impl_->tmp_replaced.reset();
|
||||||
|
update_div(impl_->div_text, name, div_text, div_type::replace);
|
||||||
|
|
||||||
modified_ptr->div_owner = div_owner;
|
modified_ptr->div_owner = div_owner;
|
||||||
modified_ptr->div_next = div_next;
|
modified_ptr->div_next = div_next;
|
||||||
@ -2740,7 +2745,7 @@ namespace nana
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_div(std::string& div, const char* field, const char* attr, bool insertion)
|
void update_div(std::string& div, const char* field, const char* attr, div_type insertion)
|
||||||
{
|
{
|
||||||
const auto fieldname_pos = find_idstr(div, field);
|
const auto fieldname_pos = find_idstr(div, field);
|
||||||
if (div.npos == fieldname_pos)
|
if (div.npos == fieldname_pos)
|
||||||
@ -2830,13 +2835,18 @@ namespace nana
|
|||||||
if (fieldstr.npos == pos)
|
if (fieldstr.npos == pos)
|
||||||
{
|
{
|
||||||
//There is not an attribute
|
//There is not an attribute
|
||||||
if (insertion)
|
if (insertion == div_type::insert)
|
||||||
div.insert(fieldname_pos + std::strlen(field), " " + std::string(attr));
|
div.insert(fieldname_pos + std::strlen(field), " " + std::string(attr));
|
||||||
|
else if (insertion == div_type::replace)
|
||||||
|
{
|
||||||
|
div.erase(begin + 1, fieldstr.length());
|
||||||
|
div.insert(begin + 1, std::string(attr) + " " + std::string(field));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//There is an attribute
|
//There is an attribute
|
||||||
if (!insertion)
|
if (insertion == div_type::erase)
|
||||||
{
|
{
|
||||||
div.erase(begin + pos + 1, std::strlen(attr));
|
div.erase(begin + pos + 1, std::strlen(attr));
|
||||||
|
|
||||||
@ -2846,7 +2856,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void place::field_visible(const char* name, bool vsb)
|
void place::field_visible(const char* name, bool vsb) const
|
||||||
{
|
{
|
||||||
if (!name) name = "";
|
if (!name) name = "";
|
||||||
|
|
||||||
@ -2857,7 +2867,7 @@ namespace nana
|
|||||||
if (div)
|
if (div)
|
||||||
{
|
{
|
||||||
div->set_visible(vsb);
|
div->set_visible(vsb);
|
||||||
update_div(impl_->div_text, name, "invisible", !vsb);
|
update_div(impl_->div_text, name, "invisible", !vsb ? div_type::insert : div_type::erase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2872,7 +2882,7 @@ namespace nana
|
|||||||
return (div && div->visible);
|
return (div && div->visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void place::field_display(const char* name, bool dsp)
|
void place::field_display(const char* name, bool dsp) const
|
||||||
{
|
{
|
||||||
if (!name) name = "";
|
if (!name) name = "";
|
||||||
|
|
||||||
@ -2882,8 +2892,8 @@ namespace nana
|
|||||||
auto div = impl_->search_div_name(impl_->root_division.get(), name);
|
auto div = impl_->search_div_name(impl_->root_division.get(), name);
|
||||||
if (div)
|
if (div)
|
||||||
{
|
{
|
||||||
update_div(impl_->div_text, name, "invisible", false);
|
update_div(impl_->div_text, name, "invisible", div_type::erase);
|
||||||
update_div(impl_->div_text, name, "undisplayed", !dsp);
|
update_div(impl_->div_text, name, "undisplayed", !dsp ? div_type::insert : div_type::erase);
|
||||||
div->set_display(dsp);
|
div->set_display(dsp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user