From ae0bdb016fb973f49765101e3ba14f898aada4e7 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 12 Dec 1998 17:27:01 +0000 Subject: [PATCH] More colour finetuning Corrected wxCheckBoc and wxRadioButton::SetValue git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/controls/controls.cpp | 4 ++- src/gtk/checkbox.cpp | 7 ++-- src/gtk/radiobut.cpp | 4 +-- src/gtk/textctrl.cpp | 65 ++++++++++++++++++++--------------- src/gtk/window.cpp | 50 +++++++++++++++++++++------ src/gtk1/checkbox.cpp | 7 ++-- src/gtk1/radiobut.cpp | 4 +-- src/gtk1/textctrl.cpp | 65 ++++++++++++++++++++--------------- src/gtk1/window.cpp | 50 +++++++++++++++++++++------ 9 files changed, 163 insertions(+), 93 deletions(-) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index d67b979d0a..371df8a09e 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -90,6 +90,7 @@ class MyPanel: public wxPanel wxSpinButton *m_spinbutton; wxTextCtrl *m_spintext; wxTextCtrl *m_multitext; + wxCheckBox *m_checkbox; wxTextCtrl *m_text; wxNotebook *m_notebook; @@ -310,7 +311,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); button = new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); // button->SetForegroundColour( "red" ); - (void)new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); + m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) ); m_notebook->AddPage(panel, "wxList", FALSE, Image_List); panel = new wxPanel(m_notebook); @@ -505,6 +506,7 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) case ID_LISTBOX_FONT: { m_listbox->SetFont( *wxITALIC_FONT ); + m_checkbox->SetFont( *wxITALIC_FONT ); break; } } diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 36753bd61b..6e94fdfceb 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -95,13 +95,10 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label void wxCheckBox::SetValue( bool state ) { wxCHECK_RET( m_widget != NULL, "invalid checkbox" ); - - if (state) - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_ACTIVE ); - else - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_NORMAL ); m_blockFirstEvent = TRUE; + + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), state ); } bool wxCheckBox::GetValue() const diff --git a/src/gtk/radiobut.cpp b/src/gtk/radiobut.cpp index a0a40eb861..ffe7dfa874 100644 --- a/src/gtk/radiobut.cpp +++ b/src/gtk/radiobut.cpp @@ -102,9 +102,9 @@ void wxRadioButton::SetValue( bool val ) { wxCHECK_RET( m_widget != NULL, "invalid radiobutton" ); - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val ); - m_blockFirstEvent = TRUE; + + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val ); } bool wxRadioButton::GetValue(void) const diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index c2fb43427b..8891fd63fb 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -13,7 +13,8 @@ #include "wx/textctrl.h" #include "wx/utils.h" -#include +#include "wx/intl.h" +#include "wx/settings.h" #include #include @@ -645,57 +646,65 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) GtkWidget* wxTextCtrl::GetConnectWidget() { - return GTK_WIDGET(m_text); + return GTK_WIDGET(m_text); } bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) { - if (m_windowStyle & wxTE_MULTILINE) - return (window == GTK_TEXT(m_text)->text_area); - else - return (window == GTK_ENTRY(m_text)->text_area); + if (m_windowStyle & wxTE_MULTILINE) + return (window == GTK_TEXT(m_text)->text_area); + else + return (window == GTK_ENTRY(m_text)->text_area); } void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - // doesn't work + // doesn't work } void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - // doesn't work + // doesn't work } void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - wxControl::SetBackgroundColour( colour ); + wxControl::SetBackgroundColour( colour ); - if (!m_backgroundColour.Ok()) return; + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + return; + } + + if (!m_backgroundColour.Ok()) return; - if (m_windowStyle & wxTE_MULTILINE) - { - GdkWindow *window = GTK_TEXT(m_text)->text_area; - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); - gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); - } + if (m_windowStyle & wxTE_MULTILINE) + { + GdkWindow *window = GTK_TEXT(m_text)->text_area; + m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + gdk_window_set_background( window, m_backgroundColour.GetColor() ); + gdk_window_clear( window ); + } } void wxTextCtrl::ApplyWidgetStyle() { - if (m_windowStyle & wxTE_MULTILINE) - { - } - else - { - SetWidgetStyle(); - gtk_widget_set_style( m_text, m_widgetStyle ); - } + if (m_windowStyle & wxTE_MULTILINE) + { + } + else + { + SetWidgetStyle(); + gtk_widget_set_style( m_text, m_widgetStyle ); + } } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index f35ab5fb86..3a1c153c6e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2164,14 +2164,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) if (m_backgroundColour == colour) return; - wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); - if (sysbg.Red() == colour.Red() && - sysbg.Green() == colour.Green() && - sysbg.Blue() == colour.Blue()) - { - return; - } - m_backgroundColour = colour; if (!m_backgroundColour.Ok()) return; @@ -2183,7 +2175,19 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) gdk_window_clear( window ); } - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } wxColour wxWindow::GetForegroundColour() const @@ -2200,7 +2204,19 @@ void wxWindow::SetForegroundColour( const wxColour &colour ) m_foregroundColour = colour; if (!m_foregroundColour.Ok()) return; - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } GtkStyle *wxWindow::GetWidgetStyle() @@ -2395,7 +2411,19 @@ void wxWindow::SetFont( const wxFont &font ) else m_font = *wxSWISS_FONT; - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == m_backgroundColour.Red() && + sysbg.Green() == m_backgroundColour.Green() && + sysbg.Blue() == m_backgroundColour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } void wxWindow::SetWindowStyleFlag( long flag ) diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index 36753bd61b..6e94fdfceb 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -95,13 +95,10 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label void wxCheckBox::SetValue( bool state ) { wxCHECK_RET( m_widget != NULL, "invalid checkbox" ); - - if (state) - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_ACTIVE ); - else - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), GTK_STATE_NORMAL ); m_blockFirstEvent = TRUE; + + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), state ); } bool wxCheckBox::GetValue() const diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp index a0a40eb861..ffe7dfa874 100644 --- a/src/gtk1/radiobut.cpp +++ b/src/gtk1/radiobut.cpp @@ -102,9 +102,9 @@ void wxRadioButton::SetValue( bool val ) { wxCHECK_RET( m_widget != NULL, "invalid radiobutton" ); - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val ); - m_blockFirstEvent = TRUE; + + gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), val ); } bool wxRadioButton::GetValue(void) const diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index c2fb43427b..8891fd63fb 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -13,7 +13,8 @@ #include "wx/textctrl.h" #include "wx/utils.h" -#include +#include "wx/intl.h" +#include "wx/settings.h" #include #include @@ -645,57 +646,65 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c) GtkWidget* wxTextCtrl::GetConnectWidget() { - return GTK_WIDGET(m_text); + return GTK_WIDGET(m_text); } bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) { - if (m_windowStyle & wxTE_MULTILINE) - return (window == GTK_TEXT(m_text)->text_area); - else - return (window == GTK_ENTRY(m_text)->text_area); + if (m_windowStyle & wxTE_MULTILINE) + return (window == GTK_TEXT(m_text)->text_area); + else + return (window == GTK_ENTRY(m_text)->text_area); } void wxTextCtrl::SetFont( const wxFont &WXUNUSED(font) ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - // doesn't work + // doesn't work } void wxTextCtrl::SetForegroundColour( const wxColour &WXUNUSED(colour) ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - // doesn't work + // doesn't work } void wxTextCtrl::SetBackgroundColour( const wxColour &colour ) { - wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); + wxCHECK_RET( m_text != NULL, "invalid text ctrl" ); - wxControl::SetBackgroundColour( colour ); + wxControl::SetBackgroundColour( colour ); - if (!m_backgroundColour.Ok()) return; + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + return; + } + + if (!m_backgroundColour.Ok()) return; - if (m_windowStyle & wxTE_MULTILINE) - { - GdkWindow *window = GTK_TEXT(m_text)->text_area; - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); - gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); - } + if (m_windowStyle & wxTE_MULTILINE) + { + GdkWindow *window = GTK_TEXT(m_text)->text_area; + m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); + gdk_window_set_background( window, m_backgroundColour.GetColor() ); + gdk_window_clear( window ); + } } void wxTextCtrl::ApplyWidgetStyle() { - if (m_windowStyle & wxTE_MULTILINE) - { - } - else - { - SetWidgetStyle(); - gtk_widget_set_style( m_text, m_widgetStyle ); - } + if (m_windowStyle & wxTE_MULTILINE) + { + } + else + { + SetWidgetStyle(); + gtk_widget_set_style( m_text, m_widgetStyle ); + } } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index f35ab5fb86..3a1c153c6e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2164,14 +2164,6 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) if (m_backgroundColour == colour) return; - wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); - if (sysbg.Red() == colour.Red() && - sysbg.Green() == colour.Green() && - sysbg.Blue() == colour.Blue()) - { - return; - } - m_backgroundColour = colour; if (!m_backgroundColour.Ok()) return; @@ -2183,7 +2175,19 @@ void wxWindow::SetBackgroundColour( const wxColour &colour ) gdk_window_clear( window ); } - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } wxColour wxWindow::GetForegroundColour() const @@ -2200,7 +2204,19 @@ void wxWindow::SetForegroundColour( const wxColour &colour ) m_foregroundColour = colour; if (!m_foregroundColour.Ok()) return; - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == colour.Red() && + sysbg.Green() == colour.Green() && + sysbg.Blue() == colour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } GtkStyle *wxWindow::GetWidgetStyle() @@ -2395,7 +2411,19 @@ void wxWindow::SetFont( const wxFont &font ) else m_font = *wxSWISS_FONT; - ApplyWidgetStyle(); + wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ); + if (sysbg.Red() == m_backgroundColour.Red() && + sysbg.Green() == m_backgroundColour.Green() && + sysbg.Blue() == m_backgroundColour.Blue()) + { + m_backgroundColour = wxNullColour; + ApplyWidgetStyle(); + m_backgroundColour = sysbg; + } + else + { + ApplyWidgetStyle(); + } } void wxWindow::SetWindowStyleFlag( long flag ) -- 2.45.2