diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index ca6fe2fc15..6121109932 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -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 diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 997f81fb55..72beb09210 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -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); diff --git a/src/gtk/filectrl.cpp b/src/gtk/filectrl.cpp index 0ab9103b48..a50a83b27d 100644 --- a/src/gtk/filectrl.cpp +++ b/src/gtk/filectrl.cpp @@ -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 ); diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index 4437030362..dd86d5c83e 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -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); diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index b84ddd9073..9c1031f9fb 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -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 );