Ejemplo n.º 1
0
void CInformationPanel::Draw(HDC hdc,const RECT &PaintRect)
{
	HDC hdcDst;
	RECT rc;
//	TCHAR szText[256];

	GetClientRect(&rc);
	if (rc.right>m_Offscreen.GetWidth()
			|| m_FontHeight+m_Style.LineSpacing>m_Offscreen.GetHeight())
		m_Offscreen.Create(rc.right,m_FontHeight+m_Style.LineSpacing);
	hdcDst=m_Offscreen.GetDC();
	if (hdcDst==NULL)
		hdcDst=hdc;

	HFONT hfontOld=DrawUtil::SelectObject(hdcDst,m_Font);
	COLORREF crOldTextColor=::SetTextColor(hdcDst,m_Theme.Style.Fore.Fill.GetSolidColor());
	int OldBkMode=::SetBkMode(hdcDst,TRANSPARENT);

	for (int i=0;i<ITEM_PROGRAMINFO;i++) {
		if (GetDrawItemRect(i,&rc,PaintRect))
			m_ItemList[i]->Draw(hdc,rc);
	}

	GetItemRect(ITEM_PROGRAMINFO-1,&rc);
	if (PaintRect.bottom>rc.bottom) {
		rc.left=PaintRect.left;
		rc.top=max(PaintRect.top,rc.bottom);
		rc.right=PaintRect.right;
		rc.bottom=PaintRect.bottom;
		::FillRect(hdc,&rc,m_BackBrush.GetHandle());
	}

	if (IsItemVisible(ITEM_PROGRAMINFO)) {
		if (m_Theme.ProgramInfoStyle.Back.Border.Type!=TVTest::Theme::BORDER_NONE) {
			GetItemRect(ITEM_PROGRAMINFO,&rc);
			TVTest::Theme::Draw(hdc,rc,m_Theme.ProgramInfoStyle.Back.Border);
		}

		GetButtonRect(BUTTON_PROGRAMINFOPREV,&rc);
		DrawProgramInfoPrevNextButton(
			hdc,rc,false,IsButtonEnabled(BUTTON_PROGRAMINFOPREV),
			m_HotButton==BUTTON_PROGRAMINFOPREV);
		GetButtonRect(BUTTON_PROGRAMINFONEXT,&rc);
		DrawProgramInfoPrevNextButton(
			hdc,rc,true,IsButtonEnabled(BUTTON_PROGRAMINFONEXT),
			m_HotButton==BUTTON_PROGRAMINFONEXT);
	}

	::SetBkMode(hdcDst,OldBkMode);
	::SetTextColor(hdcDst,crOldTextColor);
	::SelectObject(hdcDst,hfontOld);
}
Ejemplo n.º 2
0
int CInformationPanel::ButtonHitTest(int x,int y) const
{
	POINT pt={x,y};

	for (int i=0;i<NUM_BUTTONS;i++) {
		if (IsButtonEnabled(i)) {
			RECT rc;

			if (GetButtonRect(i,&rc) && ::PtInRect(&rc,pt))
				return i;
		}
	}

	return -1;
}
Ejemplo n.º 3
0
void EditPolyMod::OnParamSet(PB2Value& v, ParamID id, int tabIndex, TimeValue t) {
	switch( id ) {
	case epm_constrain_type:
		SetConstraintType(v.i);
		break;
	case epm_select_mode:
		SetSelectMode(v.i);
		break;
	case epm_ss_use:
		//When the soft selection is turned off, end any active paint session
		if( (!v.i) && InPaintMode() ) EndPaintMode();
		break;
	case epm_ss_lock:	{
			BOOL selActive = IsPaintDataActive(PAINTMODE_SEL);
			if( v.i && !selActive ) //Enable the selection lock; Activate the paintmesh selection
				ActivatePaintData(PAINTMODE_SEL);
			else if( (!v.i) && selActive ) { //Disable the selection lock; De-activate the paintmesh selection
				if( InPaintMode() ) EndPaintMode (); //end any active paint mode
				DeactivatePaintData(PAINTMODE_SEL);
			}
			//NOTE: SetEnables() is called by OnPaintDataActive() when activating or deactivating
			InvalidateDistanceCache ();
			if (mpDialogSoftsel) mpDialogSoftsel->RedrawViews (t);
			break;
		}
	case epm_paintsel_size:
	case epm_paintdeform_size:
		SetPaintBrushSize(v.f);
		UpdatePaintBrush();
		break;
	case epm_paintsel_strength:
	case epm_paintdeform_strength:
		SetPaintBrushStrength(v.f);
		UpdatePaintBrush();
		break;
	case epm_paintsel_value:
	case epm_paintdeform_value:
	case epm_paintdeform_axis:
		UpdatePaintBrush(); break;
	case epm_paintsel_mode:
		if( v.i!=GetPaintMode() ) {
			BOOL valid = FALSE;
			HWND hwnd = (mpDialogSoftsel==NULL?  NULL : mpDialogSoftsel->GetHWnd());
			if( v.i==PAINTMODE_PAINTSEL )	valid = IsButtonEnabled( hwnd, IDC_PAINTSEL_PAINT );
			if( v.i==PAINTMODE_BLURSEL )	valid = IsButtonEnabled( hwnd, IDC_PAINTSEL_BLUR );
			if( v.i==PAINTMODE_ERASESEL )	valid = IsButtonEnabled( hwnd, IDC_PAINTSEL_REVERT );
			if( v.i==PAINTMODE_OFF )		valid = TRUE;
			if( valid ) OnPaintBtn(v.i, t);
		}
		break;
	case epm_paintdeform_mode:
		if( v.i!=GetPaintMode() ) {
			BOOL valid = FALSE;
			HWND hwnd = (mpDialogPaintDeform==NULL?  NULL : mpDialogPaintDeform->GetHWnd());
			if( v.i==PAINTMODE_PAINTPUSHPULL )	valid = IsButtonEnabled( hwnd, IDC_PAINTDEFORM_PUSHPULL );
			if( v.i==PAINTMODE_PAINTRELAX )		valid = IsButtonEnabled( hwnd, IDC_PAINTDEFORM_RELAX );
			if( v.i==PAINTMODE_ERASEDEFORM )	valid = IsButtonEnabled( hwnd, IDC_PAINTDEFORM_REVERT );
			if( v.i==PAINTMODE_OFF )			valid = TRUE;
			if( valid ) OnPaintBtn(v.i, t);
		}
		break;
	}
}
Ejemplo n.º 4
0
void CToolBarCtrlZ::DrawItem(CDC *pDC, int iIndex, const CRect &rtItem, BOOL bHover)
{
	UINT			uItemId;
	UINT			uItemState;
	TBBUTTON		tbb;


	TCHAR			szText[1024];
	TBBUTTONINFO	tbi;
	CArray<CxImage*, CxImage*>	*parrImgs = NULL;
	CxImage			*pIconImg = NULL;		
	int				iIconTop;
	CRect			rtDraw;
	CRect			rtText;
	COLORREF		clrText;
	
	CClientRect		rtClient(this);
	rtDraw = rtItem;
	rtDraw.top = rtClient.top;
	rtDraw.bottom = rtClient.bottom;

	if (!GetButton(iIndex, &tbb))
		return;

	uItemId = tbb.idCommand;
	uItemState = GetState(uItemId);

	parrImgs = &m_arrImgs;
	if ( !IsButtonEnabled(uItemId) )
	{
		clrText = RGB(204, 128, 128);
		if (0 != m_arrDisableImgs.GetCount())
			parrImgs = &m_arrDisableImgs;
	}
	else
	{
		clrText = RGB(255, 254, 253);

		if (TBSTATE_PRESSED & uItemState/*IsButtonPressed(uItemId)*/)
			rtDraw.OffsetRect(1, 1);
		else if (bHover/*iIndex == GetHotItem()*/)
			rtDraw.OffsetRect(-1, -2);
	}


	ZeroMemory(&tbi, sizeof(TBBUTTONINFO));
	tbi.cbSize = sizeof(TBBUTTONINFO);
	tbi.dwMask = TBIF_TEXT | TBIF_IMAGE;
	tbi.pszText = szText;
	tbi.cchText = 1024;
	//if (GetButtonInfo(p->nmcd.dwItemSpec, &tbi))
	GetButtonInfo(uItemId, &tbi);
	{

		rtText = rtDraw;

		if (tbi.iImage < parrImgs->GetCount())
		{
			pIconImg = parrImgs->GetAt(tbi.iImage);
			if (NULL != pIconImg)
			{
				iIconTop = rtDraw.Height() - pIconImg->GetHeight();
				iIconTop /= 2;
				iIconTop += rtDraw.top;
				pIconImg->Draw(pDC->GetSafeHdc(), rtDraw.left, iIconTop);
				rtText.left += pIconImg->GetWidth() + 4;
			}
		}


		{
			CWndFontDC	fontDC(pDC->GetSafeHdc(), GetSafeHwnd());
			CTextDC		textDC(pDC->GetSafeHdc(), clrText);
			
			pDC->DrawText(tbi.pszText, -1, &rtText, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
		}
	}

}