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:
@@ -55,6 +55,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
void PostCreation(const wxSize& size);
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxString PrepareLabelMnemonics( const wxString &label ) const;
|
||||
#endif
|
||||
|
@@ -55,6 +55,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
void PostCreation(const wxSize& size);
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxString PrepareLabelMnemonics( const wxString &label ) const;
|
||||
#endif
|
||||
|
@@ -149,13 +149,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -173,10 +166,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -135,19 +135,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -120,19 +120,7 @@ bool wxCheckBox::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -122,12 +122,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -171,8 +171,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
m_focusWidget = combo->entry;
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
PostCreation(size);
|
||||
|
||||
ConnectWidget( combo->button );
|
||||
|
||||
@@ -189,23 +188,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
gtk_signal_connect( GTK_OBJECT(combo->list), "select-child",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this );
|
||||
|
||||
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 );
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
// This is required for tool bar support
|
||||
gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
|
||||
}
|
||||
|
||||
Show( TRUE );
|
||||
wxSize setsize = GetSize();
|
||||
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -86,6 +86,16 @@ wxSize wxControl::DoGetBestSize() const
|
||||
return wxSize(req.width, req.height);
|
||||
}
|
||||
|
||||
|
||||
void wxControl::PostCreation(const wxSize& size)
|
||||
{
|
||||
wxWindow::PostCreation();
|
||||
InheritAttributes();
|
||||
ApplyWidgetStyle();
|
||||
SetInitialBestSize(size);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
|
||||
{
|
||||
|
@@ -55,11 +55,9 @@ bool wxGauge::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -404,16 +404,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
DoAppend(choices[i]);
|
||||
}
|
||||
|
||||
// call it after appending the strings to the listbox, otherwise it doesn't
|
||||
// work correctly
|
||||
SetBestSize( size );
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -365,15 +365,13 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
|
||||
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
|
||||
SetFont( parent->GetFont() );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -246,16 +246,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
bool wasShown = IsShown();
|
||||
if ( wasShown )
|
||||
Hide(); // prevent PostCreation() from showing us
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
ApplyWidgetStyle();
|
||||
|
||||
SetLabel( title );
|
||||
|
||||
SetFont( parent->GetFont() );
|
||||
|
||||
SetBestSize( size );
|
||||
PostCreation(size);
|
||||
|
||||
if ( wasShown )
|
||||
Show();
|
||||
|
@@ -128,19 +128,7 @@ bool wxRadioButton::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -179,12 +179,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -141,10 +141,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -150,10 +150,7 @@ bool wxSpinButton::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(new_size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -126,24 +126,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
SetValue( value );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void wxStaticBitmap::CreatePixmapWidget()
|
||||
|
||||
m_focusWidget = m_widget;
|
||||
|
||||
PostCreation();
|
||||
PostCreation(wxDefaultSize);
|
||||
}
|
||||
|
||||
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() )
|
||||
mask = m_bitmap.GetMask()->GetBitmap();
|
||||
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
|
||||
|
||||
SetBestSize( size );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,7 +85,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
||||
m_focusWidget = m_widget;
|
||||
}
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
return TRUE;
|
||||
|
@@ -66,9 +66,7 @@ bool wxStaticBox::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
InheritAttributes();
|
||||
PostCreation(size);
|
||||
|
||||
// need to set non default alignment?
|
||||
gfloat xalign;
|
||||
@@ -82,8 +80,6 @@ bool wxStaticBox::Create( wxWindow *parent,
|
||||
if ( xalign )
|
||||
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -74,9 +74,7 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ bool wxStaticText::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
|
||||
// the bug below only happens with GTK 2
|
||||
#ifdef __WXGTK20__
|
||||
@@ -109,27 +109,6 @@ bool wxStaticText::Create(wxWindow *parent,
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -168,7 +147,10 @@ void wxStaticText::SetLabel( const wxString &label )
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -373,9 +373,7 @@ bool wxToolBar::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -348,17 +348,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
|
||||
m_focusWidget = m_text;
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
if (multi_line)
|
||||
gtk_widget_show(m_text);
|
||||
@@ -461,8 +451,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
|
||||
SetDefaultStyle( attrDef );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -79,13 +79,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -95,10 +88,7 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild(this);
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -207,15 +197,15 @@ void wxToggleBitmapButton::OnInternalIdle()
|
||||
// Get the "best" size for this control.
|
||||
wxSize wxToggleBitmapButton::DoGetBestSize() const
|
||||
{
|
||||
wxSize ret(wxControl::DoGetBestSize());
|
||||
wxSize best;
|
||||
|
||||
if (!HasFlag(wxBU_EXACTFIT))
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
if (ret.x < 80) ret.x = 80;
|
||||
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
|
||||
best.x = m_bitmap.GetWidth()+border;
|
||||
best.y = m_bitmap.GetHeight()+border;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
return best;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
// wxToggleButton
|
||||
@@ -251,19 +241,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild(this);
|
||||
|
||||
PostCreation();
|
||||
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);
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -149,13 +149,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -173,10 +166,7 @@ bool wxBitmapButton::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -135,19 +135,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -120,19 +120,7 @@ bool wxCheckBox::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -122,12 +122,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -171,8 +171,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
m_focusWidget = combo->entry;
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
PostCreation(size);
|
||||
|
||||
ConnectWidget( combo->button );
|
||||
|
||||
@@ -189,23 +188,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
gtk_signal_connect( GTK_OBJECT(combo->list), "select-child",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this );
|
||||
|
||||
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 );
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
// This is required for tool bar support
|
||||
gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
|
||||
}
|
||||
|
||||
Show( TRUE );
|
||||
wxSize setsize = GetSize();
|
||||
gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -86,6 +86,16 @@ wxSize wxControl::DoGetBestSize() const
|
||||
return wxSize(req.width, req.height);
|
||||
}
|
||||
|
||||
|
||||
void wxControl::PostCreation(const wxSize& size)
|
||||
{
|
||||
wxWindow::PostCreation();
|
||||
InheritAttributes();
|
||||
ApplyWidgetStyle();
|
||||
SetInitialBestSize(size);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __WXGTK20__
|
||||
wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
|
||||
{
|
||||
|
@@ -55,11 +55,9 @@ bool wxGauge::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -404,16 +404,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
|
||||
DoAppend(choices[i]);
|
||||
}
|
||||
|
||||
// call it after appending the strings to the listbox, otherwise it doesn't
|
||||
// work correctly
|
||||
SetBestSize( size );
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
SetBestSize(size); // need this too because this is a wxControlWithItems
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -365,15 +365,13 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
|
||||
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
|
||||
SetFont( parent->GetFont() );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
|
||||
GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -246,16 +246,10 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
bool wasShown = IsShown();
|
||||
if ( wasShown )
|
||||
Hide(); // prevent PostCreation() from showing us
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
ApplyWidgetStyle();
|
||||
|
||||
SetLabel( title );
|
||||
|
||||
SetFont( parent->GetFont() );
|
||||
|
||||
SetBestSize( size );
|
||||
PostCreation(size);
|
||||
|
||||
if ( wasShown )
|
||||
Show();
|
||||
|
@@ -128,19 +128,7 @@ bool wxRadioButton::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -179,12 +179,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
SetBestSize(size);
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -141,10 +141,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -150,10 +150,7 @@ bool wxSpinButton::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(new_size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -126,24 +126,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
SetValue( value );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void wxStaticBitmap::CreatePixmapWidget()
|
||||
|
||||
m_focusWidget = m_widget;
|
||||
|
||||
PostCreation();
|
||||
PostCreation(wxDefaultSize);
|
||||
}
|
||||
|
||||
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() )
|
||||
mask = m_bitmap.GetMask()->GetBitmap();
|
||||
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
|
||||
|
||||
SetBestSize( size );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,7 +85,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
||||
m_focusWidget = m_widget;
|
||||
}
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
return TRUE;
|
||||
|
@@ -66,9 +66,7 @@ bool wxStaticBox::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
InheritAttributes();
|
||||
PostCreation(size);
|
||||
|
||||
// need to set non default alignment?
|
||||
gfloat xalign;
|
||||
@@ -82,8 +80,6 @@ bool wxStaticBox::Create( wxWindow *parent,
|
||||
if ( xalign )
|
||||
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -74,9 +74,7 @@ bool wxStaticLine::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -90,7 +90,7 @@ bool wxStaticText::Create(wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
PostCreation(size);
|
||||
|
||||
// the bug below only happens with GTK 2
|
||||
#ifdef __WXGTK20__
|
||||
@@ -109,27 +109,6 @@ bool wxStaticText::Create(wxWindow *parent,
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -168,7 +147,10 @@ void wxStaticText::SetLabel( const wxString &label )
|
||||
|
||||
// adjust the label size to the new label unless disabled
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if (!HasFlag(wxST_NO_AUTORESIZE))
|
||||
{
|
||||
SetSize( GetBestSize() );
|
||||
|
||||
SetSizeHints(GetSize());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -373,9 +373,7 @@ bool wxToolBar::Create( wxWindow *parent,
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
PostCreation();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -348,17 +348,7 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
|
||||
m_focusWidget = m_text;
|
||||
|
||||
PostCreation();
|
||||
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 );
|
||||
PostCreation(size);
|
||||
|
||||
if (multi_line)
|
||||
gtk_widget_show(m_text);
|
||||
@@ -461,8 +451,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
||||
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
|
||||
SetDefaultStyle( attrDef );
|
||||
|
||||
Show( TRUE );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -79,13 +79,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -95,10 +88,7 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild(this);
|
||||
|
||||
PostCreation();
|
||||
InheritAttributes();
|
||||
|
||||
Show( TRUE );
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -207,15 +197,15 @@ void wxToggleBitmapButton::OnInternalIdle()
|
||||
// Get the "best" size for this control.
|
||||
wxSize wxToggleBitmapButton::DoGetBestSize() const
|
||||
{
|
||||
wxSize ret(wxControl::DoGetBestSize());
|
||||
wxSize best;
|
||||
|
||||
if (!HasFlag(wxBU_EXACTFIT))
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
if (ret.x < 80) ret.x = 80;
|
||||
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
|
||||
best.x = m_bitmap.GetWidth()+border;
|
||||
best.y = m_bitmap.GetHeight()+border;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
return best;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
// wxToggleButton
|
||||
@@ -251,19 +241,7 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_parent->DoAddChild(this);
|
||||
|
||||
PostCreation();
|
||||
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);
|
||||
PostCreation(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user