Esempio n. 1
0
// TODO: create the rest of controls
static void ParseMuiDefinition(TxtNode *root, ParsedMui& res)
{
    TxtNode **n;
    for (n = root->children->IterStart(); n; n = root->children->IterNext()) {
        TxtNode *node = *n;
        CrashIf(!node->IsStruct());
        if (node->IsStructWithName("Style")) {
            CacheStyleFromStruct(node);
        } else if (node->IsStructWithName("ButtonVector")) {
            ButtonVector *b = ButtonVectorFromDef(node);
            res.allControls.Append(b);
            res.vecButtons.Append(b);
        } else if (node->IsStructWithName("Button")) {
            Button *b = ButtonFromDef(node);
            res.allControls.Append(b);
            res.buttons.Append(b);
        } else if (node->IsStructWithName("ScrollBar")) {
            ScrollBar *sb = ScrollBarFromDef(node);
            res.allControls.Append(sb);
            res.scrollBars.Append(sb);
        } else if (node->IsStructWithName("HorizontalLayout")) {
            HorizontalLayout *l = HorizontalLayoutFromDef(res, node);
            res.layouts.Append(l);
        } else if (node->IsStructWithName("VerticalLayout")) {
            VerticalLayout *l = VerticalLayoutFromDef(res, node);
            res.layouts.Append(l);
        } else {
            ScopedMem<char> keyName(node->KeyDup());
            ControlCreatorFunc creatorFunc = FindControlCreatorFuncFor(keyName);
            if (creatorFunc) {
                Control *c = creatorFunc(node);
                if (c)
                    res.allControls.Append(c);
                continue;
            }

            LayoutCreatorFunc layoutCreatorFunc = FindLayoutCreatorFuncFor(keyName);
            CrashIf(!layoutCreatorFunc);
            ILayout *layout = layoutCreatorFunc(&res, node);
            if (layout)
                res.layouts.Append(layout);
        }
    }
}
Esempio n. 2
0
// TODO: create the rest of controls
static void ParseMuiDefinition(TxtNode* root, ParsedMui& res) {
    for (TxtNode* node = root->firstChild; node != nullptr; node = node->sibling) {
        CrashIf(!node->IsStruct());
        if (node->IsStructWithName("Style")) {
            CacheStyleFromStruct(node);
        } else if (node->IsStructWithName("ButtonVector")) {
            ButtonVector* b = ButtonVectorFromDef(node);
            res.allControls.push_back(b);
            res.vecButtons.push_back(b);
        } else if (node->IsStructWithName("Button")) {
            Button* b = ButtonFromDef(node);
            res.allControls.push_back(b);
            res.buttons.push_back(b);
        } else if (node->IsStructWithName("ScrollBar")) {
            ScrollBar* sb = ScrollBarFromDef(node);
            res.allControls.push_back(sb);
            res.scrollBars.push_back(sb);
        } else if (node->IsStructWithName("HorizontalLayout")) {
            HorizontalLayout* l = HorizontalLayoutFromDef(res, node);
            res.layouts.push_back(l);
        } else if (node->IsStructWithName("VerticalLayout")) {
            VerticalLayout* l = VerticalLayoutFromDef(res, node);
            res.layouts.push_back(l);
        } else {
            AutoFree keyName(node->KeyDup());
            ControlCreatorFunc creatorFunc = FindControlCreatorFuncFor(keyName);
            if (creatorFunc) {
                Control* c = creatorFunc(node);
                if (c) {
                    res.allControls.push_back(c);
                }
                continue;
            }

            LayoutCreatorFunc layoutCreatorFunc = FindLayoutCreatorFuncFor(keyName);
            CrashIf(!layoutCreatorFunc);
            ILayout* layout = layoutCreatorFunc(&res, node);
            if (layout) {
                res.layouts.push_back(layout);
            }
        }
    }
}