Exemplo n.º 1
0
void Stage::DestroyElement(ElementPtr inElement) {
    wxString name = inElement->GetName();

    // Make sure this element isn't on our drawing context stack.
    if (mDrawingContextStack->ContainsElement(inElement))
        gLog.Fatal("halyard.element",
                   "%s: Tried to delete element with an active drawing context",
                   inElement->GetLogName());

    // Clean up any dangling references to this object.
    if (inElement == mGrabbedElement)
        MouseUngrab(mGrabbedElement);
    if (inElement == mCurrentElement)
        mCurrentElement = ElementPtr();
    if (inElement == mCurrentElementNamedInStatusBar)
        mCurrentElementNamedInStatusBar = ElementPtr();
    MediaElementPtr as_media(inElement, dynamic_cast_tag());
    if (as_media && as_media == mWaitElement)
        EndWait();

    // If the element we're deleting is a CursorElement, then we need to
    // tell it to unregister itself, and then update the cursor we're
    // displaying in case it has changed.  This takes care of
    // mDesiredCursor and mActualCursor.
    shared_ptr<CursorElement> as_cursor_elem(inElement, dynamic_cast_tag());
    if (as_cursor_elem) {
        as_cursor_elem->UnregisterWithCursorManager(mCursorManager);

        Cursor *as_cursor(static_cast<Cursor*>(as_cursor_elem.get()));
        if (as_cursor == mDesiredCursor)
            ReplaceDisplayedCursorWithDefault();
        ASSERT(as_cursor != mDesiredCursor);
        ASSERT(as_cursor != mActualCursor);
    }

    // We don't have to destroy the object explicity, because the
    // ElementPtr smart-pointer class will take care of that for us.
    //
    // TODO - Implemented delayed destruction so element callbacks can
    // destroy the element they're attached to.

    gLog.Trace("halyard.element", "%s: Removed from stage",
               inElement->GetLogName());
}
Exemplo n.º 2
0
void Stage::AddElement(ElementPtr inElement) {
    // Delete any existing Element with the same name.
    (void) DeleteElementByName(inElement->GetName());

    // Add the new Element to our list.
    gLog.Trace("halyard.element", "%s: Added to stage",
               inElement->GetLogName());
    mElements.push_back(inElement);
    NotifyElementsChanged();
}