Fix the alignment used by custom wxDVC renderers in wxGTK by default.
Correctly initialize the alignment used by the text renderer used by wxDataViewCustomRenderer in wxGTK implementation of wxDataViewCtrl. Closes #12298. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ff7bc95e6f
commit
3e81bbbf6c
@ -52,7 +52,7 @@ public:
|
||||
|
||||
GtkCellRenderer* GetGtkHandle() { return m_renderer; }
|
||||
void GtkInitHandlers();
|
||||
void GtkUpdateAlignment();
|
||||
void GtkUpdateAlignment() { GtkApplyAlignment(m_renderer); }
|
||||
|
||||
// should be overridden to return true if the renderer supports properties
|
||||
// corresponding to wxDataViewItemAttr field, see wxGtkTreeCellDataFunc()
|
||||
@ -85,6 +85,9 @@ protected:
|
||||
const wxDataViewItem& item,
|
||||
unsigned col);
|
||||
|
||||
// Apply our effective alignment (i.e. m_alignment if specified or the
|
||||
// associated column alignment by default) to the given renderer.
|
||||
void GtkApplyAlignment(GtkCellRenderer *renderer);
|
||||
|
||||
GtkCellRenderer *m_renderer;
|
||||
int m_alignment;
|
||||
|
@ -147,6 +147,10 @@ protected:
|
||||
bool Init(wxDataViewCellMode mode, int align);
|
||||
|
||||
private:
|
||||
// Called from GtkGetTextRenderer() to really create the renderer if
|
||||
// necessary.
|
||||
void GtkInitTextRenderer();
|
||||
|
||||
wxDC *m_dc;
|
||||
|
||||
GtkCellRendererText *m_text_renderer;
|
||||
|
@ -1835,7 +1835,7 @@ wxDataViewCellMode wxDataViewRenderer::GetMode() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wxDataViewRenderer::GtkUpdateAlignment()
|
||||
void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
|
||||
{
|
||||
int align = m_alignment;
|
||||
|
||||
@ -1861,7 +1861,7 @@ void wxDataViewRenderer::GtkUpdateAlignment()
|
||||
GValue gvalue = { 0, };
|
||||
g_value_init( &gvalue, G_TYPE_FLOAT );
|
||||
g_value_set_float( &gvalue, xalign );
|
||||
g_object_set_property( G_OBJECT(m_renderer), "xalign", &gvalue );
|
||||
g_object_set_property( G_OBJECT(renderer), "xalign", &gvalue );
|
||||
g_value_unset( &gvalue );
|
||||
|
||||
// vertical alignment:
|
||||
@ -1875,7 +1875,7 @@ void wxDataViewRenderer::GtkUpdateAlignment()
|
||||
GValue gvalue2 = { 0, };
|
||||
g_value_init( &gvalue2, G_TYPE_FLOAT );
|
||||
g_value_set_float( &gvalue2, yalign );
|
||||
g_object_set_property( G_OBJECT(m_renderer), "yalign", &gvalue2 );
|
||||
g_object_set_property( G_OBJECT(renderer), "yalign", &gvalue2 );
|
||||
g_value_unset( &gvalue2 );
|
||||
}
|
||||
|
||||
@ -2359,14 +2359,20 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
||||
Init(mode, align);
|
||||
}
|
||||
|
||||
void wxDataViewCustomRenderer::GtkInitTextRenderer()
|
||||
{
|
||||
m_text_renderer = GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new());
|
||||
g_object_ref_sink(m_text_renderer);
|
||||
|
||||
GtkApplyAlignment(GTK_CELL_RENDERER(m_text_renderer));
|
||||
}
|
||||
|
||||
GtkCellRendererText *wxDataViewCustomRenderer::GtkGetTextRenderer() const
|
||||
{
|
||||
if ( !m_text_renderer )
|
||||
{
|
||||
// we create it on demand so need to do it even from a const function
|
||||
const_cast<wxDataViewCustomRenderer *>(this)->
|
||||
m_text_renderer = GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new());
|
||||
g_object_ref_sink(m_text_renderer);
|
||||
const_cast<wxDataViewCustomRenderer *>(this)->GtkInitTextRenderer();
|
||||
}
|
||||
|
||||
return m_text_renderer;
|
||||
|
Loading…
Reference in New Issue
Block a user