1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/aui/tabmdi.cpp 
   3 // Purpose:     Generic MDI (Multiple Document Interface) classes 
   4 // Author:      Hans Van Leemputten 
   5 // Modified by: Benjamin I. Williams / Kirix Corporation 
   8 // Copyright:   (c) Hans Van Leemputten 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // =========================================================================== 
  14 // =========================================================================== 
  16 // --------------------------------------------------------------------------- 
  18 // --------------------------------------------------------------------------- 
  20 // For compilers that support precompilation, includes "wx.h". 
  21 #include "wx/wxprec.h" 
  30 #include "wx/aui/tabmdi.h" 
  37     #include "wx/settings.h" 
  40 #include "wx/stockitem.h" 
  41 #include "wx/aui/dockart.h" 
  51 //----------------------------------------------------------------------------- 
  52 // wxAuiMDIParentFrame 
  53 //----------------------------------------------------------------------------- 
  55 IMPLEMENT_DYNAMIC_CLASS(wxAuiMDIParentFrame
, wxFrame
) 
  57 BEGIN_EVENT_TABLE(wxAuiMDIParentFrame
, wxFrame
) 
  59     EVT_MENU (wxID_ANY
, wxAuiMDIParentFrame::DoHandleMenu
) 
  60     EVT_UPDATE_UI (wxID_ANY
, wxAuiMDIParentFrame::DoHandleUpdateUI
) 
  64 wxAuiMDIParentFrame::wxAuiMDIParentFrame() 
  69 wxAuiMDIParentFrame::wxAuiMDIParentFrame(wxWindow 
*parent
, 
  71                                          const wxString
& title
, 
  78     (void)Create(parent
, id
, title
, pos
, size
, style
, name
); 
  81 wxAuiMDIParentFrame::~wxAuiMDIParentFrame() 
  83     // Avoid having GetActiveChild() called after m_pClientWindow is destroyed 
  85     // Make sure the client window is destructed before the menu bars are! 
  86     wxDELETE(m_pClientWindow
); 
  89     wxDELETE(m_pMyMenuBar
); 
  90     RemoveWindowMenu(GetMenuBar()); 
  91     wxDELETE(m_pWindowMenu
); 
  95 bool wxAuiMDIParentFrame::Create(wxWindow 
*parent
, 
  97                                  const wxString
& title
, 
 101                                  const wxString
& name
) 
 104     // this style can be used to prevent a window from having the standard MDI 
 106     if (!(style 
& wxFRAME_NO_WINDOW_MENU
)) 
 108         m_pWindowMenu 
= new wxMenu
; 
 109         m_pWindowMenu
->Append(wxWINDOWCLOSE
,    _("Cl&ose")); 
 110         m_pWindowMenu
->Append(wxWINDOWCLOSEALL
, _("Close All")); 
 111         m_pWindowMenu
->AppendSeparator(); 
 112         m_pWindowMenu
->Append(wxWINDOWNEXT
,     _("&Next")); 
 113         m_pWindowMenu
->Append(wxWINDOWPREV
,     _("&Previous")); 
 115 #endif // wxUSE_MENUS 
 117     if ( !wxFrame::Create(parent
, id
, title
, pos
, size
, style
, name
) ) 
 120     m_pClientWindow 
= OnCreateClient(); 
 121     return m_pClientWindow 
!= NULL
; 
 125 void wxAuiMDIParentFrame::SetArtProvider(wxAuiTabArt
* provider
) 
 129         m_pClientWindow
->SetArtProvider(provider
); 
 133 wxAuiTabArt
* wxAuiMDIParentFrame::GetArtProvider() 
 135     if (!m_pClientWindow
) 
 138     return m_pClientWindow
->GetArtProvider(); 
 141 wxAuiNotebook
* wxAuiMDIParentFrame::GetNotebook() const 
 143     return static_cast<wxAuiNotebook
*>(m_pClientWindow
); 
 149 void wxAuiMDIParentFrame::SetWindowMenu(wxMenu
* pMenu
) 
 151     // Replace the window menu from the currently loaded menu bar. 
 152     wxMenuBar 
*pMenuBar 
= GetMenuBar(); 
 156         RemoveWindowMenu(pMenuBar
); 
 157         wxDELETE(m_pWindowMenu
); 
 162         m_pWindowMenu 
= pMenu
; 
 163         AddWindowMenu(pMenuBar
); 
 167 void wxAuiMDIParentFrame::SetMenuBar(wxMenuBar
* pMenuBar
) 
 169     // Remove the Window menu from the old menu bar 
 170     RemoveWindowMenu(GetMenuBar()); 
 172     // Add the Window menu to the new menu bar. 
 173     AddWindowMenu(pMenuBar
); 
 175     wxFrame::SetMenuBar(pMenuBar
); 
 176     //m_pMyMenuBar = GetMenuBar(); 
 178 #endif // wxUSE_MENUS 
 180 void wxAuiMDIParentFrame::SetChildMenuBar(wxAuiMDIChildFrame
* pChild
) 
 185         // No Child, set Our menu bar back. 
 187             SetMenuBar(m_pMyMenuBar
); 
 189             SetMenuBar(GetMenuBar()); 
 191         // Make sure we know our menu bar is in use 
 196         if (pChild
->GetMenuBar() == NULL
) 
 199         // Do we need to save the current bar? 
 200         if (m_pMyMenuBar 
== NULL
) 
 201             m_pMyMenuBar 
= GetMenuBar(); 
 203         SetMenuBar(pChild
->GetMenuBar()); 
 205 #endif // wxUSE_MENUS 
 208 bool wxAuiMDIParentFrame::ProcessEvent(wxEvent
& event
) 
 210     // stops the same event being processed repeatedly 
 211     if (m_pLastEvt 
== &event
) 
 215     // let the active child (if any) process the event first. 
 217     wxAuiMDIChildFrame
* pActiveChild 
= GetActiveChild(); 
 219         event
.IsCommandEvent() && 
 220         event
.GetEventObject() != m_pClientWindow 
&& 
 221            !(event
.GetEventType() == wxEVT_ACTIVATE 
|| 
 222              event
.GetEventType() == wxEVT_SET_FOCUS 
|| 
 223              event
.GetEventType() == wxEVT_KILL_FOCUS 
|| 
 224              event
.GetEventType() == wxEVT_CHILD_FOCUS 
|| 
 225              event
.GetEventType() == wxEVT_COMMAND_SET_FOCUS 
|| 
 226              event
.GetEventType() == wxEVT_COMMAND_KILL_FOCUS 
) 
 229         res 
= pActiveChild
->GetEventHandler()->ProcessEvent(event
); 
 234         // if the event was not handled this frame will handle it, 
 235         // which is why we need the protection code at the beginning 
 237         res 
= wxEvtHandler::ProcessEvent(event
); 
 245 wxAuiMDIChildFrame 
*wxAuiMDIParentFrame::GetActiveChild() const 
 247     // We can be called before the client window is created, so check for its 
 249     wxAuiMDIClientWindow
* const client 
= GetClientWindow(); 
 250     return client 
? client
->GetActiveChild() : NULL
; 
 253 void wxAuiMDIParentFrame::SetActiveChild(wxAuiMDIChildFrame
* pChildFrame
) 
 255     wxAuiMDIClientWindow
* const client 
= GetClientWindow(); 
 256     if (client 
&& client
->GetActiveChild() != pChildFrame
) 
 258         client
->SetActiveChild(pChildFrame
); 
 262 wxAuiMDIClientWindow 
*wxAuiMDIParentFrame::GetClientWindow() const 
 264     return m_pClientWindow
; 
 267 wxAuiMDIClientWindow 
*wxAuiMDIParentFrame::OnCreateClient() 
 269     return new wxAuiMDIClientWindow( this ); 
 272 void wxAuiMDIParentFrame::ActivateNext() 
 274     if (m_pClientWindow 
&& m_pClientWindow
->GetSelection() != wxNOT_FOUND
) 
 276         size_t active 
= m_pClientWindow
->GetSelection() + 1; 
 277         if (active 
>= m_pClientWindow
->GetPageCount()) 
 280         m_pClientWindow
->SetSelection(active
); 
 284 void wxAuiMDIParentFrame::ActivatePrevious() 
 286     if (m_pClientWindow 
&& m_pClientWindow
->GetSelection() != wxNOT_FOUND
) 
 288         int active 
= m_pClientWindow
->GetSelection() - 1; 
 290             active 
= m_pClientWindow
->GetPageCount() - 1; 
 292         m_pClientWindow
->SetSelection(active
); 
 296 void wxAuiMDIParentFrame::Init() 
 299     m_pClientWindow 
= NULL
; 
 301     m_pWindowMenu 
= NULL
; 
 303 #endif // wxUSE_MENUS 
 307 void wxAuiMDIParentFrame::RemoveWindowMenu(wxMenuBar
* pMenuBar
) 
 309     if (pMenuBar 
&& m_pWindowMenu
) 
 311         // Remove old window menu 
 312         int pos 
= pMenuBar
->FindMenu(_("&Window")); 
 313         if (pos 
!= wxNOT_FOUND
) 
 315             // DBG:: We're going to delete the wrong menu!!! 
 316             wxASSERT(m_pWindowMenu 
== pMenuBar
->GetMenu(pos
)); 
 317             pMenuBar
->Remove(pos
); 
 322 void wxAuiMDIParentFrame::AddWindowMenu(wxMenuBar 
*pMenuBar
) 
 324     if (pMenuBar 
&& m_pWindowMenu
) 
 326         int pos 
= pMenuBar
->FindMenu(wxGetStockLabel(wxID_HELP
,wxSTOCK_NOFLAGS
)); 
 327         if (pos 
== wxNOT_FOUND
) 
 328             pMenuBar
->Append(m_pWindowMenu
, _("&Window")); 
 330             pMenuBar
->Insert(pos
, m_pWindowMenu
, _("&Window")); 
 334 void wxAuiMDIParentFrame::DoHandleMenu(wxCommandEvent
& event
) 
 336     switch (event
.GetId()) 
 340             wxAuiMDIChildFrame
* pActiveChild 
= GetActiveChild(); 
 342                 pActiveChild
->Close(); 
 345         case wxWINDOWCLOSEALL
: 
 347             wxAuiMDIChildFrame
* pActiveChild
; 
 348             while ((pActiveChild 
= GetActiveChild()) != NULL
) 
 350                 if (!pActiveChild
->Close()) 
 368 void wxAuiMDIParentFrame::DoHandleUpdateUI(wxUpdateUIEvent
& event
) 
 370     switch (event
.GetId()) 
 373         case wxWINDOWCLOSEALL
: 
 375             wxAuiMDIClientWindow
* client_window 
= GetClientWindow(); 
 376             wxCHECK_RET(client_window
, wxS("Missing MDI Client Window")); 
 377             size_t pages 
= client_window
->GetPageCount(); 
 378             event
.Enable(pages 
>= 1); 
 385             wxAuiMDIClientWindow
* client_window 
= GetClientWindow(); 
 386             wxCHECK_RET(client_window
, wxS("Missing MDI Client Window")); 
 387             size_t pages 
= client_window
->GetPageCount(); 
 388             event
.Enable(pages 
>= 2); 
 396 #endif // wxUSE_MENUS 
 398 void wxAuiMDIParentFrame::DoGetClientSize(int* width
, int* height
) const 
 400     wxFrame::DoGetClientSize(width
, height
); 
 403 void wxAuiMDIParentFrame::Tile(wxOrientation orient
) 
 405     wxAuiMDIClientWindow
* client_window 
= GetClientWindow(); 
 406     wxASSERT_MSG(client_window
, wxT("Missing MDI Client Window")); 
 408     int cur_idx 
= client_window
->GetSelection(); 
 412     if (orient 
== wxVERTICAL
) 
 414         client_window
->Split(cur_idx
, wxLEFT
); 
 416     else if (orient 
== wxHORIZONTAL
) 
 418         client_window
->Split(cur_idx
, wxTOP
); 
 423 //----------------------------------------------------------------------------- 
 424 // wxAuiMDIChildFrame 
 425 //----------------------------------------------------------------------------- 
 427 IMPLEMENT_DYNAMIC_CLASS(wxAuiMDIChildFrame
, wxPanel
) 
 429 BEGIN_EVENT_TABLE(wxAuiMDIChildFrame
, wxPanel
) 
 430     EVT_MENU_HIGHLIGHT_ALL(wxAuiMDIChildFrame::OnMenuHighlight
) 
 431     EVT_ACTIVATE(wxAuiMDIChildFrame::OnActivate
) 
 432     EVT_CLOSE(wxAuiMDIChildFrame::OnCloseWindow
) 
 435 wxAuiMDIChildFrame::wxAuiMDIChildFrame() 
 440 wxAuiMDIChildFrame::wxAuiMDIChildFrame(wxAuiMDIParentFrame 
*parent
, 
 442                                        const wxString
& title
, 
 443                                        const wxPoint
& WXUNUSED(pos
), 
 446                                        const wxString
& name
) 
 450     // There are two ways to create an tabbed mdi child fram without 
 451     // making it the active document.  Either Show(false) can be called 
 452     // before Create() (as is customary on some ports with wxFrame-type 
 453     // windows), or wxMINIMIZE can be passed in the style flags.  Note that 
 454     // wxAuiMDIChildFrame is not really derived from wxFrame, as wxMDIChildFrame 
 455     // is, but those are the expected symantics.  No style flag is passed 
 456     // onto the panel underneath. 
 457     if (style 
& wxMINIMIZE
) 
 458         m_activateOnCreate 
= false; 
 460     Create(parent
, id
, title
, wxDefaultPosition
, size
, 0, name
); 
 463 wxAuiMDIChildFrame::~wxAuiMDIChildFrame() 
 465     wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 468         if (pParentFrame
->GetActiveChild() == this) 
 470             pParentFrame
->SetActiveChild(NULL
); 
 471             pParentFrame
->SetChildMenuBar(NULL
); 
 473         wxAuiMDIClientWindow
* pClientWindow 
= pParentFrame
->GetClientWindow(); 
 474         wxASSERT(pClientWindow
); 
 475         int idx 
= pClientWindow
->GetPageIndex(this); 
 476         if (idx 
!= wxNOT_FOUND
) 
 478             pClientWindow
->RemovePage(idx
); 
 483     wxDELETE(m_pMenuBar
); 
 484 #endif // wxUSE_MENUS 
 487 bool wxAuiMDIChildFrame::Create(wxAuiMDIParentFrame
* parent
, 
 489                                 const wxString
& title
, 
 490                                 const wxPoint
& WXUNUSED(pos
), 
 493                                 const wxString
& name
) 
 495     wxAuiMDIClientWindow
* pClientWindow 
= parent
->GetClientWindow(); 
 496     wxASSERT_MSG((pClientWindow 
!= NULL
), wxT("Missing MDI client window.")); 
 498     // see comment in constructor 
 499     if (style 
& wxMINIMIZE
) 
 500         m_activateOnCreate 
= false; 
 502     wxSize cli_size 
= pClientWindow
->GetClientSize(); 
 504     // create the window off-screen to prevent flicker 
 505     wxPanel::Create(pClientWindow
, 
 507                     wxPoint(cli_size
.x
+1, cli_size
.y
+1), 
 513     SetMDIParentFrame(parent
); 
 517     pClientWindow
->AddPage(this, title
, m_activateOnCreate
); 
 519     // Check that the parent notion of the active child coincides with our one. 
 520     // This is less obvious that it seems because we must honour 
 521     // m_activateOnCreate flag but only if it's not the first child because 
 522     // this one becomes active unconditionally. 
 525         (m_activateOnCreate 
|| pClientWindow
->GetPageCount() == 1) 
 526             == (parent
->GetActiveChild() == this), 
 527         wxS("Logic error: child [not] activated when it should [not] have been.") 
 530     pClientWindow
->Refresh(); 
 535 bool wxAuiMDIChildFrame::Destroy() 
 537     wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 538     wxASSERT_MSG(pParentFrame
, wxT("Missing MDI Parent Frame")); 
 540     wxAuiMDIClientWindow
* pClientWindow 
= pParentFrame
->GetClientWindow(); 
 541     wxASSERT_MSG(pClientWindow
, wxT("Missing MDI Client Window")); 
 543     if (pParentFrame
->GetActiveChild() == this) 
 545         // deactivate ourself 
 546         wxActivateEvent 
event(wxEVT_ACTIVATE
, false, GetId()); 
 547         event
.SetEventObject(this); 
 548         GetEventHandler()->ProcessEvent(event
); 
 550         pParentFrame
->SetChildMenuBar(NULL
); 
 553     size_t page_count 
= pClientWindow
->GetPageCount(); 
 554     for (size_t pos 
= 0; pos 
< page_count
; pos
++) 
 556         if (pClientWindow
->GetPage(pos
) == this) 
 557             return pClientWindow
->DeletePage(pos
); 
 564 void wxAuiMDIChildFrame::SetMenuBar(wxMenuBar 
*menu_bar
) 
 566     wxMenuBar 
*pOldMenuBar 
= m_pMenuBar
; 
 567     m_pMenuBar 
= menu_bar
; 
 571         wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 572         wxASSERT_MSG(pParentFrame
, wxT("Missing MDI Parent Frame")); 
 574         m_pMenuBar
->SetParent(pParentFrame
); 
 575         if (pParentFrame
->GetActiveChild() == this) 
 577             // replace current menu bars 
 579                 pParentFrame
->SetChildMenuBar(NULL
); 
 580             pParentFrame
->SetChildMenuBar(this); 
 585 wxMenuBar 
*wxAuiMDIChildFrame::GetMenuBar() const 
 589 #endif // wxUSE_MENUS 
 591 void wxAuiMDIChildFrame::SetTitle(const wxString
& title
) 
 595     wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 596     wxASSERT_MSG(pParentFrame
, wxT("Missing MDI Parent Frame")); 
 598     wxAuiMDIClientWindow
* pClientWindow 
= pParentFrame
->GetClientWindow(); 
 599     if (pClientWindow 
!= NULL
) 
 602         for (pos 
= 0; pos 
< pClientWindow
->GetPageCount(); pos
++) 
 604             if (pClientWindow
->GetPage(pos
) == this) 
 606                 pClientWindow
->SetPageText(pos
, m_title
); 
 613 wxString 
wxAuiMDIChildFrame::GetTitle() const 
 618 void wxAuiMDIChildFrame::SetIcons(const wxIconBundle
& icons
) 
 620     // get icon with the system icon size 
 621     SetIcon(icons
.GetIcon(-1)); 
 622     m_iconBundle 
= icons
; 
 625 const wxIconBundle
& wxAuiMDIChildFrame::GetIcons() const 
 630 void wxAuiMDIChildFrame::SetIcon(const wxIcon
& icon
) 
 632     wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 633     wxASSERT_MSG(pParentFrame
, wxT("Missing MDI Parent Frame")); 
 638     bmp
.CopyFromIcon(m_icon
); 
 640     wxAuiMDIClientWindow
* pClientWindow 
= pParentFrame
->GetClientWindow(); 
 641     if (pClientWindow 
!= NULL
) 
 643         int idx 
= pClientWindow
->GetPageIndex(this); 
 647             pClientWindow
->SetPageBitmap((size_t)idx
, bmp
); 
 652 const wxIcon
& wxAuiMDIChildFrame::GetIcon() const 
 658 void wxAuiMDIChildFrame::Activate() 
 660     wxAuiMDIParentFrame
* pParentFrame 
= GetMDIParentFrame(); 
 661     wxASSERT_MSG(pParentFrame
, wxT("Missing MDI Parent Frame")); 
 663     wxAuiMDIClientWindow
* pClientWindow 
= pParentFrame
->GetClientWindow(); 
 665     if (pClientWindow 
!= NULL
) 
 668         for (pos 
= 0; pos 
< pClientWindow
->GetPageCount(); pos
++) 
 670             if (pClientWindow
->GetPage(pos
) == this) 
 672                 pClientWindow
->SetSelection(pos
); 
 679 void wxAuiMDIChildFrame::OnMenuHighlight(wxMenuEvent
& event
) 
 682     if (m_pMDIParentFrame
) 
 684         // we don't have any help text for this item, 
 685         // but may be the MDI frame does? 
 686         m_pMDIParentFrame
->OnMenuHighlight(event
); 
 690 #endif // wxUSE_STATUSBAR 
 693 void wxAuiMDIChildFrame::OnActivate(wxActivateEvent
& WXUNUSED(event
)) 
 698 void wxAuiMDIChildFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
)) 
 703 void wxAuiMDIChildFrame::SetMDIParentFrame(wxAuiMDIParentFrame
* parentFrame
) 
 705     m_pMDIParentFrame 
= parentFrame
; 
 708 wxAuiMDIParentFrame
* wxAuiMDIChildFrame::GetMDIParentFrame() const 
 710     return m_pMDIParentFrame
; 
 713 void wxAuiMDIChildFrame::Init() 
 715     m_activateOnCreate 
= true; 
 716     m_pMDIParentFrame 
= NULL
; 
 719 #endif // wxUSE_MENUS 
 722 bool wxAuiMDIChildFrame::Show(bool show
) 
 724     // wxAuiMDIChildFrame uses m_activateOnCreate only to decide whether to 
 725     // activate the frame when it is created.  After Create() is called, 
 726     // m_activateOnCreate will never be read again.  Therefore, calling this 
 727     // function after Create() is pointless and you probably want to call 
 728     // Activate() instead. 
 729     wxCHECK_MSG( !GetHandle(), false, 
 730                  wxS("Show() has no effect after Create(). Do you mean Activate()?") ); 
 732     m_activateOnCreate 
= show
; 
 738 void wxAuiMDIChildFrame::DoShow(bool show
) 
 740     wxWindow::Show(show
); 
 743 void wxAuiMDIChildFrame::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
) 
 745     m_mdiNewRect 
= wxRect(x
, y
, width
, height
); 
 747     wxPanel::DoSetSize(x
,y
,width
, height
, sizeFlags
); 
 749     wxUnusedVar(sizeFlags
); 
 753 void wxAuiMDIChildFrame::DoMoveWindow(int x
, int y
, int width
, int height
) 
 755     m_mdiNewRect 
= wxRect(x
, y
, width
, height
); 
 758 void wxAuiMDIChildFrame::ApplyMDIChildFrameRect() 
 760     if (m_mdiCurRect 
!= m_mdiNewRect
) 
 762         wxPanel::DoMoveWindow(m_mdiNewRect
.x
, m_mdiNewRect
.y
, 
 763                               m_mdiNewRect
.width
, m_mdiNewRect
.height
); 
 764         m_mdiCurRect 
= m_mdiNewRect
; 
 769 //----------------------------------------------------------------------------- 
 770 // wxAuiMDIClientWindow 
 771 //----------------------------------------------------------------------------- 
 773 IMPLEMENT_DYNAMIC_CLASS(wxAuiMDIClientWindow
, wxAuiNotebook
) 
 775 BEGIN_EVENT_TABLE(wxAuiMDIClientWindow
, wxAuiNotebook
) 
 776     EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY
, wxAuiMDIClientWindow::OnPageChanged
) 
 777     EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY
, wxAuiMDIClientWindow::OnPageClose
) 
 778     EVT_SIZE(wxAuiMDIClientWindow::OnSize
) 
 781 wxAuiMDIClientWindow::wxAuiMDIClientWindow() 
 785 wxAuiMDIClientWindow::wxAuiMDIClientWindow(wxAuiMDIParentFrame
* parent
, long style
) 
 787     CreateClient(parent
, style
); 
 790 bool wxAuiMDIClientWindow::CreateClient(wxAuiMDIParentFrame
* parent
, long style
) 
 792     SetWindowStyleFlag(style
); 
 794     wxSize caption_icon_size 
= 
 795             wxSize(wxSystemSettings::GetMetric(wxSYS_SMALLICON_X
), 
 796                    wxSystemSettings::GetMetric(wxSYS_SMALLICON_Y
)); 
 797     SetUniformBitmapSize(caption_icon_size
); 
 799     if (!wxAuiNotebook::Create(parent
, 
 803                                wxAUI_NB_DEFAULT_STYLE 
| wxNO_BORDER
)) 
 808     wxColour bkcolour 
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
); 
 809     SetOwnBackgroundColour(bkcolour
); 
 811     m_mgr
.GetArtProvider()->SetColour(wxAUI_DOCKART_BACKGROUND_COLOUR
, bkcolour
); 
 816 int wxAuiMDIClientWindow::SetSelection(size_t nPage
) 
 818     return wxAuiNotebook::SetSelection(nPage
); 
 821 wxAuiMDIChildFrame
* wxAuiMDIClientWindow::GetActiveChild() 
 823     const int sel 
= GetSelection(); 
 824     if ( sel 
== wxNOT_FOUND 
) 
 827     return wxStaticCast(GetPage(sel
), wxAuiMDIChildFrame
); 
 830 void wxAuiMDIClientWindow::PageChanged(int old_selection
, int new_selection
) 
 832     // don't do anything if the page doesn't actually change 
 833     if (old_selection 
== new_selection
) 
 837     // don't do anything if the new page is already active 
 838     if (new_selection != -1) 
 840         wxAuiMDIChildFrame* child = (wxAuiMDIChildFrame*)GetPage(new_selection); 
 841         if (child->GetMDIParentFrame()->GetActiveChild() == child) 
 846     // notify old active child that it has been deactivated 
 847     if ((old_selection 
!= -1) && (old_selection 
< (int)GetPageCount())) 
 849         wxAuiMDIChildFrame
* old_child 
= (wxAuiMDIChildFrame
*)GetPage(old_selection
); 
 850         wxASSERT_MSG(old_child
, wxT("wxAuiMDIClientWindow::PageChanged - null page pointer")); 
 852         wxActivateEvent 
event(wxEVT_ACTIVATE
, false, old_child
->GetId()); 
 853         event
.SetEventObject(old_child
); 
 854         old_child
->GetEventHandler()->ProcessEvent(event
); 
 857     // notify new active child that it has been activated 
 858     if (new_selection 
!= -1) 
 860         wxAuiMDIChildFrame
* active_child 
= (wxAuiMDIChildFrame
*)GetPage(new_selection
); 
 861         wxASSERT_MSG(active_child
, wxT("wxAuiMDIClientWindow::PageChanged - null page pointer")); 
 863         wxActivateEvent 
event(wxEVT_ACTIVATE
, true, active_child
->GetId()); 
 864         event
.SetEventObject(active_child
); 
 865         active_child
->GetEventHandler()->ProcessEvent(event
); 
 867         if (active_child
->GetMDIParentFrame()) 
 869             active_child
->GetMDIParentFrame()->SetActiveChild(active_child
); 
 870             active_child
->GetMDIParentFrame()->SetChildMenuBar(active_child
); 
 877 void wxAuiMDIClientWindow::OnPageClose(wxAuiNotebookEvent
& evt
) 
 879     wxAuiMDIChildFrame
* wnd
; 
 880     wnd 
= static_cast<wxAuiMDIChildFrame
*>(GetPage(evt
.GetSelection())); 
 884     // regardless of the result of wnd->Close(), we've 
 885     // already taken care of the close operations, so 
 886     // suppress further processing 
 890 void wxAuiMDIClientWindow::OnPageChanged(wxAuiNotebookEvent
& evt
) 
 892     PageChanged(evt
.GetOldSelection(), evt
.GetSelection()); 
 895 void wxAuiMDIClientWindow::OnSize(wxSizeEvent
& evt
) 
 897     wxAuiNotebook::OnSize(evt
); 
 899     for (size_t pos 
= 0; pos 
< GetPageCount(); pos
++) 
 900         ((wxAuiMDIChildFrame 
*)GetPage(pos
))->ApplyMDIChildFrameRect();