From c5af4c3057a904f2a037a624273c1c7a4b0295a5 Mon Sep 17 00:00:00 2001 From: jonas Date: Fri, 28 Dec 2018 13:04:01 +0100 Subject: Adding Click and Char event handling and focusing to cObjectHandler cObject: is now able to be parent class cObjectHandler: Implemented --- cObject.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 23 deletions(-) (limited to 'cObject.cpp') 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; } -- cgit v1.2.3