Remove wxListCtrl::EnableSortIndicator()

The old API seems unnecessarily complex, it is simpler to just let the
application call ShowSortIndicator() itself from its
wxEVT_LIST_COL_CLICK handler, which needs to be defined anyhow in order
to actually sort the items, rather than require it to enable sort
indicator, explicitly set it initially and then remember to not set it
any longer in response to the column clicks.

Also make RemoveSortIndicator() non-virtual and implement it simply as
ShowSortIndicator(-1) because this actually simplifies the code too.
This commit is contained in:
Vadim Zeitlin
2021-12-14 01:06:21 +00:00
parent 30ce892ed5
commit 52649cc566
8 changed files with 33 additions and 142 deletions

View File

@@ -1420,40 +1420,15 @@ public:
*/
void ExtendRulesAndAlternateColour(bool extend = true);
/**
Enable or disable showing a sort indicator in the header bar.
Sort indicators are only shown in report view.
When clicking on the header of a column, this column will get the sort-
indicator in ascending order, or toggle it in the opposite order. To
sort the list, call SortItems() in EVT_LIST_COL_CLICK.
Note that calling ShowSortIndicator() implicitly enables sort
indicators.
@note In wxMSW, this will disable the header icon of the column.
@param enable
If @true, enable showing a sort indicator, otherwise disable.
@since 3.1.6
*/
void EnableSortIndicator(bool enable);
/**
Returns true if a sort indicator is enabled.
@see EnableSortIndicator()
@since 3.1.6
*/
bool IsSortIndicatorEnabled() const;
/**
Show the sort indicator of a specific column in a specific direction.
This function also enables showing sort indicators if
EnableSortIndicator() hadn't been called.
Sort indicators are only shown in report view and in the native wxMSW
version override any column icon, i.e. if the sort indicator is shown
for a column, no (other) icon is shown.
This function should typically be called from EVT_LIST_COL_CLICK
handler.
@note This does not actually sort the list, use SortItems() for this.
@@ -1479,6 +1454,8 @@ public:
/**
Returns the column that shows the sort indicator.
Can return @c -1 if there is no sort indicator currently shown.
@since 3.1.6
*/
int GetSortIndicator() const;