Controls will readjust their size and minsize when SetLabel or SetFont
are called. Fixed up wxStaticText to blend the wxST_NO_AUTOSIZE with this new functionality. Made SetBestSize public under the SetBestFittingSize name. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27890 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -184,6 +184,7 @@ void wxBitmapButton::SetLabel( const wxString &label )
|
||||
wxCHECK_RET( m_widget != NULL, wxT("invalid button") );
|
||||
|
||||
wxControl::SetLabel( label );
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
wxString wxBitmapButton::GetLabel() const
|
||||
|
||||
@@ -175,6 +175,8 @@ void wxButton::SetLabel( const wxString &label )
|
||||
#else
|
||||
gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
|
||||
#endif
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
bool wxButton::Enable( bool enable )
|
||||
|
||||
@@ -158,6 +158,8 @@ void wxCheckBox::SetLabel( const wxString& label )
|
||||
#else
|
||||
gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
|
||||
#endif
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
bool wxCheckBox::Enable( bool enable )
|
||||
|
||||
@@ -33,6 +33,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
|
||||
wxControl::wxControl()
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_createComplete = false;
|
||||
}
|
||||
|
||||
bool wxControl::Create( wxWindow *parent,
|
||||
@@ -43,6 +44,7 @@ bool wxControl::Create( wxWindow *parent,
|
||||
const wxValidator& validator,
|
||||
const wxString &name )
|
||||
{
|
||||
m_createComplete = false;
|
||||
bool ret = wxWindow::Create(parent, id, pos, size, style, name);
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
@@ -68,6 +70,14 @@ void wxControl::SetLabel( const wxString &label )
|
||||
}
|
||||
}
|
||||
|
||||
void wxControl::PostSetLabel()
|
||||
{
|
||||
// make sure the widget has been created, and that PostCreate has already
|
||||
// been called
|
||||
if (m_widget && m_createComplete && GetAdjustMinSizeFlag())
|
||||
SetBestSize(wxDefaultSize);
|
||||
}
|
||||
|
||||
wxString wxControl::GetLabel() const
|
||||
{
|
||||
return m_label;
|
||||
@@ -103,6 +113,7 @@ void wxControl::PostCreation(const wxSize& size)
|
||||
InheritAttributes();
|
||||
ApplyWidgetStyle();
|
||||
SetInitialBestSize(size);
|
||||
m_createComplete = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -540,6 +540,8 @@ void wxRadioBox::SetLabel( const wxString& label )
|
||||
wxControl::SetLabel( label );
|
||||
|
||||
gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
void wxRadioBox::SetString( int item, const wxString& label )
|
||||
|
||||
@@ -145,6 +145,8 @@ void wxRadioButton::SetLabel( const wxString& label )
|
||||
#else
|
||||
gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) );
|
||||
#endif
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
void wxRadioButton::SetValue( bool val )
|
||||
|
||||
@@ -89,6 +89,7 @@ void wxStaticBox::SetLabel( const wxString &label )
|
||||
|
||||
gtk_frame_set_label( GTK_FRAME( m_widget ),
|
||||
m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -146,27 +146,10 @@ void wxStaticText::SetLabel( const wxString &label )
|
||||
#else
|
||||
gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) );
|
||||
#endif
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
bool wxStaticText::SetFont( const wxFont &font )
|
||||
{
|
||||
bool ret = wxControl::SetFont(font);
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxSize wxStaticText::DoGetBestSize() const
|
||||
{
|
||||
|
||||
@@ -287,6 +287,8 @@ void wxToggleButton::SetLabel(const wxString& label)
|
||||
wxControl::SetLabel(label);
|
||||
|
||||
gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) );
|
||||
|
||||
PostSetLabel();
|
||||
}
|
||||
|
||||
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
|
||||
|
||||
@@ -4043,7 +4043,7 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( m_hasFgCol )
|
||||
if ( m_foregroundColour.Ok() )
|
||||
{
|
||||
GdkColor *fg = m_foregroundColour.GetColor();
|
||||
|
||||
@@ -4057,7 +4057,7 @@ GtkRcStyle *wxWindowGTK::CreateWidgetStyle(bool forceStyle)
|
||||
style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_FG;
|
||||
}
|
||||
|
||||
if ( m_hasBgCol )
|
||||
if ( m_backgroundColour.Ok() )
|
||||
{
|
||||
GdkColor *bg = m_backgroundColour.GetColor();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user