]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | #include "wx/toolbar.h" | |
12 | ||
13 | // Define a new application | |
14 | class MyApp : public wxApp | |
15 | { | |
16 | public: | |
17 | virtual bool OnInit(); | |
18 | }; | |
19 | ||
20 | class MyCanvas : public wxScrolledWindow | |
21 | { | |
22 | public: | |
23 | MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size); | |
24 | virtual void OnDraw(wxDC& dc); | |
25 | ||
26 | bool IsDirty() const { return m_dirty; } | |
27 | ||
28 | void SetText(const wxString& text) { m_text = text; Refresh(); } | |
29 | ||
30 | private: | |
31 | void OnEvent(wxMouseEvent& event); | |
32 | ||
33 | wxString m_text; | |
34 | ||
35 | bool m_dirty; | |
36 | ||
37 | DECLARE_EVENT_TABLE() | |
38 | }; | |
39 | ||
40 | // Define a new frame | |
41 | class MyFrame : public wxMDIParentFrame | |
42 | { | |
43 | public: | |
44 | MyFrame(); | |
45 | virtual ~MyFrame(); | |
46 | ||
47 | static wxMenuBar *CreateMainMenubar(); | |
48 | ||
49 | private: | |
50 | void InitToolBar(wxToolBar* toolBar); | |
51 | ||
52 | void OnSize(wxSizeEvent& event); | |
53 | void OnAbout(wxCommandEvent& event); | |
54 | void OnNewWindow(wxCommandEvent& event); | |
55 | void OnFullScreen(wxCommandEvent& event); | |
56 | void OnQuit(wxCommandEvent& event); | |
57 | void OnCloseAll(wxCommandEvent& event); | |
58 | ||
59 | void OnClose(wxCloseEvent& event); | |
60 | ||
61 | wxTextCtrl *m_textWindow; | |
62 | ||
63 | DECLARE_EVENT_TABLE() | |
64 | }; | |
65 | ||
66 | class MyChild : public wxMDIChildFrame | |
67 | { | |
68 | public: | |
69 | MyChild(wxMDIParentFrame *parent); | |
70 | virtual ~MyChild(); | |
71 | ||
72 | static unsigned GetChildrenCount() { return ms_numChildren; } | |
73 | ||
74 | private: | |
75 | void OnActivate(wxActivateEvent& event); | |
76 | ||
77 | void OnRefresh(wxCommandEvent& event); | |
78 | void OnUpdateRefresh(wxUpdateUIEvent& event); | |
79 | void OnChangeTitle(wxCommandEvent& event); | |
80 | void OnChangePosition(wxCommandEvent& event); | |
81 | void OnChangeSize(wxCommandEvent& event); | |
82 | void OnClose(wxCommandEvent& event); | |
83 | void OnSize(wxSizeEvent& event); | |
84 | void OnMove(wxMoveEvent& event); | |
85 | void OnCloseWindow(wxCloseEvent& event); | |
86 | ||
87 | #if wxUSE_CLIPBOARD | |
88 | void OnPaste(wxCommandEvent& event); | |
89 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
90 | #endif // wxUSE_CLIPBOARD | |
91 | ||
92 | static unsigned ms_numChildren; | |
93 | ||
94 | MyCanvas *m_canvas; | |
95 | ||
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 | ||
116 | DECLARE_EVENT_TABLE() | |
117 | }; | |
118 | ||
119 | // menu items ids | |
120 | enum | |
121 | { | |
122 | MDI_FULLSCREEN = 100, | |
123 | MDI_REFRESH, | |
124 | MDI_CHANGE_TITLE, | |
125 | MDI_CHANGE_POSITION, | |
126 | MDI_CHANGE_SIZE | |
127 | }; |