Index: branches/new_class_id/src/lib/gui/gl/glgui_handler.cc
===================================================================
--- branches/new_class_id/src/lib/gui/gl/glgui_handler.cc	(revision 9683)
+++ branches/new_class_id/src/lib/gui/gl/glgui_handler.cc	(revision 9689)
@@ -23,5 +23,4 @@
 #include "glgui_cursor.h"
 
-#include "class_list.h"
 #include <cassert>
 
@@ -35,5 +34,5 @@
 namespace OrxGui
 {
-
+  NewObjectListDefinition(GLGuiHandler);
   /**
    * standard constructor
@@ -41,5 +40,5 @@
   GLGuiHandler::GLGuiHandler ()
   {
-    this->setClassID(CL_GLGUI_HANDLER, "GLGuiHandler");
+    this->registerObject(this, GLGuiHandler::_objectList);
     this->setName("GLGuiHandler");
 
@@ -117,63 +116,49 @@
   {
     // retrieve Objects.
-    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
-
-    if (objects)
-    {
-      std::list<BaseObject*>::const_iterator it ;
-      std::list<BaseObject*>::const_iterator currentIt = objects->end();
+    NewObjectList<GLGuiWidget>::const_iterator it, currentIt;
+    currentIt = GLGuiWidget::objectList().end();
+
+    if (GLGuiWidget::selected() != NULL)
+    {
+      it = std::find(GLGuiWidget::objectList().begin(), GLGuiWidget::objectList().end(), GLGuiWidget::selected());
+      if (it != GLGuiWidget::objectList().end())
+      {
+        currentIt = it;
+        it++;
+      }
+    }
+    else
+    {
+      it = GLGuiWidget::objectList().begin();
+    }
+
+    bool cycledOnce = false;
+
+    for (; it != currentIt; ++it)
+    {
+      if (it == GLGuiWidget::objectList().end() && !cycledOnce)
+      {
+        it = GLGuiWidget::objectList().begin();
+        cycledOnce = true;
+      }
+
+      if ((*it)->selectable() && (*it)->isVisible())
+      {
+        (*it)->select();
+        return;
+      }
+    }
+
+  }
+
+  void GLGuiHandler::selectPrevious()
+  {
+    NewObjectList<GLGuiWidget>::const_iterator it, currentIt;
+    currentIt = GLGuiWidget::objectList().begin();
 
       if (GLGuiWidget::selected() != NULL)
       {
-        it = std::find(objects->begin(), objects->end(), GLGuiWidget::selected());
-        if (it != objects->end())
-        {
-          currentIt = it;
-          it++;
-        }
-      }
-      else
-      {
-        it = objects->begin();
-      }
-
-      bool cycledOnce = false;
-
-      for (; it != currentIt; ++it)
-      {
-        if (it == objects->end() && !cycledOnce)
-        {
-          it = objects->begin();
-          cycledOnce = true;
-        }
-
-        if (dynamic_cast<GLGuiWidget*>(*it)->selectable() && dynamic_cast<GLGuiWidget*>(*it)->isVisible())
-        {
-          dynamic_cast<GLGuiWidget*>(*it)->select();
-          return;
-        }
-      }
-
-    }
-    else
-    {
-      PRINTF(0)("NO GUI-ELEMENTS EXISTING\n");
-    }
-  }
-
-  void GLGuiHandler::selectPrevious()
-  {
-    // retrieve Objects.
-    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
-
-    if (objects)
-    {
-      std::list<BaseObject*>::const_iterator it ;
-      std::list<BaseObject*>::const_iterator currentIt = objects->begin();
-
-      if (GLGuiWidget::selected() != NULL)
-      {
-        it = std::find(objects->begin(), objects->end(), GLGuiWidget::selected());
-        if (it != objects->end())
+	it = std::find(GLGuiWidget::objectList().begin(), GLGuiWidget::objectList().end(), GLGuiWidget::selected());
+	if (it != GLGuiWidget::objectList().end())
         {
           currentIt = it;
@@ -183,5 +168,5 @@
       else
       {
-        it = objects->end();
+	it = GLGuiWidget::objectList().end();
       }
 
@@ -190,5 +175,5 @@
       for (; it != currentIt; --it)
       {
-        if (it == objects->end() && !cycledOnce)
+	if (it == GLGuiWidget::objectList().end() && !cycledOnce)
         {
           --it ;
@@ -196,16 +181,11 @@
         }
 
-        if (dynamic_cast<GLGuiWidget*>(*it)->selectable() && dynamic_cast<GLGuiWidget*>(*it)->isVisible())
-        {
-          dynamic_cast<GLGuiWidget*>(*it)->select();
+        if ((*it)->selectable() && (*it)->isVisible())
+        {
+          (*it)->select();
           return;
         }
       }
 
-    }
-    else
-    {
-      PRINTF(0)("NO GUI-ELEMENTS EXISTING\n");
-    }
   }
 
@@ -217,51 +197,51 @@
     {
       case EV_MOUSE_MOTION:
-        this->checkFocus();
-        break;
+      this->checkFocus();
+      break;
 
       case  EV_MOUSE_BUTTON_LEFT:
-        if (GLGuiWidget::mouseFocused() != NULL && event.bPressed)
-        {
-          // if clickable select the Widget.
-          if (GLGuiWidget::mouseFocused()->clickable())
-          {
-            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
-            GLGuiWidget::mouseFocused()->select();
-            GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
-          }
-        }
-        else if (GLGuiWidget::selected() != NULL && !event.bPressed)
-        {
-          if (GLGuiWidget::selected()->clickable())
-          {
-            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
-            GLGuiWidget::selected()->release(cursorPos - GLGuiWidget::selected()->getAbsCoor2D());
-          }
-        }
-
-        break;
+      if (GLGuiWidget::mouseFocused() != NULL && event.bPressed)
+      {
+        // if clickable select the Widget.
+        if (GLGuiWidget::mouseFocused()->clickable())
+        {
+          Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
+          GLGuiWidget::mouseFocused()->select();
+          GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
+        }
+      }
+      else if (GLGuiWidget::selected() != NULL && !event.bPressed)
+      {
+        if (GLGuiWidget::selected()->clickable())
+        {
+          Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
+          GLGuiWidget::selected()->release(cursorPos - GLGuiWidget::selected()->getAbsCoor2D());
+        }
+      }
+
+      break;
       case EV_LEAVE_STATE:
-        if (GLGuiWidget::selected() != NULL)
-          GLGuiWidget::selected()->unselect();
-
-        if (GLGuiWidget::mouseFocused() != NULL)
-          GLGuiWidget::mouseFocused()->breakMouseFocus();
-        break;
+      if (GLGuiWidget::selected() != NULL)
+        GLGuiWidget::selected()->unselect();
+
+      if (GLGuiWidget::mouseFocused() != NULL)
+        GLGuiWidget::mouseFocused()->breakMouseFocus();
+      break;
 
       case EV_VIDEO_RESIZE:
-        if (this->_cursor != NULL)
-          this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
-        this->_resolution = Vector2D(event.resize.w, event.resize.h);
-        break;
+      if (this->_cursor != NULL)
+        this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
+      this->_resolution = Vector2D(event.resize.w, event.resize.h);
+      break;
 
       case SDLK_TAB:
-        if (event.bPressed)
-        {
-          if (EventHandler::getInstance()->isPressed(SDLK_LSHIFT) || EventHandler::getInstance()->isPressed(SDLK_RSHIFT))
-            this->selectPrevious();
-          else
-            this->selectNext();
-        }
-        break;
+      if (event.bPressed)
+      {
+        if (EventHandler::getInstance()->isPressed(SDLK_LSHIFT) || EventHandler::getInstance()->isPressed(SDLK_RSHIFT))
+          this->selectPrevious();
+        else
+          this->selectNext();
+      }
+      break;
     }
 
@@ -304,11 +284,11 @@
   {
     // CHECK THE COLLISIONS.
-    const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
-
-    if (objects != NULL && this->_cursor != NULL)
-    {
-      for (std::list<BaseObject*>::const_iterator it = objects->begin(); it != objects->end(); it++)
-      {
-        GLGuiWidget* widget = dynamic_cast<GLGuiWidget*>(*it);
+    if (this->_cursor != NULL)
+    {
+      for (NewObjectList<GLGuiWidget>::const_iterator it = GLGuiWidget::objectList().begin();
+	   it != GLGuiWidget::objectList().end();
+	   it++)
+      {
+        GLGuiWidget* widget = (*it);
 
         if (widget->isVisible() &&
