示例#1
0
文件: ASI.cpp 项目: romoadri21/boi
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;
}
示例#2
0
文件: ASI.cpp 项目: romoadri21/boi
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();
    }
}
示例#3
0
文件: ASI.cpp 项目: romoadri21/boi
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();
    }
}