summaryrefslogtreecommitdiff
path: root/views/viewgrid.c
diff options
context:
space:
mode:
Diffstat (limited to 'views/viewgrid.c')
-rw-r--r--views/viewgrid.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/views/viewgrid.c b/views/viewgrid.c
new file mode 100644
index 0000000..6488ccd
--- /dev/null
+++ b/views/viewgrid.c
@@ -0,0 +1,74 @@
+#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) {
+ esyslog("skindesigner: setting %ld to current %d", gridID, 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;
+ esyslog("skindesigner: deleting grid %ld", gridID);
+ 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) {
+ esyslog("skindesigner: rendering %ld grids", grids.size());
+ for (map < long, cGrid* >::iterator it = grids.begin(); it != grids.end(); it++) {
+ cGrid *grid = it->second;
+ if (grid->Dirty()) {
+ if (grid->Moved()) {
+ grid->DeletePixmaps();
+ }
+ 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::Debug(void) {
+
+} \ No newline at end of file