Exemplo n.º 1
0
bool Control::SetStyle(Style *style)
{
    CachedStyle *newCachedStyle = CacheStyle(style);
    if (newCachedStyle != cachedStyle) {
        cachedStyle = newCachedStyle;
        return true;
    }
    return false;
}
Exemplo n.º 2
0
// returns true if the style of control has changed
bool Control::SetStyle(Style *style)
{
    bool changed;
    CachedStyle *currStyle = cachedStyle;
    cachedStyle = CacheStyle(style, &changed);
    if (currStyle != cachedStyle)
        changed = true;
    if (changed)
        RequestRepaint(this);
    return changed;
}
Exemplo n.º 3
0
// styles are cached globally, so we only add a style if it doesn't
// exist already
static void CacheStyleFromStruct(TxtNode* def) {
    CrashIf(!def->IsStructWithName("style"));
    TxtNode* nameNode = TxtChildNodeWithKey(def, "name");
    CrashIf(!nameNode); // must have name or else no way to refer to it
    AutoFree tmp(nameNode->ValDup());
    if (StyleByName(tmp))
        return;

    Style* style = new Style();
    for (TxtNode* node = def->firstChild; node != nullptr; node = node->sibling) {
        CrashIf(!node->IsText());
        AddStyleProp(style, node);
    }
    CacheStyle(style, nullptr);
}
Exemplo n.º 4
0
// styles are cached globally, so we only add a style if it doesn't
// exist already
static void CacheStyleFromStruct(TxtNode* def)
{
    CrashIf(!def->IsStructWithName("style"));
    TxtNode *nameNode = TxtChildNodeWithKey(def, "name");
    CrashIf(!nameNode); // must have name or else no way to refer to it
    ScopedMem<char> tmp(nameNode->ValDup());
    if (StyleByName(tmp))
        return;

    Style *style = new Style();
    size_t n = def->children->Count();
    for (size_t i = 0; i < n; i++) {
        TxtNode *node = def->children->At(i);
        CrashIf(!node->IsText());
        AddStyleProp(style, node);
    }
    CacheStyle(style, NULL);
}
Exemplo n.º 5
0
void Control::SetStyle(Style *style)
{
    cachedStyle = CacheStyle(style);
}