コード例 #1
0
//=============================================================================	
void CXButtonXP::DrawText(CDC *pDC,
						  LPCTSTR lpszText,
						  CRect& rect,
						  BOOL bIsPressed,
						  BOOL bIsThemed,
						  BOOL bIsDisabled)
//=============================================================================	
{
	ASSERT(pDC);
	ASSERT(lpszText);

	CRect rectDraw(rect);

	// if button is pressed then "press" title also
	if (bIsPressed && !bIsThemed)
		rectDraw.OffsetRect(1, 1);

	UINT uTextAlignment = DT_LEFT;
	if (m_hIcon == NULL)
		uTextAlignment = DT_CENTER;
	uTextAlignment |= DT_VCENTER;
	uTextAlignment |= (GetStyle() & BS_MULTILINE) ? DT_WORDBREAK : DT_SINGLELINE;

	// center text vertically (DT_VCENTER does not work if BS_MULTILINE is set)
	CRect rectText = rectDraw;
	if (m_pDropDownMenu)
		rectText.right -= MENUBTN_WIDTH;
	pDC->DrawText(lpszText, -1, &rectDraw, uTextAlignment | DT_CALCRECT);

	rectDraw.OffsetRect((rectText.Width() - rectDraw.Width())/2, 
		(rectText.Height() - rectDraw.Height())/2);

	if (m_bDrawToolbar || !bIsThemed)
	{
		if (bIsDisabled)
		{
			rectDraw.OffsetRect(1, 1);
			pDC->SetTextColor(::GetSysColor(COLOR_3DHILIGHT));
			pDC->DrawText(lpszText, -1, &rectDraw, uTextAlignment);
			rectDraw.OffsetRect(-1, -1);
			pDC->SetTextColor(::GetSysColor(COLOR_3DSHADOW));
			pDC->DrawText(lpszText, -1, &rectDraw, uTextAlignment);
		}
		else
		{
			if (m_crText == XBUTTONXP_NO_COLOR)
				pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
			else
				pDC->SetTextColor(m_crText);
			pDC->DrawText(lpszText, -1, &rectDraw, uTextAlignment);
		}
	}
	else //if (bIsThemed)
	{
		ThemeHelper.DrawThemeText(m_hTheme, pDC->m_hDC, BP_PUSHBUTTON, 
						bIsDisabled ? PBS_DISABLED : PBS_NORMAL,
						lpszText, uTextAlignment, 0, &rectDraw);
	}
}
void Genetic_AlgorithmApp::draw()
{
    gl::clear(cinder::Color::black());

    m_camera.update();

    gl::enableDepthRead();
    gl::enableDepthWrite();

    if (m_isStarted && m_algoGenResult && m_heightMap)
    {
        auto texture = gl::Texture(m_algoGenResult);
        auto heightMap = gl::Texture(m_heightMap);

        m_shader->bind();

        m_shader->uniform("u_texture", 0);
        m_shader->uniform("u_heightMap", 1);
        m_shader->uniform("u_time", static_cast<float>(0.00025 * m_timerShader.getSeconds()));
        m_shader->uniform("u_neighbors", m_neighbors);

        texture.bind(0);
        heightMap.bind(1);
        
        gl::color(Color::white());

        gl::draw(m_planeResultAlgoGen);

        texture.unbind();
        heightMap.unbind();
        m_shader->unbind();
    }

    if (m_renderCurrentImage && m_currentImage)
    {
        auto screen = getWindowBounds();
        auto demiW = 0.5f * screen.getWidth();
        auto demiH = 0.5f * screen.getHeight();

        float widthTenPercent = 0.1f * demiW;
        float heightTenPercent = 0.1f * demiH;
        
        ci::Rectf rectDraw(demiW - widthTenPercent, demiH - heightTenPercent, demiW, demiH);

        gl::draw(gl::Texture(m_currentImage), rectDraw);
    }

    updateIHM();
}
コード例 #3
0
void WallDrawer::DrawFieldBase()
{
    Place2D::SetParams(0.4f, 0.4f, 0.4f);
    Place2D::BindBorders(NULL);
    Place2D::Clear();
    Color bgColor =  Color("#8a642d")*FieldStyles::current->bgEmptyColor;
    bgColor.alpha = 255;

    IRect rectDraw(0, 0, GameSettings::SQUARE_SIDE*2, GameSettings::SQUARE_SIDE*2);

    Place2D::mask_map = NULL;
    Place2D::Calculate(is_visible, is_base_visible);

    _textureFieldChess->Bind();
    Place2D::DrawPlace(bgColor, rectDraw, ZBuf::GROUND);
}
コード例 #4
0
/***
	准备数据
*/
BOOL CCurveButton::PrepareDrawData(CRect rectClient, int nStart, int nWeight,
								   LPRECT prectDraw, int *pnStartNew, int *pnCount, double *pdMin, double *pdMax )
{
	// RectDraw
	CRect	rectDraw( rectClient.left+SRC_LEFTMARGIN, rectClient.top+SRC_TOPMARGIN, 
					rectClient.right-SRC_RIGHTMARGIN, rectClient.bottom-SRC_BOTTOMMARGIN );
	int		nStartNew = nStart, nCount = 0;
	double	dMin = 0, dMax = 0;
	
	// Start
	if( nWeight <= 0 || m_AssetSerial.GetSize() <= 0 )
		return FALSE;
	nCount	=	rectDraw.Width() / nWeight;
	if( nStartNew >= m_AssetSerial.GetSize() || nStartNew < 0 )
		nStartNew	=	-1;

	if( -1 == nStartNew )
	{
		nStartNew	=	m_AssetSerial.GetSize()-nCount;
		if( nStartNew < 0 )
			nStartNew	=	0;
	}
	if( nStartNew+nCount-1 >= m_AssetSerial.GetSize() )
		nCount	=	m_AssetSerial.GetSize() - nStartNew;
	if( nStartNew < 0 || nStartNew >= m_AssetSerial.GetSize() )
		return FALSE;

	// MinMax
	for( int i=0; i<m_AssetSerial.GetSize(); i++ )
	{
		if( m_AssetSerial.ElementAt(i).dAsset > dMax )
			dMax	=	m_AssetSerial.ElementAt(i).dAsset;
	}
	if( m_dStartAmount < 1e-4 )
		return FALSE;
	dMax	=	dMax / m_dStartAmount;

	if( prectDraw )	*prectDraw	=	rectDraw;
	if( pnStartNew )*pnStartNew	=	nStartNew;
	if( pnCount )	*pnCount	=	nCount;
	if( pdMin )		*pdMin		=	dMin;
	if( pdMax )		*pdMax		=	dMax;
	return TRUE;
}
コード例 #5
0
ファイル: pichelp.cpp プロジェクト: 6520874/pcmanager
void DrawStrechBkG( CRect& rect, HDC hdc, CBitmap& bmpLeft, CBitmap& bmpCenter, CBitmap& bmpRight )
{
	CRect rectDraw(rect);
	BITMAP infoLeft, infoRight;
	bmpLeft.GetBitmap( infoLeft );
	rectDraw.right = rectDraw.left + infoLeft.bmWidth;

	DrawBmp( hdc, rectDraw, bmpLeft );

	bmpRight.GetBitmap( infoRight );
	rectDraw.left = rectDraw.right;
	rectDraw.right = rect.right - infoRight.bmWidth;

	DrawBmp( hdc, rectDraw, bmpCenter );

	rectDraw.left = rectDraw.right;
	rectDraw.right = rect.right;
	DrawBmp( hdc, rectDraw, bmpRight );
}
コード例 #6
0
//=============================================================================	
void CXButtonXP::DrawSplit(CDC *pDC,
						   const CRect& rect,
						   BOOL bIsPressed,
						   BOOL bIsThemed,
						   BOOL bIsDisabled)
//=============================================================================	
{
	CRect rectDraw(rect);
	if (!bIsThemed && bIsPressed)
		rectDraw.OffsetRect(1, 1);

	CPen brFace(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
	CPen* penOld = pDC->SelectObject(&brFace);
	pDC->MoveTo(rectDraw.right - MENUBTN_WIDTH, rectDraw.top + 3);
	pDC->LineTo(rectDraw.right - MENUBTN_WIDTH, rectDraw.bottom - 3);

	CPen brLite(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
	pDC->SelectObject(&brLite);
	pDC->MoveTo(rectDraw.right - MENUBTN_WIDTH + 1, rectDraw.top + 3);
	pDC->LineTo(rectDraw.right - MENUBTN_WIDTH + 1, rectDraw.bottom - 3);

	pDC->SelectObject(penOld);
}
コード例 #7
0
ファイル: pichelp.cpp プロジェクト: 6520874/pcmanager
void DrawStrechBorder( HDC dc, CRect& rect, CBitmap& bmpLeft, CBitmap& bmpRight, CBitmap& bmpTop, CBitmap& bmpBottom,
				 CBitmap& bmpLeftTop, CBitmap& bmpLeftBottom, CBitmap& bmpRightTop, CBitmap& bmpRightBottom )
{
	CRect rectDraw(rect);
	BITMAP infoLeft, infoRight, infoTop, infoBottom;
	BITMAP infoLB, infoRT, infoRB;

	bmpTop.GetBitmap( &infoTop );
	rectDraw.bottom = rectDraw.top + infoTop.bmHeight;
	DrawBmp( dc, rectDraw, bmpTop );

	bmpLeft.GetBitmap( &infoLeft );
	rectDraw.right = rectDraw.left + infoLeft.bmWidth;
	rectDraw.bottom = rect.bottom;
	DrawBmp( dc, rectDraw, bmpLeft );

	bmpBottom.GetBitmap( &infoBottom );
	rectDraw.right = rect.right;
	rectDraw.top = rectDraw.bottom - infoBottom.bmHeight;
	DrawBmp( dc, rectDraw, bmpBottom );

	bmpRight.GetBitmap( &infoRight );
	rectDraw.top = rect.top;
	rectDraw.left = rectDraw.right - infoRight.bmWidth;
	DrawBmp( dc, rectDraw, bmpRight );

	DrawBmpBit( dc, rect.left, rect.top, bmpLeftTop );

	bmpLeftBottom.GetBitmap( &infoLB );
	DrawBmpBit( dc, rect.left, rect.bottom - infoLB.bmHeight, bmpLeftBottom );

	bmpRightTop.GetBitmap( &infoRT );
	DrawBmpBit( dc, rect.right - infoRT.bmWidth, rect.top, bmpRightTop );

	bmpRightBottom.GetBitmap( &infoRB );
	DrawBmpBit( dc, rect.right - infoRB.bmWidth, rect.bottom - infoRB.bmHeight, bmpRightBottom );
}
コード例 #8
0
ファイル: ZdCtlChk.cpp プロジェクト: arksoftgit/10c
void
ZCheckBox::PrepareState( HDC hDC, HBITMAP& bmpDest, int nState )
{
   CRect rect;
   GetClientRect( &rect );

   int nWidth  = rect.right  - rect.left;
   int nHeight = rect.bottom - rect.top;

   if ( nHeight >= m_nHeight )
   {
      rect.top += (nHeight - m_nHeight) / 2;
      rect.bottom -= (nHeight - m_nHeight) / 2;
      nHeight = rect.bottom - rect.top;
   }

   int j = (m_nHeight - BOX_SIZE) / 2;

   // Create memory DCs and bitmaps to prepare the image.
   HDC srcDC  = ::CreateCompatibleDC( hDC );
   HDC maskDC = ::CreateCompatibleDC( hDC );
   HDC destDC = ::CreateCompatibleDC( hDC );

   HBITMAP bmpMask = ::CreateBitmap( BOX_SIZE,BOX_SIZE, 1, 1, NULL );
   bmpDest = ::CreateCompatibleBitmap( hDC, nWidth, m_nHeight );

   HBITMAP bmpSrcDC  = (HBITMAP) ::SelectObject( srcDC, m_bmpSrc );
   HBITMAP bmpMaskDC = (HBITMAP) ::SelectObject( maskDC, bmpMask );
   HBITMAP bmpDestDC = (HBITMAP) ::SelectObject( destDC, bmpDest );

   // Create mask - mask color: RGB( 255, 0, 255 ).
   COLORREF clr = SetBkColor( srcDC, RGB( 255, 0, 255 ) );

   // Drawing rectangle inside client area of CB.
   CRect rectDraw( 0, 0, nWidth, nHeight );

   // Copy the display surface where the CheckBox will be to destDC.
#if TRANSPARENT_CB
   BitBlt( destDC, 0, 0, nWidth, nHeight, hDC, rect.left, rect.top, SRCCOPY );
#else
   FillRect( destDC, &rectDraw, m_brush );
#endif

   int k = 0;
   if ( m_bLeftText )
      k = nWidth - BOX_SIZE;

   int x = BOX_SIZE * nState;
   BitBlt( maskDC, 0, 0, BOX_SIZE, BOX_SIZE, srcDC, x, 0, SRCCOPY );
   BitBlt( destDC, k, j, BOX_SIZE, BOX_SIZE, srcDC, x, 0, SRCINVERT );
   BitBlt( destDC, k, j, BOX_SIZE, BOX_SIZE, maskDC, 0, 0, SRCAND );
   BitBlt( destDC, k, j, BOX_SIZE, BOX_SIZE, srcDC, x, 0, SRCINVERT );

   // Draw control text.
   DrawTextToDestDC( destDC, rectDraw, nState );
   m_rectFocus.top += rect.top;
   m_rectFocus.bottom += rect.top;
   m_rectFocus.left -= 1;
   m_rectFocus.right += 1;

   // Clean up.
   SetBkColor( srcDC, clr );
   SelectObject( srcDC, bmpSrcDC );
   SelectObject( maskDC, bmpMaskDC );
   SelectObject( destDC, bmpDestDC );

   DeleteDC( srcDC );
   DeleteDC( maskDC );
   DeleteDC( destDC );

   DeleteObject( bmpMask );
}