summaryrefslogtreecommitdiff
path: root/views/viewgrid.c
blob: 008133ec0b7f0f0d904268c15d78f58563ec8340 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "viewgrid.h"

using namespace std;

cViewGrid::cViewGrid(cTemplateViewGrid *tmplGrid) {
    this->tmplGrid = tmplGrid;
}

cViewGrid::~cViewGrid() {
    Clear();
}

void cViewGrid::SetGrid(long gridID, 
                        double x, double y, double width, double height, 
                        map<string,int> *intTokens, map<string,string> *stringTokens) {
    map < long, cGrid* >::iterator hit = grids.find(gridID);
    cGrid *grid;
    if (hit == grids.end()) {
        grid = new cGrid(tmplGrid);
        grid->Set(x, y, width, height, intTokens, stringTokens);
        grids.insert(pair<long,cGrid*>(gridID, grid));
    } else {
        (hit->second)->Set(x, y, width, height, intTokens, stringTokens);
    }
}

void cViewGrid::SetCurrent(long gridID, bool current) {
    map<long,cGrid*>::iterator hit = grids.find(gridID);
    if (hit != grids.end())
        (hit->second)->SetCurrent(current);
}

void cViewGrid::Delete(long gridID) {
    map<long,cGrid*>::iterator hit = grids.find(gridID);
    if (hit == grids.end())
        return;
    delete (hit->second);
    grids.erase(gridID);
}

void cViewGrid::Clear(void) {
    for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++)
        delete it->second;
    grids.clear();
}

void cViewGrid::Render(void) {
    for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
        cGrid *grid = it->second;
        if (grid->Dirty()) {
            if (grid->Moved()) {
                grid->Move();
            }
            grid->Clear();
            //esyslog("skindesigner: rendering grid %ld", it->first);
            grid->Draw();
        } else if (grid->Resized()) {
            //esyslog("skindesigner: resizing grid %ld", it->first);
            grid->DeletePixmaps();
            grid->Draw();
        } else if (grid->Moved()) {
            //esyslog("skindesigner: moving grid %ld", it->first);
            grid->Move();
        } else {
            //esyslog("skindesigner: skipping grid %ld", it->first);
        }
    }
}

void cViewGrid::Hide(void) {
    for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
        cGrid *grid = it->second;
        grid->HidePixmaps();
    }
}

void cViewGrid::Show(void) {
    for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
        cGrid *grid = it->second;
        grid->ShowPixmaps();
    }
}


void cViewGrid::Debug(void) {
    
}