]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/mdi.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[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
d2824cdb 5// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
2bda0e17 6// Created: 01/02/97
d2824cdb
VZ
7// Copyright: (c) 1997 Julian Smart
8// (c) 2008 Vadim Zeitlin
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
d2824cdb
VZ
12#ifndef _WX_MSW_MDI_H_
13#define _WX_MSW_MDI_H_
2bda0e17 14
2bda0e17
KB
15#include "wx/frame.h"
16
1483e5db
VZ
17class WXDLLIMPEXP_FWD_CORE wxAcceleratorTable;
18
a23fd0e1
VZ
19// ---------------------------------------------------------------------------
20// wxMDIParentFrame
21// ---------------------------------------------------------------------------
22
d2824cdb 23class WXDLLIMPEXP_CORE wxMDIParentFrame : public wxMDIParentFrameBase
2bda0e17 24{
a23fd0e1 25public:
0fd2ecfe 26 wxMDIParentFrame() { Init(); }
a23fd0e1
VZ
27 wxMDIParentFrame(wxWindow *parent,
28 wxWindowID id,
29 const wxString& title,
30 const wxPoint& pos = wxDefaultPosition,
31 const wxSize& size = wxDefaultSize,
32 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
33 const wxString& name = wxFrameNameStr)
34 {
0fd2ecfe
VZ
35 Init();
36
a23fd0e1
VZ
37 Create(parent, id, title, pos, size, style, name);
38 }
39
d3c7fc99 40 virtual ~wxMDIParentFrame();
a23fd0e1
VZ
41
42 bool Create(wxWindow *parent,
43 wxWindowID id,
44 const wxString& title,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
48 const wxString& name = wxFrameNameStr);
49
d2824cdb
VZ
50 // override/implement base class [pure] virtual methods
51 // ----------------------------------------------------
2bda0e17 52
d2824cdb 53 static bool IsTDI() { return false; }
2bda0e17 54
d2824cdb
VZ
55 // we don't store the active child in m_currentChild so override this
56 // function to find it dynamically
57 virtual wxMDIChildFrame *GetActiveChild() const;
ef359b43 58
a23fd0e1 59 virtual void Cascade();
0d97c090 60 virtual void Tile(wxOrientation orient = wxHORIZONTAL);
a23fd0e1
VZ
61 virtual void ArrangeIcons();
62 virtual void ActivateNext();
63 virtual void ActivatePrevious();
2bda0e17 64
d2824cdb
VZ
65#if wxUSE_MENUS
66 virtual void SetWindowMenu(wxMenu* menu);
67
68 virtual void DoMenuUpdates(wxMenu* menu = NULL);
51181d29
VZ
69
70 // return the active child menu, if any
71 virtual WXHMENU MSWGetActiveMenu() const;
d2824cdb 72#endif // wxUSE_MENUS
ecc63060 73
51181d29 74
ecc63060
VZ
75 // implementation only from now on
76
77 // MDI helpers
78 // -----------
79
7e6d6840 80#if wxUSE_MENUS
ecc63060
VZ
81 // called by wxMDIChildFrame after it was successfully created
82 virtual void AddMDIChild(wxMDIChildFrame *child);
83
84 // called by wxMDIChildFrame just before it is destroyed
85 virtual void RemoveMDIChild(wxMDIChildFrame *child);
7e6d6840 86#endif // wxUSE_MENUS
ecc63060 87
a23fd0e1
VZ
88 // handlers
89 // --------
2bda0e17 90
a23fd0e1
VZ
91 // Responds to colour changes
92 void OnSysColourChanged(wxSysColourChangedEvent& event);
2bda0e17 93
a23fd0e1 94 void OnSize(wxSizeEvent& event);
6bbe97b7 95 void OnIconized(wxIconizeEvent& event);
2bda0e17 96
42e69d6b 97 bool HandleActivate(int state, bool minimized, WXHWND activate);
2bda0e17 98
a23fd0e1 99 // override window proc for MDI-specific message processing
c140b7e7 100 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
2bda0e17 101
c140b7e7 102 virtual WXLRESULT MSWDefWindowProc(WXUINT, WXWPARAM, WXLPARAM);
a23fd0e1 103 virtual bool MSWTranslateMessage(WXMSG* msg);
cc2b7472 104
51181d29 105#if wxUSE_MENUS
10816efb 106 // override wxFrameBase function to also look in the active child menu bar
79f9ea05
VZ
107 // and the "Window" menu
108 virtual wxMenuItem *FindItemInMenuBar(int menuId) const;
51181d29 109#endif // wxUSE_MENUS
10816efb 110
a23fd0e1 111protected:
1e6feb95 112#if wxUSE_MENUS_NATIVE
42e69d6b 113 virtual void InternalSetMenuBar();
1e6feb95 114#endif // wxUSE_MENUS_NATIVE
42e69d6b 115
82c9f85c
VZ
116 virtual WXHICON GetDefaultIcon() const;
117
6bbe97b7
VZ
118 // set the size of the MDI client window to match the frame size
119 void UpdateClientSize();
120
a23fd0e1 121private:
0fd2ecfe
VZ
122 // common part of all ctors
123 void Init();
124
51181d29 125#if wxUSE_MENUS
1483e5db
VZ
126 // "Window" menu commands event handlers
127 void OnMDICommand(wxCommandEvent& event);
128 void OnMDIChild(wxCommandEvent& event);
129
130
ecc63060
VZ
131 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
132 void AddWindowMenu();
133 void RemoveWindowMenu();
134
51181d29
VZ
135 // update the window menu (if we have it) to enable or disable the commands
136 // which only make sense when we have more than one child
137 void UpdateWindowMenu(bool enable);
1483e5db
VZ
138
139#if wxUSE_ACCEL
140 wxAcceleratorTable *m_accelWindowMenu;
141#endif // wxUSE_ACCEL
51181d29
VZ
142#endif // wxUSE_MENUS
143
ecc63060
VZ
144 // return the number of child frames we currently have (maybe 0)
145 int GetChildFramesCount() const;
146
51181d29 147
b5dbe15d 148 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
a23fd0e1
VZ
149
150 DECLARE_EVENT_TABLE()
82c9f85c 151 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
c0c133e1 152 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame);
2bda0e17
KB
153};
154
a23fd0e1
VZ
155// ---------------------------------------------------------------------------
156// wxMDIChildFrame
157// ---------------------------------------------------------------------------
2bda0e17 158
d2824cdb 159class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
2bda0e17 160{
a23fd0e1 161public:
f6bcfd97 162 wxMDIChildFrame() { Init(); }
a23fd0e1
VZ
163 wxMDIChildFrame(wxMDIParentFrame *parent,
164 wxWindowID id,
165 const wxString& title,
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize,
168 long style = wxDEFAULT_FRAME_STYLE,
169 const wxString& name = wxFrameNameStr)
170 {
f6bcfd97
BP
171 Init();
172
a23fd0e1
VZ
173 Create(parent, id, title, pos, size, style, name);
174 }
175
a23fd0e1
VZ
176 bool Create(wxMDIParentFrame *parent,
177 wxWindowID id,
178 const wxString& title,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = wxDEFAULT_FRAME_STYLE,
182 const wxString& name = wxFrameNameStr);
183
d2824cdb 184 virtual ~wxMDIChildFrame();
225fe9d6 185
d2824cdb
VZ
186 // implement MDI operations
187 virtual void Activate();
188
189 // Override some frame operations too
598ddd96 190 virtual void Maximize(bool maximize = true);
a23fd0e1 191 virtual void Restore();
d2824cdb
VZ
192
193 virtual bool Show(bool show = true);
a23fd0e1 194
f6bcfd97
BP
195 // Implementation only from now on
196 // -------------------------------
a23fd0e1 197
f6bcfd97 198 // Handlers
42e69d6b 199 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
42e69d6b 200 bool HandleWindowPosChanging(void *lpPos);
3ebcfb76 201 bool HandleGetMinMaxInfo(void *mmInfo);
42e69d6b 202
c140b7e7
JS
203 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
204 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
42e69d6b
VZ
205 virtual bool MSWTranslateMessage(WXMSG *msg);
206
207 virtual void MSWDestroyWindow();
2bda0e17 208
2bda0e17 209 bool ResetWindowStyle(void *vrect);
cc2b7472 210
f6bcfd97 211 void OnIdle(wxIdleEvent& event);
ef359b43 212
cc2b7472 213protected:
3e85709e 214 virtual void DoGetScreenPosition(int *x, int *y) const;
42e69d6b 215 virtual void DoGetPosition(int *x, int *y) const;
0598625c 216 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
a23fd0e1 217 virtual void DoSetClientSize(int width, int height);
42e69d6b 218 virtual void InternalSetMenuBar();
598ddd96 219 virtual bool IsMDIChild() const { return true; }
6f02a879 220 virtual void DetachMenuBar();
225fe9d6 221
82c9f85c
VZ
222 virtual WXHICON GetDefaultIcon() const;
223
f6bcfd97
BP
224 // common part of all ctors
225 void Init();
226
227private:
2596e9fb 228 bool m_needsInitialShow; // Show must be called in idle time after Creation
f6bcfd97
BP
229 bool m_needsResize; // flag which tells us to artificially resize the frame
230
231 DECLARE_EVENT_TABLE()
fc7a2a60 232 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
2bda0e17
KB
233};
234
a23fd0e1
VZ
235// ---------------------------------------------------------------------------
236// wxMDIClientWindow
237// ---------------------------------------------------------------------------
2bda0e17 238
d2824cdb 239class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
a23fd0e1 240{
a23fd0e1 241public:
42e69d6b 242 wxMDIClientWindow() { Init(); }
2bda0e17 243
a23fd0e1
VZ
244 // Note: this is virtual, to allow overridden behaviour.
245 virtual bool CreateClient(wxMDIParentFrame *parent,
246 long style = wxVSCROLL | wxHSCROLL);
2bda0e17 247
a23fd0e1
VZ
248 // Explicitly call default scroll behaviour
249 void OnScroll(wxScrollEvent& event);
2bda0e17 250
6f02a879 251protected:
ec06b234
JS
252 virtual void DoSetSize(int x, int y,
253 int width, int height,
254 int sizeFlags = wxSIZE_AUTO);
6f02a879 255
42e69d6b
VZ
256 void Init() { m_scrollX = m_scrollY = 0; }
257
a23fd0e1
VZ
258 int m_scrollX, m_scrollY;
259
260private:
261 DECLARE_EVENT_TABLE()
fc7a2a60 262 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
2bda0e17
KB
263};
264
d2824cdb 265#endif // _WX_MSW_MDI_H_