]>
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; | |
4fabb575 | 75 | wxSize GetClientSize() const { return wxWindow::GetClientSize(); } |
9b6dbb09 | 76 | |
0d57be45 | 77 | // Get the active MDI child window |
9b6dbb09 JS |
78 | wxMDIChildFrame *GetActiveChild() const ; |
79 | ||
80 | // Get the client window | |
81 | inline wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; | |
82 | ||
83 | // Create the client window class (don't Create the window, | |
84 | // just return a new class) | |
85 | virtual wxMDIClientWindow *OnCreateClient() ; | |
86 | ||
87 | // MDI operations | |
88 | virtual void Cascade(); | |
89 | virtual void Tile(); | |
90 | virtual void ArrangeIcons(); | |
91 | virtual void ActivateNext(); | |
92 | virtual void ActivatePrevious(); | |
93 | ||
0d57be45 | 94 | // Implementation |
621793f4 JS |
95 | |
96 | // Set the active child | |
0d57be45 JS |
97 | inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; } |
98 | ||
621793f4 JS |
99 | // Set the child's menubar into the parent frame |
100 | void SetChildMenuBar(wxMDIChildFrame* frame); | |
101 | ||
102 | inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; } | |
103 | ||
104 | // Redirect events to active child first | |
105 | virtual bool ProcessEvent(wxEvent& event); | |
106 | ||
107 | ||
9b6dbb09 JS |
108 | protected: |
109 | ||
0d57be45 JS |
110 | wxMDIClientWindow* m_clientWindow; |
111 | wxMDIChildFrame* m_activeChild; | |
621793f4 | 112 | wxMenuBar* m_activeMenuBar; |
9b6dbb09 JS |
113 | |
114 | DECLARE_EVENT_TABLE() | |
115 | }; | |
116 | ||
117 | class WXDLLEXPORT wxMDIChildFrame: public wxFrame | |
118 | { | |
119 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
120 | public: | |
121 | ||
122 | wxMDIChildFrame(); | |
123 | inline wxMDIChildFrame(wxMDIParentFrame *parent, | |
124 | wxWindowID id, | |
125 | const wxString& title, | |
126 | const wxPoint& pos = wxDefaultPosition, | |
127 | const wxSize& size = wxDefaultSize, | |
128 | long style = wxDEFAULT_FRAME_STYLE, | |
129 | const wxString& name = wxFrameNameStr) | |
130 | { | |
131 | Create(parent, id, title, pos, size, style, name); | |
132 | } | |
133 | ||
134 | ~wxMDIChildFrame(); | |
135 | ||
136 | bool Create(wxMDIParentFrame *parent, | |
137 | wxWindowID id, | |
138 | const wxString& title, | |
139 | const wxPoint& pos = wxDefaultPosition, | |
140 | const wxSize& size = wxDefaultSize, | |
141 | long style = wxDEFAULT_FRAME_STYLE, | |
142 | const wxString& name = wxFrameNameStr); | |
143 | ||
144 | // Set menu bar | |
145 | void SetMenuBar(wxMenuBar *menu_bar); | |
8704bf74 | 146 | void SetTitle(const wxString& title); |
4fabb575 | 147 | |
9b6dbb09 | 148 | void SetClientSize(int width, int height); |
4fabb575 JS |
149 | void SetClientSize(const wxSize& size) { wxWindow::SetClientSize(size); } |
150 | ||
8704bf74 | 151 | void GetClientSize(int *width, int *height) const; |
4fabb575 JS |
152 | wxSize GetClientSize() const { return wxWindow::GetClientSize(); } |
153 | ||
8704bf74 | 154 | void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); |
4fabb575 JS |
155 | virtual void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) |
156 | { wxWindow::SetSize(rect, sizeFlags); } | |
157 | virtual void SetSize(const wxSize& size) { wxWindow::SetSize(size); } | |
c330a2cf | 158 | virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } |
4fabb575 | 159 | |
8704bf74 | 160 | void GetSize(int *width, int *height) const; |
4fabb575 JS |
161 | wxSize GetSize() const { return wxWindow::GetSize(); } |
162 | ||
9b6dbb09 | 163 | void GetPosition(int *x, int *y) const ; |
4fabb575 | 164 | wxPoint GetPosition() const { return wxWindow::GetPosition(); } |
9b6dbb09 | 165 | |
8704bf74 JS |
166 | // Set icon |
167 | virtual void SetIcon(const wxIcon& icon); | |
168 | ||
621793f4 JS |
169 | // Override wxFrame operations |
170 | void CaptureMouse(); | |
171 | void ReleaseMouse(); | |
172 | void Raise(); | |
173 | void Lower(void); | |
174 | void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); | |
175 | ||
9b6dbb09 JS |
176 | // MDI operations |
177 | virtual void Maximize(); | |
8704bf74 JS |
178 | inline void Minimize() { Iconize(TRUE); }; |
179 | virtual void Iconize(bool iconize); | |
9b6dbb09 JS |
180 | virtual void Restore(); |
181 | virtual void Activate(); | |
8704bf74 JS |
182 | virtual bool IsIconized() const ; |
183 | ||
6f63ec3f JS |
184 | // Is the frame maximized? Returns TRUE for |
185 | // wxMDIChildFrame due to the tabbed implementation. | |
186 | virtual bool IsMaximized(void) const ; | |
187 | ||
8704bf74 | 188 | bool Show(bool show); |
621793f4 JS |
189 | |
190 | inline WXWidget GetMainWidget() const { return m_mainWidget; }; | |
8704bf74 | 191 | inline WXWidget GetTopWidget() const { return m_mainWidget; }; |
621793f4 JS |
192 | inline WXWidget GetClientWidget() const { return m_mainWidget; }; |
193 | ||
194 | /* | |
0d57be45 JS |
195 | virtual void OnRaise(); |
196 | virtual void OnLower(); | |
621793f4 JS |
197 | */ |
198 | ||
199 | inline void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; } | |
200 | inline wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; } | |
8704bf74 JS |
201 | |
202 | protected: | |
621793f4 | 203 | wxMDIParentFrame* m_mdiParentFrame; |
9b6dbb09 JS |
204 | }; |
205 | ||
206 | /* The client window is a child of the parent MDI frame, and itself | |
207 | * contains the child MDI frames. | |
208 | * However, you create the MDI children as children of the MDI parent: | |
209 | * only in the implementation does the client window become the parent | |
210 | * of the children. Phew! So the children are sort of 'adopted'... | |
211 | */ | |
212 | ||
621793f4 | 213 | class WXDLLEXPORT wxMDIClientWindow: public wxNotebook |
9b6dbb09 JS |
214 | { |
215 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) | |
216 | public: | |
217 | ||
218 | wxMDIClientWindow() ; | |
219 | inline wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
220 | { | |
221 | CreateClient(parent, style); | |
222 | } | |
223 | ||
224 | ~wxMDIClientWindow(); | |
225 | ||
8704bf74 | 226 | void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); |
4fabb575 JS |
227 | void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) |
228 | { wxWindow::SetSize(rect, sizeFlags); } | |
229 | void SetSize(const wxSize& size) { wxWindow::SetSize(size); } | |
c330a2cf | 230 | virtual void SetSize(int width, int height) { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); } |
4fabb575 | 231 | |
8704bf74 | 232 | void SetClientSize(int width, int height); |
4fabb575 JS |
233 | void SetClientSize(const wxSize& size) { wxWindow::SetClientSize(size); } |
234 | ||
8704bf74 | 235 | void GetClientSize(int *width, int *height) const; |
4fabb575 | 236 | wxSize GetClientSize() const { return wxWindow::GetClientSize(); } |
8704bf74 JS |
237 | |
238 | void GetSize(int *width, int *height) const ; | |
4fabb575 JS |
239 | wxSize GetSize() const { return wxWindow::GetSize(); } |
240 | ||
8704bf74 | 241 | void GetPosition(int *x, int *y) const ; |
4fabb575 | 242 | wxPoint GetPosition() const { return wxWindow::GetPosition(); } |
8704bf74 | 243 | |
9b6dbb09 JS |
244 | // Note: this is virtual, to allow overridden behaviour. |
245 | virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); | |
246 | ||
247 | // Explicitly call default scroll behaviour | |
248 | void OnScroll(wxScrollEvent& event); | |
249 | ||
621793f4 JS |
250 | // Implementation |
251 | void OnPageChanged(wxNotebookEvent& event); | |
8704bf74 | 252 | |
9b6dbb09 JS |
253 | protected: |
254 | ||
255 | DECLARE_EVENT_TABLE() | |
256 | }; | |
257 | ||
258 | #endif | |
259 | // _WX_MDI_H_ |