Some Resize/GetBestSize() changes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5169 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-01-01 23:21:04 +00:00
parent f22e0c3c3f
commit 0279e84482
8 changed files with 62 additions and 30 deletions

View File

@@ -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

View File

@@ -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 );

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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 );

View File

@@ -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

View File

@@ -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);
}