diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index e4f69aec2d..0fac7af910 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -68,10 +68,17 @@ public: virtual void SetFlags(int flags) { m_flags = flags; UpdateDisplay(); } virtual int GetFlags() const { return m_flags; } - virtual void SetAsSortKey(bool sort = true) { m_sort = sort; UpdateDisplay(); } virtual bool IsSortKey() const { return m_sort; } - virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; UpdateDisplay(); } + virtual void UnsetAsSortKey() { m_sort = false; UpdateDisplay(); } + + virtual void SetSortOrder(bool ascending) + { + m_sort = true; + m_sortAscending = ascending; + UpdateDisplay(); + } + virtual bool IsSortOrderAscending() const { return m_sortAscending; } virtual void SetBitmap( const wxBitmap& bitmap ) { wxDataViewColumnBase::SetBitmap(bitmap); UpdateDisplay(); } diff --git a/include/wx/gtk/dataview.h b/include/wx/gtk/dataview.h index 8a4e12c354..134e422b97 100644 --- a/include/wx/gtk/dataview.h +++ b/include/wx/gtk/dataview.h @@ -44,7 +44,6 @@ public: virtual void SetSortable( bool sortable ); virtual void SetSortOrder( bool ascending ); - virtual void SetAsSortKey(bool sort = true); virtual void SetResizeable( bool resizable ); virtual void SetHidden( bool hidden ); diff --git a/include/wx/headercol.h b/include/wx/headercol.h index 815c41f82a..58736edb02 100644 --- a/include/wx/headercol.h +++ b/include/wx/headercol.h @@ -186,8 +186,12 @@ public: virtual void SetHidden(bool hidden) { ChangeFlag(wxCOL_HIDDEN, hidden); } - virtual void SetAsSortKey(bool sort = true) = 0; - void UnsetAsSortKey() { SetAsSortKey(false); } + // This function can be called to indicate that this column is not used for + // sorting any more. Under some platforms it's not necessary to do anything + // in this case as just setting another column as a sort key takes care of + // everything but under MSW we currently need to call this explicitly to + // reset the sort indicator displayed on the column. + virtual void UnsetAsSortKey() { } virtual void SetSortOrder(bool ascending) = 0; void ToggleSortOrder() { SetSortOrder(!IsSortOrderAscending()); } @@ -249,10 +253,15 @@ public: virtual void SetFlags(int flags) { m_flags = flags; } virtual int GetFlags() const { return m_flags; } - virtual void SetAsSortKey(bool sort = true) { m_sort = sort; } virtual bool IsSortKey() const { return m_sort; } + virtual void UnsetAsSortKey() { m_sort = false; } + + virtual void SetSortOrder(bool ascending) + { + m_sort = true; + m_sortAscending = ascending; + } - virtual void SetSortOrder(bool ascending) { m_sortAscending = ascending; } virtual bool IsSortOrderAscending() const { return m_sortAscending; } private: diff --git a/include/wx/osx/dataview.h b/include/wx/osx/dataview.h index 883438001f..feabf7de02 100644 --- a/include/wx/osx/dataview.h +++ b/include/wx/osx/dataview.h @@ -65,7 +65,6 @@ public: virtual void SetSortOrder (bool ascending); virtual void SetTitle (wxString const& title); virtual void SetWidth (int width); - virtual void SetAsSortKey (bool sort = true); // implementation only wxDataViewColumnNativeData* GetNativeData() const diff --git a/interface/wx/headercol.h b/interface/wx/headercol.h index d554115362..53d4261017 100644 --- a/interface/wx/headercol.h +++ b/interface/wx/headercol.h @@ -338,38 +338,26 @@ public: virtual void SetHidden(bool hidden); - /** - Sets this column as the sort key for the associated control. - - Calling this function with @true argument means that this column is - currently used for sorting the control contents and so should typically - display an arrow indicating it (the direction of the arrow depends on - IsSortOrderAscending() return value). - - Don't confuse this function with SetSortable() which should be used to - indicate that the column @em may be used for sorting while this one is - used to indicate that it currently @em is used for sorting. Of course, - SetAsSortKey() can be only called for sortable columns. - - @param sort - Sort (default) or don't sort the control contents by this column. - */ - virtual void SetAsSortKey(bool sort = true) = 0; - /** Don't use this column for sorting. - This is equivalent to calling SetAsSortKey() with @false argument. + This is the reverse of SetSortOrder() and is called to indicate that + this column is not used for sorting any longer. */ void UnsetAsSortKey(); /** - Sets the sort order for this column. + Sets this column as the sort key for the associated control. - This only makes sense for sortable columns which are currently used as - sort key, i.e. for which IsSortKey() returns @true and is only taken - into account by the control in which this column is inserted, this - function just stores the sort order in the wxHeaderColumn object. + This function indicates that this column is currently used for sorting + the control and also sets the sorting direction. Notice that actual + sorting is only done in the control associated with the header, this + function doesn't do any sorting on its own. + + Don't confuse this function with SetSortable() which should be used to + indicate that the column @em may be used for sorting while this one is + used to indicate that it currently @em is used for sorting. Of course, + SetSortOrder() can be only called for sortable columns. @param ascending If @true, sort in ascending order, otherwise in descending order. @@ -444,7 +432,6 @@ public: virtual wxAlignment GetAlignment() const; virtual void SetFlags(int flags); virtual int GetFlags() const; - virtual void SetAsSortKey(bool sort = true); virtual bool IsSortKey() const; virtual void SetSortOrder(bool ascending); virtual bool IsSortOrderAscending() const; diff --git a/src/common/headerctrlcmn.cpp b/src/common/headerctrlcmn.cpp index 4e32625c6b..be858a6848 100644 --- a/src/common/headerctrlcmn.cpp +++ b/src/common/headerctrlcmn.cpp @@ -443,7 +443,7 @@ void wxHeaderCtrlSimple::DoShowSortIndicator(unsigned int idx, bool ascending) { RemoveSortIndicator(); - m_cols[idx].SetAsSortKey(ascending); + m_cols[idx].SetSortOrder(ascending); m_sortKey = idx; UpdateColumn(idx); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 46ea2141e1..f5fcf0d5e3 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -230,7 +230,7 @@ private: } owner->SetSortingColumnIndex(idx); - col->SetAsSortKey(); + col->SetSortOrder(true); } wxDataViewModel * const model = owner->GetModel(); diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index b848fcdc93..d89b8c5501 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -3286,14 +3286,6 @@ bool wxDataViewColumn::IsSortable() const return gtk_tree_view_column_get_clickable( column ); } -void wxDataViewColumn::SetAsSortKey( bool WXUNUSED(sort) ) -{ - // it might not make sense to have this function in wxHeaderColumn at - // all in fact, changing of the sort order should only be done using the - // associated control API - wxFAIL_MSG( "not implemented" ); -} - bool wxDataViewColumn::IsSortKey() const { GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(m_column); diff --git a/src/osx/carbon/dataview.cpp b/src/osx/carbon/dataview.cpp index dd288d8e17..13765f900d 100644 --- a/src/osx/carbon/dataview.cpp +++ b/src/osx/carbon/dataview.cpp @@ -2811,12 +2811,6 @@ bool wxDataViewColumn::IsHidden() const } -void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort)) -{ - // see wxGTK native wxDataViewColumn implementation - wxFAIL_MSG( "not implemented" ); -} - void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) { delete m_NativeDataPtr; diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index f9600c916e..16ce4c8fab 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -3243,12 +3243,6 @@ void wxDataViewColumn::SetWidth(int width) } } -void wxDataViewColumn::SetAsSortKey(bool WXUNUSED(sort)) -{ - // see wxGTK native wxDataViewColumn implementation - wxFAIL_MSG("not implemented"); -} - void wxDataViewColumn::SetNativeData(wxDataViewColumnNativeData* newNativeDataPtr) { delete m_NativeDataPtr;