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

📄 bcgpeditctrl.h

📁 远程网络监视程序的源码
💻 H
📖 第 1 页 / 共 4 页
字号:
#if !defined(AFX_BCGPEDITCTRL_H__078F8590_E8CE_4F07_A08A_C41CEBE48D77__INCLUDED_)
#define AFX_BCGPEDITCTRL_H__078F8590_E8CE_4F07_A08A_C41CEBE48D77__INCLUDED_

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

#include "BCGCBPro.h"
#include "BCGPOutlineParser.h"

#pragma warning (disable : 4100) 

// UAT - undo action type
#define UAT_TYPE		0x000000FF
#define UAT_REASON		0xFFFFFF00

static const DWORD g_dwUATUndefined		= 0;
static const DWORD g_dwUATInsertData	= 0x01;
static const DWORD g_dwUATDeleteData	= 0x02;
static const DWORD g_dwUATIndentData	= 0x04;

static const DWORD g_dwUATTyping		= 0x100;
static const DWORD g_dwUATCut			= 0x200;
static const DWORD g_dwUATPaste			= 0x400;
static const DWORD g_dwUATDelete		= 0x800;
static const DWORD g_dwUATBackspace		= 0x1000;
static const DWORD g_dwUATDragDrop		= 0x2000;
static const DWORD g_dwUATEnter			= 0x4000;
static const DWORD g_dwUATIndent		= 0x8000;
static const DWORD g_dwUATUnindent		= 0x10000;
static const DWORD g_dwUATTab			= 0x20000;


static const DWORD g_dwUAFIns			= 0x1;
static const DWORD g_dwUAFOvr			= 0x2;

// canceled operations
static const DWORD g_dwOpUndo			= 0x1;
static const DWORD g_dwOpRedo			= 0x2;
static const DWORD g_dwOpSetOvrMode		= 0x4;
static const DWORD g_dwOpInvokeIS		= 0x8;
static const DWORD g_dwOpLeft			= 0x10;
static const DWORD g_dwOpRight			= 0x20;
static const DWORD g_dwOpUp				= 0x40;
static const DWORD g_dwOpDown			= 0x80;
static const DWORD g_dwOpPgUp			= 0x100;
static const DWORD g_dwOpPgDn			= 0x200;
static const DWORD g_dwOpHome			= 0x400;
static const DWORD g_dwOpNextWord		= 0x800;
static const DWORD g_dwOpPrevWord		= 0x1000;
static const DWORD g_dwOpPrevIndent		= 0x2000;
static const DWORD g_dwOpInsTab			= 0x4000;
static const DWORD g_dwOpLineConcat		= 0x8000;
static const DWORD g_dwOpDelete			= 0x10000;
static const DWORD g_dwOpPaste			= 0x20000;
static const DWORD g_dwOpCopy			= 0x40000;
static const DWORD g_dwOpCut			= 0x80000;
static const DWORD g_dwOpDelSelText		= 0x100000;
static const DWORD g_dwOpMakeSel		= 0x200000;
static const DWORD g_dwOpIndent			= 0x400000;
static const DWORD g_dwOpDragDrop		= 0x800000;
static const DWORD g_dwOpLineBroken		= 0x1000000;	

// canceled operation reasons
static const DWORD g_dwOpReasonLength	= 0x10000000;
static const DWORD g_dwOpReasonBufEmpty	= 0x20000000;	
static const DWORD g_dwOpReasonReadOnly	= 0x40000000;	
static const DWORD g_dwOpReasonError	= 0x80000000;	


static const DWORD g_dwBCGPEdit_BookMark		= 0x1;
static const DWORD g_dwBCGPEdit_NamedBookMark	= 0x2;
static const DWORD g_dwBCGPEdit_LineColorMarker	= 0x4;
static const DWORD g_dwBCGPEdit_HiliteMarker	= 0x8;
static const DWORD g_dwBCGPEdit_OutlineMarker	= 0x10;
static const DWORD g_dwBCGPEdit_MarkerReserved	= 0x0000FFE0;
static const DWORD g_dwBCGPEdit_FirstUserDefinedMarker = 0x00010000;

// CBCGPOutlineBaseNode flags:
static const DWORD g_dwOBFComplete		= 0x001;
static const DWORD g_dwOBFLeft			= 0x002;
static const DWORD g_dwOBFRight			= 0x004;
// Outline block types:
static const int g_nOBTUndefined			= -2;
static const int g_nOBTUserBlock			= -1;


/////////////////////////////////////////////////////////////////////////////
// CBCGPEditCtrl window

struct BCGCBPRODLLEXPORT BCGP_BASE_UNDO_DATA
{
	virtual ~BCGP_BASE_UNDO_DATA () {}
};

struct BCGCBPRODLLEXPORT BCGP_EDIT_UNDO_ACTION
{
	BCGP_EDIT_UNDO_ACTION ()
	{
		m_nActionOffset = -1;
		m_nCursorOffset = -1;
		m_dwActionType = g_dwUATUndefined;
		m_dwFlags = g_dwUAFIns;
		m_lpActionData = NULL;
		m_bDestroyActionData = FALSE;
		m_bForceNextUndo = FALSE;
	}

	~BCGP_EDIT_UNDO_ACTION ()
	{
		if (m_bDestroyActionData)
		{
			delete m_lpActionData;
		}
	}

	int						m_nActionOffset;
	int						m_nCursorOffset;
	DWORD					m_dwActionType;
	CString					m_strActionText;
	BCGP_BASE_UNDO_DATA*	m_lpActionData;
	DWORD					m_dwFlags;
	BOOL					m_bForceNextUndo;

	BOOL					m_bDestroyActionData;
};

struct BCGCBPRODLLEXPORT BCGP_EDIT_UNDO_INDENT_DATA : public BCGP_BASE_UNDO_DATA
{
	BCGP_EDIT_UNDO_INDENT_DATA () : m_nStartOffset (0), m_nEndOffset (0), m_bForward (FALSE)
	{
	}
	BCGP_EDIT_UNDO_INDENT_DATA (int nStart, int nEnd, int bFwd) :
					m_nStartOffset (nStart), m_nEndOffset (nEnd), m_bForward (bFwd)
	{
	}

	int				m_nStartOffset;
	int				m_nEndOffset;
	BOOL			m_bForward;
	CStringArray	m_arInsDelStrings;
};

struct BCGP_EDIT_COLOR_BLOCK  
{
	BCGP_EDIT_COLOR_BLOCK () :  m_clrForeground ((COLORREF)-1), 
								m_clrBackground ((COLORREF)-1), 
								m_bWholeText (FALSE), m_bAllowNestedBlocks (FALSE)
	{
	}

	CString		m_strOpen;
	CString		m_strClose;
	COLORREF	m_clrForeground;
	COLORREF	m_clrBackground;

	BOOL		m_bWholeText;
	BOOL		m_bAllowNestedBlocks;

	virtual bool operator==(BCGP_EDIT_COLOR_BLOCK& srcBlock)
	{
		return (m_bWholeText == srcBlock.m_bWholeText && 
				m_strOpen == srcBlock.m_strOpen && 
				m_strClose == srcBlock.m_strClose);
	}
};

struct BCGP_EDIT_SYNTAX_COLOR
{
	BCGP_EDIT_SYNTAX_COLOR () : m_clrForeground ((COLORREF)-1), 
								m_clrBackground ((COLORREF)-1),
								m_bCaseSensitive (TRUE)
	{
	}						

	BCGP_EDIT_SYNTAX_COLOR (COLORREF clrFore, COLORREF clrBk, BOOL bCaseSensitive = TRUE) : 
				m_clrForeground (clrFore), m_clrBackground (clrBk), 
				m_bCaseSensitive (bCaseSensitive)
	{
	}

	COLORREF	m_clrForeground;
	COLORREF	m_clrBackground;
	BOOL		m_bCaseSensitive;
};

struct BCGP_EDIT_COLOR_AREA 
{
	int			m_nStart;
	int			m_nEnd;
	COLORREF	m_clrForeground;
	COLORREF	m_clrBackground;

	BCGP_EDIT_COLOR_AREA& operator= (BCGP_EDIT_COLOR_BLOCK& srcBlock)
	{
		m_clrForeground = srcBlock.m_clrForeground;
		m_clrBackground = srcBlock.m_clrBackground;

		return *this;
	}
};

struct BCGP_EDIT_SYM_DEF
{
	BCGP_EDIT_SYM_DEF () : m_nIndex (-1), m_bAnimated (FALSE), m_bEnabled (TRUE),
							m_chReplacement (0)
	{
	}
	CString m_strSymText;
	CString m_strSymSequence;
	int		m_nIndex;
	BOOL	m_bAnimated;
	BOOL	m_bEnabled;
	TCHAR	m_chReplacement;
};

enum CBCGPEditMarkerRange
{
	NOT_IN_RANGE,
	FULL_IN_RANGE,
	PARTIAL_IN_RANGE
};

class BCGCBPRODLLEXPORT CBCGPEditMarker : public CObject
{
	DECLARE_DYNAMIC(CBCGPEditMarker)
public:
	CBCGPEditMarker () : m_nLine (-1), m_pData (NULL), 
		m_dwMarkerType ((DWORD) -1), m_unPriority (0)
	{

	}

	CBCGPEditMarker (const CBCGPEditMarker& srcMarker)
	{
		Copy (srcMarker);
	}

	~CBCGPEditMarker ()
	{
		DestroyData ();
	}

	virtual CBCGPEditMarker& operator=(const CBCGPEditMarker& srcMarker)
	{
		Copy (srcMarker);
		return *this;
	}

	virtual void Copy (const CBCGPEditMarker& srcMarker)
	{
		m_nLine = srcMarker.m_nLine;
		m_dwMarkerType = srcMarker.m_dwMarkerType;
		m_unPriority = srcMarker.m_unPriority;
		CopyData ((DWORD) srcMarker.m_pData);
	}

	virtual CBCGPEditMarkerRange IsInRange (int nStartPos, int nEndPos) const
	{
		if (m_nLine >= nStartPos && m_nLine <= nEndPos)
		{
			return FULL_IN_RANGE;
		}

		return NOT_IN_RANGE;
	}

	virtual CBCGPEditMarkerRange IsInRangeByOffset (int nStartPos, int nEndPos) const
	{
		return NOT_IN_RANGE;
	}

	virtual void UpdateMarkerForDeletedRange (int /*nStartPos*/, int /*nEndPos*/) {}
	virtual void UpdateMarkerForDeletedRangeByOffset (int /*nStartPos*/, int /*nEndPos*/) {}

	virtual bool CompareData (DWORD dwData) const
	{
		return ((DWORD) m_pData) == dwData;
	}

	virtual void CopyData (DWORD dwData) {}
	virtual void DestroyData () {}

	virtual void Serialize (CArchive& ar)
	{
		CObject::Serialize (ar);
		if (ar.IsLoading ())
		{
			ar >> m_nLine;
			ar >> m_dwMarkerType;
			ar >> m_unPriority;
		}
		else
		{
			ar << m_nLine;
			ar << m_dwMarkerType;
			ar << m_unPriority;
		}

		SerializeData (ar);
	}

	virtual void SerializeData (CArchive& ar)
	{
		if (ar.IsLoading ())
		{
			ar << (DWORD) m_pData;
		}
		else
		{
			DWORD dw = 0;
			ar >> dw;
			m_pData = (LPVOID) dw;
		}
	}

public:	
	int			m_nLine;
	DWORD		m_dwMarkerType;
	UINT		m_unPriority;
	LPVOID		m_pData;
};

class BCGCBPRODLLEXPORT CBCGPLineColorMarker : public CBCGPEditMarker
{
	DECLARE_DYNAMIC(CBCGPLineColorMarker)

public:	
	CBCGPLineColorMarker () : m_clrForeground ((COLORREF)-1), 
							  m_clrBackground ((COLORREF)-1),
							  m_nLineCount (0), m_bFullLine (FALSE)
	{
		m_dwMarkerType = g_dwBCGPEdit_LineColorMarker;
	}							  

	CBCGPLineColorMarker (const CBCGPLineColorMarker& srcMarker)
	{
		Copy (srcMarker);
	}

	virtual void Copy (const CBCGPLineColorMarker& srcMarker)
	{
		CBCGPEditMarker::Copy (srcMarker);
		m_clrForeground = srcMarker.m_clrForeground;
		m_clrBackground = srcMarker.m_clrBackground;
		m_nLineCount	= srcMarker.m_nLineCount;
		m_bFullLine		= srcMarker.m_bFullLine;
	}

	virtual CBCGPEditMarkerRange IsInRange (int nStartPos, int nEndPos) const
	{
		int nEndLine = m_nLine + m_nLineCount;
		if (m_nLine > nEndPos || nEndLine < nStartPos)
		{
			return NOT_IN_RANGE;
		}

		if (m_nLine >= nStartPos && m_nLine <= nEndPos &&
			nEndLine <= nEndPos)
		{
			return FULL_IN_RANGE;
		}

		return PARTIAL_IN_RANGE;
	}

	virtual void UpdateMarkerForDeletedRange (int nStartPos, int nEndPos)
	{
		int nEndLine = m_nLine + m_nLineCount;

		if (m_nLine > nEndPos || nEndLine < nStartPos)
		{
			return;
		}

		if (m_nLine >= nStartPos && m_nLine <= nEndPos &&
			nEndLine <= nEndPos)
		{
			// the whole marker in the deleted range - nothing to update
			return;
		}
		
		if (m_nLine < nStartPos && nEndLine <= nEndPos)
		{
			// bottom of marker is deleted
			m_nLineCount -= nEndLine - nStartPos + 1;
		}
		else if (m_nLine >= nStartPos && nEndLine > nEndPos)
		{
			// top of marker is deleted
			m_nLineCount -= nEndPos - m_nLine + 1;
			m_nLine = nStartPos;
		}
		else if (m_nLine < nStartPos && nEndLine > nEndPos)
		{
			// middle of the marker is deleted
			m_nLineCount -= nEndPos - nStartPos + 1;
		}
	}

	virtual void Serialize (CArchive& ar)
	{
		CBCGPEditMarker::Serialize (ar);
		if (ar.IsLoading ())
		{
		}
		else
		{
		}
	}

	COLORREF	m_clrForeground;
	COLORREF	m_clrBackground;
	int			m_nLineCount;

	BOOL		m_bFullLine;
};

class BCGCBPRODLLEXPORT CBCGPHiliteMarker : public CBCGPEditMarker
{
	DECLARE_DYNAMIC(CBCGPHiliteMarker)
public:	
	CBCGPHiliteMarker () : m_nStart (-1),
							m_nEnd (-1),
							m_clrForeground ((COLORREF)-1), 
							m_clrBackground ((COLORREF)-1)
	{
		m_dwMarkerType = g_dwBCGPEdit_HiliteMarker;
	}							  

	CBCGPHiliteMarker (const CBCGPHiliteMarker& srcMarker)
	{
		Copy (srcMarker);
	}

	virtual void Copy (const CBCGPHiliteMarker& srcMarker)
	{
		CBCGPEditMarker::Copy (srcMarker);
		m_nStart		= srcMarker.m_nStart;
		m_nEnd			= srcMarker.m_nEnd;
		m_clrForeground = srcMarker.m_clrForeground;
		m_clrBackground = srcMarker.m_clrBackground;
	}

	virtual CBCGPEditMarkerRange IsInRange (int nStartPos, int nEndPos) const
	{
		return NOT_IN_RANGE;
	}

	virtual CBCGPEditMarkerRange IsInRangeByOffset (int nStartPos, int nEndPos) const
	{
		if (m_nStart > nEndPos || m_nEnd < nStartPos)
		{
			return NOT_IN_RANGE;
		}

		if (m_nStart >= nStartPos && m_nStart <= nEndPos &&
			m_nEnd <= nEndPos)
		{
			return FULL_IN_RANGE;
		}

		return PARTIAL_IN_RANGE;
	}

	virtual void UpdateMarkerForDeletedRange (int /*nStartPos*/, int /*nEndPos*/) {}
	virtual void UpdateMarkerForDeletedRangeByOffset (int nStartPos, int nEndPos)
	{
		if (m_nStart > nEndPos || m_nEnd < nStartPos)
		{
			return;
		}

		if (m_nStart >= nStartPos && m_nStart <= nEndPos &&
			m_nEnd <= nEndPos)
		{
			// the whole marker in the deleted range - nothing to update
			return;
		}
		
		if (m_nStart < nStartPos && m_nEnd <= nEndPos)

⌨️ 快捷键说明

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