Example #1
0
void ASI::EmitTo(CRef& cref, int receiver, DRef& data, bool release)
{
    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        pComponent->PostToReceiver(receiver, data, release);
        cref.ReleaseInstance();
    }
}
Example #2
0
void ASI::DisconnectFromReceiver(CRef& src, int emitter, CRef& target)
{
    Component* pComponent = src.GetInstance();
    if (pComponent != NULL)
    {
        pComponent->DisconnectFromReceiver(emitter, target);
        src.ReleaseInstance();
    }
}
Example #3
0
void ASI::SetFlag(CRef& cref, ComponentFlag flag, bool enabled)
{
    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        pComponent->SetFlag(flag, enabled);
        cref.ReleaseInstance();
    }
}
Example #4
0
void ASI::RemoveFromLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if (pComponent->m_pData->inLayout &&
                    IsParent(pLayoutComponent, pComponent))
                {
                    /*
                     * Tell the layout component to remove
                     * the item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 2, dref, true);

                    DisconnectFromReceiver(pLayoutComponent, emitter, cref);
                    DisconnectFromReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout);

                    pComponent->m_pData->inLayout = false;

                    CRef invalidCRef;
                    pComponent->SetParent(invalidCRef);
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
Example #5
0
void ASI::AddToLayout(CRef& cref, CRef& layout)
{
    Component* pLayoutComponent = layout.GetInstance();
    if (pLayoutComponent != NULL)
    {
        int funcSet  = pLayoutComponent->GetFuncSet("{f742f223-bb7b-48f0-92a8-81702e14de16}");
        int emitter  = pLayoutComponent->GetEmitter("{b11a0db4-cb96-4bf6-9631-fd96f20ea6ab}");
        int receiver = pLayoutComponent->GetReceiver("{6a7ab00f-1ab4-4324-9eb4-e614bfca4a16}");

        if ((funcSet  != -1) &&
            (emitter  != -1) &&
            (receiver != -1))
        {
            Component* pComponent = cref.GetInstance();
            if (pComponent != NULL)
            {
                if ((!pComponent->m_pData->inLayout) &&
                    (pComponent != pLayoutComponent))
                {
                    pComponent->SetParent(layout);

                    /*
                     * Tell the layout component to add
                     * a new item with the given CRef id.
                     */
                    DRef dref = NewData(BOI_STD_D(Int));
                    *dref.GetWriteInstance<int>() = cref.Id();
                    pLayoutComponent->CallFunc(funcSet, 1, dref, true);

                    ConnectToReceiver(pLayoutComponent, emitter, cref, BOI_STD_R(SetPosition));
                    ConnectToReceiver(pComponent, BOI_STD_E(ParentBoundingBox), layout, receiver);

                    pComponent->m_pData->inLayout = true;
                }

                cref.ReleaseInstance();
            }
        }

        layout.ReleaseInstance();
    }
}
Example #6
0
bool ASI::ConnectToReceiver(CRef src, int emitter, CRef target, int receiver)
{
    bool connected = false;

    Component* pComponent = src.GetInstance();
    if (pComponent != NULL)
    {
        connected = pComponent->ConnectToReceiver(emitter, target, receiver);
        src.ReleaseInstance();
    }

    return connected;
}
Example #7
0
bool ASI::ConnectToFuncSet(CRef src, int caller, CRef target, int funcSet)
{
    bool connected = false;

    Component* pComponent = src.GetInstance();
    if (pComponent != NULL)
    {
        connected = pComponent->ConnectToFuncSet(caller, target, funcSet);
        src.ReleaseInstance();
    }

    return connected;
}
Example #8
0
int ASI::GetReceiver(CRef& cref, const QString& uuid)
{
    int receiver = -1;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        receiver = pComponent->GetReceiver(uuid);
        cref.ReleaseInstance();
    }

    return receiver;
}
Example #9
0
int ASI::GetFuncSet(CRef& cref, const QString& uuid)
{
    int funcSet = -1;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        funcSet = pComponent->GetFuncSet(uuid);
        cref.ReleaseInstance();
    }

    return funcSet;
}
Example #10
0
void ASI::SetParent(CRef& cref, CRef& parent)
{
    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        if (!pComponent->m_pData->inLayout)
        {
            pComponent->SetParent(parent);
        }

        cref.ReleaseInstance();
    }
}
Example #11
0
bool ASI::IsSelected(CRef& cref)
{
    bool selected = false;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        selected = pComponent->m_pData->selected;
        cref.ReleaseInstance();
    }

    return selected;
}
Example #12
0
const QStringList ASI::GetProfile(CRef& cref, ProfileType type)
{
    QStringList list;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        list = pComponent->GetProfile(type);
        cref.ReleaseInstance();
    }

    return list;
}
Example #13
0
bool ASI::DisconnectFromFuncSet(CRef& src, int caller)
{
    bool disconnected = true;

    Component* pComponent = src.GetInstance();
    if (pComponent != NULL)
    {
        disconnected = pComponent->DisconnectFromFuncSet(caller);
        src.ReleaseInstance();
    }

    return disconnected;
}
Example #14
0
DRef ASI::CallFunc(CRef& cref, int funcSet, int func, DRef& dref, bool passThru)
{
    DRef result;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        result = pComponent->CallFunc(funcSet, func, dref, passThru);
        cref.ReleaseInstance();
    }

    return result;
}
Example #15
0
QPointF ASI::MapFromViewToParent(CRef& cref, const QPoint& point)
{
    QPointF mappedPoint;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        mappedPoint = m_pView->MapToParent(&pComponent->m_pData->graphicsItem, point);

        cref.ReleaseInstance();
    }

    return mappedPoint;
}
Example #16
0
void ASI::SetSelection(CRefList crefList)
{
    CRefList prevSelection = m_pState->Selection();

    int numCRefs = prevSelection.Count();
    for (int i=0; i < numCRefs; i++)
    {
        CRef cref = prevSelection.Value(i);

        Component* pComponent = cref.GetInstance();
        if (pComponent != NULL)
        {
            pComponent->m_pData->selected = false;
            pComponent->Update();

            cref.ReleaseInstance();
        }
    }


    numCRefs = crefList.Count();
    for (int i=0; i < numCRefs; i++)
    {
        CRef cref = crefList.Value(i);

        Component* pComponent = cref.GetInstance();
        if (pComponent != NULL)
        {
            pComponent->m_pData->selected = true;
            pComponent->Update();

            cref.ReleaseInstance();
        }
    }

    m_pState->SetSelection(crefList);
}
Example #17
0
QPointF ASI::MapToParent(CRef& cref, const QPointF& point)
{
    QPointF mappedPoint;

    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        GraphicsItem* pItem = &pComponent->m_pData->graphicsItem;
        mappedPoint = pItem->mapToParent(point);

        cref.ReleaseInstance();
    }

    return mappedPoint;
}
Example #18
0
bool ASI::IsParent(CRef& parent, CRef& child)
{
    bool isParent = false;

    Component* pParent = parent.GetInstance();
    if (pParent != NULL)
    {
        Component* pChild = child.GetInstance();
        if (pChild != NULL)
        {
            if (pChild->m_pData->graphicsItem.parentItem() ==
                &pParent->m_pData->graphicsItem)
            {
                isParent = true;
            }

            child.ReleaseInstance();
        }

        parent.ReleaseInstance();
    }

    return isParent;
}
Example #19
0
void ASI::GetMenus(CRef& cref, MenuSet& menuSet)
{
    int type = cref.Type();

    if (!m_pMenuManager->GetMenus(type, menuSet))
    {
        menuSet.Clear();

        Component* pComponent = cref.GetInstance();
        if (pComponent != NULL)
        {
            const QStringList profile = pComponent->GetProfile();

            m_pMenuManager->GetMenus(profile, menuSet, type);

            cref.ReleaseInstance();
        }
    }
}
Example #20
0
void ASI::SetPosition(CRef cref, const QPointF& pos)
{
    Component* pComponent = cref.GetInstance();
    if (pComponent != NULL)
    {
        if (!pComponent->m_pData->inLayout)
        {
            GuiRequest request;

            request.cref = cref;
            request.data.point.x = pos.x();
            request.data.point.y = pos.y();
            request.type = GuiRequest::RequestType_SetPosition;

            m_pGuiRequestHandler->PostRequest(&request);
        }

        cref.ReleaseInstance();
    }
}