]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.cpp | |
3 | // Purpose: MDI sample | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
6aa89a22 | 7 | // Copyright: (c) Julian Smart |
526954c5 | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
012f2cb2 | 11 | #include "wx/toolbar.h" |
6b0eb19f | 12 | |
c801d85f | 13 | // Define a new application |
c52d95b4 | 14 | class MyApp : public wxApp |
c801d85f | 15 | { |
c52d95b4 | 16 | public: |
d2824cdb | 17 | virtual bool OnInit(); |
c801d85f KB |
18 | }; |
19 | ||
c52d95b4 | 20 | class MyCanvas : public wxScrolledWindow |
c801d85f | 21 | { |
c52d95b4 | 22 | public: |
c801d85f KB |
23 | MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size); |
24 | virtual void OnDraw(wxDC& dc); | |
c52d95b4 VZ |
25 | |
26 | bool IsDirty() const { return m_dirty; } | |
27 | ||
c9f856af VZ |
28 | void SetText(const wxString& text) { m_text = text; Refresh(); } |
29 | ||
c52d95b4 | 30 | private: |
d2824cdb VZ |
31 | void OnEvent(wxMouseEvent& event); |
32 | ||
c9f856af VZ |
33 | wxString m_text; |
34 | ||
c52d95b4 VZ |
35 | bool m_dirty; |
36 | ||
c801d85f KB |
37 | DECLARE_EVENT_TABLE() |
38 | }; | |
39 | ||
c801d85f | 40 | // Define a new frame |
c52d95b4 | 41 | class MyFrame : public wxMDIParentFrame |
c801d85f | 42 | { |
c52d95b4 | 43 | public: |
d2824cdb VZ |
44 | MyFrame(); |
45 | virtual ~MyFrame(); | |
81d66cf3 | 46 | |
4f7cd56c VZ |
47 | static wxMenuBar *CreateMainMenubar(); |
48 | ||
d2824cdb | 49 | private: |
81d66cf3 JS |
50 | void InitToolBar(wxToolBar* toolBar); |
51 | ||
c801d85f KB |
52 | void OnSize(wxSizeEvent& event); |
53 | void OnAbout(wxCommandEvent& event); | |
54 | void OnNewWindow(wxCommandEvent& event); | |
9089cffb | 55 | void OnFullScreen(wxCommandEvent& event); |
c801d85f | 56 | void OnQuit(wxCommandEvent& event); |
1483e5db VZ |
57 | void OnCloseAll(wxCommandEvent& event); |
58 | ||
c52d95b4 | 59 | void OnClose(wxCloseEvent& event); |
c801d85f | 60 | |
d2824cdb VZ |
61 | wxTextCtrl *m_textWindow; |
62 | ||
c52d95b4 | 63 | DECLARE_EVENT_TABLE() |
c801d85f KB |
64 | }; |
65 | ||
d2824cdb | 66 | class MyChild : public wxMDIChildFrame |
c801d85f | 67 | { |
c52d95b4 | 68 | public: |
d2824cdb VZ |
69 | MyChild(wxMDIParentFrame *parent); |
70 | virtual ~MyChild(); | |
c52d95b4 | 71 | |
d2824cdb VZ |
72 | static unsigned GetChildrenCount() { return ms_numChildren; } |
73 | ||
74 | private: | |
c801d85f | 75 | void OnActivate(wxActivateEvent& event); |
c52d95b4 VZ |
76 | |
77 | void OnRefresh(wxCommandEvent& event); | |
fa762db4 | 78 | void OnUpdateRefresh(wxUpdateUIEvent& event); |
f6bcfd97 | 79 | void OnChangeTitle(wxCommandEvent& event); |
fa762db4 VZ |
80 | void OnChangePosition(wxCommandEvent& event); |
81 | void OnChangeSize(wxCommandEvent& event); | |
d2824cdb | 82 | void OnClose(wxCommandEvent& event); |
fa762db4 VZ |
83 | void OnSize(wxSizeEvent& event); |
84 | void OnMove(wxMoveEvent& event); | |
d2824cdb | 85 | void OnCloseWindow(wxCloseEvent& event); |
c801d85f | 86 | |
c9f856af VZ |
87 | #if wxUSE_CLIPBOARD |
88 | void OnPaste(wxCommandEvent& event); | |
89 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
90 | #endif // wxUSE_CLIPBOARD | |
91 | ||
d2824cdb VZ |
92 | static unsigned ms_numChildren; |
93 | ||
94 | MyCanvas *m_canvas; | |
95 | ||
396e9eb8 VZ |
96 | // simple test event handler class |
97 | class EventHandler : public wxEvtHandler | |
98 | { | |
99 | public: | |
100 | EventHandler(unsigned numChild) : m_numChild(numChild) { } | |
101 | ||
102 | private: | |
103 | void OnRefresh(wxCommandEvent& event) | |
104 | { | |
105 | wxLogMessage("Child #%u refreshed.", m_numChild); | |
106 | event.Skip(); | |
107 | } | |
108 | ||
109 | const unsigned m_numChild; | |
110 | ||
111 | DECLARE_EVENT_TABLE() | |
112 | ||
113 | wxDECLARE_NO_COPY_CLASS(EventHandler); | |
114 | }; | |
115 | ||
c52d95b4 | 116 | DECLARE_EVENT_TABLE() |
c801d85f KB |
117 | }; |
118 | ||
c52d95b4 VZ |
119 | // menu items ids |
120 | enum | |
121 | { | |
2140f273 | 122 | MDI_FULLSCREEN = 100, |
c52d95b4 | 123 | MDI_REFRESH, |
f6bcfd97 | 124 | MDI_CHANGE_TITLE, |
fa762db4 | 125 | MDI_CHANGE_POSITION, |
d2824cdb | 126 | MDI_CHANGE_SIZE |
c52d95b4 | 127 | }; |