예제 #1
0
CLibraryTileView::iterator CLibraryTileView::HitTest(const CPoint& point)
{
	ASSUME_LOCK( Library.m_pSection );

	CRect rcClient;
	GetClientRect( &rcClient );

	CPoint pt( rcClient.left, rcClient.top - m_nScroll );

	for ( iterator pTile = begin(); pTile != end() && pt.y < rcClient.bottom; ++pTile )
	{
		CRect rcBlock( pt.x, pt.y, pt.x + m_szBlock.cx, pt.y + m_szBlock.cy );

		if ( rcBlock.PtInRect( point ) )
			return pTile;

		pt.x += m_szBlock.cx;

		if ( pt.x + m_szBlock.cx > rcClient.right )
		{
			pt.x = rcClient.left;
			pt.y += m_szBlock.cy;
		}
	}

	return end();
}
예제 #2
0
bool CLibraryTileView::GetItemRect(iterator pTile, CRect* pRect)
{
	CSingleLock oLock( &Library.m_pSection );
	if ( ! oLock.Lock( 200 ) )
		return false;

	CRect rcClient;
	GetClientRect( &rcClient );

	CPoint pt( rcClient.left, rcClient.top - m_nScroll );

	for ( iterator pItem = begin(); pItem != end(); ++pItem )
	{
		CRect rcBlock( pt.x, pt.y, pt.x + m_szBlock.cx, pt.y + m_szBlock.cy );

		if ( pTile == pItem )
		{
			*pRect = rcBlock;
			return true;
		}

		pt.x += m_szBlock.cx;

		if ( pt.x + m_szBlock.cx > rcClient.right )
		{
			pt.x = rcClient.left;
			pt.y += m_szBlock.cy;
		}
	}

	return false;
}
예제 #3
0
void CLibraryTileView::OnPaint()
{
	CPaintDC dc( this );

	CDC* pBuffer = CoolInterface.GetBuffer( dc, m_szBlock );
	CRect rcBuffer( 0, 0, m_szBlock.cx, m_szBlock.cy );

	CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal );
	pBuffer->SetBkMode( OPAQUE );
	pBuffer->SetBkColor( Colors.m_crWindow );
	pBuffer->SetTextColor( Colors.m_crText );

	CDC dcMem;
	dcMem.CreateCompatibleDC( &dc );

	CRect rcClient;
	GetClientRect( &rcClient );
	CPoint pt( rcClient.left, rcClient.top - m_nScroll );

	CSingleLock oLock( &Library.m_pSection );
	if ( oLock.Lock( 100 ) )
	{
		for ( iterator pTile = begin(); pTile != end() && pt.y < rcClient.bottom; ++pTile )
		{
			CRect rcBlock( pt.x, pt.y, pt.x + m_szBlock.cx, pt.y + m_szBlock.cy );

			if ( rcBlock.bottom >= rcClient.top && dc.RectVisible( &rcBlock ) )
			{
				pBuffer->FillSolidRect( &rcBuffer, Colors.m_crWindow );
				bool bSelected = (*pTile)->m_bSelected;
				CAlbumFolder* pAlbum = (*pTile)->GetAlbum();
				if ( pAlbum && m_oDropItem == CLibraryListItem( pAlbum ) )
					(*pTile)->m_bSelected = true;

				(*pTile)->Paint( pBuffer, rcBuffer, &dcMem, pTile == m_pFocus );
				(*pTile)->m_bSelected = bSelected;
				dc.BitBlt( rcBlock.left, rcBlock.top, m_szBlock.cx, m_szBlock.cy, pBuffer, 0, 0, SRCCOPY );
				dc.ExcludeClipRect( &rcBlock );
			}

			pt.x += m_szBlock.cx;

			if ( pt.x + m_szBlock.cx > rcClient.right )
			{
				pt.x = rcClient.left;
				pt.y += m_szBlock.cy;
			}
		}
	}
	else
	{
		Invalidate( FALSE );
	}

	pBuffer->SelectObject( pOldFont );
	dc.FillSolidRect( &rcClient, Colors.m_crWindow );
}
예제 #4
0
void CTestScrollView::DrawView( CDC* pDC )
{
	CRect rcView = GetClientViewRect();
	CSize szView = GetViewSize();
	if (rcView.IsRectEmpty())
	{
		return;
	}
	rcView.OffsetRect(-GetViewOffsetPoint());
	//TRACE("\nview left = %d", rcView.left);
	for(int i = rcView.left, k = 0; i < rcView.left + szView.cx; i+=20,k++)
	{
		for (int j = rcView.top,h = 0; j < rcView.top + szView.cy; j+=20,h++)
		{
			if ((i >= -20 || j >= -20) && (i <= szView.cx + 20 || j <= szView.cy + 20))
			{
				CRect rcBlock(i, j, i+20,j+20);
				pDC->FillSolidRect(rcBlock, RGB((k*20%256), (h*20%256), (255-(k+h)*10%256)));

			}

		}
	}
}