protected:
virtual wxSize DoGetBestSize() const;
+ void PostCreation(const wxSize& size);
+
#ifdef __WXGTK20__
wxString PrepareLabelMnemonics( const wxString &label ) const;
#endif
protected:
virtual wxSize DoGetBestSize() const;
+ void PostCreation(const wxSize& size);
+
#ifdef __WXGTK20__
wxString PrepareLabelMnemonics( const wxString &label ) const;
#endif
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();
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
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;
}
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;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- SetBestSize(size);
-
- Show( TRUE );
+ PostCreation(size);
+ SetBestSize(size); // need this too because this is a wxControlWithItems
return TRUE;
}
m_focusWidget = combo->entry;
- PostCreation();
- InheritAttributes();
+ PostCreation(size);
ConnectWidget( combo->button );
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 );
-
- // This is required for tool bar support
- gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
- }
-
- Show( TRUE );
+ SetBestSize(size); // need this too because this is a wxControlWithItems
+ // This is required for tool bar support
+ wxSize setsize = GetSize();
+ gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
+
return TRUE;
}
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
{
m_parent->DoAddChild( this );
- PostCreation();
+ PostCreation(size);
SetBestSize(size);
- Show( TRUE );
-
return TRUE;
}
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;
}
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;
}
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();
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;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- SetBestSize(size);
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(new_size);
return TRUE;
}
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;
}
m_focusWidget = m_widget;
- PostCreation();
+ PostCreation(wxDefaultSize);
}
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
if ( m_bitmap.GetMask() )
mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
-
- SetBestSize( size );
}
else
{
m_focusWidget = m_widget;
}
- PostCreation();
+ PostCreation(size);
m_parent->DoAddChild( this );
return TRUE;
m_parent->DoAddChild( this );
- PostCreation();
-
- InheritAttributes();
+ PostCreation(size);
// need to set non default alignment?
gfloat xalign;
if ( xalign )
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
- Show( TRUE );
-
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
+ PostCreation(size);
// the bug below only happens with GTK 2
#ifdef __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;
}
// 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 )
// adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE))
+ {
SetSize( GetBestSize() );
-
+ SetSizeHints(GetSize());
+ }
return ret;
}
m_parent->DoAddChild( this );
- PostCreation();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
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);
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef );
- Show( TRUE );
-
return TRUE;
}
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();
}
m_parent->DoAddChild(this);
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
// Get the "best" size for this control.
wxSize wxToggleBitmapButton::DoGetBestSize() const
{
- wxSize ret(wxControl::DoGetBestSize());
-
- if (!HasFlag(wxBU_EXACTFIT))
+ wxSize best;
+
+ 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
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;
}
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();
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
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;
}
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;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- SetBestSize(size);
-
- Show( TRUE );
+ PostCreation(size);
+ SetBestSize(size); // need this too because this is a wxControlWithItems
return TRUE;
}
m_focusWidget = combo->entry;
- PostCreation();
- InheritAttributes();
+ PostCreation(size);
ConnectWidget( combo->button );
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 );
-
- // This is required for tool bar support
- gtk_widget_set_usize( m_widget, new_size.x, new_size.y );
- }
-
- Show( TRUE );
+ SetBestSize(size); // need this too because this is a wxControlWithItems
+ // This is required for tool bar support
+ wxSize setsize = GetSize();
+ gtk_widget_set_usize( m_widget, setsize.x, setsize.y );
+
return TRUE;
}
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
{
m_parent->DoAddChild( this );
- PostCreation();
+ PostCreation(size);
SetBestSize(size);
- Show( TRUE );
-
return TRUE;
}
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;
}
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;
}
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();
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;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- SetBestSize(size);
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(new_size);
return TRUE;
}
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;
}
m_focusWidget = m_widget;
- PostCreation();
+ PostCreation(wxDefaultSize);
}
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
if ( m_bitmap.GetMask() )
mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
-
- SetBestSize( size );
}
else
{
m_focusWidget = m_widget;
}
- PostCreation();
+ PostCreation(size);
m_parent->DoAddChild( this );
return TRUE;
m_parent->DoAddChild( this );
- PostCreation();
-
- InheritAttributes();
+ PostCreation(size);
// need to set non default alignment?
gfloat xalign;
if ( xalign )
gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0);
- Show( TRUE );
-
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
m_parent->DoAddChild( this );
- PostCreation();
+ PostCreation(size);
// the bug below only happens with GTK 2
#ifdef __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;
}
// 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 )
// adjust the label size to the new label unless disabled
if (!HasFlag(wxST_NO_AUTORESIZE))
+ {
SetSize( GetBestSize() );
-
+ SetSizeHints(GetSize());
+ }
return ret;
}
m_parent->DoAddChild( this );
- PostCreation();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
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);
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef );
- Show( TRUE );
-
return TRUE;
}
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();
}
m_parent->DoAddChild(this);
- PostCreation();
- InheritAttributes();
-
- Show( TRUE );
+ PostCreation(size);
return TRUE;
}
// Get the "best" size for this control.
wxSize wxToggleBitmapButton::DoGetBestSize() const
{
- wxSize ret(wxControl::DoGetBestSize());
-
- if (!HasFlag(wxBU_EXACTFIT))
+ wxSize best;
+
+ 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
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;
}