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

📄 configtooldoc.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    else        return FALSE;    // 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);        }    }    return rc;#else    wxMessageBox(_("Sorry, ShowHtmlHelp not yet implemented"), wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);    return FALSE;#endif}const wxString ecConfigToolDoc::HTMLHelpLinkFileName(){    return ecFileName(wxGetApp().GetHelpFile()).Head() + wxT("link2.htm");}bool ecConfigToolDoc::QualifyDocURL(wxString &strURL, bool prefix){    if(-1==strURL.Find(wxT("://")))    {#ifdef __WXMSW__        strURL.Replace(wxT("/"), wxT("\\"));#endif        wxString originalURL(strURL);        if (! ecFileName (strURL).IsFile ())        { // if not an absolute filepath            strURL = GetDocBase () + ecFileName (originalURL); // prepend the doc directory path        }        if (!wxFileExists(strURL))            strURL = GetDocBase() + ecFileName(wxT("html")) + ecFileName(originalURL);        if (prefix)            strURL = wxT("file://") + strURL;    }    if(0==strURL.Find(wxT("file://")))    {        ecFileName strFile(strURL.Right(strURL.Length()-7));        int nIndex=strFile.Find(wxT('#'), TRUE);        if ( -1 != nIndex )        {            strFile=strFile.Left(nIndex);        }#ifdef __WXMSW__        strFile.Replace(wxT("/"), wxT("\\"));#endif        if(!strFile.Exists())        {            wxString msg;            msg.Printf(_("Cannot locate the file %s"), (const wxChar*) strFile);            wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxID_OK);            return FALSE;        }    }    return TRUE;}wxString ecConfigToolDoc::GetPackageName (const wxString & strAlias){    const std::vector<std::string> & packages = m_CdlPkgData->get_packages ();    std::vector<std::string>::const_iterator package_i;    for (package_i = packages.begin (); package_i != packages.end (); package_i++)    {        const std::vector<std::string> & aliases = m_CdlPkgData->get_package_aliases (* package_i);        wxString strPackageAlias = aliases [0].c_str ();        if (aliases.size () && (strAlias == strPackageAlias))            return package_i->c_str ();    }    return wxEmptyString;}const wxString ecConfigToolDoc::GetCurrentTargetPrefix(){    ecConfigItem *pItem = Find(wxT("CYGBLD_GLOBAL_COMMAND_PREFIX"));    if (pItem)        return pItem->StringValue();    else        return wxT("");}ecConfigToolDoc::GlobalConflictOutcome ecConfigToolDoc::ResolveGlobalConflicts(wxList *parConflictsOfInterest){    m_ConflictsOutcome=NotDone;    m_arConflictsOfInterest.Clear();    if(parConflictsOfInterest)    {        wxNode* node = parConflictsOfInterest->First();        while (node)        {            wxObject* obj = (wxObject*) node->Data();            m_arConflictsOfInterest.Append(obj);            node = node->Next();        }    }    CdlInferenceCallback fn=CdlTransactionBody::get_inference_callback_fn();    CdlTransactionBody::set_inference_callback_fn(CdlGlobalInferenceHandler);    GetCdlInterpreter()->get_toplevel()->resolve_all_conflicts();    CdlTransactionBody::set_inference_callback_fn(fn);    if(NotDone==m_ConflictsOutcome){        // No solutions were available, but we'll run the dialog anyway        const std::list<CdlConflict>& conflicts=GetCdlConfig()->get_all_conflicts();        ecResolveConflictsDialog dlg(wxGetApp().GetTopWindow(), conflicts, NULL, &m_arConflictsOfInterest);        m_ConflictsOutcome = (wxID_OK == dlg.ShowModal())?OK:Cancel;    }    return m_ConflictsOutcome;}bool ecConfigToolDoc::CheckConflictsBeforeSave(){    if (GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size()>0)    {        if(ecSettings::Deferred & wxGetApp().GetSettings().m_nRuleChecking)        {            if ((ecSettings::SuggestFixes & wxGetApp().GetSettings().m_nRuleChecking) &&                (Cancel==ResolveGlobalConflicts()))            {                return FALSE;            }            int nConflicts = GetCdlInterpreter()->get_toplevel()->get_all_conflicts().size();            switch (nConflicts)            {            case 0:                break;            case 1:                {                    wxString msg;                    msg.Printf(_("There is 1 unresolved conflict. Save anyway?"));                    if (wxNO == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxYES_NO))                    {                        return FALSE;                    }                }            default:                {                    wxString msg;                    msg.Printf(_("There are %d unresolved conflicts. Save anyway?"), nConflicts);                    if (wxNO == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxYES_NO))                    {                        return FALSE;                    }                }            }        }    }    return TRUE;}void ecConfigToolDoc::UpdateFailingRuleCount(){    int nCount=0;    if (GetCdlConfig ())    {        // if configuration information        // calculate the number of conflicts        nCount = GetCdlConfig ()->get_all_conflicts ().size ();            //	        GetCdlConfig ()->get_structural_conflicts ().size () +    ignore for now        // update the conflicts view        if (wxGetApp().GetMainFrame() && wxGetApp().GetMainFrame()->GetConflictsWindow())        {            wxGetApp().GetMainFrame()->GetConflictsWindow()->FillRules ();        }    }    if (wxGetApp().GetMainFrame())    {        wxGetApp().GetMainFrame()->SetFailRulePane(nCount);    }}void ecConfigToolDoc::LogConflicts (const std::list<CdlConflict> & conflicts){    std::list<CdlConflict>::const_iterator conf_i;    for (conf_i = conflicts.begin (); conf_i != conflicts.end (); conf_i++) // for each conflict    {        wxString strExplain = (* conf_i)->get_explanation ().c_str (); // get the conflict explanation        wxGetApp().Log (ecUtils::StripExtraWhitespace (strExplain)); // display the message in the output window    }}bool ecConfigToolDoc::SetValue (ecConfigItem &ti, double dValue, CdlTransaction transaction/*=NULL*/){    wxASSERT (ti.GetOptionType () == ecDouble);    // test if the new double value is in range    const CdlValuable valuable = ti.GetCdlValuable();    CdlListValue list_value;    CdlEvalContext context (NULL, ti.GetCdlItem (), ti.GetCdlItem ()->get_property (CdlPropertyId_LegalValues));    valuable->get_legal_values ()->eval (context, list_value);    if (! list_value.is_member (dValue))    {        if ( dValue == valuable->get_double_value(CdlValueSource_Current) )            return FALSE;        wxString msg;        msg.Printf(_("%s is not a legal value for %s.\n\nDo you want to use this value anyway?"),            (const wxChar*) ecUtils::DoubleToStr (dValue), (const wxChar*) ti.GetMacro ());        if (wxNO == wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO))            return FALSE;    }    if (! ti.SetValue (dValue,transaction))        return FALSE;    Modify(TRUE);    wxGetApp().GetMainFrame()->UpdateFrameTitle();    // NB UpdateAllViews isn't in the MFC Configtool for double (though it is for the    // other types of value). In theory this should lead to a display inconsistency in the MFC tool.    ecConfigToolHint hint(& ti, ecValueChanged);    UpdateAllViews (NULL, & hint);    return TRUE;}bool ecConfigToolDoc::SetValue(ecConfigItem &ti, const wxString &strValue, CdlTransaction transaction/*=NULL*/){    // TODO#if 0    // warn the user if a modified memory layout is about to be discarded    if (MemoryMap.map_modified () && (ti.Macro () == _T("CYG_HAL_STARTUP")) &&        (IDCANCEL == CUtils::MessageBoxFT (MB_OKCANCEL, _T("Changes to the current memory layout will be lost."))))        return false;#endif    bool rc = FALSE;    switch(ti.GetOptionType())    {    case ecOptionTypeNone:        break;    case ecEnumerated:    case ecString:        rc = ti.SetValue(strValue, transaction);        break;    case ecLong:        {            long n;            rc = ecUtils::StrToItemIntegerType(strValue,n) && SetValue(ti,n,transaction);        }        break;    case ecDouble:        {            double dValue;            rc = ecUtils::StrToDouble (strValue, dValue) && SetValue (ti, dValue,transaction);        }        break;    default:        wxASSERT(FALSE);        break;    }    if(rc){        Modify(TRUE);        wxGetApp().GetMainFrame()->UpdateFrameTitle();        ecConfigToolHint hint(& ti, ecValueChanged);        UpdateAllViews (NULL, & hint);    }    return rc;}bool ecConfigToolDoc::SetValue(ecConfigItem &ti, long nValue, CdlTransaction transaction/*=NULL*/){    switch(ti.GetOptionType())    {    case ecEnumerated:    case ecLong:        break;    case ecOptionTypeNone:    case ecString:    default:        wxASSERT(FALSE);        break;    }    bool rc = FALSE;    // TODO#if 0    bool bChangingMemmap = MemoryMap.map_modified () && ((ti.Macro ().Compare (_T ("CYG_HAL_STARTUP")) == 0));#endif    if(nValue==ti.Value())    {        return TRUE;    }    // test if the new integer value is in range    if (ecLong == ti.GetOptionType ())    {        const CdlValuable valuable = ti.GetCdlValuable();        CdlListValue list_value;        CdlEvalContext context (NULL, ti.GetCdlItem (), ti.GetCdlItem ()->get_property (CdlPropertyId_LegalValues));        valuable->get_legal_values ()->eval (context, list_value);        if (! list_value.is_member ((cdl_int) nValue))        {            if (nValue == (long) valuable->get_integer_value (CdlValueSource_Current))                goto Exit;            wxString msg;            msg.Printf(_("%s is not a legal value for %s.\n\nDo you want to use this value anyway?"),                (const wxChar*) ecUtils::IntToStr (nValue, wxGetApp().GetSettings().m_bHex), (const wxChar*) ti.GetMacro ());            if (wxNO == wxMessageBox (msg, wxGetApp().GetSettings().GetAppName(), wxICON_QUESTION|wxYES_NO))                goto Exit;        };    }    // TODO#if 0    // warn the user if the current memory layout has been changed and will be lost    // this will happen when the layout has been modified and the target-platform-startup is changed    if (bChangingMemmap && IDCANCEL==CUtils::MessageBoxFT(MB_OKCANCEL,_T("Changes to the current memory layout will be lost."))){        goto Exit;    }#endif    // Save state    if(!ti.SetValue(nValue,transaction)){        // CanSetValue above should have caught this        wxString msg;        msg.Printf(_("Cannot set '%s' to %d"), (const wxChar*) ti.GetItemNameOrMacro(), nValue);        wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);        goto Exit;    }    rc = TRUE;Exit:    if(rc)    {        Modify(TRUE);        wxGetApp().GetMainFrame()->UpdateFrameTitle();        UpdateFailingRuleCount ();        ecConfig

⌨️ 快捷键说明

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