From 3313a31ed3e6c38343cc410278e42be8e6326450 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 24 Jan 2014 18:29:45 +0000 Subject: [PATCH] fix GetBordersForSizer(), closes #15872 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75696 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/gtk/statbox.cpp | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0e8ff26343..759bc255ab 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -603,6 +603,7 @@ wxGTK: - Fix wxPopupTransientWindow mouse events with GTK3, also fixes wxOwnerDrawnComboBox, wxDatePickerCtrl. - Fix cursor inheritance. +- Fix wxStaticBoxSizer size calculation wxMSW: diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index 6d0a9b0db1..2a385b29d1 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -158,8 +158,22 @@ wxStaticBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const { - *borderTop = GetCharHeight(); - *borderOther = GetCharWidth()/2; + GtkAllocation alloc, child_alloc; + gtk_widget_get_allocation(m_widget, &alloc); + const int w_save = alloc.width; + const int h_save = alloc.height; + if (alloc.width < 50) alloc.width = 50; + if (alloc.height < 50) alloc.height = 50; + gtk_widget_set_allocation(m_widget, &alloc); + + GTK_FRAME_GET_CLASS(m_widget)->compute_child_allocation(GTK_FRAME(m_widget), &child_alloc); + + alloc.width = w_save; + alloc.height = h_save; + gtk_widget_set_allocation(m_widget, &alloc); + + *borderTop = child_alloc.y - alloc.y; + *borderOther = child_alloc.x - alloc.x; } #endif // wxUSE_STATBOX