Esempio n. 1
0
void GUIWindow::AddChild(GUIWindow *child)
{
	// Check if the request is valid.
	if (child->Parent != 0)
	{
		MessageBoxA(0, "Tried to add a child window that already has a parent to another window!", "Error!", MB_OK);
		return;
	}

	child->Parent = this;
	Children.push_back(child);

	// Make recently added children instantly active.
	if (!child->Active())
	{
		SetActiveChild(child);
	}
}
Esempio n. 2
0
void wxGenericMDIParentFrame::WXRemoveChild(wxGenericMDIChildFrame *child)
{
    const bool removingActive = WXIsActiveChild(child);
    if ( removingActive )
    {
        SetActiveChild(NULL);
        WXSetChildMenuBar(NULL);
    }

    wxGenericMDIClientWindow * const client = GetGenericClientWindow();
    wxCHECK_RET( client, "should have client window" );

    wxBookCtrlBase * const book = client->GetBookCtrl();

    // Remove page if still there
    int pos = client->FindChild(child);
    if ( pos != wxNOT_FOUND )
    {
        if ( book->RemovePage(pos) )
            book->Refresh();
    }

    if ( removingActive )
    {
        // Set the new selection to a remaining page
        const size_t count = book->GetPageCount();
        if ( count > (size_t)pos )
        {
            book->SetSelection(pos);
        }
        else
        {
            if ( count > 0 )
                book->SetSelection(count - 1);
        }
    }
}