Fix wxGTK wxDataViewRenderers' alignment handling
Don't apply alignment to native controls in SetAlignment() method, where it may not be known yet due to column-to-renderer inheritance if wxDVR_DEFAULT_ALIGNMENT is used (the default). Move such code to GtkUpdateAlignment() (which was made virtual) in all renderers. This fixes unintended right-aligning of columns with GTK+ 2 when default alignment was used.
This commit is contained in:
@@ -2056,18 +2056,9 @@ wxDataViewCellMode wxDataViewRenderer::GetMode() const
|
||||
|
||||
void wxDataViewRenderer::GtkApplyAlignment(GtkCellRenderer *renderer)
|
||||
{
|
||||
int align = m_alignment;
|
||||
|
||||
// query alignment from column ?
|
||||
if (align == -1)
|
||||
{
|
||||
// None there yet
|
||||
if (GetOwner() == NULL)
|
||||
return;
|
||||
|
||||
align = GetOwner()->GetAlignment();
|
||||
align |= wxALIGN_CENTRE_VERTICAL;
|
||||
}
|
||||
int align = GetEffectiveAlignmentIfKnown();
|
||||
if ( align == wxDVR_DEFAULT_ALIGNMENT )
|
||||
return; // none set yet
|
||||
|
||||
// horizontal alignment:
|
||||
|
||||
@@ -2341,15 +2332,19 @@ bool wxDataViewTextRenderer::GetTextValue(wxString& str) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewTextRenderer::SetAlignment( int align )
|
||||
void wxDataViewTextRenderer::GtkUpdateAlignment()
|
||||
{
|
||||
wxDataViewRenderer::SetAlignment(align);
|
||||
wxDataViewRenderer::GtkUpdateAlignment();
|
||||
|
||||
#ifndef __WXGTK3__
|
||||
if (gtk_check_version(2,10,0))
|
||||
return;
|
||||
#endif
|
||||
|
||||
int align = GetEffectiveAlignmentIfKnown();
|
||||
if ( align == wxDVR_DEFAULT_ALIGNMENT )
|
||||
return; // none set yet
|
||||
|
||||
// horizontal alignment:
|
||||
PangoAlignment pangoAlign = PANGO_ALIGN_LEFT;
|
||||
if (align & wxALIGN_RIGHT)
|
||||
@@ -2587,6 +2582,14 @@ wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString &varianttype,
|
||||
Init(mode, align);
|
||||
}
|
||||
|
||||
void wxDataViewCustomRenderer::GtkUpdateAlignment()
|
||||
{
|
||||
wxDataViewCustomRendererBase::GtkUpdateAlignment();
|
||||
|
||||
if ( m_text_renderer )
|
||||
GtkApplyAlignment(GTK_CELL_RENDERER(m_text_renderer));
|
||||
}
|
||||
|
||||
void wxDataViewCustomRenderer::GtkInitTextRenderer()
|
||||
{
|
||||
m_text_renderer = GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new());
|
||||
@@ -2868,15 +2871,19 @@ bool wxDataViewChoiceRenderer::GetValue( wxVariant &value ) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewChoiceRenderer::SetAlignment( int align )
|
||||
void wxDataViewChoiceRenderer::GtkUpdateAlignment()
|
||||
{
|
||||
wxDataViewCustomRenderer::SetAlignment(align);
|
||||
wxDataViewCustomRenderer::GtkUpdateAlignment();
|
||||
|
||||
#ifndef __WXGTK3__
|
||||
if (gtk_check_version(2,10,0))
|
||||
return;
|
||||
#endif
|
||||
|
||||
int align = GetEffectiveAlignmentIfKnown();
|
||||
if ( align == wxDVR_DEFAULT_ALIGNMENT )
|
||||
return; // none set yet
|
||||
|
||||
// horizontal alignment:
|
||||
PangoAlignment pangoAlign = PANGO_ALIGN_LEFT;
|
||||
if (align & wxALIGN_RIGHT)
|
||||
|
Reference in New Issue
Block a user