aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-04-23 11:43:21 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:47 +0100
commitb3f87944ba62ee82684f30fc89d8bbd5cf472b48 (patch)
tree0099a83f05ae70506c1355fc2f3c7c29803664cd
parentf2b29d039424262426fd4598ce076f54e31854cf (diff)
downloadusdx-b3f87944ba62ee82684f30fc89d8bbd5cf472b48.tar.gz
usdx-b3f87944ba62ee82684f30fc89d8bbd5cf472b48.tar.xz
usdx-b3f87944ba62ee82684f30fc89d8bbd5cf472b48.zip
added parent to control
parent is used to delete the objects if the parent is deleted
-rw-r--r--src/menu/container.cpp3
-rw-r--r--src/menu/container.hpp2
-rw-r--r--src/menu/control.cpp18
-rw-r--r--src/menu/control.hpp9
-rw-r--r--src/menu/drawable_control.cpp3
-rw-r--r--src/menu/drawable_control.hpp2
-rw-r--r--src/menu/frame.cpp6
-rw-r--r--src/menu/frame.hpp4
8 files changed, 37 insertions, 10 deletions
diff --git a/src/menu/container.cpp b/src/menu/container.cpp
index 57bac666..467e5aa5 100644
--- a/src/menu/container.cpp
+++ b/src/menu/container.cpp
@@ -28,7 +28,8 @@
namespace usdx
{
- Container::Container()
+ Container::Container(Control* parent)
+ : DrawableControl(parent)
{
}
diff --git a/src/menu/container.hpp b/src/menu/container.hpp
index d85320a2..271a4f67 100644
--- a/src/menu/container.hpp
+++ b/src/menu/container.hpp
@@ -38,7 +38,7 @@ namespace usdx
std::list<DrawableControl*> controls;
public:
- Container();
+ Container(Control* parent);
virtual ~Container();
/**
diff --git a/src/menu/control.cpp b/src/menu/control.cpp
index 373fb482..68b5c328 100644
--- a/src/menu/control.cpp
+++ b/src/menu/control.cpp
@@ -24,15 +24,31 @@
* $Id$
*/
+#include <stddef.h>
#include "control.hpp"
namespace usdx
{
- Control::Control()
+ Control::Control(Control *parent)
+ : parent(parent)
{
}
Control::~Control()
{
+ if (parent) {
+ delete parent;
+ parent = NULL;
+ }
+ }
+
+ void Control::set_parent(Control *parent)
+ {
+ this->parent = parent;
+ }
+
+ Control* Control::get_parent(void) const
+ {
+ return parent;
}
};
diff --git a/src/menu/control.hpp b/src/menu/control.hpp
index 2d47eb55..d0b70d4f 100644
--- a/src/menu/control.hpp
+++ b/src/menu/control.hpp
@@ -31,9 +31,16 @@ namespace usdx
{
class Control
{
+ private:
+ Control* parent;
+
public:
- Control();
+ Control(Control *parent);
virtual ~Control();
+
+ void set_parent(Control *parent);
+
+ Control* get_parent(void) const;
};
};
diff --git a/src/menu/drawable_control.cpp b/src/menu/drawable_control.cpp
index 404b0e4c..895193f4 100644
--- a/src/menu/drawable_control.cpp
+++ b/src/menu/drawable_control.cpp
@@ -28,7 +28,8 @@
namespace usdx
{
- DrawableControl::DrawableControl()
+ DrawableControl::DrawableControl(Control* parent)
+ : Control(parent)
{
}
diff --git a/src/menu/drawable_control.hpp b/src/menu/drawable_control.hpp
index 612e17d3..60701f4b 100644
--- a/src/menu/drawable_control.hpp
+++ b/src/menu/drawable_control.hpp
@@ -42,7 +42,7 @@ namespace usdx
virtual void draw(void) const = 0;
public:
- DrawableControl();
+ DrawableControl(Control* parent);
virtual ~DrawableControl();
};
};
diff --git a/src/menu/frame.cpp b/src/menu/frame.cpp
index 8707f0cc..665a2627 100644
--- a/src/menu/frame.cpp
+++ b/src/menu/frame.cpp
@@ -28,11 +28,13 @@
namespace usdx
{
- Frame::Frame() : background(NULL)
+ Frame::Frame(Control* parent)
+ : Container(parent), background(NULL)
{
}
- Frame::Frame(FrameBackground* background) : background(background)
+ Frame::Frame(Control* parent, FrameBackground* background)
+ : Container(parent), background(background)
{
}
diff --git a/src/menu/frame.hpp b/src/menu/frame.hpp
index 7f9af120..e71bef9b 100644
--- a/src/menu/frame.hpp
+++ b/src/menu/frame.hpp
@@ -41,8 +41,8 @@ namespace usdx
virtual void draw(void) const;
public:
- Frame();
- Frame(FrameBackground* background);
+ Frame(Control* parent);
+ Frame(Control* parent, FrameBackground* background);
virtual ~Frame();