コード例 #1
0
	void Button::DrawElement(C4TargetFacet &cgo)
	{
		// draw base
		if (fDown)
			// pressed
			DrawBar(cgo, pCustomGfxDown ? *pCustomGfxDown : ::GraphicsResource.barButtonD);
		else
			// released
			DrawBar(cgo, pCustomGfx ? *pCustomGfx : ::GraphicsResource.barButton);
		// get text pos
		int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y, x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1, y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1;
		int32_t iTxtOff = fDown ? 1 : 0;
		// draw selection highlight
		if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
			{
				pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
				::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0+5, y0+3, rcBounds.Wdt-10, rcBounds.Hgt-6);
				pDraw->ResetBlitMode();
			}
		// draw text
		int32_t iTextHgt = rcBounds.Hgt-2;
		CStdFont &rUseFont =
		  (::GraphicsResource.TitleFont.GetLineHeight() > iTextHgt ?
		   (::GraphicsResource.CaptionFont.GetLineHeight() > iTextHgt ?
		    ::GraphicsResource.TextFont :
		    ::GraphicsResource.CaptionFont) :
				   ::GraphicsResource.TitleFont);
		iTextHgt = rUseFont.GetLineHeight();
		pDraw->TextOut(sText.getData(), rUseFont, 1.0f, cgo.Surface, (x0+x1)/2 + iTxtOff, (y0+y1-iTextHgt)/2 + iTxtOff, C4GUI_ButtonFontClr, ACenter, true);
	}
コード例 #2
0
	void FacetButton::DrawElement(C4TargetFacet &cgo)
	{
		// get drawing bounds
		float x0 = rcfDrawBounds.left + cgo.TargetX, y0 = rcfDrawBounds.top + cgo.TargetY;
		// draw button or highlight facet
		uint32_t dwTextClr;
		if ((HasDrawFocus() || (fMouseOver && IsInActiveDlg(false))) && fEnabled)
		{
			fctHighlight.DrawXFloat(cgo.Surface, x0, y0, rcfDrawBounds.right-rcfDrawBounds.left, rcfDrawBounds.bottom-rcfDrawBounds.top);
			dwTextClr = dwTextClrAct;
		}
		else
		{
			fctBase.DrawXFloat(cgo.Surface, x0, y0, rcfDrawBounds.right-rcfDrawBounds.left, rcfDrawBounds.bottom-rcfDrawBounds.top);
			dwTextClr = dwTextClrInact;
		}
		// draw caption text
		if (sText.getLength()>0)
		{
			CStdFont *pUseFont = pFont ? pFont : &(::GraphicsResource.GetFontByHeight(rcBounds.Hgt, &fFontZoom));
			pDraw->TextOut(sText.getData(), *pUseFont, fFontZoom, cgo.Surface, (int)(x0+iTxtOffX), (int)(y0+iTxtOffY), dwTextClr, byTxtAlign, true);
		}
		/*
		if (fEnabled) if (fMouseOver && IsInActiveDlg(false))
		  {
		  pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
		  GetRes()->fctButtonHighlight.DrawXFloat(cgo.Surface, x0, y0, rcfDrawBounds.right-rcfDrawBounds.left, rcfDrawBounds.bottom-rcfDrawBounds.top);
		  pDraw->ResetBlitMode();
		  }*/
	}
コード例 #3
0
	void IconButton::DrawElement(C4TargetFacet &cgo)
	{
		// get drawing bounds
		int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y;
		// draw selection highlight
		if (fEnabled) if (fHighlight || HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
			{
				pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
				::GraphicsResource.fctButtonHighlightRound.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
				pDraw->ResetBlitMode();
			}
		// draw the icon
		if (fHasClr && fctIcon.Surface) fctIcon.Surface->SetClr(dwClr);
		fctIcon.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
		// "button" down?
		if (fEnabled) if (fDown || fHighlight)
			{
				pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
				::GraphicsResource.fctButtonHighlightRound.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
				pDraw->ResetBlitMode();
			}
		// some icon buttons have captions. draw caption below button
		if (sText.getLength())
		{
			CStdFont &rUseFont = pCustomFont ? *pCustomFont : ::GraphicsResource.TextFont;
			pDraw->TextOut(sText.getData(), rUseFont, 1.0f, cgo.Surface, x0+rcBounds.Wdt/2, y0+rcBounds.Hgt, pCustomFont ? dwCustomFontClr : C4GUI_CaptionFontClr, ACenter);
		}
	}
コード例 #4
0
void CheckBox::DrawElement(C4FacetEx &cgo)
	{
	// left side: check facet (squared)
	int x0 = rcBounds.x + cgo.TargetX;
	int y0 = rcBounds.y + cgo.TargetY;
	GetRes()->fctCheckbox.GetPhase(fChecked + 2*!fEnabled).DrawX(cgo.Surface, x0, y0, rcBounds.Hgt, rcBounds.Hgt);
	// right of it: checkbox text
	CStdFont *pUseFont = pFont ? pFont : &(GetRes()->TextFont);
	int32_t yOff; float fZoom;
	if (pUseFont->GetLineHeight() <= rcBounds.Hgt)
		{
		yOff = Max<int32_t>(rcBounds.Hgt - pUseFont->GetLineHeight(), 0)/2;
		fZoom = 1.0f;
		}
	else
		{
		yOff = 0;
		fZoom = (float) rcBounds.Hgt / Max(pUseFont->GetLineHeight(), 1);
		}
	lpDDraw->TextOut(sCaption.getData(), *pUseFont, fZoom, cgo.Surface, x0 + rcBounds.Hgt + C4GUI_CheckBoxLabelSpacing, y0 + yOff, fEnabled ? dwEnabledClr : dwDisabledClr, ALeft, true);
	// selection marker
	if ((fMouseOn && IsInActiveDlg(false)) || HasDrawFocus())
		{
		lpDDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
		GetRes()->fctButtonHighlight.DrawX(cgo.Surface, x0+rcBounds.Hgt*1/4, y0+rcBounds.Hgt*1/4, rcBounds.Hgt*1/2, rcBounds.Hgt*1/2);
		lpDDraw->ResetBlitMode();
		}
	}
コード例 #5
0
	void ArrowButton::DrawElement(C4TargetFacet &cgo)
	{
		// get drawing bounds
		int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y;
		// draw selection highlight
		if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)))
			{
				pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE);
				::GraphicsResource.fctButtonHighlightRound.DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
				pDraw->ResetBlitMode();
			}
		// draw the arrow - down if pressed
		int32_t iFctIdx = eDir;
		if (fDown) iFctIdx += Down;
		::GraphicsResource.fctBigArrows.GetPhase(iFctIdx).DrawX(cgo.Surface, x0, y0, rcBounds.Wdt, rcBounds.Hgt);
	}