Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add listbox::items() method to get all items index_pairs #613

Open
wants to merge 1 commit into
base: develop-1.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/nana/gui/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ the nana::detail::basic_window member pointer scheme
///< Prevent sorting until `freeze` is set to false.
bool freeze_sort(bool freeze);

index_pairs items() const; ///<Get the absolute indexes of all items
index_pairs selected() const; ///<Get the absolute indexes of all the selected items

void show_header(bool);
Expand Down
25 changes: 25 additions & 0 deletions source/gui/widgets/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,25 @@ namespace nana
return changed;
}

index_pairs pick_items() const
{
index_pairs results;
index_pair id;

for (auto& cat : categories_)
{
id.item = 0;
for (auto& m : cat.items)
{
results.push_back(id); // absolute positions, no relative to display

++id.item;
}
++id.cat;
}
return results;
}

/// return absolute positions, no relative to display
/**
* @param for_selection Indicates whether the selected items or checked items to be returned.
Expand Down Expand Up @@ -6100,6 +6119,12 @@ namespace nana
return !_m_ess().lister.active_sort(!freeze);
}

auto listbox::items() const -> index_pairs
{
internal_scope_guard lock;
return _m_ess().lister.pick_items(); // absolute positions, no relative to display
}

auto listbox::selected() const -> index_pairs
{
internal_scope_guard lock;
Expand Down