Commit 2b20186c authored by twanvl's avatar twanvl

Use built in sort indicator of ListView control (on windows), wx doesn't...

Use built in sort indicator of ListView control (on windows), wx doesn't provide this, so we do some Win32 programming.
parent fd6ebfee
...@@ -201,13 +201,27 @@ void ItemList::sortBy(long column, bool ascending) { ...@@ -201,13 +201,27 @@ void ItemList::sortBy(long column, bool ascending) {
} }
void ItemList::SetColumnImage(int col, int image) { void ItemList::SetColumnImage(int col, int image) {
#if defined(__WXMSW__) && defined(HDF_SORTUP)
if ( wxApp::GetComCtl32Version() >= 470 ) {
// use built in sort indicator
HWND header = ListView_GetHeader(GetHwnd());
HDITEM header_item = {0};
header_item.mask = HDI_FORMAT;
Header_GetItem(header, col, &header_item);
header_item.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);
if (image == 0) header_item.fmt |= HDF_SORTUP;
if (image == 1) header_item.fmt |= HDF_SORTDOWN;
Header_SetItem(header, col, &header_item);
return;
}
#endif
// The wx version of this function is broken, // The wx version of this function is broken,
// setting the wxLIST_MASK_IMAGE also sets the FORMAT flag, so we lose alignment info // setting the wxLIST_MASK_IMAGE also sets the FORMAT flag, so we lose alignment info
wxListItem item; wxListItem item;
item.SetMask(wxLIST_MASK_IMAGE | wxLIST_MASK_FORMAT); item.SetMask(wxLIST_MASK_IMAGE | wxLIST_MASK_FORMAT);
GetColumn(col, item); GetColumn(col, item);
item.SetImage(image); item.SetImage(image);
SetColumn(col, item); SetColumn(col, item);
} }
// ----------------------------------------------------------------------------- : ItemList : Window events // ----------------------------------------------------------------------------- : ItemList : Window events
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment