X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ada1ff0dbcd973c0a4630318599eb469dd6e3fb6..ac1013c060bf83e0ef83f3ef4a5f6296e88157d2:/include/wx/docview.h?ds=sidebyside diff --git a/include/wx/docview.h b/include/wx/docview.h index 610dd0c6f6..0ac6cdcb3e 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -520,14 +520,44 @@ inline size_t wxDocManager::GetNoHistoryFiles() const class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase { public: + // default ctor, use Create() after it + wxDocChildFrameAnyBase() + { + m_childDocument = NULL; + m_childView = NULL; + m_win = NULL; + } + + // full ctor equivalent to using the default one and Create(0 wxDocChildFrameAnyBase(wxDocument *doc, wxView *view, wxWindow *win) - : m_win(win) + { + Create(doc, view, win); + } + + // method which must be called for an object created using the default ctor + // + // note that it returns bool just for consistency with Create() methods in + // other classes, we never return false from here + bool Create(wxDocument *doc, wxView *view, wxWindow *win) { m_childDocument = doc; m_childView = view; + m_win = win; if ( view ) view->SetDocChildFrame(this); + + return true; + } + + // dtor doesn't need to be virtual, an object should never be destroyed via + // a pointer to this class + ~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; } @@ -556,7 +586,7 @@ protected: // 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; + wxWindow* m_win; wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase); @@ -579,6 +609,9 @@ class WXDLLIMPEXP_CORE wxDocChildFrameAny : public ChildFrame, public: typedef ChildFrame BaseClass; + // default ctor, use Create after it + wxDocChildFrameAny() { } + // ctor for a frame showing the given view of the specified document wxDocChildFrameAny(wxDocument *doc, wxView *view, @@ -589,13 +622,32 @@ public: const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr) - : BaseClass(parent, id, title, pos, size, style, name), - wxDocChildFrameAnyBase(doc, view, this) { + Create(doc, view, parent, id, title, pos, size, style, name); + } + + bool Create(wxDocument *doc, + wxView *view, + ParentFrame *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + if ( !wxDocChildFrameAnyBase::Create(doc, view, this) ) + return false; + + if ( !BaseClass::Create(parent, id, title, pos, size, style, name) ) + return false; + this->Connect(wxEVT_ACTIVATE, wxActivateEventHandler(wxDocChildFrameAny::OnActivate)); this->Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow)); + + return true; } virtual bool Destroy() @@ -651,6 +703,10 @@ typedef wxDocChildFrameAny wxDocChildFrameBase; class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase { public: + wxDocChildFrame() + { + } + wxDocChildFrame(wxDocument *doc, wxView *view, wxFrame *parent, @@ -665,6 +721,23 @@ public: { } + bool Create(wxDocument *doc, + wxView *view, + wxFrame *parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) + { + return wxDocChildFrameBase::Create + ( + doc, view, + parent, id, title, pos, size, style, name + ); + } + private: DECLARE_CLASS(wxDocChildFrame) wxDECLARE_NO_COPY_CLASS(wxDocChildFrame);