} // 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
// ---------------------------------------------------------
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,
wxSize wxDataViewTextRenderer::GetSize() const
{
- const wxDataViewCtrl *view = GetView();
if (!m_text.empty())
- return view->wxWindowBase::GetTextExtent( m_text );
- return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
+ return GetTextExtent(m_text);
+ else
+ return wxSize(wxDVC_DEFAULT_RENDERER_SIZE,wxDVC_DEFAULT_RENDERER_SIZE);
}
// ---------------------------------------------------------
wxSize wxDataViewDateRenderer::GetSize() const
{
- const wxDataViewCtrl* view = GetView();
- wxString tmp = m_date.FormatDate();
- wxCoord x,y,d;
- view->GetTextExtent( tmp, &x, &y, &d );
- return wxSize(x,y+d);
+ return GetTextExtent(m_date.FormatDate());
}
void wxDataViewDateRenderer::WXOnActivate(wxDataViewModel *model,
wxSize wxDataViewIconTextRenderer::GetSize() const
{
- const wxDataViewCtrl *view = GetView();
if (!m_value.GetText().empty())
{
- int x,y;
- view->GetTextExtent( m_value.GetText(), &x, &y );
+ wxSize size = GetTextExtent(m_value.GetText());
if (m_value.GetIcon().IsOk())
- x += m_value.GetIcon().GetWidth() + 4;
- return wxSize( x, y );
+ size.x += m_value.GetIcon().GetWidth() + 4;
+ return size;
}
return wxSize(80,20);
}
!model->HasContainerColumns(item))
continue; // skip it!
- wxVariant value;
- model->GetValue( value, item, column->GetModelColumn() );
-
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
+
+ wxVariant value;
+ model->GetValue( value, item, column->GetModelColumn() );
renderer->SetValue( value );
+
+ wxDataViewItemAttr attr;
+ model->GetAttr(item, column->GetModelColumn(), attr);
+ renderer->SetAttr(attr);
+
height = wxMax( height, renderer->GetSize().y );
}
!model->HasContainerColumns(item))
continue; // skip it!
- wxVariant value;
- model->GetValue( value, item, column->GetModelColumn() );
-
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
+
+ wxVariant value;
+ model->GetValue( value, item, column->GetModelColumn() );
renderer->SetValue( value );
+
+ wxDataViewItemAttr attr;
+ model->GetAttr(item, column->GetModelColumn(), attr);
+ renderer->SetAttr(attr);
+
height = wxMax( height, renderer->GetSize().y );
}
!model->HasContainerColumns(item))
continue; // skip it!
- wxVariant value;
- model->GetValue( value, item, column->GetModelColumn() );
-
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
+
+ wxVariant value;
+ model->GetValue( value, item, column->GetModelColumn() );
renderer->SetValue( value );
+
+ wxDataViewItemAttr attr;
+ model->GetAttr(item, column->GetModelColumn(), attr);
+ renderer->SetAttr(attr);
+
height = wxMax( height, renderer->GetSize().y );
}
wxVariant value;
model->GetValue( value, item, col->GetModelColumn() );
custom->SetValue( value );
+
+ wxDataViewItemAttr attr;
+ model->GetAttr(item, col->GetModelColumn(), attr);
+ custom->SetAttr(attr);
+
wxRect cell_rect( xpos, GetLineStart( current ),
col->GetWidth(), GetLineHeight( current ) );
GetModel()->GetValue(value, item, column->GetModelColumn());
renderer->SetValue(value);
+ wxDataViewItemAttr attr;
+ GetModel()->GetAttr(item, column->GetModelColumn(), attr);
+ renderer->SetAttr(attr);
+
max_width = (unsigned)wxMax((int)max_width, renderer->GetSize().x);
}