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

📄 configitem.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    return wxT("ref/ecos-ref.html"); // the default URL}bool ecConfigItem::SetValue(const wxString& value, CdlTransaction transaction/*=NULL*/){    wxASSERT ((m_optionType == ecString) || (m_optionType == ecEnumerated));    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);    const std::string str = value.c_str();    if(transaction){        if (CdlValueFlavor_BoolData == valuable->get_flavor ()){            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (transaction, valuable->is_enabled (), str, CdlValueSource_User);        } else {// CdlValueFlavor_Data            valuable->set_value (transaction, str, CdlValueSource_User);        }    } else {        if (CdlValueFlavor_BoolData == valuable->get_flavor ()){            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (valuable->is_enabled (), str, CdlValueSource_User);        } else {// CdlValueFlavor_Data            valuable->set_value (str, CdlValueSource_User);        }    }    // TODO: eliminate m_value, since the value is always taken from the Cdl object.    m_value = value;        return TRUE;}bool ecConfigItem::SetValue (double dValue, CdlTransaction transaction/*=NULL*/){    wxASSERT (m_optionType == ecDouble);    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);        if(transaction) {        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (transaction, valuable->is_enabled (), dValue, CdlValueSource_User);        } else {// CdlValueFlavor_Data            valuable->set_double_value (transaction, dValue, CdlValueSource_User);        }    } else {        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (valuable->is_enabled (), dValue, CdlValueSource_User);        } else {// CdlValueFlavor_Data            valuable->set_double_value (dValue, CdlValueSource_User);        }    }    // TODO: BoolData?    m_value = dValue;        return TRUE;}bool ecConfigItem::SetValue (long nValue, CdlTransaction transaction/*=NULL*/){    wxASSERT (m_optionType == ecLong);    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);        if(transaction) {        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (transaction, valuable->is_enabled (), (cdl_int) nValue, CdlValueSource_User);        } else { // CdlValueFlavor_Data            valuable->set_integer_value (transaction, nValue, CdlValueSource_User);        }    } else {        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {            // set the user bool to the current bool when changing a booldata            // value to avoid a possible change in the current bool            valuable->set_enabled_and_value (valuable->is_enabled (), (cdl_int) nValue, CdlValueSource_User);        } else { // CdlValueFlavor_Data            valuable->set_integer_value (nValue, CdlValueSource_User);        }    }    // TODO: BoolData?    m_value = nValue;        return TRUE;}bool ecConfigItem::HasRadio() const{    const CdlValuable valuable = GetCdlValuable();    if (! valuable)        return FALSE;        CdlWidgetHint hint;    valuable->get_widget_hint (hint);    return (CdlBoolWidget_Radio == hint.bool_widget);}ecConfigItem *ecConfigItem::FirstRadio() const{    wxASSERT(HasRadio ());        for(ecConfigItem *h=GetParent()->FirstChild();h;h=h->NextSibling()){        if(h->HasRadio ()){            return h;        }    }    // No radio buttons found    wxASSERT(FALSE);    return FALSE;}ecConfigItem *ecConfigItem::FirstChild() const{     ecConfigTreeCtrl* treeCtrl = wxGetApp().GetTreeCtrl();    long cookie;    wxTreeItemId hChild=treeCtrl->GetFirstChild(GetTreeItem(), cookie);    if (hChild)    {        ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(hChild);        wxASSERT(data);        return data->GetConfigItem();    }    else        return NULL;}ecConfigItem *ecConfigItem::NextSibling() const{     ecConfigTreeCtrl* treeCtrl = wxGetApp().GetTreeCtrl();    wxTreeItemId hChild=treeCtrl->GetNextSibling(GetTreeItem());    if (hChild)    {        ecTreeItemData* data = (ecTreeItemData*) wxGetApp().GetTreeCtrl()->GetItemData(hChild);        wxASSERT(data);        return data->GetConfigItem();    }    else        return NULL;}bool ecConfigItem::IsEnabled() const{    const CdlValuable valuable = GetCdlValuable();    return NULL==valuable ||valuable->is_enabled();}bool ecConfigItem::IsActive() const{//    return GetCdlItem()->is_active();    const CdlValuable valuable = GetCdlValuable();    if (valuable && ((GetOptionType() != ecOptionTypeNone) || HasBool()))    {        return (valuable->is_modifiable () && valuable->is_active ());    }    else        return GetCdlItem()->is_active();}bool ecConfigItem::HasModifiedChildren() const{    for(ecConfigItem *pItem=FirstChild();pItem;pItem=pItem->NextSibling()){        if(pItem->Modified()||pItem->HasModifiedChildren()){            return TRUE;        }    }    return FALSE;}bool ecConfigItem::Modified () const{    const CdlValuable valuable = GetCdlValuable();    return         valuable        // accommodate the root config item which has no CDL item        && !IsPackage() // packages are never modified        && valuable->get_source () != CdlValueSource_Default;}void ecConfigItem::DumpItem(){    //TRACE(wxT("Item %08x\n\tDisplay Name='%s'\n\tMacro Name='%s'\n\tType=%s"), this,	Name(),           Macro(),    TreeItemTypeImage[m_Type]);    //TRACE(wxT("\n\tValue=%s\n\tURL=%s\n\tParent=%08x"),StringValue(), GetURL(), Parent());        //TRACE(wxT("\n"));}ecConfigItem * ecConfigItem::NextRadio() const{    wxASSERT(this->HasRadio ());    for(ecConfigItem *pItem=NextSibling();pItem;pItem=pItem->NextSibling()){        if(pItem->HasRadio()){            return pItem;        }    }    return NULL;}bool ecConfigItem::IsDescendantOf(ecConfigItem * pAncestor){    for(ecConfigItem *pItem=GetParent();pItem;pItem=pItem->GetParent()){        if(pItem==pAncestor){            return TRUE;        }    }    return FALSE;}bool ecConfigItem::ViewHeader(){    bool rc=FALSE;    const ecFileName strFile(GetFilename());    if(!strFile.IsEmpty())    {        ecConfigToolDoc *pDoc=wxGetApp().GetConfigToolDoc();        if(pDoc->GetBuildTree().IsEmpty()){            wxString msg;            msg.Printf(wxT("Cannot display header file until configuration is saved"));            wxMessageBox(msg);        } else        {            rc=wxGetApp().Launch(strFile, wxGetApp().GetSettings().m_strViewer);        }    }    return rc;}bool ecConfigItem::ViewURL(){    return wxGetApp().GetConfigToolDoc()->ShowURL(GetURL());}bool ecConfigItem::HasBool() const{    if (!m_CdlItem) {        return FALSE;    } else if (IsPackage()) {        return FALSE;    } else {        const CdlValuable valuable = GetCdlValuable();        CdlValueFlavor flavor = valuable->get_flavor ();        return (flavor == CdlValueFlavor_Bool) || (flavor == CdlValueFlavor_BoolData);    }}bool ecConfigItem::SetEnabled(bool bEnabled, CdlTransaction current_transaction/*=NULL*/){    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);        // use a transaction object to ensure that all config items are changed together    CdlTransaction transaction = current_transaction ? current_transaction : CdlTransactionBody::make (wxGetApp().GetConfigToolDoc ()->GetCdlConfig ());        if (HasRadio () && bEnabled) { // if a new radio button has been selected        for (ecConfigItem *pItem = FirstRadio(); pItem; pItem = pItem->NextRadio ()) { // for each radio button in the group            if (pItem != this) { // if not the newly selected radio button                pItem->SetEnabled (FALSE, transaction); // disable the radio button            }        }    }        if (CdlValueFlavor_BoolData == valuable->get_flavor ()) {        // set the user value to the current data value when enabling/disabling        // a booldata item to avoid a possible change in the current data value        CdlSimpleValue simple_value = valuable->get_simple_value ();        valuable->set_enabled_and_value (transaction, bEnabled, simple_value, CdlValueSource_User);    } else { // CdlValueFlavor_Bool        valuable->set_enabled (transaction, bEnabled, CdlValueSource_User);    }        if (! current_transaction) { // if not a recursive call to disable a radio button        transaction->body (); // commit the transaction        delete transaction;        transaction = NULL;    }        return TRUE;}long ecConfigItem::DefaultValue () const{    return (long) atoi (StringValue (CdlValueSource_Default)) ;}long ecConfigItem::Value () const{    wxASSERT (!IsPackage()); // not a package item    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);    long nValue (0);        switch (valuable->get_flavor ())    {        //	case CdlValueFlavor_Bool:        //		nValue = valuable->is_enabled (CdlValueSource_Current) ? 1 : 0;        //		break;            case CdlValueFlavor_BoolData:    case CdlValueFlavor_Data:        nValue = (long) valuable->get_integer_value (CdlValueSource_Current);        break;            default:        wxASSERT (0); // specified flavor not supported    }        return nValue;}const double ecConfigItem::DoubleValue (CdlValueSource source /* = CdlValueSource_Current */ ) const{    wxASSERT (!IsPackage()); // not a package item    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);    wxASSERT (valuable->has_double_value (source));    return valuable->get_double_value (source);}const wxString ecConfigItem::StringValue (CdlValueSource source /* = CdlValueSource_Current */ ) const{    //	wxASSERT (!IsPackage()); // not a package item    const CdlValuable valuable = GetCdlValuable();    wxASSERT (valuable);    wxString strValue (wxT(""));        switch (valuable->get_flavor ())    {    case CdlValueFlavor_Data:    case CdlValueFlavor_BoolData:    case CdlValueFlavor_None: // a package        if (m_optionType == ecLong)            strValue = ecUtils::IntToStr (Value (), wxGetApp().GetSettings().m_bHex);        else if (m_optionType == ecDouble)            strValue = ecUtils::DoubleToStr (DoubleValue ());        else            strValue = valuable->get_value (source).c_str ();        break;            default:        wxASSERT (0); // specified flavor not supported    }        return strValue;}const wxString ecConfigItem::StringValue(ecWhereType where) const{    wxString str;    switch(where){    case ecInName:        str=GetName();        break;    case ecInMacro:        str=GetMacro();        break;    case ecInDesc:        str=GetDescription();        break;    case ecInCurrentValue:        if (ecOptionTypeNone==GetOptionType())	    str = wxEmptyString;        else            str = StringValue(CdlValueSource_Current);        break;    case ecInDefaultValue:        if (ecOptionTypeNone==GetOptionType())	    str = wxEmptyString;        else            str = StringValue(CdlValueSource_Default);        break;

⌨️ 快捷键说明

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