mdi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: mdi.cpp
  3. // Purpose: MDI sample
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 04/01/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #include "wx/toolbar.h"
  11. // Define a new application
  12. class MyApp : public wxApp
  13. {
  14. public:
  15. virtual bool OnInit();
  16. };
  17. class MyCanvas : public wxScrolledWindow
  18. {
  19. public:
  20. MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
  21. virtual void OnDraw(wxDC& dc);
  22. bool IsDirty() const { return m_dirty; }
  23. void SetText(const wxString& text) { m_text = text; Refresh(); }
  24. private:
  25. void OnEvent(wxMouseEvent& event);
  26. wxString m_text;
  27. bool m_dirty;
  28. wxDECLARE_EVENT_TABLE();
  29. };
  30. // Define a new frame
  31. class MyFrame : public wxMDIParentFrame
  32. {
  33. public:
  34. MyFrame();
  35. virtual ~MyFrame();
  36. static wxMenuBar *CreateMainMenubar();
  37. private:
  38. void InitToolBar(wxToolBar* toolBar);
  39. void OnSize(wxSizeEvent& event);
  40. void OnAbout(wxCommandEvent& event);
  41. void OnNewWindow(wxCommandEvent& event);
  42. void OnFullScreen(wxCommandEvent& event);
  43. void OnQuit(wxCommandEvent& event);
  44. void OnCloseAll(wxCommandEvent& event);
  45. void OnClose(wxCloseEvent& event);
  46. wxTextCtrl *m_textWindow;
  47. wxDECLARE_EVENT_TABLE();
  48. };
  49. class MyChild : public wxMDIChildFrame
  50. {
  51. public:
  52. MyChild(wxMDIParentFrame *parent);
  53. virtual ~MyChild();
  54. static unsigned GetChildrenCount() { return ms_numChildren; }
  55. private:
  56. void OnActivate(wxActivateEvent& event);
  57. void OnRefresh(wxCommandEvent& event);
  58. void OnUpdateRefresh(wxUpdateUIEvent& event);
  59. void OnChangeTitle(wxCommandEvent& event);
  60. void OnChangePosition(wxCommandEvent& event);
  61. void OnChangeSize(wxCommandEvent& event);
  62. void OnClose(wxCommandEvent& event);
  63. void OnSize(wxSizeEvent& event);
  64. void OnMove(wxMoveEvent& event);
  65. void OnCloseWindow(wxCloseEvent& event);
  66. #if wxUSE_CLIPBOARD
  67. void OnPaste(wxCommandEvent& event);
  68. void OnUpdatePaste(wxUpdateUIEvent& event);
  69. #endif // wxUSE_CLIPBOARD
  70. static unsigned ms_numChildren;
  71. MyCanvas *m_canvas;
  72. // simple test event handler class
  73. class EventHandler : public wxEvtHandler
  74. {
  75. public:
  76. EventHandler(unsigned numChild) : m_numChild(numChild) { }
  77. private:
  78. void OnRefresh(wxCommandEvent& event)
  79. {
  80. wxLogMessage("Child #%u refreshed.", m_numChild);
  81. event.Skip();
  82. }
  83. const unsigned m_numChild;
  84. wxDECLARE_EVENT_TABLE();
  85. wxDECLARE_NO_COPY_CLASS(EventHandler);
  86. };
  87. wxDECLARE_EVENT_TABLE();
  88. };
  89. // menu items ids
  90. enum
  91. {
  92. MDI_FULLSCREEN = 100,
  93. MDI_REFRESH,
  94. MDI_CHANGE_TITLE,
  95. MDI_CHANGE_POSITION,
  96. MDI_CHANGE_SIZE
  97. };