From 0279e8448266e474d07bf7e3b0635f2a53fcc8b8 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 1 Jan 2000 23:21:04 +0000 Subject: [PATCH] Some Resize/GetBestSize() changes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5169 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 6 +++--- src/gtk/control.cpp | 3 +++ src/gtk/spinctrl.cpp | 24 ++++++++++++++---------- src/gtk/textctrl.cpp | 13 +++++++++++-- src/gtk1/combobox.cpp | 6 +++--- src/gtk1/control.cpp | 3 +++ src/gtk1/spinctrl.cpp | 24 ++++++++++++++---------- src/gtk1/textctrl.cpp | 13 +++++++++++-- 8 files changed, 62 insertions(+), 30 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index b8ed05b45f..0571f48fe4 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -108,8 +108,8 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, newSize.x = bestSize.x; if (newSize.y == -1) newSize.y = bestSize.y; - if (newSize.y > 30) - newSize.y = 30; + if (newSize.y > 22) + newSize.y = 22; if (!PreCreation( parent, pos, newSize ) || !CreateBase( parent, id, pos, size, style, validator, name )) @@ -666,7 +666,7 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { // totally bogus - should measure the strings in the combo! - return wxSize(100, 26); + return wxSize(100, 22); } #endif diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index b369c4d8c1..959092087b 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -74,6 +74,9 @@ wxString wxControl::GetLabel() const wxSize wxControl::DoGetBestSize() const { + // Do not return any arbitrary default value... + wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") ); + GtkRequisition req; (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req ); diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 439794f545..766b1c58ae 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -75,15 +75,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize new_size = size, - sizeBest = DoGetBestSize(); - if (new_size.x == -1) - new_size.x = sizeBest.x; - if (new_size.y == -1) - new_size.y = sizeBest.y; - - if (!PreCreation( parent, pos, new_size ) || - !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) + if (!PreCreation( parent, pos, size ) || + !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxSpinCtrl creation failed") ); return FALSE; @@ -94,6 +87,16 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_adjust = (GtkAdjustment*) gtk_adjustment_new( initial, min, max, 1.0, 5.0, 0.0); m_widget = gtk_spin_button_new( m_adjust, 1, 0 ); + + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; + if (new_size.y == -1) + new_size.y = sizeBest.y; + + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), (int)(m_windowStyle & wxSP_WRAP) ); @@ -224,7 +227,8 @@ void wxSpinCtrl::ApplyWidgetStyle() wxSize wxSpinCtrl::DoGetBestSize() const { - return wxSize(95, 26); + wxSize ret( wxControl::DoGetBestSize() ); + return wxSize(95, ret.y); } #endif diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index a81a25db28..e832dcdf05 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -192,7 +192,15 @@ bool wxTextCtrl::Create( wxWindow *parent, m_text = gtk_entry_new(); } - SetSizeOrDefault( size ); + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; + if (new_size.y == -1) + new_size.y = sizeBest.y; + + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); m_parent->DoAddChild( this ); @@ -977,5 +985,6 @@ void wxTextCtrl::OnInternalIdle() wxSize wxTextCtrl::DoGetBestSize() const { // FIXME should be different for multi-line controls... - return wxSize(80, 26); + wxSize ret( wxControl::DoGetBestSize() ); + return wxSize(80, ret.y); } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index b8ed05b45f..0571f48fe4 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -108,8 +108,8 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, newSize.x = bestSize.x; if (newSize.y == -1) newSize.y = bestSize.y; - if (newSize.y > 30) - newSize.y = 30; + if (newSize.y > 22) + newSize.y = 22; if (!PreCreation( parent, pos, newSize ) || !CreateBase( parent, id, pos, size, style, validator, name )) @@ -666,7 +666,7 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { // totally bogus - should measure the strings in the combo! - return wxSize(100, 26); + return wxSize(100, 22); } #endif diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index b369c4d8c1..959092087b 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -74,6 +74,9 @@ wxString wxControl::GetLabel() const wxSize wxControl::DoGetBestSize() const { + // Do not return any arbitrary default value... + wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") ); + GtkRequisition req; (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req ); diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index 439794f545..766b1c58ae 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -75,15 +75,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize new_size = size, - sizeBest = DoGetBestSize(); - if (new_size.x == -1) - new_size.x = sizeBest.x; - if (new_size.y == -1) - new_size.y = sizeBest.y; - - if (!PreCreation( parent, pos, new_size ) || - !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) + if (!PreCreation( parent, pos, size ) || + !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxSpinCtrl creation failed") ); return FALSE; @@ -94,6 +87,16 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_adjust = (GtkAdjustment*) gtk_adjustment_new( initial, min, max, 1.0, 5.0, 0.0); m_widget = gtk_spin_button_new( m_adjust, 1, 0 ); + + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; + if (new_size.y == -1) + new_size.y = sizeBest.y; + + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), (int)(m_windowStyle & wxSP_WRAP) ); @@ -224,7 +227,8 @@ void wxSpinCtrl::ApplyWidgetStyle() wxSize wxSpinCtrl::DoGetBestSize() const { - return wxSize(95, 26); + wxSize ret( wxControl::DoGetBestSize() ); + return wxSize(95, ret.y); } #endif diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index a81a25db28..e832dcdf05 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -192,7 +192,15 @@ bool wxTextCtrl::Create( wxWindow *parent, m_text = gtk_entry_new(); } - SetSizeOrDefault( size ); + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; + if (new_size.y == -1) + new_size.y = sizeBest.y; + + if ((new_size.x != size.x) || (new_size.y != size.y)) + SetSize( new_size.x, new_size.y ); m_parent->DoAddChild( this ); @@ -977,5 +985,6 @@ void wxTextCtrl::OnInternalIdle() wxSize wxTextCtrl::DoGetBestSize() const { // FIXME should be different for multi-line controls... - return wxSize(80, 26); + wxSize ret( wxControl::DoGetBestSize() ); + return wxSize(80, ret.y); } -- 2.45.2