refactor text_renderer
This commit is contained in:
@@ -140,7 +140,7 @@ namespace nana
|
||||
|
||||
//draw caption
|
||||
auto text = to_wstring(API::window_caption(window_handle_));
|
||||
text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, true);
|
||||
text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
|
||||
//draw x button
|
||||
auto r = _m_button_area();
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace nana{ namespace drawerbase
|
||||
graph.palette(true, text_color);
|
||||
|
||||
if (attr_.omitted)
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
else
|
||||
#ifdef _nana_std_has_string_view
|
||||
graph.bidi_string(pos, { txtptr, txtlen });
|
||||
@@ -276,9 +276,9 @@ namespace nana{ namespace drawerbase
|
||||
graph.palette(true, color{ colors::white });
|
||||
if(attr_.omitted)
|
||||
{
|
||||
tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true);
|
||||
tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
graph.palette(true, color{ colors::gray });
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, true);
|
||||
tr.render(pos, txtptr, txtlen, omitted_pixels, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -70,13 +70,13 @@ namespace nana{ namespace drawerbase
|
||||
if (!wdg->enabled())
|
||||
{
|
||||
graph.palette(true, colors::white);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
|
||||
tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels, paint::text_renderer::mode::word_wrap);
|
||||
graph.palette(true, static_cast<color_rgb>(0x808080));
|
||||
}
|
||||
else
|
||||
graph.palette(true, wdg->fgcolor());
|
||||
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
|
||||
tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels, paint::text_renderer::mode::word_wrap);
|
||||
}
|
||||
|
||||
//draw crook
|
||||
|
||||
@@ -2059,6 +2059,11 @@ namespace nana
|
||||
};
|
||||
}
|
||||
|
||||
unsigned suspension_width() const
|
||||
{
|
||||
return (graph ? graph->text_extent_size(L"...").width : 0);
|
||||
}
|
||||
|
||||
bool cs_status(index_pair abs_pos, bool for_selection) const
|
||||
{
|
||||
if (abs_pos.is_category())
|
||||
@@ -3352,7 +3357,7 @@ namespace nana
|
||||
else
|
||||
{
|
||||
//Default scheme
|
||||
new_w = (std::max)(new_w, essence_->scheme_ptr->suspension_width + essence_->scheme_ptr->min_column_width);
|
||||
new_w = (std::max)(new_w, essence_->suspension_width() + essence_->scheme_ptr->min_column_width);
|
||||
}
|
||||
|
||||
if(col.width_px != new_w)
|
||||
@@ -3997,6 +4002,7 @@ namespace nana
|
||||
|
||||
if (draw_column)
|
||||
{
|
||||
//Draw item text
|
||||
paint::aligner text_aligner{*graph, col.alignment};
|
||||
|
||||
unsigned text_margin_right = 0;
|
||||
@@ -4142,7 +4148,6 @@ namespace nana
|
||||
if (graph.text_metrics(as, ds, il))
|
||||
essence_->text_height = as + ds;
|
||||
|
||||
essence_->scheme_ptr->suspension_width = graph.text_extent_size("...").width;
|
||||
essence_->calc_content_size(true);
|
||||
}
|
||||
|
||||
@@ -6114,6 +6119,12 @@ namespace nana
|
||||
_m_ess().pred_msup_deselect = std::move(predicate);
|
||||
}
|
||||
|
||||
unsigned listbox::suspension_width() const
|
||||
{
|
||||
nana::internal_scope_guard lock;
|
||||
return _m_ess().suspension_width();
|
||||
}
|
||||
|
||||
drawerbase::listbox::essence & listbox::_m_ess() const
|
||||
{
|
||||
return get_drawer_trigger().ess();
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace nana
|
||||
nana::paint::text_renderer tr(graph);
|
||||
|
||||
auto wstr = to_wstring(text);
|
||||
tr.render(pos, wstr.c_str(), wstr.length(), text_pixels, true);
|
||||
tr.render(pos, wstr.c_str(), wstr.length(), text_pixels, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
}
|
||||
|
||||
void sub_arrow(graph_reference graph, const nana::point& pos, unsigned pixels, const attr&)
|
||||
|
||||
@@ -1050,7 +1050,7 @@ namespace nana
|
||||
|
||||
std::wstring wtext = to_wstring(item.text);
|
||||
tr.render({ m.r.x + 24, m.r.y + static_cast<int>(m.r.height - ts.height) / 2 },
|
||||
wtext.c_str(), wtext.length(), basis_.item_pixels - 24 - 18, true);
|
||||
wtext.c_str(), wtext.length(), basis_.item_pixels - 24 - 18, paint::text_renderer::mode::truncate_with_ellipsis);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user