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