+ // This is similar to wxDocChildFrameAnyBase method with the same name:
+ // while we're not an event handler ourselves and so can't override
+ // TryBefore(), we provide a helper that the derived template class can use
+ // from its TryBefore() implementation.
+ bool TryProcessEvent(wxEvent& event);
+
+ wxWindow* const m_frame;
+ wxDocManager *m_docManager;
+
+ wxDECLARE_NO_COPY_CLASS(wxDocParentFrameAnyBase);
+};
+
+// This is similar to wxDocChildFrameAny and is used to provide common
+// implementation for both wxDocParentFrame and wxDocMDIParentFrame
+template <class BaseFrame>
+class WXDLLIMPEXP_CORE wxDocParentFrameAny : public BaseFrame,
+ public wxDocParentFrameAnyBase
+{
+public:
+ wxDocParentFrameAny() : wxDocParentFrameAnyBase(this) { }
+ wxDocParentFrameAny(wxDocManager *manager,
+ wxFrame *frame,
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDEFAULT_FRAME_STYLE,
+ const wxString& name = wxFrameNameStr)
+ : wxDocParentFrameAnyBase(this)
+ {
+ Create(manager, frame, id, title, pos, size, style, name);
+ }
+
+ bool Create(wxDocManager *manager,
+ wxFrame *frame,
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxDEFAULT_FRAME_STYLE,
+ const wxString& name = wxFrameNameStr)
+ {
+ m_docManager = manager;
+
+ if ( !BaseFrame::Create(frame, id, title, pos, size, style, name) )
+ return false;
+
+ this->Connect(wxID_EXIT, wxEVT_MENU,
+ wxCommandEventHandler(wxDocParentFrameAny::OnExit));
+ this->Connect(wxEVT_CLOSE_WINDOW,
+ wxCloseEventHandler(wxDocParentFrameAny::OnCloseWindow));
+
+ return true;
+ }
+
+protected:
+ // hook the document manager into event handling chain here
+ virtual bool TryBefore(wxEvent& event)
+ {
+ // It is important to send the event to the base class first as
+ // wxMDIParentFrame overrides its TryBefore() to send the menu events
+ // to the currently active child frame and the child must get them
+ // before our own TryProcessEvent() is executed, not afterwards.
+ return BaseFrame::TryBefore(event) || TryProcessEvent(event);
+ }