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