new feature "fit_width_to_header caption text" for a new header with width=0
(cherry picked from commit 23efa5088d742a48e7ad07f273e84bcf50c2d979)
This commit is contained in:
parent
a1b97e48b5
commit
74f42f1778
@ -167,7 +167,7 @@ namespace nana
|
||||
|
||||
column(column&& other):
|
||||
caption(std::move(other.caption)),
|
||||
width_px(other.width_px),
|
||||
width_px(other.width_px),
|
||||
range_width_px(other.range_width_px),
|
||||
visible_state(other.visible_state),
|
||||
index(other.index),
|
||||
@ -184,7 +184,13 @@ namespace nana
|
||||
index(pos),
|
||||
ess_(ess)
|
||||
{
|
||||
if (px == 0)
|
||||
{
|
||||
fit_width_to_header();
|
||||
}
|
||||
}
|
||||
|
||||
void fit_width_to_header();
|
||||
private:
|
||||
/// The definition is provided after essence
|
||||
void _m_refresh() noexcept;
|
||||
@ -2881,6 +2887,23 @@ namespace nana
|
||||
return max_px;
|
||||
}
|
||||
|
||||
void es_header::column::fit_width_to_header()
|
||||
{
|
||||
std::cout<< "Column: " << to_utf8(caption) ;
|
||||
std::unique_ptr<paint::graphics> graph_helper;
|
||||
auto graph = ess_->graph;
|
||||
if (graph->empty())
|
||||
{
|
||||
//Creates a helper if widget graph is empty(when its size is 0).
|
||||
graph_helper.reset(new paint::graphics{ nana::size{ 5, 5 } });
|
||||
graph_helper->typeface(ess_->graph->typeface());
|
||||
graph = graph_helper.get();
|
||||
}
|
||||
width_px = ess_->scheme_ptr->text_margin * 2; //margin at left/right end.
|
||||
|
||||
width_px += graph->text_extent_size(caption).width;
|
||||
}
|
||||
|
||||
//es_header::column member functions
|
||||
void es_header::column::_m_refresh() noexcept
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user