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

📄 mainfrm.cpp

📁 eCos1.31版
💻 CPP
📖 第 1 页 / 共 3 页
字号:
void CMainFrame::OnUpdateViewShortdesc(CCmdUI* pCmdUI) {  pCmdUI->SetCheck(arView[ShortDesc].bVisible);}void CMainFrame::OnViewOutput() {  arView[Output].bVisible^=1;  arView[Output].pParent->ShowPane(arView[Output].pView,arView[Output].bVisible);}void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI) {  pCmdUI->SetCheck(arView[Output].bVisible);}	void CMainFrame::OnUpdateBuildConfigure(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnBuildStop() {  m_psp->CygKill(); // leave the rest to OnSubprocessComplete()}void CMainFrame::OnUpdateBuildStop(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL!=m_psp);}void CMainFrame::OnConfigurationBuild() {  Build();}DWORD CMainFrame::ThreadFunc(LPVOID param){  CMainFrame *pMain=(CMainFrame *)param;  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  CString strCmd(_T("make -n "));  strCmd+=pMain->m_strBuildTarget;  CSubprocess sp(true);;  sp.Run(GetCurrentThreadId(),strCmd, pDoc->BuildTree());  CString strBuf;  for(;;){    MSG msg;    switch(::GetMessage(&msg,NULL,WM_SUBPROCESS,WM_SUBPROCESS+1)){    case 0:      return 0; //WM_QUIT    case -1:      return 1; // error    case 1:      if(WM_SUBPROCESS==msg.message){        if(msg.lParam){          LPTSTR pszMsg=(LPTSTR)msg.lParam;          strBuf+=pszMsg;          deleteZA(pszMsg);        } else {#ifdef _DEBUG          CStdioFile file;          CFileName strFile(CFileName::GetTempPath()+_T("__ctbuffer.tmp"));          if(file.Open(strFile,CFile::modeCreate|CFile::modeWrite|CFile::typeText)){            file.WriteString(strBuf);            file.Close();          }#endif  // Don't attempt to change the thermometer itself - not safe from a separate thread          pMain->m_nThermometerMax=pDoc->GetCompilationCount(strBuf);        }      } else {        sp.CygKill();      }    }  }    return 0;}void CMainFrame::Build(const CString &strWhat/*=_T("")*/){  ASSERT(NULL==m_psp);  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();    if(!arView[Output].bVisible){    SendMessage(WM_COMMAND,ID_VIEW_OUTPUT,0);  }    if(pDoc->IsModified()||pDoc->BuildTree().IsEmpty()){    SendMessage (WM_COMMAND, ID_FILE_SAVE);  }    if(!(pDoc->IsModified()||pDoc->BuildTree().IsEmpty())){ // verify the save worked    CString strCmd (_T("make"));    if(!strWhat.IsEmpty()){      strCmd+=_TCHAR(' ');      strCmd+=strWhat;    }    if(!GetApp()->m_strMakeOptions.IsEmpty()){      strCmd+=_TCHAR(' ');      strCmd+=GetApp()->m_strMakeOptions;    }    if(PrepareEnvironment()){      m_strBuildTarget=strWhat;      SetThermometerMax(250); // This is just a guess.  The thread we are about to spawn will work out the correct answer      m_nLogicalLines=0;      UpdateThermometer(0);      CloseHandle(CreateThread(NULL, 0, ThreadFunc, this, 0 ,&m_dwThreadId));      CString strMsg;      strMsg.Format(_T("Building %s"),strWhat);      SetIdleMessage(strMsg);            m_psp=new CSubprocess(true);       if(!m_psp->Run(m_hWnd, strCmd, pDoc->BuildTree())){         deleteZ(m_psp);      }      SetIdleMessage();    }  }}CConfigToolApp * CMainFrame::GetApp(){  return (CConfigToolApp *)AfxGetApp();}void CMainFrame::ActivateFrame(int nCmdShow) {  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  CRect rcDefault;  SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)(RECT *)rcDefault, 0);  // Insist on nothing more than 1000 width, with the golden ratio  rcDefault.DeflateRect(max(0,(rcDefault.Width()-1000)/2),max(0,(rcDefault.Height()-618)/2));    GetApp()->RestoreWindowPlacement (this, _T("Window size"),rcDefault);  LoadBarState(_T("DockState"));    ShowControlBar(&m_wndMLTToolBar,arView[MLT].bVisible,false);  CFrameWnd::ActivateFrame(nCmdShow); // must be before we muck about with the splitters    CRect rcClient;  GetClientRect(rcClient);  for(int j=0;j<sizeof arSplit/sizeof arSplit[0];j++){    Split &s=arSplit[j];    if(s.pSplit){      CString strKey;      strKey.Format(_T("Split %d"),j);      const CString strSplit(GetApp()->GetProfileString(_T("Split"),strKey));      double fSplit=s.fFrac;      _tscanf(_T("%f"),&fSplit);      s.pSplit->SetSplitPoint(fSplit);      s.pSplit->RecalcLayout();    }  }  for(int i=0;i<PaneTypeMax;i++){    ViewStruct &v=arView[(PaneType)i];    v.pParent->ShowPane(v.pView,v.bVisible);  }  RecalcLayout();  pDoc->UpdateFailingRuleCount();  }void CMainFrame::OnDestroy() {    GetApp()->SaveWindowPlacement (this, _T("Window size"));  for(int i=0;i<PaneTypeMax;i++){    LOGFONT lf;    ViewStruct &v=arView[(PaneType)i];    v.font.GetLogFont(&lf);    GetApp()->SaveFont(v.pszName,lf);  }  for(int j=0;j<sizeof arSplit/sizeof arSplit[0];j++){    Split &s=arSplit[j];    if(s.pSplit){      CString strSplit;      strSplit.Format(_T("%f"),s.pSplit->GetSplitPoint());      CString strKey;      strKey.Format(_T("%d"),j);      GetApp()->WriteProfileString(_T("Split"),strKey,strSplit);    }  }  for(j=0;j<sizeof arSplit/sizeof arSplit[0];j++){    Split &s=arSplit[j];    if(s.pSplit){      deleteZ(s.pSplit);    }  }    if(NULL!=m_psp){    m_psp->CygKill();  }    for(i=0;i<sizeof arView/sizeof arView[0];i++){    GetApp()->WriteProfileInt(_T("Windows"), arView[i].pszName, arView[i].bVisible);  }  CFrameWnd::OnDestroy();}void CMainFrame::OnBuildTests() {  Build("tests");}void CMainFrame::OnUpdateBuildTests(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnUpdateFileSave(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnUpdateFileNew(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnUpdateAppExit(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam) {  CFrameWnd::OnSysCommand(nID, lParam);}void CMainFrame::OnUpdateConfigurationRefresh(CCmdUI* pCmdUI) {  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pCmdUI->Enable(NULL==m_psp && !pDoc->BuildTree().IsEmpty());}void CMainFrame::OnConfigurationRefresh() {  CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  pDoc->Reload();}void CMainFrame::OnViewSettings() {  CViewOptions dlg;  dlg.DoModal();}void CMainFrame::OnHelp() // Help->Configuration Tool Help{  CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_CONFIGTOOL_HELP));}void CMainFrame::OnSize(UINT nType, int cx, int cy) {  CFrameWnd::OnSize(nType, cx, cy);  if(m_wndStatusBar){    cx=max(0,cx-m_nFailRulePaneSize-m_nThermometerPaneSize-m_nPercentagePaneSize);    m_wndStatusBar.SetPaneInfo(StatusPane, 0, SBPS_STRETCH   , 0);	    m_wndStatusBar.SetPaneInfo(ThermometerPane, 0, SBPS_NORMAL, m_nThermometerPaneSize);	    m_wndStatusBar.SetPaneInfo(PercentagePane, 0, SBPS_NORMAL, m_nPercentagePaneSize);	    m_wndStatusBar.SetPaneInfo(FailRulePane, 0, SBPS_NORMAL, m_nFailRulePaneSize);	    CRect rc;	    m_wndStatusBar.GetItemRect(ThermometerPane, rc);    // Reposition the progress control correctly!    m_Progress.SetWindowPos(&wndTop, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);   }}void CMainFrame::OnUpdateConfigurationRepository(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnWindowNext() {  BumpWindow(+1);}void CMainFrame::OnWindowPrev() {  BumpWindow(-1);}void CMainFrame::BumpWindow(int nInc){  CWnd *pWnd=CWnd::GetFocus();  if(pWnd){    int nWindows=sizeof arView/sizeof arView[0];    for(int i=0;i<nWindows;i++){      CWnd *pThisWnd=arView[i].pView;      if(pWnd->m_hWnd==pThisWnd->m_hWnd){        for(int j=((i+nInc+nWindows)%nWindows);j!=i;j=((j+nInc+nWindows)%nWindows)){          if(arView[j].bVisible){            arView[j].pView->SetFocus();            return;          }        }      }    }  }}void CMainFrame::OnHelpSubmitPr() {  CString strURL;  if(strURL.LoadString(IDS_ECOS_PR_URL)){    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);  }}void CMainFrame::OnHelpEcos() {  CString strURL;  if(strURL.LoadString(IDS_ECOS_SOURCEWARE_URL)){    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);  }}void CMainFrame::OnHelpEcoshome() {  CString strURL;  if(strURL.LoadString(IDS_ECOS_HOME_URL)){    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);  }}void CMainFrame::OnHelpRedHatHome() {  CString strURL;  if(strURL.LoadString(IDS_RED_HAT_HOME_URL)){    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);  }}void CMainFrame::OnHelpUitron() {  CString strURL;  if(strURL.LoadString(IDS_UITRON_HOME_URL)){    CConfigTool::GetConfigToolDoc()->ShowURL(strURL);  }}void CMainFrame::OnBuildClean() {  Build("clean");}void CMainFrame::OnUpdateBuildClean(CCmdUI* pCmdUI) {  pCmdUI->Enable(NULL==m_psp);}void CMainFrame::OnToolsShell() {  if(PrepareEnvironment()){        CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();    const CFileName strOldFolder(CFileName::SetCurrentDirectory(pDoc->BuildTree()));    CUtils::Launch(_T(""),CUtils::LoadString(IDS_SHELL_NAME));    if(!strOldFolder.IsEmpty()){ // if the current directory was changed      SetCurrentDirectory(strOldFolder); // restore the previous current directory    }  }}bool CMainFrame::PrepareEnvironment(bool bWithBuildTools /* = true */){    CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc();  CConfigToolApp *pApp=(CConfigToolApp *)GetApp();  ::SetEnvironmentVariable(_T("PATH"),pApp->m_strOriginalPath);  const CString strPrefix(pDoc->CurrentTargetPrefix());  CFileName strBinDir;  bool rc=(! bWithBuildTools) || pApp->m_arstrBinDirs.Lookup(strPrefix,strBinDir);  if(!rc){    SendMessage(WM_COMMAND,ID_TOOLS_PATHS,0);    rc=pApp->m_arstrBinDirs.Lookup(strPrefix,strBinDir);  }    if(rc){        CFileName strUserBinDir(pApp->m_strUserToolsDir);    if(strUserBinDir.IsEmpty()){      if(1==pDoc->m_arstrUserToolPaths.GetSize()){        pApp->m_strUserToolsDir=pDoc->m_arstrUserToolPaths[0];      } else {        SendMessage(WM_COMMAND,ID_USERTOOLS_PATHS,0);      }      strUserBinDir=pApp->m_strUserToolsDir;    }    if(!strUserBinDir.IsEmpty()){      // calculate the directory of the host tools from this application's module name      CFileName strHostToolsBinDir;      ::GetModuleFileName (::GetModuleHandle (NULL), strHostToolsBinDir.GetBuffer (1 + MAX_PATH), MAX_PATH);      strHostToolsBinDir.ReleaseBuffer ();      strHostToolsBinDir = strHostToolsBinDir.Head ();      // tools directories are in the order host-tools, user-tools, comp-tools, install/bin (if present), contrib-tools (if present) on the path      const CFileName strContribBinDir(strUserBinDir,_T("..\\contrib\\bin"));      const CFileName strUsrBinDir(strUserBinDir,_T("..\\usr\\bin"));      const CFileName strInstallBinDir(pDoc->InstallTree (),_T("bin"));      if (        (strUsrBinDir.IsDir ()     && ! CUtils::AddToPath (strUsrBinDir)) ||         (strContribBinDir.IsDir () && ! CUtils::AddToPath (strContribBinDir)) ||         (strInstallBinDir.IsDir () && ! CUtils::AddToPath (strInstallBinDir)) || 

⌨️ 快捷键说明

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