docview.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: samples/docview/docview.h
  3. // Purpose: Document/view demo
  4. // Author: Julian Smart
  5. // Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup
  6. // Created: 04/01/98
  7. // Copyright: (c) 1998 Julian Smart
  8. // (c) 2008 Vadim Zeitlin
  9. // Licence: wxWindows licence
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
  12. #define _WX_SAMPLES_DOCVIEW_DOCVIEW_H_
  13. #include "wx/docview.h"
  14. class MyCanvas;
  15. // Define a new application
  16. class MyApp : public wxApp
  17. {
  18. public:
  19. // this sample can be launched in several different ways:
  20. enum Mode
  21. {
  22. #if wxUSE_MDI_ARCHITECTURE
  23. Mode_MDI, // MDI mode: multiple documents, single top level window
  24. #endif // wxUSE_MDI_ARCHITECTURE
  25. Mode_SDI, // SDI mode: multiple documents, multiple top level windows
  26. Mode_Single // single document mode (and hence single top level window)
  27. };
  28. MyApp();
  29. // override some wxApp virtual methods
  30. virtual bool OnInit();
  31. virtual int OnExit();
  32. virtual void OnInitCmdLine(wxCmdLineParser& parser);
  33. virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
  34. // our specific methods
  35. Mode GetMode() const { return m_mode; }
  36. wxFrame *CreateChildFrame(wxView *view, bool isCanvas);
  37. // these accessors should only be called in single document mode, otherwise
  38. // the pointers are NULL and an assert is triggered
  39. MyCanvas *GetMainWindowCanvas() const
  40. { wxASSERT(m_canvas); return m_canvas; }
  41. wxMenu *GetMainWindowEditMenu() const
  42. { wxASSERT(m_menuEdit); return m_menuEdit; }
  43. private:
  44. // append the standard document-oriented menu commands to this menu
  45. void AppendDocumentFileCommands(wxMenu *menu, bool supportsPrinting);
  46. // create the edit menu for drawing documents
  47. wxMenu *CreateDrawingEditMenu();
  48. // create and associate with the given frame the menu bar containing the
  49. // given file and edit (possibly NULL) menus as well as the standard help
  50. // one
  51. void CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit);
  52. // show the about box: as we can have different frames it's more
  53. // convenient, even if somewhat less usual, to handle this in the
  54. // application object itself
  55. void OnAbout(wxCommandEvent& event);
  56. // the currently used mode
  57. Mode m_mode;
  58. // only used if m_mode == Mode_Single
  59. MyCanvas *m_canvas;
  60. wxMenu *m_menuEdit;
  61. wxDECLARE_EVENT_TABLE();
  62. wxDECLARE_NO_COPY_CLASS(MyApp);
  63. };
  64. DECLARE_APP(MyApp)
  65. #endif // _WX_SAMPLES_DOCVIEW_DOCVIEW_H_