]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mdi.h | |
3 | // Purpose: MDI (Multiple Document Interface) classes. | |
9b6dbb09 JS |
4 | // Author: Julian Smart |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_MDI_H_ | |
13 | #define _WX_MDI_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "mdi.h" | |
17 | #endif | |
18 | ||
621793f4 JS |
19 | /* |
20 | New MDI scheme using tabs. We can use a wxNotebook to implement the client | |
21 | window. wxMDIChildFrame can be implemented as an XmMainWindow widget | |
22 | as before, and is a child of the notebook _and_ of the parent frame... | |
23 | but wxMDIChildFrame::GetParent should return the parent frame. | |
24 | ||
25 | */ | |
26 | ||
9b6dbb09 | 27 | #include "wx/frame.h" |
621793f4 | 28 | #include "wx/notebook.h" |
9b6dbb09 JS |
29 | |
30 | WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; | |
31 | WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr; | |
32 | ||
33 | class WXDLLEXPORT wxMDIClientWindow; | |
34 | class WXDLLEXPORT wxMDIChildFrame; | |
35 | ||
36 | class WXDLLEXPORT wxMDIParentFrame: public wxFrame | |
37 | { | |
38 | DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) | |
39 | ||
40 | friend class WXDLLEXPORT wxMDIChildFrame; | |
41 | public: | |
42 | ||
43 | wxMDIParentFrame(); | |
44 | inline wxMDIParentFrame(wxWindow *parent, | |
45 | wxWindowID id, | |
46 | const wxString& title, | |
47 | const wxPoint& pos = wxDefaultPosition, | |
48 | const wxSize& size = wxDefaultSize, | |
49 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window | |
50 | const wxString& name = wxFrameNameStr) | |
51 | { | |
52 | Create(parent, id, title, pos, size, style, name); | |
53 | } | |
54 | ||
55 | ~wxMDIParentFrame(); | |
56 | ||
57 | bool Create(wxWindow *parent, | |
58 | wxWindowID id, | |
59 | const wxString& title, | |
60 | const wxPoint& pos = wxDefaultPosition, | |
61 | const wxSize& size = wxDefaultSize, | |
62 | long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, | |
63 | const wxString& name = wxFrameNameStr); | |
64 | ||
65 | void OnSize(wxSizeEvent& event); | |
66 | void OnActivate(wxActivateEvent& event); | |
67 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
68 | ||
69 | void SetMenuBar(wxMenuBar *menu_bar); | |
70 | ||
71 | // Gets the size available for subwindows after menu size, toolbar size | |
72 | // and status bar size have been subtracted. If you want to manage your own | |
73 | // toolbar(s), don't call SetToolBar. | |
74 | void GetClientSize(int *width, int *height) const; | |
75 | ||
0d57be45 | 76 | // Get the active MDI child window |
9b6dbb09 JS |
77 | wxMDIChildFrame *GetActiveChild() const ; |
78 | ||
79 | // Get the client window | |
80 | inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; | |
81 | ||
82 | // Create the client window class (don't Create the window, | |
83 | // just return a new class) | |
84 | virtual wxMDIClientWindow *OnCreateClient() ; | |
85 | ||
86 | // MDI operations | |
87 | virtual void Cascade(); | |
88 | virtual void Tile(); | |
89 | virtual void ArrangeIcons(); | |
90 | virtual void ActivateNext(); | |
91 | virtual void ActivatePrevious(); | |
92 | ||
0d57be45 | 93 | // Implementation |
621793f4 JS |
94 | |
95 | // Set the active child | |
0d57be45 JS |
96 | inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } |
97 | ||
621793f4 JS |
98 | // Set the child's menubar into the parent frame |
99 | void SetChildMenuBar(wxMDIChildFrame* frame); | |
100 | ||
101 | inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; } | |
102 | ||
103 | // Redirect events to active child first | |
104 | virtual bool ProcessEvent(wxEvent& event); | |
105 | ||
106 | ||
9b6dbb09 JS |
107 | protected: |
108 | ||
0d57be45 JS |
109 | wxMDIClientWindow* m_clientWindow; |
110 | wxMDIChildFrame* m_activeChild; | |
621793f4 | 111 | wxMenuBar* m_activeMenuBar; |
9b6dbb09 JS |
112 | |
113 | DECLARE_EVENT_TABLE() | |
114 | }; | |
115 | ||
116 | class WXDLLEXPORT wxMDIChildFrame: public wxFrame | |
117 | { | |
118 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
119 | public: | |
120 | ||
121 | wxMDIChildFrame(); | |
122 | inline wxMDIChildFrame(wxMDIParentFrame *parent, | |
123 | wxWindowID id, | |
124 | const wxString& title, | |
125 | const wxPoint& pos = wxDefaultPosition, | |
126 | const wxSize& size = wxDefaultSize, | |
127 | long style = wxDEFAULT_FRAME_STYLE, | |
128 | const wxString& name = wxFrameNameStr) | |
129 | { | |
130 | Create(parent, id, title, pos, size, style, name); | |
131 | } | |
132 | ||
133 | ~wxMDIChildFrame(); | |
134 | ||
135 | bool Create(wxMDIParentFrame *parent, | |
136 | wxWindowID id, | |
137 | const wxString& title, | |
138 | const wxPoint& pos = wxDefaultPosition, | |
139 | const wxSize& size = wxDefaultSize, | |
140 | long style = wxDEFAULT_FRAME_STYLE, | |
141 | const wxString& name = wxFrameNameStr); | |
142 | ||
143 | // Set menu bar | |
144 | void SetMenuBar(wxMenuBar *menu_bar); | |
8704bf74 | 145 | void SetTitle(const wxString& title); |
9b6dbb09 | 146 | void SetClientSize(int width, int height); |
8704bf74 JS |
147 | void GetClientSize(int *width, int *height) const; |
148 | void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
149 | void GetSize(int *width, int *height) const; | |
9b6dbb09 JS |
150 | void GetPosition(int *x, int *y) const ; |
151 | ||
8704bf74 JS |
152 | // Set icon |
153 | virtual void SetIcon(const wxIcon& icon); | |
154 | ||
621793f4 JS |
155 | // Override wxFrame operations |
156 | void CaptureMouse(); | |
157 | void ReleaseMouse(); | |
158 | void Raise(); | |
159 | void Lower(void); | |
160 | void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); | |
161 | ||
9b6dbb09 JS |
162 | // MDI operations |
163 | virtual void Maximize(); | |
8704bf74 JS |
164 | inline void Minimize() { Iconize(TRUE); }; |
165 | virtual void Iconize(bool iconize); | |
9b6dbb09 JS |
166 | virtual void Restore(); |
167 | virtual void Activate(); | |
8704bf74 JS |
168 | virtual bool IsIconized() const ; |
169 | ||
170 | bool Show(bool show); | |
621793f4 JS |
171 | |
172 | inline WXWidget GetMainWidget() const { return m_mainWidget; }; | |
8704bf74 | 173 | inline WXWidget GetTopWidget() const { return m_mainWidget; }; |
621793f4 JS |
174 | inline WXWidget GetClientWidget() const { return m_mainWidget; }; |
175 | ||
176 | /* | |
0d57be45 JS |
177 | virtual void OnRaise(); |
178 | virtual void OnLower(); | |
621793f4 JS |
179 | */ |
180 | ||
181 | inline void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; } | |
182 | inline wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; } | |
8704bf74 JS |
183 | |
184 | protected: | |
621793f4 | 185 | wxMDIParentFrame* m_mdiParentFrame; |
9b6dbb09 JS |
186 | }; |
187 | ||
188 | /* The client window is a child of the parent MDI frame, and itself | |
189 | * contains the child MDI frames. | |
190 | * However, you create the MDI children as children of the MDI parent: | |
191 | * only in the implementation does the client window become the parent | |
192 | * of the children. Phew! So the children are sort of 'adopted'... | |
193 | */ | |
194 | ||
621793f4 | 195 | class WXDLLEXPORT wxMDIClientWindow: public wxNotebook |
9b6dbb09 JS |
196 | { |
197 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) | |
198 | public: | |
199 | ||
200 | wxMDIClientWindow() ; | |
201 | inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
202 | { | |
203 | CreateClient(parent, style); | |
204 | } | |
205 | ||
206 | ~wxMDIClientWindow(); | |
207 | ||
8704bf74 JS |
208 | void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); |
209 | void SetClientSize(int width, int height); | |
210 | void GetClientSize(int *width, int *height) const; | |
211 | ||
212 | void GetSize(int *width, int *height) const ; | |
213 | void GetPosition(int *x, int *y) const ; | |
214 | ||
9b6dbb09 JS |
215 | // Note: this is virtual, to allow overridden behaviour. |
216 | virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); | |
217 | ||
218 | // Explicitly call default scroll behaviour | |
219 | void OnScroll(wxScrollEvent& event); | |
220 | ||
621793f4 JS |
221 | // Implementation |
222 | void OnPageChanged(wxNotebookEvent& event); | |
8704bf74 | 223 | |
9b6dbb09 JS |
224 | protected: |
225 | ||
226 | DECLARE_EVENT_TABLE() | |
227 | }; | |
228 | ||
229 | #endif | |
230 | // _WX_MDI_H_ |