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

📄 packagesdlg.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        Fill();        wxStartTimer();    }}void ecPackagesDialog::Insert(const wxString& str, bool added, const wxString& descr, const wxString& version){    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );        m_items.Add(str);    m_descriptions.Add(str);    m_currentVersions.Add(version);    m_arnItems.Add(added);        if (added)        m_added.Add(str);        //(added ? useList : availableList) -> Append(str);}bool ecPackagesDialog::IsAdded(const wxString& str){    return (m_added.Index(str) != wxNOT_FOUND);        //	return (((wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST ))->FindString(str) > -1) ;}static int ecPositionInStringList(const wxStringList& list, const wxString& item){    int i;    for (i = 0 ; i < list.Number(); i++)        if (list[i] == item)            return i;        else            i ++;        return -1;}void ecPackagesDialog::DisplayDescription(const wxString& item){    //wxTextCtrl* descrCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION ) ;    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();        //    int pos = ecPositionInStringList(m_items, item);    //    if (pos > -1)    {        wxString text;        //        wxString descr = m_descriptions[pos];        //        text += descr;        //        text += wxT("\n");                wxString macroName(pDoc->GetPackageName (item));                // Match all aliases        const std::vector<std::string> & aliases = pDoc->GetCdlPkgData ()->get_package_aliases (ecUtils::UnicodeToStdStr (macroName));                size_t j;        for (j = 0; j < aliases.size(); j ++)        {            if (j == 1)                text += wxT(".\nAliases: ");            else if (j > 1)                text += wxT(", ");                        wxString alias(aliases[j].c_str());            text += alias;        }        text += wxT("\nMacro: ");        text += macroName;        text += wxT("\n\n");                wxString descr = pDoc->GetCdlPkgData ()->get_package_description (ecUtils::UnicodeToStdStr (macroName)).c_str ();                text += ecUtils::StripExtraWhitespace (descr);                m_packageDescription = text;                //descrCtrl->SetValue(text);    }}void ecPackagesDialog::ClearDescription(){    wxTextCtrl* descrCtrl = (wxTextCtrl*) FindWindow( ecID_PACKAGES_DIALOG_DESCRIPTION ) ;    descrCtrl->SetValue(wxEmptyString);}wxString ecPackagesDialog::GetVersion (const wxString& item){    int nCount;    for (nCount = GetCount() - 1; nCount >= 0; --nCount)    {        if (m_items [nCount] == item)        {            return m_currentVersions [nCount];        }    }    wxASSERT (FALSE);    return wxEmptyString;}void ecPackagesDialog::UpdateHardwareSelectionFlag(){    m_bHardwarePackageSelected = FALSE;        wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );    wxListBox * pListBox = NULL;        wxArrayInt selections1, selections2;    wxArrayInt* selections = NULL;    availableList->GetSelections(selections1);    useList->GetSelections(selections2);        int nListSelCount = selections1.GetCount ();    if (nListSelCount)    {        pListBox = availableList;        selections = & selections1;    }    else    {        nListSelCount = selections2.GetCount ();        if (nListSelCount)        {            pListBox = useList;            selections = & selections2;        }    }        if (pListBox) // if there are packages selected    {        ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();                // retrieve the list box indices of the selected packages                //int * arnIndices = new int [nListSelCount];        //pListBox->GetSelItems (nListSelCount, arnIndices);                int nIndex;        for (nIndex = 0; nIndex < nListSelCount; nIndex++) // for each selected package        {            wxString strPackageAlias = pListBox->GetString((*selections)[nIndex]);                        // check if the package is a hardware package                        //TRACE (_T("Checking '%s' for hardware status\n"), strPackageAlias);            if (pDoc->GetCdlPkgData ()->is_hardware_package (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias))))            {                m_bHardwarePackageSelected = TRUE;                break;            }        }    }}void ecPackagesDialog::HardwarePackageMessageBox(){    // TODO: could give the user the choice of going to the template dialog.    wxMessageBox (wxT("Add and remove hardware packages by selecting a new hardware template."),        wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK, this);}void ecPackagesDialog::UpdatePackageDescription (){    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();        wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );        wxListBox * pListBox = NULL;        wxArrayInt selections1, selections2;    wxArrayInt* selections = NULL;    availableList->GetSelections(selections1);    useList->GetSelections(selections2);        if (1 == selections1.GetCount ())    {        pListBox = availableList;        selections = & selections1;    }    else if (1 == selections2.GetCount ())    {        pListBox = useList;        selections = & selections2;    }        if (pListBox && selections)    {        int nIndex = (*selections)[0];        wxString strPackageAlias = pListBox->GetString(nIndex);                DisplayDescription(strPackageAlias);        //m_packageDescription = pDoc->GetCdlPkgData ()->get_package_description (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias))).c_str ();        //m_packageDescription = ecUtils::StripExtraWhitespace (m_packageDescription);    }    else    {        m_packageDescription = wxEmptyString;    }    TransferDataToWindow ();}void ecPackagesDialog::UpdateVersionList (){    ecConfigToolDoc * pDoc = wxGetApp().GetConfigToolDoc ();        wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );    wxChoice* versionChoice = (wxChoice*) FindWindow( ecID_PACKAGES_DIALOG_VERSION );        versionChoice->Clear(); // clear the version combo box        wxArrayInt selections1, selections2;    wxArrayInt* selections = NULL;    availableList->GetSelections(selections1);    useList->GetSelections(selections2);    wxListBox* pListBox = NULL;        if (selections1.GetCount () > 0)    {        pListBox = availableList;        selections = & selections1;    }    else if (selections2.GetCount () > 0)    {        pListBox = useList;        selections = & selections2;    }        if (pListBox) // if there are packages selected    {        std::list<std::string> common_versions;        bool bCommonSelectedVersion = true;        int nCommonVersionIndex=-1;        int nListSelCount = selections->GetCount();                // retrieve the list box indices of the selected packages                //int * arnIndices = new int [nListSelCount];        //pListBox->GetSelItems (nListSelCount, arnIndices);        int nIndex;        for (nIndex = 0; nIndex < nListSelCount; nIndex++) // for each selected package        {            // retrieve the first package alias            wxString strPackageAlias = pListBox->GetString ((*selections)[nIndex]);                        // retrieve the dialog item array index for use in            // comparing current version strings            const int nVersionIndex = (int) pListBox->GetClientData ((*selections)[nIndex]);                        // retrieve the installed version array                        //TRACE (_T("Retrieving versions for '%s'\n"), strPackageAlias);            const std::vector<std::string>& versions = pDoc->GetCdlPkgData ()->get_package_versions (ecUtils::UnicodeToStdStr (pDoc->GetPackageName (strPackageAlias)));                        if (0 == nIndex) // if this is the first selected package            {                // use the version array to initialise a linked list of version                // strings held in common between the selected packages                unsigned int uCount;                for (uCount = 0; uCount < versions.size (); uCount++)                {                    //TRACE (_T("Adding common version '%s'\n"), wxString (versions [uCount].c_str ()));                    common_versions.push_back (versions [uCount]);                }                nCommonVersionIndex = nVersionIndex; // save the item array index            }            else // this is not the first selected package            {                std::list<std::string>::iterator i_common_versions = common_versions.begin ();                while (i_common_versions != common_versions.end ()) // iterate through the common versions                {                    if (versions.end () == std::find (versions.begin (), versions.end (), * i_common_versions)) // if the common version is not in the versions list                    {                        //TRACE (_T("Removing common version '%s'\n"), CString (i_common_versions->c_str ()));                        common_versions.erase (i_common_versions++); // remove the version from the common versions list                    }                    else                    {                        i_common_versions++;                    }                }                if (bCommonSelectedVersion) // if the selected versions of all preceding packages are identical                {                    // check if the selected version of this package matches that of the preceding ones                    bCommonSelectedVersion = (m_currentVersions [nVersionIndex] == m_currentVersions [nCommonVersionIndex]);                }            }        }                // add the common versions to the version combo box                std::list<std::string>::iterator i_common_versions;        for (i_common_versions = common_versions.begin (); i_common_versions != common_versions.end (); i_common_versions++)        {            //TRACE (_T("Adding version '%s'\n"), CString (i_common_versions->c_str ()));            versionChoice->Append(wxString (i_common_versions->c_str ()));        }                // select the common current version (if any) in the version combo box                if (bCommonSelectedVersion)        {            //TRACE (_T("Selecting version '%s'\n"), m_arstrVersions [nCommonVersionIndex]);            versionChoice->SetStringSelection (m_currentVersions [nCommonVersionIndex]);        }                // enable the version combo box only if there are multiple common versions                versionChoice->Enable (common_versions.size () > 1);    }    else // there are no packages selected    {        versionChoice->Enable (FALSE); // disable the version combo box    }}void ecPackagesDialog::UpdateAddRemoveButtons(){    wxListBox* availableList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_AVAILABLE_LIST );    wxListBox* useList = (wxListBox*) FindWindow( ecID_PACKAGES_DIALOG_USE_LIST );        wxArrayInt selections1, selections2;    availableList->GetSelections(selections1);    useList->GetSelections(selections2);        FindWindow( ecID_PACKAGES_DIALOG_ADD )->Enable( selections1.GetCount() > 0 );    FindWindow( ecID_PACKAGES_DIALOG_REMOVE )->Enable( selections2.GetCount() > 0 );}void ecPackagesDialog::ClearSelections(wxListBox& lbox){    int i;    for (i = 0; i < lbox.Number(); i++)    {        lbox.Deselect(i);    }}void ecPackagesTimer::Notify(){    static bool s_inNotify = FALSE;        if (s_inNotify)        return;        s_inNotify = TRUE;        // On Windows, simply having the timer going will ping the message queue    // and cause idle processing to happen.    // On Unix, this doesn't happen so we have to do the processing explicitly.#ifdef __WXMSW__    // Nothing to do#else    if ( m_dialog )    {        wxIdleEvent event;        m_dialog->OnIdle(event);    }#endif        s_inNotify = FALSE;}

⌨️ 快捷键说明

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