1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMDI base header
4 // Author: Julian Smart (original)
5 // Vadim Zeitlin (base MDI classes refactoring)
6 // Copyright: (c) 1998 Julian Smart
7 // (c) 2008 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MDI_H_BASE_
13 #define _WX_MDI_H_BASE_
22 // forward declarations
23 class WXDLLIMPEXP_FWD_CORE wxMDIParentFrame
;
24 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
25 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindowBase
;
26 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
28 // ----------------------------------------------------------------------------
29 // wxMDIParentFrameBase: base class for parent frame for MDI children
30 // ----------------------------------------------------------------------------
32 class WXDLLIMPEXP_CORE wxMDIParentFrameBase
: public wxFrame
35 wxMDIParentFrameBase()
37 m_clientWindow
= NULL
;
38 m_currentChild
= NULL
;
45 Derived classes should provide ctor and Create() with the following
48 bool Create(wxWindow *parent,
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);
58 virtual ~wxMDIParentFrameBase()
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
; }
74 // Get the client window
75 wxMDIClientWindowBase
*GetClientWindow() const { return m_clientWindow
; }
78 // MDI windows menu functions
79 // --------------------------
82 // return the pointer to the current window menu or NULL if we don't have
83 // because of wxFRAME_NO_WINDOW_MENU style
84 wxMenu
* GetWindowMenu() const { return m_windowMenu
; };
86 // use the given menu instead of the default window menu
88 // menu can be NULL to disable the window menu completely
89 virtual void SetWindowMenu(wxMenu
*menu
)
91 if ( menu
!= m_windowMenu
)
100 // standard MDI window management functions
101 // ----------------------------------------
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;
110 Derived classes must provide the following function:
115 // Create the client window class (don't Create() the window here, just
116 // return a new object of a wxMDIClientWindow-derived class)
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();
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
130 wxMDIClientWindowBase
*m_clientWindow
;
131 wxMDIChildFrame
*m_currentChild
;
134 // the current window menu or NULL if we are not using it
135 wxMenu
*m_windowMenu
;
136 #endif // wxUSE_MENUS
139 // ----------------------------------------------------------------------------
140 // wxMDIChildFrameBase: child frame managed by wxMDIParentFrame
141 // ----------------------------------------------------------------------------
143 class WXDLLIMPEXP_CORE wxMDIChildFrameBase
: public wxFrame
146 wxMDIChildFrameBase() { m_mdiParent
= NULL
; }
149 Derived classes should provide Create() with the following signature:
151 bool Create(wxMDIParentFrame *parent,
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);
159 And setting m_mdiParent to parent parameter.
162 // MDI children specific methods
163 virtual void Activate() = 0;
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
; }
170 // Synonym for GetMDIParent(), was used in some other ports
171 wxMDIParentFrame
*GetMDIParentFrame() const { return GetMDIParent(); }
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
177 virtual bool IsTopLevel() const { return false; }
180 wxMDIParentFrame
*m_mdiParent
;
183 // ----------------------------------------------------------------------------
184 // wxTDIChildFrame: child frame used by TDI implementations
185 // ----------------------------------------------------------------------------
187 class WXDLLIMPEXP_CORE wxTDIChildFrame
: public wxMDIChildFrameBase
190 // override wxFrame methods for this non top-level window
195 // TODO: MDI children should have their own status bars, why not?
196 virtual wxStatusBar
* CreateStatusBar(int WXUNUSED(number
) = 1,
197 long WXUNUSED(style
) = 1,
198 wxWindowID
WXUNUSED(id
) = 1,
199 const wxString
& WXUNUSED(name
)
203 virtual wxStatusBar
*GetStatusBar() const
205 virtual void SetStatusText(const wxString
&WXUNUSED(text
),
206 int WXUNUSED(number
)=0)
208 virtual void SetStatusWidths(int WXUNUSED(n
),
209 const int WXUNUSED(widths
)[])
211 #endif // wxUSE_STATUSBAR
216 // TODO: again, it should be possible to have tool bars
217 virtual wxToolBar
*CreateToolBar(long WXUNUSED(style
),
218 wxWindowID
WXUNUSED(id
),
219 const wxString
& WXUNUSED(name
))
221 virtual wxToolBar
*GetToolBar() const { return NULL
; }
222 #endif // wxUSE_TOOLBAR
225 virtual void SetIcons(const wxIconBundle
& WXUNUSED(icons
)) { }
227 // title is used as the tab label
228 virtual wxString
GetTitle() const { return m_title
; }
229 virtual void SetTitle(const wxString
& title
) = 0;
232 virtual void Maximize(bool WXUNUSED(maximize
) = true) { }
233 virtual bool IsMaximized() const { return true; }
234 virtual bool IsAlwaysMaximized() const { return true; }
235 virtual void Iconize(bool WXUNUSED(iconize
) = true) { }
236 virtual bool IsIconized() const { return false; }
237 virtual void Restore() { }
239 virtual bool ShowFullScreen(bool WXUNUSED(show
),
240 long WXUNUSED(style
)) { return false; }
241 virtual bool IsFullScreen() const { return false; }
244 // we need to override these functions to ensure that a child window is
245 // created even though we derive from wxFrame -- basically we make it
246 // behave as just a wxWindow by short-circuiting wxTLW changes to the base
249 virtual void AddChild(wxWindowBase
*child
) { wxWindow::AddChild(child
); }
251 virtual bool Destroy() { return wxWindow::Destroy(); }
253 // extra platform-specific hacks
255 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
= NULL
) const
257 return wxWindow::MSWGetStyle(flags
, exstyle
);
260 virtual WXHWND
MSWGetParent() const
262 return wxWindow::MSWGetParent();
265 WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
267 return wxWindow::MSWWindowProc(message
, wParam
, lParam
);
272 virtual void DoGetSize(int *width
, int *height
) const
274 wxWindow::DoGetSize(width
, height
);
277 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
279 wxWindow::DoSetSize(x
, y
, width
, height
, sizeFlags
);
282 virtual void DoGetClientSize(int *width
, int *height
) const
284 wxWindow::DoGetClientSize(width
, height
);
287 virtual void DoSetClientSize(int width
, int height
)
289 wxWindow::DoSetClientSize(width
, height
);
293 virtual void DoSetSizeHints(int WXUNUSED(minW
), int WXUNUSED(minH
),
294 int WXUNUSED(maxW
), int WXUNUSED(maxH
),
295 int WXUNUSED(incW
), int WXUNUSED(incH
)) { }
300 // ----------------------------------------------------------------------------
301 // wxMDIClientWindowBase: child of parent frame, parent of children frames
302 // ----------------------------------------------------------------------------
304 class WXDLLIMPEXP_CORE wxMDIClientWindowBase
: public wxWindow
308 The derived class must provide the default ctor only (CreateClient()
309 will be called later).
312 // Can be overridden in the derived classes but the base class version must
313 // be usually called first to really create the client window.
314 virtual bool CreateClient(wxMDIParentFrame
*parent
,
315 long style
= wxVSCROLL
| wxHSCROLL
) = 0;
318 // ----------------------------------------------------------------------------
319 // Include the port-specific implementation of the base classes defined above
320 // ----------------------------------------------------------------------------
322 // wxUSE_GENERIC_MDI_AS_NATIVE may be predefined to force the generic MDI
323 // implementation use even on the platforms which usually don't use it
325 // notice that generic MDI can still be used without this, but you would need
326 // to explicitly use wxGenericMDIXXX classes in your code (and currently also
327 // add src/generic/mdig.cpp to your build as it's not compiled in if generic
328 // MDI is not used by default -- but this may change later...)
329 #ifndef wxUSE_GENERIC_MDI_AS_NATIVE
330 // wxUniv always uses the generic MDI implementation and so do the ports
331 // without native version (although wxCocoa seems to have one -- but it's
332 // probably not functional?)
333 #if defined(__WXCOCOA__) || \
334 defined(__WXMOTIF__) || \
335 defined(__WXPM__) || \
336 defined(__WXUNIVERSAL__)
337 #define wxUSE_GENERIC_MDI_AS_NATIVE 1
339 #define wxUSE_GENERIC_MDI_AS_NATIVE 0
341 #endif // wxUSE_GENERIC_MDI_AS_NATIVE
343 #if wxUSE_GENERIC_MDI_AS_NATIVE
344 #include "wx/generic/mdig.h"
345 #elif defined(__WXMSW__)
346 #include "wx/msw/mdi.h"
347 #elif defined(__WXGTK20__)
348 #include "wx/gtk/mdi.h"
349 #elif defined(__WXGTK__)
350 #include "wx/gtk1/mdi.h"
351 #elif defined(__WXMAC__)
352 #include "wx/osx/mdi.h"
353 #elif defined(__WXCOCOA__)
354 #include "wx/cocoa/mdi.h"
357 inline wxMDIClientWindow
*wxMDIParentFrameBase::OnCreateClient()
359 return new wxMDIClientWindow
;
364 #endif // _WX_MDI_H_BASE_