From 2874a19701c7b85856851106d57dba4e9c17ea0a Mon Sep 17 00:00:00 2001 From: twanvl Date: Mon, 10 Jan 2011 22:22:48 +0000 Subject: [PATCH] Use built in sort indicator of ListView control (on windows), wx doesn't provide this, so we do some Win32 programming. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1612 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/item_list.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/control/item_list.cpp b/src/gui/control/item_list.cpp index ef1eab83..33096da3 100644 --- a/src/gui/control/item_list.cpp +++ b/src/gui/control/item_list.cpp @@ -201,13 +201,27 @@ void ItemList::sortBy(long column, bool ascending) { } 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, // setting the wxLIST_MASK_IMAGE also sets the FORMAT flag, so we lose alignment info wxListItem item; item.SetMask(wxLIST_MASK_IMAGE | wxLIST_MASK_FORMAT); GetColumn(col, item); - item.SetImage(image); - SetColumn(col, item); + item.SetImage(image); + SetColumn(col, item); } // ----------------------------------------------------------------------------- : ItemList : Window events