]> git.saurik.com Git - wxWidgets.git/blame - src/generic/mdig.cpp
Rename delegates to try and stop name clashes, probably with wxWebKitCtrl.
[wxWidgets.git] / src / generic / mdig.cpp
CommitLineData
6c70a9b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/generic/mdig.cpp
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
13// ===========================================================================
14// declarations
15// ===========================================================================
16
17// ---------------------------------------------------------------------------
18// headers
19// ---------------------------------------------------------------------------
20
6c70a9b5
JS
21// For compilers that support precompilation, includes "wx.h".
22#include "wx/wxprec.h"
23
24#ifdef __BORLANDC__
25 #pragma hdrstop
26#endif
27
9a6384ca
WS
28#if wxUSE_MDI
29
6c70a9b5 30#ifndef WX_PRECOMP
6c70a9b5 31 #include "wx/menu.h"
2b5f62a0 32 #include "wx/intl.h"
e4db172a 33 #include "wx/log.h"
6c70a9b5
JS
34#endif //WX_PRECOMP
35
d2824cdb
VZ
36#include "wx/mdi.h"
37#include "wx/generic/mdig.h"
38#include "wx/notebook.h"
39#include "wx/scopeguard.h"
40
e27d9a91 41#include "wx/stockitem.h"
6c70a9b5 42
c0924519 43enum MDI_MENU_ID
6c70a9b5
JS
44{
45 wxWINDOWCLOSE = 4001,
46 wxWINDOWCLOSEALL,
47 wxWINDOWNEXT,
48 wxWINDOWPREV
49};
50
51//-----------------------------------------------------------------------------
52// wxGenericMDIParentFrame
53//-----------------------------------------------------------------------------
54
55IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIParentFrame, wxFrame)
56
57BEGIN_EVENT_TABLE(wxGenericMDIParentFrame, wxFrame)
d2824cdb 58 EVT_CLOSE(wxGenericMDIParentFrame::OnClose)
d7260478 59#if wxUSE_MENUS
d2824cdb 60 EVT_MENU(wxID_ANY, wxGenericMDIParentFrame::OnWindowMenu)
d7260478 61#endif
6c70a9b5
JS
62END_EVENT_TABLE()
63
d2824cdb 64void wxGenericMDIParentFrame::Init()
6c70a9b5 65{
d2824cdb
VZ
66#if wxUSE_MENUS
67 m_pMyMenuBar = NULL;
68#endif // wxUSE_MENUS
6c70a9b5
JS
69}
70
71wxGenericMDIParentFrame::~wxGenericMDIParentFrame()
c0924519 72{
6c70a9b5 73 // Make sure the client window is destructed before the menu bars are!
d2824cdb 74 wxDELETE(m_clientWindow);
6c70a9b5 75
c0924519 76#if wxUSE_MENUS
5276b0a5 77 wxDELETE(m_pMyMenuBar);
c0924519 78
6c70a9b5 79 RemoveWindowMenu(GetMenuBar());
6c70a9b5
JS
80#endif // wxUSE_MENUS
81}
82
83bool wxGenericMDIParentFrame::Create(wxWindow *parent,
84 wxWindowID id,
85 const wxString& title,
86 const wxPoint& pos,
87 const wxSize& size,
88 long style,
89 const wxString& name)
90{
d2824cdb
VZ
91 // this style can be used to prevent a window from having the standard MDI
92 // "Window" menu
93 if ( !(style & wxFRAME_NO_WINDOW_MENU) )
94 {
6c70a9b5 95#if wxUSE_MENUS
d2824cdb 96 m_windowMenu = new wxMenu;
6c70a9b5 97
d2824cdb
VZ
98 m_windowMenu->Append(wxWINDOWCLOSE, _("Cl&ose"));
99 m_windowMenu->Append(wxWINDOWCLOSEALL, _("Close All"));
100 m_windowMenu->AppendSeparator();
101 m_windowMenu->Append(wxWINDOWNEXT, _("&Next"));
102 m_windowMenu->Append(wxWINDOWPREV, _("&Previous"));
6c70a9b5 103#endif // wxUSE_MENUS
d2824cdb 104 }
6c70a9b5 105
d2824cdb
VZ
106 // the scrolling styles don't make sense neither for us nor for our client
107 // window (to which they're supposed to apply)
108 style &= ~(wxHSCROLL | wxVSCROLL);
6c70a9b5 109
d2824cdb
VZ
110 if ( !wxFrame::Create( parent, id, title, pos, size, style, name ) )
111 return false;
6c70a9b5 112
d2824cdb
VZ
113 wxGenericMDIClientWindow * const client = OnCreateGenericClient();
114 if ( !client->CreateGenericClient(this) )
115 return false;
116
117 m_clientWindow = client;
118
119 return true;
120}
121
122wxGenericMDIClientWindow *wxGenericMDIParentFrame::OnCreateGenericClient()
123{
124 return new wxGenericMDIClientWindow;
125}
126
127bool wxGenericMDIParentFrame::CloseAll()
128{
129 wxGenericMDIClientWindow * const client = GetGenericClientWindow();
130 if ( !client )
131 return true; // none of the windows left
132
133 wxBookCtrlBase * const book = client->GetBookCtrl();
134 while ( book->GetPageCount() )
135 {
136 wxGenericMDIChildFrame * const child = client->GetChild(0);
137 if ( !child->Close() )
138 {
139 // it refused to close, don't close the remaining ones neither
140 return false;
141 }
142 }
143
144 return true;
6c70a9b5
JS
145}
146
147#if wxUSE_MENUS
148void wxGenericMDIParentFrame::SetWindowMenu(wxMenu* pMenu)
149{
150 // Replace the window menu from the currently loaded menu bar.
151 wxMenuBar *pMenuBar = GetMenuBar();
152
d2824cdb 153 if (m_windowMenu)
6c70a9b5
JS
154 {
155 RemoveWindowMenu(pMenuBar);
156
d2824cdb 157 wxDELETE(m_windowMenu);
6c70a9b5
JS
158 }
159
160 if (pMenu)
161 {
d2824cdb 162 m_windowMenu = pMenu;
6c70a9b5
JS
163
164 AddWindowMenu(pMenuBar);
165 }
166}
167
168void wxGenericMDIParentFrame::SetMenuBar(wxMenuBar *pMenuBar)
169{
170 // Remove the Window menu from the old menu bar
171 RemoveWindowMenu(GetMenuBar());
172 // Add the Window menu to the new menu bar.
173 AddWindowMenu(pMenuBar);
174
175 wxFrame::SetMenuBar(pMenuBar);
176}
177#endif // wxUSE_MENUS
178
d2824cdb 179void wxGenericMDIParentFrame::WXSetChildMenuBar(wxGenericMDIChildFrame *pChild)
6c70a9b5
JS
180{
181#if wxUSE_MENUS
d2824cdb 182 if (pChild == NULL)
6c70a9b5
JS
183 {
184 // No Child, set Our menu bar back.
185 SetMenuBar(m_pMyMenuBar);
c0924519 186
6c70a9b5 187 // Make sure we know our menu bar is in use
d2824cdb 188 m_pMyMenuBar = NULL;
6c70a9b5
JS
189 }
190 else
191 {
d2824cdb 192 if (pChild->GetMenuBar() == NULL)
6c70a9b5
JS
193 return;
194
195 // Do we need to save the current bar?
196 if (m_pMyMenuBar == NULL)
197 m_pMyMenuBar = GetMenuBar();
198
199 SetMenuBar(pChild->GetMenuBar());
200 }
201#endif // wxUSE_MENUS
202}
203
d2824cdb
VZ
204wxGenericMDIClientWindow *
205wxGenericMDIParentFrame::GetGenericClientWindow() const
6c70a9b5 206{
d2824cdb 207 return static_cast<wxGenericMDIClientWindow *>(m_clientWindow);
6c70a9b5
JS
208}
209
d2824cdb 210wxBookCtrlBase *wxGenericMDIParentFrame::GetBookCtrl() const
6c70a9b5 211{
d2824cdb
VZ
212 wxGenericMDIClientWindow * const client = GetGenericClientWindow();
213 return client ? client->GetBookCtrl() : NULL;
6c70a9b5
JS
214}
215
d2824cdb 216void wxGenericMDIParentFrame::AdvanceActive(bool forward)
6c70a9b5 217{
d2824cdb
VZ
218 wxBookCtrlBase * const book = GetBookCtrl();
219 if ( book )
220 book->AdvanceSelection(forward);
6c70a9b5
JS
221}
222
d2824cdb 223void wxGenericMDIParentFrame::WXUpdateChildTitle(wxGenericMDIChildFrame *child)
6c70a9b5 224{
d2824cdb
VZ
225 wxGenericMDIClientWindow * const client = GetGenericClientWindow();
226
227 const int pos = client->FindChild(child);
228 if ( pos == wxNOT_FOUND )
229 return;
230
231 client->GetBookCtrl()->SetPageText(pos, child->GetTitle());
6c70a9b5
JS
232}
233
d2824cdb 234void wxGenericMDIParentFrame::WXActivateChild(wxGenericMDIChildFrame *child)
6c70a9b5 235{
d2824cdb
VZ
236 wxGenericMDIClientWindow * const client = GetGenericClientWindow();
237
238 const int pos = client->FindChild(child);
239 if ( pos == wxNOT_FOUND )
240 return;
241
242 client->GetBookCtrl()->SetSelection(pos);
6c70a9b5
JS
243}
244
d2824cdb 245void wxGenericMDIParentFrame::WXRemoveChild(wxGenericMDIChildFrame *child)
6c70a9b5 246{
d2824cdb
VZ
247 const bool removingActive = WXIsActiveChild(child);
248 if ( removingActive )
6c70a9b5 249 {
d2824cdb
VZ
250 SetActiveChild(NULL);
251 WXSetChildMenuBar(NULL);
6c70a9b5 252 }
6c70a9b5 253
d2824cdb
VZ
254 wxGenericMDIClientWindow * const client = GetGenericClientWindow();
255 wxCHECK_RET( client, "should have client window" );
256
257 wxBookCtrlBase * const book = client->GetBookCtrl();
258
259 // Remove page if still there
260 int pos = client->FindChild(child);
261 if ( pos != wxNOT_FOUND )
6c70a9b5 262 {
d2824cdb
VZ
263 if ( book->RemovePage(pos) )
264 book->Refresh();
265 }
6c70a9b5 266
d2824cdb
VZ
267 if ( removingActive )
268 {
269 // Set the new selection to a remaining page
270 const size_t count = book->GetPageCount();
271 if ( count > (size_t)pos )
272 {
273 book->SetSelection(pos);
274 }
275 else
276 {
277 if ( count > 0 )
278 book->SetSelection(count - 1);
279 }
6c70a9b5
JS
280 }
281}
282
d2824cdb
VZ
283bool
284wxGenericMDIParentFrame::WXIsActiveChild(wxGenericMDIChildFrame *child) const
6c70a9b5 285{
d2824cdb 286 return static_cast<wxMDIChildFrameBase *>(GetActiveChild()) == child;
6c70a9b5
JS
287}
288
289#if wxUSE_MENUS
290void wxGenericMDIParentFrame::RemoveWindowMenu(wxMenuBar *pMenuBar)
291{
d2824cdb 292 if (pMenuBar && m_windowMenu)
6c70a9b5
JS
293 {
294 // Remove old window menu
2b5f62a0 295 int pos = pMenuBar->FindMenu(_("&Window"));
6c70a9b5
JS
296 if (pos != wxNOT_FOUND)
297 {
d2824cdb 298 wxASSERT(m_windowMenu == pMenuBar->GetMenu(pos)); // DBG:: We're going to delete the wrong menu!!!
6c70a9b5
JS
299 pMenuBar->Remove(pos);
300 }
301 }
302}
303
304void wxGenericMDIParentFrame::AddWindowMenu(wxMenuBar *pMenuBar)
305{
d2824cdb 306 if (pMenuBar && m_windowMenu)
c0924519 307 {
e27d9a91 308 int pos = pMenuBar->FindMenu(wxGetStockLabel(wxID_HELP,false));
6c70a9b5
JS
309 if (pos == wxNOT_FOUND)
310 {
d2824cdb 311 pMenuBar->Append(m_windowMenu, _("&Window"));
6c70a9b5
JS
312 }
313 else
314 {
d2824cdb 315 pMenuBar->Insert(pos, m_windowMenu, _("&Window"));
6c70a9b5
JS
316 }
317 }
318}
319
d2824cdb 320void wxGenericMDIParentFrame::OnWindowMenu(wxCommandEvent &event)
6c70a9b5 321{
d2824cdb 322 switch ( event.GetId() )
6c70a9b5 323 {
d2824cdb
VZ
324 case wxWINDOWCLOSE:
325 if ( m_currentChild )
326 m_currentChild->Close();
327 break;
328
329 case wxWINDOWCLOSEALL:
330 CloseAll();
331 break;
332
333 case wxWINDOWNEXT:
334 ActivateNext();
335 break;
336
337 case wxWINDOWPREV:
338 ActivatePrevious();
339 break;
340
341 default:
342 event.Skip();
6c70a9b5
JS
343 }
344}
345#endif // wxUSE_MENUS
346
d2824cdb 347void wxGenericMDIParentFrame::OnClose(wxCloseEvent& event)
6c70a9b5 348{
d2824cdb
VZ
349 if ( !CloseAll() )
350 event.Veto();
351 else
352 event.Skip();
6c70a9b5
JS
353}
354
d2824cdb
VZ
355bool wxGenericMDIParentFrame::ProcessEvent(wxEvent& event)
356{
357 if ( m_currentChild )
358 {
359 // the menu events should be given to the child as we show its menu bar
360 // as our own
361 const wxEventType eventType = event.GetEventType();
362 if ( eventType == wxEVT_COMMAND_MENU_SELECTED ||
363 eventType == wxEVT_UPDATE_UI )
364 {
365 // set the flag indicating that this event was forwarded to the
366 // child from the parent and so shouldn't be propagated upwards if
367 // not processed to avoid infinite loop
368 m_childHandler = m_currentChild;
369 wxON_BLOCK_EXIT_NULL(m_childHandler);
370
3b7fa206 371 if ( m_currentChild->ProcessWindowEvent(event) )
d2824cdb
VZ
372 return true;
373 }
374 }
6c70a9b5 375
d2824cdb
VZ
376 return wxMDIParentFrameBase::ProcessEvent(event);
377}
378
379// ----------------------------------------------------------------------------
6c70a9b5 380// wxGenericMDIChildFrame
d2824cdb 381// ----------------------------------------------------------------------------
6c70a9b5 382
d2824cdb 383IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIChildFrame, wxFrame)
6c70a9b5 384
d2824cdb 385BEGIN_EVENT_TABLE(wxGenericMDIChildFrame, wxFrame)
6c70a9b5 386 EVT_MENU_HIGHLIGHT_ALL(wxGenericMDIChildFrame::OnMenuHighlight)
6c70a9b5 387
d2824cdb 388 EVT_CLOSE(wxGenericMDIChildFrame::OnClose)
6c70a9b5
JS
389END_EVENT_TABLE()
390
d2824cdb 391void wxGenericMDIChildFrame::Init()
6c70a9b5 392{
d2824cdb
VZ
393#if wxUSE_MENUS
394 m_pMenuBar = NULL;
395#endif // wxUSE_MENUS
6c70a9b5 396
d2824cdb
VZ
397#if !wxUSE_GENERIC_MDI_AS_NATIVE
398 m_mdiParentGeneric = NULL;
399#endif
6c70a9b5
JS
400}
401
6c70a9b5
JS
402wxGenericMDIChildFrame::~wxGenericMDIChildFrame()
403{
d2824cdb 404 wxGenericMDIParentFrame * const parent = GetGenericMDIParent();
6c70a9b5 405
d2824cdb
VZ
406 // it could happen that we don't have a valid parent if we hadn't been ever
407 // really created -- but in this case there is nothing else to do neither
408 if ( parent )
409 parent->WXRemoveChild(this);
6c70a9b5
JS
410
411#if wxUSE_MENUS
d2824cdb 412 delete m_pMenuBar;
6c70a9b5
JS
413#endif // wxUSE_MENUS
414}
415
d2824cdb
VZ
416bool wxGenericMDIChildFrame::Create(wxGenericMDIParentFrame *parent,
417 wxWindowID id,
418 const wxString& title,
419 const wxPoint& WXUNUSED(pos),
420 const wxSize& size,
421 long WXUNUSED(style),
422 const wxString& name)
6c70a9b5 423{
d2824cdb
VZ
424 // unfortunately we can't use the base class m_mdiParent field unless
425 // wxGenericMDIParentFrame is wxMDIParentFrame
426#if wxUSE_GENERIC_MDI_AS_NATIVE
427 m_mdiParent = parent;
428#else // generic != native
429 // leave m_mdiParent NULL, we don't have it
430 m_mdiParentGeneric = parent;
431#endif
c0924519 432
d2824cdb 433 wxBookCtrlBase * const book = parent->GetBookCtrl();
6c70a9b5 434
d2824cdb 435 wxASSERT_MSG( book, "Missing MDI client window." );
6c70a9b5 436
d2824cdb
VZ
437 // note that we ignore the styles, none of the usual TLW styles apply to
438 // this (child) window
439 if ( !wxWindow::Create(book, id, wxDefaultPosition, size, 0, name) )
440 return false;
6c70a9b5 441
d2824cdb
VZ
442 m_title = title;
443 book->AddPage(this, title, true);
6c70a9b5 444
ca65c044 445 return true;
6c70a9b5
JS
446}
447
c0924519 448#if wxUSE_MENUS
6c70a9b5
JS
449void wxGenericMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
450{
451 wxMenuBar *pOldMenuBar = m_pMenuBar;
452 m_pMenuBar = menu_bar;
453
454 if (m_pMenuBar)
455 {
d2824cdb 456 wxGenericMDIParentFrame *parent = GetGenericMDIParent();
c0924519 457
d2824cdb 458 if ( parent )
6c70a9b5 459 {
d2824cdb 460 m_pMenuBar->SetParent(parent);
6c70a9b5 461
d2824cdb 462 if ( parent->WXIsActiveChild(this) )
6c70a9b5
JS
463 {
464 // Replace current menu bars
465 if (pOldMenuBar)
d2824cdb
VZ
466 parent->WXSetChildMenuBar(NULL);
467 parent->WXSetChildMenuBar(this);
6c70a9b5
JS
468 }
469 }
470 }
471}
472
473wxMenuBar *wxGenericMDIChildFrame::GetMenuBar() const
474{
475 return m_pMenuBar;
476}
c0924519 477#endif // wxUSE_MENUS
6c70a9b5
JS
478
479void wxGenericMDIChildFrame::SetTitle(const wxString& title)
480{
d2824cdb 481 m_title = title;
6c70a9b5 482
d2824cdb
VZ
483 wxGenericMDIParentFrame * const parent = GetGenericMDIParent();
484 if ( parent )
485 parent->WXUpdateChildTitle(this);
486 //else: it's ok, we might be not created yet
6c70a9b5
JS
487}
488
489void wxGenericMDIChildFrame::Activate()
490{
d2824cdb 491 wxGenericMDIParentFrame * const parent = GetGenericMDIParent();
6c70a9b5 492
d2824cdb
VZ
493 wxCHECK_RET( parent, "can't activate MDI child without parent" );
494 parent->WXActivateChild(this);
6c70a9b5
JS
495}
496
497void wxGenericMDIChildFrame::OnMenuHighlight(wxMenuEvent& event)
498{
d2824cdb
VZ
499 wxGenericMDIParentFrame * const parent = GetGenericMDIParent();
500 if ( parent)
6c70a9b5 501 {
c0924519 502 // we don't have any help text for this item,
6c70a9b5 503 // but may be the MDI frame does?
d2824cdb 504 parent->OnMenuHighlight(event);
6c70a9b5
JS
505 }
506}
507
d2824cdb 508void wxGenericMDIChildFrame::OnClose(wxCloseEvent& WXUNUSED(event))
6c70a9b5 509{
d2824cdb
VZ
510 // we're not a TLW so don't delay the destruction of this window
511 delete this;
6c70a9b5
JS
512}
513
8cc208e3 514bool wxGenericMDIChildFrame::TryAfter(wxEvent& event)
c0924519 515{
d2824cdb
VZ
516 // we shouldn't propagate the event to the parent if we received it from it
517 // in the first place
518 wxGenericMDIParentFrame * const parent = GetGenericMDIParent();
519 if ( parent && parent->WXIsInsideChildHandler(this) )
520 return false;
6c70a9b5 521
8cc208e3 522 return wxTDIChildFrame::TryAfter(event);
6c70a9b5
JS
523}
524
d2824cdb 525// ----------------------------------------------------------------------------
6c70a9b5 526// wxGenericMDIClientWindow
d2824cdb 527// ----------------------------------------------------------------------------
6c70a9b5 528
d2824cdb 529IMPLEMENT_DYNAMIC_CLASS(wxGenericMDIClientWindow, wxWindow)
6c70a9b5 530
d2824cdb
VZ
531bool
532wxGenericMDIClientWindow::CreateGenericClient(wxWindow *parent)
533{
534 if ( !wxWindow::Create(parent, wxID_ANY) )
535 return false;
6c70a9b5 536
d2824cdb
VZ
537 m_notebook = new wxNotebook(this, wxID_ANY);
538 m_notebook->Connect
539 (
540 wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
541 wxNotebookEventHandler(
542 wxGenericMDIClientWindow::OnPageChanged),
543 NULL,
544 this
545 );
6c70a9b5 546
d2824cdb
VZ
547 // now that we have a notebook to resize, hook up OnSize() too
548 Connect(wxEVT_SIZE, wxSizeEventHandler(wxGenericMDIClientWindow::OnSize));
6c70a9b5 549
d2824cdb 550 return true;
6c70a9b5
JS
551}
552
d2824cdb 553wxBookCtrlBase *wxGenericMDIClientWindow::GetBookCtrl() const
6c70a9b5 554{
d2824cdb 555 return m_notebook;
6c70a9b5
JS
556}
557
d2824cdb 558wxGenericMDIChildFrame *wxGenericMDIClientWindow::GetChild(size_t pos) const
6c70a9b5 559{
d2824cdb 560 return static_cast<wxGenericMDIChildFrame *>(GetBookCtrl()->GetPage(pos));
6c70a9b5
JS
561}
562
d2824cdb 563int wxGenericMDIClientWindow::FindChild(wxGenericMDIChildFrame *child) const
6c70a9b5 564{
d2824cdb
VZ
565 wxBookCtrlBase * const book = GetBookCtrl();
566 const size_t count = book->GetPageCount();
567 for ( size_t pos = 0; pos < count; pos++ )
6c70a9b5 568 {
d2824cdb
VZ
569 if ( book->GetPage(pos) == child )
570 return pos;
6c70a9b5 571 }
6c70a9b5 572
d2824cdb 573 return wxNOT_FOUND;
6c70a9b5
JS
574}
575
d2824cdb 576void wxGenericMDIClientWindow::PageChanged(int oldSelection, int newSelection)
6c70a9b5 577{
d2824cdb
VZ
578 // Don't do anything if nothing changed
579 if (oldSelection == newSelection)
6c70a9b5 580 return;
d2824cdb
VZ
581
582 // Again check if we really need to do this...
6c70a9b5
JS
583 if (newSelection != -1)
584 {
d2824cdb 585 wxGenericMDIChildFrame * const child = GetChild(newSelection);
6c70a9b5 586
d2824cdb 587 if ( child->GetGenericMDIParent()->WXIsActiveChild(child) )
6c70a9b5
JS
588 return;
589 }
590
591 // Notify old active child that it has been deactivated
d2824cdb 592 if (oldSelection != -1)
6c70a9b5 593 {
d2824cdb 594 wxGenericMDIChildFrame * const oldChild = GetChild(oldSelection);
6c70a9b5
JS
595 if (oldChild)
596 {
ca65c044 597 wxActivateEvent event(wxEVT_ACTIVATE, false, oldChild->GetId());
6c70a9b5
JS
598 event.SetEventObject( oldChild );
599 oldChild->GetEventHandler()->ProcessEvent(event);
600 }
601 }
602
603 // Notify new active child that it has been activated
604 if (newSelection != -1)
605 {
d2824cdb
VZ
606 wxGenericMDIChildFrame * const activeChild = GetChild(newSelection);
607 if ( activeChild )
6c70a9b5 608 {
ca65c044 609 wxActivateEvent event(wxEVT_ACTIVATE, true, activeChild->GetId());
6c70a9b5
JS
610 event.SetEventObject( activeChild );
611 activeChild->GetEventHandler()->ProcessEvent(event);
612
d2824cdb
VZ
613 wxGenericMDIParentFrame * const
614 parent = activeChild->GetGenericMDIParent();
615
616 if ( parent )
6c70a9b5 617 {
d2824cdb
VZ
618 // this is a dirty hack as activeChild is not really a
619 // wxMDIChildFrame at all but we still want to store it in the
620 // base class m_currentChild field and this will work as long
621 // as we only use as wxMDIChildFrameBase pointer (which it is)
622 parent->SetActiveChild(
623 reinterpret_cast<wxMDIChildFrame *>(activeChild));
624 parent->WXSetChildMenuBar(activeChild);
6c70a9b5
JS
625 }
626 }
627 }
628}
629
3e97a905 630void wxGenericMDIClientWindow::OnPageChanged(wxBookCtrlEvent& event)
6c70a9b5
JS
631{
632 PageChanged(event.GetOldSelection(), event.GetSelection());
633
634 event.Skip();
635}
636
d2824cdb 637void wxGenericMDIClientWindow::OnSize(wxSizeEvent& WXUNUSED(event))
6c70a9b5 638{
d2824cdb 639 m_notebook->SetSize(GetClientSize());
6c70a9b5
JS
640}
641
b4ca5976
VS
642#endif // wxUSE_MDI
643