summaryrefslogtreecommitdiff
path: root/cObject.cpp
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2018-12-28 13:04:01 +0100
committerGravatar jonas <himself@jonasgunz.de> 2018-12-28 13:04:01 +0100
commitc5af4c3057a904f2a037a624273c1c7a4b0295a5 (patch)
tree4af973d27706db05a5fba267fa93370429a056d3 /cObject.cpp
parent3cfea2815e3edfeb15fd7f0173957254babc7326 (diff)
downloadtermgl-c5af4c3057a904f2a037a624273c1c7a4b0295a5.tar.gz
Adding Click and Char event handling and focusing to cObjectHandler
cObject: is now able to be parent class cObjectHandler: Implemented
Diffstat (limited to 'cObject.cpp')
-rw-r--r--cObject.cpp74
1 files changed, 51 insertions, 23 deletions
diff --git a/cObject.cpp b/cObject.cpp
index 8b18e41..118fe6f 100644
--- a/cObject.cpp
+++ b/cObject.cpp
@@ -2,6 +2,50 @@
cObject::cObject(int _sx, int _sy)
{
+ bSizeSet = false;
+
+ setSize(_sx, _sy);
+}
+
+cObject::~cObject()
+{
+ destruct();
+}
+
+sPos cObject::getPosition()
+{
+ return pos;
+}
+
+void cObject::setPosition(sPos _pos)
+{
+ pos = _pos;
+}
+
+
+void cObject::setPosition(int _x, int _y)
+{
+ pos.x = _x;
+ pos.y = _y;
+}
+
+
+sObject cObject::getObject()
+{
+ return sObject{pos, wColor, cScreen, sizeX, sizeY};
+}
+
+//protected
+cObject::cObject()
+{
+ bSizeSet = false;
+}
+
+void cObject::setSize(int _sx, int _sy)
+{
+ if(bSizeSet)
+ return;
+
bBlockRender = true; //Block inherited render capabilities of parent
sizeX = _sx;
@@ -22,10 +66,15 @@ cObject::cObject(int _sx, int _sy)
wColor[o][i] = _COL_DEFAULT;
}
}
+
+ bSizeSet = true;
}
-cObject::~cObject()
+void cObject::destruct()
{
+ if(!bSizeSet)
+ return;
+
for (int i = 0; i < sizeX; i++) {
free(cScreen[i]);
free(wColor[i]);
@@ -33,27 +82,6 @@ cObject::~cObject()
free(cScreen);
free(wColor);
-}
-
-sPos cObject::getPosition()
-{
- return pos;
-}
-
-void cObject::setPosition(sPos _pos)
-{
- pos = _pos;
-}
-
-void cObject::setPosition(int _x, int _y)
-{
- pos.x = _x;
- pos.y = _y;
-}
-
-
-sObject cObject::getObject()
-{
- return sObject{pos, wColor, cScreen, sizeX, sizeY};
+ bSizeSet = false;
}