bool wxAuiMDIChildFrame::Destroy() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); wxASSERT_MSG(pClientWindow, wxT("Missing MDI Client Window")); if (pParentFrame->GetActiveChild() == this) { // deactivate ourself wxActivateEvent event(wxEVT_ACTIVATE, false, GetId()); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); pParentFrame->SetActiveChild(NULL); pParentFrame->SetChildMenuBar(NULL); } size_t page_count = pClientWindow->GetPageCount(); for (size_t pos = 0; pos < page_count; pos++) { if (pClientWindow->GetPage(pos) == this) return pClientWindow->DeletePage(pos); } return false; }
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar) { // Don't create the underlying menubar yet; need to recreate // it every time the child is activated. m_frameMenuBar = menuBar; // We make the assumption that if you're setting the menubar, // this is the currently active child. GetMDIParentFrame()->SetChildMenuBar(this); }
void wxMDIChildFrame::SetTitle(const wxString& title) { wxTopLevelWindow::SetTitle( title ); wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow(); // Remove page if still there { int i = clientWindow->FindPage(this); if (i != -1) clientWindow->SetPageText(i, title); } }
wxMDIChildFrame::~wxMDIChildFrame() { if (m_mainWidget) XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask,False, wxUniversalRepaintProc, (XtPointer) this); if (GetMDIParentFrame()) { wxMDIParentFrame* parentFrame = GetMDIParentFrame(); if (parentFrame->GetActiveChild() == this) parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow(); // Remove page if still there { int i = clientWindow->FindPage(this); if (i != -1) { clientWindow->RemovePage(i); clientWindow->Refresh(); } } // Set the selection to the first remaining page if (clientWindow->GetPageCount() > 0) { wxMDIChildFrame* child = (wxMDIChildFrame*) clientWindow->GetPage(0); parentFrame->SetActiveChild(child); parentFrame->SetChildMenuBar(child); } else { parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); parentFrame->SetChildMenuBar((wxMDIChildFrame*) NULL); } } }
wxAuiMDIChildFrame::~wxAuiMDIChildFrame() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); if (pParentFrame && pParentFrame->GetActiveChild() == this) { pParentFrame->SetActiveChild(NULL); pParentFrame->SetChildMenuBar(NULL); } #if wxUSE_MENUS wxDELETE(m_pMenuBar); #endif // wxUSE_MENUS }
void wxAuiMDIChildFrame::Activate() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); if (pClientWindow != NULL) { size_t pos; for (pos = 0; pos < pClientWindow->GetPageCount(); pos++) { if (pClientWindow->GetPage(pos) == this) { pClientWindow->SetSelection(pos); break; } } } }
void wxAuiMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar) { wxMenuBar *pOldMenuBar = m_pMenuBar; m_pMenuBar = menu_bar; if (m_pMenuBar) { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); m_pMenuBar->SetParent(pParentFrame); if (pParentFrame->GetActiveChild() == this) { // replace current menu bars if (pOldMenuBar) pParentFrame->SetChildMenuBar(NULL); pParentFrame->SetChildMenuBar(this); } } }
void wxAuiMDIChildFrame::SetIcon(const wxIcon& icon) { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); m_icon = icon; wxBitmap bmp; bmp.CopyFromIcon(m_icon); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); if (pClientWindow != NULL) { int idx = pClientWindow->GetPageIndex(this); if (idx != -1) { pClientWindow->SetPageBitmap((size_t)idx, bmp); } } }
void wxAuiMDIChildFrame::SetTitle(const wxString& title) { m_title = title; wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); wxASSERT_MSG(pParentFrame, wxT("Missing MDI Parent Frame")); wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); if (pClientWindow != NULL) { size_t pos; for (pos = 0; pos < pClientWindow->GetPageCount(); pos++) { if (pClientWindow->GetPage(pos) == this) { pClientWindow->SetPageText(pos, m_title); break; } } } }
wxAuiMDIChildFrame::~wxAuiMDIChildFrame() { wxAuiMDIParentFrame* pParentFrame = GetMDIParentFrame(); if (pParentFrame) { if (pParentFrame->GetActiveChild() == this) { pParentFrame->SetActiveChild(NULL); pParentFrame->SetChildMenuBar(NULL); } wxAuiMDIClientWindow* pClientWindow = pParentFrame->GetClientWindow(); wxASSERT(pClientWindow); int idx = pClientWindow->GetPageIndex(this); if (idx != wxNOT_FOUND) { pClientWindow->RemovePage(idx); } } #if wxUSE_MENUS wxDELETE(m_pMenuBar); #endif // wxUSE_MENUS }