Add wxDataViewTextRendererAttr, blind noop under wxMac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -386,6 +386,11 @@ bool wxDataViewIndexListModel::SetValue( const wxVariant &variant,
|
||||
return SetValue( variant, GetRow(item), col );
|
||||
}
|
||||
|
||||
bool wxDataViewIndexListModel::GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr )
|
||||
{
|
||||
return GetAttr( GetRow(item), col, attr );
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
|
||||
{
|
||||
return wxDataViewItem(0);
|
||||
|
||||
@@ -607,6 +607,8 @@ wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype,
|
||||
m_dc = NULL;
|
||||
m_align = align;
|
||||
m_mode = mode;
|
||||
m_wantsAttr = false;
|
||||
m_hasAttr = false;
|
||||
}
|
||||
|
||||
wxDataViewRenderer::~wxDataViewRenderer()
|
||||
@@ -713,6 +715,60 @@ wxSize wxDataViewTextRenderer::GetSize() const
|
||||
return wxSize(80,20);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewTextRendererAttr
|
||||
// ---------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxDataViewTextRendererAttr, wxDataViewTextRenderer)
|
||||
|
||||
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString &varianttype,
|
||||
wxDataViewCellMode mode, int align ) :
|
||||
wxDataViewTextRenderer( varianttype, mode, align )
|
||||
{
|
||||
m_wantsAttr = true;
|
||||
}
|
||||
|
||||
bool wxDataViewTextRendererAttr::Render( wxRect cell, wxDC *dc, int WXUNUSED(state) )
|
||||
{
|
||||
wxFont font;
|
||||
wxColour colour;
|
||||
|
||||
if (m_hasAttr)
|
||||
{
|
||||
if (m_attr.HasColour())
|
||||
{
|
||||
colour = dc->GetTextForeground();
|
||||
dc->SetTextForeground( m_attr.GetColour() );
|
||||
}
|
||||
|
||||
if (m_attr.GetBold() || m_attr.GetItalic())
|
||||
{
|
||||
font = dc->GetFont();
|
||||
wxFont myfont = font;
|
||||
if (m_attr.GetBold())
|
||||
myfont.SetWeight( wxFONTWEIGHT_BOLD );
|
||||
if (m_attr.GetItalic())
|
||||
myfont.SetStyle( wxFONTSTYLE_ITALIC );
|
||||
dc->SetFont( myfont );
|
||||
}
|
||||
}
|
||||
|
||||
dc->DrawText( m_text, cell.x, cell.y + ((cell.height - dc->GetCharHeight()) / 2));
|
||||
|
||||
// restore dc
|
||||
if (m_hasAttr)
|
||||
{
|
||||
if (m_attr.HasColour())
|
||||
dc->SetTextForeground( colour );
|
||||
|
||||
if (m_attr.GetBold() || m_attr.GetItalic())
|
||||
dc->SetFont( font );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewBitmapRenderer
|
||||
// ---------------------------------------------------------
|
||||
@@ -2363,6 +2419,15 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
|
||||
model->GetValue( value, dataitem, col->GetModelColumn());
|
||||
cell->SetValue( value );
|
||||
|
||||
if (cell->GetWantsAttr())
|
||||
{
|
||||
wxDataViewItemAttr attr;
|
||||
bool ret = model->GetAttr( dataitem, col->GetModelColumn(), attr );
|
||||
if (ret)
|
||||
cell->SetAttr( attr );
|
||||
cell->SetHasAttr( ret );
|
||||
}
|
||||
|
||||
// update the y offset
|
||||
cell_rect.y = item * m_lineHeight;
|
||||
@@ -3788,7 +3853,7 @@ wxDataViewColumn* wxDataViewCtrl::GetColumn( unsigned int pos ) const
|
||||
bool wxDataViewCtrl::DeleteColumn( wxDataViewColumn *column )
|
||||
{
|
||||
wxDataViewColumnList::compatibility_iterator ret = m_cols.Find( column );
|
||||
if (ret == NULL)
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
m_cols.Erase(ret);
|
||||
|
||||
@@ -1475,6 +1475,18 @@ void wxDataViewTextRenderer::SetAlignment( int align )
|
||||
g_value_unset( &gvalue );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewTextRendererAttr
|
||||
// ---------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(wxDataViewTextRendererAttr,wxDataViewTextRenderer)
|
||||
|
||||
wxDataViewTextRendererAttr::wxDataViewTextRendererAttr( const wxString &varianttype,
|
||||
wxDataViewCellMode mode, int align ) :
|
||||
wxDataViewTextRenderer( varianttype, mode, align )
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// wxDataViewBitmapRenderer
|
||||
// ---------------------------------------------------------
|
||||
@@ -2112,10 +2124,82 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column,
|
||||
|
||||
cell->SetValue( value );
|
||||
|
||||
#if 0
|
||||
wxListItemAttr attr;
|
||||
wx_model->GetAttr( item, attr, cell->GetOwner()->GetModelColumn() );
|
||||
if (cell->GtkHasAttributes())
|
||||
{
|
||||
wxDataViewItemAttr attr;
|
||||
bool colour_set = false;
|
||||
bool style_set = false;
|
||||
bool weight_set = false;
|
||||
|
||||
if (wx_model->GetAttr( item, cell->GetOwner()->GetModelColumn(), attr ))
|
||||
{
|
||||
// this must be a GtkCellRendererText
|
||||
wxColour colour = attr.GetColour();
|
||||
if (colour.IsOk())
|
||||
{
|
||||
const GdkColor * const gcol = colour.GetColor();
|
||||
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, GDK_TYPE_COLOR );
|
||||
g_value_set_boxed( &gvalue, gcol );
|
||||
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
|
||||
colour_set = true;
|
||||
}
|
||||
|
||||
if (attr.GetItalic())
|
||||
{
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, PANGO_TYPE_STYLE );
|
||||
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
|
||||
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
|
||||
style_set = true;
|
||||
}
|
||||
|
||||
if (attr.GetBold())
|
||||
{
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, PANGO_TYPE_WEIGHT );
|
||||
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
|
||||
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
|
||||
weight_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!style_set)
|
||||
{
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||
g_value_set_boolean( &gvalue, FALSE );
|
||||
g_object_set_property( G_OBJECT(renderer), "style-set", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
}
|
||||
|
||||
if (!weight_set)
|
||||
{
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||
g_value_set_boolean( &gvalue, FALSE );
|
||||
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
}
|
||||
|
||||
if (!colour_set)
|
||||
{
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, G_TYPE_BOOLEAN );
|
||||
g_value_set_boolean( &gvalue, FALSE );
|
||||
g_object_set_property( G_OBJECT(renderer), "foreground-set", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (attr.HasBackgroundColour())
|
||||
{
|
||||
wxColour colour = attr.GetBackgroundColour();
|
||||
|
||||
Reference in New Issue
Block a user