예제 #1
0
void PresetButtonControl::OnPaint(DibBitmap *pbm)
{
	bool fSet = (m_wf & kfCtlSet) != 0;

	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	bool fSelected = m_pfrm->IsControlInside(this);
	Rect rcT = m_rc;
	rcT.Offset(rcForm.left, rcForm.top);

	if (fSelected) {
		pbm->Fill(rcT.left + 1, rcT.top + 1, rcT.Width() - 2, rcT.Height() - 2, GetColor(kiclrButtonFillHighlight));
	}

	TBitmap *ptbm;
	if (fSet)
		ptbm = m_ptbmDown;
	else
		ptbm = m_ptbmUp;

	if (ptbm != NULL)
		ptbm->BltTo(pbm, m_rc.left + rcForm.left + 1, m_rc.top + rcForm.top + 1);
}
예제 #2
0
void CheckBoxControl::OnPaint(DibBitmap *pbm)
{
	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	// Draw up / down image (if present)

	TBitmap *ptbm;
	bool fPenDownInside = m_pfrm->IsControlInside(this);
	if (fPenDownInside) {
		ptbm = m_fChecked ? s_ptbmOnDown : s_ptbmOffDown;
	} else {
		ptbm = m_fChecked ? s_ptbmOnUp : s_ptbmOffUp;
	}

	// Center the text horizontally and draw to the right of the checkbox

	Font *pfnt = gapfnt[m_ifnt];
	int cy = pfnt->GetHeight();
	Size siz;
	ptbm->GetSize(&siz);
	ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + (cy - siz.cy) / 2 + rcForm.top - 1);
	gapfnt[m_ifnt]->DrawText(pbm, m_szLabel, m_rc.left + rcForm.left + siz.cx, m_rc.top + rcForm.top);
}
예제 #3
0
void ButtonControl::OnPaint(DibBitmap *pbm)
{
	Rect rcForm;
	m_pfrm->GetRect(&rcForm);

	bool fSelected = m_pfrm->IsControlInside(this);
	if (m_ptbmDown != NULL && m_ptbmUp != NULL) {
		// Draw up / down image (if present)

		TBitmap *ptbm;
		if (m_wf & kfCtlDisabled)
			ptbm = m_ptbmDisabled;
		else
			ptbm = fSelected ? m_ptbmDown : m_ptbmUp;

		ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + rcForm.top, m_wf & kfCtlUseSide1Colors ? kside1 : ksideNeutral);

		// Center the text (if present)

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2;
			if (fSelected) {
				x++;
				y++;
			}
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
	} else {
#if 0 // old-style filled-rect buttons
		Rect rcT = m_rc;
		rcT.Offset(rcForm.left, rcForm.top);

		int cxyBorder2x = gcxyBorder * 2;
		pbm->Fill(rcT.left + gcxyBorder, rcT.top + gcxyBorder, rcT.Width() - cxyBorder2x, rcT.Height() - cxyBorder2x, GetColor(fSelected ? kiclrButtonFillHighlight : kiclrButtonFill));

		int iclr = GetColor(fSelected ? kiclrWhite : kiclrButtonBorder);
		pbm->Fill(rcT.left + gcxyBorder, rcT.top, rcT.Width() - cxyBorder2x, gcxyBorder, iclr);
		pbm->Fill(rcT.left, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr);
		pbm->Fill(rcT.right - gcxyBorder, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr);
		pbm->Fill(rcT.left + gcxyBorder, rcT.bottom - gcxyBorder, rcT.Width() - cxyBorder2x, gcxyBorder, iclr);

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2;
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
#else
		Rect rcT = m_rc;
		rcT.Offset(rcForm.left, rcForm.top);

		TBitmap *ptbmLeft, *ptbmMid, *ptbmRight;
		if (!fSelected) {
			ptbmLeft = s_ptbmLeftUp;
			ptbmMid = s_ptbmMidUp;
			ptbmRight = s_ptbmRightUp;
		} else {
			ptbmLeft = s_ptbmLeftDown;
			ptbmMid = s_ptbmMidDown;
			ptbmRight = s_ptbmRightDown;
		}

		Size sizLeft, sizMid, sizRight;
		ptbmLeft->GetSize(&sizLeft);
		ptbmMid->GetSize(&sizMid);
		ptbmRight->GetSize(&sizRight);

		int x = rcT.left;
		int xRight = rcT.right - sizRight.cx;

		ptbmLeft->BltTo(pbm, x, rcT.top);
		x += sizLeft.cx;
#if 0
		while (x < xRight) {
			ptbmMid->BltTo(pbm, x, rcT.top);
			x += sizMid.cx;
		}
#else
		ptbmMid->FillTo(0, pbm, x, rcT.top, xRight - x, rcT.Height());
		x = xRight;
#endif

		ptbmRight->BltTo(pbm, xRight, rcT.top);

		if (m_szLabel[0] != 0) {
			Font *pfnt = gapfnt[m_nfnt];
			int cx = pfnt->GetTextExtent(m_szLabel);
			int cy = pfnt->GetHeight();
			int x = m_rc.left + (m_rc.Width() - cx + 1) / 2;
			int y = m_rc.top + ((sizMid.cy - gapfnt[m_nfnt]->GetHeight() + 1) / 2);
			gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top);
		}
#endif
	}
}