]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
Removed a return statement from void function
[wxWidgets.git] / src / common / datavcmn.cpp
index 6c9423bc386e71364c5e462aaded2056fd256393..94ddc67dc272a1fdcb2f1f006c360843525a4048 100644 (file)
@@ -69,6 +69,24 @@ private:
 
 } // anonymous namespace
 
+// ---------------------------------------------------------
+// wxDataViewItemAttr
+// ---------------------------------------------------------
+
+wxFont wxDataViewItemAttr::GetEffectiveFont(const wxFont& font) const
+{
+    if ( !HasFont() )
+        return font;
+
+    wxFont f(font);
+    if ( GetBold() )
+        f.MakeBold();
+    if ( GetItalic() )
+        f.MakeItalic();
+    return f;
+}
+
+
 // ---------------------------------------------------------
 // wxDataViewModelNotifier
 // ---------------------------------------------------------
@@ -376,7 +394,7 @@ wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
 void wxDataViewIndexListModel::Reset( unsigned int new_size )
 {
     /* wxDataViewModel:: */ BeforeReset();
-    
+
     m_hash.Clear();
 
     // IDs are ordered until an item gets deleted or inserted
@@ -534,7 +552,7 @@ void wxDataViewVirtualListModel::Reset( unsigned int new_size )
     /* wxDataViewModel:: */ BeforeReset();
 
     m_size = new_size;
-    
+
     /* wxDataViewModel:: */ AfterReset();
 }
 
@@ -761,6 +779,20 @@ bool wxDataViewRendererBase::FinishEditing()
     return true;
 }
 
+void wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
+                                            const wxDataViewItem& item,
+                                            unsigned column)
+{
+    wxVariant value;
+    model->GetValue(value, item, column);
+    SetValue(value);
+
+    wxDataViewItemAttr attr;
+    model->GetAttr(item, column, attr);
+    SetAttr(attr);
+}
+
+
 // ----------------------------------------------------------------------------
 // wxDataViewCustomRendererBase
 // ----------------------------------------------------------------------------
@@ -826,19 +858,28 @@ wxDataViewCustomRendererBase::WXCallRender(wxRect rectCell, wxDC *dc, int state)
 
     wxDCFontChanger changeFont(*dc);
     if ( m_attr.HasFont() )
-    {
-        wxFont font(dc->GetFont());
-        if ( m_attr.GetBold() )
-            font.MakeBold();
-        if ( m_attr.GetItalic() )
-            font.MakeItalic();
-
-        changeFont.Set(font);
-    }
+        changeFont.Set(m_attr.GetEffectiveFont(dc->GetFont()));
 
     Render(rectItem, dc, state);
 }
 
+wxSize wxDataViewCustomRendererBase::GetTextExtent(const wxString& str) const
+{
+    const wxDataViewCtrl *view = GetView();
+
+    if ( m_attr.HasFont() )
+    {
+        wxFont font(m_attr.GetEffectiveFont(view->GetFont()));
+        wxSize size;
+        view->GetTextExtent(str, &size.x, &size.y, NULL, NULL, &font);
+        return size;
+    }
+    else
+    {
+        return view->GetTextExtent(str);
+    }
+}
+
 void
 wxDataViewCustomRendererBase::RenderText(const wxString& text,
                                          int xoffset,
@@ -1487,11 +1528,11 @@ wxDataViewChoiceByIndexRenderer::wxDataViewChoiceByIndexRenderer( const wxArrayS
       wxDataViewChoiceRenderer( choices, mode, alignment )
 {
 }
-                            
+
 wxControl* wxDataViewChoiceByIndexRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
 {
     wxVariant string_value = GetChoice( value.GetLong() );
-    
+
     return wxDataViewChoiceRenderer::CreateEditorCtrl( parent, labelRect, string_value );
 }
 
@@ -1510,13 +1551,13 @@ bool wxDataViewChoiceByIndexRenderer::SetValue( const wxVariant &value )
     wxVariant string_value = GetChoice( value.GetLong() );
     return wxDataViewChoiceRenderer::SetValue( string_value );
 }
-    
+
 bool wxDataViewChoiceByIndexRenderer::GetValue( wxVariant &value ) const
 {
     wxVariant string_value;
     if (!wxDataViewChoiceRenderer::GetValue( string_value ))
         return false;
-            
+
     value = (long) GetChoices().Index( string_value.GetString() );
     return true;
 }