Esempio n. 1
0
void CGuiToolBarWnd::DrawArrow(CDC* pDC,CRect m_rc)
{
	int difh =m_rc.Height()-mHeight.y;
	difh/=2;
	
	m_rc.left=m_rc.right-_AfxGetDropDownWidth();
	m_imgArrow.Draw(pDC,0,CPoint(m_rc.left+2,m_rc.top+difh),ILD_TRANSPARENT);		
	
}
Esempio n. 2
0
CGuiToolBarWnd::CGuiToolBarWnd()
{
	m_style = Office2000; //Office97;  //by default
	m_pArray.RemoveAll();
	m_iElements=0;
	m_bIsXp=TRUE;
	bPressDown=FALSE;
	m_imgArrow.Create(IDB_DOCKBAR,9,10,RGB(255,0,255));
	_AfxGetDropDownWidth();
	//m_iWidthDrowDown=GetSystemMetrics(SM_CXHTHUMB);
	CBitmap cbmp;
	BITMAP bmp;
	cbmp.LoadBitmap(IDB_DOCKBAR);
	cbmp.GetBitmap(&bmp);
	mHeight=CPoint(bmp.bmWidth,bmp.bmHeight);	
	// Modified Bu SunZhenyu
	if( !m_cfont.CreateStockObject( DEFAULT_GUI_FONT ) )
		m_cfont.CreateStockObject( ANSI_VAR_FONT );
	// m_cfont.CreateFont(14,0,0,0,400,0,0,0,0,1,2,1,34,_T("Marlett"));
}
Esempio n. 3
0
// Will work only for unwrappable hosizontal toolbars  
// Fixes MFC bug with drop-down buttons when system metrics are changed
// It's a copy of CalcSize() protected function: fixed drop-down width
CSize CIVToolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
	CToolBarCtrl & tb = GetToolBarCtrl();
	int nCount = tb.GetButtonCount();

	ASSERT(nCount > 0);

	CPoint cur(0,0);
	CSize sizeResult(0,0);

	DWORD dwExtendedStyle = tb.GetExtendedStyle();

	for (int i = 0; i < nCount; i++)
	{
		TBBUTTON btn;
		tb.GetButton(i, &btn);
		
		//WINBUG: The IE4 version of COMCTL32.DLL calculates the separation
		//  on a TBSTYLE_WRAP button as 100% of the value in iBitmap compared
		//  to the other versions which calculate it at 2/3 of that value.
		//  This is actually a bug which should be fixed in IE 4.01, so we
		//  only do the 100% calculation specifically for IE4.
		int cySep = btn.iBitmap;
		if (!(GetStyle() & TBSTYLE_FLAT) && _AfxGetComCtlVersion() != VERSION_IE4)
			cySep = cySep * 2 / 3;

		if (btn.fsState & TBSTATE_HIDDEN)
			continue;

		int cx = m_sizeButton.cx;
		if (btn.fsStyle & TBSTYLE_SEP)
		{
			// a separator represents either a height or width
			if (btn.fsState & TBSTATE_WRAP)
				sizeResult.cy = max(cur.y + m_sizeButton.cy + cySep, sizeResult.cy);
			else
				sizeResult.cx = max(cur.x + btn.iBitmap, sizeResult.cx);
		}
		else
		{
			// check for dropdown style, but only if the buttons are being drawn
			if ((btn.fsStyle & TBSTYLE_DROPDOWN) &&
				(dwExtendedStyle & TBSTYLE_EX_DRAWDDARROWS))
			{
				cx += _AfxGetDropDownWidth();
			}
			sizeResult.cx = max(cur.x + cx, sizeResult.cx);
			sizeResult.cy = max(cur.y + m_sizeButton.cy, sizeResult.cy);
		}

		if (btn.fsStyle & TBSTYLE_SEP)
			cur.x += btn.iBitmap;
		else
			cur.x += cx - CX_OVERLAP;

		if (btn.fsState & TBSTATE_WRAP)
		{
			cur.x = 0;
			cur.y += m_sizeButton.cy;
			if (btn.fsStyle & TBSTYLE_SEP)
				cur.y += cySep;
		}
	}
	return sizeResult;
	
}
Esempio n. 4
0
void CGuiToolBarWnd::OnPaint()
{

	CPaintDC dc(this);  	
	CRect rcBtn;
	
	int nBtn=GetToolBarCtrl().GetButtonCount();
	int iBitmap;
	UINT nID;
	UINT nStyle;
	WORD wStyle, wState;
	DWORD dwBarStyle = GetToolBarCtrl().GetStyle();
	BOOL mbIsPress;
	BOOL mbIsEnabled;
	CBrush cb;
	CImageList m_imgList;
	CRect rcUpdate;
	int iUltbot;
	CRect rcClient;
	GetClientRect(&rcClient);
	cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorXP());
	
    // draw borders in non-client area
    CRect rcDraw = rcClient;
 
	dc.FillRect(rcDraw, &cb);
	
	
	HIMAGELIST hiImg = 0;
	iBitmap=0;
	hiImg = HIMAGELIST(SendMessage(TB_GETIMAGELIST));
	m_imgList.Attach(hiImg);
	int j=0;
	for(int i=0; i < nBtn; i++)
	{
		
		bOver=FALSE;
		GetItemRect(i,&rcBtn);
		GetButtonInfo(i,nID,nStyle,iBitmap);
		wStyle= LOWORD(nStyle);
		wState= HIWORD(nStyle);
		if (wState & TBSTATE_HIDDEN) continue;
		if (wStyle == TBSTYLE_SEP)
		{
			if (!(wState & TBSTATE_WRAP) || ! IsFloating() )
			{
				CRect m_Separ;
				m_Separ=rcBtn;
				
				//si existe un separador vertical
				if (m_dwStyle & CBRS_ORIENT_HORZ)
				{
					dc.FillRect(&rcBtn,&cb);
					int nhalf=(m_Separ.Width()/2)-1;
					m_Separ.top-=1;
					m_Separ.left+=nhalf;
					m_Separ.right=m_Separ.left+1;
					m_Separ.bottom+=1;
					
				}
				else
				{
					int nhalf=(m_Separ.Width()/2)-1;
					int iHeigh=m_Separ.Height();
					
					m_Separ.left=0;
					m_Separ.right=m_Separ.left+m_Separ.Height()+1;
					m_Separ.top=iUltbot;
					m_Separ.bottom=m_Separ.top+m_Separ.Width();			
					dc.FillRect(&m_Separ,&cb);
					
					m_Separ.left=0;
					m_Separ.right=m_Separ.left+iHeigh+1;
					m_Separ.top=iUltbot+nhalf;
					m_Separ.bottom=m_Separ.top+1;
					
					
				}
				CBrush cbt;
				cbt.CreateSolidBrush(RGB(167, 167, 167));
				dc.FillRect(m_Separ,&cbt);
				continue;
				
			}
			
				 
		}
		else {
			
			mbIsPress=(wState & TBSTATE_CHECKED) || (wState & TBSTATE_PRESSED);
			mbIsEnabled= GetToolBarCtrl().IsButtonEnabled((int)nID);
			CPoint pt;
			GetCursorPos(&pt);
			ScreenToClient(&pt);
			CBrush cblu;
			if(!rcBtn.PtInRect(pt))
			{
				if (wState & TBSTATE_CHECKED)
				{
					cblu.CreateSolidBrush(GuiDrawLayer::GetRGBPressBXP());
					dc.FillRect(rcBtn,&cblu);					
				}
				else
				{
					dc.FillRect(rcBtn,&cb);
				}
			}
			else
			{
				
				if (bPressDown)
					dc.Draw3dRect(rcBtn,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
				else
					dc.Draw3dRect(rcBtn,GuiDrawLayer::GetRGBCaptionXP(),GuiDrawLayer::GetRGBCaptionXP());
				rcBtn.DeflateRect(1,1);
				if (wState & TBSTATE_CHECKED)
				{
					cblu.CreateSolidBrush(GuiDrawLayer::GetRGBFondoXP());
					dc.FillRect(rcBtn,&cblu);					
				}
				else
				{
					
					if (bPressDown)
					{
						cblu.CreateSolidBrush(GuiDrawLayer::GetRGBColorXP());
						dc.FillRect(rcBtn,&cblu);
					}
					else
					{
						cblu.CreateSolidBrush(mbIsPress?GuiDrawLayer::GetRGBPressBXP():GuiDrawLayer::GetRGBFondoXP());
						dc.FillRect(rcBtn,&cblu);					
					}
					if (wStyle == 8) 
					{
						
						CRect rcCli=rcBtn;
						int dif=rcBtn.right-_afxDropDownWidth;
						rcCli.left=dif+1;
						
						if (!bPressDown)
						{
							CPen Cp( PS_SOLID, 1, GuiDrawLayer::GetRGBCaptionXP());
							CPen* oldPen= dc.SelectObject(&Cp);
							dc.MoveTo(dif,rcBtn.top);
							dc.LineTo(dif,rcBtn.bottom);
							dc.SelectObject(oldPen);
						}
						
					}
					if (!mbIsPress && !bPressDown)
						bOver=TRUE;
					else
						bOver=FALSE;
					if (!bPressDown) 
						SetTimer(1,10,NULL);
					else
						KillTimer(1);		

				}
				rcBtn.InflateRect(1,1);
				
			}

		}

		if (wStyle != TBSTYLE_SEP)
	{
			
			int OldMode=dc.SetBkMode(TRANSPARENT);
			IMAGEINFO pImageInfo;
			m_imgList.GetImageInfo(iBitmap,&pImageInfo);
			CRect rcima =pImageInfo.rcImage;
			CSize siImg=CSize(rcima.Width(),rcima.Height());
			/* Modified By SunZhenyu 2003/6/27, Replace by the next 5 lines, CPoint pti(rcBtn.left+2,rcBtn.top+4); */
			CPoint pti(rcBtn.left+(rcBtn.Width()-siImg.cx)/2,rcBtn.top+4);
			if( dwBarStyle & TBSTYLE_LIST ) // ÎÄ×ÖÔÚÓÒ±ß
				pti = CPoint(rcBtn.left+4,rcBtn.top+(rcBtn.Height()-siImg.cy)/2);
			else if( wStyle & TBSTYLE_DROPDOWN )
				pti.x -= _AfxGetDropDownWidth()/2;
			CString mszText=GetButtonText(i);
			CFont* m_fontOld=dc.SelectObject(&m_cfont);
			if (!(wState & TBSTATE_ENABLED))
			{
				if (bOver==TRUE)
				{
					pti.x+=1;
					pti.y+=1;
					dc.DrawState(pti,siImg,m_imgList.ExtractIcon(iBitmap),DSS_MONO,CBrush (GuiDrawLayer::GetRGBColorShadow()));
							pti.x-=2;					pti.y-=2;
				
				}
				m_imgList.Draw(&dc, iBitmap, pti, ILD_TRANSPARENT);
				if (mszText.GetLength() > 0 && !bVertDocked)
				{
					CRect m_rctext=rcBtn;
					/* Modified By SunZhenyu 2003/6/27, Replace by the next 6 line, m_rctext.left+=siImg.cx+4; */
					if( dwBarStyle & TBSTYLE_LIST )
						m_rctext.left += siImg.cx+4;
					else
						m_rctext.top += siImg.cy+4;
					if( wStyle & TBSTYLE_DROPDOWN )
						m_rctext.right -= _AfxGetDropDownWidth();
					m_rctext.bottom-=1;
					/* Modified By SunZhenyu 2003/6/27, Replace by the next 5 line
					dc.DrawText(mszText,&m_rctext,DT_SINGLELINE|DT_BOTTOM|DT_CENTER);
					*/
					m_rctext.right-=1;
					if( dwBarStyle & TBSTYLE_LIST )
						dc.DrawText(mszText,&m_rctext,DT_SINGLELINE|DT_VCENTER|DT_RIGHT);
					else
						dc.DrawText(mszText,&m_rctext,DT_SINGLELINE|DT_BOTTOM|DT_CENTER);
				}
			}
			else
			{
				dc.DrawState(pti,siImg,m_imgList.ExtractIcon(iBitmap),DSS_DISABLED,(CBrush*)NULL);
				CRect m_rctext=rcBtn;
				/* Modified By SunZhenyu 2003/6/27, Replace by the next 5 line, m_rctext.left+=siImg.cx+4; */
				if( dwBarStyle & TBSTYLE_LIST )
					m_rctext.left += siImg.cx+4;
				else
					m_rctext.top += siImg.cy+4;
				m_rctext.bottom-=1;
				CSize szText=dc.GetTextExtent(mszText);
				/* Modified By SunZhenyu 2003/6/27, Replace by the next 4 lines,
				pti.x= m_rctext.left+2;
				pti.y= (m_rctext.Height()/2)-1;
				*/
				pti.x = m_rctext.left+(m_rctext.Width()-szText.cx)/2;
				if( wStyle & TBSTYLE_DROPDOWN )
					pti.x = m_rctext.left+(m_rctext.Width()-szText.cx-_AfxGetDropDownWidth())/2;
				pti.y= m_rctext.top+(m_rctext.Height()-szText.cy)/2;
				//DrawState(pt, m_Csize, m_szCaption, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
				dc.DrawState(pti,szText,mszText,DSS_DISABLED,TRUE,0,(HBRUSH)NULL);
			}
			
			if (wStyle == TBSTYLE_DROPDOWN) 
				DrawArrow(&dc,rcBtn);
			dc.SetBkMode(OldMode);
			// Modified By SunZhenyu
			dc.SelectObject(m_fontOld);
			iBitmap++;
			iUltbot=rcBtn.bottom;
			j++;
		}
	}
	m_imgList.Detach();
	
	
    ReleaseDC(&dc);

  
}