X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9e2e6e52b9c2371413597a92ccc4f8352963c32..cbeda384e51acb82e13994cb67ac1714669cae10:/include/wx/docview.h diff --git a/include/wx/docview.h b/include/wx/docview.h index 2a08d2c0ff..55fa2c7920 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -248,10 +248,7 @@ public: // set the associated frame, it is used to reset its view when we're // destroyed - void SetDocChildFrame(wxDocChildFrameAnyBase *docChildFrame) - { - m_docChildFrame = docChildFrame; - } + void SetDocChildFrame(wxDocChildFrameAnyBase *docChildFrame); protected: // hook the document into event handlers chain here @@ -520,10 +517,11 @@ inline size_t wxDocManager::GetNoHistoryFiles() const // wxDocChildFrameAny does // ---------------------------------------------------------------------------- -class wxDocChildFrameAnyBase +class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase { public: - wxDocChildFrameAnyBase(wxDocument *doc, wxView *view) + wxDocChildFrameAnyBase(wxDocument *doc, wxView *view, wxWindow *win) + : m_win(win) { m_childDocument = doc; m_childView = view; @@ -532,11 +530,21 @@ public: view->SetDocChildFrame(this); } + ~wxDocChildFrameAnyBase() + { + // prevent the view from deleting us if we're being deleted directly + // (and not via Close() + Destroy()) + if ( m_childView ) + m_childView->SetDocChildFrame(NULL); + } + wxDocument *GetDocument() const { return m_childDocument; } wxView *GetView() const { return m_childView; } void SetDocument(wxDocument *doc) { m_childDocument = doc; } void SetView(wxView *view) { m_childView = view; } + wxWindow *GetWindow() const { return m_win; } + protected: // we're not a wxEvtHandler but we provide this wxEvtHandler-like function // which is called from TryBefore() of the derived classes to give our view @@ -554,6 +562,11 @@ protected: wxDocument* m_childDocument; wxView* m_childView; + // the associated window: having it here is not terribly elegant but it + // allows us to avoid having any virtual functions in this class + wxWindow * const m_win; + + wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase); }; @@ -585,11 +598,8 @@ public: long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr) : BaseClass(parent, id, title, pos, size, style, name), - wxDocChildFrameAnyBase(doc, view) + wxDocChildFrameAnyBase(doc, view, this) { - if ( view ) - view->SetFrame(this); - this->Connect(wxEVT_ACTIVATE, wxActivateEventHandler(wxDocChildFrameAny::OnActivate)); this->Connect(wxEVT_CLOSE_WINDOW, @@ -636,6 +646,14 @@ private: // otherwise we could simply typedef it // ---------------------------------------------------------------------------- +#ifdef __VISUALC6__ + // "non dll-interface class 'wxDocChildFrameAny<>' used as base interface + // for dll-interface class 'wxDocChildFrame'" -- this is bogus as the + // template will be DLL-exported but only once it is used as base class + // here! + #pragma warning (disable:4275) +#endif + typedef wxDocChildFrameAny wxDocChildFrameBase; class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase @@ -660,7 +678,9 @@ private: wxDECLARE_NO_COPY_CLASS(wxDocChildFrame); }; -WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxDocChildFrameBase ) +#ifdef __VISUALC6__ + #pragma warning (default:4275) +#endif // ---------------------------------------------------------------------------- // A default parent frame