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

📄 textdiagramctrl.h

📁 TabBars的开源源码
💻 H
字号:
#if !defined(AFX_TEXTDIAGRAMCTRL_H__DB16232E_C9BD_483B_86CA_5858C77045FC__INCLUDED_)
#define AFX_TEXTDIAGRAMCTRL_H__DB16232E_C9BD_483B_86CA_5858C77045FC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TextDiagramCtrl.h : header file
//

#include "textdiagram.h"
#include "maskedit.h"

/////////////////////////////////////////////////////////////////////////////
// CTextDiagramCtrl window

// WM_NOTIFY codes
enum 
{
	TDN_SELCHANGE = 1,
	TDN_SELRECTMOVE,
	TDN_SELRECTDELETE,
	TDN_SELRECTSIZE,
	TDN_DBLCLK,
	TDN_SELRECTTEXTCHANGE,
	TDN_IMPLCONNNEW, // host must implement this functionality

	TDN_INTERNALERROR,
};

struct TDNHDR
{
	NMHDR nmhdr;
	POINT ptCursor; // client coords
};

//{{DIAGRAM_START
//                                     
//           ----------------          
//          |CTextDiagramCtrl|         
//          |                |         
//           #--------------#          
//           |              |          
//   --------*-----     ----*--------- 
//  |CWnd          |   |CTextDiagram  |
//  |              |   |              |
//  |              |   |              |
//  |              |   |              |
//  |              |   |              |
//   --------------     -------------- 
//
//}}DIAGRAM_END
class CTextDiagramCtrl : public CWnd, public CTextDiagram
{
// Construction
public:
	CTextDiagramCtrl();
	virtual ~CTextDiagramCtrl();

// Operations
public:
	BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParent, UINT nID);

	void SetDiagram(const CTextDiagram& diagram);
	void SetDiagram(const CStringArray& diagram);
	void SetDiagram(LPCTSTR szDiagram);
	void ResetDiagram();

	int AddRect(LPCRECT pRect = NULL, LPCTSTR szText = NULL);
	BOOL DeleteRect(int nRect);
	BOOL SetRect(int nRect, const CTDRect& rect);
	BOOL SetText(int nRect, LPCTSTR szText);

	void EditSelectedText();
	inline BOOL EditingText() { return (m_editText.GetSafeHwnd() && m_editText.IsWindowVisible()); }

	int AddConnection(int nRectFrom, int nRectTo, int nSideFrom);
	BOOL DeleteConnection(int nConn);
	BOOL SetConnection(int nConn, const CTDConnection& conn);

	int GetSelRect() { return m_nSelRect; }
	int HitTestConn(CPoint point); // client coords
	int HitTestRect(CPoint point); // client coords

protected:
	int m_nSelRect;
	CPoint m_ptScrollOffset; // for scrolling
	BOOL m_bMoving;
	int m_nSizing;
	CPoint m_ptDragStart, m_ptDragPrev;
	CMaskEdit m_editText;
	BOOL m_bDblClick;
	CPoint m_ptContextMenu; // client coords

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTextDiagramCtrl)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

	// Generated message map functions
protected:
	//{{AFX_MSG(CTextDiagramCtrl)
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnCaptureChanged(CWnd *pWnd);
	afx_msg UINT OnNcHitTest(CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg UINT OnGetDlgCode();
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
	afx_msg void OnRectNew();
	afx_msg void OnRectDelete();
	afx_msg void OnRectEditText();
	afx_msg void OnConnNew();
	afx_msg void OnConnModify();
	afx_msg void OnConnDelete();
	afx_msg void OnReset();
	//}}AFX_MSG
	afx_msg void OnEndTextEdit();
	DECLARE_MESSAGE_MAP()

protected:
	void DrawArrow(CDC* pDC, CPoint point, int nDirection);
	void DrawRect(CDC* pDC, const CTDRect& rect, BOOL bSelected);
	void DrawConn(CDC* pDC, const CTDConnection& conn);
	void DrawGrid(CDC* pDC);
	void RenderText(CDC* pDC, const CRect& rect, const CString& sText);

	void UpdateScrollbars();
	CRect GetBoundingRect();
	BOOL RebuildConnections();
	void SnapToGrid(CRect& rect);
	void ClientToLogical(CPoint& point);
	void LogicalToClient(CRect& rect);

	void SendNotification(UINT nCode, CPoint point = CPoint(-1, -1));
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TEXTDIAGRAMCTRL_H__DB16232E_C9BD_483B_86CA_5858C77045FC__INCLUDED_)

⌨️ 快捷键说明

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