📄 mainwin.cpp
字号:
{ //wxString strURL(wxT("redirect/the-ecos-configuration-tool.html")); wxString strURL(wxGetApp().GetFullAppPath(wxT("manual/user-guides.2.html"))); if (!wxFileExists(strURL)) strURL = wxT("user-guide/the-ecos-configuration-tool.html"); if (wxGetApp().GetConfigToolDoc()) { wxGetApp().GetConfigToolDoc()->ShowURL(strURL); }}void ecMainFrame::OnHelpContext(wxCommandEvent& event){ wxContextHelp contextHelp;}void ecMainFrame::OnResolveConflicts(wxCommandEvent& event){/* ecResolveConflictsDialog dialog(this); dialog.ShowModal();*/ if ( ecConfigToolDoc::NotDone == wxGetApp().GetConfigToolDoc()->ResolveGlobalConflicts() ) { // Global inference handler was never invoked. Say something wxString msg; msg.Printf(_("No solutions can be automatically determined for the current set of conflicts.")); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); } }void ecMainFrame::OnUpdateResolveConflicts(wxUpdateUIEvent& event){ if (!wxGetApp().GetConfigToolDoc() || !wxGetApp().GetConfigToolDoc()->GetCdlInterpreter()) { event.Enable(FALSE); return; } event.Enable(wxGetApp().GetConfigToolDoc()->GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0);}void ecMainFrame::OnSettings(wxCommandEvent& event){ ecSettingsDialog dialog(this); dialog.ShowModal();}void ecMainFrame::OnPlatforms(wxCommandEvent& event){ ecPlatformsDialog dialog(this); if (dialog.ShowModal() == wxID_OK) { CeCosTestPlatform::RemoveAllPlatforms(); unsigned int i ; for(i=0; i < dialog.PlatformCount();i++){ CeCosTestPlatform::Add(*dialog.Platform(i)); } CeCosTestPlatform::Save(); }}void ecMainFrame::OnBuildOptions(wxCommandEvent& event){ ecBuildOptionsDialog dialog(this); dialog.ShowModal();}void ecMainFrame::OnTemplates(wxCommandEvent& event){ ecTemplatesDialog dialog(this); if (dialog.ShowModal() == wxID_OK) {#ifdef __WXMSW__ // Ensure display gets updated ::UpdateWindow((HWND) GetHWND()); //wxYield();#endif ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); doc->SelectHardware(dialog.GetSelectedHardware()); doc->SelectTemplate(dialog.GetSelectedTemplate(), dialog.GetSelectedTemplateVersion()); }}void ecMainFrame::OnAdmin(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); wxASSERT (doc) ; if (wxYES == wxMessageBox(_("This command will close the current document.\n\nDo you wish to continue?"), wxGetApp().GetAppName(), wxYES_NO, this)) { wxString shellCommands; // ensure that the user tools are on the path for use by ecosadmin.tcl // TODO: need to something else for Linux (since it returns settings in shellCommands) if (wxGetApp().PrepareEnvironment(FALSE, & shellCommands)) { // make sure we use doc data before the doc is destroyed ecAdminDialog dlg(this, doc->GetPackagesDir(), wxGetApp().GetSettings().GetUserToolsDir()); if (dlg.ShowModal() == wxID_OK) { // Create new document wxGetApp().GetDocManager()->CreateDocument(wxEmptyString, wxDOC_NEW); } } }}void ecMainFrame::OnPackages(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (doc) doc->SelectPackages();}void ecMainFrame::OnRunTests(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (doc) doc->RunTests();}void ecMainFrame::OnChooseRepository(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (doc && !doc->OnSaveModified()) return; if (!doc) { doc = (ecConfigToolDoc*) wxGetApp().GetDocManager()->CreateDocument(wxString(""), wxDOC_NEW|ecDOC_PROMPT_FOR_REPOSITORY); return; } if (doc) doc->m_bRepositoryOpen = FALSE; if (wxGetApp().GetConfigToolDoc()->OpenRepository(wxEmptyString, TRUE)) { // TODO#if 0 // reset the document title as shown in the frame window GetDocTemplate ()->SetDefaultTitle (this); // load the memory layout for the default target-platform-startup from the new repository NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf")));#endif doc->UpdateAllViews(NULL); doc->UpdateFailingRuleCount(); } else { if (doc) doc->m_bRepositoryOpen = TRUE; }}void ecMainFrame::OnBuildToolsPath(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (!doc) return; // add the current build tools dir to the drop-down list box wxArrayString arstrPaths; if (!wxGetApp().GetSettings().m_buildToolsDir.IsEmpty()) arstrPaths.Add(wxGetApp().GetSettings().m_buildToolsDir); // also add the sub-directory containing tools for the current command prefix wxString value; wxStringToStringMap& map = wxGetApp().GetSettings().GetBinDirs(); const wxString strPrefix(doc->GetCurrentTargetPrefix()); if (map.Find(strPrefix, value) && (wxNOT_FOUND == arstrPaths.Index(value))) arstrPaths.Add(value); wxString msg; msg.Printf(_("Enter the location of the %s build tools\n" "folder. You can type in a path or use the\n" "Browse button to navigate to a folder."), (const wxChar*) (strPrefix.IsEmpty() ? wxString(wxT("native")) : strPrefix)); wxString caption(_("Build Tools Path")); ecFolderDialog dialog(wxGetApp().GetSettings().m_buildToolsDir, arstrPaths, msg, this, ecID_BUILD_TOOLS_DIALOG, caption); if (dialog.ShowModal() == wxID_OK) { wxString path (dialog.GetPath()); // look for *objcopy under the user-specified build tools directory wxArrayString objcopyFiles; wxString objcopyFileSpec(wxT("objcopy"));#ifdef __WXMSW__ objcopyFileSpec += wxT(".exe");#endif size_t objcopyCount = wxDir::GetAllFiles(path, &objcopyFiles, wxT("*") + objcopyFileSpec, wxDIR_FILES | wxDIR_DIRS); bool bPrefixFound = false; for (int count=0; count < objcopyCount; count++) { wxFileName file (objcopyFiles [count]); wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec))); if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last())) new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen if (new_prefix == strPrefix) bPrefixFound = true; } wxString msg; msg.Printf(wxT("%s does not appear to contain the build tools - use this folder anyway?"), (const wxChar*) path); if(bPrefixFound || (wxYES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO))) { for (int count=0; count < objcopyCount; count++) { wxFileName file (objcopyFiles [count]); wxString new_prefix (file.GetFullName().Left (file.GetFullName().Find(objcopyFileSpec))); if ((! new_prefix.IsEmpty()) && ('-' == new_prefix.Last())) new_prefix = new_prefix.Left (new_prefix.Len() - 1); // strip off trailing hyphen map.Set(new_prefix, file.GetPath(wxPATH_GET_VOLUME)); } wxGetApp().GetSettings().m_buildToolsDir = path; } }}void ecMainFrame::OnUserToolsPath(wxCommandEvent& event){ ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc(); if (!doc) return; wxArrayString paths = wxGetApp().GetSettings().m_userToolPaths; if (!wxGetApp().GetSettings().m_userToolsDir.IsEmpty()) paths.Add(wxGetApp().GetSettings().m_userToolsDir); wxString msg(_("Enter the location of the user tools folder,\n" "which should contain cat and ls. You can type in\n" "a path or use the Browse button to navigate to a\n" "folder.")); wxString caption(_("User Tools Path")); wxString defaultPath(wxGetApp().GetSettings().m_userToolsDir); ecFolderDialog dialog(defaultPath, paths, msg, this, ecID_USER_TOOLS_DIALOG, caption); if (dialog.ShowModal() == wxID_OK) { wxString path(dialog.GetPath()); ecFileName strFile(path);#ifdef __WXMSW__ wxString exeSuffix(wxT(".exe"));#else wxString exeSuffix(wxEmptyString);#endif wxString prog(wxString(wxT("ls")) + exeSuffix); strFile += (const wxChar*) prog; wxString msg; msg.Printf(wxT("%s does not appear to contain the user tools - use this folder anyway?"), (const wxChar*) path); if(strFile.Exists() || (wxYES == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO))) { wxGetApp().GetSettings().m_userToolsDir = path; } }}// Process events for the window with the focus first.bool ecMainFrame::ProcessEvent(wxEvent& event){ static wxEvent* s_lastEvent = NULL; if (& event == s_lastEvent) return FALSE; if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxChildFocusEvent))) { s_lastEvent = & event; wxWindow* focusWin = wxFindFocusDescendant(this); bool success = FALSE; if (focusWin) { //long windowId = focusWin->GetId(); //wxLogDebug("Found focus window %d", windowId); success = focusWin->GetEventHandler()->ProcessEvent(event); } if (!success) success = wxDocParentFrame::ProcessEvent(event); s_lastEvent = NULL; return success; } else { return wxDocParentFrame::ProcessEvent(event); }}void ecMainFrame::SetFailRulePane(int nCount){ wxString strCount; switch (nCount) { case 0: strCount = wxT("No conflicts"); break; case 1: strCount = wxT("1 conflict"); break; default: strCount.Printf (_("%d conflicts"), nCount); break; } if (GetStatusBar()) { GetStatusBar()->SetStatusText(strCount, ecFailRulePane); }}// Update the title, either via the document's view or explicitly if no docvoid ecMainFrame::UpdateFrameTitle(){ if (wxGetApp().GetConfigToolDoc()) wxGetApp().GetConfigToolDoc()->GetFirstView()->OnChangeFilename(); else SetTitle(wxGetApp().GetSettings().GetAppName());}void ecMainFrame::OnUpdatePlatforms(wxUpdateUIEvent& event){ event.Enable(TRUE);}void ecMainFrame::OnUpdateBuildOptions(wxUpdateUIEvent& event){ event.Enable(wxGetApp().GetConfigToolDoc() != NULL);}void ecMainFrame::OnUpdateBuildToolsPath(wxUpdateUIEvent& event){ event.Enable(wxGetApp().GetConfigToolDoc() != NULL);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -