+ // this sample can be launched in several different ways:
+ enum Mode
+ {
+#if wxUSE_MDI_ARCHITECTURE
+ Mode_MDI, // MDI mode: multiple documents, single top level window
+#endif // wxUSE_MDI_ARCHITECTURE
+ Mode_SDI, // SDI mode: multiple documents, multiple top level windows
+ Mode_Single // single document mode (and hence single top level window)
+ };
+
+ MyApp();
+
+ // override some wxApp virtual methods
+ virtual bool OnInit();
+ virtual int OnExit();
+
+ virtual void OnInitCmdLine(wxCmdLineParser& parser);
+ virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
+
+ // our specific methods
+ Mode GetMode() const { return m_mode; }
+ wxFrame *CreateChildFrame(wxView *view, bool isCanvas);
+
+ // these accessors should only be called in single document mode, otherwise
+ // the pointers are NULL and an assert is triggered
+ MyCanvas *GetMainWindowCanvas() const
+ { wxASSERT(m_canvas); return m_canvas; }
+ wxMenu *GetMainWindowEditMenu() const
+ { wxASSERT(m_menuEdit); return m_menuEdit; }
+
+private:
+ // append the standard document-oriented menu commands to this menu
+ void AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting);
+
+ // create the edit menu for drawing documents
+ wxMenu *CreateDrawingEditMenu();
+
+ // create and associate with the given frame the menu bar containing the
+ // given file and edit (possibly NULL) menus as well as the standard help
+ // one
+ void CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit);
+
+
+ // show the about box: as we can have different frames it's more
+ // convenient, even if somewhat less usual, to handle this in the
+ // application object itself
+ void OnAbout(wxCommandEvent& event);