Avoid GtkAlignment with GTK+4

This commit is contained in:
Paul Cornett
2017-12-19 10:12:04 -08:00
parent 96befc88c0
commit ecda9c2016
5 changed files with 43 additions and 4 deletions

View File

@@ -119,7 +119,17 @@ bool wxButton::Create(wxWindow *parent,
else if (HasFlag(wxBU_BOTTOM))
y_alignment = 1.0;
#ifdef __WXGTK4__
if (useLabel)
{
g_object_set(gtk_bin_get_child(GTK_BIN(m_widget)),
"xalign", x_alignment, "yalign", y_alignment, NULL);
}
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment);
wxGCC_WARNING_RESTORE()
#endif
if ( useLabel )
SetLabel(label);
@@ -259,6 +269,13 @@ bool wxButton::DoSetLabelMarkup(const wxString& markup)
GtkLabel *wxButton::GTKGetLabel() const
{
GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
#ifdef __WXGTK4__
if (GTK_IS_LABEL(child))
return GTK_LABEL(child);
return NULL;
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
if ( GTK_IS_ALIGNMENT(child) )
{
GtkWidget* box = gtk_bin_get_child(GTK_BIN(child));
@@ -274,6 +291,8 @@ GtkLabel *wxButton::GTKGetLabel() const
}
return GTK_LABEL(child);
wxGCC_WARNING_RESTORE()
#endif
}
#endif // wxUSE_MARKUP
@@ -283,6 +302,8 @@ void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
GtkWidget* child = gtk_bin_get_child(GTK_BIN(m_widget));
GTKApplyStyle(child, style);
#ifndef __WXGTK4__
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
// for buttons with images, the path to the label is (at least in 2.12)
// GtkButton -> GtkAlignment -> GtkHBox -> GtkLabel
if ( GTK_IS_ALIGNMENT(child) )
@@ -297,6 +318,8 @@ void wxButton::DoApplyWidgetStyle(GtkRcStyle *style)
}
}
}
wxGCC_WARNING_RESTORE()
#endif
}
wxSize wxButton::DoGetBestSize() const

View File

@@ -123,7 +123,13 @@ bool wxCheckBox::Create(wxWindow *parent,
m_widgetCheckbox = gtk_check_button_new();
m_widgetLabel = gtk_label_new("");
#ifdef __WXGTK4__
g_object_set(m_widgetLabel, "xalign", 0.0f, NULL);
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5);
wxGCC_WARNING_RESTORE()
#endif
m_widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3);

View File

@@ -339,11 +339,9 @@ bool wxGtkFileCtrl::Create( wxWindow *parent,
if ( style & wxFC_SAVE )
gtkAction = GTK_FILE_CHOOSER_ACTION_SAVE;
m_widget = gtk_alignment_new ( 0, 0, 1, 1 );
g_object_ref(m_widget);
m_fcWidget = GTK_FILE_CHOOSER( gtk_file_chooser_widget_new(gtkAction) );
gtk_widget_show ( GTK_WIDGET( m_fcWidget ) );
gtk_container_add ( GTK_CONTAINER ( m_widget ), GTK_WIDGET( m_fcWidget ) );
m_widget = GTK_WIDGET(m_fcWidget);
g_object_ref(m_widget);
m_focusWidget = GTK_WIDGET( m_fcWidget );

View File

@@ -422,7 +422,13 @@ void wxMDIClientWindow::AddChildGTK(wxWindowGTK* child)
s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
#ifdef __WXGTK4__
g_object_set(label_widget, "xalign", 0.0f, NULL);
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
wxGCC_WARNING_RESTORE()
#endif
GtkNotebook* notebook = GTK_NOTEBOOK(m_widget);

View File

@@ -108,7 +108,13 @@ bool wxStaticText::Create(wxWindow *parent,
// GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2
static const float labelAlignments[] = { 0.0, 1.0, 0.5 };
#ifdef __WXGTK4__
g_object_set(m_widget, "xalign", labelAlignments[justify], NULL);
#else
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0);
wxGCC_WARNING_RESTORE()
#endif
gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE );