X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/952a3bd46dc50f95c462606fac8214573022f612..72da4057731919c6d386aa5a4cf8f3d0258bbe46:/src/aui/framemanager.cpp?ds=sidebyside diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 6e38dd291d..9ceabbf8dc 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -67,6 +67,12 @@ DEFINE_EVENT_TYPE(wxEVT_AUI_FIND_MANAGER) #include "wx/mac/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) @@ -214,7 +220,7 @@ END_EVENT_TABLE() #else // __WXGTK20__ -#include "wx/gtk/private.h" +#include static void gtk_pseudo_window_realized_callback( GtkWidget *m_widget, void *WXUNUSED(win) ) @@ -248,12 +254,12 @@ public: return; m_title = title; - + m_widget = gtk_window_new( GTK_WINDOW_POPUP ); g_signal_connect( m_widget, "realize", G_CALLBACK (gtk_pseudo_window_realized_callback), this ); - + GdkColor col; col.red = 128 * 256; col.green = 192 * 256; @@ -265,7 +271,7 @@ public: { return true; } - + private: DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame) }; @@ -291,10 +297,15 @@ static void DrawResizeHint(wxDC& dc, const wxRect& rect) wxBitmap stipple = wxPaneCreateStippleBitmap(); wxBrush brush(stipple); dc.SetBrush(brush); +#ifdef __WXMSW__ + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + PatBlt(GetHdcOf(*impl), rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight(), PATINVERT); +#else dc.SetPen(*wxTRANSPARENT_PEN); dc.SetLogicalFunction(wxXOR); dc.DrawRectangle(rect); +#endif } @@ -511,7 +522,7 @@ static void RenumberDockRows(wxAuiDockInfoPtrArray& docks) { wxAuiDockInfo& dock = *docks.Item(i); dock.dock_row = i; - + int j, pane_count; for (j = 0, pane_count = dock.panes.GetCount(); j < pane_count; ++j) dock.panes.Item(j)->dock_row = i; @@ -586,12 +597,29 @@ wxAuiManager::wxAuiManager(wxWindow* managed_wnd, unsigned int flags) wxAuiManager::~wxAuiManager() { + // NOTE: It's possible that the windows have already been destroyed by the + // time this dtor is called, so this loop can result in memory access via + // invalid pointers, resulting in a crash. So it will be disabled while + // waiting for a better solution. +#if 0 for ( size_t i = 0; i < m_panes.size(); i++ ) { wxAuiPaneInfo& pinfo = m_panes[i]; if (pinfo.window && !pinfo.window->GetParent()) delete pinfo.window; } +#endif + + // We need to remove any reference to this wxAuiManager in any of the + // wxAuiFloatingFrames associated with this manager in case they haven't + // been deleted just yet. + // We need an array copy since Unregister removes the items. + wxAuiFloatingFramePtrArray array_copy = m_floating_frames; + int i, count = array_copy.GetCount(); + for (i = 0; i < count; ++i) + { + UnregisterFloatingFrame(array_copy.Item(i)); + } delete m_art; } @@ -600,7 +628,9 @@ wxAuiManager::~wxAuiManager() wxAuiFloatingFrame* wxAuiManager::CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& pane_info) { - return new wxAuiFloatingFrame(parent, this, pane_info); + wxAuiFloatingFrame* frame = new wxAuiFloatingFrame(parent, this, pane_info); + RegisterFloatingFrame(frame); + return frame; } bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p)) @@ -610,6 +640,37 @@ bool wxAuiManager::CanDockPanel(const wxAuiPaneInfo & WXUNUSED(p)) return !(wxGetKeyState(WXK_CONTROL) || wxGetKeyState(WXK_ALT)); } +// registers a floating frame with this manager (see header) +void wxAuiManager::RegisterFloatingFrame(wxAuiFloatingFrame* frame) +{ + frame->SetOwnerManager(this); + int i, count = m_floating_frames.GetCount(); + for (i = 0; i < count; ++i) + { + wxAuiFloatingFrame* f = m_floating_frames.Item(i); + if (f == frame) + // this frame is already registered + return; + } + m_floating_frames.Add(frame); +} + +// unregisters a floating frame from this manager (see header) +void wxAuiManager::UnregisterFloatingFrame(wxAuiFloatingFrame* frame) +{ + frame->SetOwnerManager(NULL); + int i, count = m_floating_frames.GetCount(); + for (i = 0; i < count; ++i) + { + wxAuiFloatingFrame* f = m_floating_frames.Item(i); + if (f == frame) + { + m_floating_frames.Remove(f); + return; + } + } +} + // GetPane() looks up a wxAuiPaneInfo structure based // on the supplied window pointer. Upon failure, GetPane() // returns an empty wxAuiPaneInfo, a condition which can be checked @@ -756,6 +817,7 @@ void wxAuiManager::UpdateHintWindowConfig() { wxFrame* f = static_cast(w); can_do_transparent = f->CanSetTransparent(); + break; } @@ -952,7 +1014,7 @@ bool wxAuiManager::AddPane(wxWindow* window, const wxAuiPaneInfo& pane_info) if (pinfo.name.empty() || already_exists) { pinfo.name.Printf(wxT("%08lx%08x%08x%08lx"), - ((unsigned long)pinfo.window) & 0xffffffff, + wxPtrToUInt(pinfo.window) & 0xffffffff, (unsigned int)time(NULL), #ifdef __WXWINCE__ (unsigned int)GetTickCount(), @@ -2301,7 +2363,8 @@ wxSizer* wxAuiManager::LayoutAll(wxAuiPaneInfoArray& panes, LayoutAddDock(middle, *arr.Item(row), uiparts, spacer_only); } - cont->Add(middle, 1, wxEXPAND); + if (middle->GetChildren().GetCount() > 0) + cont->Add(middle, 1, wxEXPAND); @@ -4429,7 +4492,7 @@ void wxAuiManager::OnPaneButton(wxAuiManagerEvent& evt) { ClosePane(pane); } - + Update(); } }