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

📄 skillbookview.h

📁 vc++的技巧查找方式源代码。
💻 H
字号:
// SkillBookView.h : interface of the CSkillBookView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_SKILLBOOKVIEW_H__C5B41BA4_F89E_4A0B_A09D_ED6E96414BCC__INCLUDED_)
#define AFX_SKILLBOOKVIEW_H__C5B41BA4_F89E_4A0B_A09D_ED6E96414BCC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "MainFrm.h"
#include "LeftTreeView.h"

//颜色索引
enum
{
	COLORINDEX_COMMENT,
	COLORINDEX_SYNTAX,
	COLORINDEX_NORMAL,
	COLORINDEX_NUMBER,
	COLORINDEX_STRING,
	COLORINDEX_CHAR,
	COLORINDEX_BK,
};

//语言
enum
{
	_CPP,
	_BASIC,
 	NONE,
};

struct COLORINFO
{
	int Pos;
	int Color;
};

struct SYMBOLCOLOR
{
	COLORREF clrColor;
	BOOL bBold;
};

class CSkillBookDoc;

class CSkillBookView : public CRichEditView
{
private:
	void SetSynEditViewTabSize(int nSize);
	void SetSynEditViewFont(LOGFONT lf);
	void SetSynCtrlFont();
	void SetCharacterColor(COLORREF clr, BOOL bBold);
	void SetStringColor(COLORREF clr, BOOL bBold);
	void SetNumberColor(COLORREF clr, BOOL bBold);
	void SetCommentColor(COLORREF clr, BOOL bBold);
	void SetConstantColor(COLORREF clr, BOOL bBold);
	void SetKeywordColor(COLORREF clr, BOOL bBold);
	void AddConstants(LPCTSTR lpszConst);
	void AddKeywords(LPCTSTR lpszKwd);
	void SetSLComment(TCHAR chComment, TCHAR chComment2);
	void SetSLComment(LPCTSTR lpszComment);
	void SetStringQuotes(LPCTSTR lpszStrQ);
	void SetFormatRange(int nStart, int nEnd, BOOL bBold, COLORREF clr);
	int IsConstant(LPCTSTR lpszSymbol);
	BOOL IsKeyword(LPCTSTR lpszSymbol);
	BOOL IsStringQuote(TCHAR ch);
	void FormatTextRange(int nStart, int nEnd, BOOL &bComment);
	void FormatTextLines(int nLineStart, int nLineEnd);
public:
	void FormatAll();
private:
	CString GetLineText(const int nIndex);
	int GetLineLength(int nIndex);
	void FormatOneTextLine(const int nLineIndex, BOOL &bComment);
	int m_nCharTabWidth;		//Tab宽度,以Point表示
	int m_nCharSpaceWidth;		//空格宽度,以Point表示

	CFont m_font;				//RichEditCtrl字体
	LOGFONT m_lf;				//语法编辑视字体

	int m_nCharNumberWidth;		//数字宽度

	enum ChangeType {ctUndo, ctUnknown, ctReplSel, ctDelete, ctBack, ctCut, ctPaste, ctMove};

	TCHAR m_chComment;
	TCHAR m_chComment2;
	CString m_strComment;
	CString m_strStringQuotes;
	CString m_strKeywords;
	CString m_strKeywordsLower;
	CString m_strConstants;
	CString m_strConstantsLower;

	SYMBOLCOLOR m_icComment;
	SYMBOLCOLOR m_icNumber;
	SYMBOLCOLOR m_icString;
	SYMBOLCOLOR m_icKeyword;
	SYMBOLCOLOR m_icConstant;
	SYMBOLCOLOR m_icCharacter;

	BOOL m_bComment;
	BOOL m_bInForcedChange;
	ChangeType m_changeType;
	CHARRANGE m_crOldSel;
protected: // create from serialization only
	CSkillBookView();
	DECLARE_DYNCREATE(CSkillBookView)

// Attributes
public:
	CSkillBookDoc* GetDocument();

// Operations
public:
	//接口,其它如语法解析相关、字体、颜色属性等接口请自行设定

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSkillBookView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void OnInitialUpdate();
	protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CSkillBookView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CSkillBookView)
	afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
	afx_msg void OnChange();
	afx_msg void OnMenuSavearticle();
	afx_msg void OnMenuUndo();
	afx_msg void OnMenuCut();
	afx_msg void OnMenuSelectall();
	afx_msg void OnMenuCopy();
	afx_msg void OnMenuPaste();
	afx_msg void OnUpdateMenuCut(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuCopy(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuPaste(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMenuUndo(CCmdUI* pCmdUI);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnCopy() {GetRichEditCtrl().Copy(); }
	afx_msg void OnCut() {GetRichEditCtrl().Cut(); }
	afx_msg void OnPaste() {GetRichEditCtrl().Paste(); }
	afx_msg void OnSelectall() {GetRichEditCtrl().SetSel(0, -1); }
	afx_msg void OnUndo() {GetRichEditCtrl().Undo(); }
	afx_msg void OnClear() {GetRichEditCtrl().Clear(); }
	afx_msg void OnSelectfont();
	afx_msg void OnFilePrintPreview();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in SkillBookView.cpp
inline CSkillBookDoc* CSkillBookView::GetDocument()
   { return (CSkillBookDoc*)m_pDocument; }
#endif

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

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

#endif // !defined(AFX_SKILLBOOKVIEW_H__C5B41BA4_F89E_4A0B_A09D_ED6E96414BCC__INCLUDED_)

⌨️ 快捷键说明

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