📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "AutoMake.h"
#include "MainFrm.h"
#include "AutoMakeView.h"
#include "AutoMakeView0.h"
#include "AutoMakeView1.h"
#include "AutoMakeView2.h"
#include "AutoMakeView3.h"
#include "Globals.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_SIZE()
ON_COMMAND(ID_NFA, OnNfa)
ON_COMMAND(ID_DFA, OnDfa)
ON_COMMAND(ID_MINDFA, OnMindfa)
ON_COMMAND(ID_BUILDALLS, OnBuildalls)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
Is_show=FALSE;
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
CRect cr;
BOOL bIsCreate;
/*创建分割视图*/
if (!m_wndSplitterH.CreateStatic(this,2,1))
{
TRACE0("Failed to create split bar ");
return FALSE; // failed to create
}
if (!m_wndSplitterV.CreateStatic(&m_wndSplitterH,1,2,
WS_CHILD | WS_VISIBLE,m_wndSplitterH.IdFromRowCol(1,0)))
{
TRACE0("Failed to create split bar ");
return FALSE; // failed to create
}
if (!m_wndSplitterh.CreateStatic(&m_wndSplitterV,3,1,
WS_CHILD | WS_VISIBLE,m_wndSplitterV.IdFromRowCol(0,1)))
{
TRACE0("Failed to create split bar ");
return FALSE; // failed to create
}
GetClientRect(&cr);
CSize paneSize(cr.Width(), cr.Height()/10);
CSize paneSize0(cr.Width()/5, 9*cr.Height()/10);
CSize paneSize1(4*cr.Width()/5, 5*cr.Height()/10);
CSize paneSize2(4*cr.Width()/5, 4*cr.Height()/10);
CSize paneSize3(4*cr.Width()/5, 0);
((CAutoMakeApp*)AfxGetApp())->m_pDoc=(CAutoMakeDoc*)
(pContext->m_pCurrentDoc);
m_wndSplitterH.CreateView(0,0,RUNTIME_CLASS(CAutoMakeView),
paneSize,pContext);
m_wndSplitterV.CreateView(0,0,RUNTIME_CLASS(CAutoMakeView0),
paneSize0,pContext);
pContext->m_pNewViewClass=RUNTIME_CLASS(CAutoMakeView1);
pContext->m_pCurrentDoc=((CAutoMakeApp*)AfxGetApp())->m_pDoc;
pContext->m_pCurrentFrame=this;
bIsCreate=m_wndSplitterh.CreateView(0,0,pContext->m_pNewViewClass,paneSize1, pContext);
if(!bIsCreate)return FALSE;
pContext->m_pNewViewClass=RUNTIME_CLASS(CAutoMakeView2);
pContext->m_pCurrentDoc=((CAutoMakeApp*)AfxGetApp())->m_pDoc;
pContext->m_pCurrentFrame=this;
bIsCreate=m_wndSplitterh.CreateView(1,0,pContext->m_pNewViewClass,paneSize2,pContext);
pContext->m_pNewViewClass=RUNTIME_CLASS(CAutoMakeView3);
pContext->m_pCurrentDoc=((CAutoMakeApp*)AfxGetApp())->m_pDoc;
pContext->m_pCurrentFrame=this;
bIsCreate=m_wndSplitterh.CreateView(2,0,pContext->m_pNewViewClass,paneSize3,pContext);
m_wndSplitterH.RecalcLayout();
m_wndSplitterV.RecalcLayout();
m_wndSplitterh.RecalcLayout();
return bIsCreate;
// return CFrameWnd::OnCreateClient(lpcs, pContext);
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
/*设置分割视图的大小*/
if(Is_show)
{
CRect cr;
GetClientRect(&cr);
m_wndSplitterH.SetRowInfo(0,cr.Height()/10,0);
m_wndSplitterV.SetColumnInfo(0,cr.Width()/5,0);
m_wndSplitterh.SetRowInfo(0,cr.Height(),0);
m_wndSplitterh.SetRowInfo(1,0,0);
m_wndSplitterh.SetRowInfo(2,0,0);
m_wndSplitterH.RecalcLayout();
m_wndSplitterV.RecalcLayout();
m_wndSplitterh.RecalcLayout();
}
}
void CMainFrame::ActivateFrame(int nCmdShow)
{
// TODO: Add your specialized code here and/or call the base class
/*最大化显示主窗口*/
Is_show=TRUE;
nCmdShow=SW_SHOWMAXIMIZED;
CFrameWnd::ActivateFrame(nCmdShow);
}
void CMainFrame::OnNfa()
{
// TODO: Add your command handler code here
CRect cr;
GetClientRect(&cr);
m_wndSplitterh.SetRowInfo(0,cr.Height(),0);
m_wndSplitterh.SetRowInfo(1,0,0);
m_wndSplitterh.SetRowInfo(2,0,0);
m_wndSplitterh.RecalcLayout();
CurrentIter=NULL;
((CAutoMakeView1*)m_wndSplitterh.GetPane(0,0))->drawNFA();
}
void CMainFrame::OnDfa()
{
// TODO: Add your command handler code here
CRect cr;
GetClientRect(&cr);
m_wndSplitterh.SetRowInfo(0,0,0);
m_wndSplitterh.SetRowInfo(1,cr.Height(),0);
m_wndSplitterh.SetRowInfo(2,0,0);
m_wndSplitterh.RecalcLayout();
CurrentIter=NULL;
((CAutoMakeView2*)m_wndSplitterh.GetPane(1,0))->drawDFA();
}
void CMainFrame::OnMindfa()
{
// TODO: Add your command handler code here
CRect cr;
GetClientRect(&cr);
m_wndSplitterh.SetRowInfo(0,0,0);
m_wndSplitterh.SetRowInfo(1,0,0);
m_wndSplitterh.SetRowInfo(2,cr.Height(),0);
m_wndSplitterh.RecalcLayout();
((CAutoMakeView3*)m_wndSplitterh.GetPane(2,0))->drawMinDFA();
}
void CMainFrame::OnBuildalls()
{
// TODO: Add your command handler code here
ClearNFA();
ClearDFA();
ClearMinDFA();
((CAutoMakeView0*)m_wndSplitterV.GetPane(0,0))->m_Edit.GetWindowText(rExp);
if(BuildNFA(rExp))
{
BuildDFA();
MinDFA();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -