コード例 #1
0
ファイル: ILayoutItem.cpp プロジェクト: mengskysama/V8
tagSIZE ILayoutItem::GetRootOffset()
{
    CSize szOffset(0, 0);
    ILayout* pLayout = GetLayout();
    while (pLayout != NULL) {
        CRect rc = pLayout->GetRect();
        szOffset.cx += rc.left;
        szOffset.cy += rc.top;
    }

    return szOffset;
}
コード例 #2
0
// ****************************************************************************
//
//  Function Name:	BitmapImageList::Add()
//
//  Description:		Adds one or more images or an icon to the image 
//                   list.
//
//  Returns:			Zero-based index of the first new image if 
//                   successful; otherwise -1.
//
//  Exceptions:		None
//
// ****************************************************************************
int RBitmapImageList::Add( RBitmapImage* pbmImage, RBitmapImage* pbmMask )
{
	int nImageIndex = m_ulImageCount ;

	if (!m_ulImageCount)
	{
		// Copy the palette of the incoming image
	}

	RIntRect rcDestRect(0, 0, 
		pbmImage->GetWidthInPixels(), 
		pbmImage->GetHeightInPixels()) ;

	RIntSize szOffset((m_ulImageCount - 1) * m_szImage.m_dx, 0) ;
	rcDestRect.Offset( szOffset ) ;

	while (GetWidthInPixels() < (uLONG) rcDestRect.m_Right)
	{
		uLONG cx = GetWidthInPixels() + m_uwGrow * m_szImage.m_dx ;
		uLONG cy = GetHeightInPixels() ;

		// Resize the bitmaps
//		Resize( cx, cy ) ;
		
		if (m_fMask)
		{
//			m_bmMask.Resize( cx, cy ) ;
		}
	}

	ROffscreenDrawingSurface dsMem ;

	dsMem.SetImage( (RBitmapImage*) this ) ;
	pbmImage->Render( dsMem, rcDestRect ) ;
	dsMem.ReleaseImage() ;

	if (m_fMask)
	{
		dsMem.SetImage( &m_bmMask ) ;
		pbmMask->Render( dsMem, rcDestRect ) ;
		dsMem.ReleaseImage() ;
	}

	// Update the image count
	m_ulImageCount += pbmImage->GetWidthInPixels() / m_szImage.m_dx ;

	return nImageIndex ;
}
コード例 #3
0
// ****************************************************************************
//
//  Function Name:	BitmapImageList::Render()
//
//  Description:		Renders the specified image onto the drawing
//							surface int the specified style.
//
//  Returns:			TRUE if successful; otherwise FALSE.
//
//  Exceptions:		None
//
// ****************************************************************************
BOOLEAN RBitmapImageList::Render( RDrawingSurface& ds, int nImage, RIntRect rcDestRect, uLONG ulStyle )
{
	if ((uLONG) nImage < 0 || (uLONG) nImage > m_ulImageCount)
	{
		return FALSE ;
	}

	int nCols = GetWidthInPixels() / m_szImage.m_dx ;

	RIntSize szOffset( 
		nImage % nCols * m_szImage.m_dx, 
		nImage / nCols * m_szImage.m_dy ) ;

	RIntRect rcSrcRect( 0, 0, m_szImage.m_dx, m_szImage.m_dy ) ;
	rcSrcRect.Offset( szOffset ) ;

	if (!m_fMask)
	{
		// If there is no mask, the bitmap will always be drawn normal
		RBitmapImage::Render( ds, rcSrcRect, rcDestRect ) ;
	}
	else
	{
		//
		// Render the bitmap in the appropriate style
		//
		switch (ulStyle)
		{
		case kNormal:
			RBitmapImage::Render( ds, rcSrcRect, rcDestRect ) ;
			break ;

		case kTransparent:
			RBitmapImage::RenderWithMask( ds, m_bmMask, rcSrcRect, rcDestRect ) ;
			break ;

		default:
			TpsAssertAlways( "Not yet implemented!" ) ;
		}
	}

	return TRUE ;
}
コード例 #4
0
ファイル: HlprFuncs.cpp プロジェクト: jiazhy-zhiyuan/TANGRAM
//***************************************************************************
//
//
//***************************************************************************
BOOL DrawVerticalText
( 
	CDC* pDC, 
	const CRect& rectWindow, 
	CString szcText, 
	const DWORD dwStyle 
)
{
	int nSavedDC = pDC->SaveDC();

	//
    // Start by getting this control's font, and then tweak it a bit.
	//

	LOGFONT lf;
	CFont *pTmpFont = pDC->GetCurrentFont();

	if( NULL == pTmpFont )
	{
		ASSERT( pTmpFont );  // Font not selected in DC!
		return FALSE;
	}

	pTmpFont->GetObject( sizeof(LOGFONT), &lf );
	
	//
    // Text will be rotated counter-clockwise 90 degrees.
	//
	lf.lfOrientation = lf.lfEscapement = 900;

	//
    // We need a TrueType font to get rotated text.  MS Sans Serif
    // won't cut it!  Opps!  A hard coded string!  
	//
    lstrcpy( lf.lfFaceName, _T("Tahoma") );

	//
	// Create a font with the tweaked attributes.
	//
    CFont font;
    if( FALSE == font.CreateFontIndirect( &lf ) )
	{
		TRACE2("Error creating font! Line: %d, File: %s\n", __LINE__, __FILE__ );
		return FALSE;
	}

	CFont *pfontOld = pDC->SelectObject( &font );


	CRect rectText( rectWindow );

	//
	// Compute size of horizontal oriented string
	//
	pDC->DrawText ( CString(szcText), 
		            rectText,
                    DT_LEFT 
				   |DT_TOP 
				   |DT_CALCRECT 
				   |DT_SINGLELINE );

	//
    // Dependence on format flags, compute offset of text rectangle
	// Horizontal offset is constant for all formats
	// Vertical offset depend on format
	//
	CSize szOffset(0,0);
    if ( dwStyle & SS_CENTER )
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              -(rectWindow.Height()-rectText.Width())/2+rectText.Height() );
	}
    else if ( dwStyle & SS_RIGHT )
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              -rectWindow.Height()+rectText.Width()+rectText.Height() );
	}
    else
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              rectText.Height() );
	}
	
	//
	// Convert dimensions of horizontal oriented rectangle 
	// to dimensions of vertical oriented rectangle 
	// (swap horizontal and vertical sizes)
	// rectText.SetRect( rectWindow.left, 0, rectWindow.left + rectText.Height(), rectWindow.Height());
	// rectText.SetRect( rectWindow.left, rectWindow.top, rectText.right, rectWindow.Height());
	//

	rectText.top    = rectWindow.top;
	rectText.bottom = rectWindow.bottom;
	
	//
    // Offset text rectangle
	//
	rectText.OffsetRect(szOffset);
	rectText.top = 0;

	if( rectWindow.Height() < rectText.Width() )
		rectText.right -= ((rectText.Width() - rectWindow.Height())/2);

	pDC->SetBkMode( TRANSPARENT );
	pDC->DrawText( szcText, 
		           rectText,
                   DT_LEFT 
				  |DT_BOTTOM 
				  |DT_SINGLELINE 
				  |DT_END_ELLIPSIS );
    pDC->SelectObject ( pfontOld );
	pDC->RestoreDC( nSavedDC );
    
	return TRUE;
}
コード例 #5
0
ファイル: atltypes.cpp プロジェクト: Moteesh/reactos
static void test_CPoint()
{
    CPoint empty;

    ok(empty.x == 0, "Expected x to be 0, was %ld\n", empty.x);
    ok(empty.y == 0, "Expected y to be 0, was %ld\n", empty.y);

    CPoint ptTopLeft(0, 0);
    POINT ptHere;
    ptHere.x = 35;
    ptHere.y = 95;

    CPoint ptMFCHere(ptHere);

    SIZE sHowBig;
    sHowBig.cx = 300;
    sHowBig.cy = 10;

    CPoint ptMFCBig(sHowBig);
    DWORD dwSize;
    dwSize = MAKELONG(35, 95);

    CPoint ptFromDouble(dwSize);
    ok_point(ptFromDouble, ptMFCHere);

    CPoint ptStart(100, 100);
    ptStart.Offset(35, 35);

    CPoint ptResult(135, 135);
    ok_point(ptStart, ptResult);

    ptStart = CPoint(100, 100);
    POINT pt;

    pt.x = 35;
    pt.y = 35;

    ptStart.Offset(pt);
    ok_point(ptStart, ptResult);

    ptStart = CPoint(100, 100);
    SIZE size;

    size.cx = 35;
    size.cy = 35;

    ptStart.Offset(size);
    ok_point(ptStart, ptResult);

    CPoint ptFirst(256, 128);
    CPoint ptTest(256, 128);
    ok_point(ptFirst, ptTest);

    pt.x = 256;
    pt.y = 128;
    ok_point(ptTest, pt);

    ptTest = CPoint(111, 333);
    nok_point(ptFirst, ptTest);

    pt.x = 333;
    pt.y = 111;
    nok_point(ptTest, pt);

    ptStart = CPoint(100, 100);
    CSize szOffset(35, 35);

    ptStart += szOffset;

    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);

    ptStart += size;
    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);

    ptStart -= szOffset;

    ptResult = CPoint(65, 65);
    ok_point(ptResult, ptStart);


    ptStart = CPoint(100, 100);

    ptStart -= size;
    ok_point(ptResult, ptStart);

    ptStart = CPoint(100, 100);
    CPoint ptEnd;

    ptEnd = ptStart + szOffset;

    ptResult = CPoint(135, 135);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart + size;
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart + pt;
    ptResult = CPoint(433, 211);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart - szOffset;
    ptResult = CPoint(65, 65);
    ok_point(ptResult, ptEnd);

    ptEnd = ptStart - size;
    ok_point(ptResult, ptEnd);

    szOffset = ptStart - pt;
    CSize expected(-233, -11);
    ok_size(szOffset, expected);

    ptStart += pt;
    ptResult = CPoint(433, 211);
    ok_point(ptResult, ptStart);

    ptStart -= pt;
    ptResult = CPoint(100, 100);
    ok_point(ptResult, ptStart);

    ptTest = CPoint(35, 35);
    ptTest = -ptTest;

    CPoint ptNeg(-35, -35);
    ok_point(ptTest, ptNeg);

    RECT rc = { 1, 2, 3, 4 };

    CRect rcres = ptStart + &rc;
    CRect rcexp(101, 102, 103, 104);
    ok_rect(rcexp, rcres);

    rcres = ptStart - &rc;
    rcexp = CRect(-99, -98, -97, -96);
    ok_rect(rcexp, rcres);
}