Exemple #1
0
BOOL SGifPlayer::_PlayFile( LPCTSTR pszFileName, BOOL bGif )
{
    SStringW key=S_CT2W(pszFileName);
    SSkinPool *pBuiltinSkinPool = SSkinPoolMgr::getSingletonPtr()->GetBuiltinSkinPool();
    ISkinObj *pSkin=pBuiltinSkinPool->GetSkin(key);
    if(pSkin)
    {
        if(!pSkin->IsClass(SSkinAni::GetClassName())) return FALSE;
        m_aniSkin=static_cast<SSkinAni*>(pSkin);
    }else
    {
        SSkinAni *pGifSkin = (SSkinAni*)SApplication::getSingleton().CreateSkinByName(bGif?SSkinGif::GetClassName():SSkinAPNG::GetClassName());
        if(!pGifSkin) return FALSE;
        if(0==pGifSkin->LoadFromFile(pszFileName))
        {
            pGifSkin->Release();
            return FALSE;
        }

        pBuiltinSkinPool->AddKeyObject(key,pGifSkin);//将创建的skin交给skinpool管理
        m_aniSkin = pGifSkin;
    }
    if(m_layout.IsFitContent())
    {
        GetParent()->UpdateChildrenPosition();
    }
	if(IsVisible(TRUE))
	{
		GetContainer()->RegisterTimelineHandler(this);
	}
    return TRUE;
}
Exemple #2
0
BOOL SApplication::Init( LPCTSTR pszName ,LPCTSTR pszType)
{
    SASSERT(m_RenderFactory);

    pugi::xml_document xmlDoc;
    if(!LOADXML(xmlDoc,pszName,pszType)) return FALSE;
    pugi::xml_node root=xmlDoc.child(L"UIDEF");
    if(!root) return FALSE;

    //set default font
    pugi::xml_node xmlFont;
    xmlFont=root.child(L"font");
    if(xmlFont)
    {
        int nSize=xmlFont.attribute(L"size").as_int(12);
        BYTE byCharset=(BYTE)xmlFont.attribute(L"charset").as_int(DEFAULT_CHARSET);
        SFontPool::getSingleton().SetDefaultFont(S_CW2T(xmlFont.attribute(L"face").value()),nSize,byCharset);
    }
    
    SStringPool::getSingleton().Init(root.child(L"string"));
    SNamedID::getSingleton().Init(root.child(L"id"));

    SSkinPool *pSkinPool = new SSkinPool;
    pSkinPool->LoadSkins(root.child(L"skin"));
    SSkinPoolMgr::getSingletonPtr()->PushSkinPool(pSkinPool);
    pSkinPool->Release();
    
    SStylePool *pStylePool = new SStylePool;
    pStylePool->Init(root.child(L"style"));
    SStylePoolMgr::getSingleton().PushStylePool(pStylePool);
    pStylePool->Release();
    
    SObjDefAttr::getSingleton().Init(root.child(L"objattr"));
    return TRUE;
}
Exemple #3
0
BOOL SImagePlayer::_PlayFile( LPCTSTR pszFileName, BOOL bGif )
{
    SStringW key=S_CT2W(pszFileName);
    SSkinPool *pBuiltinSkinPool = SSkinPoolMgr::getSingletonPtr()->GetBuiltinSkinPool();
    ISkinObj *pSkin=pBuiltinSkinPool->GetSkin(key);
    if(pSkin)
    {
        if(!pSkin->IsClass(SSkinAni::GetClassName())) return FALSE;
        m_aniSkin=static_cast<SSkinAni*>(pSkin);
    }else
    {
        SSkinAni *pGifSkin = (SSkinAni*)SApplication::getSingleton().CreateSkinByName(SSkinMutiFrameImg::GetClassName());
        if(!pGifSkin) return FALSE;
        if(0==pGifSkin->LoadFromFile(pszFileName))
        {
            pGifSkin->Release();
            return FALSE;
        }

        pBuiltinSkinPool->AddKeyObject(key,pGifSkin);//将创建的skin交给skinpool管理
        m_aniSkin = pGifSkin;
    }
    if(m_layout.IsFitContent())
    {
        GetParent()->UpdateChildrenPosition();
    }
    OnShowWindow(TRUE, NormalShow);
    return TRUE;
}
Exemple #4
0
SSkinPoolMgr::~SSkinPoolMgr()
{
    POSITION pos=m_lstSkinPools.GetHeadPosition();
    while(pos)
    {
        SSkinPool *p = m_lstSkinPools.GetNext(pos);
        p->Release();
    }
    m_lstSkinPools.RemoveAll();

}