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

📄 configtooldoc.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                } else {                    // the package was not loaded but should now be loaded                    //TRACE (_T("Loading package %s\n"), strMacroName);                    try                    {                        GetCdlConfig()->load_package (ecUtils::UnicodeToStdStr(strMacroName), ecUtils::UnicodeToStdStr (strVersion), ecConfigToolDoc::CdlParseErrorHandler, ecConfigToolDoc::CdlParseWarningHandler);                        bChanged=true;                    }                    catch (CdlStringException exception)                    {                        wxString msg;                        msg.Printf(_("Error loading package %s:\n\n%s"), (const wxChar*) strMacroName, (const wxChar*) exception.get_message ().c_str ());                        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    }                    catch (...)                    {                        wxString msg;                        msg.Printf(_("Error loading package %s"), (const wxChar*) strMacroName);                        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                    }                }            }        }        if (bChanged) {// at least one package was loaded, unloaded or changed version            Modify(TRUE);            wxGetApp().GetMainFrame()->UpdateFrameTitle();            RegenerateData();        }    }#endif}bool ecConfigToolDoc::UpdateBuildInfo(bool WXUNUSED(bFirstTime)){    try {        GetCdlConfig()->get_build_info(m_BuildInfo);        generate_build_tree (GetCdlConfig(), ecUtils::UnicodeToStdStr(GetBuildTree()), ecUtils::UnicodeToStdStr(GetInstallTree()));        return TRUE;    }    catch(...){        return FALSE;    }}wxString ecConfigToolDoc::GetDefaultHardware (){#ifdef __WXMSW__    // get the greatest eCos version subkey    wxConfig config(wxT("eCos"), wxEmptyString, wxEmptyString, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE);    wxString versionKey(wxT(""));    wxString key(wxT(""));    long index;    bool bMore = config.GetFirstGroup(key, index);    while (bMore)    {        if (wxIsdigit(key.GetChar(0)) && versionKey.CompareTo(key) < 0)            versionKey = key;        bMore = config.GetNextGroup(key, index);    }    if (!versionKey.IsEmpty())    {        wxString defaultHardware;        wxString defaultHardwareKey(versionKey + wxString(wxT("/")) + wxString(wxT("Default Hardware")));        if (config.Read(defaultHardwareKey, & defaultHardware))        {            return defaultHardware;        }    }    return wxEmptyString;#else    // For other platforms, simply rely on Cdl to get the default hardware.    return wxEmptyString;#endif}void ecConfigToolDoc::EnableCallbacks (bool bEnable/*=TRUE*/){    CdlTransactionCallback::set_callback_fn(bEnable?&CdlTransactionHandler:0);    CdlTransactionBody::set_inference_callback_fn(bEnable?&CdlInferenceHandler:0);    CdlTransactionBody::set_inference_override(CdlValueSource_Invalid);}CdlInferenceCallbackResult ecConfigToolDoc::CdlGlobalInferenceHandler(CdlTransaction transaction){    CdlInferenceCallbackResult rc=CdlInferenceCallbackResult_Continue;    ecConfigToolDoc *pDoc = wxGetApp().GetConfigToolDoc();    pDoc->m_ConflictsOutcome=NotDone;  // prepare for the case that there are no solutions    const std::list<CdlConflict>& conflicts=pDoc->GetCdlConfig()->get_all_conflicts();    ecResolveConflictsDialog dlg(wxGetApp().GetTopWindow(), conflicts, transaction, &pDoc->m_arConflictsOfInterest);    rc = (wxID_OK == dlg.ShowModal()) ? CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel;    pDoc->m_ConflictsOutcome=(CdlInferenceCallbackResult_Continue==rc)?OK:Cancel;    return rc;}CdlInferenceCallbackResult ecConfigToolDoc::CdlInferenceHandler (CdlTransaction transaction){    CdlInferenceCallbackResult rc=CdlInferenceCallbackResult_Continue;    ecConfigToolDoc *pDoc=wxGetApp().GetConfigToolDoc();    const std::list<CdlConflict>&conflicts=transaction->get_new_conflicts();    if ((wxGetApp().GetSettings().m_nRuleChecking & ecSettings::Immediate) && conflicts.size()>0)    {        if (wxGetApp().GetSettings().m_nRuleChecking & ecSettings::SuggestFixes)        {            std::list<CdlConflict> s_conflicts;            for (std::list<CdlConflict>::const_iterator conf_i= conflicts.begin (); conf_i != conflicts.end (); conf_i++) { // for each conflict                if((*conf_i)->has_known_solution()){                    s_conflicts.push_back(*conf_i);                }            }            if(s_conflicts.size()>0)            {                wxGetApp().LockValues();                ecResolveConflictsDialog dlg(wxGetApp().GetTopWindow(), s_conflicts, transaction);                int ret = dlg.ShowModal() ;                wxGetApp().UnlockValues();                return (wxID_OK == ret ? CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel);            }        }        wxGetApp().LockValues();        wxString strMsg;        if(1==conflicts.size()){            strMsg=wxT("There is 1 unresolved conflict. Make the change anyway?");        } else {            strMsg.Printf(_("There are %d unresolved conflict%s. Make the change anyway?"), conflicts.size(), (const wxChar*) (1==conflicts.size()? wxT(""):wxT("s")) );        }        rc = (wxYES == wxMessageBox(strMsg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxYES_NO)) ? CdlInferenceCallbackResult_Continue:CdlInferenceCallbackResult_Cancel;        wxGetApp().UnlockValues();    }    return rc;}// a CDL transaction handler to refresh the configuration treevoid ecConfigToolDoc::CdlTransactionHandler (const CdlTransactionCallback & data){    static int nNesting=0;    //TRACE(_T("Transaction handler: nesting level=%d\n"),nNesting++);    ecConfigToolDoc *pDoc = wxGetApp().GetConfigToolDoc();    std::vector<CdlValuable>::const_iterator val_i;    std::vector<CdlNode>::const_iterator node_i;    std::list<CdlConflict>::const_iterator conf_i;    ecConfigToolView *pControlView = (ecConfigToolView*) pDoc->GetFirstView();    for (val_i = data.value_changes.begin(); val_i != data.value_changes.end(); val_i++)    {        const wxString strName((*val_i)->get_name().c_str());        //TRACE(_T("%s %s : value change\n"), wxString ((*val_i)->get_class_name().c_str()), strName);        pControlView->Refresh(strName);        if (strName==wxT("CYGHWR_MEMORY_LAYOUT")){               // the memory layout has changed...            // TODO            // pDoc->SwitchMemoryLayout (FALSE); // ...so display a new one        }    }    for (node_i = data.active_changes.begin(); node_i != data.active_changes.end(); node_i++)    {        const wxString strName((*node_i)->get_name().c_str());        //TRACE(_T("%s %s : this has become active or inactive\n"), CString ((*node_i)->get_class_name().c_str()),        //    CString ((*node_i)->get_name().c_str()));        if (! dynamic_cast<CdlInterface> (*node_i)){ // if not an interface node            pControlView->Refresh(strName);        }    }    for (val_i = data.legal_values_changes.begin(); val_i != data.legal_values_changes.end(); val_i++)    {        const wxString strName((*node_i)->get_class_name().c_str());        //TRACE(_T("%s %s : the legal_values list has changed, a new widget may be needed.\n"),        //    CString ((*val_i)->get_class_name().c_str()), strName);    }    for (val_i = data.value_source_changes.begin(); val_i != data.value_source_changes.end(); val_i++)    {        const wxString strName((*val_i)->get_name().c_str());        CdlValueSource source = (*val_i)->get_source();/*        TRACE(_T("%s %s : the value source has changed to %s\n"),            CString ((*val_i)->get_class_name().c_str()), strName,            CString ((CdlValueSource_Default  == source) ? "default"  :        (CdlValueSource_Inferred == source) ? "inferred" :        (CdlValueSource_Wizard   == source) ? "wizard"   : "user"));*/        pControlView->Refresh (strName);    }    pDoc->UpdateFailingRuleCount();    nNesting--;}bool ecConfigToolDoc::ShowURL(const wxString& strURL1){    bool rc = TRUE;    wxString strURL(strURL1);/*    if(!QualifyDocURL(strURL)){        return FALSE; // error message already output    }*/    switch (wxGetApp().GetSettings().m_eUseCustomBrowser)    {    case ecInternal:        rc = ShowInternalHtmlHelp(strURL);        break;    case ecAssociatedExternal:        {            rc = ShowExternalHtmlHelp(strURL);        }        break;    case ecCustomExternal:        QualifyDocURL(strURL, FALSE);        wxGetApp().Launch(strURL, wxGetApp().GetSettings().m_strBrowser);        break;    default:        wxASSERT(FALSE);    }    return rc;}bool ecConfigToolDoc::ShowExternalHtmlHelp (const wxString& strURL){#if defined(__WXMSW__) || defined(__WXGTK__)    wxString url;    wxString sep(wxFILE_SEP_PATH);    wxString docDir(wxString(m_strRepository) + sep + wxString(wxT("doc")));    if (wxDirExists(docDir + sep + wxT("html")))        docDir += sep + wxT("html") ;    if (strURL.Left(7) == wxT("http://") || strURL.Left(7) == wxT("file://"))        url = strURL;    else    {	if (wxIsAbsolutePath(strURL))	    url = strURL;	else            url = docDir + sep + strURL;    }    wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("html"));    if ( !ft )    {        wxLogError(_T("Impossible to determine the file type for extension html"));        return FALSE;    }    wxString cmd;    bool ok = ft->GetOpenCommand(&cmd,                                 wxFileType::MessageParameters(url, _T("")));    delete ft;    if (!ok)    {        // TODO: some kind of configuration dialog here.        wxMessageBox(_("Could not determine the command for running the browser."),		   wxGetApp().GetSettings().GetAppName(), wxOK|wxICON_EXCLAMATION);        return FALSE;    }    // Remove spurious file:// if added#ifdef __WXMSW__    if (strURL.Left(7) == wxT("http://"))        cmd.Replace(wxT("file://"), wxT(""));#endif    ok = (wxExecute(cmd, FALSE) != 0);    return ok;    // Old code using MS HTML Help#elif 0    HWND hwndCaller = ::GetDesktopWindow();    wxString helpFile(wxGetApp().GetHelpFile());    bool rc = FALSE;    const ecFileName strFile(HTMLHelpLinkFileName());    if (wxFileExists(strFile))        wxRemoveFile(strFile);    wxTextFile f(strFile);    if(!ecFileName(helpFile).Exists())    {        wxString msg;        msg.Printf(_("Cannot display help - %s does not exist"), (const wxChar*) helpFile);        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    } else if (!f.Create())    {        wxString msg;        msg.Printf(_("Cannot display help - error creating %s"), (const wxChar*) strFile);        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    } else    {        wxString str;        str.Printf(_T("<meta HTTP-EQUIV=\"refresh\" CONTENT=\"0;URL=%s\">"), (const wxChar*) strURL);        f.AddLine(str);        f.Write();        f.Close();        if(0==HtmlHelp(hwndCaller, wxGetApp().GetHelpFile(), HH_DISPLAY_TOPIC, 0))        {            wxString msg;            msg.Printf(_("Cannot display %s"), (const wxChar*) strURL);            wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);        }#if 0        else        {            // JACS: I don't think we need to do this. Even on the MFC version, the notification            // callback didn't do anything interesting.#define ID_HHNOTIFICATION               55017            // FIXME: Do this the first time only?            HH_WINTYPE WinType;            HWND wnd;            HH_WINTYPE *pWinType=NULL;            wxString s = wxGetApp().GetHelpFile() + wxT(">mainwin");            wnd = HtmlHelp(hwndCaller, s, HH_GET_WIN_TYPE, (DWORD) &pWinType);            WinType=*pWinType;            WinType.hwndCaller=hwndCaller;            WinType.fsWinProperties|=HHWIN_PROP_TRACKING;            WinType.idNotify = ID_HHNOTIFICATION;            wnd = HtmlHelp(hwndCaller, wxGetApp().GetHelpFile(), HH_SET_WIN_TYPE, (DWORD) &WinType);            rc = TRUE;        }#endif        //wxRemoveFile(strFile);    }    return rc;#else    wxMessageBox(_("Sorry, ShowHtmlHelp not yet implemented"), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    return FALSE;#endif}bool ecConfigToolDoc::ShowInternalHtmlHelp (const wxString& strURL){#if defined(__WXMSW__) || defined(__WXGTK__)    wxString url(strURL);    wxString sep(wxFILE_SEP_PATH);    wxString docDir(wxString(m_strRepository) + sep + wxString(wxT("doc")));    if (wxDirExists(docDir + sep + wxT("html")))        docDir += sep + wxT("html") ;    url = docDir + sep + ecHtmlIndexer::Redirect(docDir, url);#if 0    if (strURL.Left(7) == wxT("http://") || strURL.Left(7) == wxT("file://"))        url = strURL;    else        url = docDir + sep + strURL;#endif    //url = url.Mid(docDir.Length() + 1);    if (wxGetApp().HasHelpController())    {        return wxGetApp().GetHelpController().Display(url);    }

⌨️ 快捷键说明

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