X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fc0ae1e3193cab2e29f80d06515c8e83c072dc68..fc85e0db36b368de041dfaffbd308d2f5c861a60:/samples/erase/erase.cpp diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index 554c989f2a..138b3fa2bc 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -139,6 +139,34 @@ private: DECLARE_EVENT_TABLE() }; +class ControlWithTransparency : public wxWindow +{ +public: + ControlWithTransparency(wxWindow *parent, + const wxPoint& pos, + const wxSize& size) + : wxWindow(parent, wxID_ANY, pos, size, wxBORDER_NONE) + { + Connect(wxEVT_PAINT, + wxPaintEventHandler(ControlWithTransparency::OnPaint)); + } + + virtual bool HasTransparentBackground() { return true; } + +private: + void OnPaint( wxPaintEvent& WXUNUSED(event) ) + { + wxPaintDC dc(this); + + dc.SetPen(*wxRED_PEN); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(GetClientSize()); + + dc.SetTextForeground(*wxBLUE); + dc.SetBackgroundMode(wxTRANSPARENT); + dc.DrawText("This is custom control with transparency", 0, 2); + } +}; // ---------------------------------------------------------------------------- // constants @@ -299,6 +327,8 @@ MyCanvas::MyCanvas(wxFrame *parent) "right one drawn directly", wxPoint(150, 20)); + new ControlWithTransparency(this, wxPoint(65, 125), wxSize(300, 22)); + SetFocusIgnoringChildren(); SetBackgroundColour(*wxCYAN); }