+IMPLEMENT_DYNAMIC_CLASS(wxFrameManagerEvent, wxEvent)
+
+class wxPseudoTransparentFrame : public wxFrame
+{
+public:
+ wxPseudoTransparentFrame(wxWindow* parent = NULL,
+ wxWindowID id = wxID_ANY,
+ const wxString& title = wxEmptyString,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDEFAULT_FRAME_STYLE,
+ const wxString &name = wxT("frame"))
+ : wxFrame(parent, id, title, pos, size, style | wxFRAME_SHAPED, name)
+ {
+ SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+ m_Amount=0;
+ m_MaxWidth=0;
+ m_MaxHeight=0;
+#ifdef __WXGTK__
+ m_CanSetShape = false; // have to wait for window create event on GTK
+#else
+ m_CanSetShape = true;
+#endif
+ SetTransparent(0);
+ }
+
+ virtual bool SetTransparent(wxByte alpha)
+ {
+ if (m_CanSetShape)
+ {
+ int w=100; // some defaults
+ int h=100;
+ GetClientSize(&w, &h);
+ if ((alpha != m_Amount) || (m_MaxWidth<w) | (m_MaxHeight<h))
+ {
+ // Make the region at least double the height and width so we don't have
+ // to rebuild if the size changes.
+ m_MaxWidth=w*2;
+ m_MaxHeight=h*2;
+ m_Amount = alpha;
+ m_Region.Clear();
+// m_Region.Union(0, 0, 1, m_MaxWidth);
+ if (m_Amount)
+ {
+ for (int y=0; y<m_MaxHeight; y++)
+ {
+ // Reverse the order of the bottom 4 bits
+ int j=((y&8)?1:0)|((y&4)?2:0)|((y&2)?4:0)|((y&1)?8:0);
+ if ((j*16+8)<m_Amount)
+ m_Region.Union(0, y, m_MaxWidth, 1);
+ }
+ }
+ SetShape(m_Region);
+ Refresh();
+ }
+ }
+ return true;
+ }
+
+ void OnPaint(wxPaintEvent& WXUNUSED(event))
+ {
+ wxPaintDC dc(this);
+
+ dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
+ dc.SetPen(*wxTRANSPARENT_PEN);
+
+ wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
+
+ while (upd)
+ {
+ wxRect rect(upd.GetRect());
+ dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
+
+ upd++;
+ }
+ }
+
+#ifdef __WXGTK__
+ void OnWindowCreate(wxWindowCreateEvent& WXUNUSED(event)) {m_CanSetShape=true; SetTransparent(0);}
+#endif
+
+private:
+ int m_Amount;
+ int m_MaxWidth;
+ int m_MaxHeight;
+ bool m_CanSetShape;
+
+ wxRegion m_Region;
+
+ DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame);
+ DECLARE_EVENT_TABLE();
+};
+
+
+IMPLEMENT_DYNAMIC_CLASS( wxPseudoTransparentFrame, wxFrame )
+
+BEGIN_EVENT_TABLE(wxPseudoTransparentFrame, wxFrame)
+ EVT_PAINT(wxPseudoTransparentFrame::OnPaint)
+#ifdef __WXGTK__
+ EVT_WINDOW_CREATE(wxPseudoTransparentFrame::OnWindowCreate)
+#endif
+END_EVENT_TABLE()
+