small fix, more comments

This commit is contained in:
qPCR4vir 2016-03-27 20:50:51 +02:00
parent 5779b979f7
commit c1f95c7f3c

View File

@ -329,7 +329,7 @@ namespace nana
struct column_t struct column_t
{ {
native_string_type text; ///< "text" header of the column number "index" with weigth "pixels" native_string_type text; ///< "text" header of the column number "index" with weigth "pixels"
unsigned pixels; unsigned pixels; ///< width
bool visible{true}; bool visible{true};
size_type index; size_type index;
std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> weak_ordering; std::function<bool(const std::string&, nana::any*, const std::string&, nana::any*, bool reverse)> weak_ordering;
@ -411,7 +411,7 @@ namespace nana
return cont_.back().index; return cont_.back().index;
} }
void item_width(size_type pos, unsigned width) void item_width(size_type pos, unsigned width) ///< set the column width
{ {
column(pos).pixels = width; column(pos).pixels = width;
} }
@ -428,7 +428,7 @@ namespace nana
return 0; return 0;
} }
unsigned pixels() const unsigned pixels() const ///< the visible width of the whole header
{ {
unsigned pixels = 0; unsigned pixels = 0;
for(auto & m : cont_) for(auto & m : cont_)
@ -471,12 +471,13 @@ namespace nana
{ {
if(x < static_cast<int>(col.pixels)) if(x < static_cast<int>(col.pixels))
return col.index; return col.index;
x -= col.pixels; if (col.visible)
x -= col.pixels;
} }
return npos; return npos;
} }
/// return the left position of the column originaly at index "pos" . /// return the left position and width (in variable *pixels) of the column originaly at index "pos" .
int item_pos(size_type pos, unsigned * pixels) const int item_pos(size_type pos, unsigned * pixels) const
{ {
int left = 0; int left = 0;
@ -494,7 +495,8 @@ namespace nana
} }
return left; return left;
} }
/// return the original index of the visible col currently before(in front of) or after the col originaly at index "index"
/// return the original index of the visible col currently before(in front of) or after the col originaly at index "index"
size_type neighbor(size_type index, bool front) const size_type neighbor(size_type index, bool front) const
{ {
size_type n = npos; size_type n = npos;
@ -510,11 +512,12 @@ namespace nana
break; break;
} }
else if(i->visible) else if(i->visible)
n = i->index; n = i->index;
} }
return npos; return npos;
} }
/// return the original index of the currently first visible col
/// return the original index of the currently first visible col
size_type begin() const size_type begin() const
{ {
for(const auto & m : cont_) for(const auto & m : cont_)
@ -533,7 +536,8 @@ namespace nana
} }
return npos; return npos;
} }
/// move the col originaly at index to the position currently in front (or after) the col originaly at index "to" invalidating some current index
/// move the col originaly at "index" to the position currently in front (or after) the col originaly at index "to" invalidating some current index
void move(size_type index, size_type to, bool front) throw() void move(size_type index, size_type to, bool front) throw()
{ {
if ((index == to) || (index >= cont_.size()) || (to >= cont_.size())) if ((index == to) || (index >= cont_.size()) || (to >= cont_.size()))
@ -880,7 +884,8 @@ namespace nana
list_.back().key_ptr = ptr; list_.back().key_ptr = ptr;
return &list_.back(); return &list_.back();
} }
/// add a new cat created at "pos" and return a ref to it
/// add a new cat created at "pos" and return a ref to it
category_t* create_cat(std::size_t pos, native_string_type&& text) category_t* create_cat(std::size_t pos, native_string_type&& text)
{ {
return &(*list_.emplace(this->get(pos), std::move(text))); return &(*list_.emplace(this->get(pos), std::move(text)));
@ -1941,8 +1946,8 @@ namespace nana
//number_of_lister_item //number_of_lister_item
//@brief: Returns the number of items that are contained in pixels /// @brief Returns the number of items that are contained in pixels
//@param,with_rest: Means whether including extra one item that is not completely contained in reset pixels. /// @param with_rest: Means whether including extra one item that is not completely contained in reset pixels.
size_type number_of_lister_items(bool with_rest) const size_type number_of_lister_items(bool with_rest) const
{ {
unsigned lister_s = graph->height() - 2 - header_visible_px() - (scroll.h.empty() ? 0 : scroll.scale); unsigned lister_s = graph->height() - 2 - header_visible_px() - (scroll.h.empty() ? 0 : scroll.scale);
@ -2072,10 +2077,10 @@ namespace nana
bool v = (lister.the_number_of_expanded() > screen_number); bool v = (lister.the_number_of_expanded() > screen_number);
if(v == true && h == false) if(v == true && h == false)
h = (header_s > (sz.width - 2 - scroll.scale)); h = ( (header_s + 2 + scroll.scale ) > sz.width); // 2?
unsigned width = sz.width - 2 - (v ? scroll.scale : 0); unsigned width = sz.width - 2 - (v ? scroll.scale : 0); // -? 2?
unsigned height = sz.height - 2 - (h ? scroll.scale : 0); unsigned height = sz.height - 2 - (h ? scroll.scale : 0); // -? 2?
//event hander for scrollbars //event hander for scrollbars
auto evt_fn = [this](const arg_scroll& arg) auto evt_fn = [this](const arg_scroll& arg)
@ -2168,7 +2173,8 @@ namespace nana
return (seq.size() ? (header.item_pos(seq[0], nullptr) - scroll.offset_x + r.x) : 0); return (seq.size() ? (header.item_pos(seq[0], nullptr) - scroll.offset_x + r.x) : 0);
} }
std::pair<parts, size_t> where(int x, int y){ std::pair<parts, size_t> where(int x, int y)
{
std::pair<parts, size_t> new_where; std::pair<parts, size_t> new_where;
if(2 < x && x < static_cast<int>(graph->width()) - 2 && 1 < y && y < static_cast<int>(graph->height()) - 1) if(2 < x && x < static_cast<int>(graph->width()) - 2 && 1 < y && y < static_cast<int>(graph->height()) - 1)
@ -2659,7 +2665,7 @@ namespace nana
item_spliter_ = hd.index; // original index item_spliter_ = hd.index; // original index
return true; return true;
} }
x -= hd.pixels; x -= hd.pixels;
} }
} }
} }
@ -2673,7 +2679,7 @@ namespace nana
if(is_grab) if(is_grab)
{ {
ref_xpos_ = pos.x; ref_xpos_ = pos.x;
if(item_spliter_ != npos) if(item_spliter_ != npos) // resize header item, not move it
orig_item_width_ = essence_->header.column(item_spliter_).pixels; orig_item_width_ = essence_->header.column(item_spliter_).pixels;
} }
else if(grab_terminal_.index != npos && grab_terminal_.index != essence_->pointer_where.second) else if(grab_terminal_.index != npos && grab_terminal_.index != essence_->pointer_where.second)
@ -2686,16 +2692,16 @@ namespace nana
int grab_move(const nana::rectangle& rect, const nana::point& pos) int grab_move(const nana::rectangle& rect, const nana::point& pos)
{ {
if(item_spliter_ == npos) if(item_spliter_ == npos)
{ { // move header item, not resize it
draw(rect); draw(rect); // first draw the entery header as it was
_m_make_float(rect, pos); _m_make_float(rect, pos); // now draw one floating header item
//Draw the target strip //Draw the target strip
grab_terminal_.index = _m_target_strip(pos.x, rect, essence_->pointer_where.second, grab_terminal_.place_front); grab_terminal_.index = _m_target_strip(pos.x, rect, essence_->pointer_where.second, grab_terminal_.place_front);
return 1; return 1;
} }
else else
{ { // resize header item, not move it
const auto& item = essence_->header.column(item_spliter_); const auto& item = essence_->header.column(item_spliter_);
//Resize the item specified by item_spliter_. //Resize the item specified by item_spliter_.
auto new_w = orig_item_width_ - (ref_xpos_ - pos.x); auto new_w = orig_item_width_ - (ref_xpos_ - pos.x);
@ -3350,18 +3356,18 @@ namespace nana
if(essence_->ptr_state == item_state::pressed) if(essence_->ptr_state == item_state::pressed)
{ {
if(essence_->pointer_where.first == parts::header) if(essence_->pointer_where.first == parts::header)
{ { // moving a pressed header : grab it (or split-resize?)
essence_->ptr_state = item_state::grabbed; essence_->ptr_state = item_state::grabbed;
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);
drawer_header_->grab(pos, true); drawer_header_->grab(pos, true);
API::capture_window(essence_->lister.wd_ptr()->handle(), true); API::capture_window(essence_->lister.wd_ptr()->handle(), true);
update = 2; update = 2; //0 = nothing, 1 = update, 2 = refresh
} }
} }
if(essence_->ptr_state == item_state::grabbed) if(essence_->ptr_state == item_state::grabbed)
{ { // moving a grabbed header
nana::point pos = arg.pos; nana::point pos = arg.pos;
essence_->widget_to_header(pos); essence_->widget_to_header(pos);
@ -3713,6 +3719,7 @@ namespace nana
//end class trigger //end class trigger
//class item_proxy //class item_proxy
item_proxy::item_proxy(essence_t * ess) item_proxy::item_proxy(essence_t * ess)
: ess_(ess) : ess_(ess)
{} {}
@ -3985,6 +3992,7 @@ namespace nana
//end class item_proxy //end class item_proxy
//class cat_proxy //class cat_proxy
//the member cat_ is used for fast accessing to the category //the member cat_ is used for fast accessing to the category
cat_proxy::cat_proxy(essence_t * ess, size_type pos) cat_proxy::cat_proxy(essence_t * ess, size_type pos)
: ess_(ess), : ess_(ess),
@ -4315,6 +4323,7 @@ namespace nana
//Implementation of arg_category //Implementation of arg_category
//Contributed by leobackes(pr#97) //Contributed by leobackes(pr#97)
arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat ) noexcept arg_category::arg_category ( const nana::drawerbase::listbox::cat_proxy& cat ) noexcept
: category(cat), block_change_(false) : category(cat), block_change_(false)
{ {
@ -4332,6 +4341,7 @@ namespace nana
//class listbox //class listbox
listbox::listbox(window wd, bool visible) listbox::listbox(window wd, bool visible)
{ {
create(wd, rectangle(), visible); create(wd, rectangle(), visible);