]> git.saurik.com Git - wxWidgets.git/commitdiff
Corrected/implemented sorting (by way of clicking on
authorRobert Roebling <robert@roebling.de>
Wed, 18 Apr 2007 12:31:35 +0000 (12:31 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 18 Apr 2007 12:31:35 +0000 (12:31 +0000)
   on the header button) for the generic code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dataview.h
include/wx/generic/dataview.h
src/common/datavcmn.cpp
src/generic/datavgen.cpp

index 2f6548ad36787665c3787216a30b3053fadf53f4..c1c3a2387a12b5cc3ffcb1fd04b63391b60153b8 100644 (file)
@@ -24,7 +24,7 @@
 
 #if defined(__WXGTK20__)
     // for testing
-    // #define wxUSE_GENERICDATAVIEWCTRL 1
+    #define wxUSE_GENERICDATAVIEWCTRL 1
 #elif defined(__WXMAC__)
     #define wxUSE_GENERICDATAVIEWCTRL 1
 #else
index 13ce60fc6a9095ee22bd56ccdfa195521947b069..cb0007521bab2307c2e6c4875b65a2f344116626 100644 (file)
@@ -297,6 +297,7 @@ private:
     int                      m_flags;
     wxAlignment              m_align;
     wxString                 m_title;
+    bool                     m_ascending;
 
     void Init(int width);
 
index 633822e6b5c41a505518416a525c6db0cdabcf49..5e5e4e8fd035a22ff76e8d0ffed73b7034da171e 100644 (file)
@@ -348,6 +348,9 @@ void wxDataViewSortedListModel::Resort()
     unsigned int i;
     for (i = 0; i < n; i++)
         m_array.Add( i );
+       
+    // do we need the neworder?
+    wxDataViewListModel::RowsReordered( NULL );
 }
 
 #if 0
index c03a08ff924d13158e20d04ddff9c399ccd203c2..07585c579f4d047221140548e9781e59ffd4903a 100644 (file)
@@ -176,6 +176,8 @@ public:
         delete m_resizeCursor;
     }
 
+    virtual void UpdateDisplay() { Refresh(); }
+    
     // event handlers:
 
     void OnPaint( wxPaintEvent &event );
@@ -819,6 +821,7 @@ void wxDataViewColumn::Init( int width )
 {
     m_width = width;
     m_minWidth = wxDVC_DEFAULT_MINWIDTH;
+    m_ascending = true;
 }
 
 void wxDataViewColumn::SetResizeable( bool resizeable )
@@ -847,17 +850,24 @@ void wxDataViewColumn::SetSortable( bool sortable )
         m_flags |= wxDATAVIEW_COL_SORTABLE;
     else
         m_flags &= ~wxDATAVIEW_COL_SORTABLE;
+        
+    // Update header button
+    if (GetOwner())
+        GetOwner()->OnColumnChange();
 }
 
-void wxDataViewColumn::SetSortOrder( bool WXUNUSED(ascending) )
+void wxDataViewColumn::SetSortOrder( bool ascending )
 {
-    // TODO
+    m_ascending = ascending;
+    
+    // Update header button
+    if (GetOwner())
+        GetOwner()->OnColumnChange();
 }
 
 bool wxDataViewColumn::IsSortOrderAscending() const
 {
-    // TODO
-    return true;
+    return m_ascending;
 }
 
 void wxDataViewColumn::SetInternalWidth( int width )
@@ -1279,13 +1289,23 @@ void wxGenericDataViewHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         int cw = col->GetWidth();
         int ch = h;
 
+        wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE;
+        if (col->IsSortable())
+        {
+            if (col->IsSortOrderAscending())
+                sortArrow = wxHDR_SORT_ICON_UP;
+            else
+                sortArrow = wxHDR_SORT_ICON_DOWN;
+        }
+
         wxRendererNative::Get().DrawHeaderButton
                                 (
                                     this,
                                     dc,
                                     wxRect(xpos, 0, cw, ch-1),
                                     m_parent->IsEnabled() ? 0
-                                                          : (int)wxCONTROL_DISABLED
+                                                          : (int)wxCONTROL_DISABLED,
+                                    sortArrow
                                 );
 
         // align as required the column title: