]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/mdi.h
fix the incoherence pointed out by ifacecheck between wx docs, that documents usage...
[wxWidgets.git] / include / wx / msw / mdi.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
f6bcfd97 2// Name: wx/msw/mdi.h
2bda0e17
KB
3// Purpose: MDI (Multiple Document Interface) classes
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_MDI_H_
13#define _WX_MDI_H_
2bda0e17 14
2bda0e17
KB
15#include "wx/frame.h"
16
53a2db12 17extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[];
2bda0e17 18
b5dbe15d
VS
19class WXDLLIMPEXP_FWD_CORE wxMDIClientWindow;
20class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
2bda0e17 21
a23fd0e1
VZ
22// ---------------------------------------------------------------------------
23// wxMDIParentFrame
24// ---------------------------------------------------------------------------
25
53a2db12 26class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxFrame
2bda0e17 27{
a23fd0e1
VZ
28public:
29 wxMDIParentFrame();
30 wxMDIParentFrame(wxWindow *parent,
31 wxWindowID id,
32 const wxString& title,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize,
35 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
36 const wxString& name = wxFrameNameStr)
37 {
38 Create(parent, id, title, pos, size, style, name);
39 }
40
d3c7fc99 41 virtual ~wxMDIParentFrame();
a23fd0e1
VZ
42
43 bool Create(wxWindow *parent,
44 wxWindowID id,
45 const wxString& title,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
49 const wxString& name = wxFrameNameStr);
50
51 // accessors
52 // ---------
53
ecc63060 54 // Get the active MDI child window
42e69d6b 55 wxMDIChildFrame *GetActiveChild() const;
2bda0e17 56
a23fd0e1
VZ
57 // Get the client window
58 wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; }
2bda0e17 59
a23fd0e1
VZ
60 // Create the client window class (don't Create the window,
61 // just return a new class)
ecc63060 62 virtual wxMDIClientWindow *OnCreateClient();
2bda0e17 63
ecc63060
VZ
64 // MDI windows menu functions
65 // --------------------------
66
67 // return the pointer to the current window menu or NULL if we don't have
68 // because of wxFRAME_NO_WINDOW_MENU style
69 wxMenu *GetWindowMenu() const { return m_windowMenu; }
70
71 // use the given menu instead of the default window menu
72 //
73 // menu can be NULL to disable the window menu completely
df61c009 74 void SetWindowMenu(wxMenu* menu) ;
ecc63060 75
6aca4628 76 virtual void DoMenuUpdates(wxMenu* menu = NULL);
ef359b43 77
a23fd0e1
VZ
78 // MDI operations
79 // --------------
80 virtual void Cascade();
0d97c090 81 virtual void Tile(wxOrientation orient = wxHORIZONTAL);
a23fd0e1
VZ
82 virtual void ArrangeIcons();
83 virtual void ActivateNext();
84 virtual void ActivatePrevious();
2bda0e17 85
ecc63060
VZ
86
87 // implementation only from now on
88
89 // MDI helpers
90 // -----------
91
92 // called by wxMDIChildFrame after it was successfully created
93 virtual void AddMDIChild(wxMDIChildFrame *child);
94
95 // called by wxMDIChildFrame just before it is destroyed
96 virtual void RemoveMDIChild(wxMDIChildFrame *child);
97
a23fd0e1
VZ
98 // handlers
99 // --------
2bda0e17 100
a23fd0e1
VZ
101 // Responds to colour changes
102 void OnSysColourChanged(wxSysColourChangedEvent& event);
2bda0e17 103
a23fd0e1 104 void OnSize(wxSizeEvent& event);
6bbe97b7 105 void OnIconized(wxIconizeEvent& event);
2bda0e17 106
42e69d6b
VZ
107 bool HandleActivate(int state, bool minimized, WXHWND activate);
108 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
2bda0e17 109
a23fd0e1 110 // override window proc for MDI-specific message processing
c140b7e7 111 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
2bda0e17 112
c140b7e7 113 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
a23fd0e1 114 virtual bool MSWTranslateMessage(WXMSG* msg);
cc2b7472 115
10816efb
VZ
116 // override wxFrameBase function to also look in the active child menu bar
117 virtual const wxMenuItem *FindItemInMenuBar(int menuId) const;
118
a23fd0e1 119protected:
1e6feb95 120#if wxUSE_MENUS_NATIVE
42e69d6b 121 virtual void InternalSetMenuBar();
1e6feb95 122#endif // wxUSE_MENUS_NATIVE
42e69d6b 123
82c9f85c
VZ
124 virtual WXHICON GetDefaultIcon() const;
125
6bbe97b7
VZ
126 // set the size of the MDI client window to match the frame size
127 void UpdateClientSize();
128
129
2bda0e17
KB
130 wxMDIClientWindow * m_clientWindow;
131 wxMDIChildFrame * m_currentChild;
ecc63060
VZ
132
133 // the current window menu or NULL if we are not using it
134 wxMenu *m_windowMenu;
a23fd0e1 135
598ddd96 136 // true if MDI Frame is intercepting commands, not child
42e69d6b 137 bool m_parentFrameActive;
a23fd0e1
VZ
138
139private:
ecc63060
VZ
140 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
141 void AddWindowMenu();
142 void RemoveWindowMenu();
143
144 // return the number of child frames we currently have (maybe 0)
145 int GetChildFramesCount() const;
146
b5dbe15d 147 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
a23fd0e1
VZ
148
149 DECLARE_EVENT_TABLE()
82c9f85c 150 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
22f3361e 151 DECLARE_NO_COPY_CLASS(wxMDIParentFrame)
2bda0e17
KB
152};
153
a23fd0e1
VZ
154// ---------------------------------------------------------------------------
155// wxMDIChildFrame
156// ---------------------------------------------------------------------------
2bda0e17 157
53a2db12 158class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxFrame
2bda0e17 159{
a23fd0e1 160public:
f6bcfd97 161 wxMDIChildFrame() { Init(); }
a23fd0e1
VZ
162 wxMDIChildFrame(wxMDIParentFrame *parent,
163 wxWindowID id,
164 const wxString& title,
165 const wxPoint& pos = wxDefaultPosition,
166 const wxSize& size = wxDefaultSize,
167 long style = wxDEFAULT_FRAME_STYLE,
168 const wxString& name = wxFrameNameStr)
169 {
f6bcfd97
BP
170 Init();
171
a23fd0e1
VZ
172 Create(parent, id, title, pos, size, style, name);
173 }
174
d3c7fc99 175 virtual ~wxMDIChildFrame();
a23fd0e1
VZ
176
177 bool Create(wxMDIParentFrame *parent,
178 wxWindowID id,
179 const wxString& title,
180 const wxPoint& pos = wxDefaultPosition,
181 const wxSize& size = wxDefaultSize,
182 long style = wxDEFAULT_FRAME_STYLE,
183 const wxString& name = wxFrameNameStr);
184
598ddd96 185 virtual bool IsTopLevel() const { return false; }
225fe9d6 186
a23fd0e1 187 // MDI operations
598ddd96 188 virtual void Maximize(bool maximize = true);
a23fd0e1
VZ
189 virtual void Restore();
190 virtual void Activate();
191
f6bcfd97
BP
192 // Implementation only from now on
193 // -------------------------------
a23fd0e1 194
55ae1551
VZ
195 wxMDIParentFrame* GetMDIParent() const
196 {
197 return wxStaticCast(wxFrame::GetParent(), wxMDIParentFrame);
198 }
199
f6bcfd97 200 // Handlers
42e69d6b 201 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
42e69d6b
VZ
202 bool HandleWindowPosChanging(void *lpPos);
203 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
3ebcfb76 204 bool HandleGetMinMaxInfo(void *mmInfo);
42e69d6b 205
c140b7e7
JS
206 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
207 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
42e69d6b
VZ
208 virtual bool MSWTranslateMessage(WXMSG *msg);
209
210 virtual void MSWDestroyWindow();
2bda0e17 211
2bda0e17 212 bool ResetWindowStyle(void *vrect);
cc2b7472 213
f6bcfd97 214 void OnIdle(wxIdleEvent& event);
ef359b43 215
2596e9fb 216 virtual bool Show(bool show = true);
f6bcfd97 217
cc2b7472 218protected:
3e85709e 219 virtual void DoGetScreenPosition(int *x, int *y) const;
42e69d6b 220 virtual void DoGetPosition(int *x, int *y) const;
a23fd0e1 221 virtual void DoSetClientSize(int width, int height);
42e69d6b 222 virtual void InternalSetMenuBar();
598ddd96 223 virtual bool IsMDIChild() const { return true; }
6f02a879 224 virtual void DetachMenuBar();
225fe9d6 225
82c9f85c
VZ
226 virtual WXHICON GetDefaultIcon() const;
227
f6bcfd97
BP
228 // common part of all ctors
229 void Init();
230
231private:
2596e9fb 232 bool m_needsInitialShow; // Show must be called in idle time after Creation
f6bcfd97
BP
233 bool m_needsResize; // flag which tells us to artificially resize the frame
234
235 DECLARE_EVENT_TABLE()
fc7a2a60 236 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
2bda0e17
KB
237};
238
a23fd0e1
VZ
239// ---------------------------------------------------------------------------
240// wxMDIClientWindow
241// ---------------------------------------------------------------------------
2bda0e17 242
53a2db12 243class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxWindow
a23fd0e1 244{
a23fd0e1 245public:
42e69d6b 246 wxMDIClientWindow() { Init(); }
a23fd0e1
VZ
247 wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
248 {
42e69d6b
VZ
249 Init();
250
a23fd0e1
VZ
251 CreateClient(parent, style);
252 }
2bda0e17 253
a23fd0e1
VZ
254 // Note: this is virtual, to allow overridden behaviour.
255 virtual bool CreateClient(wxMDIParentFrame *parent,
256 long style = wxVSCROLL | wxHSCROLL);
2bda0e17 257
a23fd0e1
VZ
258 // Explicitly call default scroll behaviour
259 void OnScroll(wxScrollEvent& event);
2bda0e17 260
6f02a879 261protected:
ec06b234
JS
262 virtual void DoSetSize(int x, int y,
263 int width, int height,
264 int sizeFlags = wxSIZE_AUTO);
6f02a879 265
42e69d6b
VZ
266 void Init() { m_scrollX = m_scrollY = 0; }
267
a23fd0e1
VZ
268 int m_scrollX, m_scrollY;
269
270private:
271 DECLARE_EVENT_TABLE()
fc7a2a60 272 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
2bda0e17
KB
273};
274
275#endif
bbcdf8bc 276 // _WX_MDI_H_