allow 2 step creation of wxDocChildFrameAnyBase and derived classes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60713 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -520,16 +520,33 @@ inline size_t wxDocManager::GetNoHistoryFiles() const
|
|||||||
class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase
|
class WXDLLIMPEXP_CORE wxDocChildFrameAnyBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// default ctor, use Create() after it
|
||||||
|
wxDocChildFrameAnyBase() { m_win = NULL; }
|
||||||
|
|
||||||
|
// full ctor equivalent to using the default one and Create(0
|
||||||
wxDocChildFrameAnyBase(wxDocument *doc, wxView *view, wxWindow *win)
|
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_childDocument = doc;
|
||||||
m_childView = view;
|
m_childView = view;
|
||||||
|
m_win = win;
|
||||||
|
|
||||||
if ( view )
|
if ( view )
|
||||||
view->SetDocChildFrame(this);
|
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()
|
~wxDocChildFrameAnyBase()
|
||||||
{
|
{
|
||||||
// prevent the view from deleting us if we're being deleted directly
|
// prevent the view from deleting us if we're being deleted directly
|
||||||
@@ -564,7 +581,7 @@ protected:
|
|||||||
|
|
||||||
// the associated window: having it here is not terribly elegant but it
|
// the associated window: having it here is not terribly elegant but it
|
||||||
// allows us to avoid having any virtual functions in this class
|
// allows us to avoid having any virtual functions in this class
|
||||||
wxWindow * const m_win;
|
wxWindow* m_win;
|
||||||
|
|
||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase);
|
wxDECLARE_NO_COPY_CLASS(wxDocChildFrameAnyBase);
|
||||||
@@ -587,6 +604,9 @@ class WXDLLIMPEXP_CORE wxDocChildFrameAny : public ChildFrame,
|
|||||||
public:
|
public:
|
||||||
typedef ChildFrame BaseClass;
|
typedef ChildFrame BaseClass;
|
||||||
|
|
||||||
|
// default ctor, use Create after it
|
||||||
|
wxDocChildFrameAny() { }
|
||||||
|
|
||||||
// ctor for a frame showing the given view of the specified document
|
// ctor for a frame showing the given view of the specified document
|
||||||
wxDocChildFrameAny(wxDocument *doc,
|
wxDocChildFrameAny(wxDocument *doc,
|
||||||
wxView *view,
|
wxView *view,
|
||||||
@@ -597,13 +617,32 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxDEFAULT_FRAME_STYLE,
|
long style = wxDEFAULT_FRAME_STYLE,
|
||||||
const wxString& name = wxFrameNameStr)
|
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 ( !BaseClass::Create(parent, id, title, pos, size, style, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !wxDocChildFrameAnyBase::Create(doc, view, this) )
|
||||||
|
return false;
|
||||||
|
|
||||||
this->Connect(wxEVT_ACTIVATE,
|
this->Connect(wxEVT_ACTIVATE,
|
||||||
wxActivateEventHandler(wxDocChildFrameAny::OnActivate));
|
wxActivateEventHandler(wxDocChildFrameAny::OnActivate));
|
||||||
this->Connect(wxEVT_CLOSE_WINDOW,
|
this->Connect(wxEVT_CLOSE_WINDOW,
|
||||||
wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow));
|
wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Destroy()
|
virtual bool Destroy()
|
||||||
@@ -659,6 +698,10 @@ typedef wxDocChildFrameAny<wxFrame, wxFrame> wxDocChildFrameBase;
|
|||||||
class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase
|
class WXDLLIMPEXP_CORE wxDocChildFrame : public wxDocChildFrameBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
wxDocChildFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
wxDocChildFrame(wxDocument *doc,
|
wxDocChildFrame(wxDocument *doc,
|
||||||
wxView *view,
|
wxView *view,
|
||||||
wxFrame *parent,
|
wxFrame *parent,
|
||||||
@@ -673,6 +716,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:
|
private:
|
||||||
DECLARE_CLASS(wxDocChildFrame)
|
DECLARE_CLASS(wxDocChildFrame)
|
||||||
wxDECLARE_NO_COPY_CLASS(wxDocChildFrame);
|
wxDECLARE_NO_COPY_CLASS(wxDocChildFrame);
|
||||||
|
Reference in New Issue
Block a user