1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include "CTransparentStaticText.h"
#include "wx/dcclient.h"
IMPLEMENT_DYNAMIC_CLASS (CTransparentStaticText, wxStaticText)
BEGIN_EVENT_TABLE(CTransparentStaticText, wxStaticText)
EVT_PAINT(CTransparentStaticText::OnPaint)
END_EVENT_TABLE()
CTransparentStaticText::CTransparentStaticText() {}
CTransparentStaticText::CTransparentStaticText(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 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());
SetBackgroundStyle(wxBG_STYLE_COLOUR);
SetForegroundColour(parent->GetForegroundColour());
return bRetVal;
}
void CTransparentStaticText::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
dc.SetFont(GetFont());
dc.DrawText(GetLabel(), 0, 0);
}
void CTransparentStaticText::OnRepaint()
{
GetParent()->RefreshRect(GetRect(), false);
GetParent()->Update();
wxPaintDC dc(this);
dc.SetFont(GetFont());
dc.DrawText(GetLabel(), 0, 0);
} |