Ejemplo n.º 1
0
void wxPageContainer::DoDeletePage(size_t page)
{
	// Remove the page from the vector
	wxFlatNotebook* book = (wxFlatNotebook*)GetParent();

	PopPageHistory((int)page);

	// same thing with the active page
	if (m_iActivePage > (int)page || (int)page >= (int)(m_pagesInfoVec.Count())){
		m_iActivePage -= 1;
	}else if (m_iActivePage == (int)page){
		m_iActivePage = GetPreviousSelection();
		//PopPageHistory(m_iActivePage);
 	}

	m_pagesInfoVec.RemoveAt(page);

	if(m_iActivePage == wxNOT_FOUND && m_pagesInfoVec.Count() > 0){
		m_iActivePage = 0;
	}

	// Refresh the tabs
	book->SetForceSelection(true);
	book->SetSelection(m_iActivePage);
	book->SetForceSelection(false);

	if(m_pagesInfoVec.empty())
	{
		// Erase the page container drawings
		wxClientDC dc(this);
		dc.Clear();
	}
}
Ejemplo n.º 2
0
bool Notebook::RemovePage(size_t page, bool notify)
{
    if (notify) {
        //send event to noitfy that the page has changed
        NotebookEvent event(wxEVT_COMMAND_BOOK_PAGE_CLOSING, GetId());
        event.SetSelection( page );
        event.SetEventObject( this );
        GetEventHandler()->ProcessEvent(event);

        if (!event.IsAllowed()) {
            return false;
        }
    }

    wxWindow* win = GetPage(page);
    win->Disconnect(wxEVT_KEY_DOWN, wxKeyEventHandler(Notebook::OnKeyDown),  NULL, this);

    bool rc = wxNotebook::RemovePage(page);
    if (rc) {
        GTKDeletePgInfo(win);
        PopPageHistory(win);
    }

    if (rc && notify) {
        //send event to noitfy that the page has been closed
        NotebookEvent event(wxEVT_COMMAND_BOOK_PAGE_CLOSED, GetId());
        event.SetSelection( page );
        event.SetEventObject( this );
        GetEventHandler()->ProcessEvent(event);
    }

    return rc;
}