| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: mdi.cpp |
| 3 | // Purpose: MDI sample |
| 4 | // Author: Julian Smart |
| 5 | // Modified by: |
| 6 | // Created: 04/01/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Julian Smart and Markus Holzem |
| 9 | // Licence: wxWindows license |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #include <wx/toolbar.h> |
| 13 | |
| 14 | // Define a new application |
| 15 | class MyApp : public wxApp |
| 16 | { |
| 17 | public: |
| 18 | bool OnInit(); |
| 19 | }; |
| 20 | |
| 21 | class MyCanvas : public wxScrolledWindow |
| 22 | { |
| 23 | public: |
| 24 | MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size); |
| 25 | virtual void OnDraw(wxDC& dc); |
| 26 | |
| 27 | bool IsDirty() const { return m_dirty; } |
| 28 | |
| 29 | void OnEvent(wxMouseEvent& event); |
| 30 | |
| 31 | private: |
| 32 | bool m_dirty; |
| 33 | |
| 34 | DECLARE_EVENT_TABLE() |
| 35 | }; |
| 36 | |
| 37 | // Define a new frame |
| 38 | class MyFrame : public wxMDIParentFrame |
| 39 | { |
| 40 | public: |
| 41 | wxTextCtrl *textWindow; |
| 42 | |
| 43 | MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, |
| 44 | const wxPoint& pos, const wxSize& size, const long style); |
| 45 | |
| 46 | void InitToolBar(wxToolBar* toolBar); |
| 47 | |
| 48 | void OnSize(wxSizeEvent& event); |
| 49 | void OnAbout(wxCommandEvent& event); |
| 50 | void OnNewWindow(wxCommandEvent& event); |
| 51 | void OnQuit(wxCommandEvent& event); |
| 52 | void OnClose(wxCloseEvent& event); |
| 53 | |
| 54 | DECLARE_EVENT_TABLE() |
| 55 | }; |
| 56 | |
| 57 | class MyChild: public wxMDIChildFrame |
| 58 | { |
| 59 | public: |
| 60 | MyCanvas *canvas; |
| 61 | MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style); |
| 62 | ~MyChild(); |
| 63 | |
| 64 | void OnActivate(wxActivateEvent& event); |
| 65 | |
| 66 | void OnRefresh(wxCommandEvent& event); |
| 67 | void OnQuit(wxCommandEvent& event); |
| 68 | void OnClose(wxCloseEvent& event); |
| 69 | |
| 70 | DECLARE_EVENT_TABLE() |
| 71 | }; |
| 72 | |
| 73 | // menu items ids |
| 74 | enum |
| 75 | { |
| 76 | MDI_QUIT = 100, |
| 77 | MDI_NEW_WINDOW, |
| 78 | MDI_REFRESH, |
| 79 | MDI_CHILD_QUIT, |
| 80 | MDI_ABOUT |
| 81 | }; |