SetFont() the second

#ifdefed SetFont() in Statusbars destructor
  wxRadioBox setsize corrected (Still only simple layout)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-09-06 18:34:18 +00:00
parent f4ada56822
commit 3f659fd6b1
19 changed files with 108 additions and 48 deletions

View File

@@ -81,6 +81,8 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n ); void SetNumberOfRowsOrCols( int n );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
// implementation // implementation
bool m_alreadySent; bool m_alreadySent;
@@ -89,6 +91,8 @@ class wxRadioBox: public wxControl
GtkRadioButton *m_radio; GtkRadioButton *m_radio;
DECLARE_EVENT_TABLE()
}; };
#endif // __GTKRADIOBOXH__ #endif // __GTKRADIOBOXH__

View File

@@ -81,6 +81,8 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n ); void SetNumberOfRowsOrCols( int n );
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
// implementation // implementation
bool m_alreadySent; bool m_alreadySent;
@@ -89,6 +91,8 @@ class wxRadioBox: public wxControl
GtkRadioButton *m_radio; GtkRadioButton *m_radio;
DECLARE_EVENT_TABLE()
}; };
#endif // __GTKRADIOBOXH__ #endif // __GTKRADIOBOXH__

View File

@@ -62,7 +62,9 @@ wxStatusBar::wxStatusBar(void)
wxStatusBar::~wxStatusBar(void) wxStatusBar::~wxStatusBar(void)
{ {
#ifdef __WXMSW__
SetFont(wxNullFont); SetFont(wxNullFont);
#endif
if ( m_statusWidths ) if ( m_statusWidths )
delete[] m_statusWidths; delete[] m_statusWidths;

View File

@@ -105,7 +105,10 @@ void wxButton::Enable( bool enable )
void wxButton::SetFont( const wxFont &font ) void wxButton::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -91,7 +91,10 @@ bool wxCheckBox::GetValue(void) const
void wxCheckBox::SetFont( const wxFont &font ) void wxCheckBox::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -53,6 +53,10 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE()
wxRadioBox::wxRadioBox(void) wxRadioBox::wxRadioBox(void)
{ {
} }
@@ -118,6 +122,24 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
return TRUE; return TRUE;
} }
void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) )
{
int x = m_x+5;
int y = m_y+15;
GSList *item = gtk_radio_button_group( m_radio );
while (item)
{
GtkWidget *button = GTK_WIDGET( item->data );
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, x, y );
y += 20;
item = item->next;
}
}
bool wxRadioBox::Show( bool show ) bool wxRadioBox::Show( bool show )
{ {
wxWindow::Show( show ); wxWindow::Show( show );

View File

@@ -88,7 +88,10 @@ bool wxRadioButton::GetValue(void) const
void wxRadioButton::SetFont( const wxFont &font ) void wxRadioButton::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -22,14 +22,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox,wxControl)
wxStaticBox::wxStaticBox(void) wxStaticBox::wxStaticBox(void)
{ {
}; }
wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label, wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
Create( parent, id, label, pos, size, style, name ); Create( parent, id, label, pos, size, style, name );
}; }
bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -47,4 +47,4 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
}; }

View File

@@ -23,14 +23,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
wxStaticText::wxStaticText(void) wxStaticText::wxStaticText(void)
{ {
}; }
wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label, wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
Create( parent, id, label, pos, size, style, name ); Create( parent, id, label, pos, size, style, name );
}; }
bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -95,7 +95,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
}; }
wxString wxStaticText::GetLabel(void) const wxString wxStaticText::GetLabel(void) const
{ {
@@ -103,11 +103,11 @@ wxString wxStaticText::GetLabel(void) const
gtk_label_get( GTK_LABEL(m_widget), &str ); gtk_label_get( GTK_LABEL(m_widget), &str );
wxString tmp( str ); wxString tmp( str );
return tmp; return tmp;
}; }
void wxStaticText::SetLabel( const wxString &label ) void wxStaticText::SetLabel( const wxString &label )
{ {
wxControl::SetLabel(label); wxControl::SetLabel(label);
gtk_label_set( GTK_LABEL(m_widget), m_label ); gtk_label_set( GTK_LABEL(m_widget), m_label );
}; }

View File

@@ -431,7 +431,10 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
void wxTextCtrl::SetFont( const wxFont &font ) void wxTextCtrl::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL; GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle) if (!m_hasOwnStyle)

View File

@@ -1926,20 +1926,12 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
void wxWindow::SetFont( const wxFont &font ) void wxWindow::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
// Unfortunately this results in a crash in GTK on deletion
// of windows, e.g. the wxStatusBar in Dialog Editor.
#if 0
// ADDED BY JACS: not sure if this is the right thing to do,
// but will avoid a segv when SetFont(wxNullFont) is called.
if (((wxFont*) &font)->Ok())
m_font = font; m_font = font;
else else
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle`*) NULL; GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle) if (!m_hasOwnStyle)
{ {
m_hasOwnStyle = TRUE; m_hasOwnStyle = TRUE;
@@ -1954,7 +1946,6 @@ void wxWindow::SetFont( const wxFont &font )
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( m_widget, style ); gtk_widget_set_style( m_widget, style );
#endif
} }
wxFont *wxWindow::GetFont(void) wxFont *wxWindow::GetFont(void)

View File

@@ -105,7 +105,10 @@ void wxButton::Enable( bool enable )
void wxButton::SetFont( const wxFont &font ) void wxButton::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -91,7 +91,10 @@ bool wxCheckBox::GetValue(void) const
void wxCheckBox::SetFont( const wxFont &font ) void wxCheckBox::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -53,6 +53,10 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
EVT_SIZE(wxRadioBox::OnSize)
END_EVENT_TABLE()
wxRadioBox::wxRadioBox(void) wxRadioBox::wxRadioBox(void)
{ {
} }
@@ -118,6 +122,24 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
return TRUE; return TRUE;
} }
void wxRadioBox::OnSize( wxSizeEvent &WXUNUSED(event) )
{
int x = m_x+5;
int y = m_y+15;
GSList *item = gtk_radio_button_group( m_radio );
while (item)
{
GtkWidget *button = GTK_WIDGET( item->data );
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, x, y );
y += 20;
item = item->next;
}
}
bool wxRadioBox::Show( bool show ) bool wxRadioBox::Show( bool show )
{ {
wxWindow::Show( show ); wxWindow::Show( show );

View File

@@ -88,7 +88,10 @@ bool wxRadioButton::GetValue(void) const
void wxRadioButton::SetFont( const wxFont &font ) void wxRadioButton::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkButton *bin = GTK_BUTTON( m_widget ); GtkButton *bin = GTK_BUTTON( m_widget );
GtkWidget *label = bin->child; GtkWidget *label = bin->child;

View File

@@ -22,14 +22,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox,wxControl)
wxStaticBox::wxStaticBox(void) wxStaticBox::wxStaticBox(void)
{ {
}; }
wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label, wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
Create( parent, id, label, pos, size, style, name ); Create( parent, id, label, pos, size, style, name );
}; }
bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -47,4 +47,4 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
}; }

View File

@@ -23,14 +23,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl)
wxStaticText::wxStaticText(void) wxStaticText::wxStaticText(void)
{ {
}; }
wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label, wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
Create( parent, id, label, pos, size, style, name ); Create( parent, id, label, pos, size, style, name );
}; }
bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label, bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
@@ -95,7 +95,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe
Show( TRUE ); Show( TRUE );
return TRUE; return TRUE;
}; }
wxString wxStaticText::GetLabel(void) const wxString wxStaticText::GetLabel(void) const
{ {
@@ -103,11 +103,11 @@ wxString wxStaticText::GetLabel(void) const
gtk_label_get( GTK_LABEL(m_widget), &str ); gtk_label_get( GTK_LABEL(m_widget), &str );
wxString tmp( str ); wxString tmp( str );
return tmp; return tmp;
}; }
void wxStaticText::SetLabel( const wxString &label ) void wxStaticText::SetLabel( const wxString &label )
{ {
wxControl::SetLabel(label); wxControl::SetLabel(label);
gtk_label_set( GTK_LABEL(m_widget), m_label ); gtk_label_set( GTK_LABEL(m_widget), m_label );
}; }

View File

@@ -431,7 +431,10 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
void wxTextCtrl::SetFont( const wxFont &font ) void wxTextCtrl::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle*) NULL; GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle) if (!m_hasOwnStyle)

View File

@@ -1926,20 +1926,12 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
void wxWindow::SetFont( const wxFont &font ) void wxWindow::SetFont( const wxFont &font )
{ {
m_font = font; if (((wxFont*)&font)->Ok())
// Unfortunately this results in a crash in GTK on deletion
// of windows, e.g. the wxStatusBar in Dialog Editor.
#if 0
// ADDED BY JACS: not sure if this is the right thing to do,
// but will avoid a segv when SetFont(wxNullFont) is called.
if (((wxFont*) &font)->Ok())
m_font = font; m_font = font;
else else
m_font = *wxSWISS_FONT; m_font = *wxSWISS_FONT;
GtkStyle *style = (GtkStyle`*) NULL; GtkStyle *style = (GtkStyle*) NULL;
if (!m_hasOwnStyle) if (!m_hasOwnStyle)
{ {
m_hasOwnStyle = TRUE; m_hasOwnStyle = TRUE;
@@ -1954,7 +1946,6 @@ void wxWindow::SetFont( const wxFont &font )
style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
gtk_widget_set_style( m_widget, style ); gtk_widget_set_style( m_widget, style );
#endif
} }
wxFont *wxWindow::GetFont(void) wxFont *wxWindow::GetFont(void)