refine code
fix bug that listbox may throw std::runtime when the modal is enabled fix bug that textbox attachs a wrong event angent
This commit is contained in:
@@ -285,8 +285,7 @@ namespace nana{ namespace drawerbase
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ui_container_.push_back(el);
|
||||
ui_container_.emplace_back(el);
|
||||
}
|
||||
|
||||
std::size_t radio_group::checked() const
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace nana
|
||||
editor_->show_caret(enb);
|
||||
if (!enb)
|
||||
{
|
||||
editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&)
|
||||
editor_->customized_renderers().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&)
|
||||
{
|
||||
auto clr_from = colors::button_face_shadow_start;
|
||||
auto clr_to = colors::button_face_shadow_end;
|
||||
@@ -190,7 +190,7 @@ namespace nana
|
||||
};
|
||||
}
|
||||
else
|
||||
editor_->ext_renderer().background = nullptr;
|
||||
editor_->customized_renderers().background = nullptr;
|
||||
|
||||
editor_->enable_background(enb);
|
||||
editor_->enable_background_counterpart(!enb);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <nana/gui/widgets/float_listbox.hpp>
|
||||
#include <nana/gui/widgets/scroll.hpp>
|
||||
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace drawerbase{
|
||||
@@ -66,35 +68,7 @@ namespace nana
|
||||
unsigned vpix = (r.height - 4);
|
||||
if(item->image())
|
||||
{
|
||||
nana::size imgsz = item->image().size();
|
||||
if(imgsz.width > image_pixels_)
|
||||
{
|
||||
unsigned new_h = image_pixels_ * imgsz.height / imgsz.width;
|
||||
if(new_h > vpix)
|
||||
{
|
||||
imgsz.width = vpix * imgsz.width / imgsz.height;
|
||||
imgsz.height = vpix;
|
||||
}
|
||||
else
|
||||
{
|
||||
imgsz.width = image_pixels_;
|
||||
imgsz.height = new_h;
|
||||
}
|
||||
}
|
||||
else if(imgsz.height > vpix)
|
||||
{
|
||||
unsigned new_w = vpix * imgsz.width / imgsz.height;
|
||||
if(new_w > image_pixels_)
|
||||
{
|
||||
imgsz.height = image_pixels_ * imgsz.height / imgsz.width;
|
||||
imgsz.width = image_pixels_;
|
||||
}
|
||||
else
|
||||
{
|
||||
imgsz.height = vpix;
|
||||
imgsz.width = new_w;
|
||||
}
|
||||
}
|
||||
auto imgsz = nana::fit_zoom(item->image().size(), {image_pixels_, vpix});
|
||||
|
||||
nana::point to_pos(x, r.y + 2);
|
||||
to_pos.x += (image_pixels_ - imgsz.width) / 2;
|
||||
|
||||
@@ -206,15 +206,13 @@ namespace nana
|
||||
{
|
||||
if(fbp->target.size() || fbp->url.size())
|
||||
{
|
||||
traceable tr;
|
||||
traceable_.emplace_back();
|
||||
auto & tr = traceable_.back();
|
||||
tr.r.x = x;
|
||||
tr.r.y = y;
|
||||
tr.r.width = sz.width;
|
||||
tr.r.height = sz.height;
|
||||
tr.r.dimension(sz);
|
||||
tr.target = fbp->target;
|
||||
tr.url = fbp->url;
|
||||
|
||||
traceable_.push_back(tr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +329,7 @@ namespace nana
|
||||
px.pixels = def_line_pixels;
|
||||
px.x_base = 0;
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -374,7 +372,7 @@ namespace nana
|
||||
if(max_ascent < as) max_ascent = as;
|
||||
if(max_descent < ds) max_descent = ds;
|
||||
if(max_px < sz.height) max_px = sz.height;
|
||||
line_values.push_back(i);
|
||||
line_values.emplace_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,13 +391,13 @@ namespace nana
|
||||
px.baseline = max_ascent;
|
||||
px.values.swap(line_values);
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
|
||||
w = sz.width;
|
||||
max_px = sz.height;
|
||||
max_ascent = as;
|
||||
max_descent = ds;
|
||||
line_values.push_back(i);
|
||||
line_values.emplace_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -409,9 +407,9 @@ namespace nana
|
||||
px.pixels = sz.height;
|
||||
px.baseline = as;
|
||||
|
||||
px.values.push_back(i);
|
||||
px.values.emplace_back(i);
|
||||
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
max_px = 0;
|
||||
max_ascent = max_descent = 0;
|
||||
}
|
||||
@@ -432,7 +430,7 @@ namespace nana
|
||||
px.pixels = max_px;
|
||||
px.baseline = max_ascent;
|
||||
px.values.swap(line_values);
|
||||
rs.pixels.push_back(px);
|
||||
rs.pixels.emplace_back(px);
|
||||
}
|
||||
return total_w;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <nana/system/dataexch.hpp>
|
||||
#include <cassert>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@@ -972,6 +973,7 @@ namespace nana
|
||||
|
||||
if (catobj.model_ptr)
|
||||
{
|
||||
throw_if_immutable_model(catobj.model_ptr.get());
|
||||
auto container = catobj.model_ptr->container();
|
||||
std::size_t item_index;
|
||||
//
|
||||
@@ -1249,28 +1251,17 @@ namespace nana
|
||||
return n;
|
||||
}
|
||||
|
||||
std::vector<cell>& get_cells(category_t * cat, std::size_t pos) const
|
||||
std::vector<cell> get_cells(category_t * cat, std::size_t pos) const
|
||||
{
|
||||
if (!cat)
|
||||
throw std::out_of_range("nana::listbox: category is null");
|
||||
|
||||
if (cat->model_ptr)
|
||||
throw std::runtime_error("nana::listbox disallow to get item cells, because there are model cells");
|
||||
return cat->model_ptr->container()->to_cells(pos);
|
||||
|
||||
return *(cat->items.at(pos).cells);
|
||||
}
|
||||
|
||||
std::vector<cell> get_model_cells(category_t* cat, std::size_t pos) const
|
||||
{
|
||||
if (!cat)
|
||||
throw std::out_of_range("nana::listbox: category is null");
|
||||
|
||||
if (!(cat->model_ptr))
|
||||
throw std::runtime_error("nana::listbox: the category hasn't a model");
|
||||
|
||||
return cat->model_ptr->container()->to_cells(pos);
|
||||
}
|
||||
|
||||
void text(category_t* cat, size_type pos, size_type col, cell&& cl, size_type columns)
|
||||
{
|
||||
if ((col < columns) && (pos < cat->items.size()))
|
||||
@@ -2868,8 +2859,8 @@ namespace nana
|
||||
return *this;
|
||||
}
|
||||
|
||||
iresolver::iresolver(const std::vector<cell>& cl)
|
||||
: cells_(cl)
|
||||
iresolver::iresolver(std::vector<cell> cl)
|
||||
: cells_(std::move(cl))
|
||||
{}
|
||||
|
||||
iresolver& iresolver::operator>>(cell& cl)
|
||||
@@ -4565,14 +4556,6 @@ namespace nana
|
||||
|
||||
std::string item_proxy::text(size_type col) const
|
||||
{
|
||||
if (cat_->model_ptr)
|
||||
{
|
||||
auto cells = cat_->model_ptr->container()->to_cells(pos_.item);
|
||||
if (col < cells.size())
|
||||
return cells[col].text;
|
||||
|
||||
return{};
|
||||
}
|
||||
return ess_->lister.get_cells(cat_, pos_.item).at(col).text;
|
||||
}
|
||||
|
||||
@@ -4692,7 +4675,7 @@ namespace nana
|
||||
return pos_;
|
||||
}
|
||||
|
||||
auto item_proxy::_m_cells() const -> std::vector<cell>&
|
||||
auto item_proxy::_m_cells() const -> std::vector<cell>
|
||||
{
|
||||
return ess_->lister.get_cells(cat_, pos_.item);
|
||||
}
|
||||
@@ -5027,9 +5010,24 @@ namespace nana
|
||||
|
||||
internal_scope_guard lock;
|
||||
|
||||
cat_->sorted.push_back(cat_->items.size());
|
||||
cells.resize(columns());
|
||||
cat_->items.emplace_back(std::move(cells));
|
||||
if (cat_->model_ptr)
|
||||
{
|
||||
es_lister::throw_if_immutable_model(cat_->model_ptr.get());
|
||||
|
||||
auto container = cat_->model_ptr->container();
|
||||
|
||||
auto item_index = container->size();
|
||||
cat_->items.emplace_back();
|
||||
container->emplace_back();
|
||||
|
||||
container->assign(item_index, cells);
|
||||
}
|
||||
else
|
||||
{
|
||||
cat_->sorted.push_back(cat_->items.size());
|
||||
cells.resize(columns());
|
||||
cat_->items.emplace_back(std::move(cells));
|
||||
}
|
||||
|
||||
assign_colors_for_last(ess_, cat_);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <nana/gui/wvl.hpp>
|
||||
#include <nana/paint/text_renderer.hpp>
|
||||
#include <cctype> //introduces tolower
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
|
||||
#include <nana/gui/widgets/slider.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
#include <cstring> //memcpy
|
||||
|
||||
namespace nana
|
||||
@@ -645,7 +646,6 @@ namespace nana
|
||||
{
|
||||
adorn.bound.x = static_cast<int>(attr_.adorn_pos + attr_.slider.border_weight + bar.area.y);
|
||||
adorn.bound.y = static_cast<int>(graph.height()) - static_cast<int>(attr_.slider.border_weight + bar.area.y);
|
||||
//adorn.bound.x =
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -65,7 +65,6 @@ namespace drawerbase {
|
||||
{
|
||||
auto wd = wdg.handle();
|
||||
widget_ = &wdg;
|
||||
evt_agent_.reset(new event_agent(static_cast<::nana::textbox&>(wdg), editor_->text_position()));
|
||||
|
||||
auto scheme = API::dev::get_scheme(wdg);
|
||||
|
||||
@@ -73,6 +72,8 @@ namespace drawerbase {
|
||||
editor_->textbase().set_event_agent(evt_agent_.get());
|
||||
editor_->set_event(evt_agent_.get());
|
||||
|
||||
evt_agent_.reset(new event_agent(static_cast<::nana::textbox&>(wdg), editor_->text_position()));
|
||||
|
||||
_m_text_area(graph.width(), graph.height());
|
||||
|
||||
API::tabstop(wd);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <nana/gui/layout_utility.hpp>
|
||||
#include <nana/system/platform.hpp>
|
||||
#include <stdexcept>
|
||||
#include <map>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user