remove overloading assignment operator of rectangle
This commit is contained in:
parent
8489e16d72
commit
5d5a808b2d
@ -449,9 +449,6 @@ namespace nana
|
|||||||
bool operator==(const rectangle& rhs) const;
|
bool operator==(const rectangle& rhs) const;
|
||||||
bool operator!=(const rectangle& rhs) const;
|
bool operator!=(const rectangle& rhs) const;
|
||||||
|
|
||||||
rectangle& operator=(const point&);
|
|
||||||
rectangle& operator=(const size&);
|
|
||||||
|
|
||||||
point position() const noexcept;
|
point position() const noexcept;
|
||||||
rectangle& position(const point&) noexcept;
|
rectangle& position(const point&) noexcept;
|
||||||
|
|
||||||
|
|||||||
@ -607,20 +607,6 @@ namespace nana
|
|||||||
return (width != rhs.width) || (height != rhs.height) || (x != rhs.x) || (y != rhs.y);
|
return (width != rhs.width) || (height != rhs.height) || (x != rhs.x) || (y != rhs.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
rectangle & rectangle::operator=(const point& pos)
|
|
||||||
{
|
|
||||||
x = pos.x;
|
|
||||||
y = pos.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
rectangle & rectangle::operator=(const size & sz)
|
|
||||||
{
|
|
||||||
width = sz.width;
|
|
||||||
height = sz.height;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
point rectangle::position() const noexcept
|
point rectangle::position() const noexcept
|
||||||
{
|
{
|
||||||
return{ x, y };
|
return{ x, y };
|
||||||
|
|||||||
@ -61,7 +61,7 @@ namespace nana
|
|||||||
if (0 == effect_range_.width || 0 == effect_range_.height)
|
if (0 == effect_range_.width || 0 == effect_range_.height)
|
||||||
{
|
{
|
||||||
rect.x = rect.y = 0;
|
rect.x = rect.y = 0;
|
||||||
rect = owner_->dimension;
|
rect.dimension(owner_->dimension);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -56,7 +56,7 @@ namespace nana
|
|||||||
if (overlap(ir, valid_r, op_ir) == false)
|
if (overlap(ir, valid_r, op_ir) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
valid_r = valid_dst_area;
|
valid_r.dimension(valid_dst_area);
|
||||||
rectangle good_dr;
|
rectangle good_dr;
|
||||||
if (overlap(dr, valid_r, good_dr) == false)
|
if (overlap(dr, valid_r, good_dr) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -1684,7 +1684,7 @@ namespace nana
|
|||||||
graph.blend(r, clr, 0.5);
|
graph.blend(r, clr, 0.5);
|
||||||
|
|
||||||
r.x = r.y = 0;
|
r.x = r.y = 0;
|
||||||
r = graph.size();
|
r.dimension(graph.size());
|
||||||
r.width = border_px;
|
r.width = border_px;
|
||||||
graph.blend(r, clr, 0.5);
|
graph.blend(r, clr, 0.5);
|
||||||
r.x = right - border_px;
|
r.x = right - border_px;
|
||||||
@ -2099,7 +2099,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if (root_division && window_handle)
|
if (root_division && window_handle)
|
||||||
{
|
{
|
||||||
root_division->field_area = API::window_size(window_handle);
|
root_division->field_area.dimension(API::window_size(window_handle));
|
||||||
|
|
||||||
if (root_division->field_area.empty())
|
if (root_division->field_area.empty())
|
||||||
return;
|
return;
|
||||||
@ -2590,7 +2590,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if (impl_->root_division)
|
if (impl_->root_division)
|
||||||
{
|
{
|
||||||
impl_->root_division->field_area = ::nana::size(arg.width, arg.height);
|
impl_->root_division->field_area.dimension({ arg.width, arg.height });
|
||||||
impl_->root_division->collocate(arg.window_handle);
|
impl_->root_division->collocate(arg.window_handle);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -474,7 +474,7 @@ namespace API
|
|||||||
|
|
||||||
nana::point pos{ r.x, r.y };
|
nana::point pos{ r.x, r.y };
|
||||||
calc_window_point(wd, pos);
|
calc_window_point(wd, pos);
|
||||||
r = pos;
|
r.position(pos);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -565,7 +565,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
using container = std::vector<cell>;
|
using container = std::vector<cell>;
|
||||||
|
|
||||||
container cells;
|
std::unique_ptr<container> cells;
|
||||||
nana::color bgcolor;
|
nana::color bgcolor;
|
||||||
nana::color fgcolor;
|
nana::color fgcolor;
|
||||||
paint::image img;
|
paint::image img;
|
||||||
@ -585,7 +585,7 @@ namespace nana
|
|||||||
}
|
}
|
||||||
|
|
||||||
item_data(const item_data& r)
|
item_data(const item_data& r)
|
||||||
: cells(r.cells),
|
: cells(r.cells ? std::make_unique<container>(*r.cells) : nullptr),
|
||||||
bgcolor(r.bgcolor),
|
bgcolor(r.bgcolor),
|
||||||
fgcolor(r.fgcolor),
|
fgcolor(r.fgcolor),
|
||||||
img(r.img),
|
img(r.img),
|
||||||
@ -594,30 +594,34 @@ namespace nana
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
item_data(container&& cont)
|
item_data(container&& cont)
|
||||||
: cells(std::move(cont))
|
: cells(std::make_unique<container>(std::move(cont)))
|
||||||
{
|
{
|
||||||
flags.selected = flags.checked = false;
|
flags.selected = flags.checked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
item_data(std::string&& s)
|
item_data(std::string&& s)
|
||||||
|
: cells(std::make_unique<container>())
|
||||||
{
|
{
|
||||||
flags.selected = flags.checked = false;
|
flags.selected = flags.checked = false;
|
||||||
cells.emplace_back(std::move(s));
|
cells->emplace_back(std::move(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
item_data(std::string&& s, const nana::color& bg, const nana::color& fg)
|
item_data(std::string&& s, const nana::color& bg, const nana::color& fg):
|
||||||
: bgcolor(bg),
|
cells(std::make_unique<container>()),
|
||||||
fgcolor(fg)
|
bgcolor(bg),
|
||||||
|
fgcolor(fg)
|
||||||
{
|
{
|
||||||
flags.selected = flags.checked = false;
|
flags.selected = flags.checked = false;
|
||||||
cells.emplace_back(std::move(s));
|
cells->emplace_back(std::move(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
item_data& operator=(const item_data& r)
|
item_data& operator=(const item_data& r)
|
||||||
{
|
{
|
||||||
if (this != &r)
|
if (this != &r)
|
||||||
{
|
{
|
||||||
cells = r.cells;
|
if (r.cells)
|
||||||
|
cells = std::make_unique<container>(*r.cells);
|
||||||
|
|
||||||
flags = r.flags;
|
flags = r.flags;
|
||||||
anyobj.reset(r.anyobj ? new nana::any(*r.anyobj) : nullptr);
|
anyobj.reset(r.anyobj ? new nana::any(*r.anyobj) : nullptr);
|
||||||
bgcolor = r.bgcolor;
|
bgcolor = r.bgcolor;
|
||||||
@ -644,7 +648,7 @@ namespace nana
|
|||||||
if (model_cells)
|
if (model_cells)
|
||||||
item_str += model_cells->operator[](col).text;
|
item_str += model_cells->operator[](col).text;
|
||||||
else
|
else
|
||||||
item_str += cells[col].text;
|
item_str += (*cells)[col].text;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item_str;
|
return item_str;
|
||||||
@ -790,20 +794,20 @@ namespace nana
|
|||||||
auto & mx = cat.items[x];
|
auto & mx = cat.items[x];
|
||||||
auto & my = cat.items[y];
|
auto & my = cat.items[y];
|
||||||
|
|
||||||
if (mx.cells.size() <= sorted_index_ || my.cells.size() <= sorted_index_)
|
if (mx.cells->size() <= sorted_index_ || my.cells->size() <= sorted_index_)
|
||||||
{
|
{
|
||||||
std::string a;
|
std::string a;
|
||||||
if (mx.cells.size() > sorted_index_)
|
if (mx.cells->size() > sorted_index_)
|
||||||
a = mx.cells[sorted_index_].text;
|
a = (*mx.cells)[sorted_index_].text;
|
||||||
|
|
||||||
std::string b;
|
std::string b;
|
||||||
if (my.cells.size() > sorted_index_)
|
if (my.cells->size() > sorted_index_)
|
||||||
b = my.cells[sorted_index_].text;
|
b = (*my.cells)[sorted_index_].text;
|
||||||
|
|
||||||
return weak_ordering_comp(a, mx.anyobj.get(), b, my.anyobj.get(), sorted_reverse_);
|
return weak_ordering_comp(a, mx.anyobj.get(), b, my.anyobj.get(), sorted_reverse_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return weak_ordering_comp(mx.cells[sorted_index_].text, mx.anyobj.get(), my.cells[sorted_index_].text, my.anyobj.get(), sorted_reverse_);
|
return weak_ordering_comp((*mx.cells)[sorted_index_].text, mx.anyobj.get(), (*my.cells)[sorted_index_].text, my.anyobj.get(), sorted_reverse_);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -843,21 +847,21 @@ namespace nana
|
|||||||
auto & mx = cat.items[x];
|
auto & mx = cat.items[x];
|
||||||
auto & my = cat.items[y];
|
auto & my = cat.items[y];
|
||||||
|
|
||||||
if (mx.cells.size() <= sorted_index_ || my.cells.size() <= sorted_index_)
|
if (mx.cells->size() <= sorted_index_ || my.cells->size() <= sorted_index_)
|
||||||
{
|
{
|
||||||
std::string a;
|
std::string a;
|
||||||
if (mx.cells.size() > sorted_index_)
|
if (mx.cells->size() > sorted_index_)
|
||||||
a = mx.cells[sorted_index_].text;
|
a = (*mx.cells)[sorted_index_].text;
|
||||||
|
|
||||||
std::string b;
|
std::string b;
|
||||||
if (my.cells.size() > sorted_index_)
|
if (my.cells->size() > sorted_index_)
|
||||||
b = my.cells[sorted_index_].text;
|
b = (*my.cells)[sorted_index_].text;
|
||||||
|
|
||||||
return (sorted_reverse_ ? a > b : a < b);
|
return (sorted_reverse_ ? a > b : a < b);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & a = mx.cells[sorted_index_].text;
|
auto & a = (*mx.cells)[sorted_index_].text;
|
||||||
auto & b = my.cells[sorted_index_].text;
|
auto & b = (*my.cells)[sorted_index_].text;
|
||||||
return (sorted_reverse_ ? a > b : a < b);
|
return (sorted_reverse_ ? a > b : a < b);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1010,7 +1014,7 @@ namespace nana
|
|||||||
catobj.items.emplace_back(std::move(text));
|
catobj.items.emplace_back(std::move(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
catobj.items.back().cells.emplace_back(std::move(text));
|
catobj.items.back().cells->emplace_back(std::move(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!!
|
/// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!!
|
||||||
@ -1268,7 +1272,7 @@ namespace nana
|
|||||||
if (cat->model_ptr)
|
if (cat->model_ptr)
|
||||||
throw std::runtime_error("nana::listbox disallow to get item cells, because there are model cells");
|
throw std::runtime_error("nana::listbox disallow to get item cells, because there are model cells");
|
||||||
|
|
||||||
return cat->items.at(pos).cells;
|
return *(cat->items.at(pos).cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cell> get_model_cells(category_t* cat, std::size_t pos) const
|
std::vector<cell> get_model_cells(category_t* cat, std::size_t pos) const
|
||||||
@ -1295,7 +1299,7 @@ namespace nana
|
|||||||
model_cells = cat->model_ptr->container()->to_cells(pos);
|
model_cells = cat->model_ptr->container()->to_cells(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & cells = (cat->model_ptr ? model_cells : cat->items[pos].cells);
|
auto & cells = (cat->model_ptr ? model_cells : *(cat->items[pos].cells));
|
||||||
|
|
||||||
if (col < cells.size())
|
if (col < cells.size())
|
||||||
{
|
{
|
||||||
@ -1328,7 +1332,7 @@ namespace nana
|
|||||||
model_cells = cat->model_ptr->container()->to_cells(pos);
|
model_cells = cat->model_ptr->container()->to_cells(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & cells = (cat->model_ptr ? model_cells : cat->items[pos].cells);
|
auto & cells = (cat->model_ptr ? model_cells : *(cat->items[pos].cells));
|
||||||
|
|
||||||
if (col < cells.size())
|
if (col < cells.size())
|
||||||
{
|
{
|
||||||
@ -1934,6 +1938,7 @@ namespace nana
|
|||||||
|
|
||||||
return (display_pos.item < catobj.sorted.size() ? catobj.sorted[display_pos.item] : npos);
|
return (display_pos.item < catobj.sorted.size() ? catobj.sorted[display_pos.item] : npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
index_pair absolute_pair(const index_pair& display_pos) const
|
index_pair absolute_pair(const index_pair& display_pos) const
|
||||||
{
|
{
|
||||||
//Returns an empty pos if item pos npos
|
//Returns an empty pos if item pos npos
|
||||||
@ -2499,7 +2504,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
if (lister.wd_ptr()->borderless())
|
if (lister.wd_ptr()->borderless())
|
||||||
{
|
{
|
||||||
r = graph->size();
|
r.dimension(graph->size());
|
||||||
r.height = scheme_ptr->header_height;
|
r.height = scheme_ptr->header_height;
|
||||||
return !r.empty();
|
return !r.empty();
|
||||||
}
|
}
|
||||||
@ -2870,14 +2875,30 @@ namespace nana
|
|||||||
unsigned max_px = 0;
|
unsigned max_px = 0;
|
||||||
for (auto & cat : categories_)
|
for (auto & cat : categories_)
|
||||||
{
|
{
|
||||||
for (auto & m : cat.items)
|
if (cat.model_ptr)
|
||||||
{
|
{
|
||||||
if (pos >= m.cells.size())
|
for (std::size_t i = 0; i < cat.items.size(); ++i)
|
||||||
continue;
|
{
|
||||||
|
auto model_cells = cat.model_ptr->container()->to_cells(i);
|
||||||
|
if (pos >= model_cells.size())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto content_px = ess_->graph->text_extent_size(m.cells[pos].text).width;
|
auto content_px = ess_->graph->text_extent_size(model_cells[pos].text).width;
|
||||||
if (content_px > max_px)
|
if (content_px > max_px)
|
||||||
max_px = content_px;
|
max_px = content_px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto & m : cat.items)
|
||||||
|
{
|
||||||
|
if (pos >= m.cells->size())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto content_px = ess_->graph->text_extent_size((*m.cells)[pos].text).width;
|
||||||
|
if (content_px > max_px)
|
||||||
|
max_px = content_px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return max_px;
|
return max_px;
|
||||||
@ -2965,7 +2986,7 @@ namespace nana
|
|||||||
ess_->lister.throw_if_immutable_model(pos);
|
ess_->lister.throw_if_immutable_model(pos);
|
||||||
|
|
||||||
auto model_cells = ess_->lister.at_model_abs(pos);
|
auto model_cells = ess_->lister.at_model_abs(pos);
|
||||||
auto & cells = ess_->lister.have_model(pos) ? model_cells : ess_->lister.at_abs(pos).cells;
|
auto & cells = ess_->lister.have_model(pos) ? model_cells : (*ess_->lister.at_abs(pos).cells);
|
||||||
|
|
||||||
if (cells.size() <= column_pos_)
|
if (cells.size() <= column_pos_)
|
||||||
cells.resize(column_pos_ + 1);
|
cells.resize(column_pos_ + 1);
|
||||||
@ -3696,7 +3717,7 @@ namespace nana
|
|||||||
model_cells = cat.model_ptr->container()->to_cells(item_pos.item);
|
model_cells = cat.model_ptr->container()->to_cells(item_pos.item);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto & cells = (cat.model_ptr ? model_cells : item.cells);
|
auto & cells = (cat.model_ptr ? model_cells : *item.cells);
|
||||||
|
|
||||||
if (item.flags.selected) // fetch the "def" colors
|
if (item.flags.selected) // fetch the "def" colors
|
||||||
bgcolor = essence_->scheme_ptr->item_selected;
|
bgcolor = essence_->scheme_ptr->item_selected;
|
||||||
@ -5050,7 +5071,10 @@ namespace nana
|
|||||||
cat_->sorted.clear();
|
cat_->sorted.clear();
|
||||||
|
|
||||||
cat_->items.resize(cat_->model_ptr->container()->size());
|
cat_->items.resize(cat_->model_ptr->container()->size());
|
||||||
for (std::size_t pos = 0; pos < cat_->items.size(); ++pos)
|
|
||||||
|
const auto item_size = cat_->items.size();
|
||||||
|
cat_->sorted.reserve(item_size + 100);
|
||||||
|
for (std::size_t pos = 0; pos != item_size; ++pos)
|
||||||
cat_->sorted.push_back(pos);
|
cat_->sorted.push_back(pos);
|
||||||
|
|
||||||
ess_->lister.sort();
|
ess_->lister.sort();
|
||||||
|
|||||||
@ -76,7 +76,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
auto valid_area = backimg.valid_area;
|
auto valid_area = backimg.valid_area;
|
||||||
if (valid_area.empty())
|
if (valid_area.empty())
|
||||||
valid_area = backimg.image.size();
|
valid_area.dimension(backimg.image.size());
|
||||||
|
|
||||||
if (backimg.stretchable)
|
if (backimg.stretchable)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1280,7 +1280,7 @@ namespace nana{ namespace widgets
|
|||||||
graph_(graph),
|
graph_(graph),
|
||||||
scheme_(schm), keywords_(new keywords)
|
scheme_(schm), keywords_(new keywords)
|
||||||
{
|
{
|
||||||
text_area_.area = graph.size();
|
text_area_.area.dimension(graph.size());
|
||||||
text_area_.captured = false;
|
text_area_.captured = false;
|
||||||
text_area_.tab_space = 4;
|
text_area_.tab_space = 4;
|
||||||
text_area_.scroll_pixels = 16;
|
text_area_.scroll_pixels = 16;
|
||||||
|
|||||||
@ -1274,8 +1274,8 @@ namespace nana
|
|||||||
|
|
||||||
attr.area.x += (attr.area.width - fit_size.width) / 2;
|
attr.area.x += (attr.area.width - fit_size.width) / 2;
|
||||||
attr.area.y += (attr.area.height - fit_size.height) / 2;
|
attr.area.y += (attr.area.height - fit_size.height) / 2;
|
||||||
attr.area = fit_size;
|
attr.area.dimension(fit_size);
|
||||||
img->stretch(::nana::rectangle{ size }, graph, attr.area);
|
img->stretch(rectangle{ size }, graph, attr.area);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
img->paste(graph, point{ attr.area.x + static_cast<int>(attr.area.width - size.width) / 2, attr.area.y + static_cast<int>(attr.area.height - size.height) / 2 });
|
img->paste(graph, point{ attr.area.x + static_cast<int>(attr.area.width - size.width) / 2, attr.area.y + static_cast<int>(attr.area.height - size.height) / 2 });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user