Correct bug with items without attributes in wxGTK wxDVC.
After the change to the sample in r62390 it turned out that wxGTK version didn't handle items without attributes in a column where other items did have attributes neither -- they inherited the last used attribute. Fix this by remembering whether we are using any non-default attributes or not and resetting them if we do. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,10 +42,17 @@ public:
|
|||||||
void GtkInitHandlers();
|
void GtkInitHandlers();
|
||||||
void GtkUpdateAlignment();
|
void GtkUpdateAlignment();
|
||||||
|
|
||||||
|
bool GtkIsUsingDefaultAttrs() const { return m_usingDefaultAttrs; }
|
||||||
|
void GtkSetUsingDefaultAttrs(bool def) { m_usingDefaultAttrs = def; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GtkCellRenderer *m_renderer;
|
GtkCellRenderer *m_renderer;
|
||||||
int m_alignment;
|
int m_alignment;
|
||||||
|
|
||||||
|
// true if we hadn't changed any visual attributes or restored them since
|
||||||
|
// doing this
|
||||||
|
bool m_usingDefaultAttrs;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
|
||||||
};
|
};
|
||||||
|
@@ -1553,6 +1553,9 @@ wxDataViewRenderer::wxDataViewRenderer( const wxString &varianttype, wxDataViewC
|
|||||||
{
|
{
|
||||||
m_renderer = NULL;
|
m_renderer = NULL;
|
||||||
|
|
||||||
|
// we haven't changed them yet
|
||||||
|
m_usingDefaultAttrs = true;
|
||||||
|
|
||||||
// NOTE: SetMode() and SetAlignment() needs to be called in the renderer's ctor,
|
// NOTE: SetMode() and SetAlignment() needs to be called in the renderer's ctor,
|
||||||
// after the m_renderer pointer has been initialized
|
// after the m_renderer pointer has been initialized
|
||||||
}
|
}
|
||||||
@@ -2550,9 +2553,18 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
|
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
|
|
||||||
|
// deal with attributes
|
||||||
wxDataViewItemAttr attr;
|
wxDataViewItemAttr attr;
|
||||||
if (wx_model->GetAttr( item, cell->GetOwner()->GetModelColumn(), attr ))
|
if ( !wx_model->GetAttr( item, cell->GetOwner()->GetModelColumn(), attr )
|
||||||
|
&& cell->GtkIsUsingDefaultAttrs() )
|
||||||
{
|
{
|
||||||
|
// no custom attributes specified and we're already using the default
|
||||||
|
// ones -- nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool usingDefaultAttrs = true;
|
||||||
if (attr.HasColour())
|
if (attr.HasColour())
|
||||||
{
|
{
|
||||||
const GdkColor * const gcol = attr.GetColour().GetColor();
|
const GdkColor * const gcol = attr.GetColour().GetColor();
|
||||||
@@ -2562,6 +2574,8 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_value_set_boxed( &gvalue, gcol );
|
g_value_set_boxed( &gvalue, gcol );
|
||||||
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "foreground_gdk", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
|
usingDefaultAttrs = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2579,6 +2593,8 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
|
g_value_set_enum( &gvalue, PANGO_STYLE_ITALIC );
|
||||||
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "style", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
|
usingDefaultAttrs = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2597,6 +2613,8 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
|
g_value_set_enum( &gvalue, PANGO_WEIGHT_BOLD );
|
||||||
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "weight", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
|
|
||||||
|
usingDefaultAttrs = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2606,7 +2624,6 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
|
g_object_set_property( G_OBJECT(renderer), "weight-set", &gvalue );
|
||||||
g_value_unset( &gvalue );
|
g_value_unset( &gvalue );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (attr.HasBackgroundColour())
|
if (attr.HasBackgroundColour())
|
||||||
@@ -2630,6 +2647,7 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *WXUNUSED(column),
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cell->GtkSetUsingDefaultAttrs(usingDefaultAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
Reference in New Issue
Block a user