+ #include "wx/osx/private.h"
+#endif
+
+#ifdef __WXMSW__
+ #include "wx/msw/wrapwin.h"
+ #include "wx/msw/private.h"
+ #include "wx/msw/dc.h"
+#endif
+
+IMPLEMENT_DYNAMIC_CLASS(wxAuiManagerEvent, wxEvent)
+IMPLEMENT_CLASS(wxAuiManager, wxEvtHandler)
+
+
+
+const int auiToolBarLayer = 10;
+
+#ifndef __WXGTK20__
+
+
+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;
+ m_lastWidth=0;
+ m_lastHeight=0;
+#ifdef __WXGTK__
+ m_CanSetShape = false; // have to wait for window create event on GTK
+#else
+ m_CanSetShape = true;
+#endif
+ m_Region = wxRegion(0, 0, 0, 0);
+ SetTransparent(0);
+ }
+
+ virtual bool SetTransparent(wxByte alpha)
+ {
+ if (m_CanSetShape)
+ {
+ int w=100; // some defaults
+ int h=100;
+ GetClientSize(&w, &h);
+
+ m_MaxWidth = w;
+ m_MaxHeight = h;
+ 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);
+
+ if (m_Region.IsEmpty())
+ return;
+
+#ifdef __WXMAC__
+ dc.SetBrush(wxColour(128, 192, 255));
+#else
+ dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
+#endif
+ 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
+
+ void OnSize(wxSizeEvent& event)
+ {
+ // We sometimes get surplus size events
+ if ((event.GetSize().GetWidth() == m_lastWidth) &&
+ (event.GetSize().GetHeight() == m_lastHeight))
+ {
+ event.Skip();
+ return;
+ }
+ m_lastWidth = event.GetSize().GetWidth();
+ m_lastHeight = event.GetSize().GetHeight();
+
+ SetTransparent(m_Amount);
+ m_Region.Intersect(0, 0, event.GetSize().GetWidth(),
+ event.GetSize().GetHeight());
+ SetShape(m_Region);
+ Refresh();
+ event.Skip();
+ }
+
+private:
+ wxByte m_Amount;
+ int m_MaxWidth;
+ int m_MaxHeight;
+ bool m_CanSetShape;
+ int m_lastWidth,m_lastHeight;
+
+ wxRegion m_Region;
+
+ DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame)
+ DECLARE_EVENT_TABLE()
+};
+
+
+IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame)
+
+BEGIN_EVENT_TABLE(wxPseudoTransparentFrame, wxFrame)
+ EVT_PAINT(wxPseudoTransparentFrame::OnPaint)
+ EVT_SIZE(wxPseudoTransparentFrame::OnSize)
+#ifdef __WXGTK__
+ EVT_WINDOW_CREATE(wxPseudoTransparentFrame::OnWindowCreate)
+#endif
+END_EVENT_TABLE()
+
+
+#else
+ // __WXGTK20__
+
+#include <gtk/gtk.h>
+
+static void
+gtk_pseudo_window_realized_callback( GtkWidget *m_widget, void *WXUNUSED(win) )
+{
+ wxSize disp = wxGetDisplaySize();
+ int amount = 128;
+ wxRegion region;
+ for (int y=0; y<disp.y; 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)<amount)
+ region.Union(0, y, disp.x, 1);
+ }
+ gdk_window_shape_combine_region(m_widget->window, region.GetRegion(), 0, 0);
+}
+
+
+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"))
+ {
+ if (!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
+ return;
+
+ m_title = title;
+
+ m_widget = gtk_window_new( GTK_WINDOW_POPUP );
+ g_object_ref(m_widget);
+
+ if (parent) parent->AddChild(this);
+
+ g_signal_connect( m_widget, "realize",
+ G_CALLBACK (gtk_pseudo_window_realized_callback), this );
+
+ GdkColor col;
+ col.red = 128 * 256;
+ col.green = 192 * 256;
+ col.blue = 255 * 256;
+ gtk_widget_modify_bg( m_widget, GTK_STATE_NORMAL, &col );
+ }
+
+ bool SetTransparent(wxByte WXUNUSED(alpha))
+ {
+ return true;
+ }
+
+protected:
+ virtual void DoSetSizeHints( int minW, int minH,
+ int maxW, int maxH,
+ int incW, int incH)
+ {
+ // the real wxFrame method doesn't work for us because we're not really
+ // a top level window so skip it
+ wxWindow::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
+ }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame)
+