📄 mainfrm.cpp
字号:
(bWithBuildTools && ! CUtils::AddToPath (strBinDir)) || ! CUtils::AddToPath (strUserBinDir) || ! CUtils::AddToPath (strHostToolsBinDir)) { CUtils::MessageBoxF(_T("Failed to set PATH environment variable - rc=%d"),GetLastError()); rc=false; } else { if(!SetEnvironmentVariable(_T("MAKE_MODE"),_T("unix"))){ CUtils::MessageBoxF(_T("Failed to set MAKE_MODE environment variable - rc=%d"),GetLastError()); rc=false; } else { SetEnvironmentVariable(_T("GDBTK_LIBRARY"),NULL); SetEnvironmentVariable(_T("GCC_EXEC_PREFIX"),NULL); SetEnvironmentVariable(_T("ECOS_REPOSITORY"),pDoc->PackagesDir()); // useful for ecosconfig if (! pDoc->BuildTree().IsEmpty()) CygMount(pDoc->BuildTree()[0]); if (! pDoc->InstallTree().IsEmpty()) CygMount(pDoc->InstallTree()[0]); if (! pDoc->Repository().IsEmpty()) CygMount(pDoc->Repository()[0]); } } } } return rc;}void CMainFrame::OnClose() { if(NULL!=m_psp){ if(IDNO==CUtils::MessageBoxFT(MB_YESNO|MB_DEFBUTTON2,_T("A build is in progress: exit anyway?"))){ return; } m_psp->CygKill(); } SaveBarState(_T("DockState")); CFrameWnd::OnClose();}void CMainFrame::OnBuildOptions() { CBuildOptionsDialog dlg; dlg.DoModal();}void CMainFrame::OnUpdateBuildOptions(CCmdUI* pCmdUI) { pCmdUI->Enable(TRUE); }void CMainFrame::OnToolsOptions() { CToolsOptionsDialog dlg; dlg.DoModal();}void CMainFrame::OnUpdateViewMLT(CCmdUI* pCmdUI) { pCmdUI->SetCheck(arView[MLT].bVisible);}void CMainFrame::OnViewConflicts() { arView[Rules].bVisible^=1; arView[Rules].pParent->ShowPane(arView[Rules].pView,arView[Rules].bVisible);}void CMainFrame::OnUpdateViewConflicts(CCmdUI* pCmdUI) { pCmdUI->SetCheck(arView[Rules].bVisible);}void CMainFrame::OnToolsPaths() { CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc(); CConfigToolApp *pApp=(CConfigToolApp *)GetApp(); CString strDefault; const CString strPrefix(pDoc->CurrentTargetPrefix()); CStringArray arstrPaths; for(POSITION pos = pApp->m_arstrBinDirs.GetStartPosition(); pos != NULL; ){ CString strP,strB; pApp->m_arstrBinDirs.GetNextAssoc(pos, strP, strB); arstrPaths.Add(strB); if(strP==strPrefix){ strDefault=strB; } } CBinDirDialog dlg(arstrPaths,strDefault); dlg.m_strDesc.Format(CUtils::LoadString(IDS_COMPTOOLS_DLG_DESC),strPrefix.IsEmpty()?_T("native"):strPrefix,strPrefix.IsEmpty()?_T(""):strPrefix+_T("-")); dlg.m_strTitle=_T("Build Tools"); if(IDOK==dlg.DoModal()){ CFileName strExe; strExe.Format(_T("%s\\%s%sgcc.exe"),dlg.m_strFolder,strPrefix,strPrefix.IsEmpty()?_T(""):_T("-")); if(strExe.Exists()|| IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("%s does not appear to contain the build tools - use this folder anyway?"),dlg.m_strFolder)){ pApp->m_arstrBinDirs.SetAt(strPrefix,dlg.m_strFolder); } }}void CMainFrame::OnUsertoolsPaths() { CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc(); CConfigToolApp * pApp = (CConfigToolApp *) GetApp (); CStringArray arstrPaths; arstrPaths.Copy(pDoc->m_arstrUserToolPaths); if(!pApp->m_strUserToolsDir.IsEmpty()){ arstrPaths.Add(pApp->m_strUserToolsDir); } CBinDirDialog dlg(arstrPaths, pApp->m_strUserToolsDir); dlg.m_strDesc.LoadString(IDS_USERTOOLS_DLG_DESC); dlg.m_strTitle=_T("User Tools"); if(IDOK==dlg.DoModal()){ CFileName strFile(dlg.m_strFolder); strFile+=_T("ls.exe"); if(strFile.Exists()|| IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("%s does not appear to contain the user tools - use this folder anyway?"),dlg.m_strFolder)){ pApp->m_strUserToolsDir=dlg.m_strFolder; } }}void CMainFrame::UpdateThermometer(int nLines){ if(nLines>=0 && 0!=m_nThermometerMax){ int nPercentage=min(100,(100*nLines)/m_nThermometerMax); m_Progress.SetPos(nPercentage); CString str; if(nLines>0){ str.Format(_T("%d%%"),nPercentage); } m_wndStatusBar.SetPaneText(PercentagePane,str); }}void CMainFrame::SetThermometerMax (int nMax){ if(0==nMax){ UpdateThermometer(0); } m_nThermometerMax=nMax;}LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam){ if (AFX_IDS_IDLEMESSAGE==wParam){ wParam=0; lParam=(LPARAM)(LPCTSTR )m_strIdleMessage; } return CFrameWnd::OnSetMessageString(wParam, lParam);}void CMainFrame::SetIdleMessage (LPCTSTR pszIdleMessage){ if(NULL==pszIdleMessage){ m_strIdleMessage.LoadString(AFX_IDS_IDLEMESSAGE); } else { m_strIdleMessage=pszIdleMessage; } SendMessage(WM_SETMESSAGESTRING, AFX_IDS_IDLEMESSAGE, 0);} void CMainFrame::OnRunSim(){ CConfigTool::GetConfigToolDoc()->RunTests();}bool CMainFrame::SetPaneFont(PaneType pane,const LOGFONT &lf){ CFont &font=arView[pane].font; font.Detach(); font.CreateFontIndirect(&lf); switch(pane){ case Output: CConfigTool::GetOutputView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); break; case ShortDesc: CConfigTool::GetDescView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetDescView()->Invalidate(); break; case Control: case Cell: CConfigTool::GetControlView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetCellView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetControlView()->Invalidate(); CConfigTool::GetCellView()->Invalidate(); break; case Properties: CConfigTool::GetPropertiesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetPropertiesView()->Invalidate(); break; case Rules: CConfigTool::GetRulesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetRulesView()->Invalidate(); break; case MLT: CConfigTool::GetRulesView()->SendMessage(WM_SETFONT, (WPARAM)(HFONT)font, 0); CConfigTool::GetRulesView()->Invalidate(); break; default: ASSERT(FALSE); break; } return true;}CFont &CMainFrame::GetPaneFont(PaneType pane){ return arView[pane].font;}void CMainFrame::OnUpdateRunSim(CCmdUI* pCmdUI) { pCmdUI->Enable(!CConfigTool::GetConfigToolDoc()->InstallTree().IsEmpty() && NULL==m_psp);}void CMainFrame::SetFailRulePane(int nCount){ CString strCount; switch (nCount) { case 0: strCount = _T("No conflicts"); break; case 1: strCount = _T("1 conflict"); break; default: strCount.Format (_T("%d conflicts"), nCount); break; } if(m_bStatusBarCreated){ m_wndStatusBar.SetPaneText (FailRulePane, strCount); }}void CMainFrame::OnUpdateFrameTitle (BOOL bAddToTitle){ if ((GetStyle() & FWS_ADDTOTITLE) == 0) return; // leave it alone! /* #ifndef _AFX_NO_OLE_SUPPORT // allow hook to set the title (used for OLE support) if (m_pNotifyHook != NULL && m_pNotifyHook->OnUpdateFrameTitle()) return; #endif */ CDocument* pDoc=CConfigTool::GetConfigToolDoc(); if (bAddToTitle && pDoc != NULL) UpdateFrameTitleForDocument(pDoc->GetTitle() + (pDoc->IsModified () ? "*" : "")); else UpdateFrameTitleForDocument(NULL);}void CMainFrame::OnViewMltbar() { m_bMLTToolbarVisible^=1; ShowControlBar(&m_wndMLTToolBar,m_bMLTToolbarVisible,false);}void CMainFrame::OnUpdateViewMltbar(CCmdUI* pCmdUI) { pCmdUI->Enable(arView[MLT].bVisible); pCmdUI->SetCheck(m_bMLTToolbarVisible);}void CMainFrame::OnResolveConflicts() { if(CConfigToolDoc::NotDone==CConfigTool::GetConfigToolDoc()->ResolveGlobalConflicts()){ // Global inference handler was never invoked. Say something CUtils::MessageBoxF(_T("No solutions can be automatically determined for the current set of conflicts.")); }}void CMainFrame::OnUpdateResolveConflicts(CCmdUI* pCmdUI) { pCmdUI->Enable(CConfigTool::GetConfigToolDoc()->GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0);}void CMainFrame::OnGoHome() // Help->eCos Documentation{ CConfigTool::GetConfigToolDoc()->ShowURL(CUtils::LoadString(IDS_ECOS_HELP));}HMENU CMainFrame::NewMenu(){ // Load the menu from the resources m_menu.LoadMenu(IDR_MAINFRAME); m_menu.LoadToolbar(IDR_MAINFRAME); m_menu.LoadToolbar(IDR_MISCBAR); m_menu.ModifyODMenu(NULL,ID_HELP,IDB_HELP); m_menu.ModifyODMenu(NULL,ID_GO_HOME,IDB_HELP); m_menu.ModifyODMenu(NULL,ID_HELP_RED_HATONTHEWEB,IDB_HTML); m_menu.ModifyODMenu(NULL,ID_HELP_ECOSHOME,IDB_HTML); m_menu.ModifyODMenu(NULL,ID_HELP_ECOS,IDB_HTML); m_menu.ModifyODMenu(NULL,ID_HELP_UITRON,IDB_HTML); return(m_menu.Detach());}//This handler ensure that the popup menu items are drawn correctlyvoid CMainFrame::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { BOOL setflag=FALSE; if(lpMeasureItemStruct->CtlType==ODT_MENU){ if(IsMenu((HMENU)lpMeasureItemStruct->itemID)){ CMenu* cmenu=CMenu::FromHandle((HMENU)lpMeasureItemStruct->itemID); if(BCMenu::IsMenu(cmenu)){ m_menu.MeasureItem(lpMeasureItemStruct); setflag=TRUE; } } } if(!setflag)CFrameWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);} //This handler ensures that keyboard shortcuts workLRESULT CMainFrame::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu) { LRESULT lresult; if(BCMenu::IsMenu(pMenu)) lresult=BCMenu::FindKeyboardShortcut(nChar, nFlags, pMenu); else lresult=CFrameWnd::OnMenuChar(nChar, nFlags, pMenu); return(lresult);} //This handler updates the menus from time to timevoid CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) { CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); if(!bSysMenu){ if(BCMenu::IsMenu(pPopupMenu))BCMenu::UpdateMenu(pPopupMenu); }}LRESULT CMainFrame::OnSubprocess(WPARAM, LPARAM lParam){ if(lParam){ LPTSTR psz=(LPTSTR)lParam; CConfigToolDoc *pDoc=CConfigTool::GetConfigToolDoc(); m_nLogicalLines+=pDoc->GetCompilationCount(psz); UpdateThermometer (m_nLogicalLines); CConfigTool::GetOutputView()->AddText(psz); deleteZA(psz); } else { ::PostThreadMessage(m_dwThreadId,WM_SUBPROCESS+1,0,0); TRACE(_T("m_nThermometerMax=%d m_nLogicalLines=%d\n"),m_nThermometerMax,m_nLogicalLines); if(0==m_psp->GetExitCode){ UpdateThermometer(m_nThermometerMax); Sleep(250); // Allow user to see it } UpdateThermometer(0); SetThermometerMax(0); deleteZ(m_psp); return 0; } return 0;}void CMainFrame::OnUpdateToolsAdministration(CCmdUI* pCmdUI) { pCmdUI->Enable(NULL==m_psp);}void CMainFrame::CygMount(TCHAR c){ ASSERT(_istalpha(c)); c=towlower(c); if(!m_arMounted[c-_TCHAR('a')]){ m_arMounted[c-_TCHAR('a')]=true; CString strCmd,strOutput; strCmd.Format(_T("mount %c: /%c"),c,c); CSubprocess::Run(strOutput,strCmd); }}BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo) { // TODO: Add your message handler code here and/or call default return CFrameWnd::OnHelpInfo(pHelpInfo);}void CMainFrame::OnNavComplete(NMHDR* pHdr, LRESULT*){ TRACE(_T("HH Notify\n"));}BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { if(WM_NOTIFY==pMsg->message){ LPNMHDR pHdr=(LPNMHDR)pMsg->lParam; TRACE(_T("WM_NOTIFY id=%d idFrom=%d code=%d\n"),pMsg->wParam,pHdr->idFrom,pHdr->code); } return CFrameWnd::PreTranslateMessage(pMsg);}void CMainFrame::OnEditPlatforms() { CPlatformsDialog dlg; if(IDOK==dlg.DoModal()){ CeCosTest::RemoveAllPlatforms(); for(unsigned int i=0;i<dlg.PlatformCount();i++){ CeCosTest::AddPlatform(*dlg.Platform(i)); } CeCosTest::SaveTargetInfo(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -