⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guitoolbarwnd.cpp.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
					}
					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);

  
}


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);		
	
}

void CGuiToolBarWnd::DrawGripper(CWindowDC* dc,CRect* rcWin)
{

	if (m_dwStyle & CBRS_FLOATING) return ;
	if(!m_bIsXp) //no es XP
	{
		if (m_dwStyle & CBRS_ORIENT_HORZ)
		{
			rcWin->top+=2;
			rcWin->left+=2;
			rcWin->right=rcWin->left+3;
			rcWin->bottom-=1;
			dc->Draw3dRect(rcWin,::GetSysColor(COLOR_BTNHIGHLIGHT),
										 ::GetSysColor(COLOR_BTNSHADOW));
			if (m_style == Office97)
			{
				rcWin->left=rcWin->right+1;
				rcWin->right=rcWin->left+3;
				dc->Draw3dRect(rcWin,::GetSysColor(COLOR_BTNHIGHLIGHT),
										 ::GetSysColor(COLOR_BTNSHADOW));
			}
		}
		else
		{
			rcWin->top+=2;
			//rcWin->left+=1;
			rcWin->right-=2;
			rcWin->bottom=rcWin->top+3;
			dc->Draw3dRect(rcWin,::GetSysColor(COLOR_BTNHIGHLIGHT),
										 ::GetSysColor(COLOR_BTNSHADOW));
			if (m_style == Office97)
			{
				rcWin->top=rcWin->bottom+1;
				rcWin->bottom=rcWin->top+3;
				dc->Draw3dRect(rcWin,::GetSysColor(COLOR_BTNHIGHLIGHT),
										 ::GetSysColor(COLOR_BTNSHADOW));
			}

		}
	}
	else
	{
		if (m_dwStyle & CBRS_ORIENT_HORZ)
		{
			
			rcWin->top+=5;
			rcWin->left+=4;
			rcWin->right=rcWin->left+3;
			rcWin->bottom-=3;

			for (int i=0; i < rcWin->Height(); i+=2)
			{
				CRect rcWindow;
				CBrush cb;
				cb.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
				rcWindow=rcWin;
				rcWindow.top=rcWin->top+i;
				rcWindow.bottom=rcWindow.top+1;
				dc->FillRect(rcWindow,&cb);
		
			}
			
		}
		else
		{
			rcWin->top+=2;
			rcWin->left+=2;
			rcWin->right-=2;
			rcWin->bottom=rcWin->top+3;
			for (int i=0; i < rcWin->Width(); i+=2)
			{
				CRect rcWindow;
				CBrush cb;
				cb.CreateSolidBrush(::GetSysColor(COLOR_BTNSHADOW));
				rcWindow=rcWin;
				rcWindow.left=rcWindow.left+i;
				rcWindow.right=rcWindow.left+1;
				dc->FillRect(rcWindow,&cb);
		
			}

		}
	}

}

void CGuiToolBarWnd::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CToolBar::OnLButtonDown(nFlags, point);
	
	if (m_iSelected == 1) return;
	m_iSelected =1;
	

		
}

BOOL CGuiToolBarWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{

	CPoint ptCurPos; 
	CRect rc;GetClientRect(rc);
	GetCursorPos (&ptCurPos);
	ScreenToClient (&ptCurPos);
	if (m_dwStyle & CBRS_ORIENT_HORZ)
	{
		rc.right=rc.left+2;
		if (ptCurPos.x< 0)
		{
			SetCursor (LoadCursor(NULL, IDC_SIZEALL));
			return TRUE;
		}
	}
	else
	{
		rc.bottom=rc.top+2;
		if (ptCurPos.y< 0)
		{
			SetCursor (LoadCursor(NULL, IDC_SIZEALL));
			return TRUE;
		}
	}
	return CToolBar::OnSetCursor(pWnd, nHitTest, message);

}



void CGuiToolBarWnd::OnLButtonUp(UINT nFlags, CPoint point) 
{
	CToolBar::OnLButtonUp(nFlags, point);
	
	if (m_iSelected == 1)
	{
		m_iSelected =0;
		KillTimer(1);
		SetTimer(1,10,NULL);
	}
}

void CGuiToolBarWnd::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CRect m_rect;
	CPoint pt(GetMessagePos());
	ScreenToClient(&pt);
	GetClientRect(m_rect);
	if (nIDEvent == 1)
	{
		
		if (!m_rect.PtInRect(pt))
		{
			m_iSelected =0;
			KillTimer(1);
			Invalidate();
			UpdateWindow();
			
		}
	}
	CToolBar::OnTimer(nIDEvent);
}



//**************************************************************************
int CGuiToolBarWnd::GetLastPos()
{
	
	int nNumBars=(int)m_pDockBar->m_arrBars.GetSize();
	int m_pos=m_pDockBar->FindBar(this);
	for(int i=m_pos+1; i< nNumBars;i++)
	{
		if (m_pDockBar->m_arrBars[i]== NULL)
		    return i-1;	
	}
	return -1;
}

//**************************************************************************
int CGuiToolBarWnd::GetFirstPos()
{
	int m_pos=m_pDockBar->FindBar(this);
	for(int i=m_pos; i>=0;i--)
	{
		if (m_pDockBar->m_arrBars[i]== NULL)
		    return i+1;	
	}
	return -1;

}
//**************************************************************************
CRect CGuiToolBarWnd::GetDockRect()
{
	CRect rcWin;
	if (IsVert())
		if (IsLeft())
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rcWin);
		else
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_RIGHT)->GetWindowRect(rcWin);
	else
		if(IsBottom())
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_BOTTOM)->GetWindowRect(rcWin);
		else
			m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rcWin);
	return rcWin;
}
//**************************************************************************
int CGuiToolBarWnd::GetHiWid()
{
	CRect rcWin;
	rcWin=GetDockRect();
	if (IsVert())
		return rcWin.Height() ;
	else
		return rcWin.Width() ;
}
//**************************************************************************

void CGuiToolBarWnd::SetRealSize()
{
	CRect rcWinFrame;
	CRect rcThisBar;
	
	int nVisibles=0;
	
	int nThis = m_pDockBar->FindBar(this);
	int nFirst= GetFirstPos();
	int nLast=  GetLastPos();
	UINT m_nDockBarID = m_pDockBar->GetDlgCtrlID();
	int  nMaxlen=GetHiWid();
    int  nLen=0; 
	for (int i=nFirst;i <nLast;  i++)
	{
		
		CGuiToolBarWnd* pBar;
		pBar = (CGuiToolBarWnd*) m_pDockBar->m_arrBars[i];
		if (HIWORD(pBar) == 0) continue; 
		if (!pBar->IsVisible()) continue;
		
		CRect rc;
		pBar->GetWindowRect(rc);
		if (IsVert())
			nLen+=rc.Height() ;
		else
			nLen+= rc.Width() ;
		nVisibles++;
	}
	
	if ( nLen > nMaxlen)
	{
		int nDif=nLen-nMaxlen;
		

	}
	


/*	if (rcThisBar.Width() > nAfterThis)
	{
		if (nVisibles > 0)
			nAfterThis/=nVisibles;
		

	}
*/		
}

#define CX_OVERLAP  0
//***************************************************************************
CSize  CGuiToolBarWnd::CalcSize(TBBUTTON* pData, int nCount)
{
	ASSERT(pData != NULL && nCount > 0);
	BOOL bDrow=FALSE;
	int  nNumDrow=0;
	CPoint cur(0,0);
	CSize sizeResult(0,0);
	CClientDC dc(this);
	int xSizeMin=32;
	if(m_dwStyle & CBRS_FLOATING )  
		SetSizes(m_sizeButton, m_sizeImage);
	if (bVertDocked)
	 ::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 0, 0);
	else
	 ::SendMessage(m_hWnd, TB_SETMAXTEXTROWS, 1, 0);
	//CFont* m_fontOld=dc.SelectObject(&m_cfont);
//	SetRealSize();
	DWORD dwExtendedStyle = DefWindowProc(TB_GETEXTENDEDSTYLE, 0, 0);
	for (int i = 0; i < nCount; i++)
	{
		
		if ((pData[i].fsStyle &  TBSTYLE_SEP) &&(pData[i].idCommand!=0))
		{
		    if (bVertDocked)
			{
				 CWnd * pWnd =GetDlgItem(pData[i].idCommand);
				 ASSERT_VALID(pWnd);
				 pWnd->ShowWindow( SW_HIDE   );
				 pData[i].fsState |= TBSTATE_HIDDEN;
				 continue;
				
			}
			else
			{
				
					CWnd * pWnd =GetDlgItem(pData[i].idCommand);
					ASSERT_VALID(pWnd);
					pData[i].fsState &= ~TBSTATE_HIDDEN;
					pWnd->ShowWindow( SW_SHOW   );
					
								
			}
		}
		
		int cySep = pData[i].iBitmap;
		cySep = cySep * 2 / 3;
		CRect rci;
		GetItemRect(i, &rci);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -