]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/mdig.h
split wxEVT_GRID_CELL_CHANGE into wxEVT_GRID_CELL_CHANGING/ED pair for consistency...
[wxWidgets.git] / include / wx / generic / mdig.h
CommitLineData
6c70a9b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/mdig.h
3// Purpose: Generic MDI (Multiple Document Interface) classes
4// Author: Hans Van Leemputten
d2824cdb 5// Modified by: 2008-10-31 Vadim Zeitlin: derive from the base classes
6c70a9b5
JS
6// Created: 29/07/2002
7// RCS-ID: $Id$
d2824cdb
VZ
8// Copyright: (c) 2002 Hans Van Leemputten
9// (c) 2008 Vadim Zeitlin
65571936 10// Licence: wxWindows licence
6c70a9b5
JS
11/////////////////////////////////////////////////////////////////////////////
12
d2824cdb
VZ
13#ifndef _WX_GENERIC_MDIG_H_
14#define _WX_GENERIC_MDIG_H_
6c70a9b5 15
6c70a9b5
JS
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
6c70a9b5 20#include "wx/panel.h"
6c70a9b5 21
d2824cdb
VZ
22class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;
23class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent;
75aea0d8
VZ
24class WXDLLIMPEXP_FWD_CORE wxIcon;
25class WXDLLIMPEXP_FWD_CORE wxIconBundle;
d2824cdb 26class WXDLLIMPEXP_FWD_CORE wxNotebook;
75aea0d8 27
d2824cdb
VZ
28#if wxUSE_GENERIC_MDI_AS_NATIVE
29 #define wxGenericMDIParentFrame wxMDIParentFrame
30 #define wxGenericMDIChildFrame wxMDIChildFrame
31 #define wxGenericMDIClientWindow wxMDIClientWindow
32#else // !wxUSE_GENERIC_MDI_AS_NATIVE
33 class WXDLLIMPEXP_FWD_CORE wxGenericMDIParentFrame;
34 class WXDLLIMPEXP_FWD_CORE wxGenericMDIChildFrame;
35 class WXDLLIMPEXP_FWD_CORE wxGenericMDIClientWindow;
36#endif // wxUSE_GENERIC_MDI_AS_NATIVE/!wxUSE_GENERIC_MDI_AS_NATIVE
6c70a9b5 37
d2824cdb 38// ----------------------------------------------------------------------------
6c70a9b5 39// wxGenericMDIParentFrame
d2824cdb 40// ----------------------------------------------------------------------------
6c70a9b5 41
d2824cdb 42class WXDLLIMPEXP_CORE wxGenericMDIParentFrame : public wxMDIParentFrameBase
6c70a9b5
JS
43{
44public:
d2824cdb 45 wxGenericMDIParentFrame() { Init(); }
6c70a9b5 46 wxGenericMDIParentFrame(wxWindow *parent,
aa6f64c7 47 wxWindowID winid,
6c70a9b5
JS
48 const wxString& title,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
d2824cdb
VZ
52 const wxString& name = wxFrameNameStr)
53 {
54 Init();
55
56 Create(parent, winid, title, pos, size, style, name);
57 }
58
59 bool Create(wxWindow *parent,
60 wxWindowID winid,
61 const wxString& title,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
65 const wxString& name = wxFrameNameStr);
6c70a9b5 66
d3c7fc99 67 virtual ~wxGenericMDIParentFrame();
d2824cdb
VZ
68
69 // implement base class pure virtuals
70 static bool IsTDI() { return true; }
71
72 virtual void ActivateNext() { AdvanceActive(true); }
73 virtual void ActivatePrevious() { AdvanceActive(false); }
6c70a9b5
JS
74
75#if wxUSE_MENUS
d2824cdb 76 virtual void SetWindowMenu(wxMenu* pMenu);
6c70a9b5
JS
77
78 virtual void SetMenuBar(wxMenuBar *pMenuBar);
79#endif // wxUSE_MENUS
80
6c70a9b5
JS
81 virtual bool ProcessEvent(wxEvent& event);
82
d2824cdb 83 virtual wxGenericMDIClientWindow *OnCreateGenericClient();
6c70a9b5 84
6c70a9b5 85
d2824cdb
VZ
86 // implementation only from now on
87 void WXSetChildMenuBar(wxGenericMDIChildFrame *child);
88 void WXUpdateChildTitle(wxGenericMDIChildFrame *child);
89 void WXActivateChild(wxGenericMDIChildFrame *child);
90 void WXRemoveChild(wxGenericMDIChildFrame *child);
91 bool WXIsActiveChild(wxGenericMDIChildFrame *child) const;
92 bool WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const;
93
94 // return the book control used by the client window to manage the pages
95 wxBookCtrlBase *GetBookCtrl() const;
6c70a9b5
JS
96
97protected:
6c70a9b5 98#if wxUSE_MENUS
d2824cdb 99 wxMenuBar *m_pMyMenuBar;
6c70a9b5
JS
100#endif // wxUSE_MENUS
101
d2824cdb
VZ
102 // advance the activation forward or backwards
103 void AdvanceActive(bool forward);
104
105private:
6c70a9b5
JS
106 void Init();
107
108#if wxUSE_MENUS
109 void RemoveWindowMenu(wxMenuBar *pMenuBar);
110 void AddWindowMenu(wxMenuBar *pMenuBar);
111
d2824cdb 112 void OnWindowMenu(wxCommandEvent& event);
6c70a9b5
JS
113#endif // wxUSE_MENUS
114
d2824cdb
VZ
115 void OnClose(wxCloseEvent& event);
116
117 // return the client window, may be NULL if we hadn't been created yet
118 wxGenericMDIClientWindow *GetGenericClientWindow() const;
119
120 // close all children, return false if any of them vetoed it
121 bool CloseAll();
122
123
124 // this pointer is non-NULL if we're currently inside our ProcessEvent()
125 // and we forwarded the event to this child (as we do with menu events)
126 wxMDIChildFrameBase *m_childHandler;
6c70a9b5 127
6c70a9b5
JS
128 DECLARE_EVENT_TABLE()
129 DECLARE_DYNAMIC_CLASS(wxGenericMDIParentFrame)
130};
131
d2824cdb 132// ----------------------------------------------------------------------------
6c70a9b5 133// wxGenericMDIChildFrame
d2824cdb 134// ----------------------------------------------------------------------------
6c70a9b5 135
d2824cdb 136class WXDLLIMPEXP_CORE wxGenericMDIChildFrame : public wxTDIChildFrame
6c70a9b5
JS
137{
138public:
d2824cdb
VZ
139 wxGenericMDIChildFrame() { Init(); }
140 wxGenericMDIChildFrame(wxGenericMDIParentFrame *parent,
141 wxWindowID winid,
142 const wxString& title,
143 const wxPoint& pos = wxDefaultPosition,
144 const wxSize& size = wxDefaultSize,
145 long style = wxDEFAULT_FRAME_STYLE,
146 const wxString& name = wxFrameNameStr)
147 {
148 Init();
149
150 Create(parent, winid, title, pos, size, style, name);
151 }
152
153 bool Create(wxGenericMDIParentFrame *parent,
154 wxWindowID winid,
155 const wxString& title,
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
158 long style = wxDEFAULT_FRAME_STYLE,
159 const wxString& name = wxFrameNameStr);
6c70a9b5
JS
160
161 virtual ~wxGenericMDIChildFrame();
d2824cdb
VZ
162
163 // implement MDI operations
164 virtual void Activate();
165
6c70a9b5 166
923b48fc 167#if wxUSE_MENUS
6c70a9b5
JS
168 virtual void SetMenuBar( wxMenuBar *menu_bar );
169 virtual wxMenuBar *GetMenuBar() const;
923b48fc 170#endif // wxUSE_MENUS
6c70a9b5 171
d2824cdb 172 virtual wxString GetTitle() const { return m_title; }
6c70a9b5 173 virtual void SetTitle(const wxString& title);
6c70a9b5 174
d2824cdb 175 virtual bool TryParent(wxEvent& event);
6c70a9b5 176
d2824cdb 177 // implementation only from now on
6c70a9b5 178
d2824cdb
VZ
179 wxGenericMDIParentFrame* GetGenericMDIParent() const
180 {
181#if wxUSE_GENERIC_MDI_AS_NATIVE
182 return GetMDIParent();
183#else // generic != native
184 return m_mdiParentGeneric;
6c70a9b5 185#endif
d2824cdb 186 }
6c70a9b5
JS
187
188protected:
d2824cdb 189 wxString m_title;
6c70a9b5
JS
190
191#if wxUSE_MENUS
192 wxMenuBar *m_pMenuBar;
923b48fc 193#endif // wxUSE_MENUS
6c70a9b5 194
d2824cdb
VZ
195#if !wxUSE_GENERIC_MDI_AS_NATIVE
196 wxGenericMDIParentFrame *m_mdiParentGeneric;
197#endif
198
6c70a9b5
JS
199protected:
200 void Init();
201
6c70a9b5 202private:
d2824cdb
VZ
203 void OnMenuHighlight(wxMenuEvent& event);
204 void OnClose(wxCloseEvent& event);
205
6c70a9b5
JS
206 DECLARE_DYNAMIC_CLASS(wxGenericMDIChildFrame)
207 DECLARE_EVENT_TABLE()
208
209 friend class wxGenericMDIClientWindow;
210};
211
d2824cdb 212// ----------------------------------------------------------------------------
6c70a9b5 213// wxGenericMDIClientWindow
d2824cdb 214// ----------------------------------------------------------------------------
6c70a9b5 215
d2824cdb 216class WXDLLIMPEXP_CORE wxGenericMDIClientWindow : public wxMDIClientWindowBase
6c70a9b5
JS
217{
218public:
d2824cdb
VZ
219 wxGenericMDIClientWindow() { }
220
221 // unfortunately we need to provide our own version of CreateClient()
222 // because of the difference in the type of the first parameter and
223 // implement the base class pure virtual method in terms of it
224 // (CreateGenericClient() is virtual itself to allow customizing the client
225 // window creation by overriding it in the derived classes)
226 virtual bool CreateGenericClient(wxWindow *parent);
227 virtual bool CreateClient(wxMDIParentFrame *parent,
228 long WXUNUSED(style) = wxVSCROLL | wxHSCROLL)
229 {
230 return CreateGenericClient(parent);
231 }
6c70a9b5 232
d2824cdb
VZ
233 // implementation only
234 wxBookCtrlBase *GetBookCtrl() const;
235 wxGenericMDIChildFrame *GetChild(size_t pos) const;
236 int FindChild(wxGenericMDIChildFrame *child) const;
6c70a9b5 237
d2824cdb 238private:
6c70a9b5
JS
239 void PageChanged(int OldSelection, int newSelection);
240
3e97a905 241 void OnPageChanged(wxBookCtrlEvent& event);
6c70a9b5
JS
242 void OnSize(wxSizeEvent& event);
243
d2824cdb
VZ
244 // the notebook containing all MDI children as its pages
245 wxNotebook *m_notebook;
6c70a9b5 246
d2824cdb 247 DECLARE_DYNAMIC_CLASS(wxGenericMDIClientWindow)
6c70a9b5
JS
248};
249
d2824cdb
VZ
250// ----------------------------------------------------------------------------
251// inline functions implementation
252// ----------------------------------------------------------------------------
6c70a9b5 253
d2824cdb
VZ
254inline bool
255wxGenericMDIParentFrame::
256WXIsInsideChildHandler(wxGenericMDIChildFrame *child) const
6c70a9b5 257{
d2824cdb
VZ
258 return child == m_childHandler;
259}
6c70a9b5 260
d2824cdb 261#endif // _WX_GENERIC_MDIG_H_