diff --git a/clientgui/sg_BoincSimpleFrame.cpp b/clientgui/sg_BoincSimpleFrame.cpp index 43b7a48a0b..b4f7260b78 100644 --- a/clientgui/sg_BoincSimpleFrame.cpp +++ b/clientgui/sg_BoincSimpleFrame.cpp @@ -42,6 +42,7 @@ #include "version.h" #include "sg_BoincSimpleFrame.h" +#include "sg_CustomControls.h" #include "sg_TaskPanel.h" #include "sg_ProjectPanel.h" #include "sg_DlgMessages.h" @@ -744,7 +745,7 @@ CSimpleGUIPanel::CSimpleGUIPanel(wxWindow* parent) : wxBoxSizer* buttonsSizer; buttonsSizer = new wxBoxSizer( wxHORIZONTAL ); - m_NoticesButton = new wxButton( this, ID_SGNOTICESBUTTON, _("Notices"), wxDefaultPosition, wxDefaultSize, 0 ); + m_NoticesButton = new CTransparentButton( this, ID_SGNOTICESBUTTON, _("Notices"), wxDefaultPosition, wxDefaultSize, 0 ); m_NoticesButton->SetToolTip( _("Open a window to view notices from projects or BOINC")); buttonsSizer->Add( m_NoticesButton, 0, wxEXPAND | wxALIGN_LEFT, 0 ); buttonsSizer->AddStretchSpacer(); @@ -754,7 +755,7 @@ CSimpleGUIPanel::CSimpleGUIPanel(wxWindow* parent) : GetTextExtent(m_sResumeString, &resumeWidth, &y); m_bIsSuspended = suspendWidth > resumeWidth; - m_SuspendResumeButton = new wxButton( this, ID_SGSUSPENDRESUMEBUTTON, + m_SuspendResumeButton = new CTransparentButton( this, ID_SGSUSPENDRESUMEBUTTON, m_bIsSuspended ? m_sSuspendString : m_sResumeString, wxDefaultPosition, wxDefaultSize, 0 ); m_SuspendResumeButton->SetToolTip(wxEmptyString); @@ -762,7 +763,7 @@ CSimpleGUIPanel::CSimpleGUIPanel(wxWindow* parent) : buttonsSizer->Add( m_SuspendResumeButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 ); buttonsSizer->AddStretchSpacer(); - m_HelpButton = new wxButton( this, ID_SIMPLE_HELP, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); + m_HelpButton = new CTransparentButton( this, ID_SIMPLE_HELP, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); buttonsSizer->Add( m_HelpButton, 0, wxEXPAND | wxALIGN_RIGHT, 0 ); wxString helpTip; diff --git a/clientgui/sg_BoincSimpleFrame.h b/clientgui/sg_BoincSimpleFrame.h index 7e5b08f07e..aaf92be7ae 100644 --- a/clientgui/sg_BoincSimpleFrame.h +++ b/clientgui/sg_BoincSimpleFrame.h @@ -25,6 +25,7 @@ #pragma interface "sg_BoincSimpleFrame.cpp" #endif +class CTransparentButton; class CSimpleTaskPanel; class CSimpleProjectPanel; class CSimpleTaskPanel; @@ -79,9 +80,9 @@ protected: int m_iRedRingRadius; #endif wxBitmap m_bmpBg; - wxButton *m_NoticesButton; - wxButton *m_SuspendResumeButton; - wxButton *m_HelpButton; + CTransparentButton *m_NoticesButton; + CTransparentButton *m_SuspendResumeButton; + CTransparentButton *m_HelpButton; wxString m_sSuspendString; wxString m_sResumeString; int m_oldWorkCount; diff --git a/clientgui/sg_CustomControls.cpp b/clientgui/sg_CustomControls.cpp index ddc63200fe..aa00ceb7e1 100644 --- a/clientgui/sg_CustomControls.cpp +++ b/clientgui/sg_CustomControls.cpp @@ -100,6 +100,40 @@ void CTransparentStaticText::OnPaint(wxPaintEvent& /*event*/) { } +IMPLEMENT_DYNAMIC_CLASS (CTransparentButton, wxButton) + +BEGIN_EVENT_TABLE(CTransparentButton, wxButton) + EVT_ERASE_BACKGROUND(CTransparentButton::OnEraseBackground) +END_EVENT_TABLE() + +CTransparentButton::CTransparentButton() {} + +CTransparentButton::CTransparentButton(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) +{ + Create(parent, id, label, pos, size, style, validator, name); +} + +bool CTransparentButton::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) +{ + bool bRetVal = wxButton::Create(parent, id, label, pos, size, style|wxTRANSPARENT_WINDOW, validator, name); + + SetBackgroundStyle(wxBG_STYLE_CUSTOM); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); + + return bRetVal; +} + +void CTransparentButton::SetLabel(const wxString& label) +{ + wxButton::SetLabel(label); +} + +void CTransparentButton::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) +{ +} + + IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticTextAssociate, wxPanel) BEGIN_EVENT_TABLE(CTransparentStaticTextAssociate, wxPanel) diff --git a/clientgui/sg_CustomControls.h b/clientgui/sg_CustomControls.h index 7446204e16..1996ba80d9 100644 --- a/clientgui/sg_CustomControls.h +++ b/clientgui/sg_CustomControls.h @@ -100,6 +100,42 @@ public: }; +class CTransparentButton : public wxButton +{ + DECLARE_DYNAMIC_CLASS (CTransparentButton) + DECLARE_EVENT_TABLE() + +public: + CTransparentButton(); + CTransparentButton( + wxWindow* parent, + wxWindowID id, + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr + ); + + bool Create( + wxWindow* parent, + wxWindowID id, + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxButtonNameStr + ); + + virtual bool HasTransparentBackground() { return true; }; + + virtual void SetLabel(const wxString& label); + virtual void OnEraseBackground(wxEraseEvent& event); +}; + + class CTransparentStaticTextAssociate : public wxPanel { DECLARE_DYNAMIC_CLASS (CTransparentStaticTextAssociate)