]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/datavgen.cpp
compilation fix: wxColour::GetColor() returns const object
[wxWidgets.git] / src / generic / datavgen.cpp
index 579c2a9db6768a158220cedc92a7305111d636aa..07585c579f4d047221140548e9781e59ffd4903a 100644 (file)
@@ -176,6 +176,8 @@ public:
         delete m_resizeCursor;
     }
 
+    virtual void UpdateDisplay() { Refresh(); }
+    
     // event handlers:
 
     void OnPaint( wxPaintEvent &event );
@@ -418,106 +420,6 @@ wxDC *wxDataViewRenderer::GetDC()
     return m_dc;
 }
 
-bool wxDataViewRenderer::StartEditing( unsigned int row, wxRect labelRect )
-{
-    GetView()->CalcScrolledPosition( labelRect.x, labelRect.y,
-                                     &labelRect.x, &labelRect.y);
-
-    m_row = row; // remember for later
-                                     
-    unsigned int col = GetOwner()->GetModelColumn();
-    wxVariant value;
-    GetOwner()->GetOwner()->GetModel()->GetValue( value, col, row );
-    
-    m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value );
-    
-    m_editorCtrl->PushEventHandler( new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, this ) );
-    
-    m_editorCtrl->SetFocus();
-    
-    return true;
-}
-
-void wxDataViewRenderer::CancelEditing()
-{
-    // m_editorCtrl->PopEventHandler( true );
-
-    delete m_editorCtrl;
-    
-    GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-}
-
-bool wxDataViewRenderer::FinishEditing()
-{
-    // m_editorCtrl->PopEventHandler( true );
-
-    wxVariant value;
-    GetValueFromEditorCtrl( m_editorCtrl, value );
-
-    delete m_editorCtrl;
-    
-    GetOwner()->GetOwner()->GetMainWindow()->SetFocus();
-    
-    if (!Validate(value))
-        return false;
-        
-    unsigned int col = GetOwner()->GetModelColumn();
-    GetOwner()->GetOwner()->GetModel()->SetValue( value, col, m_row );
-    GetOwner()->GetOwner()->GetModel()->ValueChanged( col, m_row );
-    
-    return true;
-}
-
-//-----------------------------------------------------------------------------
-// wxDataViewEditorCtrlEvtHandler
-//-----------------------------------------------------------------------------
-
-BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler)
-    EVT_CHAR           (wxDataViewEditorCtrlEvtHandler::OnChar)
-    EVT_KILL_FOCUS     (wxDataViewEditorCtrlEvtHandler::OnKillFocus)
-END_EVENT_TABLE()
-
-wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler(
-                                wxControl *editorCtrl,
-                                wxDataViewRenderer *owner )
-{
-    m_owner = owner;
-    m_editorCtrl = editorCtrl;
-
-    m_finished = false;
-}
-
-void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event )
-{
-    switch ( event.m_keyCode )
-    {
-        case WXK_RETURN:
-            m_finished = true;
-            m_owner->FinishEditing();
-            break;
-
-        case WXK_ESCAPE:
-            m_finished = true;
-            m_owner->CancelEditing();
-            break;
-
-        default:
-            event.Skip();
-    }
-}
-
-void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event )
-{
-    if (!m_finished)
-    {
-        m_finished = true;
-        m_owner->FinishEditing();
-    }
-
-    // We must let the native text control handle focus
-    event.Skip();
-}
-
 // ---------------------------------------------------------
 // wxDataViewCustomRenderer
 // ---------------------------------------------------------
@@ -919,6 +821,7 @@ void wxDataViewColumn::Init( int width )
 {
     m_width = width;
     m_minWidth = wxDVC_DEFAULT_MINWIDTH;
+    m_ascending = true;
 }
 
 void wxDataViewColumn::SetResizeable( bool resizeable )
@@ -947,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 )
@@ -1379,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:
@@ -1665,7 +1585,6 @@ void wxDataViewMainWindow::OnRenameTimer()
     if ( m_dirty )
         wxSafeYield();
 
-
     int xpos = 0;
     unsigned int cols = GetOwner()->GetColumnCount();
     unsigned int i;
@@ -1682,6 +1601,9 @@ void wxDataViewMainWindow::OnRenameTimer()
     wxRect labelRect( xpos, m_currentRow * m_lineHeight,
                       m_currentCol->GetWidth(), m_lineHeight );
 
+    GetOwner()->CalcScrolledPosition( labelRect.x, labelRect.y,
+                                     &labelRect.x, &labelRect.y);
+
     m_currentCol->GetRenderer()->StartEditing( m_currentRow, labelRect );
 }