📄 bottomview.cpp
字号:
// BottomView.cpp : implementation file
//
#include "stdafx.h"
#include "cmmg.h"
#include "BottomView.h"
#include "MainFrm.h"
#include "util.h"
#include "AnalyseTree.h"
// CBottomView
IMPLEMENT_DYNCREATE(CBottomView, CView)
CBottomView::CBottomView()
{
}
CBottomView::~CBottomView()
{
}
BEGIN_MESSAGE_MAP(CBottomView, CView)
ON_COMMAND(ID_PRO_SCAN,scan)
ON_COMMAND(ID_PRO_PARSE,parse)
ON_COMMAND(ID_PRO_EXEC,exec)
ON_NOTIFY(TCN_SELCHANGE,4001,OnSelChange)
ON_WM_SIZE()
END_MESSAGE_MAP()
// CBottomView drawing
void CBottomView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
// CBottomView diagnostics
#ifdef _DEBUG
void CBottomView::AssertValid() const
{
CView::AssertValid();
}
#ifndef _WIN32_WCE
void CBottomView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif
#endif //_DEBUG
void CBottomView::OnInitialUpdate(){
GetDocument()->out = ((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.GetPane(1,0);
CRect rect;
::GetClientRect(GetDocument()->out->m_hWnd,rect);
GetDocument()->outTab.Create(WS_CHILD|WS_VISIBLE|TCS_FIXEDWIDTH|TCS_TABS ,rect,GetDocument()->out,4001);
TCITEM tc;
tc.mask=TCIF_TEXT;
tc.pszText=TEXT("输出");
GetDocument()->outTab.InsertItem(0,&tc);
//tc.pszText=TEXT("控制台");
//GetDocument()->outTab.InsertItem(1,&tc);
tc.pszText=TEXT("错误列表");
GetDocument()->outTab.InsertItem(1,&tc);
GetDocument()->outTab.GetClientRect(&rect);
output.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_READONLY,rect,&GetDocument()->outTab,4104);
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
err.Create(WS_CHILD|WS_VISIBLE,rect,&GetDocument()->outTab,4105);
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
}
// CBottomView message handlers
void CBottomView::scan(){
err.DestroyWindow();
output.DestroyWindow();
RECT rect;
GetDocument()->outTab.GetClientRect(&rect);
output.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_READONLY,rect,&GetDocument()->outTab,4104);
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
GetDocument()->outTab.GetClientRect(&rect);
err.Create(WS_CHILD|WS_VISIBLE,rect,&GetDocument()->outTab,4105);
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
int k = GetDocument()->hedits.size() - GetDocument()->editTab.GetCurSel()-1;
save(GetDocument()->paths.at(k),GetDocument()->hedits.at(k));
scanFile(GetDocument()->paths.at(k),output.m_hWnd);
int cy = 0;
int cymin;
CMainFrame* cmf = (CMainFrame*)GetParentFrame();
cmf->m_wndSplitter.GetRowInfo(1,cy,cymin);
if (cy==0)
{
int cy1 = 0;
int cymin1;
cmf->m_wndSplitter.GetRowInfo(0,cy1,cymin1);
cmf->m_wndSplitter.SetRowInfo(0,cy1-200,cymin1);
}
GetDocument()->outTab.SetCurSel(0);
OnSelChange(NULL,NULL);
}
void CBottomView::parse(){
err.DestroyWindow();
output.DestroyWindow();
RECT rect;
GetDocument()->outTab.GetClientRect(&rect);
output.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_READONLY,rect,&GetDocument()->outTab,4104);
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
GetDocument()->outTab.GetClientRect(&rect);
err.Create(WS_CHILD|WS_VISIBLE,rect,&GetDocument()->outTab,4105);
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
bool flag;
int k = GetDocument()->hedits.size() - GetDocument()->editTab.GetCurSel()-1;
save(GetDocument()->paths.at(k),GetDocument()->hedits.at(k));
string s = parseFile(GetDocument()->paths.at(k),flag);
if (flag)
{
analyse_tree = new AnalyseTree(s);
analyse_tree->Create(IDD_ANALYSETREE,this);
analyse_tree->ShowWindow(SW_SHOW);
}
else{
int begin = s.find_first_of('\n');
int end = s.find_first_of('\n',begin+1);
while (end!=string::npos)
{
string temp = s.substr(begin+1,end-begin-1);
begin = end;
end = s.find_first_of('\n',begin+1);
CString cs(temp.c_str());
this->err.AddString(cs);
}
string temp = s.substr(begin+1,s.length()-begin);
CString cs(temp.c_str());
this->err.AddString(cs);
}
GetDocument()->outTab.SetCurSel(1);
OnSelChange(NULL,NULL);
}
void CBottomView::exec(){
err.DestroyWindow();
output.DestroyWindow();
RECT rect;
GetDocument()->outTab.GetClientRect(&rect);
output.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|ES_MULTILINE|ES_READONLY,rect,&GetDocument()->outTab,4104);
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
GetDocument()->outTab.GetClientRect(&rect);
err.Create(WS_CHILD|WS_VISIBLE,rect,&GetDocument()->outTab,4105);
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
int k = GetDocument()->hedits.size() - GetDocument()->editTab.GetCurSel()-1;
save(GetDocument()->paths.at(k),GetDocument()->hedits.at(k));
bool success;
execFile(GetDocument()->paths.at(k),success);
if(!success){
parse();
}
}
VOID CBottomView::OnSelChange(NMHDR * pNotifyStruct, LRESULT * result){
int k = GetDocument()->outTab.GetCurSel();
RECT rect;
GetDocument()->outTab.GetClientRect(&rect);
if (k==0)
{
err.ShowWindow(SW_HIDE);
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
}
else if(k=1){
output.ShowWindow(SW_HIDE);
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
}
}
void CBottomView::OnSize(UINT nType, int cx, int cy){
CView::OnSize(nType,cx,cy);
if (GetDocument()->outTab.m_hWnd)
{
GetDocument()->outTab.SetWindowPos(NULL,0,0,cx,cy,SWP_SHOWWINDOW);
RECT rect;
GetDocument()->outTab.GetClientRect(&rect);
int k = GetDocument()->outTab.GetCurSel();
if (k==0)
output.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
else if(k==1)
err.SetWindowPos(NULL,rect.left,rect.top+25,rect.right-rect.left,rect.bottom-rect.top-25,SWP_SHOWWINDOW);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -