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