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

📄 cffview.cpp

📁 与vc++界面十分类似的词法分析器
💻 CPP
字号:
// CFFView.cpp : implementation of the CCFFView class
//

#include "stdafx.h"
#include "CFF.h"

#include "CFFDoc.h"
#include "CFFView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCFFView

IMPLEMENT_DYNCREATE(CCFFView, CEditView)

BEGIN_MESSAGE_MAP(CCFFView, CEditView)
	//{{AFX_MSG_MAP(CCFFView)
	ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
	ON_WM_PAINT()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCFFView construction/destruction

CCFFView::CCFFView()
{
	// TODO: add construction code here
m_text.Empty();
::SetTimer(this->m_hWnd,0,100,NULL);
}

CCFFView::~CCFFView()
{
//	KillTimer(0);
}

BOOL CCFFView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
	//cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL|ES_AUTOVSCROLL|WS_VSCROLL);	// Enable word-wrapping

	return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CCFFView drawing


/////////////////////////////////////////////////////////////////////////////
// CCFFView printing

BOOL CCFFView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default CEditView preparation
	return CEditView::OnPreparePrinting(pInfo);
}

void CCFFView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView begin printing.
	CEditView::OnBeginPrinting(pDC, pInfo);
}

void CCFFView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView end printing
	CEditView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CCFFView diagnostics

#ifdef _DEBUG
void CCFFView::AssertValid() const
{
	CEditView::AssertValid();
}

void CCFFView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}

CCFFDoc* CCFFView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCFFDoc)));
	return (CCFFDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CCFFView message handlers

void CCFFView::DrawText(CString &text)
{
	CDC *pDC=GetDC();
    if(!text.IsEmpty())
	pDC->TextOut(0,0,text);
}

void CCFFView::OnInitialUpdate() 
{	
	// TODO: Add your specialized code here and/or call the base class
SIZE size;
GetTextExtentPoint(GetDC()->GetSafeHdc (),"A",1,&size);
m_LineHeight = size.cy;		//得到行的高度

CEdit& theEdit = GetEditCtrl ();
theEdit.SetMargins (m_LineHeight+5,0);	//设置编辑框的左边界
CEditView::OnInitialUpdate();
}

void CCFFView::PaintLeft()
{
	CBrush brushb(RGB(222,222,222));
	CDC* hdc;
	hdc = GetWindowDC();
	CRect rect;
	GetClientRect(&rect);
	hdc->FillRect (CRect(rect.left+2 ,rect.top+2 ,rect.left + m_LineHeight + 7,rect.Height ()+2),&brushb);//画底色
	brushb.DeleteObject ();

}

void CCFFView::OnChange() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CEditView::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	PaintLeft();
}

void CCFFView::OnPaint() 
{
//	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	// Do not call CEditView::OnPaint() for painting messages
	CEditView::OnPaint();
	PaintLeft();
}


void CCFFView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	SendMessage(WM_PAINT);
	CEditView::OnTimer(nIDEvent);
}

void CCFFView::OnDraw(CDC* pDC) 
{
	CCFFDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	if(!m_text.IsEmpty())
	pDC->TextOut(0,0,m_text);
}

⌨️ 快捷键说明

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