1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/motif/mdi.h
3 // Purpose: MDI (Multiple Document Interface) classes.
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
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.
24 #include "wx/notebook.h"
26 class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow
;
27 class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
29 class WXDLLEXPORT wxMDIParentFrame
: public wxFrame
31 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame
)
33 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame
;
37 inline wxMDIParentFrame(wxWindow
*parent
,
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
)
45 Create(parent
, id
, title
, pos
, size
, style
, name
);
48 virtual ~wxMDIParentFrame();
50 bool Create(wxWindow
*parent
,
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
);
58 void OnSize(wxSizeEvent
& event
);
59 void OnActivate(wxActivateEvent
& event
);
60 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
61 void OnMenuHighlight(wxMenuEvent
& event
);
63 void SetMenuBar(wxMenuBar
*menu_bar
);
65 // Get the active MDI child window
66 wxMDIChildFrame
*GetActiveChild() const ;
68 // Get the client window
69 wxMDIClientWindow
*GetClientWindow() const { return m_clientWindow
; };
71 // Create the client window class (don't Create the window,
72 // just return a new class)
73 virtual wxMDIClientWindow
*OnCreateClient() ;
76 virtual void Cascade();
77 virtual void Tile(wxOrientation
WXUNUSED(orient
) = wxHORIZONTAL
);
78 virtual void ArrangeIcons();
79 virtual void ActivateNext();
80 virtual void ActivatePrevious();
84 // Set the active child
85 inline void SetActiveChild(wxMDIChildFrame
* child
) { m_activeChild
= child
; }
87 // Set the child's menubar into the parent frame
88 void SetChildMenuBar(wxMDIChildFrame
* frame
);
90 inline wxMenuBar
* GetActiveMenuBar() const { return m_activeMenuBar
; }
92 // Redirect events to active child first
93 virtual bool ProcessEvent(wxEvent
& event
);
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
);
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;
108 wxMDIClientWindow
* m_clientWindow
;
109 wxMDIChildFrame
* m_activeChild
;
110 wxMenuBar
* m_activeMenuBar
;
112 DECLARE_EVENT_TABLE()
115 class WXDLLEXPORT wxMDIChildFrame
: public wxFrame
117 DECLARE_DYNAMIC_CLASS(wxMDIChildFrame
)
121 wxMDIChildFrame(wxMDIParentFrame
*parent
,
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
)
129 Create(parent
, id
, title
, pos
, size
, style
, name
);
132 virtual ~wxMDIChildFrame();
134 bool Create(wxMDIParentFrame
*parent
,
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
);
143 void SetMenuBar(wxMenuBar
*menu_bar
);
144 void SetTitle(const wxString
& title
);
147 virtual void SetIcon(const wxIcon
& icon
);
148 virtual void SetIcons(const wxIconBundle
& icons
);
150 // Override wxFrame operations
157 virtual void Maximize();
158 virtual void Maximize(bool WXUNUSED(maximize
)) { };
159 inline void Minimize() { Iconize(true); };
160 virtual void Iconize(bool iconize
);
161 virtual void Restore();
162 virtual void Activate();
163 virtual bool IsIconized() const ;
165 virtual bool IsTopLevel() const { return false; }
167 // Is the frame maximized? Returns true for
168 // wxMDIChildFrame due to the tabbed implementation.
169 virtual bool IsMaximized(void) const ;
171 bool Show(bool show
);
173 WXWidget
GetMainWidget() const { return m_mainWidget
; };
174 WXWidget
GetTopWidget() const { return m_mainWidget
; };
175 WXWidget
GetClientWidget() const { return m_mainWidget
; };
178 virtual void OnRaise();
179 virtual void OnLower();
182 void SetMDIParentFrame(wxMDIParentFrame
* parentFrame
) { m_mdiParentFrame
= parentFrame
; }
183 wxMDIParentFrame
* GetMDIParentFrame() const { return m_mdiParentFrame
; }
186 wxMDIParentFrame
* m_mdiParentFrame
;
188 virtual void DoSetSize(int x
, int y
,
189 int width
, int height
,
190 int sizeFlags
= wxSIZE_AUTO
);
191 virtual void DoSetClientSize(int width
, int height
);
193 void DoGetClientSize(int *width
, int *height
) const;
194 void DoGetSize(int *width
, int *height
) const;
195 void DoGetPosition(int *x
, int *y
) const ;
196 void DoSetSizeHints(int minW
, int minH
,
201 /* The client window is a child of the parent MDI frame, and itself
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'...
208 class WXDLLEXPORT wxMDIClientWindow
: public wxNotebook
210 DECLARE_DYNAMIC_CLASS(wxMDIClientWindow
)
213 wxMDIClientWindow() ;
214 wxMDIClientWindow(wxMDIParentFrame
*parent
, long style
= 0)
216 CreateClient(parent
, style
);
219 virtual ~wxMDIClientWindow();
221 // Note: this is virtual, to allow overridden behaviour.
222 virtual bool CreateClient(wxMDIParentFrame
*parent
, long style
= wxVSCROLL
| wxHSCROLL
);
224 // Explicitly call default scroll behaviour
225 void OnScroll(wxScrollEvent
& event
);
228 void OnPageChanged(wxNotebookEvent
& event
);
230 int FindPage(const wxNotebookPage
* page
);
233 virtual void DoSetSize(int x
, int y
,
234 int width
, int height
,
235 int sizeFlags
= wxSIZE_AUTO
);
236 virtual void DoSetClientSize(int width
, int height
);
238 void DoGetClientSize(int *width
, int *height
) const;
239 void DoGetSize(int *width
, int *height
) const ;
240 void DoGetPosition(int *x
, int *y
) const ;
243 DECLARE_EVENT_TABLE()