From 69cdfbf7f89bd17af47c5c77c7bc94fe59937db9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 4 May 1999 15:54:49 +0000 Subject: [PATCH] Found a few situations where the most recent corrections crashed. Changed default size of wxComboBox to what seems to be the only value the arrow button likes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2338 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 4 +--- src/gtk/frame.cpp | 3 --- src/gtk/win_gtk.c | 6 ++++-- src/gtk/window.cpp | 41 ++++++++++++++++++++++++++--------------- src/gtk1/combobox.cpp | 4 +--- src/gtk1/frame.cpp | 3 --- src/gtk1/win_gtk.c | 6 ++++-- src/gtk1/window.cpp | 41 ++++++++++++++++++++++++++--------------- 8 files changed, 62 insertions(+), 46 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 91ed541378..07bbd6e5d5 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -110,7 +110,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, if (newSize.x == -1) newSize.x = 100; if (newSize.y == -1) - newSize.y = 26; + newSize.y = 22; SetSize( newSize.x, newSize.y ); GtkWidget *list = GTK_COMBO(m_widget)->list; @@ -584,13 +584,11 @@ void wxComboBox::OnSize( wxSizeEvent &event ) { wxControl::OnSize( event ); -/* int w = 21; gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height ); -*/ } void wxComboBox::ApplyWidgetStyle() diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 62cfe002c0..0e181020ff 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -708,9 +708,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height int client_w = m_width - 2*m_miniEdge; int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; gtk_widget_set_usize( m_wxwindow, client_w, client_h ); - GtkAllocation alloc; - alloc.x = client_x; alloc.y = client_y; alloc.width = client_w; alloc.height = client_h; - gtk_widget_size_allocate( m_wxwindow, &alloc ); } else { diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index 3aeb79f5b3..9a9f3e5f7b 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -447,8 +447,10 @@ gtk_myfixed_size_allocate (GtkWidget *widget, { child = children->data; children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) + + /* please look at the text in wxWindow::DoSetSize() on why the + test GTK_WIDGET_REALIZED() has to be here */ + if (GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_REALIZED(child->widget) ) { child_allocation.x = child->x; child_allocation.y = child->y; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a67dfa0df7..de14150665 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2052,28 +2052,39 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if ((old_width != m_width) || (old_height != m_height)) { -/* - wxPrintf( _T("On DoSetSize from ") ); - wxPrintf( GetClassInfo()->GetClassName() ); - wxPrintf( _T(": %d %d.\n"), m_width, m_height ); -*/ - gtk_widget_set_usize( m_widget, m_width, m_height ); - /* this is the result of hours of debugging: the followomg code + /* this is the result of hours of debugging: the following code means that if we have a m_wxwindow and we set the size of m_widget, m_widget (which is a GtkScrolledWindow) does NOT automatically propagate its size down to its m_wxwindow, which is its client area. therefore, we have to tell the - client area directly that it has to get resize itself */ - GtkAllocation alloc; - alloc.x = m_x; - alloc.y = m_y; - alloc.width = m_width; - alloc.height = m_height; - gtk_widget_size_allocate( m_widget, &alloc ); + client area directly that it has to resize itself. + this will lead to that m_widget (GtkScrolledWindow) will + calculate how much size it needs for scrollbars etc and + it will then call XXX_size_allocate of its child, which + is m_wxwindow. m_wxwindow in turn will do the same with its + children and so on. problems can arise if this happens + before all the children have been realized as some widgets + stupidy need to be realized during XXX_size_allocate (e.g. + GtkNotebook) and they will segv if called otherwise. this + emergency is tested in gtk_myfixed_size_allocate. Normally + this shouldn't be needed and only gtk_widget_queue_resize() + should be enough to provoke a resize at the next appropriate + moment, but this seems to fail, e.g. when a wxNotebook contains + a wxSplitterWindow: the splitter window's children won't + show up properly resized then. */ + + if (m_wxwindow) + { + GtkAllocation alloc; + alloc.x = m_x; + alloc.y = m_y; + alloc.width = m_width; + alloc.height = m_height; + gtk_widget_size_allocate( m_widget, &alloc ); + } } - } } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 91ed541378..07bbd6e5d5 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -110,7 +110,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, if (newSize.x == -1) newSize.x = 100; if (newSize.y == -1) - newSize.y = 26; + newSize.y = 22; SetSize( newSize.x, newSize.y ); GtkWidget *list = GTK_COMBO(m_widget)->list; @@ -584,13 +584,11 @@ void wxComboBox::OnSize( wxSizeEvent &event ) { wxControl::OnSize( event ); -/* int w = 21; gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height ); -*/ } void wxComboBox::ApplyWidgetStyle() diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 62cfe002c0..0e181020ff 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -708,9 +708,6 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height int client_w = m_width - 2*m_miniEdge; int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; gtk_widget_set_usize( m_wxwindow, client_w, client_h ); - GtkAllocation alloc; - alloc.x = client_x; alloc.y = client_y; alloc.width = client_w; alloc.height = client_h; - gtk_widget_size_allocate( m_wxwindow, &alloc ); } else { diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index 3aeb79f5b3..9a9f3e5f7b 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -447,8 +447,10 @@ gtk_myfixed_size_allocate (GtkWidget *widget, { child = children->data; children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) + + /* please look at the text in wxWindow::DoSetSize() on why the + test GTK_WIDGET_REALIZED() has to be here */ + if (GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_REALIZED(child->widget) ) { child_allocation.x = child->x; child_allocation.y = child->y; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index a67dfa0df7..de14150665 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2052,28 +2052,39 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) if ((old_width != m_width) || (old_height != m_height)) { -/* - wxPrintf( _T("On DoSetSize from ") ); - wxPrintf( GetClassInfo()->GetClassName() ); - wxPrintf( _T(": %d %d.\n"), m_width, m_height ); -*/ - gtk_widget_set_usize( m_widget, m_width, m_height ); - /* this is the result of hours of debugging: the followomg code + /* this is the result of hours of debugging: the following code means that if we have a m_wxwindow and we set the size of m_widget, m_widget (which is a GtkScrolledWindow) does NOT automatically propagate its size down to its m_wxwindow, which is its client area. therefore, we have to tell the - client area directly that it has to get resize itself */ - GtkAllocation alloc; - alloc.x = m_x; - alloc.y = m_y; - alloc.width = m_width; - alloc.height = m_height; - gtk_widget_size_allocate( m_widget, &alloc ); + client area directly that it has to resize itself. + this will lead to that m_widget (GtkScrolledWindow) will + calculate how much size it needs for scrollbars etc and + it will then call XXX_size_allocate of its child, which + is m_wxwindow. m_wxwindow in turn will do the same with its + children and so on. problems can arise if this happens + before all the children have been realized as some widgets + stupidy need to be realized during XXX_size_allocate (e.g. + GtkNotebook) and they will segv if called otherwise. this + emergency is tested in gtk_myfixed_size_allocate. Normally + this shouldn't be needed and only gtk_widget_queue_resize() + should be enough to provoke a resize at the next appropriate + moment, but this seems to fail, e.g. when a wxNotebook contains + a wxSplitterWindow: the splitter window's children won't + show up properly resized then. */ + + if (m_wxwindow) + { + GtkAllocation alloc; + alloc.x = m_x; + alloc.y = m_y; + alloc.width = m_width; + alloc.height = m_height; + gtk_widget_size_allocate( m_widget, &alloc ); + } } - } } -- 2.47.2