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

📄 splitterxy.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
字号:
// SplitterXY.cpp : implementation file//#include "stdafx.h"#include "fusion.h"#include "SplitterXY.h"#include "FusionColorUI.h"#include "SuppressStyle.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// RxSplitterXRxSplitterX::RxSplitterX(){	m_bIsFixed		= FALSE;	m_pParentWnd	= NULL;	m_nMinLeft		= m_nMinRight = 50;    m_leftIDs.RemoveAll();	m_rightIDs.RemoveAll();	m_brFace.CreateSolidBrush(RXCOLOR_11);}RxSplitterX::~RxSplitterX(){}BEGIN_MESSAGE_MAP(RxSplitterX, CWnd)	//{{AFX_MSG_MAP(RxSplitterX)	ON_WM_SETCURSOR()	ON_WM_LBUTTONDOWN()	ON_WM_MOUSEMOVE()	ON_WM_LBUTTONUP()	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// RxSplitterX message handlersBOOL RxSplitterX::PreCreateWindow(CREATESTRUCT& cs) {	cs.style &= ~WS_BORDER;	cs.style |= WS_CLIPSIBLINGS;	cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW, 										AfxGetApp()->LoadCursor(IDC_ARROW), m_brFace, NULL);		return CWnd::PreCreateWindow(cs);}void RxSplitterX::PostNcDestroy() {	CWnd::PostNcDestroy();	delete this;}BOOL RxSplitterX::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) {	if(!m_bIsFixed)	{		::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32644)));		return TRUE;	}		return CWnd::OnSetCursor(pWnd, nHitTest, message);}void RxSplitterX::OnLButtonDown(UINT nFlags, CPoint point) {	if(!m_bIsFixed)	{		SetCapture();		m_ptOldPoint = point;				// don't handle if no room to drag		RECT rectMouseClip;		if (!GetMouseClipRect(&rectMouseClip, point)) return;		::ClipCursor(&rectMouseClip);		GetWindowRect(m_rcOrg);		m_szBar = CSize(m_rcOrg.Width(), m_rcOrg.Height());		m_pParentWnd->ScreenToClient(m_rcOrg); 		// get DC for drawing		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC				*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcOrg, m_szBar, NULL, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);				m_rcOld = m_rcCur = m_rcOrg;	}		CWnd::OnLButtonDown(nFlags, point);}void RxSplitterX::OnMouseMove(UINT nFlags, CPoint point) {	if(!m_bIsFixed && GetCapture() == this)	{		int nDiffX = point.x - m_ptOldPoint.x;		m_rcCur = m_rcOrg;		m_rcCur.left += nDiffX;		m_rcCur.right += nDiffX;		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC				*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcCur, m_szBar, &m_rcOld, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);		m_rcOld = m_rcCur;	}			CWnd::OnMouseMove(nFlags, point);}void RxSplitterX::OnLButtonUp(UINT nFlags, CPoint point) {	if(!m_bIsFixed && GetCapture() == this)	{		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC		*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcCur, m_szBar, NULL, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);		ReleaseCapture();		::ClipCursor(NULL);		// move the splitter bar & re-position the attached panes if necessary		SetWindowPos(NULL, m_rcCur.left, m_rcCur.top, -1, -1, SWP_NOSIZE|SWP_NOZORDER);		RecalcLayout();	}		CWnd::OnLButtonUp(nFlags, point);}/////////////////////////////////////////////////////////////////////////////// User Defined FunctionsBOOL RxSplitterX::BindToView(CWnd *pWnd, DWORD nMinLeft, DWORD nMinRight){	m_pParentWnd = pWnd;	m_nMinLeft = nMinLeft;	m_nMinRight = nMinRight;	return TRUE;}BOOL RxSplitterX::AttachAsLeftPane(DWORD ctrlID){    m_leftIDs.Add(ctrlID);	return TRUE;}BOOL RxSplitterX::AttachAsRightPane(DWORD ctrlID){    m_rightIDs.Add(ctrlID);	return TRUE;}BOOL RxSplitterX::DetachLeftPane(){	int		i;	DWORD	nID;	CWnd	*pane;    for (i = 0; i < m_leftIDs.GetSize(); i++)	{        nID = m_leftIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);        pane->ShowWindow(SW_HIDE);	}	m_leftIDs.RemoveAll();	return TRUE;}BOOL RxSplitterX::VisibleLeftPane(BOOL bShow){	int		i;	DWORD	nID;	CWnd	*pane = NULL;		for (i = 0; i < m_leftIDs.GetSize(); i++)	{        nID = m_leftIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(bShow ? SW_SHOW : SW_HIDE);	}	return TRUE;}BOOL RxSplitterX::DetachRightPane(){	int		i;	DWORD	nID;	CWnd	*pane;	for (i = 0; i < m_rightIDs.GetSize(); i++)	{		nID = m_rightIDs.GetAt(i);		pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(SW_HIDE);	}    m_rightIDs.RemoveAll();	return TRUE;}BOOL RxSplitterX::VisibleRightPane(BOOL bShow){	int		i;	DWORD	nID;	CWnd	*pane;	for (i = 0; i < m_rightIDs.GetSize(); i++)	{		nID = m_rightIDs.GetAt(i);		pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(bShow ? SW_SHOW : SW_HIDE);	}	return TRUE;}// 嘿绢 乐绰 芒阑 见扁绊 磊脚档 见变促.BOOL RxSplitterX::Unbind(){	DetachLeftPane();	DetachRightPane();	ShowWindow(SW_HIDE);    return TRUE;}// 嘿绢 乐绰 芒阑 见扁绊 磊脚档 见变促.BOOL RxSplitterX::VisibleAllPane(BOOL bShow){	VisibleLeftPane(bShow);	VisibleRightPane(bShow);	ShowWindow(bShow ? SW_SHOW : SW_HIDE);    return TRUE;}void RxSplitterX::SetMinWidth(int nMinLeft, int nMinRight){	m_nMinLeft = nMinLeft;	m_nMinRight = nMinRight;}void RxSplitterX::RecalcLayout(){    CWnd	*pane;    RECT	rcBar, rcPane;    GetWindowRect(&rcBar);    m_pParentWnd->ScreenToClient(&rcBar);    int i;    DWORD nID;	// Attach to left    for (i = 0; i < m_leftIDs.GetSize(); i++)	{        nID = m_leftIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);        pane->GetWindowRect(&rcPane);        m_pParentWnd->ScreenToClient(&rcPane);        rcPane.right = rcBar.left;        pane->MoveWindow(&rcPane);    }	// Attach to right    for (i = 0; i < m_rightIDs.GetSize(); i++)	{		nID = m_rightIDs.GetAt(i);		pane = m_pParentWnd->GetDlgItem(nID);		pane->GetWindowRect(&rcPane);		m_pParentWnd->ScreenToClient(&rcPane);		rcPane.left = rcBar.right;		pane->MoveWindow(&rcPane);    }}BOOL RxSplitterX::GetMouseClipRect(LPRECT rcClip, CPoint point){    RECT rcOrg, rcTarget, rcParent, rcPane;    int i;    DWORD nID;    GetWindowRect(&rcOrg);    m_pParentWnd->GetClientRect(&rcParent);    m_pParentWnd->ClientToScreen(&rcParent);    rcTarget = rcOrg;    rcTarget.left = rcParent.left + m_nMinLeft;    for (i = 0; i < m_leftIDs.GetSize(); i++) {        nID = m_leftIDs.GetAt(i);        m_pParentWnd->GetDlgItem(nID)->GetWindowRect(&rcPane);        if (rcTarget.left < rcPane.left + m_nMinLeft) {            rcTarget.left = rcPane.left + m_nMinLeft;        }    }    rcTarget.right = rcParent.right - m_nMinRight;    for (i = 0; i < m_rightIDs.GetSize(); i++) {        nID = m_rightIDs.GetAt(i);        m_pParentWnd->GetDlgItem(nID)->GetWindowRect(&rcPane);        if (rcTarget.right > rcPane.right - m_nMinRight) {            rcTarget.right = rcPane.right - m_nMinRight;        }    }    if (rcTarget.left >= rcTarget.right) {        TRACE(_T("No room to drag the x-splitter bar"));        return FALSE;    }    rcClip->left = rcTarget.left + point.x;    rcClip->right = rcTarget.right - (rcOrg.right - rcOrg.left - point.x) + 1;    rcClip->top = rcOrg.top;    rcClip->bottom = rcOrg.bottom;    return TRUE;}/////////////////////////////////////////////////////////////////////////////// RxSplitterY/////////////////////////////////////////////////////////////////////////////RxSplitterY::RxSplitterY(){	m_bIsFixed		= FALSE;	m_pParentWnd	= NULL;	m_nMinTop		= m_nMinBottom = 50;    m_topIDs.RemoveAll();	m_bottomIDs.RemoveAll();	m_brFace.CreateSolidBrush(RXCOLOR_11);}RxSplitterY::~RxSplitterY(){}BEGIN_MESSAGE_MAP(RxSplitterY, CWnd)	//{{AFX_MSG_MAP(RxSplitterY)	ON_WM_SETCURSOR()	ON_WM_LBUTTONDOWN()	ON_WM_MOUSEMOVE()	ON_WM_LBUTTONUP()	//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// RxSplitterY message handlersBOOL RxSplitterY::PreCreateWindow(CREATESTRUCT& cs) {	cs.style &= ~WS_BORDER;	cs.style |= WS_CLIPSIBLINGS;	cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW, 										AfxGetApp()->LoadCursor(IDC_ARROW), m_brFace, NULL);		return CWnd::PreCreateWindow(cs);}void RxSplitterY::PostNcDestroy() {	CWnd::PostNcDestroy();	delete this;}BOOL RxSplitterY::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) {	if(!m_bIsFixed)	{		::SetCursor(AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32645)));		return TRUE;	}		return CWnd::OnSetCursor(pWnd, nHitTest, message);}void RxSplitterY::OnLButtonDown(UINT nFlags, CPoint point) {	if(!m_bIsFixed)	{		SetCapture();		m_ptOldPoint = point;				// don't handle if no room to drag		RECT rectMouseClip;		if (!GetMouseClipRect(&rectMouseClip, point)) return;		::ClipCursor(&rectMouseClip);		GetWindowRect(m_rcOrg);		m_szBar = CSize(m_rcOrg.Width(), m_rcOrg.Height());		m_pParentWnd->ScreenToClient(m_rcOrg); 		// get DC for drawing		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC				*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcOrg, m_szBar, NULL, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);				m_rcOld = m_rcCur = m_rcOrg;	}		CWnd::OnLButtonDown(nFlags, point);}void RxSplitterY::OnMouseMove(UINT nFlags, CPoint point) {	if(!m_bIsFixed && GetCapture() == this)	{		int nDiffY = point.y - m_ptOldPoint.y;		m_rcCur = m_rcOrg;		m_rcCur.top += nDiffY;		m_rcCur.bottom += nDiffY;		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC				*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcCur, m_szBar, &m_rcOld, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);		m_rcOld = m_rcCur;	}			CWnd::OnMouseMove(nFlags, point);}void RxSplitterY::OnLButtonUp(UINT nFlags, CPoint point) {	if(!m_bIsFixed && GetCapture() == this)	{		RxSuppressStyle	supStyle(m_pParentWnd->GetSafeHwnd(), WS_CLIPCHILDREN);		CDC				*pParentDC;		pParentDC = m_pParentWnd->GetDC();		pParentDC->DrawDragRect(&m_rcCur, m_szBar, NULL, m_szBar);		m_pParentWnd->ReleaseDC(pParentDC);		ReleaseCapture();		::ClipCursor(NULL);		// move the splitter bar & re-position the attached panes if necessary		SetWindowPos(NULL, m_rcCur.left, m_rcCur.top, -1, -1, SWP_NOSIZE|SWP_NOZORDER);		RecalcLayout();	}		CWnd::OnLButtonUp(nFlags, point);}/////////////////////////////////////////////////////////////////////////////// User Defined FunctionsBOOL RxSplitterY::BindToView(CWnd *pWnd, DWORD nMinTop, DWORD nMinBottom){	m_pParentWnd = pWnd;	m_nMinTop = nMinTop;	m_nMinBottom = nMinBottom;	return TRUE;}BOOL RxSplitterY::AttachAsTopPane(DWORD ctrlID){    m_topIDs.Add(ctrlID);	return TRUE;}BOOL RxSplitterY::AttachAsBottomPane(DWORD ctrlID){    m_bottomIDs.Add(ctrlID);	return TRUE;}BOOL RxSplitterY::DetachTopPane(){	int		i;	DWORD	nID;	CWnd	*pane;    for (i = 0; i < m_topIDs.GetSize(); i++)	{        nID = m_topIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);        pane->ShowWindow(SW_HIDE);	}	m_topIDs.RemoveAll();	return TRUE;}BOOL RxSplitterY::VisibleTopPane(BOOL bShow){	int		i;	DWORD	nID;	CWnd	*pane;    for (i = 0; i < m_topIDs.GetSize(); i++)	{        nID = m_topIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(bShow ? SW_SHOW : SW_HIDE);	}	return TRUE;}BOOL RxSplitterY::DetachBottomPane(){	int		i;	DWORD	nID;	CWnd	*pane;	for (i = 0; i < m_bottomIDs.GetSize(); i++)	{		nID = m_bottomIDs.GetAt(i);		pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(SW_HIDE);	}    m_bottomIDs.RemoveAll();	return TRUE;}BOOL RxSplitterY::VisibleBottomPane(BOOL bShow){	int		i;	DWORD	nID;	CWnd	*pane;	for (i = 0; i < m_bottomIDs.GetSize(); i++)	{		nID = m_bottomIDs.GetAt(i);		pane = m_pParentWnd->GetDlgItem(nID);		pane->ShowWindow(bShow ? SW_SHOW : SW_HIDE);	}	return TRUE;}// 嘿绢 乐绰 芒阑 见扁绊 磊脚档 见变促.BOOL RxSplitterY::Unbind(){	DetachTopPane();	DetachBottomPane();	ShowWindow(SW_HIDE);    return TRUE;}BOOL RxSplitterY::VisibleAllPane(BOOL bShow){	VisibleTopPane(bShow);	VisibleBottomPane(bShow);	ShowWindow(bShow ? SW_SHOW : SW_HIDE);    return TRUE;}void RxSplitterY::SetMinHeight(int nMinTop, int nMinBottom){	m_nMinTop = nMinTop;	m_nMinBottom = nMinBottom;}void RxSplitterY::RecalcLayout(){    CWnd *pane;    RECT rcBar, rcPane;    GetWindowRect(&rcBar);    m_pParentWnd->ScreenToClient(&rcBar);    int i;    DWORD nID;	// Attach to top	for (i = 0; i < m_topIDs.GetSize(); i++)	{        nID = m_topIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);        pane->GetWindowRect(&rcPane);        m_pParentWnd->ScreenToClient(&rcPane);        rcPane.bottom = rcBar.top;        pane->MoveWindow(&rcPane);    }	// Attach to bottom	for (i = 0; i < m_bottomIDs.GetSize(); i++)	{        nID = m_bottomIDs.GetAt(i);	    pane = m_pParentWnd->GetDlgItem(nID);        pane->GetWindowRect(&rcPane);        m_pParentWnd->ScreenToClient(&rcPane);        rcPane.top = rcBar.bottom;        pane->MoveWindow(&rcPane);    }}// 付快胶啊 框流老荐 乐绰 康开阑 汲沥茄促.BOOL RxSplitterY::GetMouseClipRect(LPRECT rcClip, CPoint point){    RECT rcOrg, rcTarget, rcParent, rcPane;    int i;    DWORD nID;    GetWindowRect(&rcOrg);    m_pParentWnd->GetClientRect(&rcParent);    m_pParentWnd->ClientToScreen(&rcParent);    rcTarget = rcOrg;    rcTarget.top = rcParent.top + m_nMinTop;    for (i = 0; i < m_topIDs.GetSize(); i++) {        nID = m_topIDs.GetAt(i);        m_pParentWnd->GetDlgItem(nID)->GetWindowRect(&rcPane);        if (rcTarget.top < rcPane.top + m_nMinTop) {            rcTarget.top = rcPane.top + m_nMinTop;        }    }    rcTarget.bottom = rcParent.bottom - m_nMinBottom;    for (i = 0; i < m_bottomIDs.GetSize(); i++) {        nID = m_bottomIDs.GetAt(i);        m_pParentWnd->GetDlgItem(nID)->GetWindowRect(&rcPane);        if (rcTarget.bottom > rcPane.bottom - m_nMinBottom) {            rcTarget.bottom = rcPane.bottom - m_nMinBottom;        }    }    if (rcTarget.top >= rcTarget.bottom) {        TRACE(_T("No room to drag the y-splitter bar"));        return FALSE;    }    rcClip->left = rcOrg.left;    rcClip->right = rcOrg.right;    rcClip->top = rcTarget.top + point.y;    rcClip->bottom = rcTarget.bottom - (rcOrg.bottom - rcOrg.top - point.y) + 1;    return TRUE;}

⌨️ 快捷键说明

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