Index: trunk/src/lib/gui/gl/Makefile.am
===================================================================
--- trunk/src/lib/gui/gl/Makefile.am	(revision 8711)
+++ trunk/src/lib/gui/gl/Makefile.am	(revision 8717)
@@ -60,8 +60,3 @@
 		specials/glgui_notifier.h
 
-
-
-
-
 EXTRA_DIST =
-
Index: trunk/src/lib/gui/gl/glgui_box.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_box.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_box.cc	(revision 8717)
@@ -125,5 +125,4 @@
       height += borderBottom(); /* *2 done further up */
 
-      printf("%f %f\n", width, height);
       this->setSize2D(width, height);
     }
@@ -145,5 +144,4 @@
       height += borderBottom(); /* *2 done further up */
 
-      printf("%f %f\n", width, height);
       this->setSize2D(width, height);
     }
Index: trunk/src/lib/gui/gl/glgui_button.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_button.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_button.cc	(revision 8717)
@@ -51,4 +51,6 @@
   {
     this->setClassID(CL_GLGUI_BUTTON, "GLGuiButton");
+
+    this->setSelectable(true);
     this->setFocusable(true);
     this->setClickable(true);
@@ -79,7 +81,7 @@
     emit(clicked());
   }
-  void GLGuiButton::releasing(const Vector2D& pos)
+  void GLGuiButton::releasing(const Vector2D& pos, bool focused)
   {
-    GLGuiWidget::releasing(pos);
+    GLGuiWidget::releasing(pos, focused);
     emit(released());
   }
@@ -96,4 +98,15 @@
 
 
+  bool GLGuiButton::processEvent(const Event& event)
+  {
+    if (event.type == SDLK_SPACE && !event.bPressed)
+    {
+      emit(released());
+      return true;
+    }
+    return false;
+  }
+
+
   /**
    * @brief draws the GLGuiButton
Index: trunk/src/lib/gui/gl/glgui_button.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_button.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_button.h	(revision 8717)
@@ -40,7 +40,9 @@
 
       virtual void draw() const;
+      virtual bool processEvent(const Event& event);
 
       DeclareSignal0(clicked);
       DeclareSignal0(released);
+
 
     protected:
@@ -48,5 +50,5 @@
 
       virtual void clicking(const Vector2D& pos);
-      virtual void releasing(const Vector2D& pos);
+      virtual void releasing(const Vector2D& pos, bool focused);
       virtual void hiding();
       virtual void showing();
Index: trunk/src/lib/gui/gl/glgui_checkbutton.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_checkbutton.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_checkbutton.cc	(revision 8717)
@@ -78,8 +78,9 @@
 
 
-  void GLGuiCheckButton::releasing(const Vector2D& pos)
+  void GLGuiCheckButton::releasing(const Vector2D& pos, bool focused)
   {
-    GLGuiButton::releasing(pos);
-    this->toggleActiveState();
+    GLGuiButton::releasing(pos, focused);
+    if (focused)
+      this->toggleActiveState();
   }
 
Index: trunk/src/lib/gui/gl/glgui_checkbutton.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_checkbutton.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_checkbutton.h	(revision 8717)
@@ -38,5 +38,5 @@
   protected:
     virtual void resize();
-    virtual void releasing(const Vector2D& pos);
+    virtual void releasing(const Vector2D& pos, bool focused);
 
   private:
Index: trunk/src/lib/gui/gl/glgui_handler.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_handler.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_handler.cc	(revision 8717)
@@ -25,4 +25,6 @@
 #include <cassert>
 
+#include "debug.h"
+
 #include <cassert>
 
@@ -99,4 +101,101 @@
   }
 
+  void GLGuiHandler::selectNext()
+  {
+    // 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();
+
+      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)->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())
+        {
+          currentIt = it;
+          it--;
+        }
+      }
+      else
+      {
+        it = objects->end();
+      }
+
+      bool cycledOnce = false;
+
+      for (; it != currentIt; --it)
+      {
+        if (it == objects->end() && !cycledOnce)
+        {
+          --it ;
+          cycledOnce = true;
+        }
+
+        if (dynamic_cast<GLGuiWidget*>(*it)->selectable())
+        {
+          dynamic_cast<GLGuiWidget*>(*it)->select();
+          return;
+        }
+      }
+
+    }
+    else
+    {
+      PRINTF(0)("NO GUI-ELEMENTS EXISTING\n");
+    }
+  }
+
+
 
   void GLGuiHandler::process(const Event &event)
@@ -105,27 +204,30 @@
     {
       case  EV_MOUSE_BUTTON_LEFT:
-        if (GLGuiWidget::focused() != NULL)
-        {
-          if (event.bPressed)
+        if (GLGuiWidget::mouseFocused() != NULL && event.bPressed)
+        {
+          // if clickable select the Widget.
+          if (GLGuiWidget::mouseFocused()->clickable())
           {
-            if (GLGuiWidget::focused()->clickable())
-            {
-              Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
-              GLGuiWidget::focused()->click(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
-            }
+            Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
+            GLGuiWidget::mouseFocused()->select();
+            GLGuiWidget::mouseFocused()->click(cursorPos - GLGuiWidget::mouseFocused()->getAbsCoor2D());
           }
-          else
+        }
+        else if (GLGuiWidget::selected() != NULL && !event.bPressed)
+        {
+          if (GLGuiWidget::selected()->clickable())
           {
-            if (GLGuiWidget::focused()->clickable())
-            {
-              Vector2D cursorPos = (this->_cursor != NULL) ? this->_cursor->getAbsCoor2D() : Vector2D(event.x, event.y);
-              GLGuiWidget::focused()->release(cursorPos - GLGuiWidget::focused()->getAbsCoor2D());
-            }
+            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::focused() != NULL)
-          GLGuiWidget::focused()->breakFocus();
+        if (GLGuiWidget::selected() != NULL)
+          GLGuiWidget::selected()->unselect();
+
+        if (GLGuiWidget::mouseFocused() != NULL)
+          GLGuiWidget::mouseFocused()->breakMouseFocus();
         break;
 
@@ -134,11 +236,13 @@
           this->_cursor->setMaxBorders(Vector2D(event.resize.w, event.resize.h));
         break;
-    }
-
-
-
-    if (GLGuiWidget::focused())
-    {
-      GLGuiWidget::focused()->processEvent(event);
+      case SDLK_TAB:
+        if (event.bPressed)
+          this->selectNext();
+        break;
+    }
+
+    if (GLGuiWidget::selected() != NULL)
+    {
+      GLGuiWidget::selected()->processEvent(event);
     }
 
@@ -160,4 +264,5 @@
       return Vector2D::nullVector();
   }
+
   Vector2D GLGuiHandler::cursorPositionRel(const GLGuiWidget* const widget) const
   {
@@ -170,14 +275,7 @@
 
 
-  void GLGuiHandler::draw()
-  {
-    //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
-  }
-
-
-  void GLGuiHandler::tick(float dt)
-  {
-
-    // CHECK THE COLLISIONS.
+  void GLGuiHandler::checkFocus()
+  {
+   // CHECK THE COLLISIONS.
     const std::list<BaseObject*>* objects = ClassList::getList(CL_GLGUI_WIDGET);
 
@@ -193,14 +291,29 @@
         {
           // receiving Focus
-          if (GLGuiWidget::focused() != widget)
+          if (GLGuiWidget::mouseFocused() != widget)
           {
-            widget->giveFocus();
+            widget->giveMouseFocus();
           }
           return ;
         }
       }
-      if (GLGuiWidget::focused() != NULL)
-        GLGuiWidget::focused()->breakFocus();
-    }
+      if (GLGuiWidget::mouseFocused() != NULL)
+        GLGuiWidget::mouseFocused()->breakMouseFocus();
+    }
+  }
+
+  void GLGuiHandler::draw()
+  {
+    //    GLGuiMainWidget::getInstance()->draw2D(E2D_LAYER_TOP);
+  }
+
+
+  void GLGuiHandler::tick(float dt)
+  {
+    // do not change if we already clicked into a Widget.
+    // if (GLGuiWidget::selected() != NULL && GLGuiWidget::selected()->pushed())
+    //      return ;
+
+    this->checkFocus();
   }
 }
Index: trunk/src/lib/gui/gl/glgui_handler.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_handler.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_handler.h	(revision 8717)
@@ -34,7 +34,11 @@
     Vector2D cursorPositionRel(const GLGuiWidget* const widget) const;
 
+    void selectNext();
+    void selectPrevious();
+
     void activate();
     void deactivate();
 
+    void checkFocus();
 
     virtual void process(const Event &event);
Index: trunk/src/lib/gui/gl/glgui_inputline.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_inputline.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_inputline.cc	(revision 8717)
@@ -47,4 +47,6 @@
 
     this->setFocusable(true);
+    this->setClickable(true);
+    this->setSelectable(true);
 
     this->_clearOnEnter = false;
Index: trunk/src/lib/gui/gl/glgui_pushbutton.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_pushbutton.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_pushbutton.cc	(revision 8717)
@@ -63,5 +63,4 @@
   void GLGuiPushButton::receivedFocus()
   {
-    printf("%s received focus\n", this->label().c_str());
     GLGuiWidget::receivedFocus();
   }
@@ -69,5 +68,4 @@
   void GLGuiPushButton::removedFocus()
   {
-    printf("%s removed focus\n", this->label().c_str());
     GLGuiWidget::removedFocus();
 
@@ -76,13 +74,12 @@
   void GLGuiPushButton::clicking(const Vector2D& pos)
   {
-    printf("%s clicked\n", this->label().c_str());
     GLGuiButton::clicking(pos);
   }
 
 
-  void GLGuiPushButton::releasing(const Vector2D& pos)
+  void GLGuiPushButton::releasing(const Vector2D& pos, bool focused)
   {
-    printf("%s released\n", this->label().c_str());
-    GLGuiButton::releasing(pos);
+    if (focused)
+      GLGuiButton::releasing(pos, focused);
   }
 
Index: trunk/src/lib/gui/gl/glgui_pushbutton.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_pushbutton.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_pushbutton.h	(revision 8717)
@@ -31,8 +31,9 @@
     virtual void draw() const;
     virtual void update();
+
   protected:
     virtual void resize();
     virtual void clicking(const Vector2D& pos);
-    virtual void releasing(const Vector2D& pos);
+    virtual void releasing(const Vector2D& pos, bool focused);
     virtual void receivedFocus();
     virtual void removedFocus();
Index: trunk/src/lib/gui/gl/glgui_slider.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_slider.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_slider.cc	(revision 8717)
@@ -48,6 +48,7 @@
     this->setClassID(CL_GLGUI_SLIDER, "GLGuiSlider");
 
-    this->setClickable( );
-    this->setFocusable( );
+    this->setClickable(true);
+    this->setFocusable(true);
+    this->setSelectable(true);
 
     this->_value = 0.0;
@@ -193,7 +194,7 @@
   }
 
-  void GLGuiSlider::releasing(const Vector2D& pos)
-  {
-    GLGuiWidget::releasing(pos);
+  void GLGuiSlider::releasing(const Vector2D& pos, bool focused)
+  {
+    GLGuiWidget::releasing(pos, focused);
     this->grabbed = false;
   }
@@ -202,5 +203,4 @@
   {
     GLGuiWidget::removedFocus();
-    this->grabbed = false;
   }
 
Index: trunk/src/lib/gui/gl/glgui_slider.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_slider.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_slider.h	(revision 8717)
@@ -59,5 +59,5 @@
 
     virtual void clicking(const Vector2D& pos);
-    virtual void releasing(const Vector2D& pos);
+    virtual void releasing(const Vector2D& pos, bool focused);
     virtual void removedFocus();
 
Index: trunk/src/lib/gui/gl/glgui_table.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_table.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_table.cc	(revision 8717)
@@ -19,4 +19,6 @@
 #include "debug.h"
 
+#include "glgui_handler.h"
+
 namespace OrxGui
 {
@@ -25,6 +27,8 @@
    */
   GLGuiTable::GLGuiTable (unsigned int rows, unsigned int columns)
+  : _selected(-1, -1), _focused(-1, -1)
   {
     this->init();
+
     this->setRowCount(rows);
     this->setColumnCount(columns);
@@ -45,8 +49,9 @@
     this->setClassID(CL_GLGUI_TABLE, "GLGuiTable");
 
+    this->setBorderTop(10);
+
     this->setFocusable(true);
     this->setClickable(true);
 
-    this->resize();
   }
 
@@ -56,4 +61,7 @@
 
     unsigned int currentRowCount = this->rowCount();
+
+    this->_rowHeights.resize(rowCount, 20);
+
     this->_entries.resize(rowCount);
     for (unsigned int i = currentRowCount; i < this->rowCount(); ++i)
@@ -65,5 +73,8 @@
 
     assert(this->checkIntegrity());
-    this->debug();
+    this->repositionText(currentRowCount, 0);
+
+
+    this->resize();
 
     if (!this->isVisible())
@@ -75,4 +86,6 @@
     unsigned int i;
     unsigned int currentColumnCount = this->columnCount();
+
+    this->_columnWidths.resize(columnCount, 100);
 
     // setup Headers.
@@ -89,6 +102,8 @@
     }
     assert(this->checkIntegrity());
-    this->debug();
-
+
+    this->repositionText(0, currentColumnCount);
+
+    this->resize();
     if (!this->isVisible())
       this->hiding();
@@ -111,5 +126,5 @@
   }
 
-  void GLGuiTable::setEntry(unsigned int column, unsigned int row, const std::string& name)
+  void GLGuiTable::setEntry(unsigned int row, unsigned int column, const std::string& name)
   {
     if (column >= this->columnCount() )
@@ -125,6 +140,7 @@
     for (unsigned int i = 0; i < this->rowCount(); ++i)
       this->_entries[i][column].setLineWidth(size);
-
-  }
+  }
+
+
 
   /// TODO.
@@ -144,5 +160,4 @@
 
 
-
   /**
    * @brief Processes an Event.
@@ -152,4 +167,10 @@
   bool GLGuiTable::processEvent(const Event& event)
   {
+    if (event.type == EV_MOUSE_MOTION)
+    {
+      this->pixelPositionToElement((OrxGui::GLGuiHandler::getInstance()->cursorPositionRel(this)), &this->_focused.row, &this->_focused.column);
+      return true;
+    }
+
     return false;
   }
@@ -161,4 +182,15 @@
   void GLGuiTable::resize()
   {
+    Vector2D size;
+    unsigned int i;
+    for(i = 0; i < this->columnCount(); ++i)
+      size.x += this->_columnWidths[i];
+
+    for(i = 0; i < this->rowCount(); ++i)
+      size.y += this->_rowHeights[i];
+
+    this->setSize2D(size);
+    this->setSize2D( size + Vector2D(borderLeft() + borderRight(), borderTop() + borderBottom()));
+
     GLGuiWidget::resize();
   }
@@ -172,4 +204,5 @@
         this->_entries[j][i].setColor(this->foregroundColor());
     }
+
   }
 
@@ -196,11 +229,4 @@
 
   /**
-   * @brief ticks the Table
-   * @param dt the time passed.
-   */
-  void GLGuiTable::tick(float dt)
-{}
-
-  /**
    * @brief draws the GLGuiTable
    */
@@ -210,10 +236,88 @@
     GLGuiWidget::draw();
 
-    //     this->frontMaterial().select();
-    //     GLGuiWidget::drawRect(this->frontRect());
+    float columnPos = this->borderLeft();
+    float rowPos = this->borderTop();
+
+    unsigned int i;
+    glColor4fv(&this->foregroundColor()[0]);
+    glLineWidth(1.5);
+    glBegin(GL_LINES);
+
+    glVertex2f(columnPos, this->borderTop());
+    glVertex2f(columnPos, this->getSizeY2D());
+    for (i = 0; i < this->columnCount(); ++i)
+    {
+      columnPos +=this->_columnWidths[i];
+      glVertex2f(columnPos, this->borderTop());
+      glVertex2f(columnPos, this->getSizeY2D());
+    }
+
+    glVertex2f(this->borderLeft(), rowPos);
+    glVertex2f(this->getSizeX2D(), rowPos);
+    for (i = 0; i < this->rowCount(); ++i)
+    {
+      rowPos +=this->_rowHeights[i];
+      glVertex2f(this->borderLeft(), rowPos);
+      glVertex2f(this->getSizeX2D(), rowPos);
+    }
+
+
+    glEnd();
+
+
 
     this->endDraw();
   }
 
+
+  void GLGuiTable::pixelPositionToElement(const Vector2D& pixelPosition, int* row, int* column)
+  {
+    *row = 0;
+    *column = 0;
+    float columnPos = this->borderLeft();
+    float rowPos = this->borderTop();
+
+    for (*row = 0; *row < (int)this->rowCount(); (*row)++)
+    {
+      if (pixelPosition.y > rowPos  && pixelPosition.y  < (rowPos += _rowHeights[*row]))
+        break;
+    }
+    for (*column = 0; *column < (int)this->columnCount(); (*column)++)
+    {
+      if (pixelPosition.x > columnPos && pixelPosition.x  < (columnPos += _columnWidths[*column]))
+        break;
+    }
+
+    PRINTF(3)("Mouse Over row:%d Column:%d\n", *row, *column);
+  }
+
+
+  void GLGuiTable::repositionText(unsigned int fromLeft, unsigned int fromTop)
+  {
+    float columnPos = this->borderLeft();
+    float rowPos = this->borderTop();
+    unsigned int i, j;
+    for (i = 0; i< fromLeft; ++i)
+      columnPos+=this->_columnWidths[i];
+    for (i = 0; i < fromTop; ++i)
+      rowPos += this->_rowHeights[i];
+
+    for (i = fromLeft; i < this->columnCount(); ++i)
+    {
+      this->_headers[i].setRelCoor2D(columnPos, rowPos);
+
+      // not required, but a good idea :)
+      this->_headers[i].setLineWidth(_columnWidths[i]);
+
+      float rowPosI = rowPos;
+      for (j = fromTop; j < this->rowCount(); ++j)
+      {
+        this->_entries[j][i].setRelCoor2D(columnPos, rowPosI);
+        this->_entries[j][i].setLineWidth(_columnWidths[i]);
+        rowPosI += _rowHeights[j];
+      }
+      columnPos+=this->_columnWidths[i];
+    }
+  }
 
   /**
@@ -224,6 +328,7 @@
   {
     text->setSize(this->textSize());
-    //text->setLineWidth(  );
+    text->setLineWidth( this->_columnWidths[column] );
     text->setFont("fonts/final_frontier.ttf", (int)this->textSize());
+    text->setColor(this->foregroundColor());
 
     text->setColor(this->foregroundColor());
@@ -257,8 +362,8 @@
     for (unsigned int i = 0; i < this->rowCount(); ++i)
       if (this->_entries[i].size() != this->columnCount())
-    {
-      PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount());
-      retVal = false;
-    }
+      {
+        PRINTF(1)("COLUMN-COUNT OF ROW %d WRONG (is %d should be %d)\n", i, this->_entries[i].size(), this->columnCount());
+        retVal = false;
+      }
     return retVal;
   }
Index: trunk/src/lib/gui/gl/glgui_table.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_table.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_table.h	(revision 8717)
@@ -39,10 +39,9 @@
     void setHeader(const std::vector<std::string>& headerNames);
 
-    void setEntry(unsigned int column, unsigned int row, const std::string& name);
+    void setEntry(unsigned int row, unsigned int column, const std::string& name);
 
     void setColumnWidth(unsigned int column, float size);
     void setRowHeight(unsigned int row, unsigned int size);
 
-    virtual void tick(float dt);
     virtual void draw() const;
 
@@ -60,15 +59,28 @@
     virtual bool processEvent(const Event& event);
 
-
   private:
     void init();
 
+    void pixelPositionToElement(const Vector2D& pixelPosition, int* row, int* column);
+    void repositionText(unsigned int fromLeft, unsigned int fromTop);
     void applyTextSettings(unsigned int row, unsigned int column, LimitedWidthText* text);
     bool checkIntegrity() const;
 
   private:
+    typedef struct Entry {
+      Entry(int row, int column) :row(row), column(column) {};
+      int  row;
+      int  column;
+    };
+
     typedef std::vector<LimitedWidthText> TableTextList;
     TableTextList                _headers;
+    std::vector<float>           _columnWidths;
+    std::vector<float>           _rowHeights;
+
     std::vector<TableTextList>   _entries;     //!< inner is by column, outer is by row.
+
+    Entry                        _selected;
+    Entry                        _focused;
 
 
Index: trunk/src/lib/gui/gl/glgui_widget.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_widget.cc	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_widget.cc	(revision 8717)
@@ -72,10 +72,12 @@
   GLGuiWidget::~GLGuiWidget()
   {
-    if (this == GLGuiWidget::_focused)
-      GLGuiWidget::_focused = NULL;
+    if (this == GLGuiWidget::_mouseFocused)
+      GLGuiWidget::_mouseFocused = NULL;
+    if (this == GLGuiWidget::selected())
+      this->unselect();
   }
 
   GLGuiWidget* GLGuiWidget::_selected = NULL;
-  GLGuiWidget* GLGuiWidget::_focused = NULL;
+  GLGuiWidget* GLGuiWidget::_mouseFocused = NULL;
   GLGuiWidget* GLGuiWidget::_inputGrabber = NULL;
 
@@ -91,4 +93,5 @@
     this->_focusable = false;
     this->_clickable = false;
+    this->_selectable = false;
     this->_pushed = false;
     this->_state = OrxGui::Normal;
@@ -133,42 +136,84 @@
   }
 
+
+  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
+  {
+    this->_currentStyle._foreground.setDiffuseColor(frontColor);
+    this->animateBack();
+  };
+
+
+  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
+  {
+    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
+        this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
+  }
+
+  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
+  {
+    return this->focusOverWidget(cursor->getAbsCoor2D());
+  }
+
+
+
   /** @brief gives focus to this widget */
-  void GLGuiWidget::giveFocus()
-  {
-    if (GLGuiWidget::focused() != NULL)
-      GLGuiWidget::focused()->breakFocus();
-    GLGuiWidget::_focused = this;
+  void GLGuiWidget::giveMouseFocus()
+  {
+    if (this->_state == OrxGui::Insensitive)
+      return ;
+
+    if (GLGuiWidget::mouseFocused() != NULL)
+      GLGuiWidget::mouseFocused()->breakMouseFocus();
+    GLGuiWidget::_mouseFocused = this;
+
+    this->switchState(OrxGui::Focused);
+
     this->receivedFocus();
   };
 
-  void GLGuiWidget::breakFocus()
-  {
-    if (GLGuiWidget::_focused == this)
+  void GLGuiWidget::breakMouseFocus()
+  {
+    if (GLGuiWidget::_mouseFocused == this)
     {
-      GLGuiWidget::_focused = NULL;
-      this->_pushed = false;
+      GLGuiWidget::_mouseFocused = NULL;
+
+      if (GLGuiWidget::_selected != this)
+        this->switchState(OrxGui::Normal);
+      else
+        this->switchState(OrxGui::Selected);
+
       this->removedFocus();
     }
   };
 
-
-  bool GLGuiWidget::focusOverWidget(const Vector2D& position) const
-  {
-    return (this->getAbsCoor2D().x < position.x && this->getAbsCoor2D().x + this->getSizeX2D() > position.x &&
-            this->getAbsCoor2D().y < position.y && this->getAbsCoor2D().y + this->getSizeY2D() > position.y);
-  }
-
-  bool GLGuiWidget::focusOverWidget(const GLGuiCursor* const cursor) const
-  {
-    return this->focusOverWidget(cursor->getAbsCoor2D());
-  }
-
-
-
-  void GLGuiWidget::setFrontColor(const Color& frontColor, bool instantaniously)
-  {
-    this->_currentStyle._foreground.setDiffuseColor(frontColor);
-    this->animateBack();
-  };
+  /**
+   * @brief selects the Widget, unselecting the old one (if existing)
+   */
+  void GLGuiWidget::select()
+  {
+    if (GLGuiWidget::_selected != NULL)
+      GLGuiWidget::selected()->unselect();
+    GLGuiWidget::_selected = this;
+
+    this->switchState(OrxGui::Selected);
+  }
+
+  /**
+   * @brief unselects the current Widget.
+   *
+   * if the current Widget is not selected, nothing is done here.
+   */
+  void GLGuiWidget::unselect()
+  {
+    if (GLGuiWidget::_selected != this)
+      return;
+
+    if (GLGuiWidget::_mouseFocused == this)
+      this->switchState(OrxGui::Focused);
+    else
+      this->switchState(OrxGui::Normal);
+
+    GLGuiWidget::_selected = NULL;
+  }
 
 
@@ -193,5 +238,5 @@
     if (this->_pushed)
     {
-      this->releasing(pos);
+      this->releasing(pos, GLGuiWidget::_mouseFocused == this);
       this->_pushed = false;
     }
@@ -200,27 +245,30 @@
 
   void GLGuiWidget::clicking(const Vector2D& pos)
-  {
-    this->switchState(OrxGui::Selected);
-  }
-
-  void GLGuiWidget::releasing(const Vector2D& pos)
-  {
-    this->switchState(OrxGui::Normal);
-  }
+  {}
+
+  void GLGuiWidget::releasing(const Vector2D& pos, bool focused)
+  {}
 
   void GLGuiWidget::receivedFocus()
   {
-    this->switchState(OrxGui::Focused);
   }
 
   void GLGuiWidget::removedFocus()
   {
-    this->switchState(OrxGui::Normal);
-
-  }
-
-  void GLGuiWidget::destroyed()
-  {}
-  ;
+
+  }
+
+  void GLGuiWidget::selecting()
+  {
+  }
+
+  void GLGuiWidget::unselecting()
+  {
+  }
+
+
+  void GLGuiWidget::destroying()
+  {
+  }
 
 
@@ -706,5 +754,5 @@
     //this->_currentStyle = this->_style[state];
     this->_state = state;
-    PRINTF(3)("Switching to state %s\n", OrxGui::StateString[state].c_str());
+    PRINTF(3)("%s::%s Switches to state %s\n", this->getClassName(), this->getName(), OrxGui::StateString[state].c_str());
 
     this->animateBack();
@@ -762,8 +810,8 @@
     for (unsigned int i = 0; i < GLGUI_STATE_COUNT; ++i)
       if (stateName == OrxGui::StateString[i])
-    {
-      *state = (OrxGui::State)i;
-      return true;
-    }
+      {
+        *state = (OrxGui::State)i;
+        return true;
+      }
     return false;
   }
@@ -772,5 +820,5 @@
    * @brief print out some nice debug output about the Widget.
    */
-  void GLGuiWidget::debug() const
+  void GLGuiWidget::debug(unsigned int level) const
   {
     PRINT(0)("Debug of %s::%s - WidgetPart ", this->getClassName(), this->getName());
Index: trunk/src/lib/gui/gl/glgui_widget.h
===================================================================
--- trunk/src/lib/gui/gl/glgui_widget.h	(revision 8711)
+++ trunk/src/lib/gui/gl/glgui_widget.h	(revision 8717)
@@ -42,11 +42,10 @@
 
     /// FOCUS
-    /** @brief gives focus to this widget */
-    void giveFocus();
-    void breakFocus();
+    /** @brief gives mouse - focus to this widget */
+    void giveMouseFocus();
+    void breakMouseFocus();
+
     /** @returns true if the widget is focusable */
     bool focusable() const { return this->_focusable; };
-    /** @param focusable sets if the Widget should be focusable */
-    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
     /** @returns true if the position is inside of the Widget. @param position the position to check */
     bool focusOverWidget(const Vector2D& position) const;
@@ -54,13 +53,21 @@
     bool focusOverWidget(const OrxGui::GLGuiCursor* const cursor) const;
 
-    /** @returns the currently focused Widget (NULL if none is selected) */
-    static GLGuiWidget* focused() { return GLGuiWidget::_focused; };
-
+    /** @returns the currently mouse - focused Widget (NULL if none is focused). */
+    static GLGuiWidget* mouseFocused() { return GLGuiWidget::_mouseFocused; };
+
+    /// SELECT
+    void select();
+    void unselect();
+    /** @returns true if the Widget is selectable */
+    bool selectable() const { return this->_selectable; }
+
+    /** @returns the currently Selected Widget (NULL if none is selected). */
+    static GLGuiWidget* selected() { return GLGuiWidget::_selected; };
 
     /// CLICK
+    bool pushed() { return _pushed; };
     void click(const Vector2D& pos);
     void release(const Vector2D& pos);
     bool clickable() const { return this->_clickable; };
-    void setClickable(bool clickable = true) { this->_clickable = clickable; };
 
     static void connect(GLGuiWidget* sender, Signal& signal, BaseObject* receiver, Slot executor);
@@ -81,5 +88,6 @@
     void animateBack();
 
-    /// STYLE
+    ///////////////////////////////////////////////////////////////////////////////////
+    /// STYLE /////////////////////////////////////////////////////////////////////////
     ////////////////////////////////
     /// Retrieve Current Values. ///
@@ -201,5 +209,5 @@
     void setAnimatedStateChanges(bool animated);
     void switchState(OrxGui::State state);
-
+    ///////////////////////////////////////////////////////////////////////////////////
 
 
@@ -225,4 +233,17 @@
 
   protected:
+    /** @param focusable sets if the Widget should be focusable */
+    void setFocusable(bool focusable = true) { this->_focusable = focusable; };
+    /** @param selectable true if the widget should be selectable */
+    void setSelectable(bool selectable) { this->_selectable = selectable; }
+    /** @param focusable true if the widget should be focusable */
+    void setClickable(bool clickable = true) { this->_clickable = clickable; };
+
+
+    /// RENDERING
+    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
+    inline void endDraw() const { glPopMatrix(); };
+
+
     /// LOOKS
     virtual void resize();
@@ -230,19 +251,23 @@
     virtual void hiding() {};
     virtual void showing() {};
+
     virtual void updateFrontColor() {};
 
-    inline void beginDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); };
-    inline void endDraw() const { glPopMatrix(); };
 
     /// EVENTS
-    // if something was clickt on the GUI-widget.
+    // mouse clicking
     virtual void clicking(const Vector2D& pos);
-    virtual void releasing(const Vector2D& pos);
+    virtual void releasing(const Vector2D& pos, bool focused);
+    // mouse focusing
     virtual void receivedFocus();
     virtual void removedFocus();
-
-    virtual void destroyed();
-
-    virtual void debug() const;
+    // selecting either with the mouse by clicking, or by the keybord traversing to it.
+    virtual void selecting();
+    virtual void unselecting();
+    // destroying the Widget.
+    virtual void destroying();
+
+
+    virtual void debug(unsigned int level) const;
 
   private:
@@ -251,6 +276,6 @@
   private:
     static GLGuiWidget*            _selected;         //!< The currently selected Widget.
-    static GLGuiWidget*            _focused;          //!< The currently Focused Widget.
-    static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input.
+    static GLGuiWidget*            _mouseFocused;     //!< The currently Focused Widget (mouse-focus).
+    static GLGuiWidget*            _inputGrabber;     //!< The Widget that grabs input (keyboard-focus).
 
 
@@ -265,9 +290,10 @@
     /// EVENTS
     OrxGui::State                  _state;
+    bool                           _pushed;
 
     bool                           _focusable;        //!< If this widget can receive focus.
     bool                           _clickable;        //!< if this widget can be clicked upon.
-
-    bool                           _pushed;
+    bool                           _selectable;       //!< If this widget can be selected.
+
 
 
@@ -276,31 +302,31 @@
     typedef struct
     {
-      float             _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
-      float             _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
-      float             _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
-      float             _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
-
-      float             _textSize;             //!< The TextSize of the Widget.
-
-      Material          _background;           //!< The Background Material of the Widget.
-
-      Material          _foreground;           //!< The foreground Material of the Widget.
+      float                        _borderLeft;           //!< The Distance to the left Border of the widget, before any internal Element starts.
+      float                        _borderRight;          //!< The Distance to the right Border of the widget, before any internal Element starts.
+      float                        _borderTop;            //!< The Distance to the top Border of the widget, before any internal Element starts
+      float                        _borderBottom;         //!< The Distance to the bottom Border of the widget, before any internal Element starts
+
+      float                        _textSize;             //!< The TextSize of the Widget.
+
+      Material                     _background;           //!< The Background Material of the Widget.
+
+      Material                     _foreground;           //!< The foreground Material of the Widget.
     }
     StatedStyle;
 
 
-    StatedStyle         _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States
-
-    FeaturePosition     _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
-    Font*               _font;                 //!< The Font used in the current Widget.
+    StatedStyle                    _style[GLGUI_STATE_COUNT]; //!< Styles configured for different States
+
+    FeaturePosition                _featurePosition;      //!< The Position a Feature will be layed at (checkbox(box), slider(text),...)
+    Font*                          _font;                 //!< The Font used in the current Widget.
 
 
     /// ANIMATION STUFF:
-    bool                _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
-
-    bool                _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
-    float               _animationCycle;
-    float               _animationDuration;
-    StatedStyle         _currentStyle;
+    bool                           _animatedStateChanges; //!< If the Transitions between States are Animated automatically.
+
+    bool                           _animating;            //!< If the Widget is animated at the moment (Texture might be an AnimatedTexture.)
+    float                          _animationCycle;
+    float                          _animationDuration;
+    StatedStyle                    _currentStyle;
 
   };
