Ejemplo n.º 1
0
xpr_bool_t Filter::load(fxfile::base::ConfFileEx &aConfFile)
{
    xpr_size_t         i;
    xpr_tchar_t        sKey[0xff];
    const xpr_tchar_t *sValue;
    FilterItem        *sFilterItem;
    ConfFile::Section *sSection;

    sSection = aConfFile.findSection(kFilterSection);
    if (XPR_IS_NULL(sSection))
        return XPR_FALSE;

    for (i = 0; i < MAX_FILTER; ++i)
    {
        _stprintf(sKey, kNameKey, i + 1);

        sValue = aConfFile.getValueS(sSection, sKey, XPR_NULL);
        if (XPR_IS_NULL(sValue))
            break;

        sFilterItem = new FilterItem;
        XPR_ASSERT(sFilterItem != XPR_NULL);

        sFilterItem->mName = sValue;

        _stprintf(sKey, kExtensionKey, i + 1);
        sFilterItem->mExts = aConfFile.getValueS(sSection, sKey, XPR_STRING_LITERAL(""));

        _stprintf(sKey, kColorKey, i + 1);
        sFilterItem->mColor = aConfFile.getValueC(sSection, sKey, RGB(0,0,0));

        _stprintf(sKey, kIconIndexKey, i + 1);
        sFilterItem->mIconIndex = aConfFile.getValueI(sSection, sKey, -1);

        addFilter(sFilterItem);
    }

    return XPR_TRUE;
}