Merge branch 'develop'

This commit is contained in:
Jinhao 2015-12-09 00:31:32 +08:00
commit 22ddc02184
4 changed files with 53 additions and 19 deletions

View File

@ -287,12 +287,12 @@ namespace nana
tabbar& append(std::wstring text, window attach_wd, value_type value = {}) tabbar& append(std::wstring text, window attach_wd, value_type value = {})
{ {
if (attach_wd && API::empty_window(attach_wd))
throw std::invalid_argument("tabbar.attach: invalid window handle");
this->get_drawer_trigger().insert(::nana::npos, std::move(text), std::move(value)); this->get_drawer_trigger().insert(::nana::npos, std::move(text), std::move(value));
if (attach_wd) if (attach_wd)
{ this->attach(this->get_drawer_trigger().length() - 1, attach_wd);
auto pos = this->get_drawer_trigger().length();
relate(pos, attach_wd);
}
API::update_window(*this); API::update_window(*this);
return *this; return *this;
@ -324,9 +324,12 @@ namespace nana
this->get_drawer_trigger().attach(pos, wd); this->get_drawer_trigger().attach(pos, wd);
} }
void attach(std::size_t pos, window wd) void attach(std::size_t pos, window attach_wd)
{ {
this->get_drawer_trigger().attach(pos, wd); if (attach_wd && API::empty_window(attach_wd))
throw std::invalid_argument("tabbar.attach: invalid window handle");
this->get_drawer_trigger().attach(pos, attach_wd);
} }
void erase(std::size_t pos) void erase(std::size_t pos)

View File

@ -24,12 +24,12 @@ namespace nana
//class window_layout //class window_layout
void window_layout::paint(core_window_t* wd, bool is_redraw, bool is_child_refreshed) void window_layout::paint(core_window_t* wd, bool is_redraw, bool is_child_refreshed)
{ {
if (wd->flags.refreshing || wd->drawer.graphics.empty()) if (wd->flags.refreshing)
return; return;
if (nullptr == wd->effect.bground) if (nullptr == wd->effect.bground)
{ {
if (is_redraw) if (is_redraw && (!wd->drawer.graphics.empty()))
{ {
wd->flags.refreshing = true; wd->flags.refreshing = true;
wd->drawer.refresh(); wd->drawer.refresh();
@ -305,7 +305,10 @@ namespace nana
void window_layout::_m_paint_glass_window(core_window_t* wd, bool is_redraw, bool is_child_refreshed, bool called_by_notify, bool notify_other) void window_layout::_m_paint_glass_window(core_window_t* wd, bool is_redraw, bool is_child_refreshed, bool called_by_notify, bool notify_other)
{ {
if (wd->flags.refreshing && is_redraw) return; //A window which has an empty graphics(and lite-widget) does not notify
//glass windows for updating their background.
if ((wd->flags.refreshing && is_redraw) || wd->drawer.graphics.empty())
return;
nana::rectangle vr; nana::rectangle vr;
if (read_visual_rectangle(wd, vr)) if (read_visual_rectangle(wd, vr))

View File

@ -2006,23 +2006,50 @@ namespace nana
void adjust_scroll_value() void adjust_scroll_value()
{ {
const auto graph_size = graph->size();
if(scroll.h.empty() == false) if(scroll.h.empty() == false)
{ {
unsigned width = 4 + (scroll.v.empty() ? 0 : scroll.scale - 1); const auto ext_px = (4 + (scroll.v.empty() ? 0 : scroll.scale - 1));
if(width >= graph->width()) return; if (ext_px > graph_size.width)
scroll.h.amount(header.pixels()); return;
scroll.h.range(graph->width() - width);
const auto header_px = header.pixels();
const unsigned window_px = graph_size.width - (4 + (scroll.v.empty() ? 0 : scroll.scale - 1));
if (header_px < window_px + scroll.offset_x)
{
scroll.offset_x = header_px - window_px;
}
scroll.h.amount(header_px);
scroll.h.range(window_px);
scroll.h.value(scroll.offset_x); scroll.h.value(scroll.offset_x);
scroll.h.step(graph->text_extent_size(L"W").width); scroll.h.step(graph->text_extent_size(L"W").width);
} }
if(scroll.v.empty() == false) if(scroll.v.empty() == false)
{ {
unsigned height = 2 + (scroll.h.empty() ? 0 : scroll.scale); const auto ext_px = 2 + (scroll.h.empty() ? 0 : scroll.scale);
if(height >= graph->height()) return; if (ext_px >= graph_size.height)
return;
const auto items = lister.the_number_of_expanded();
const auto disp_items = number_of_lister_items(false);
size_type off = lister.distance({ 0, 0 }, scroll.offset_y_dpl);
if (items < disp_items + off)
{
index_pair pos;
if (lister.forward({ 0, 0 }, items - disp_items, pos))
{
off = items - disp_items;
set_scroll_y_dpl(pos);
}
}
scroll.v.amount(lister.the_number_of_expanded()); scroll.v.amount(lister.the_number_of_expanded());
scroll.v.range(number_of_lister_items(false)); scroll.v.range(number_of_lister_items(false));
size_type off = lister.distance({0,0}, scroll.offset_y_dpl );
scroll.v.value(off); scroll.v.value(off);
} }
} }
@ -3139,7 +3166,7 @@ namespace nana
graph->set_text_color(cell_txtcolor); graph->set_text_color(cell_txtcolor);
graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text); // draw full text of the cell index (column) graph->string(point{ item_xpos + content_pos, y + txtoff }, m_cell.text); // draw full text of the cell index (column)
if (ts.width + static_cast<unsigned>(content_pos) > header.pixels) // it was an excess if (static_cast<int>(ts.width) > static_cast<int>(header.pixels) - (content_pos + item_xpos)) // it was an excess
{ {
//The text is painted over the next subitem // here beging the ... //The text is painted over the next subitem // here beging the ...
int xpos = item_xpos + static_cast<int>(header.pixels) - static_cast<int>(essence_->suspension_width); int xpos = item_xpos + static_cast<int>(header.pixels) - static_cast<int>(essence_->suspension_width);
@ -3148,8 +3175,8 @@ namespace nana
graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true); graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true);
graph->string(point{ xpos, y + 2 }, STR("...")); graph->string(point{ xpos, y + 2 }, STR("..."));
//Erase the part that over the next subitem. //Erase the part that over the next subitem only if the right of column is less than right of listbox
if (display_order + 1 < seqs.size()) // this is not the last column if (item_xpos + content_pos < content_r.right() - static_cast<int>(header.pixels))
{ {
graph->set_color(bgcolor); // we need to erase the excess, because some cell may not draw text over graph->set_color(bgcolor); // we need to erase the excess, because some cell may not draw text over
graph->rectangle(rectangle{ item_xpos + static_cast<int>(header.pixels), y + 2, graph->rectangle(rectangle{ item_xpos + static_cast<int>(header.pixels), y + 2,

View File

@ -608,6 +608,7 @@ namespace nana
if (pos >= list_.size()) if (pos >= list_.size())
throw std::out_of_range("tabbar: invalid position"); throw std::out_of_range("tabbar: invalid position");
iterator_at(pos)->relative = wd;
API::show_window(wd, basis_.active == pos); API::show_window(wd, basis_.active == pos);
} }