📄 demoview1.cpp
字号:
// DemoView1.cpp : implementation file
//
#include "stdafx.h"
#include "scanner.h"
#include "DemoView1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDemoView1
IMPLEMENT_DYNCREATE(CDemoView1, CView)
CDemoView1::CDemoView1()
{
m_showToken = false;
m_pTokenNode = NULL;
}
CDemoView1::~CDemoView1()
{
}
BEGIN_MESSAGE_MAP(CDemoView1, CView)
//{{AFX_MSG_MAP(CDemoView1)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDemoView1 drawing
void CDemoView1::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
//刷新视图类
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(&rect,RGB(255,255,255));
//输出TOKEN字串
int x=0;
int y=0;
pDC->TextOut(x,y,"The Tokens are:");
y+=20;
pDC->TextOut(x,y,"(种别码,符号表的入口结点序号(_代表非标识符))");
y+=20;
CString strNode;
if(m_showToken)
{
if(m_pTokenNode->next == NULL)
{ //为空则提示并返回
pDC->TextOut(x,y,"There is no any legal Tokens !");
return;
}
while(m_pTokenNode->next)
{
strNode.Empty();
m_pTokenNode = m_pTokenNode->next;
if(m_pTokenNode->strId==NULL)
strNode.Format("( %d , _ )",m_pTokenNode->keycode);
else
strNode.Format("( %d , %d )",m_pTokenNode->keycode,m_pTokenNode->strId);
pDC->TextOut(x,y,strNode);
y+=20;
if(y>300)
{
x=x+100;
y=40;
}
}
}
}
void CDemoView1::MyDrawing(PTokenNode pTokenCollection)
{
m_showToken=true;
CDC *pDC=GetDC();
m_pTokenNode = pTokenCollection;
OnDraw(pDC);
m_showToken=false;
}
/////////////////////////////////////////////////////////////////////////////
// CDemoView1 diagnostics
#ifdef _DEBUG
void CDemoView1::AssertValid() const
{
CView::AssertValid();
}
void CDemoView1::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDemoView1 message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -