Exemple #1
0
void Dialog::ReadRC(RCFile &rcFile)
{
    if (extended)
    {
        italics = 256;
    }
    resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure);
    resInfo.ReadRC(rcFile,false);
    pos.x = rcFile.GetNumber();
    rcFile.SkipComma();
    pos.y = rcFile.GetNumber();
    rcFile.SkipComma();
    size.x = rcFile.GetNumber();
    rcFile.SkipComma();
    size.y = rcFile.GetNumber();
    rcFile.SkipComma();
    rcFile.NeedEol();
    ReadSettings(rcFile);
    rcFile.NeedBegin();
    while (Control::ValidType(rcFile))
    {	
        Control *c = new Control;
        controls.push_back(c);
        c->ReadRC(rcFile, extended);
    }
    rcFile.NeedEnd();
}
Exemple #2
0
void Control::ReadGeneric(RCFile &rcFile, bool extended)
{
    text.ReadRC(rcFile, true);
    rcFile.SkipComma();
    id = rcFile.GetNumber();
    rcFile.SkipComma();
    GetClass(rcFile);
    rcFile.SkipComma();
    style = rcFile.GetNumber() | WS_CHILD | WS_VISIBLE;
    rcFile.SkipComma();
    pos.x = rcFile.GetNumber();
    rcFile.SkipComma();
    pos.y = rcFile.GetNumber();
    rcFile.SkipComma();
    size.x = rcFile.GetNumber();
    rcFile.SkipComma();
    size.y = rcFile.GetNumber();
    if (!rcFile.AtEol())
    {
        rcFile.SkipComma();
        exStyle = rcFile.GetNumber();
    }
    if (!rcFile.AtEol())
    {
        helpIndex = rcFile.GetNumber();
        rcFile.SkipComma();
    }
}
Exemple #3
0
void Control::ReadStandard(RCFile &rcFile, int clss , int addStyle, int extended, int hasText)
{
    addStyle |= WS_CHILD | WS_VISIBLE;
    cls.SetId(clss);
    if (hasText)
    {
        text.ReadRC(rcFile, true);
        rcFile.SkipComma();
    }
    id = rcFile.GetNumber();
    rcFile.SkipComma();
    pos.x = rcFile.GetNumber();
    rcFile.SkipComma();
    pos.y = rcFile.GetNumber();
    rcFile.SkipComma();
    size.x = rcFile.GetNumber();
    rcFile.SkipComma();
    size.y = rcFile.GetNumber();
    rcFile.SkipComma();
    if (!rcFile.AtEol())
    {
        style = addStyle | rcFile.GetNumber();
        rcFile.SkipComma();
    }
    else
        style = addStyle;
    if (!rcFile.AtEol())
    {
        exStyle = rcFile.GetNumber();
        rcFile.SkipComma();
    }
    if (!rcFile.AtEol())
    {
        helpIndex = rcFile.GetNumber();
        rcFile.SkipComma();
    }
    if (cls == Scrollbar)
    {
        if (style & SBS_VERT)
            style &= ~SBS_HORZ;
    }
}
Exemple #4
0
void ResourceData::ReadRC(RCFile &rcFile)
{
    if (rcFile.IsKeyword())
    {
        int maxLen = 1024;
        data = new unsigned char [maxLen];
        rcFile.NeedBegin();
        while (rcFile.IsNumber())
        {
            if (len == maxLen)
            {
                maxLen += 1024;
                unsigned char *hold = data;
                data = new unsigned char [maxLen];
                memcpy(data, hold, maxLen - 1024);
                delete [] hold;
            }
            data[len++] = rcFile.GetNumber() & 0xff;
            rcFile.SkipComma();
        }
        rcFile.NeedEnd();
    }
    else
    {
        std::string name = rcFile.GetFileName();
        std::fstream in(name.c_str(), std::ios::in | std::ios::binary);
        if (!in.fail())
        {
            in.seekg(0, std::ios::end);
            len = in.tellg();
            in.seekg(0, std::ios::beg);
            data = new unsigned char[len];
            in.read((char *)data, len);
        }
        else
            throw new std::runtime_error(std::string("Could not open file '") + name + "'");
    }
}
void ResourceInfo::ReadRC(RCFile &rcFile, bool secondary)
{
    bool done = false;
    while (!done)
    {
        switch (rcFile.GetToken()->GetKeyword())
        {
            case Lexer::DISCARDABLE:
                memoryFlags |= Discardable;
                break;
            case Lexer::PURE:
                memoryFlags |= Pure;
                break;
            case Lexer::PRELOAD:
                memoryFlags |= Preload;
                break;
            case Lexer::MOVEABLE:
                memoryFlags |= Moveable;
                break;
            case Lexer::LOADONCALL:
                memoryFlags |= LoadOnCall;
                break;			
            case Lexer::NONDISCARDABLE:
                memoryFlags &= ~Discardable;
                break;
            case Lexer::IMPURE:
                memoryFlags &= ~Pure;
                break;
            case Lexer::FIXED:
                memoryFlags &= ~Moveable;
                break;
            default:
                done = true;
                break;
        }
        if (!done)
            rcFile.NextToken();
    }
    if (secondary)
    {
        done = false;
        language = rcFile.GetLanguage();
        while (!done)
        {
            switch (rcFile.GetToken()->GetKeyword())
            {
                case Lexer::LANGUAGE:
                    rcFile.NextToken();
                    language = rcFile.GetNumber();
                    rcFile.GetNumber();
                    rcFile.NeedEol();
                    break;
                case Lexer::VERSION:
                    rcFile.NextToken();
                    version = rcFile.GetNumber();
                    rcFile.NeedEol();
                    break;
                case Lexer::CHARACTERISTICS:
                    rcFile.NextToken();
                    characteristics = rcFile.GetNumber();
                    rcFile.NeedEol();
                    break;
                default:
                    done = true;
                    break;
            }
        }
    }
}
Exemple #6
0
void Accelerators::Key::ReadRC(RCFile &rcFile)
{
    if (rcFile.IsString())
    {
        std::wstring str = rcFile.GetString();
        if (str[0] == '^')
        {
            if (str.size() != 2)
                throw new std::runtime_error("Invalid key sequence");
            if (str[1] == '^')
                key = '^';
            else
                key = str[1] & 0x1f;
        }
        else
        {
            if (str.size() != 1)
                throw new std::runtime_error("Invalid key sequence");
            key = str[0];
        }
    }
    else
    {
        key = rcFile.GetNumber();
    }
    rcFile.SkipComma();
    id = rcFile.GetNumber();
    rcFile.SkipComma();
    bool done = false;
    while (rcFile.IsKeyword() && !done)
    {
        switch (rcFile.GetToken()->GetKeyword())
        {
            case Lexer::ASCII:
                flags &= ~Virtkey;
                break;
            case Lexer::VIRTKEY:
                flags |= Virtkey;
                break;
            case Lexer::NOINVERT:
                flags |= NoInvert;
                break;
            case Lexer::SHIFT:
                flags |= Shift;
                break;
            case Lexer::CONTROL:
                flags |= Control;
                break;
            case Lexer::ALT:
                flags |= Alt;
                break;
            default:
                done = true;
                break;
        }
        if (!done)
        {
            rcFile.NextToken();
            rcFile.SkipComma();
        }
    }
    rcFile.NeedEol();
}
Exemple #7
0
void Dialog::ReadSettings(RCFile &rcFile)
{
    bool hascaption = false, hasstyle = false, hasfont = false;
    resInfo.SetLanguage(rcFile.GetLanguage());
    bool done = FALSE;
    while (!done && rcFile.IsKeyword())
    {
        switch (rcFile.GetToken()->GetKeyword())
        {
            case Lexer::LANGUAGE:
            {
                rcFile.NextToken();
                int n = rcFile.GetNumber() ;
                rcFile.SkipComma();
                n += rcFile.GetNumber() * 1024;
                resInfo.SetLanguage(n);
            }
                break;
            case Lexer::VERSION:
                rcFile.NextToken();
                resInfo.SetVersion(rcFile.GetNumber());
                break;
            case Lexer::CHARACTERISTICS:
                rcFile.NextToken();
                resInfo.SetCharacteristics(rcFile.GetNumber());
                break;
            case Lexer::STYLE:
                hasstyle = true;
                rcFile.NextToken();
                style = rcFile.GetNumber();
                break;
            case Lexer::EXSTYLE:
                rcFile.NextToken();
                exStyle |= rcFile.GetNumber();
                break;
            case Lexer::MENU:
                rcFile.NextToken();
                menu.ReadRC(rcFile);
                break;
            case Lexer::FONT:
                hasfont = true;
                rcFile.NextToken();
                pointSize = rcFile.GetNumber();
                rcFile.SkipComma();
                font = rcFile.GetString();
                break;
            case Lexer::CAPTION:
                hascaption = true;
                rcFile.NextToken();
                caption = rcFile.GetString();
                break;
            case Lexer::CLASS:
                rcFile.NextToken();
                cls.ReadRC(rcFile, true);
                break;
            case Lexer::HELP:
                rcFile.NextToken();
                if (!extended)
                    throw new std::runtime_error("Need DialogEx");
                helpIndex = rcFile.GetNumber();
                break;
            case Lexer::WEIGHT:
                rcFile.NextToken();
                if (!extended)
                    throw new std::runtime_error("Need DialogEx");
                weight = rcFile.GetNumber();
                break;
            case Lexer::ITALIC:
                rcFile.NextToken();
                if (!extended)
                    throw new std::runtime_error("Need DialogEx");
                italics = rcFile.GetNumber();
                break;
            default:
                done = TRUE;
                break;
        }
        if (!done)
        {
            rcFile.NeedEol();
        }
    }
    if (hascaption)
        style |= WS_CAPTION;
    if (!hasstyle)
        style |= WS_POPUPWINDOW;
    if (hasfont)
        style |= DS_SETFONT;
}