From 3f659fd6b10a8a5c899eaa99adc76a55322b33fd Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 6 Sep 1998 18:34:18 +0000 Subject: [PATCH] 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 --- include/wx/gtk/radiobox.h | 4 ++++ include/wx/gtk1/radiobox.h | 4 ++++ src/generic/statusbr.cpp | 2 ++ src/gtk/button.cpp | 7 +++++-- src/gtk/checkbox.cpp | 5 ++++- src/gtk/radiobox.cpp | 22 ++++++++++++++++++++++ src/gtk/radiobut.cpp | 5 ++++- src/gtk/statbox.cpp | 6 +++--- src/gtk/stattext.cpp | 10 +++++----- src/gtk/textctrl.cpp | 5 ++++- src/gtk/window.cpp | 13 ++----------- src/gtk1/button.cpp | 7 +++++-- src/gtk1/checkbox.cpp | 5 ++++- src/gtk1/radiobox.cpp | 22 ++++++++++++++++++++++ src/gtk1/radiobut.cpp | 5 ++++- src/gtk1/statbox.cpp | 6 +++--- src/gtk1/stattext.cpp | 10 +++++----- src/gtk1/textctrl.cpp | 5 ++++- src/gtk1/window.cpp | 13 ++----------- 19 files changed, 108 insertions(+), 48 deletions(-) diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h index 443ea706ec..1da4e3d979 100644 --- a/include/wx/gtk/radiobox.h +++ b/include/wx/gtk/radiobox.h @@ -81,6 +81,8 @@ class wxRadioBox: public wxControl void SetNumberOfRowsOrCols( int n ); void SetFont( const wxFont &font ); + void OnSize( wxSizeEvent &event ); + // implementation bool m_alreadySent; @@ -89,6 +91,8 @@ class wxRadioBox: public wxControl GtkRadioButton *m_radio; + DECLARE_EVENT_TABLE() + }; #endif // __GTKRADIOBOXH__ diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h index 443ea706ec..1da4e3d979 100644 --- a/include/wx/gtk1/radiobox.h +++ b/include/wx/gtk1/radiobox.h @@ -81,6 +81,8 @@ class wxRadioBox: public wxControl void SetNumberOfRowsOrCols( int n ); void SetFont( const wxFont &font ); + void OnSize( wxSizeEvent &event ); + // implementation bool m_alreadySent; @@ -89,6 +91,8 @@ class wxRadioBox: public wxControl GtkRadioButton *m_radio; + DECLARE_EVENT_TABLE() + }; #endif // __GTKRADIOBOXH__ diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index fee8fe43f8..8ea6f36bd7 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -62,7 +62,9 @@ wxStatusBar::wxStatusBar(void) wxStatusBar::~wxStatusBar(void) { +#ifdef __WXMSW__ SetFont(wxNullFont); +#endif if ( m_statusWidths ) delete[] m_statusWidths; diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index f10b170bef..034e229f18 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -105,8 +105,11 @@ void wxButton::Enable( bool enable ) 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 2604d6d360..e5b2beb157 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -91,7 +91,10 @@ bool wxCheckBox::GetValue(void) const 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index b42b2e82e0..31e9a8e856 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -53,6 +53,10 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) +BEGIN_EVENT_TABLE(wxRadioBox, wxControl) + EVT_SIZE(wxRadioBox::OnSize) +END_EVENT_TABLE() + wxRadioBox::wxRadioBox(void) { } @@ -118,6 +122,24 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, 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 ) { wxWindow::Show( show ); diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index a0e789bcbd..42fddad8e6 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -88,7 +88,10 @@ bool wxRadioButton::GetValue(void) const 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp index 3f6abe3198..3f28b07a58 100644 --- a/src/gtk/statbox.cpp +++ b/src/gtk/statbox.cpp @@ -22,14 +22,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox,wxControl) wxStaticBox::wxStaticBox(void) { -}; +} wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { Create( parent, id, label, pos, size, style, name ); -}; +} bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, @@ -47,4 +47,4 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label Show( TRUE ); return TRUE; -}; +} diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index 502014914f..b05d93c32c 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -23,14 +23,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl) wxStaticText::wxStaticText(void) { -}; +} wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { Create( parent, id, label, pos, size, style, name ); -}; +} bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, @@ -95,7 +95,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe Show( TRUE ); return TRUE; -}; +} wxString wxStaticText::GetLabel(void) const { @@ -103,11 +103,11 @@ wxString wxStaticText::GetLabel(void) const gtk_label_get( GTK_LABEL(m_widget), &str ); wxString tmp( str ); return tmp; -}; +} void wxStaticText::SetLabel( const wxString &label ) { wxControl::SetLabel(label); gtk_label_set( GTK_LABEL(m_widget), m_label ); -}; +} diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index f5e2643287..7405f2df26 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -431,7 +431,10 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) 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; if (!m_hasOwnStyle) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 8159b280a2..47e9012dcb 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1926,20 +1926,12 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) void wxWindow::SetFont( const wxFont &font ) { - m_font = font; - - // 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()) + if (((wxFont*)&font)->Ok()) m_font = font; else m_font = *wxSWISS_FONT; - GtkStyle *style = (GtkStyle`*) NULL; + GtkStyle *style = (GtkStyle*) NULL; if (!m_hasOwnStyle) { m_hasOwnStyle = TRUE; @@ -1954,7 +1946,6 @@ void wxWindow::SetFont( const wxFont &font ) style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); gtk_widget_set_style( m_widget, style ); -#endif } wxFont *wxWindow::GetFont(void) diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index f10b170bef..034e229f18 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -105,8 +105,11 @@ void wxButton::Enable( bool enable ) 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 2604d6d360..e5b2beb157 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -91,7 +91,10 @@ bool wxCheckBox::GetValue(void) const 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index b42b2e82e0..31e9a8e856 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -53,6 +53,10 @@ static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRad IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) +BEGIN_EVENT_TABLE(wxRadioBox, wxControl) + EVT_SIZE(wxRadioBox::OnSize) +END_EVENT_TABLE() + wxRadioBox::wxRadioBox(void) { } @@ -118,6 +122,24 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, 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 ) { wxWindow::Show( show ); diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index a0e789bcbd..42fddad8e6 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -88,7 +88,10 @@ bool wxRadioButton::GetValue(void) const 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 ); GtkWidget *label = bin->child; diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp index 3f6abe3198..3f28b07a58 100644 --- a/src/gtk1/statbox.cpp +++ b/src/gtk1/statbox.cpp @@ -22,14 +22,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBox,wxControl) wxStaticBox::wxStaticBox(void) { -}; +} wxStaticBox::wxStaticBox( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { Create( parent, id, label, pos, size, style, name ); -}; +} bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, @@ -47,4 +47,4 @@ bool wxStaticBox::Create( wxWindow *parent, wxWindowID id, const wxString &label Show( TRUE ); return TRUE; -}; +} diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index 502014914f..b05d93c32c 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -23,14 +23,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl) wxStaticText::wxStaticText(void) { -}; +} wxStaticText::wxStaticText( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { Create( parent, id, label, pos, size, style, name ); -}; +} bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, @@ -95,7 +95,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe Show( TRUE ); return TRUE; -}; +} wxString wxStaticText::GetLabel(void) const { @@ -103,11 +103,11 @@ wxString wxStaticText::GetLabel(void) const gtk_label_get( GTK_LABEL(m_widget), &str ); wxString tmp( str ); return tmp; -}; +} void wxStaticText::SetLabel( const wxString &label ) { wxControl::SetLabel(label); gtk_label_set( GTK_LABEL(m_widget), m_label ); -}; +} diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index f5e2643287..7405f2df26 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -431,7 +431,10 @@ bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) 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; if (!m_hasOwnStyle) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 8159b280a2..47e9012dcb 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1926,20 +1926,12 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) void wxWindow::SetFont( const wxFont &font ) { - m_font = font; - - // 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()) + if (((wxFont*)&font)->Ok()) m_font = font; else m_font = *wxSWISS_FONT; - GtkStyle *style = (GtkStyle`*) NULL; + GtkStyle *style = (GtkStyle*) NULL; if (!m_hasOwnStyle) { m_hasOwnStyle = TRUE; @@ -1954,7 +1946,6 @@ void wxWindow::SetFont( const wxFont &font ) style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); gtk_widget_set_style( m_widget, style ); -#endif } wxFont *wxWindow::GetFont(void) -- 2.45.2