Added wxControl::PostCreation for wxGTK. Moved calls to

InheritAttributes and ApplyWidgetStyle there, and added a call to
SetInitialBestSize.   Also removed calls to Show from Create since
PostCreation already does it.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27088 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-05-04 07:09:32 +00:00
parent 0886039fa7
commit abdeb9e700
46 changed files with 112 additions and 416 deletions

View File

@@ -55,6 +55,8 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void PostCreation(const wxSize& size);
#ifdef __WXGTK20__ #ifdef __WXGTK20__
wxString PrepareLabelMnemonics( const wxString &label ) const; wxString PrepareLabelMnemonics( const wxString &label ) const;
#endif #endif

View File

@@ -55,6 +55,8 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
void PostCreation(const wxSize& size);
#ifdef __WXGTK20__ #ifdef __WXGTK20__
wxString PrepareLabelMnemonics( const wxString &label ) const; wxString PrepareLabelMnemonics( const wxString &label ) const;
#endif #endif

View File

@@ -149,13 +149,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
if (m_bmpNormal.Ok()) if (m_bmpNormal.Ok())
{ {
wxSize newSize = size;
wxSize bestSize = DoGetBestSize();
if (newSize.x == -1)
newSize.x = bestSize.x;
if (newSize.y == -1)
newSize.y = bestSize.y;
SetSize( newSize.x, newSize.y );
OnSetBitmap(); OnSetBitmap();
} }
@@ -173,10 +166,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -135,19 +135,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize best_size( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = best_size.x;
if (new_size.y == -1)
new_size.y = best_size.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
SetSize( new_size );
return TRUE; return TRUE;
} }

View File

@@ -120,19 +120,7 @@ bool wxCheckBox::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -122,12 +122,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes(); SetBestSize(size); // need this too because this is a wxControlWithItems
SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -171,8 +171,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
m_focusWidget = combo->entry; m_focusWidget = combo->entry;
PostCreation(); PostCreation(size);
InheritAttributes();
ConnectWidget( combo->button ); ConnectWidget( combo->button );
@@ -189,24 +188,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
gtk_signal_connect( GTK_OBJECT(combo->list), "select-child", gtk_signal_connect( GTK_OBJECT(combo->list), "select-child",
GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this );
wxSize size_best( DoGetBestSize() ); SetBestSize(size); // need this too because this is a wxControlWithItems
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if (new_size.y > size_best.y)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
{
SetSize( new_size.x, new_size.y );
// This is required for tool bar support
gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
}
Show( TRUE );
// This is required for tool bar support
wxSize setsize = GetSize();
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
return TRUE; return TRUE;
} }

View File

@@ -86,6 +86,16 @@ wxSize wxControl::DoGetBestSize() const
return wxSize(req.width, req.height); return wxSize(req.width, req.height);
} }
void wxControl::PostCreation(const wxSize& size)
{
wxWindow::PostCreation();
InheritAttributes();
ApplyWidgetStyle();
SetInitialBestSize(size);
}
#ifdef __WXGTK20__ #ifdef __WXGTK20__
wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
{ {

View File

@@ -55,11 +55,9 @@ bool wxGauge::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
SetBestSize(size); SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -404,16 +404,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
DoAppend(choices[i]); DoAppend(choices[i]);
} }
// call it after appending the strings to the listbox, otherwise it doesn't
// work correctly
SetBestSize( size );
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes(); SetBestSize(size); // need this too because this is a wxControlWithItems
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -365,15 +365,13 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
PostCreation(); PostCreation(size);
SetFont( parent->GetFont() ); SetFont( parent->GetFont() );
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -246,16 +246,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
bool wasShown = IsShown(); bool wasShown = IsShown();
if ( wasShown ) if ( wasShown )
Hide(); // prevent PostCreation() from showing us Hide(); // prevent PostCreation() from showing us
PostCreation();
InheritAttributes();
ApplyWidgetStyle();
SetLabel( title ); SetLabel( title );
SetFont( parent->GetFont() ); PostCreation(size);
SetBestSize( size );
if ( wasShown ) if ( wasShown )
Show(); Show();

View File

@@ -128,19 +128,7 @@ bool wxRadioButton::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -179,12 +179,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -141,10 +141,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -150,10 +150,7 @@ bool wxSpinButton::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(new_size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -126,24 +126,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if (new_size.y > size_best.y)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
SetValue( value ); SetValue( value );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -54,7 +54,7 @@ void wxStaticBitmap::CreatePixmapWidget()
m_focusWidget = m_widget; m_focusWidget = m_widget;
PostCreation(); PostCreation(wxDefaultSize);
} }
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
@@ -78,8 +78,6 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
if ( m_bitmap.GetMask() ) if ( m_bitmap.GetMask() )
mask = m_bitmap.GetMask()->GetBitmap(); mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
SetBestSize( size );
} }
else else
{ {
@@ -87,7 +85,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
m_focusWidget = m_widget; m_focusWidget = m_widget;
} }
PostCreation(); PostCreation(size);
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
return TRUE; return TRUE;

View File

@@ -66,9 +66,7 @@ bool wxStaticBox::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
// need to set non default alignment? // need to set non default alignment?
gfloat xalign; gfloat xalign;
@@ -82,8 +80,6 @@ bool wxStaticBox::Create( wxWindow *parent,
if ( xalign ) if ( xalign )
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0); gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -74,9 +74,7 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -90,7 +90,7 @@ bool wxStaticText::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
// the bug below only happens with GTK 2 // the bug below only happens with GTK 2
#ifdef __WXGTK20__ #ifdef __WXGTK20__
@@ -109,27 +109,6 @@ bool wxStaticText::Create(wxWindow *parent,
} }
#endif // __WXGTK20__ #endif // __WXGTK20__
ApplyWidgetStyle();
InheritAttributes();
// wxControl::SetFont( parent->GetFont() );
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
// if (ShouldInheritColours())
// {
// SetBackgroundColour( parent->GetBackgroundColour() );
// SetForegroundColour( parent->GetForegroundColour() );
// }
Show( TRUE );
return TRUE; return TRUE;
} }
@@ -168,7 +147,10 @@ void wxStaticText::SetLabel( const wxString &label )
// adjust the label size to the new label unless disabled // adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE)) if (!HasFlag(wxST_NO_AUTORESIZE))
{
SetSize( GetBestSize() ); SetSize( GetBestSize() );
SetSizeHints(GetSize());
}
} }
bool wxStaticText::SetFont( const wxFont &font ) bool wxStaticText::SetFont( const wxFont &font )
@@ -177,8 +159,10 @@ bool wxStaticText::SetFont( const wxFont &font )
// adjust the label size to the new label unless disabled // adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE)) if (!HasFlag(wxST_NO_AUTORESIZE))
{
SetSize( GetBestSize() ); SetSize( GetBestSize() );
SetSizeHints(GetSize());
}
return ret; return ret;
} }

View File

@@ -373,9 +373,7 @@ bool wxToolBar::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -348,17 +348,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
m_focusWidget = m_text; m_focusWidget = m_text;
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
if (multi_line) if (multi_line)
gtk_widget_show(m_text); gtk_widget_show(m_text);
@@ -461,8 +451,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() ); wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef ); SetDefaultStyle( attrDef );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -79,13 +79,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
wxSize newSize = size;
int border = (style & wxNO_BORDER) ? 4 : 10;
if (newSize.x == -1)
newSize.x = m_bitmap.GetWidth()+border;
if (newSize.y == -1)
newSize.y = m_bitmap.GetHeight()+border;
SetSize( newSize.x, newSize.y );
OnSetBitmap(); OnSetBitmap();
} }
@@ -95,10 +88,7 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild(this); m_parent->DoAddChild(this);
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }
@@ -207,15 +197,15 @@ void wxToggleBitmapButton::OnInternalIdle()
// Get the "best" size for this control. // Get the "best" size for this control.
wxSize wxToggleBitmapButton::DoGetBestSize() const wxSize wxToggleBitmapButton::DoGetBestSize() const
{ {
wxSize ret(wxControl::DoGetBestSize()); wxSize best;
if (!HasFlag(wxBU_EXACTFIT))
{
if (ret.x < 80) ret.x = 80;
}
if (m_bitmap.Ok())
return ret; {
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
best.x = m_bitmap.GetWidth()+border;
best.y = m_bitmap.GetHeight()+border;
}
return best;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// wxToggleButton // wxToggleButton
@@ -251,19 +241,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild(this); m_parent->DoAddChild(this);
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best(DoGetBestSize());
wxSize new_size(size);
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize(new_size.x, new_size.y);
Show(TRUE);
return TRUE; return TRUE;
} }

View File

@@ -149,13 +149,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
if (m_bmpNormal.Ok()) if (m_bmpNormal.Ok())
{ {
wxSize newSize = size;
wxSize bestSize = DoGetBestSize();
if (newSize.x == -1)
newSize.x = bestSize.x;
if (newSize.y == -1)
newSize.y = bestSize.y;
SetSize( newSize.x, newSize.y );
OnSetBitmap(); OnSetBitmap();
} }
@@ -173,10 +166,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -135,19 +135,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize best_size( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = best_size.x;
if (new_size.y == -1)
new_size.y = best_size.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
SetSize( new_size );
return TRUE; return TRUE;
} }

View File

@@ -120,19 +120,7 @@ bool wxCheckBox::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -122,12 +122,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes(); SetBestSize(size); // need this too because this is a wxControlWithItems
SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -171,8 +171,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
m_focusWidget = combo->entry; m_focusWidget = combo->entry;
PostCreation(); PostCreation(size);
InheritAttributes();
ConnectWidget( combo->button ); ConnectWidget( combo->button );
@@ -189,24 +188,12 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
gtk_signal_connect( GTK_OBJECT(combo->list), "select-child", gtk_signal_connect( GTK_OBJECT(combo->list), "select-child",
GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this );
wxSize size_best( DoGetBestSize() ); SetBestSize(size); // need this too because this is a wxControlWithItems
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if (new_size.y > size_best.y)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
{
SetSize( new_size.x, new_size.y );
// This is required for tool bar support
gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
}
Show( TRUE );
// This is required for tool bar support
wxSize setsize = GetSize();
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
return TRUE; return TRUE;
} }

View File

@@ -86,6 +86,16 @@ wxSize wxControl::DoGetBestSize() const
return wxSize(req.width, req.height); return wxSize(req.width, req.height);
} }
void wxControl::PostCreation(const wxSize& size)
{
wxWindow::PostCreation();
InheritAttributes();
ApplyWidgetStyle();
SetInitialBestSize(size);
}
#ifdef __WXGTK20__ #ifdef __WXGTK20__
wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
{ {

View File

@@ -55,11 +55,9 @@ bool wxGauge::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
SetBestSize(size); SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -404,16 +404,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
DoAppend(choices[i]); DoAppend(choices[i]);
} }
// call it after appending the strings to the listbox, otherwise it doesn't
// work correctly
SetBestSize( size );
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes(); SetBestSize(size); // need this too because this is a wxControlWithItems
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -365,15 +365,13 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
PostCreation(); PostCreation(size);
SetFont( parent->GetFont() ); SetFont( parent->GetFont() );
gtk_signal_connect( GTK_OBJECT(m_widget), "realize", gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -246,16 +246,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
bool wasShown = IsShown(); bool wasShown = IsShown();
if ( wasShown ) if ( wasShown )
Hide(); // prevent PostCreation() from showing us Hide(); // prevent PostCreation() from showing us
PostCreation();
InheritAttributes();
ApplyWidgetStyle();
SetLabel( title ); SetLabel( title );
SetFont( parent->GetFont() ); PostCreation(size);
SetBestSize( size );
if ( wasShown ) if ( wasShown )
Show(); Show();

View File

@@ -128,19 +128,7 @@ bool wxRadioButton::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -179,12 +179,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
SetBestSize(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -141,10 +141,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -150,10 +150,7 @@ bool wxSpinButton::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(new_size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -126,24 +126,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if (new_size.y > size_best.y)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
SetValue( value ); SetValue( value );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -54,7 +54,7 @@ void wxStaticBitmap::CreatePixmapWidget()
m_focusWidget = m_widget; m_focusWidget = m_widget;
PostCreation(); PostCreation(wxDefaultSize);
} }
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
@@ -78,8 +78,6 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
if ( m_bitmap.GetMask() ) if ( m_bitmap.GetMask() )
mask = m_bitmap.GetMask()->GetBitmap(); mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
SetBestSize( size );
} }
else else
{ {
@@ -87,7 +85,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
m_focusWidget = m_widget; m_focusWidget = m_widget;
} }
PostCreation(); PostCreation(size);
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
return TRUE; return TRUE;

View File

@@ -66,9 +66,7 @@ bool wxStaticBox::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
InheritAttributes();
// need to set non default alignment? // need to set non default alignment?
gfloat xalign; gfloat xalign;
@@ -82,8 +80,6 @@ bool wxStaticBox::Create( wxWindow *parent,
if ( xalign ) if ( xalign )
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0); gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -74,9 +74,7 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -90,7 +90,7 @@ bool wxStaticText::Create(wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
// the bug below only happens with GTK 2 // the bug below only happens with GTK 2
#ifdef __WXGTK20__ #ifdef __WXGTK20__
@@ -109,27 +109,6 @@ bool wxStaticText::Create(wxWindow *parent,
} }
#endif // __WXGTK20__ #endif // __WXGTK20__
ApplyWidgetStyle();
InheritAttributes();
// wxControl::SetFont( parent->GetFont() );
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
// if (ShouldInheritColours())
// {
// SetBackgroundColour( parent->GetBackgroundColour() );
// SetForegroundColour( parent->GetForegroundColour() );
// }
Show( TRUE );
return TRUE; return TRUE;
} }
@@ -168,7 +147,10 @@ void wxStaticText::SetLabel( const wxString &label )
// adjust the label size to the new label unless disabled // adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE)) if (!HasFlag(wxST_NO_AUTORESIZE))
{
SetSize( GetBestSize() ); SetSize( GetBestSize() );
SetSizeHints(GetSize());
}
} }
bool wxStaticText::SetFont( const wxFont &font ) bool wxStaticText::SetFont( const wxFont &font )
@@ -177,8 +159,10 @@ bool wxStaticText::SetFont( const wxFont &font )
// adjust the label size to the new label unless disabled // adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE)) if (!HasFlag(wxST_NO_AUTORESIZE))
{
SetSize( GetBestSize() ); SetSize( GetBestSize() );
SetSizeHints(GetSize());
}
return ret; return ret;
} }

View File

@@ -373,9 +373,7 @@ bool wxToolBar::Create( wxWindow *parent,
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
PostCreation(); PostCreation(size);
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -348,17 +348,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
m_focusWidget = m_text; m_focusWidget = m_text;
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best( DoGetBestSize() );
wxSize new_size( size );
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize( new_size.x, new_size.y );
if (multi_line) if (multi_line)
gtk_widget_show(m_text); gtk_widget_show(m_text);
@@ -461,8 +451,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() ); wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef ); SetDefaultStyle( attrDef );
Show( TRUE );
return TRUE; return TRUE;
} }

View File

@@ -79,13 +79,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
wxSize newSize = size;
int border = (style & wxNO_BORDER) ? 4 : 10;
if (newSize.x == -1)
newSize.x = m_bitmap.GetWidth()+border;
if (newSize.y == -1)
newSize.y = m_bitmap.GetHeight()+border;
SetSize( newSize.x, newSize.y );
OnSetBitmap(); OnSetBitmap();
} }
@@ -95,10 +88,7 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild(this); m_parent->DoAddChild(this);
PostCreation(); PostCreation(size);
InheritAttributes();
Show( TRUE );
return TRUE; return TRUE;
} }
@@ -207,15 +197,15 @@ void wxToggleBitmapButton::OnInternalIdle()
// Get the "best" size for this control. // Get the "best" size for this control.
wxSize wxToggleBitmapButton::DoGetBestSize() const wxSize wxToggleBitmapButton::DoGetBestSize() const
{ {
wxSize ret(wxControl::DoGetBestSize()); wxSize best;
if (!HasFlag(wxBU_EXACTFIT))
{
if (ret.x < 80) ret.x = 80;
}
if (m_bitmap.Ok())
return ret; {
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
best.x = m_bitmap.GetWidth()+border;
best.y = m_bitmap.GetHeight()+border;
}
return best;
} }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// wxToggleButton // wxToggleButton
@@ -251,19 +241,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
m_parent->DoAddChild(this); m_parent->DoAddChild(this);
PostCreation(); PostCreation(size);
InheritAttributes();
wxSize size_best(DoGetBestSize());
wxSize new_size(size);
if (new_size.x == -1)
new_size.x = size_best.x;
if (new_size.y == -1)
new_size.y = size_best.y;
if ((new_size.x != size.x) || (new_size.y != size.y))
SetSize(new_size.x, new_size.y);
Show(TRUE);
return TRUE; return TRUE;
} }