]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/datavgen.cpp
support for file-type popup, compatible for 10.4+, solves #12429
[wxWidgets.git] / src / generic / datavgen.cpp
index 90a1241631cbba77757413803bb66c352fc9c5bf..ca7dc0a9bd50219f3b9dd4b98f6505a7070f4f36 100644 (file)
@@ -145,7 +145,6 @@ protected:
         return *(GetOwner()->GetColumn(idx));
     }
 
-    // FIXME: currently unused
     virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle)
     {
         wxDataViewCtrl * const owner = GetOwner();
@@ -435,7 +434,7 @@ public:
     bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
     bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
     bool ItemChanged( const wxDataViewItem &item );
-    bool ValueChanged( const wxDataViewItem &item, unsigned int col );
+    bool ValueChanged( const wxDataViewItem &item, unsigned int model_column );
     bool Cleared();
     void Resort()
     {
@@ -1665,22 +1664,23 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         dc.SetPen(m_penRule);
         dc.SetBrush(*wxTRANSPARENT_BRUSH);
 
-        int x = x_start;
+        // NB: Vertical rules are drawn in the last pixel of a column so that
+        //     they align perfectly with native MSW wxHeaderCtrl as well as for
+        //     consistency with MSW native list control. There's no vertical
+        //     rule at the most-left side of the control.
+
+        int x = x_start - 1;
         for (unsigned int i = col_start; i < col_last; i++)
         {
             wxDataViewColumn *col = GetOwner()->GetColumnAt(i);
             if (col->IsHidden())
                 continue;       // skip it
 
+            x += col->GetWidth();
+
             dc.DrawLine(x, GetLineStart( item_start ),
                         x, GetLineStart( item_last ) );
-
-            x += col->GetWidth();
         }
-
-        // Draw last vertical rule
-        dc.DrawLine(x, GetLineStart( item_start ),
-                    x, GetLineStart( item_last ) );
     }
 
     // redraw the background for the items which are selected/current
@@ -2073,9 +2073,23 @@ bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
     return true;
 }
 
-bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int col )
+bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int model_column )
 {
-    GetOwner()->InvalidateColBestWidth(col);
+    int view_column = -1;
+    unsigned int n_col = m_owner->GetColumnCount();
+    for (unsigned i = 0; i < n_col; i++)
+    {
+        wxDataViewColumn *column = m_owner->GetColumn( i );
+        if (column->GetModelColumn() == model_column)
+        {
+            view_column = (int) i;
+            break;
+        }
+    }
+    if (view_column == -1)
+        return false;
+
+    GetOwner()->InvalidateColBestWidth(view_column);
 
     // NOTE: to be valid, we cannot use e.g. INT_MAX - 1
 /*#define MAX_VIRTUAL_WIDTH       100000
@@ -2095,8 +2109,8 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
     le.SetEventObject(parent);
     le.SetModel(GetOwner()->GetModel());
     le.SetItem(item);
-    le.SetColumn(col);
-    le.SetDataViewColumn(GetOwner()->GetColumn(col));
+    le.SetColumn(view_column);
+    le.SetDataViewColumn(GetOwner()->GetColumn(view_column));
     parent->GetEventHandler()->ProcessEvent(le);
 
     return true;
@@ -2154,6 +2168,8 @@ void wxDataViewMainWindow::RecalculateDisplay()
 
 void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
 {
+    m_underMouse = NULL;
+
     wxWindow::ScrollWindow( dx, dy, rect );
 
     if (GetOwner()->m_headerArea)
@@ -2162,6 +2178,8 @@ void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
 
 void wxDataViewMainWindow::ScrollTo( int rows, int column )
 {
+    m_underMouse = NULL;
+
     int x, y;
     m_owner->GetScrollPixelsPerUnit( &x, &y );
     int sy = GetLineStart( rows )/y;
@@ -4220,7 +4238,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
         calculator.UpdateWithRow(row);
     }
 
-    // row is the first unmeasured item now; that's out value of N/2
+    // row is the first unmeasured item now; that's our value of N/2
 
     if ( row < count )
     {
@@ -4260,8 +4278,6 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
 
     const_cast<wxDataViewCtrl*>(this)->m_colsBestWidths[idx] = max_width;
     return max_width;
-
-    #undef MEASURE_ITEM
 }
 
 void wxDataViewCtrl::ColumnMoved(wxDataViewColumn * WXUNUSED(col),
@@ -4309,8 +4325,9 @@ void wxDataViewCtrl::InvalidateColBestWidths()
 
     if ( m_headerArea )
     {
-        // this updates visual appearance of columns 0 and up, not just 0
-        m_headerArea->UpdateColumn(0);
+        const unsigned cols = m_headerArea->GetColumnCount();
+        for ( unsigned i = 0; i < cols; i++ )
+            m_headerArea->UpdateColumn(i);
     }
 }
 
@@ -4616,7 +4633,8 @@ void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int colu
 
     wxRect itemRect = GetItemRect(item, col);
     wxDataViewRenderer* renderer = col->GetRenderer();
-    renderer->StartEditing(item, itemRect);
+    if (renderer->GetMode() == wxDATAVIEW_CELL_EDITABLE)
+        renderer->StartEditing(item, itemRect);
 }
 
 #endif // !wxUSE_GENERICDATAVIEWCTRL