]>
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 | |
25b1fc05 | 81 | wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }; |
9b6dbb09 JS |
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 | ||
b23386b2 JS |
107 | protected: |
108 | virtual void DoSetSize(int x, int y, | |
109 | int width, int height, | |
110 | int sizeFlags = wxSIZE_AUTO); | |
111 | virtual void DoSetClientSize(int width, int height); | |
112 | ||
621793f4 | 113 | |
9b6dbb09 JS |
114 | protected: |
115 | ||
0d57be45 JS |
116 | wxMDIClientWindow* m_clientWindow; |
117 | wxMDIChildFrame* m_activeChild; | |
621793f4 | 118 | wxMenuBar* m_activeMenuBar; |
9b6dbb09 JS |
119 | |
120 | DECLARE_EVENT_TABLE() | |
121 | }; | |
122 | ||
123 | class WXDLLEXPORT wxMDIChildFrame: public wxFrame | |
124 | { | |
125 | DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) | |
4fabb575 | 126 | |
bfc6fde4 VZ |
127 | public: |
128 | wxMDIChildFrame(); | |
129 | wxMDIChildFrame(wxMDIParentFrame *parent, | |
130 | wxWindowID id, | |
131 | const wxString& title, | |
132 | const wxPoint& pos = wxDefaultPosition, | |
133 | const wxSize& size = wxDefaultSize, | |
134 | long style = wxDEFAULT_FRAME_STYLE, | |
135 | const wxString& name = wxFrameNameStr) | |
136 | { | |
137 | Create(parent, id, title, pos, size, style, name); | |
138 | } | |
139 | ||
140 | ~wxMDIChildFrame(); | |
141 | ||
142 | bool Create(wxMDIParentFrame *parent, | |
143 | wxWindowID id, | |
144 | const wxString& title, | |
145 | const wxPoint& pos = wxDefaultPosition, | |
146 | const wxSize& size = wxDefaultSize, | |
147 | long style = wxDEFAULT_FRAME_STYLE, | |
148 | const wxString& name = wxFrameNameStr); | |
149 | ||
150 | // Set menu bar | |
151 | void SetMenuBar(wxMenuBar *menu_bar); | |
152 | void SetTitle(const wxString& title); | |
153 | ||
ad813b00 | 154 | void GetClientSize(int *width, int *height) const; |
bfc6fde4 VZ |
155 | void GetSize(int *width, int *height) const; |
156 | void GetPosition(int *x, int *y) const ; | |
157 | ||
158 | // Set icon | |
159 | virtual void SetIcon(const wxIcon& icon); | |
160 | ||
161 | // Override wxFrame operations | |
162 | void CaptureMouse(); | |
163 | void ReleaseMouse(); | |
164 | void Raise(); | |
165 | void Lower(void); | |
166 | void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1); | |
167 | ||
168 | // MDI operations | |
169 | virtual void Maximize(); | |
170 | virtual void Maximize(bool WXUNUSED(maximize)) { }; | |
171 | inline void Minimize() { Iconize(TRUE); }; | |
172 | virtual void Iconize(bool iconize); | |
173 | virtual void Restore(); | |
174 | virtual void Activate(); | |
175 | virtual bool IsIconized() const ; | |
176 | ||
177 | // Is the frame maximized? Returns TRUE for | |
178 | // wxMDIChildFrame due to the tabbed implementation. | |
179 | virtual bool IsMaximized(void) const ; | |
180 | ||
181 | bool Show(bool show); | |
182 | ||
183 | WXWidget GetMainWidget() const { return m_mainWidget; }; | |
184 | WXWidget GetTopWidget() const { return m_mainWidget; }; | |
185 | WXWidget GetClientWidget() const { return m_mainWidget; }; | |
186 | ||
187 | /* | |
188 | virtual void OnRaise(); | |
189 | virtual void OnLower(); | |
190 | */ | |
191 | ||
192 | void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; } | |
193 | wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; } | |
8704bf74 JS |
194 | |
195 | protected: | |
bfc6fde4 VZ |
196 | wxMDIParentFrame* m_mdiParentFrame; |
197 | ||
198 | virtual void DoSetSize(int x, int y, | |
199 | int width, int height, | |
200 | int sizeFlags = wxSIZE_AUTO); | |
201 | virtual void DoSetClientSize(int width, int height); | |
9b6dbb09 JS |
202 | }; |
203 | ||
204 | /* The client window is a child of the parent MDI frame, and itself | |
205 | * contains the child MDI frames. | |
206 | * However, you create the MDI children as children of the MDI parent: | |
207 | * only in the implementation does the client window become the parent | |
208 | * of the children. Phew! So the children are sort of 'adopted'... | |
209 | */ | |
210 | ||
621793f4 | 211 | class WXDLLEXPORT wxMDIClientWindow: public wxNotebook |
9b6dbb09 | 212 | { |
bfc6fde4 | 213 | DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) |
9b6dbb09 | 214 | |
bfc6fde4 VZ |
215 | public: |
216 | wxMDIClientWindow() ; | |
217 | wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0) | |
218 | { | |
219 | CreateClient(parent, style); | |
220 | } | |
8704bf74 | 221 | |
bfc6fde4 | 222 | ~wxMDIClientWindow(); |
4fabb575 | 223 | |
bfc6fde4 VZ |
224 | void GetClientSize(int *width, int *height) const; |
225 | void GetSize(int *width, int *height) const ; | |
226 | void GetPosition(int *x, int *y) const ; | |
8704bf74 | 227 | |
bfc6fde4 VZ |
228 | // Note: this is virtual, to allow overridden behaviour. |
229 | virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL); | |
9b6dbb09 | 230 | |
bfc6fde4 VZ |
231 | // Explicitly call default scroll behaviour |
232 | void OnScroll(wxScrollEvent& event); | |
9b6dbb09 | 233 | |
bfc6fde4 VZ |
234 | // Implementation |
235 | void OnPageChanged(wxNotebookEvent& event); | |
8704bf74 | 236 | |
9b6dbb09 | 237 | protected: |
bfc6fde4 VZ |
238 | virtual void DoSetSize(int x, int y, |
239 | int width, int height, | |
240 | int sizeFlags = wxSIZE_AUTO); | |
241 | virtual void DoSetClientSize(int width, int height); | |
9b6dbb09 | 242 | |
bfc6fde4 VZ |
243 | private: |
244 | DECLARE_EVENT_TABLE() | |
9b6dbb09 JS |
245 | }; |
246 | ||
247 | #endif | |
248 | // _WX_MDI_H_ |