summaryrefslogtreecommitdiff
path: root/coreengine/gridelement.c
blob: f9773d335af19377df301b5fb9b94e0c227c0e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "gridelement.h"
#include "../config.h"

cGridElement::cGridElement(void) {
    current = false;
    indexCurrent = -1;
    viewId = -1;
    plugId = -1;
}

cGridElement::cGridElement(const cGridElement &other) : cViewElement(other) {
    current = false;
    viewId = other.viewId;
    plugId = other.plugId;
    tokenContainer = new skindesignerapi::cTokenContainer(*other.tokenContainer);
    indexCurrent = other.indexCurrent;
    InheritTokenContainerDeep();
}

cGridElement::~cGridElement(void) {
}

void cGridElement::SetTokenContainer(void) {
    skindesignerapi::cTokenContainer *tkGe = plgManager->GetTokenContainerGE(plugId, viewId, id);
    if (!tkGe)
        return;
    tokenContainer = new skindesignerapi::cTokenContainer(*tkGe);
    indexCurrent = tokenContainer->GetNumDefinedIntTokens();
    tokenContainer->DefineIntToken("{current}", indexCurrent);
    InheritTokenContainer();
}

void cGridElement::Set(skindesignerapi::cTokenContainer *tk) {
    tokenContainer->Clear();
    tokenContainer->SetTokens(tk);
    SetDirty();
}

void cGridElement::SetCurrent(bool current) {
    this->current = current;
    SetDirty();
}

bool cGridElement::Parse(bool forced) {
    if (!dirty)
        return false;
    tokenContainer->AddIntToken(indexCurrent, current);
    return true;
}

int cGridElement::Width(void) {
    return container.Width();
}

int cGridElement::Height(void) {
    return container.Height();
}