Пример #1
0
void AnimateBox::OnRender(suic::DrawingContext * drawing)
{
    suic::ImagePtr img = CurrentFrame();
    int flag = 2;

    suic::FrameworkElement::OnRender(drawing);

    if (_frames.size() > 1)
    {
        suic::Rect rc(0, 0, RenderSize().cx, RenderSize().cy);
        flag = _frames[_curframe].flag;

        // 先恢复背景色
        if (flag == 2)
        {
            //drawing->FillRectangle(rc, _bkcolor);
        }

    //    // 如果需要,绘制前一帧
    //    //if (_frame)
    //    //{ 
    //    //    suic::Rect rcim(0, 0, _frame->Width(), _frame->Height());

    //    //    drawing->DrawImage(_frame.get(), &rc, &rcim, CurrentTransparent());
    //    //    _frame = NULL;
    //    //}

    //    //// 需要保留上一帧
    //    if (flag == 3)
    //    {
    //        _frame = img;
    //    }
    }

    if (img)
    {
        suic::Rect rect(0, 0, RenderSize().cx, RenderSize().cy);
        suic::Rect rcimg(0, 0, img->Width(), img->Height());

        drawing->DrawImage(img.get(), &rect, &rcimg, CurrentTransparent());
    }
}
Пример #2
0
void ClsFlatButton::PaintControl( ClsDC *pDC )
{
	// Get the client rectangle.
	ClsRect	rc = GetClientRect();

	// Any room to render in?
	if ( ! rc.IsEmpty())
	{
		// Create an off-screen buffer.
		ClsBufferDC	dc( *pDC, rc );

		// Snapshot the DC.
		int sDC = dc.SaveDC();

		// Render the frame.
		if ( ! m_bXPStyle ) RenderFrame( &dc, rc );
		else
		{
			// Only when were hot or down.
			COLORREF crFg, crBg;
			if (( IsHot() || IsDown()) && IsWindowEnabled())
			{
				crFg = XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION );
				crBg = XPColors.GetXPColor( IsDown() ? ClsXPColors::XPC_INNER_CHECKED_SELECTED : ClsXPColors::XPC_INNER_SELECTION );
			}
			else
			{
				// Default colors...
				crFg = ( IsDefault() && IsWindowEnabled() && ! m_bXPDefault ) ? XPColors.GetXPColor( ClsXPColors::XPC_OUTER_SELECTION ) : XPColors.GetXPColor( ClsXPColors::XPC_IMAGE_DISABLED );
				crBg = ::GetSysColor( COLOR_BTNFACE );
			}

			// Render rectangle.
			dc.OutlinedRectangle( rc, crFg, crBg );
		}

		// Determine rendering flags.
		DWORD dwFlags = 0;
		if ( ! IsWindowEnabled())			  dwFlags |= ClsDrawTools::CDSF_DISABLED;
		if ( IsDown() && ! ThemingAPI.IsThemingEnabled()) dwFlags |= ClsDrawTools::CDSF_DOWNPRESSED;
		if ( GetUIState() & UISF_HIDEACCEL )		  dwFlags |= ClsDrawTools::CDSF_HIDEACCEL;
		if ( IsHot())					  dwFlags |= ClsDrawTools::CDSF_HOT;

		// Do we have any images?
		if ( m_hImages )
		{
			// Copy the client rectangle.
			ClsRect rcimg( rc );

			// We need to know the size of the images
			// in the image list.
			int cx, cy;
			::ImageList_GetIconSize( m_hImages, &cx, &cy );

			// Determine the place at which we render the images.
			rcimg.Offset( ::GetSystemMetrics( SM_CXFRAME ), 0 );
			rcimg.Right() = rcimg.Left() + cx;

			// Adjust label rectangle.
			rc.Left() += cx + 4;
			
			// Render the image.
			if ( ! m_bXPStyle ) ClsDrawTools::RenderBitmap( dc, m_hImages, ( IsHot() || IsDown()) ? m_aImageIndex[ FIIF_HOT ] : m_aImageIndex[ FIIF_NORMAL ], rcimg, dwFlags );
			else ClsDrawTools::RenderXPBitmap( dc, m_hImages, ( IsHot() || IsDown()) ? m_aImageIndex[ FIIF_HOT ] : m_aImageIndex[ FIIF_NORMAL ], rcimg, dwFlags );
		}

		// Render the caption.
		ClsString str( m_hWnd );

		// Anything to render?
		if ( str.GetStringLength())
		{
			// Deflate the label rectangle.
			rc.Deflate( 3, 3 );

			// Do we have the focus?
			if ( HasFocus() && ! ( GetUIState() & UISF_HIDEFOCUS ) && ! m_bPanelHeader ) dc.DrawFocusRect( rc );

			// Setup the font to use.
			ClsFont font;
			GetFont( font );
			ClsSelector sel( &dc, font );

			// Render transparently.
			dc.SetBkMode( TRANSPARENT );
			
			// We must not use the disabled flag if we are
			// rendering XP style...
			if ( m_bXPStyle ) dwFlags &= ~( ClsDrawTools::CDSF_DISABLED | ClsDrawTools::CDSF_DOWNPRESSED );

			// Set text color.
			COLORREF cr = GetSysColor( IsWindowEnabled() ? COLOR_BTNTEXT : COLOR_GRAYTEXT );
			if ( IsDown() && m_bXPStyle ) cr = XPColors.GetXPColor( ClsXPColors::XPC_TEXT_BACKGROUND );

			if ( IsHot() || IsDown()) cr = m_crHotLabelColor == CLR_NONE ? cr : m_crHotLabelColor;
			else			  cr = m_crLabelColor    == CLR_NONE ? cr : m_crLabelColor;
			dc.SetTextColor( cr );

			// Render the caption.
			ClsDrawTools::RenderText( dc, str, rc, dwFlags );
		}

		// Restore device context.
		dc.RestoreDC( sDC );
	}
}