Add GetUpdatedAscendingSortIndicator() helper function

It seems like this function will need to be used in every implementation
of EVT_LIST_COL_CLICK handler when using sorting, so it makes sense to
provide it in the library itself.
This commit is contained in:
Vadim Zeitlin
2021-12-14 14:22:08 +00:00
parent 0a8e82b010
commit c834c0b8b7
3 changed files with 32 additions and 8 deletions

View File

@@ -1460,6 +1460,31 @@ public:
*/
int GetSortIndicator() const;
/**
Returns the new value to use for sort indicator after clicking a
column.
This helper function can be useful in the EVT_LIST_COL_CLICK handler
when it updates the sort indicator after the user clicked on a column.
For example:
@code
void MyListCtrl::OnColClick(wxListEvent& event)
{
int col = event.GetColumn();
if ( col == -1 )
return; // clicked outside any column.
const bool ascending = GetUpdatedAscendingSortIndicator(col);
SortItems(MyCompareFunction, ascending);
ShowSortIndicator(col, ascending);
}
@endcode
@since 3.1.6
*/
bool GetUpdatedAscendingSortIndicator(int col) const;
/**
Returns @true if the sort indicator direction is ascending,
@false when the direction is descending.