add methods for listbox visible range
This commit is contained in:
parent
07a971c6ef
commit
54cfd3075d
@ -1555,6 +1555,27 @@ the nana::detail::basic_window member pointer scheme
|
|||||||
* @return the reference of *this.
|
* @return the reference of *this.
|
||||||
*/
|
*/
|
||||||
listbox& category_icon(const paint::image& img_expanded, const paint::image&& img_collapsed);
|
listbox& category_icon(const paint::image& img_expanded, const paint::image&& img_collapsed);
|
||||||
|
|
||||||
|
/// Returns first visible element
|
||||||
|
/**
|
||||||
|
* It may return an item or a category item.
|
||||||
|
* @return the index of first visible element.
|
||||||
|
*/
|
||||||
|
index_pair first_visible() const;
|
||||||
|
|
||||||
|
/// Returns last visible element
|
||||||
|
/**
|
||||||
|
* It may return an item or a category item.
|
||||||
|
* @return the index of last visible element.
|
||||||
|
*/
|
||||||
|
index_pair last_visible() const;
|
||||||
|
|
||||||
|
/// Returns all visible items
|
||||||
|
/**
|
||||||
|
* It returns all visible items that are displayed in listbox window.
|
||||||
|
* @return index_pairs containing all visible items.
|
||||||
|
*/
|
||||||
|
index_pairs visibles() const;
|
||||||
private:
|
private:
|
||||||
drawerbase::listbox::essence & _m_ess() const;
|
drawerbase::listbox::essence & _m_ess() const;
|
||||||
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const override;
|
nana::any* _m_anyobj(size_type cat, size_type index, bool allocate_if_empty) const override;
|
||||||
|
@ -5989,6 +5989,54 @@ namespace nana
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto listbox::first_visible() const ->index_pair
|
||||||
|
{
|
||||||
|
return _m_ess().first_display();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto listbox::last_visible() const -> index_pair
|
||||||
|
{
|
||||||
|
return _m_ess().lister.advance(_m_ess().first_display(), _m_ess().count_of_exposed(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto listbox::visibles() const -> index_pairs
|
||||||
|
{
|
||||||
|
index_pairs indexes;
|
||||||
|
|
||||||
|
auto idx = _m_ess().first_display();
|
||||||
|
|
||||||
|
auto n = _m_ess().count_of_exposed(true);
|
||||||
|
while (n > 0)
|
||||||
|
{
|
||||||
|
if (idx.empty())
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (idx.is_category())
|
||||||
|
{
|
||||||
|
indexes.push_back(idx);
|
||||||
|
--n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto const count = (std::min)(_m_ess().lister.size_item(idx.cat) - idx.item, n);
|
||||||
|
for (std::size_t i = 0; i < count; ++i)
|
||||||
|
{
|
||||||
|
indexes.push_back(idx);
|
||||||
|
++idx.item;
|
||||||
|
}
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
n -= count;
|
||||||
|
--idx.item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
idx = _m_ess().lister.advance(idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return indexes;
|
||||||
|
}
|
||||||
|
|
||||||
drawerbase::listbox::essence & listbox::_m_ess() const
|
drawerbase::listbox::essence & listbox::_m_ess() const
|
||||||
{
|
{
|
||||||
return get_drawer_trigger().ess();
|
return get_drawer_trigger().ess();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user