refactor wxDocChildFrame and wxDocMDIChildFrame to use wxDocChildFrameAny intead of duplicating its code (with subtle differences, as usual); also added wxDocChildFrameAnyBase and store a pointer to it in wxView to reset the frame view if the view is being deleted because its creation fails to avoid crashes in this case

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-02-27 12:24:03 +00:00
parent 021f9dee07
commit a9e2e6e52b
4 changed files with 192 additions and 206 deletions

View File

@@ -54,54 +54,39 @@ private:
wxDECLARE_NO_COPY_CLASS(wxDocMDIParentFrame);
};
/*
* Use this instead of wxMDIChildFrame
*/
// ----------------------------------------------------------------------------
// An MDI document child frame: we need to define it as a class just for wxRTTI,
// otherwise we could simply typedef it
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDocMDIChildFrame: public wxMDIChildFrame
typedef
wxDocChildFrameAny<wxMDIChildFrame, wxMDIParentFrame> wxDocMDIChildFrameBase;
class WXDLLIMPEXP_CORE wxDocMDIChildFrame : public wxDocMDIChildFrameBase
{
public:
wxDocMDIChildFrame();
wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id,
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr);
virtual ~wxDocMDIChildFrame();
bool Create(wxDocument *doc,
wxView *view,
wxMDIParentFrame *frame,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long type = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
void OnActivate(wxActivateEvent& event);
void OnCloseWindow(wxCloseEvent& event);
inline wxDocument *GetDocument() const { return m_childDocument; }
inline wxView *GetView(void) const { return m_childView; }
inline void SetDocument(wxDocument *doc) { m_childDocument = doc; }
inline void SetView(wxView *view) { m_childView = view; }
bool Destroy() { m_childView = NULL; return wxMDIChildFrame::Destroy(); }
protected:
void Init();
virtual bool TryBefore(wxEvent& event);
wxDocument* m_childDocument;
wxView* m_childView;
wxDocMDIChildFrame(wxDocument *doc,
wxView *view,
wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
: wxDocMDIChildFrameBase(doc, view,
parent, id, title, pos, size, style, name)
{
}
private:
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxDocMDIChildFrame)
wxDECLARE_NO_COPY_CLASS(wxDocMDIChildFrame);
};
#endif
// wxUSE_MDI_ARCHITECTURE
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxDocMDIChildFrameBase )
#endif
// _WX_DOCMDI_H_
#endif // wxUSE_MDI_ARCHITECTURE
#endif // _WX_DOCMDI_H_