]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/mdi.h
Implement monitoring of file descriptors in wxMotif event loop.
[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:
1e6feb95 113#if wxUSE_MENUS_NATIVE
42e69d6b 114 virtual void InternalSetMenuBar();
1e6feb95 115#endif // wxUSE_MENUS_NATIVE
42e69d6b 116
82c9f85c
VZ
117 virtual WXHICON GetDefaultIcon() const;
118
6bbe97b7
VZ
119 // set the size of the MDI client window to match the frame size
120 void UpdateClientSize();
121
a23fd0e1 122private:
0fd2ecfe
VZ
123 // common part of all ctors
124 void Init();
125
51181d29 126#if wxUSE_MENUS
1483e5db
VZ
127 // "Window" menu commands event handlers
128 void OnMDICommand(wxCommandEvent& event);
129 void OnMDIChild(wxCommandEvent& event);
130
131
ecc63060
VZ
132 // add/remove window menu if we have it (i.e. m_windowMenu != NULL)
133 void AddWindowMenu();
134 void RemoveWindowMenu();
135
51181d29
VZ
136 // update the window menu (if we have it) to enable or disable the commands
137 // which only make sense when we have more than one child
138 void UpdateWindowMenu(bool enable);
1483e5db
VZ
139
140#if wxUSE_ACCEL
141 wxAcceleratorTable *m_accelWindowMenu;
142#endif // wxUSE_ACCEL
51181d29
VZ
143#endif // wxUSE_MENUS
144
ecc63060
VZ
145 // return the number of child frames we currently have (maybe 0)
146 int GetChildFramesCount() const;
147
51181d29 148
b5dbe15d 149 friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
a23fd0e1
VZ
150
151 DECLARE_EVENT_TABLE()
82c9f85c 152 DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
c0c133e1 153 wxDECLARE_NO_COPY_CLASS(wxMDIParentFrame);
2bda0e17
KB
154};
155
a23fd0e1
VZ
156// ---------------------------------------------------------------------------
157// wxMDIChildFrame
158// ---------------------------------------------------------------------------
2bda0e17 159
d2824cdb 160class WXDLLIMPEXP_CORE wxMDIChildFrame : public wxMDIChildFrameBase
2bda0e17 161{
a23fd0e1 162public:
f6bcfd97 163 wxMDIChildFrame() { Init(); }
a23fd0e1
VZ
164 wxMDIChildFrame(wxMDIParentFrame *parent,
165 wxWindowID id,
166 const wxString& title,
167 const wxPoint& pos = wxDefaultPosition,
168 const wxSize& size = wxDefaultSize,
169 long style = wxDEFAULT_FRAME_STYLE,
170 const wxString& name = wxFrameNameStr)
171 {
f6bcfd97
BP
172 Init();
173
a23fd0e1
VZ
174 Create(parent, id, title, pos, size, style, name);
175 }
176
a23fd0e1
VZ
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
d2824cdb 185 virtual ~wxMDIChildFrame();
225fe9d6 186
d2824cdb
VZ
187 // implement MDI operations
188 virtual void Activate();
189
190 // Override some frame operations too
598ddd96 191 virtual void Maximize(bool maximize = true);
a23fd0e1 192 virtual void Restore();
d2824cdb
VZ
193
194 virtual bool Show(bool show = true);
a23fd0e1 195
f6bcfd97
BP
196 // Implementation only from now on
197 // -------------------------------
a23fd0e1 198
f6bcfd97 199 // Handlers
42e69d6b 200 bool HandleMDIActivate(long bActivate, WXHWND, WXHWND);
42e69d6b 201 bool HandleWindowPosChanging(void *lpPos);
3ebcfb76 202 bool HandleGetMinMaxInfo(void *mmInfo);
42e69d6b 203
c140b7e7
JS
204 virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
205 virtual WXLRESULT MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
42e69d6b
VZ
206 virtual bool MSWTranslateMessage(WXMSG *msg);
207
208 virtual void MSWDestroyWindow();
2bda0e17 209
2bda0e17 210 bool ResetWindowStyle(void *vrect);
cc2b7472 211
f6bcfd97 212 void OnIdle(wxIdleEvent& event);
ef359b43 213
cc2b7472 214protected:
3e85709e 215 virtual void DoGetScreenPosition(int *x, int *y) const;
42e69d6b 216 virtual void DoGetPosition(int *x, int *y) const;
0598625c 217 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags);
a23fd0e1 218 virtual void DoSetClientSize(int width, int height);
42e69d6b 219 virtual void InternalSetMenuBar();
598ddd96 220 virtual bool IsMDIChild() const { return true; }
6f02a879 221 virtual void DetachMenuBar();
225fe9d6 222
82c9f85c
VZ
223 virtual WXHICON GetDefaultIcon() const;
224
f6bcfd97
BP
225 // common part of all ctors
226 void Init();
227
228private:
2596e9fb 229 bool m_needsInitialShow; // Show must be called in idle time after Creation
f6bcfd97
BP
230 bool m_needsResize; // flag which tells us to artificially resize the frame
231
232 DECLARE_EVENT_TABLE()
fc7a2a60 233 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIChildFrame)
2bda0e17
KB
234};
235
a23fd0e1
VZ
236// ---------------------------------------------------------------------------
237// wxMDIClientWindow
238// ---------------------------------------------------------------------------
2bda0e17 239
d2824cdb 240class WXDLLIMPEXP_CORE wxMDIClientWindow : public wxMDIClientWindowBase
a23fd0e1 241{
a23fd0e1 242public:
42e69d6b 243 wxMDIClientWindow() { Init(); }
2bda0e17 244
a23fd0e1
VZ
245 // Note: this is virtual, to allow overridden behaviour.
246 virtual bool CreateClient(wxMDIParentFrame *parent,
247 long style = wxVSCROLL | wxHSCROLL);
2bda0e17 248
a23fd0e1
VZ
249 // Explicitly call default scroll behaviour
250 void OnScroll(wxScrollEvent& event);
2bda0e17 251
6f02a879 252protected:
ec06b234
JS
253 virtual void DoSetSize(int x, int y,
254 int width, int height,
255 int sizeFlags = wxSIZE_AUTO);
6f02a879 256
42e69d6b
VZ
257 void Init() { m_scrollX = m_scrollY = 0; }
258
a23fd0e1
VZ
259 int m_scrollX, m_scrollY;
260
261private:
262 DECLARE_EVENT_TABLE()
fc7a2a60 263 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMDIClientWindow)
2bda0e17
KB
264};
265
d2824cdb 266#endif // _WX_MSW_MDI_H_