Example #1
0
int ecConfigItem::EvalEnumStrings (wxArrayString &arEnumStrings) const
{
    const CdlValuable valuable = GetCdlValuable();
    wxASSERT (valuable);
    /*
    if (m_Type == Boolean)
    {
    arEnumStrings.SetSize (2);
    arEnumStrings.SetAt (0, wxT("True"));
    arEnumStrings.SetAt (1, wxT("False"));
    }
    else
    */
    {
        wxASSERT (m_optionType == ecEnumerated);
        CdlListValue list_value;
        CdlEvalContext context (NULL, m_CdlItem, m_CdlItem->get_property (CdlPropertyId_LegalValues));
        valuable->get_legal_values ()->eval (context, list_value);
        const std::vector<CdlSimpleValue> & table = list_value.get_table ();
        
        // add legal values to the list
        for (unsigned int nValue = 0; nValue < table.size (); nValue++)
        {
            arEnumStrings.Add (table [nValue].get_value ().c_str ());
        }
    }
    return arEnumStrings.GetCount();
}
Example #2
0
// Convert from Cdl to internal representation
bool ecConfigItem::ConvertFromCdl()
{
    if (!GetCdlItem())
        return FALSE;

    m_name = GetCdlItem()->get_display ().c_str ();
    m_macro = GetCdlItem()->get_name().c_str();
    m_strDescr = ecUtils::StripExtraWhitespace (wxString (GetCdlItem()->get_description ().c_str ()));


    // FIXME: re-implement using CdlValuableBody::get_widget_hint()
    // (comment from original MFC configtool)

    if (IsPackage())
    {
        // If a package item, display the package version string
        m_optionType = ecString; 
        m_configType = ecPackage;
        m_optionFlavor = ecFlavorNone;
    }
    else
    {
        const CdlValuable valuable = dynamic_cast<CdlValuable> (GetCdlItem());
        switch (valuable->get_flavor ()){
        case CdlValueFlavor_None:
            m_optionFlavor = ecFlavorNone;
            m_optionType=ecOptionTypeNone; //??? Shouldn't it be ecBool for CdlValueFlavor_Bool?
            m_configType = ecContainer;
            break;
        case CdlValueFlavor_Bool:
            m_optionFlavor = ecFlavorBool;
            m_optionType=ecOptionTypeNone; //??? Shouldn't it be ecBool for CdlValueFlavor_Bool?
            m_configType = ecOption;
            m_hint = (HasRadio() ? ecHintRadio : ecHintCheck);
            break;
        case CdlValueFlavor_Data:
        case CdlValueFlavor_BoolData:

            m_optionFlavor = (valuable->get_flavor() == CdlValueFlavor_Data ? ecFlavorData : ecFlavorBoolData);
            m_configType = ecOption;
            m_hint = (HasRadio() ? ecHintRadio : ecHintCheck);

            if (! valuable->has_legal_values ()) {
                m_optionType=ecString;
            } else if (0 == valuable->get_legal_values ()->ranges.size ()) {
                m_optionType=ecEnumerated;
            } else {
                CdlListValue list_value;
                CdlEvalContext context (NULL, valuable, valuable->get_property (CdlPropertyId_LegalValues));
                valuable->get_legal_values ()->eval (context, list_value);
                m_optionType=list_value.get_double_ranges ().size () ? ecDouble : ecLong;
            }
            break;
        default:
            wxASSERT (0); // specified flavor not supported
            break;
        }
    }  

    m_active = IsActive();
    m_enabled = IsEnabled();
    m_modifiable = IsModifiable();

    return TRUE;
}