1
// Berkeley Open Infrastructure for Network Computing
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2005 University of California
5
// This is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU Lesser General Public
7
// License as published by the Free Software Foundation;
8
// either version 2.1 of the License, or (at your option) any later version.
10
// This software is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// To view the GNU Lesser General Public License visit
16
// http://www.gnu.org/copyleft/lesser.html
17
// or write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
#if defined(__GNUG__) && !defined(__APPLE__)
21
#pragma implementation "sg_CustomControls.h"
25
#include "sg_CustomControls.h"
28
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticLine, wxPanel)
30
BEGIN_EVENT_TABLE(CTransparentStaticLine, wxPanel)
31
EVT_PAINT(CTransparentStaticLine::OnPaint)
35
CTransparentStaticLine::CTransparentStaticLine() {}
37
CTransparentStaticLine::CTransparentStaticLine(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
38
Create(parent, id, pos, size, style, name);
42
bool CTransparentStaticLine::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
43
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
45
SetBackgroundColour(parent->GetBackgroundColour());
46
SetBackgroundStyle(wxBG_STYLE_COLOUR);
47
SetForegroundColour(parent->GetForegroundColour());
53
void CTransparentStaticLine::OnPaint(wxPaintEvent& /*event*/) {
55
wxPen pen = wxPen(GetLineColor(), 1);
57
dc.DrawLine(0, 0, GetSize().GetWidth(), 0);
61
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticText, wxStaticText)
63
BEGIN_EVENT_TABLE(CTransparentStaticText, wxStaticText)
65
EVT_ERASE_BACKGROUND(CTransparentStaticText::OnEraseBackground)
67
EVT_PAINT(CTransparentStaticText::OnPaint)
71
CTransparentStaticText::CTransparentStaticText() {}
73
CTransparentStaticText::CTransparentStaticText(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
74
Create(parent, id, label, pos, size, style, name);
78
bool CTransparentStaticText::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
79
bool bRetVal = wxStaticText::Create(parent, id, label, pos, size, style|wxTRANSPARENT_WINDOW, name);
81
SetBackgroundColour(parent->GetBackgroundColour());
82
SetBackgroundStyle(wxBG_STYLE_COLOUR);
83
SetForegroundColour(parent->GetForegroundColour());
89
void CTransparentStaticText::OnPaint(wxPaintEvent& /*event*/) {
91
dc.SetFont(GetFont());
92
dc.DrawText(GetLabel(), 0, 0);
96
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticTextAssociate, wxPanel)
98
BEGIN_EVENT_TABLE(CTransparentStaticTextAssociate, wxPanel)
99
EVT_ERASE_BACKGROUND(CTransparentStaticTextAssociate::OnEraseBackground)
100
EVT_PAINT(CTransparentStaticTextAssociate::OnPaint)
101
EVT_MOUSE_EVENTS(CTransparentStaticTextAssociate::OnMouse)
105
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate() {}
107
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
108
Create(parent, id, label, pos, size, style, name);
112
bool CTransparentStaticTextAssociate::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
113
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
120
SetBackgroundColour(parent->GetBackgroundColour());
121
SetBackgroundStyle(wxBG_STYLE_COLOUR);
122
SetForegroundColour(parent->GetForegroundColour());
128
bool CTransparentStaticTextAssociate::SetFont(const wxFont& font) {
130
bool ret = wxPanel::SetFont(font);
132
InvalidateBestSize();
134
wxCoord width, height;
137
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
139
CacheBestSize(wxSize(width, height));
145
// Due to the nature of how wxWidgets handles some controls when Windows XP
146
// themes are enabled, it is easier to make a simulated CheckBox or
147
// RadioButton by linking two windows together. So when a mouse event
148
// happens with this window it forwards the event to the associated
150
bool CTransparentStaticTextAssociate::AssociateWindow(wxWindow* pWnd) {
156
void CTransparentStaticTextAssociate::OnPaint(wxPaintEvent& /*event*/) {
158
dc.SetFont(GetFont());
159
dc.DrawText(GetLabel(), 1, 1);
163
void CTransparentStaticTextAssociate::OnMouse(wxMouseEvent& event) {
165
wxMouseEvent evtAssociate(event);
166
evtAssociate.SetId(m_pWnd->GetId());
167
m_pWnd->ProcessEvent(event);
170
// If we get the left button up event and we already had focus, that must
171
// mean the user clicked on the static text, So change the associated
172
// control so that it has been clicked.
173
if (event.GetEventType() == wxEVT_LEFT_UP) {
174
wxCheckBox* pCheckBox = wxDynamicCast(m_pWnd, wxCheckBox);
176
// Send the updated click event
177
wxCommandEvent evtCheckBox(wxEVT_COMMAND_CHECKBOX_CLICKED, pCheckBox->GetId());
178
evtCheckBox.SetEventObject(pCheckBox);
179
if (pCheckBox->IsChecked()) {
180
evtCheckBox.SetInt(wxCHK_UNCHECKED);
182
evtCheckBox.SetInt(wxCHK_CHECKED);
184
pCheckBox->Command(evtCheckBox);
191
IMPLEMENT_DYNAMIC_CLASS (CLinkButton, wxBitmapButton)
193
BEGIN_EVENT_TABLE(CLinkButton, wxBitmapButton)
194
EVT_MOUSE_EVENTS(CLinkButton::OnMouse)
198
CLinkButton::CLinkButton() {}
200
CLinkButton::CLinkButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
201
Create(parent, id, bitmap, pos, size, style, validator, name);
205
bool CLinkButton::Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
206
bool bRetVal = wxBitmapButton::Create(parent, id, bitmap, pos, size, style, validator, name);
208
m_HandCursor = wxCursor(wxCURSOR_HAND);
214
void CLinkButton::OnMouse(wxMouseEvent& event) {
215
if (event.Entering()) {
216
SetCursor(m_HandCursor);
217
} else if (event.Leaving()) {
218
SetCursor(*wxSTANDARD_CURSOR);
1
// This file is part of BOINC.
2
// http://boinc.berkeley.edu
3
// Copyright (C) 2008 University of California
5
// BOINC is free software; you can redistribute it and/or modify it
6
// under the terms of the GNU Lesser General Public License
7
// as published by the Free Software Foundation,
8
// either version 3 of the License, or (at your option) any later version.
10
// BOINC is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
// See the GNU Lesser General Public License for more details.
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
18
#if defined(__GNUG__) && !defined(__APPLE__)
19
#pragma implementation "sg_CustomControls.h"
23
#include "sg_CustomControls.h"
26
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticLine, wxPanel)
28
BEGIN_EVENT_TABLE(CTransparentStaticLine, wxPanel)
29
EVT_PAINT(CTransparentStaticLine::OnPaint)
33
CTransparentStaticLine::CTransparentStaticLine() {}
35
CTransparentStaticLine::CTransparentStaticLine(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
36
Create(parent, id, pos, size, style, name);
40
bool CTransparentStaticLine::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
41
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
43
SetBackgroundColour(parent->GetBackgroundColour());
44
SetBackgroundStyle(wxBG_STYLE_COLOUR);
45
SetForegroundColour(parent->GetForegroundColour());
51
void CTransparentStaticLine::OnPaint(wxPaintEvent& /*event*/) {
53
wxPen pen = wxPen(GetLineColor(), 1);
55
dc.DrawLine(0, 0, GetSize().GetWidth(), 0);
59
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticText, wxStaticText)
61
BEGIN_EVENT_TABLE(CTransparentStaticText, wxStaticText)
63
EVT_ERASE_BACKGROUND(CTransparentStaticText::OnEraseBackground)
65
EVT_PAINT(CTransparentStaticText::OnPaint)
69
CTransparentStaticText::CTransparentStaticText() {}
71
CTransparentStaticText::CTransparentStaticText(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
72
Create(parent, id, label, pos, size, style, name);
76
bool CTransparentStaticText::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
77
bool bRetVal = wxStaticText::Create(parent, id, label, pos, size, style|wxTRANSPARENT_WINDOW, name);
79
SetBackgroundColour(parent->GetBackgroundColour());
80
SetBackgroundStyle(wxBG_STYLE_COLOUR);
81
SetForegroundColour(parent->GetForegroundColour());
87
void CTransparentStaticText::OnPaint(wxPaintEvent& /*event*/) {
89
dc.SetFont(GetFont());
90
dc.DrawText(GetLabel(), 0, 0);
94
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticTextAssociate, wxPanel)
96
BEGIN_EVENT_TABLE(CTransparentStaticTextAssociate, wxPanel)
97
EVT_ERASE_BACKGROUND(CTransparentStaticTextAssociate::OnEraseBackground)
98
EVT_PAINT(CTransparentStaticTextAssociate::OnPaint)
99
EVT_MOUSE_EVENTS(CTransparentStaticTextAssociate::OnMouse)
103
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate() {}
105
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
106
Create(parent, id, label, pos, size, style, name);
110
bool CTransparentStaticTextAssociate::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
111
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
118
SetBackgroundColour(parent->GetBackgroundColour());
119
SetBackgroundStyle(wxBG_STYLE_COLOUR);
120
SetForegroundColour(parent->GetForegroundColour());
126
bool CTransparentStaticTextAssociate::SetFont(const wxFont& font) {
128
bool ret = wxPanel::SetFont(font);
130
InvalidateBestSize();
132
wxCoord width, height;
135
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
137
CacheBestSize(wxSize(width, height));
143
// Due to the nature of how wxWidgets handles some controls when Windows XP
144
// themes are enabled, it is easier to make a simulated CheckBox or
145
// RadioButton by linking two windows together. So when a mouse event
146
// happens with this window it forwards the event to the associated
148
bool CTransparentStaticTextAssociate::AssociateWindow(wxWindow* pWnd) {
154
void CTransparentStaticTextAssociate::OnPaint(wxPaintEvent& /*event*/) {
156
dc.SetFont(GetFont());
157
dc.DrawText(GetLabel(), 1, 1);
161
void CTransparentStaticTextAssociate::OnMouse(wxMouseEvent& event) {
163
wxMouseEvent evtAssociate(event);
164
evtAssociate.SetId(m_pWnd->GetId());
165
m_pWnd->ProcessEvent(event);
168
// If we get the left button up event and we already had focus, that must
169
// mean the user clicked on the static text, So change the associated
170
// control so that it has been clicked.
171
if (event.GetEventType() == wxEVT_LEFT_UP) {
172
wxCheckBox* pCheckBox = wxDynamicCast(m_pWnd, wxCheckBox);
174
// Send the updated click event
175
wxCommandEvent evtCheckBox(wxEVT_COMMAND_CHECKBOX_CLICKED, pCheckBox->GetId());
176
evtCheckBox.SetEventObject(pCheckBox);
177
if (pCheckBox->IsChecked()) {
178
evtCheckBox.SetInt(wxCHK_UNCHECKED);
180
evtCheckBox.SetInt(wxCHK_CHECKED);
182
pCheckBox->Command(evtCheckBox);
189
IMPLEMENT_DYNAMIC_CLASS (CLinkButton, wxBitmapButton)
191
BEGIN_EVENT_TABLE(CLinkButton, wxBitmapButton)
192
EVT_MOUSE_EVENTS(CLinkButton::OnMouse)
196
CLinkButton::CLinkButton() {}
198
CLinkButton::CLinkButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
199
Create(parent, id, bitmap, pos, size, style, validator, name);
203
bool CLinkButton::Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
204
bool bRetVal = wxBitmapButton::Create(parent, id, bitmap, pos, size, style, validator, name);
206
m_HandCursor = wxCursor(wxCURSOR_HAND);
212
void CLinkButton::OnMouse(wxMouseEvent& event) {
213
if (event.Entering()) {
214
SetCursor(m_HandCursor);
215
} else if (event.Leaving()) {
216
SetCursor(*wxSTANDARD_CURSOR);