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