]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mdi.h
fix wxBitmapComboBox Gtk-CRITICAL assertion `GTK_IS_ENTRY (entry)' failed
[wxWidgets.git] / include / wx / mdi.h
CommitLineData
2ecf902b 1/////////////////////////////////////////////////////////////////////////////
99d80019 2// Name: wx/mdi.h
2ecf902b 3// Purpose: wxMDI base header
d2824cdb
VZ
4// Author: Julian Smart (original)
5// Vadim Zeitlin (base MDI classes refactoring)
6// Copyright: (c) 1998 Julian Smart
7// (c) 2008 Vadim Zeitlin
2ecf902b
WS
8// RCS-ID: $Id$
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_MDI_H_BASE_
13#define _WX_MDI_H_BASE_
c801d85f 14
2ecf902b 15#include "wx/defs.h"
1ce0cc20 16
efd17a1d 17#if wxUSE_MDI
1bf49fb9 18
d2824cdb 19#include "wx/frame.h"
975dd469 20#include "wx/menu.h"
d2824cdb
VZ
21
22// forward declarations
23class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame;
24class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
25class WXDLLIMPEXP_FWD_CORE wxMDIClientWindowBase;
26class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
27
28// ----------------------------------------------------------------------------
29// wxMDIParentFrameBase: base class for parent frame for MDI children
30// ----------------------------------------------------------------------------
31
32class WXDLLIMPEXP_CORE wxMDIParentFrameBase : public wxFrame
33{
34public:
35 wxMDIParentFrameBase()
36 {
37 m_clientWindow = NULL;
38 m_currentChild = NULL;
39#if wxUSE_MENUS
40 m_windowMenu = NULL;
41#endif // wxUSE_MENUS
42 }
43
44 /*
45 Derived classes should provide ctor and Create() with the following
46 declaration:
47
48 bool Create(wxWindow *parent,
49 wxWindowID winid,
50 const wxString& title,
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
53 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
54 const wxString& name = wxFrameNameStr);
55 */
56
57#if wxUSE_MENUS
58 virtual ~wxMDIParentFrameBase()
59 {
60 delete m_windowMenu;
61 }
62#endif // wxUSE_MENUS
63
64 // accessors
65 // ---------
66
67 // Get or change the active MDI child window
68 virtual wxMDIChildFrame *GetActiveChild() const
69 { return m_currentChild; }
70 virtual void SetActiveChild(wxMDIChildFrame *child)
71 { m_currentChild = child; }
72
73
74 // Get the client window
75 wxMDIClientWindowBase *GetClientWindow() const { return m_clientWindow; }
76
77
78 // MDI windows menu functions
79 // --------------------------
80
81#if wxUSE_MENUS
82 // return the pointer to the current window menu or NULL if we don't have
83 // because of wxFRAME_NO_WINDOW_MENU style
6dd0883d 84 wxMenu* GetWindowMenu() const { return m_windowMenu; }
d2824cdb
VZ
85
86 // use the given menu instead of the default window menu
87 //
88 // menu can be NULL to disable the window menu completely
89 virtual void SetWindowMenu(wxMenu *menu)
90 {
74c34d22
VZ
91 if ( menu != m_windowMenu )
92 {
93 delete m_windowMenu;
94 m_windowMenu = menu;
95 }
d2824cdb
VZ
96 }
97#endif // wxUSE_MENUS
98
99
100 // standard MDI window management functions
101 // ----------------------------------------
102
103 virtual void Cascade() { }
104 virtual void Tile(wxOrientation WXUNUSED(orient) = wxHORIZONTAL) { }
105 virtual void ArrangeIcons() { }
106 virtual void ActivateNext() = 0;
107 virtual void ActivatePrevious() = 0;
108
109 /*
110 Derived classes must provide the following function:
111
112 static bool IsTDI();
113 */
114
115 // Create the client window class (don't Create() the window here, just
116 // return a new object of a wxMDIClientWindow-derived class)
117 //
118 // Notice that if you override this method you should use the default
119 // constructor and Create() and not the constructor creating the window
120 // when creating the frame or your overridden version is not going to be
121 // called (as the call to a virtual function from ctor will be dispatched
122 // to this class version)
123 virtual wxMDIClientWindow *OnCreateClient();
124
125protected:
126 // This is wxMDIClientWindow for all the native implementations but not for
127 // the generic MDI version which has its own wxGenericMDIClientWindow and
128 // so we store it as just a base class pointer because we don't need its
129 // exact type anyhow
130 wxMDIClientWindowBase *m_clientWindow;
131 wxMDIChildFrame *m_currentChild;
132
133#if wxUSE_MENUS
134 // the current window menu or NULL if we are not using it
135 wxMenu *m_windowMenu;
136#endif // wxUSE_MENUS
137};
138
139// ----------------------------------------------------------------------------
140// wxMDIChildFrameBase: child frame managed by wxMDIParentFrame
141// ----------------------------------------------------------------------------
142
143class WXDLLIMPEXP_CORE wxMDIChildFrameBase : public wxFrame
144{
145public:
146 wxMDIChildFrameBase() { m_mdiParent = NULL; }
147
148 /*
149 Derived classes should provide Create() with the following signature:
150
151 bool Create(wxMDIParentFrame *parent,
152 wxWindowID id,
153 const wxString& title,
154 const wxPoint& pos = wxDefaultPosition,
155 const wxSize& size = wxDefaultSize,
156 long style = wxDEFAULT_FRAME_STYLE,
157 const wxString& name = wxFrameNameStr);
158
159 And setting m_mdiParent to parent parameter.
160 */
161
162 // MDI children specific methods
163 virtual void Activate() = 0;
164
165 // Return the MDI parent frame: notice that it may not be the same as
166 // GetParent() (our parent may be the client window or even its subwindow
167 // in some implementations)
168 wxMDIParentFrame *GetMDIParent() const { return m_mdiParent; }
169
170 // Synonym for GetMDIParent(), was used in some other ports
171 wxMDIParentFrame *GetMDIParentFrame() const { return GetMDIParent(); }
172
173
174 // in most ports MDI children frames are not really top-level, the only
175 // exception are the Mac ports in which MDI children are just normal top
176 // level windows too
177 virtual bool IsTopLevel() const { return false; }
178
6e92c299
VZ
179 // In all ports keyboard navigation must stop at MDI child frame level and
180 // can't cross its boundary. Indicate this by overriding this function to
181 // return true.
182 virtual bool IsTopNavigationDomain() const { return true; }
183
3285e9a3
VZ
184 // Raising any frame is supposed to show it but wxFrame Raise()
185 // implementation doesn't work for MDI child frames in most forms so
186 // forward this to Activate() which serves the same purpose by default.
187 virtual void Raise() { Activate(); }
188
d2824cdb
VZ
189protected:
190 wxMDIParentFrame *m_mdiParent;
191};
192
193// ----------------------------------------------------------------------------
194// wxTDIChildFrame: child frame used by TDI implementations
195// ----------------------------------------------------------------------------
196
197class WXDLLIMPEXP_CORE wxTDIChildFrame : public wxMDIChildFrameBase
198{
199public:
200 // override wxFrame methods for this non top-level window
201
202#if wxUSE_STATUSBAR
203 // no status bars
204 //
205 // TODO: MDI children should have their own status bars, why not?
206 virtual wxStatusBar* CreateStatusBar(int WXUNUSED(number) = 1,
207 long WXUNUSED(style) = 1,
208 wxWindowID WXUNUSED(id) = 1,
209 const wxString& WXUNUSED(name)
210 = wxEmptyString)
211 { return NULL; }
212
213 virtual wxStatusBar *GetStatusBar() const
214 { return NULL; }
215 virtual void SetStatusText(const wxString &WXUNUSED(text),
216 int WXUNUSED(number)=0)
217 { }
218 virtual void SetStatusWidths(int WXUNUSED(n),
219 const int WXUNUSED(widths)[])
220 { }
221#endif // wxUSE_STATUSBAR
222
223#if wxUSE_TOOLBAR
224 // no toolbar
225 //
226 // TODO: again, it should be possible to have tool bars
227 virtual wxToolBar *CreateToolBar(long WXUNUSED(style),
228 wxWindowID WXUNUSED(id),
229 const wxString& WXUNUSED(name))
230 { return NULL; }
231 virtual wxToolBar *GetToolBar() const { return NULL; }
232#endif // wxUSE_TOOLBAR
233
234 // no icon
235 virtual void SetIcons(const wxIconBundle& WXUNUSED(icons)) { }
236
237 // title is used as the tab label
238 virtual wxString GetTitle() const { return m_title; }
239 virtual void SetTitle(const wxString& title) = 0;
240
241 // no maximize etc
242 virtual void Maximize(bool WXUNUSED(maximize) = true) { }
243 virtual bool IsMaximized() const { return true; }
244 virtual bool IsAlwaysMaximized() const { return true; }
245 virtual void Iconize(bool WXUNUSED(iconize) = true) { }
246 virtual bool IsIconized() const { return false; }
247 virtual void Restore() { }
248
249 virtual bool ShowFullScreen(bool WXUNUSED(show),
250 long WXUNUSED(style)) { return false; }
251 virtual bool IsFullScreen() const { return false; }
252
253
254 // we need to override these functions to ensure that a child window is
255 // created even though we derive from wxFrame -- basically we make it
256 // behave as just a wxWindow by short-circuiting wxTLW changes to the base
257 // class behaviour
258
259 virtual void AddChild(wxWindowBase *child) { wxWindow::AddChild(child); }
260
261 virtual bool Destroy() { return wxWindow::Destroy(); }
262
263 // extra platform-specific hacks
264#ifdef __WXMSW__
265 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const
266 {
267 return wxWindow::MSWGetStyle(flags, exstyle);
268 }
269
270 virtual WXHWND MSWGetParent() const
271 {
272 return wxWindow::MSWGetParent();
273 }
274
275 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
276 {
277 return wxWindow::MSWWindowProc(message, wParam, lParam);
278 }
279#endif // __WXMSW__
280
281protected:
282 virtual void DoGetSize(int *width, int *height) const
283 {
284 wxWindow::DoGetSize(width, height);
285 }
286
287 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags)
288 {
289 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
290 }
291
292 virtual void DoGetClientSize(int *width, int *height) const
293 {
294 wxWindow::DoGetClientSize(width, height);
295 }
296
297 virtual void DoSetClientSize(int width, int height)
298 {
299 wxWindow::DoSetClientSize(width, height);
300 }
301
302 // no size hints
303 virtual void DoSetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH),
304 int WXUNUSED(maxW), int WXUNUSED(maxH),
305 int WXUNUSED(incW), int WXUNUSED(incH)) { }
306
307 wxString m_title;
308};
309
310// ----------------------------------------------------------------------------
311// wxMDIClientWindowBase: child of parent frame, parent of children frames
312// ----------------------------------------------------------------------------
313
314class WXDLLIMPEXP_CORE wxMDIClientWindowBase : public wxWindow
315{
316public:
317 /*
318 The derived class must provide the default ctor only (CreateClient()
319 will be called later).
320 */
321
322 // Can be overridden in the derived classes but the base class version must
323 // be usually called first to really create the client window.
324 virtual bool CreateClient(wxMDIParentFrame *parent,
325 long style = wxVSCROLL | wxHSCROLL) = 0;
326};
327
328// ----------------------------------------------------------------------------
329// Include the port-specific implementation of the base classes defined above
330// ----------------------------------------------------------------------------
331
332// wxUSE_GENERIC_MDI_AS_NATIVE may be predefined to force the generic MDI
333// implementation use even on the platforms which usually don't use it
334//
335// notice that generic MDI can still be used without this, but you would need
336// to explicitly use wxGenericMDIXXX classes in your code (and currently also
337// add src/generic/mdig.cpp to your build as it's not compiled in if generic
338// MDI is not used by default -- but this may change later...)
339#ifndef wxUSE_GENERIC_MDI_AS_NATIVE
340 // wxUniv always uses the generic MDI implementation and so do the ports
341 // without native version (although wxCocoa seems to have one -- but it's
342 // probably not functional?)
343 #if defined(__WXCOCOA__) || \
344 defined(__WXMOTIF__) || \
345 defined(__WXPM__) || \
346 defined(__WXUNIVERSAL__)
347 #define wxUSE_GENERIC_MDI_AS_NATIVE 1
348 #else
349 #define wxUSE_GENERIC_MDI_AS_NATIVE 0
350 #endif
351#endif // wxUSE_GENERIC_MDI_AS_NATIVE
352
353#if wxUSE_GENERIC_MDI_AS_NATIVE
1bf49fb9 354 #include "wx/generic/mdig.h"
b9f933ab 355#elif defined(__WXMSW__)
1bf49fb9 356 #include "wx/msw/mdi.h"
1be7a35c 357#elif defined(__WXGTK20__)
1bf49fb9 358 #include "wx/gtk/mdi.h"
1be7a35c
MR
359#elif defined(__WXGTK__)
360 #include "wx/gtk1/mdi.h"
34138703 361#elif defined(__WXMAC__)
ef0e9220 362 #include "wx/osx/mdi.h"
0201182b 363#elif defined(__WXCOCOA__)
9de2e75a 364 #include "wx/cocoa/mdi.h"
c801d85f
KB
365#endif
366
d2824cdb
VZ
367inline wxMDIClientWindow *wxMDIParentFrameBase::OnCreateClient()
368{
369 return new wxMDIClientWindow;
370}
371
efd17a1d 372#endif // wxUSE_MDI
1bf49fb9 373
d2824cdb 374#endif // _WX_MDI_H_BASE_