📄 bcgpeditctrl.h
字号:
{
return m_bEnableOutlineMargin;
}
int GetOutlineMarginWidth () const
{
return m_nOutlineMarginWidth;
}
void SetLineNumbersMargin (BOOL bShow = TRUE, int nMarginWidth = 45)
{
ASSERT (nMarginWidth >= 0);
m_bEnableLineNumbersMargin = bShow;
m_nLineNumbersMarginWidth = nMarginWidth;
RecalcLayout ();
SetCaret (m_nCurrOffset, TRUE, FALSE);
RedrawWindow ();
}
BOOL IsLineNumbersMarginVisible () const
{
return m_bEnableLineNumbersMargin;
}
int GetLineNumbersMarginWidth () const
{
return m_nLineNumbersMarginWidth;
}
void UpdateAutoOutlining (int nStartOffset, int nEndOffset);
void HideSelection ();
void ToggleOutlining ();
void ToggleAllOutlining ();
void StopHidingCurrent ();
void CollapseToDefinitions ();
void StopOutlining ();
BOOL GetHiddenTextFromPoint (CPoint pt, CString& strWord);
BOOL GetHiddenTextFromOffset (int nOffset, CString& strWord);
CString GetVisibleText (int nStartOffset, int nEndOffset) const;
CBCGPOutlineBaseNode* AddOutlining (int nStartOffset, int nEndOffset, int nNameOffset = 0,
BOOL bCollapsed = TRUE, LPCTSTR lpszReplace = NULL);
void RedrawOutlineArea (int nRow = -1);
// Overrides
public:
//---------------------
// IntelliSense Support
//---------------------
virtual BOOL FillIntelliSenseList (CObList& lstIntelliSenseData, LPCTSTR lpszIntelliSense) const { return FALSE; }
virtual BOOL FindText(LPCTSTR lpszFind, BOOL bNext = TRUE, BOOL bCase = TRUE, BOOL bWholeWord = FALSE);
virtual BOOL ReplaceText(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bNext = TRUE,
BOOL bCase = TRUE, BOOL bWholeWord = FALSE);
virtual int ReplaceAll(LPCTSTR lpszFind, LPCTSTR lpszReplace, BOOL bNext = TRUE,
BOOL bCase = TRUE, BOOL bWholeWord = FALSE);
virtual CSize GetCaretSize () const;
virtual BOOL OnSetOvrMode ();
//------------
// Navigation:
//------------
virtual BOOL Left (BOOL bRedrawOnScroll = TRUE);
virtual BOOL Right (BOOL bRedrawOnScroll = TRUE);
virtual BOOL Up (BOOL bSetCaretToMaxColumn = TRUE, BOOL bRedrawOnScroll = TRUE);
virtual BOOL Down (BOOL bSetCaretToMaxColumn = TRUE, BOOL bRedrawOnScroll = TRUE);
virtual BOOL Home (BOOL bRedrawOnScroll = TRUE);
virtual BOOL End (BOOL bRedrawOnScroll = TRUE);
virtual BOOL StartOfText (BOOL bRedraw = TRUE);
virtual BOOL EndOfText (BOOL bRedrawOnScroll = TRUE);
virtual BOOL PageUp (BOOL bRedrawOnScroll = TRUE);
virtual BOOL PageDown (BOOL bRedrawOnScroll = TRUE);
virtual BOOL NextWord (BOOL bRedrawOnScroll = TRUE);
virtual BOOL PrevWord (BOOL bRedrawOnScroll = TRUE);
virtual BOOL PrevIndent ();
virtual void OnSetCaret () {}
virtual BOOL OnScroll (int fnBar, UINT nSBCode, int nPos =-1);
virtual BOOL SetCaretToLastMaxColumn (int nOffset, BOOL bRedrawOnScroll = TRUE);
//---------------
// Insert/delete:
//---------------
virtual BOOL InsertChar (TCHAR nChar, BOOL bRedraw = FALSE);
virtual BOOL InsertText (LPCTSTR lpszText, int nInsertFrom = -1, BOOL bRedraw = FALSE,
BOOL bSuppressUndo = FALSE, BOOL bUpdateLineData = TRUE,
BOOL bForceNextUndo = FALSE, BOOL bAlwaysAtEnd = TRUE);
virtual BOOL InsertTextAsBlock (LPCTSTR lpszText, int nInsertFrom = -1, BOOL bRedraw = FALSE,
BOOL bSuppressUndo = FALSE, BOOL bUpdateLineData = TRUE,
BOOL bForceNextUndo = FALSE);
virtual BOOL InsertNewLine (BOOL bRedraw = FALSE, BOOL bForceNextUndo = FALSE,
int nOffset = -1, BOOL bSetCaret = TRUE);
virtual BOOL InsertTab (BOOL bRedraw = FALSE);
virtual BOOL OnDelete (BOOL bRedraw = FALSE, BOOL bForceNextUndo = FALSE);
virtual BOOL ProcessTextBeforeInsert (CString& strText);
virtual BOOL OnInsertNewLine (BOOL bForceNextUndo = FALSE, int nOffset = -1,
BOOL bSetCaret = FALSE);
virtual void OnDeleteTextFromBuffer (int nStartOffset, int nEndOffset,
LPCTSTR lpcszDeletedText);
virtual void OnInsertTextToBuffer (int nStartOffset, const CString& strInsertedText,
BOOL bUpdateLineData = TRUE);
//---------------
// Text changing notifications:
//---------------
virtual BOOL OnBeforeTextInserted (CString& strInsertedText, int nOffset) {return TRUE;}
virtual BOOL OnBeforeTextDeleted (int nOffset, const CString& strDeletedText) {return TRUE;}
virtual void OnAfterTextChanged (int nOffsetFrom, const CString& strText, BOOL bInserted);
//----------
// Undo/Redo
//----------
virtual void SetOverrideMode (BOOL bSet = FALSE) {m_bOvrMode = bSet;}
virtual BOOL GetOverrideMode () const {return m_bOvrMode;}
//----------
// Undo/Redo
//----------
virtual BOOL CanUndo () const;
virtual BOOL CanRedo () const;
virtual BOOL OnUndo (BOOL bSetCaret = TRUE, BOOL bRedraw = TRUE);
virtual BOOL OnRedo (BOOL bSetCaret = TRUE, BOOL bRedraw = TRUE);
virtual void AddUndoAction (CString& strText, DWORD dwAction, int nCurrOffset, BOOL bForceInsertMode,
BOOL bForceNextUndo = FALSE);
virtual void AddUndoAction (TCHAR ch, DWORD dwAction, int nCurrOffset, BOOL bForceInsertMode);
virtual void AddUndoAction (BCGP_BASE_UNDO_DATA* lpActionData, DWORD dwAction, BOOL bDestroyData = TRUE);
virtual void AddUndoAction (BCGP_EDIT_UNDO_ACTION* pUndoAction);
virtual BOOL OnBeforeUndoRedo (BCGP_EDIT_UNDO_ACTION* /*pUndoAction*/) {return TRUE;}
virtual void OnAfterUndoRedo (BCGP_EDIT_UNDO_ACTION* /*pUndoAction*/) {}
virtual BOOL OnBeforeAddUndoAction (BCGP_EDIT_UNDO_ACTION* pUndoAction) {return TRUE;}
virtual void OnRemoveUndoAction (BCGP_EDIT_UNDO_ACTION* pUndoAction) {};
virtual BOOL ProcessUndoRedoAction (BCGP_EDIT_UNDO_ACTION* pUndoAction, BOOL bUndo, BOOL bSetCaret);
virtual void EmptyUndoList ();
virtual void SetLastUndoReason (DWORD dwUndoReason) {m_dwLastUndoReason = dwUndoReason;}
virtual DWORD GetLastUndoReason () const {return m_dwLastUndoReason;}
//----------
// Selection
//----------
enum BCGP_EDIT_SEL_TYPE
{
ST_PREV_WORD,
ST_NEXT_WORD,
ST_PREV_SYMBOL,
ST_NEXT_SYMBOL,
ST_PREV_LINE,
ST_NEXT_LINE,
ST_PREV_PAGE,
ST_NEXT_PAGE,
ST_HOME,
ST_END,
ST_START_OF_TEXT,
ST_END_OF_TEXT,
ST_ALL_TEXT
};
virtual BOOL MakeSelection (BCGP_EDIT_SEL_TYPE selType);
virtual BOOL RemoveSelection (BOOL bSetCaretToSelStart = TRUE,
BOOL bKeepCurrPos = FALSE, BOOL bRedraw = TRUE);
virtual BOOL IndentSelection (BOOL bForward);
virtual void SetSel (int nStartSel, int nEndSel, BOOL bNoScroll = FALSE)
{
SetSel2 (nStartSel, nEndSel, bNoScroll);
}
virtual void SetSel2 (int nStartSel, int nEndSel, BOOL bNoScroll = FALSE, BOOL bRedraw = TRUE);
//----------------
// Copy/Cut/Paste:
//----------------
virtual BOOL Copy ();
virtual BOOL Cut ();
virtual BOOL Paste (int iPos = -1);
virtual BOOL Clear ();
virtual BOOL IsPasteEnabled () const;
virtual BOOL IsCopyEnabled () const
{
return m_bEnableWholeTextCopy || (m_iStartSel >= 0 && m_iEndSel >= 0 &&
(m_iStartSel != m_iEndSel));
}
virtual BOOL IsCutEnabled () const
{
return m_iStartSel >= 0 && m_iEndSel >= 0 && (m_iStartSel != m_iEndSel);
}
virtual BOOL IsIndentEnabled (BOOL bForward);
//--------
// Drawing
//--------
virtual void RedrawText (int nStartRow, int nEndRow = 0);
virtual void RedrawTextOffsets (int nStartOffset, int nEndOffset);
virtual void OnFillBackground (CDC* pDC);
virtual void OnDrawText (CDC* pDC);
virtual void OnDrawSideBar (CDC* pDC, CRect rect);
virtual void OnDrawLineNumbersBar (CDC* pDC, CRect rect);
virtual void OnDrawOutlineBar (CDC* pDC, CRect rectLeft);
virtual void OnDrawMarker (CDC* pDC, CRect rectMarker, const CBCGPEditMarker* pMarker);
virtual void OnDrawLineNumber (CDC* pDC, CRect rect, const int nLineNumber);
virtual void OnDrawOutlineButton (CDC* pDC, CRect rectButton, CBCGPOutlineBaseNode* pRowOutlineBlock,
BOOL bInsideOpenBlockAtStart, BOOL bInsideOpenBlockAtEnd, BOOL bEndOfBlock);
// -----
// Print
// -----
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
//--------------------
// Drag & Drop support
//--------------------
virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
virtual void OnDragLeave();
virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
//----------------
// Syntax coloring
//----------------
virtual BOOL OnGetWordColor (const CString& strWord, COLORREF& clrText, COLORREF& clrBk, int nPos);
virtual void OnGetCharColor (TCHAR ch, int nOffset, COLORREF& clrText, COLORREF& clrBk) {}
virtual BOOL OnGetTextColor (int nStart, int nEnd,
COLORREF& clrText, COLORREF& clrBk, BOOL bColorFound) const
{
return FALSE;
}
//-------------
// XML settings
//-------------
virtual BOOL LoadXMLSettings (const CString& strFileName);
virtual BOOL LoadXMLSettingsFromBuffer (const CString& strBuffer);
virtual void RemoveXMLSettings ();
//---------------------
// IntelliSense Support
//---------------------
virtual BOOL OnFillIntelliSenseList (int& nCurrOffset, CObList& lstIntelliSenseData) const;
virtual BOOL OnBeforeInvokeIntelliSense (const CString& strBuffer, int& nCurrOffset, CString& strIntelliSense) const {return TRUE;}
virtual BOOL InvokeIntelliSense (CObList& lstIntelliSenseData, CPoint ptTopLeft);
virtual BOOL IntelliSenseCharUpdate(const CString& strBuffer, int nCurrOffset, TCHAR nChar, CString& strIntelliSense) { return FALSE; }
virtual BOOL InvokeIntelliSense ();
//---------------------
// Graphical symbols support
//---------------------
virtual BOOL OnDrawSymbol (CDC* pDC, CRect rectRow, BCGP_EDIT_SYM_DEF& symDef)
{
return FALSE;
}
virtual BOOL LookUpSymbol (LPCTSTR lpcszBuffer, int nOffset, int nCount, TCHAR chSymbol,
BCGP_EDIT_SYM_DEF& symDef, int& nSymExtraLen, BOOL bForward = TRUE);
virtual BOOL OnFillSymListData (int& nCurrOffset, CObList& lstIntelliSenseData) const;
virtual BOOL InvokeSymList (CObList& lstIntelliSenseData, CPoint ptTopLeft);
virtual BOOL InvokeSymList ();
virtual int GetSymbolExtraLen (CString& strBuffer, int nOffset, BOOL bForward = TRUE);
//---------------
// Marker Support
//---------------
virtual CBCGPEditMarker* FindMarkerByData (DWORD dwData) const;
virtual void GetMarkerListByData (CObList& lstMarkers, DWORD dwData) const;
virtual BOOL GoToMarker (const CBCGPEditMarker* pMarker);
virtual BOOL HasMarkers (DWORD dwMarkerType = (DWORD) -1);
virtual BOOL CanUpdateMarker (CBCGPEditMarker* pMarker) const {return TRUE;}
virtual BOOL CanRemoveMarker (CBCGPEditMarker* pMarker) const {return TRUE;}
virtual BOOL OnUpdateMarkerLine (int nNewLine) {return TRUE;}
virtual BOOL OnRemoveMarker (CBCGPEditMarker* pMarker, POSITION posMarker) {return TRUE;}
//------------------
// Outlining Support
//------------------
virtual void OnCalcOutlineSymbol (CDC* pDC, CPoint ptCharOffset, CBCGPOutlineBaseNode* pHiddenText);
virtual void OnDrawOutlineSymbol (CDC* pDC, CBCGPOutlineBaseNode* pHiddenText,
COLORREF clrFore, COLORREF clrBack);
virtual BOOL OnOutlineButtonClick (int nOffset);
virtual BOOL OnOutlineButtonClick (CBCGPOutlineNode *pOutlineNode);
virtual CBCGPOutlineParser* CreateOutlineParser () const
{
return new CBCGPOutlineParser;
}
virtual BOOL LoadOutlineParserXMLSettings (CString& strInBuffer);
virtual void OnOutlineChanges (BCGP_EDIT_OUTLINE_CHANGES& changes, BOOL bRedraw = TRUE);
virtual void OnInsertOutlineBlock (CBCGPOutlineBaseNode* pBlock) {}
virtual void OnRemoveOutlineBlock (CBCGPOutlineBaseNode* pBlock) {}
virtual void OnUpdateAutoOutlining (int nOffsetFrom, int nCharsCount, BOOL bRedraw = TRUE);
//----------------
// Tooltip Support
//----------------
virtual BOOL OnGetTipText (CString& strTipString) {return TRUE;}
//--------
// Notifications
//--------
virtual void OnFailedOperation (DWORD dwOpType) {}
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBCGPEditCtrl)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual void Serialize(CArchive& ar);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CBCGPEditCtrl();
protected:
void Initialize ();
void OnChangeFont (CDC* pDC = NULL);
void InitColors ();
COLORREF GetDefaultTextColor () const;
COLORREF GetDefaultBackColor () const;
int GetCurrRowStart (BOOL bSkipHidden = FALSE) const;
int GetCurrRowEnd (BOOL bSkipHidden = FALSE) const;
int GetCurrRowTextStart (BOOL bSkipHidden = FALSE) const;
int GetRowTextStart (int nRowOffset, BOOL bSkipHidden = FALSE) const;
int GetRowStart (int nRow, BOOL bSkipHidden = FALSE) const;
int RowFromOffset (int nOffset, BOOL bCalcAll = FALSE, BOOL bSkipHidden = FALSE) const;
int GetNumOfColumnsInRowByOffset (int nOffset, int& nRowEndOffset, BOOL bSkipHidden = FALSE) const;
int GetOffsetOfColumnInRow (int nColumn, int nRowEndOffset, BOOL bEndOffsetSpecified = TRUE, BOOL bSkipHidden = FALSE);
int GetColumnFromOffset (int nOffset, BOOL bSkipHidden = FALSE) const;
int GetRowStartByOffset (int nOffset, BOOL bSkipHidden = FALSE) const;
int GetRowEndByOffset (int nOffset, BOOL bSkipHidden = FALSE) const;
int GetHorzRowExtent (CDC* pDC, int nOffset);
int GetVirtualRow (int nRow, BOOL bCalcAll = FALSE) const;
int GetRowFromVirtual (int nRowVirt, BOOL bCalcAll = FALSE) const;
CFont* SelectFont (CDC* pDC);
void RedrawRestOfLine (int nOffset);
void RedrawRestOfText (int nOffset);
void DrawColorLine (CDC* pDC, int nRow, CRect rectRow);
BOOL CopyTextToClipboard (LPCTSTR lpszText, int nLen = -1);
HGLOBAL CopyTextToClipboardInternal (LPCTSTR lpszText, CLIPFORMAT cFormat, int nLen);
BOOL GetSelectionRect (CRect& rect1, CRect& rect2, CRect& rect3);
void BuildColorAreas (CList <BCGP_EDIT_COLOR_AREA, BCGP_EDIT_COLOR_AREA&>& colorAreas,
int nStartOffset, int nEndOffset,
BCGP_EDIT_COLOR_BLOCK* pColorBlockToExclude,
BOOL bRedraw = TRUE);
BOOL IsOffsetAtColorBlock (int nOffset);
inline int ReverseFindOneOf (const CString& strBuffer, int nPos, const CString& strChars) const;
void ReverseFindOneOf(const CString& strCharSet, const ciStartPos, int& nCurrOffset) const;
int FindOneOf (const CString& strBuffer, int nPos, const CString& strChars) const;
int WhileOneOf (const CString& strBuffer, int nOffset, bool bForward,
const CString& strChars);
BOOL DoFindText(int& nPos, int& nFindLength,
LPCTSTR lpszFind, BOOL bNext = TRUE, BOOL bCase = TRUE,
BOOL bWholeWord = FALSE);
virtual int DrawString (CDC* pDC, LPCTSTR str, CRect rect, int nOrigin,
COLORREF clrBack);
virtual CSize GetStringExtent (CDC* pDC, LPCTSTR lpszString, int nCount);
BOOL IsInsideSelection (int nOffset, CPoint& ptCharOffset, CRect rectSel, int nCharWidth);
BOOL IsColoredLine (int nRow, COLORREF& clrFore, COLORREF& clrBack);
BOOL IsHilitedText (int nOffset, COLORREF& clrFore, COLORREF& clrBack);
CBCGPOutlineNode* FindCollapsedBlock (int nOffset) const;
CBCGPOutlineNode* FindCollapsedBlockInRange (int nStart, int nEnd, BOOL bForward = TRUE) const;
CBCGPOutlineNode* FindCollapsedBlockByPoint(CPoint point, int nOffset) const;
void NextRow (int& nRow, int& nRowVirtual, int& nRowStartOffset) const;
void PrepareBlock (CString& strOut);
void RetrieveSelectedBlock (CStringArray& arStrings);
void BuildTabString (CString& str);
void UpdateLineRelatedData (int nStartLine, int nNumLines);
void RemoveLineDataInRange (int nStartRow, int nEndRow);
void UpdateOffsetRelatedData (int nStartOffset, int nEndOffset);
void RemoveOffsetDataInRange (int nStartOffset, int nEndOffset);
BOOL FindOpenBlock (int nStartOffset, BCGP_EDIT_COLOR_BLOCK* pFoundBlock);
int FindCloseBlock (int nStartOffset, BCGP_EDIT_COLOR_BLOCK* pFoundBlock);
BOOL IsCharBlockSymbol (TCHAR ch);
BOOL IsStringHasBlockSymbols (const CString& str);
BOOL PasteFromDataObject (COleDataObject* pDataObject,
int nInsertFrom = -1, BOOL bRedraw = FALSE,
BOOL bSuppressUndo = FALSE,
BOOL bUpdateLineData = TRUE,
BOOL bForceNextUndo = FALSE);
void RecalcLayout ();
void UpdateHiddenLines (BCGP_EDIT_OUTLINE_CHANGES& changes);
// Generated message map functions
protected:
BOOL m_bIntelliSenseUpdate;
//{{AFX_MSG(CBCGPEditCtrl)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnPaint();
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnSysColorChange();
afx_msg UINT OnGetDlgCode();
//}}AFX_MSG
afx_msg LRESULT OnSetFont (WPARAM, LPARAM);
afx_msg LRESULT OnGetFont (WPARAM, LPARAM);
afx_msg BOOL OnTTNeedTipText(UINT /*id*/, NMHDR* pNMH, LRESULT* /*pResult*/);
afx_msg LRESULT OnSetText (WPARAM, LPARAM);
afx_msg LRESULT OnGetText (WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
};
//////////////////////////////////////////////////////////////////////////////
// CBCGPEditCtrl notification messages:
extern BCGCBPRODLLEXPORT UINT BCGM_ON_EDITCHANGE;
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BCGPEDITCTRL_H__078F8590_E8CE_4F07_A08A_C41CEBE48D77__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -