2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2006-10-28 09:02:46 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2006-10-28 09:02:46 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2006-10-28 09:02:46 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2006-10-28 09:02:46 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2006-10-28 09:02:46 +00:00
|
|
|
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "sg_CustomControls.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "sg_CustomControls.h"
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticLine, wxPanel)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CTransparentStaticLine, wxPanel)
|
|
|
|
EVT_PAINT(CTransparentStaticLine::OnPaint)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
CTransparentStaticLine::CTransparentStaticLine() {}
|
|
|
|
|
|
|
|
CTransparentStaticLine::CTransparentStaticLine(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
|
|
|
|
Create(parent, id, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CTransparentStaticLine::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
|
2006-10-30 00:19:58 +00:00
|
|
|
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
|
2006-10-28 09:02:46 +00:00
|
|
|
|
|
|
|
SetBackgroundColour(parent->GetBackgroundColour());
|
|
|
|
SetBackgroundStyle(wxBG_STYLE_COLOUR);
|
|
|
|
SetForegroundColour(parent->GetForegroundColour());
|
2012-10-26 06:06:14 +00:00
|
|
|
SetLineColor(GetForegroundColour());
|
2006-10-28 09:02:46 +00:00
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTransparentStaticLine::OnPaint(wxPaintEvent& /*event*/) {
|
2012-10-26 06:06:14 +00:00
|
|
|
wxPaintDC dc(this);
|
2006-10-28 09:02:46 +00:00
|
|
|
wxPen pen = wxPen(GetLineColor(), 1);
|
|
|
|
dc.SetPen(pen);
|
|
|
|
dc.DrawLine(0, 0, GetSize().GetWidth(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticText, wxStaticText)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CTransparentStaticText, wxStaticText)
|
2006-11-01 08:58:24 +00:00
|
|
|
EVT_ERASE_BACKGROUND(CTransparentStaticText::OnEraseBackground)
|
2012-10-25 10:00:42 +00:00
|
|
|
#ifndef __WXMAC__
|
2006-10-28 09:02:46 +00:00
|
|
|
EVT_PAINT(CTransparentStaticText::OnPaint)
|
2012-10-25 10:00:42 +00:00
|
|
|
#endif
|
2006-10-28 09:02:46 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
CTransparentStaticText::CTransparentStaticText() {}
|
|
|
|
|
2011-03-29 19:28:27 +00:00
|
|
|
CTransparentStaticText::CTransparentStaticText(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& WXUNUSED(name) ) {
|
2011-01-27 14:36:49 +00:00
|
|
|
// Set name same as label for accessibility on Windows
|
|
|
|
Create(parent, id, label, pos, size, style, label);
|
2006-10-28 09:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CTransparentStaticText::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
|
|
|
|
bool bRetVal = wxStaticText::Create(parent, id, label, pos, size, style|wxTRANSPARENT_WINDOW, name);
|
|
|
|
|
|
|
|
SetBackgroundColour(parent->GetBackgroundColour());
|
2012-10-24 11:32:38 +00:00
|
|
|
// SetBackgroundStyle(wxBG_STYLE_COLOUR);
|
2006-10-28 09:02:46 +00:00
|
|
|
SetForegroundColour(parent->GetForegroundColour());
|
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-25 10:00:42 +00:00
|
|
|
#ifndef __WXMAC__
|
2006-10-28 09:02:46 +00:00
|
|
|
void CTransparentStaticText::OnPaint(wxPaintEvent& /*event*/) {
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
dc.SetFont(GetFont());
|
|
|
|
dc.DrawText(GetLabel(), 0, 0);
|
|
|
|
}
|
2012-10-25 10:00:42 +00:00
|
|
|
#endif
|
2006-10-28 09:02:46 +00:00
|
|
|
|
2013-02-14 21:43:31 +00:00
|
|
|
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))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 00:24:26 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticTextAssociate, wxPanel)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CTransparentStaticTextAssociate, wxPanel)
|
|
|
|
EVT_ERASE_BACKGROUND(CTransparentStaticTextAssociate::OnEraseBackground)
|
|
|
|
EVT_PAINT(CTransparentStaticTextAssociate::OnPaint)
|
|
|
|
EVT_MOUSE_EVENTS(CTransparentStaticTextAssociate::OnMouse)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate() {}
|
|
|
|
|
|
|
|
CTransparentStaticTextAssociate::CTransparentStaticTextAssociate(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);
|
2006-10-28 09:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 00:24:26 +00:00
|
|
|
bool CTransparentStaticTextAssociate::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) {
|
|
|
|
bool bRetVal = wxPanel::Create(parent, id, pos, size, style|wxTRANSPARENT_WINDOW, name);
|
|
|
|
|
|
|
|
m_pWnd = NULL;
|
|
|
|
|
|
|
|
SetLabel(label);
|
|
|
|
SetFont(GetFont());
|
|
|
|
|
|
|
|
SetBackgroundColour(parent->GetBackgroundColour());
|
|
|
|
SetBackgroundStyle(wxBG_STYLE_COLOUR);
|
|
|
|
SetForegroundColour(parent->GetForegroundColour());
|
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CTransparentStaticTextAssociate::SetFont(const wxFont& font) {
|
|
|
|
|
|
|
|
bool ret = wxPanel::SetFont(font);
|
|
|
|
|
|
|
|
InvalidateBestSize();
|
|
|
|
|
|
|
|
wxCoord width, height;
|
|
|
|
wxClientDC dc(this);
|
|
|
|
dc.SetFont(font);
|
|
|
|
dc.GetMultiLineTextExtent(GetLabel(), &width, &height);
|
|
|
|
|
|
|
|
CacheBestSize(wxSize(width, height));
|
|
|
|
|
|
|
|
return ret;
|
2006-10-28 09:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Due to the nature of how wxWidgets handles some controls when Windows XP
|
|
|
|
// themes are enabled, it is easier to make a simulated CheckBox or
|
|
|
|
// RadioButton by linking two windows together. So when a mouse event
|
|
|
|
// happens with this window it forwards the event to the associated
|
|
|
|
// window.
|
2006-10-29 00:24:26 +00:00
|
|
|
bool CTransparentStaticTextAssociate::AssociateWindow(wxWindow* pWnd) {
|
2006-10-28 09:02:46 +00:00
|
|
|
m_pWnd = pWnd;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-29 00:24:26 +00:00
|
|
|
void CTransparentStaticTextAssociate::OnPaint(wxPaintEvent& /*event*/) {
|
|
|
|
wxPaintDC dc(this);
|
|
|
|
dc.SetFont(GetFont());
|
|
|
|
dc.DrawText(GetLabel(), 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTransparentStaticTextAssociate::OnMouse(wxMouseEvent& event) {
|
|
|
|
if (m_pWnd) {
|
|
|
|
wxMouseEvent evtAssociate(event);
|
|
|
|
evtAssociate.SetId(m_pWnd->GetId());
|
2012-10-16 19:56:34 +00:00
|
|
|
m_pWnd->GetEventHandler()->ProcessEvent(event);
|
2006-10-29 00:24:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we get the left button up event and we already had focus, that must
|
|
|
|
// mean the user clicked on the static text, So change the associated
|
|
|
|
// control so that it has been clicked.
|
|
|
|
if (event.GetEventType() == wxEVT_LEFT_UP) {
|
|
|
|
wxCheckBox* pCheckBox = wxDynamicCast(m_pWnd, wxCheckBox);
|
|
|
|
if (pCheckBox) {
|
|
|
|
// Send the updated click event
|
|
|
|
wxCommandEvent evtCheckBox(wxEVT_COMMAND_CHECKBOX_CLICKED, pCheckBox->GetId());
|
|
|
|
evtCheckBox.SetEventObject(pCheckBox);
|
|
|
|
if (pCheckBox->IsChecked()) {
|
|
|
|
evtCheckBox.SetInt(wxCHK_UNCHECKED);
|
|
|
|
} else {
|
|
|
|
evtCheckBox.SetInt(wxCHK_CHECKED);
|
|
|
|
}
|
|
|
|
pCheckBox->Command(evtCheckBox);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
}
|
2006-11-20 21:59:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS (CLinkButton, wxBitmapButton)
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(CLinkButton, wxBitmapButton)
|
|
|
|
EVT_MOUSE_EVENTS(CLinkButton::OnMouse)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
CLinkButton::CLinkButton() {}
|
|
|
|
|
|
|
|
CLinkButton::CLinkButton(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
|
|
|
|
Create(parent, id, bitmap, pos, size, style, validator, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CLinkButton::Create(wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) {
|
|
|
|
bool bRetVal = wxBitmapButton::Create(parent, id, bitmap, pos, size, style, validator, name);
|
|
|
|
|
|
|
|
m_HandCursor = wxCursor(wxCURSOR_HAND);
|
|
|
|
|
|
|
|
return bRetVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CLinkButton::OnMouse(wxMouseEvent& event) {
|
|
|
|
if (event.Entering()) {
|
|
|
|
SetCursor(m_HandCursor);
|
|
|
|
} else if (event.Leaving()) {
|
|
|
|
SetCursor(*wxSTANDARD_CURSOR);
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
}
|