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

📄 configtool.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            saveFile = dir + wxString(wxFILE_SEP_PATH) + filename;            return TRUE;        }    }    return FALSE;}int ecApp::OnExit(void){/*    if (m_helpController)    {        delete m_helpController;        m_helpController = NULL;    }*/    if (m_splashScreen)    {        m_splashScreen->Destroy();        m_splashScreen = NULL;    }    m_settings.SaveConfig();    {        wxConfig config(wxGetApp().GetSettings().GetConfigAppName());        if (config.HasGroup(wxT("FileHistory")))            config.DeleteGroup(wxT("FileHistory"));	config.SetPath(wxT("FileHistory/"));        m_docManager->FileHistorySave(config);    }    delete m_docManager;    return 0;}// Prepend the current program directory to the namewxString ecApp::GetFullAppPath(const wxString& filename) const{    wxString path(m_appDir);    if (path.Last() != '\\' && path.Last() != '/' && filename[0] != '\\' && filename[0] != '/')#ifdef __WXGTK__        path += '/';#else        path += '\\';#endif    path += filename;        return path;}// Are we running in 32K colours or more?bool ecApp::GetHiColour() const{    static bool hiColour = (wxDisplayDepth() >= 16) ;    return hiColour;}// General handler for 'What's this?'void ecApp::OnWhatsThis(wxCommandEvent& event){    wxObject* obj = event.GetEventObject();    wxWindow* win = NULL;    if (obj->IsKindOf(CLASSINFO(wxMenu)))    {        win = ((wxMenu*) obj)->GetInvokingWindow();    }    else if (obj->IsKindOf(CLASSINFO(wxWindow)))    {        win = (wxWindow*) obj;    }    wxWindow* subjectOfHelp = win;    bool eventProcessed = FALSE;    wxPoint pt = wxGetMousePosition();    while (subjectOfHelp && !eventProcessed)    {        wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), pt) ;        helpEvent.SetEventObject(this);        eventProcessed = win->GetEventHandler()->ProcessEvent(helpEvent);                // Go up the window hierarchy until the event is handled (or not).        // I.e. keep submitting ancestor windows until one is recognised        // by the app code that processes the ids and displays help.        subjectOfHelp = subjectOfHelp->GetParent();    }    // wxGetApp().GetHelpController().DisplayTextPopup(GetHelpText(), wxGetMousePosition());}// Log to output windowvoid ecApp::Log(const wxString& msg){    ecMainFrame* frame = (ecMainFrame*) GetTopWindow();    if (frame)    {        frame->GetOutputWindow()->AppendText(msg /* + wxT("\n") */ );        if ((msg == wxEmptyString) || (msg.Last() != wxT('\n')))            frame->GetOutputWindow()->AppendText(wxT("\n"));//        frame->GetOutputWindow()->ShowPosition(frame->GetOutputWindow()->GetLastPosition());    }}void ecApp::SetStatusText(const wxString& text, bool clearFailingRulesPane){    ecMainFrame* mainFrame = GetMainFrame();    if(mainFrame)    {        mainFrame->GetStatusBar()->SetStatusText(text, ecStatusPane);        if (clearFailingRulesPane)            mainFrame->GetStatusBar()->SetStatusText(wxT(""), ecFailRulePane);#ifdef __WXMSW__        ::UpdateWindow((HWND) mainFrame->GetHWND());        //wxYield();#endif    }}// Config tree controlecConfigTreeCtrl* ecApp::GetTreeCtrl() const{    return GetMainFrame()->GetTreeCtrl();}// MLT windowecMemoryLayoutWindow* ecApp::GetMLTWindow() const{    return GetMainFrame()->GetMemoryLayoutWindow();}// Get active documentecConfigToolDoc* ecApp::GetConfigToolDoc() const{    if (m_currentDoc)        return m_currentDoc;    if (!m_docManager)        return NULL;    return wxDynamicCast(m_docManager->GetCurrentDocument(), ecConfigToolDoc);}bool ecApp::Launch(const wxString & strFileName,const wxString &strViewer){    bool ok = FALSE;    wxString cmd;    if (!strViewer.IsEmpty())    {        cmd = strViewer + wxString(wxT(" ")) + strFileName ;    }    else    {        wxString path, filename, ext;        wxSplitPath(strFileName, & path, & filename, & ext);                wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);        if ( !ft )        {            wxLogError(_T("Impossible to determine the file type for extension '%s'"),                ext.c_str());            return FALSE;        }        bool ok = ft->GetOpenCommand(&cmd,            wxFileType::MessageParameters(strFileName, _T("")));        delete ft;                if (!ok)        {            // TODO: some kind of configuration dialog here.            wxMessageBox(_("Could not determine the command for opening this file."),                wxGetApp().GetSettings().GetAppName(), wxOK|wxICON_EXCLAMATION);            return FALSE;        }    }            ok = (wxExecute(cmd, FALSE) != 0);        return ok;#if 0        bool rc=false;        if(!strViewer.IsEmpty())//use custom editor    {        CString strCmdline(strViewer);                TCHAR *pszCmdLine=strCmdline.GetBuffer(strCmdline.GetLength());        GetShortPathName(pszCmdLine,pszCmdLine,strCmdline.GetLength());        strCmdline.ReleaseBuffer();                strCmdline+=_TCHAR(' ');        strCmdline+=strFileName;        PROCESS_INFORMATION pi;        STARTUPINFO si;                si.cb = sizeof(STARTUPINFO);         si.lpReserved = NULL;         si.lpReserved2 = NULL;         si.cbReserved2 = 0;         si.lpDesktop = NULL;         si.dwFlags = 0;         si.lpTitle=NULL;                if(CreateProcess(            NULL, // app name            //strCmdline.GetBuffer(strCmdline.GetLength()),    // command line            strCmdline.GetBuffer(strCmdline.GetLength()),    // command line            NULL, // process security            NULL, // thread security            TRUE, // inherit handles            0,            NULL, // environment            NULL, // current dir            &si, // startup info            &pi)){            CloseHandle(pi.hProcess);            CloseHandle(pi.hThread);            rc=true;        } else {            CUtils::MessageBoxF(_T("Failed to invoke %s.\n"),strCmdline);        }        strCmdline.ReleaseBuffer();    } else {// Use association        TCHAR szExe[MAX_PATH];        HINSTANCE h=FindExecutable(strFileName,_T("."),szExe);        if(int(h)<=32){            CString str;            switch(int(h)){            case 0:  str=_T("The system is out of memory or resources.");break;            case 31: str=_T("There is no association for the specified file type.");break;            case ERROR_FILE_NOT_FOUND: str=_T("The specified file was not found.");break;            case ERROR_PATH_NOT_FOUND: str=_T("The specified path was not found.");break;            case ERROR_BAD_FORMAT:     str=_T("The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).");break;            default: break;            }            CUtils::MessageBoxF(_T("Failed to open document %s.\r\n%s"),strFileName,str);        } else {                        SHELLEXECUTEINFO sei = {sizeof(sei), 0, AfxGetMainWnd()->GetSafeHwnd(), _T("open"),                strFileName, NULL, NULL, SW_SHOWNORMAL, AfxGetInstanceHandle( )};                        sei.hInstApp=0;            HINSTANCE hInst=ShellExecute(AfxGetMainWnd()->GetSafeHwnd(),_T("open"), strFileName, NULL, _T("."), 0)/*ShellExecuteEx(&sei)*/;            if(int(hInst)<=32/*sei.hInstApp==0*/)            {                CString str;                switch(int(hInst))                {                case 0 : str=_T("The operating system is out of memory or resources. ");break;                case ERROR_FILE_NOT_FOUND : str=_T("The specified file was not found. ");break;                case ERROR_PATH_NOT_FOUND : str=_T("The specified path was not found. ");break;                case ERROR_BAD_FORMAT : str=_T("The .EXE file is invalid (non-Win32 .EXE or error in .EXE image). ");break;                case SE_ERR_ACCESSDENIED : str=_T("The operating system denied access to the specified file. ");break;                case SE_ERR_ASSOCINCOMPLETE : str=_T("The filename association is incomplete or invalid. ");break;                case SE_ERR_DDEBUSY : str=_T("The DDE transaction could not be completed because other DDE transactions were being processed. ");break;                case SE_ERR_DDEFAIL : str=_T("The DDE transaction failed. ");break;                case SE_ERR_DDETIMEOUT : str=_T("The DDE transaction could not be completed because the request timed out. ");break;                case SE_ERR_DLLNOTFOUND : str=_T("The specified dynamic-link library was not found. ");break;                    //case SE_ERR_FNF : str=_T("The specified file was not found. ");break;                case SE_ERR_NOASSOC : str=_T("There is no application associated with the given filename extension. ");break;                case SE_ERR_OOM : str=_T("There was not enough memory to complete the operation. ");break;                    //case SE_ERR_PNF : str=_T("The specified path was not found. ");break;                case SE_ERR_SHARE : str=_T("A sharing violation occurred. ");break;                default: str=_T("An unexpected error occurred");break;                }                CUtils::MessageBoxF(_T("Failed to open document %s using %s.\r\n%s"),strFileName,szExe,str);            } else {                rc=true;            }        }    }    return rc;#endif}bool ecApp::PrepareEnvironment(bool bWithBuildTools, wxString* cmdLine){#ifdef __WXMSW__    // Under Windows we can set variables.    ecConfigToolDoc *pDoc = GetConfigToolDoc();        wxSetEnv(wxT("PATH"), m_strOriginalPath);        const wxString strPrefix(pDoc->GetCurrentTargetPrefix());    ecFileName strBinDir;    bool rc = FALSE;    rc=(! bWithBuildTools) || GetSettings().m_arstrBinDirs.Find(strPrefix, strBinDir);    if(!rc)    {        // Use fallback of previously-entered build tools directory, if available        if (!GetSettings().m_buildToolsDir.IsEmpty())        {            strBinDir = GetSettings().m_buildToolsDir ;            rc = TRUE;        }        else        {            wxCommandEvent event;            GetMainFrame()->OnBuildToolsPath(event);            rc = GetSettings().m_arstrBinDirs.Find(strPrefix, strBinDir);        }    }        if (rc)    {        ecFileName strUserBinDir(GetSettings().m_userToolsDir);        if(strUserBinDir.IsEmpty())        {            if ( 1 == GetSettings().m_userToolPaths.GetCount() )            {                GetSettings().m_userToolsDir = GetSettings().m_userToolPaths[0];            } else            {                wxCommandEvent event;                GetMainFrame()->OnUserToolsPath(event);            }            strUserBinDir = GetSettings().m_userToolsDir;        }        if ( !strUserBinDir.IsEmpty() )        {            // calculate the directory of the host tools from this application's module name            ecFileName strHostToolsBinDir(this->argv[0]);            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 ecFileName strContribBinDir(strUserBinDir, wxT("..\\contrib\\bin"));            ecFileName strUsrBinDir(strUserBinDir, wxT("..\\usr\\bin"));            const ecFileName strInstallBinDir(pDoc->GetInstallTree (), wxT("bin"));            // In case strUserBinDir is e.g. c:\program files\red hat\cygwin-00r1\usertools\h-i686-pc-cygwin\bin            if (!strUsrBinDir.IsDir ())                strUsrBinDir = ecFileName(strUserBinDir + _T("..\\..\\..\\H-i686-pc-cygwin\\bin"));            if (                (strUsrBinDir.IsDir ()     && ! ecUtils::AddToPath (strUsrBinDir)) ||                 (strContribBinDir.IsDir () && ! ecUtils::AddToPath (strContribBinDir)) ||                 (strInstallBinDir.IsDir () && ! ecUtils::AddToPath (strInstallBinDir)) ||                 (bWithBuildTools && ! ecUtils::AddToPath (strBinDir)) ||                 ! ecUtils::AddToPath (strUserBinDir) ||                 ! ecUtils::AddToPath (strHostToolsBinDir))            {                wxString msg;                msg.Printf(wxT("Failed to set PATH environment variable"));                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                rc = FALSE;            } else            {                if(!wxSetEnv(_T("MAKE_MODE"),_T("unix")))                {                    wxString msg;                    msg.Printf(wxT("Failed to set MAKE_MODE environment variable"));                    wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    rc = FALSE;                } else                {                    // Remove from the environment                    wxUnsetEnv(wxT("GDBTK_LIBRARY"));                    wxUnsetEnv(wxT("GCC_EXEC_PREFIX"));                    // Useful for ecosconfig                    wxSetEnv(wxT("ECOS_REPOSITORY"), pDoc->GetPackagesDir());                    // Mount /ecos-x so we can access these in text mode                    if (! pDoc->GetBuildTree().IsEmpty() && wxIsalpha(pDoc->GetBuildTree()[0]))                        CygMount(pDoc->GetBuildTree()[0]);                    if (! pDoc->GetInstallTree().IsEmpty() && wxIsalpha(pDoc->GetInstallTree()[0]))                        CygMount(pDoc->GetInstallTree()[0]);                    if (! pDoc->GetRepository().IsEmpty() && wxIsalpha(pDoc->GetRepository()[0]))                        CygMount(pDoc->GetRepository()[0]);                }            }        }    }    return rc;#else    wxASSERT ( cmdLine != NULL );    (* cmdLine) = wxEmptyString;    // Under Unix we need to build up a command line to set variables and invoke make    ecConfigToolDoc *pDoc = GetConfigToolDoc();        const wxString strPrefix(pDoc->GetCurrentTargetPrefix());    ecFileName strBinDir;    bool rc = FALSE;

⌨️ 快捷键说明

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