예제 #1
0
파일: CtrlPage.cpp 프로젝트: twkevin/ddz
int CCtrlPage::AddPageItem(CCMyDialog* lpObj, bool bAutoDestory)
{
	if (NULL == lpObj)
	{
		return -1;
	}

	lpObj->Create(lpObj->getWndID(), this);
	lpObj->setVisible(true);

	LPPageItemAtt pPageItem = new PageItemAtt;
	pPageItem->pObj = lpObj;
	pPageItem->bAutoDestory = bAutoDestory;
	pPageItem->m_dwData = NULL;
	pPageItem->nWidth = getWidth();
	pPageItem->nHeight = getHeight();
	m_vecPageItem.push_back(pPageItem);

	if (m_pScrollView)
	{
		m_pScrollView->addChild(lpObj, 0, lpObj->GetHandle());
	}

	ResetPagePos();
	return m_vecPageItem.size() - 1;
}
예제 #2
0
/**
Implementation of pure virtual function.
@see    MWTCacheInterface::InvalidateCache()
*/
void CDynamicDirCache::InvalidateCache(void)
    {
    __PRINT2(_L("CDynamicDirCache::InvalidateCache(locked=%d, unlocked=%d)"), iLockedQCount, iUnlockedQCount);
    // we should never decommit locked pages as they needs to be reserved anyway
    // the overhead of unnecessary page committing operations
    while(!iLockedQ.IsEmpty())
        {
        TDynamicDirCachePage* page = iLockedQ.Last();
        DeQueue(page);                      // remove from queue
        LookupTblRemove(page->StartPos());  // remove from lookuptable
        delete page;
        }
    ASSERT(iLockedQCount == 0);

    // however we should decommit unlocked pages here
    while (!iUnlockedQ.IsEmpty())
        {
        TDynamicDirCachePage* page = iUnlockedQ.Last();
        DeQueue(page);                      // remove from queue
        LookupTblRemove(page->StartPos());  // remove from lookuptable
        DecommitPage(page);                 // inform cache client to decommit page memory
        delete page;
        }
    ASSERT(iUnlockedQCount == 0);

    ASSERT(iLookupTable.Count() == 0);
    iLookupTable.Close();

    ASSERT(iCacheMemoryClient);

    // initialize cache state.
    // Note that once the client is reset, all pages lose connection with the client
    //  including the active page. So we will need to reset and re-allocate active page
    //  properly.
    if (iCacheMemoryClient)
        iCacheMemoryClient->Reset();

    // reset and re-allocate active page
    ResetPagePos(iActivePage);              // reset start media position (0), invalidate page content
    TUint8* startRamAddr = iCacheMemoryClient->AllocateAndLockSegments(PageSizeInSegs());
    // this should always succeed as the client has just been reset and there are always reserved pages
    ASSERT(startRamAddr);
    iActivePage->SetStartPtr(startRamAddr); // set RAM address
    }
예제 #3
0
파일: CtrlPage.cpp 프로젝트: twkevin/ddz
//#hy: 会崩溃,暂时不要调用
void CCtrlPage::RemovePageItem(int nIndex)
{
	if (static_cast<int>(m_vecPageItem.size()) <= nIndex || 0 > nIndex)
	{
		return ;
	}

	VECPAGES::iterator it = m_vecPageItem.begin();
	std::advance(it, nIndex);
	LPPageItemAtt pItem = *it;

	if (NULL != pItem && NULL != pItem->pObj)
	{
		if (m_pScrollView)
		{
			CCNode* pContainer = m_pScrollView->getContainer();
			if (pContainer)
			{
				pContainer->removeChild(pItem->pObj, true);
			}
		}

		if (pItem->bAutoDestory)
		{
			CC_SAFE_RELEASE(pItem->pObj);
		}
	}

	CC_SAFE_DELETE(pItem);
	m_vecPageItem.erase(it);

	if (0 == m_vecPageItem.size())
	{
		m_nPageIndex = -1;
	}

	ResetPagePos();
}
예제 #4
0
/**
Implementation of pure virtual function.
@see    MWTCacheInterface::MakePageMRU()
*/
void CDynamicDirCache::MakePageMRU(TInt64 aPos)
    {
    __PRINT1(_L("MakePageMRU (%lx)"), aPos);
//  __PRINT4(_L("Current Cache State: iLockedQCount=%d, iUnlockedQCount=%d, iLookupTbl=%d, iMaxSizeInPages=%d"), iLockedQCount, iUnlockedQCount, iLookupTable.Count(), iMaxSizeInPages);
    // check the MRU page first, if it is already the MRU page, we can return immediately
    TInt64 pageStartMedPos = CalcPageStartPos(aPos);
    if (!iLockedQ.IsEmpty())
        {
        if (iLockedQ.First()->StartPos() == pageStartMedPos)
            {
            return;
            }
        }

    TDynamicDirCachePage* pPage = FindPageByPos(aPos);
    if (pPage)
        {
        ASSERT(pPage->IsValid());
        // lock page before make it MRU
        if (pPage->PageType() == TDynamicDirCachePage::EUnlocked)
            {
            ASSERT(!pPage->IsLocked());
            if (LockPage(pPage) == NULL)
                {
                DeQueue(pPage);
                LookupTblRemove(pPage->StartPos());
                DecommitPage(pPage);
                delete pPage;
                pPage = NULL;
                }
            }
        else
            {
            // error checking: page should either be locked or active
            ASSERT(LockPage(pPage) != NULL);
            }
        }

    // if page not found or page data not valid anymore, use active page to read data
    if (!pPage)
        {
        TRAPD(err, pPage = UpdateActivePageL(aPos));
        if (err != KErrNone)
            {
            // problem occurred reading active page, return immediately.
            return;
            }
        }

    // by now, the page is either locked or active page
    ASSERT(pPage && pPage->IsValid() && pPage->IsLocked());

    switch (pPage->PageType())
        {
        // if the page is the active page, we will need to find a new active page for replacement
        case TDynamicDirCachePage::EActivePage:
            {
            TDynamicDirCachePage* newAP = NULL;
            // if there is more cache room available, try to create a new page first
            if (!CacheIsFull())
                {
                // allocate and lock a new page
                TRAPD(err, newAP = AllocateAndLockNewPageL(0));
                // if any error ocurrs, return immediately
                if (err != KErrNone)
                    {
                    // unlock the page that was originally unlocked before leave
                    if (pPage->PageType() == TDynamicDirCachePage::EUnlocked)
                        {
                        UnlockPage(pPage);
                        }
                    return;
                    }

                if (newAP)
                    {
                    // replace the active page with the new page
                    newAP->SetPageType(TDynamicDirCachePage::EActivePage);
                    iActivePage = newAP;
                    }
                }

            // if cache has grown to its max size, or new page allocation failed
            if (!newAP)
                {
                // try to lock the LRU page on the unlocked page queque first
                if (!iUnlockedQ.IsEmpty())
                    {
                    newAP = iUnlockedQ.Last();
                    ASSERT(newAP->IsValid());
                    if (LockPage(newAP) != NULL)
                        {
                        // deque, reset pos, set new type
                        DeQueue(newAP);
                        LookupTblRemove(newAP->StartPos());
                        ResetPagePos(newAP);
                        newAP->SetPageType(TDynamicDirCachePage::EActivePage);
                        // replace active page
                        iActivePage = newAP;
                        }
                    // if falied locking the LRU page from unclocked queque,
                    // delete it
                    else
                        {
                        DeQueue(newAP);
                        LookupTblRemove(newAP->StartPos());
                        DecommitPage(newAP);
                        delete newAP;
                        newAP = NULL;
                        }
                    }
                }

            // if still have not found new active page
            // grab the LRU page from Locked Page Queue for active page
            if (!newAP)
                {
                ASSERT(!iLockedQ.IsEmpty());
                newAP = iLockedQ.Last();
                // deque, reset pos, set new type
                DeQueue(newAP);
                LookupTblRemove(newAP->StartPos());
                ResetPagePos(newAP);
                newAP->SetPageType(TDynamicDirCachePage::EActivePage);
                // replace active page
                iActivePage = newAP;
                }

            // we should always be able to find a locked page for active page
            ASSERT(newAP != NULL);

            // make original page (i.e. former active page) MRU
            // add onto locked queue
            AddFirstOntoQueue(pPage, TDynamicDirCachePage::ELocked);
            // add onto lookuptbl, as active page is not on lookup tbl originally
            LookupTblAdd(pPage);
            // check cache limit
            CheckThresholds();
            return;
            }
        case TDynamicDirCachePage::EUnlocked:
            {
            // if page was originally on Unlocked Page Queque, remove it from Unlocked Page Queue, add it
            // to the Locked Page Queue and make it MRU
            DeQueue(pPage);
            AddFirstOntoQueue(pPage, TDynamicDirCachePage::ELocked);
            // check cache limit
            CheckThresholds();
            return;
            }
        case TDynamicDirCachePage::ELocked:
            {
            // otherwise the page was on Locked Page Queue, make it MRU
            // no need to check cache limit
            if (pPage != iLockedQ.First())
                {
                DeQueue(pPage);
                AddFirstOntoQueue(pPage, TDynamicDirCachePage::ELocked);
                return;
                }
            break;
            }
        default:
            ASSERT(0);
        }
    }
예제 #5
0
파일: WinMain.cpp 프로젝트: ylca/XCGUI
	void SetLabelDirection(tabbar_direction_ nDirection)
	{
		m_Direction = nDirection;

		if (nDirection == tabbar_direction_left ||
			nDirection == tabbar_direction_right)
		{
			XSView_ShowSBarV(m_hSview,TRUE);
			XSView_ShowSBarH(m_hSview,FALSE);
			XSView_ScrollPosV(m_hSview,0);
			XSView_ScrollPosH(m_hSview,0);
			m_bHorizon = FALSE;
		}else
		{
			XSView_ShowSBarV(m_hSview,FALSE);
			XSView_ShowSBarH(m_hSview,TRUE);
			XSView_ScrollPosH(m_hSview,0);
			XSView_ScrollPosV(m_hSview,0);
			m_bHorizon = TRUE;
		}


		int labelSize = GetLableSize();
		if (m_bHorizon)
		{
			ReSizeView(labelSize);
		}else
		{
			ReSizeView(labelSize);
		}




		RECT rtView;
		RECT rtTabBar;
		XEle_GetClientRect(m_hEle,&rtTabBar);
		switch (m_Direction)
		{
		case tabbar_direction_left:
			{
				rtView.left = 0;
				rtView.top  = 0;
				rtView.right = m_ViewWidth;
				rtView.bottom = rtTabBar.bottom;
			}
			break;
		case tabbar_direction_top:
			{
				rtView.left = 0;
				rtView.top  = 0;
				rtView.right = rtTabBar.right;
				rtView.bottom = m_ViewHeight;
			}
			break;
		case tabbar_direction_right:
			{
				rtView.left = rtTabBar.right - m_ViewWidth;
				rtView.top  = 0;
				rtView.right = rtTabBar.right;
				rtView.bottom = rtTabBar.bottom;
			}
			break;
		case tabbar_direction_bottom:
			{
				rtView.top = rtTabBar.bottom - m_ViewHeight;
				rtView.left = 0;
				rtView.right = rtTabBar.right;
				rtView.bottom = rtTabBar.bottom;
			}
			break;
		}
		XEle_SetRect(m_hSview,&rtView);


		 
		ResetBtnPos();
		ResetPagePos();
		XEle_RedrawEle(m_hEle);
	}