예제 #1
0
bool
ESChildSeatStatus::Create(int nId, _Rect rcRect, MercuryBaseView* pOwner, ESChildControl* pParent){
	bool bRet = ESChildControl::Create(nId, rcRect, pOwner, pParent);
	if( bRet ){
		MercuryGUI* pGUI = MercuryGUI::GetInstance();
		_String sImage;
		if( !m_pBgImage ){
			sImage = m_sBgImageFile;
			Path::BuildFullPath(sImage);
			m_pBgImage = pGUI->LoadImage(sImage);
			
			// Save seat status region. {{
			if( !m_pOwner->IsDesignerMode() ){
				CRgn* pSeatStatusImageRgn = ESChildControlTable::GetSeatStatusImageRgn();
				if( !pSeatStatusImageRgn->m_hObject && m_pBgImage && !m_pBgImage->IsNull() ){
					HRGN hRgn = m_pBgImage->GetBitmap32bppRgnByAlphaChannel(200);
					if( hRgn )
						pSeatStatusImageRgn->Attach(hRgn);
					}
				}
			// }}
			}

		if( !m_pBgActiveImage ){
			sImage = m_sActiveBgImageFile;
			Path::BuildFullPath(sImage);
			m_pBgActiveImage = pGUI->LoadImage(sImage);
			}
		}
	return bRet;
	}
예제 #2
0
void CSkinImage::Draw(CDC* pDC, LPRECT lpInvalidRect, CRgn* pInvalidRgn)
{
	CRect drawRect = GetSkinRect();
    //绘制背景
    if (m_clrBackgroundColor != -1) {
        LONG bkColor = m_clrBackgroundColor;
        if (GetColorTransform())
            GetEngine()->TransformColor(bkColor, bkColor);
        CRenderEngine::FillRect(*pDC, drawRect, bkColor);
    }

	if (m_bConstrainedRatio){
		long drawWidth = drawRect.Width();
		long drawHeight = drawRect.Height();
		long originWidth = GetoriginWidth();
		long originHeight = GetoriginHeight();
		if (originWidth > drawWidth || originHeight > drawHeight) {
			if ( (drawHeight * originWidth) > (drawWidth * originHeight) ){
				drawHeight = drawWidth * originHeight / originWidth;
				drawRect.top = drawRect.top + (drawRect.Height() - drawHeight) / 2;
				drawRect.bottom = drawRect.top + drawHeight;
			} else {
				drawWidth = drawHeight * originWidth / originHeight;
				drawRect.left = drawRect.left + (drawRect.Width() - drawWidth) / 2;
				drawRect.right = drawRect.left + drawWidth;
			}
		} else {
			drawRect.DeflateRect((drawWidth - originWidth) / 2, (drawHeight - originHeight) / 2);
		}
	}

	//绘制动画或图片
	CImageBase* pImage = GetDrawImage();
	LONG lFrameNum = (pImage != NULL) ? (pImage->GetNumFrames()) : (0);
	if (m_bAnimating && pImage != NULL && lFrameNum > 1) { //Animation
		if (m_bRestoreDC) {
			AnimationRestoreDC(*pDC, drawRect);
			AnimationDrawDC();
			m_bRestoreDC = FALSE;
		}
		AnimationDraw(*pDC, drawRect);
	} else if (pImage != NULL) { //Still
		if (m_bSmoothDisplay) {
			CImageTransformParam param;
			param.enTransformType = TRANSFORM_TYPE_SMOOTH;
			param.width = drawRect.Width();
			param.height = drawRect.Height();
			//DragonZ:支持画指定区域图片
			if (m_bNeedClip)
			{
				pImage->Draw(*pDC, &drawRect, &m_rcClipRc, &param, GetTransparentColor(), m_bAlpha);
			}else
			{
				pImage->Draw(*pDC, &drawRect, NULL, &param, GetTransparentColor(), m_bAlpha);
			}
		} else if (! GetColorTransform()) {
			if (m_bNeedClip)
			{
				pImage->Draw(*pDC, &drawRect, &m_rcClipRc, NULL, GetTransparentColor(), m_bAlpha);
			} 
			else
			{
				pImage->Draw(*pDC, &drawRect, NULL, NULL, GetTransparentColor(), m_bAlpha);
			}
		} else {
			if (m_bNeedClip)
			{
				pImage->Draw(*pDC, &drawRect, &m_rcClipRc, GetImageParam(), GetTransformedTransparentColor(), m_bAlpha);
			} 
			else
			{
				pImage->Draw(*pDC, &drawRect, NULL, GetImageParam(), GetTransformedTransparentColor(), m_bAlpha);
			}
		}
	}

	//绘制区域边框
	if (m_nBorderLineWidth > 0 && m_clrBorderLineColor != -1){
		CBrush brush;
		LONG lineColor = m_clrBorderLineColor;
		if (GetColorTransform()) {
			GetEngine()->TransformColor(lineColor, lineColor);
		}
		brush.CreateSolidBrush(lineColor);
		CRgn rgn;
		rgn.Attach(GetSkinRgn());
		pDC->FrameRgn(&rgn, &brush, m_nBorderLineWidth, m_nBorderLineWidth);
	}
}