refactor WM_COMMAND messages handling in MDI frames to avoid duplicating code unneces...
[wxWidgets.git] / samples / mdi / mdi.h
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
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 virtual 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 SetText(const wxString& text) { m_text = text; Refresh(); }
30
31 private:
32 void OnEvent(wxMouseEvent& event);
33
34 wxString m_text;
35
36 bool m_dirty;
37
38 DECLARE_EVENT_TABLE()
39 };
40
41 // Define a new frame
42 class MyFrame : public wxMDIParentFrame
43 {
44 public:
45 MyFrame();
46 virtual ~MyFrame();
47
48 private:
49 void InitToolBar(wxToolBar* toolBar);
50
51 void OnSize(wxSizeEvent& event);
52 void OnAbout(wxCommandEvent& event);
53 void OnNewWindow(wxCommandEvent& event);
54 void OnFullScreen(wxCommandEvent& event);
55 void OnQuit(wxCommandEvent& event);
56 void OnCloseAll(wxCommandEvent& event);
57
58 void OnClose(wxCloseEvent& event);
59
60 wxTextCtrl *m_textWindow;
61
62 DECLARE_EVENT_TABLE()
63 };
64
65 class MyChild : public wxMDIChildFrame
66 {
67 public:
68 MyChild(wxMDIParentFrame *parent);
69 virtual ~MyChild();
70
71 static unsigned GetChildrenCount() { return ms_numChildren; }
72
73 private:
74 void OnActivate(wxActivateEvent& event);
75
76 void OnRefresh(wxCommandEvent& event);
77 void OnUpdateRefresh(wxUpdateUIEvent& event);
78 void OnChangeTitle(wxCommandEvent& event);
79 void OnChangePosition(wxCommandEvent& event);
80 void OnChangeSize(wxCommandEvent& event);
81 void OnClose(wxCommandEvent& event);
82 void OnSize(wxSizeEvent& event);
83 void OnMove(wxMoveEvent& event);
84 void OnCloseWindow(wxCloseEvent& event);
85
86 #if wxUSE_CLIPBOARD
87 void OnPaste(wxCommandEvent& event);
88 void OnUpdatePaste(wxUpdateUIEvent& event);
89 #endif // wxUSE_CLIPBOARD
90
91 static unsigned ms_numChildren;
92
93 MyCanvas *m_canvas;
94
95 DECLARE_EVENT_TABLE()
96 };
97
98 // menu items ids
99 enum
100 {
101 MDI_FULLSCREEN,
102 MDI_REFRESH,
103 MDI_CHANGE_TITLE,
104 MDI_CHANGE_POSITION,
105 MDI_CHANGE_SIZE
106 };