From fe39b16a973c623003a0a1df95259223e56fc518 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 1 Mar 2006 22:43:57 +0000 Subject: [PATCH 1/1] Apply patch which makes it possible to resize a control in a toolbar. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37772 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 70 +++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 631345526a..eda96a1e10 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -24,6 +24,9 @@ #include "wx/msgdlg.h" #include "wx/module.h" #include "wx/combobox.h" +#if wxUSE_TOOLBAR_NATIVE +#include "wx/toolbar.h" +#endif #if wxUSE_DRAG_AND_DROP #include "wx/dnd.h" @@ -2910,9 +2913,46 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags y = currentY; AdjustForParentClientOrigin(x, y, sizeFlags); - if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ + // calculate the best size if we should auto size the window + if ( ((sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1) || + ((sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1) ) + { + const wxSize sizeBest = GetBestSize(); + if ( (sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1 ) + width = sizeBest.x; + if ( (sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1 ) + height = sizeBest.y; + } + + if (width != -1) + m_width = width; + if (height != -1) + m_height = height; + + int minWidth = GetMinWidth(), + minHeight = GetMinHeight(), + maxWidth = GetMaxWidth(), + maxHeight = GetMaxHeight(); + + if ((minWidth != -1) && (m_width < minWidth )) m_width = minWidth; + if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; + if ((maxWidth != -1) && (m_width > maxWidth )) m_width = maxWidth; + if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; + +#if wxUSE_TOOLBAR_NATIVE + if (wxDynamicCast(GetParent(), wxToolBar)) { - /* don't set the size for children of wxNotebook, just take the values. */ + // don't take the x,y values, they're wrong because toolbar sets them + GtkWidget *widget = GTK_WIDGET(m_widget); + gtk_widget_set_size_request (widget, m_width, m_height); + if (GTK_WIDGET_VISIBLE (widget)) + gtk_widget_queue_resize (widget); + } + else +#endif + if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook + { + // don't set the size for children of wxNotebook, just take the values. m_x = x; m_y = y; m_width = width; @@ -2932,32 +2972,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags m_y = y + pizza->yoffset; } - // calculate the best size if we should auto size the window - if ( ((sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1) || - ((sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1) ) - { - const wxSize sizeBest = GetBestSize(); - if ( (sizeFlags & wxSIZE_AUTO_WIDTH) && width == -1 ) - width = sizeBest.x; - if ( (sizeFlags & wxSIZE_AUTO_HEIGHT) && height == -1 ) - height = sizeBest.y; - } - - if (width != -1) - m_width = width; - if (height != -1) - m_height = height; - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - int left_border = 0; int right_border = 0; int top_border = 0; -- 2.45.2