Index: /code/branches/chat2/data/gui/layouts/ChatBox.layout
===================================================================
--- /code/branches/chat2/data/gui/layouts/ChatBox.layout	(revision 6845)
+++ /code/branches/chat2/data/gui/layouts/ChatBox.layout	(revision 6846)
@@ -8,74 +8,19 @@
         <Window Type="MenuWidgets/FrameWindow" Name="/ChatBox" >
             <Property Name="Text" Value="Chat" />
-            <Property Name="TitlebarFont" Value="Commonwealth-10" />
             <Property Name="InheritsAlpha" Value="False" />
             <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
             <Property Name="TitlebarEnabled" Value="True" />
             <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.03,0},{0.6,0},{0.69375,0}}" />
-            <Window Type="MenuWidgets/Listbox" Name="/ChatBox/List" >
+            <Window Type="MenuWidgets/Listbox" Name="orxonox/ChatBox/history" >
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.078,0},{0.98,0},{1,-30}}" />
             </Window>
-            <!--<Window Type="MenuWidgets/Editbox" Name="/ChatBox/Text" >-->
-                <!--<Property Name="Text" Value="Error: you did not register any font or none were valid" />-->
-                <!--<Property Name="MaxTextLength" Value="1073741823" />-->
-                <!--<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />-->
-                <!--<Property Name="UnifiedAreaRect" Value="{{0.02,0},{1,-30},{0.98,0},{1,-5}}" />-->
-            <!--</Window>-->
-            <Window Type="MenuWidgets/StaticText" Name="/ChatBox/Text" >
-                <Property Name="Text" Value="History" />
-                <Property Name="HorzFormatting" Value="RightAligned" />
+            <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox/input" >
+                <Property Name="Text" Value="" />
+                <Property Name="MaxTextLength" Value="1073741823" />
                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
                 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{1,-30},{0.98,0},{1,-5}}" />
             </Window>
         </Window>
-        <!--<Window Type="MenuWidgets/Editbox" Name="/ChatBox/History" >-->
-            <!--<Property Name="Text" Value="5" />-->
-            <!--<Property Name="MaxTextLength" Value="1073741823" />-->
-            <!--<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />-->
-            <!--<Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.03,0},{0.81,0},{0.1,0}}" />-->
-        <!--</Window>-->
-        <Window Type="MenuWidgets/StaticText" Name="/ChatBox/History" >
-            <Property Name="Text" Value="5" />
-            <Property Name="HorzFormatting" Value="RightAligned" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.03,0},{0.81,0},{0.1,0}}" />
-        </Window>
-        <Window Type="MenuWidgets/StaticText" Name="/ChatBox/HistoryLabel" >
-            <Property Name="Text" Value="History size:" />
-            <Property Name="HorzFormatting" Value="RightAligned" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.03,0},{0.77,0},{0.1,0}}" />
-        </Window>
-        <Window Type="MenuWidgets/StaticText" Name="/ChatBox/FonSizeLabel" >
-            <Property Name="Font" Value="Commonwealth-10" />
-            <Property Name="Text" Value="Font size:" />
-            <Property Name="HorzFormatting" Value="RightAligned" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.1,0},{0.77,0},{0.17,0}}" />
-        </Window>
-        <Window Type="MenuWidgets/Spinner" Name="/ChatBox/FontSize" >
-            <Property Name="Text" Value="10" />
-            <Property Name="StepSize" Value="1" />
-            <Property Name="CurrentValue" Value="10" />
-            <Property Name="MaximumValue" Value="72" />
-            <Property Name="MinimumValue" Value="-32768" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.1,0},{0.83,0},{0.17,0}}" />
-        </Window>
-        <Window Type="MenuWidgets/StaticText" Name="/ChatBox/FontNameLabel" >
-            <Property Name="Font" Value="Commonwealth-10" />
-            <Property Name="Text" Value="Font name:" />
-            <Property Name="HorzFormatting" Value="RightAligned" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.17,0},{0.77,0},{0.24,0}}" />
-        </Window>
-        <Window Type="MenuWidgets/Combobox" Name="/ChatBox/FontName" >
-            <Property Name="Text" Value="ChatBoxFont" />
-            <Property Name="ReadOnly" Value="True" />
-            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
-            <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.17,0},{0.99,0},{0.45,0}}" />
-            <Property Name="MaxEditTextLength" Value="1073741823" />
-        </Window>
     </Window>
 </GUILayout>
Index: /code/branches/chat2/data/gui/scripts/ChatBox.lua
===================================================================
--- /code/branches/chat2/data/gui/scripts/ChatBox.lua	(revision 6846)
+++ /code/branches/chat2/data/gui/scripts/ChatBox.lua	(revision 6846)
@@ -0,0 +1,5 @@
+-- ChatBox.lua
+
+local P = createMenuSheet("ChatBox")
+return P
+
Index: /code/branches/chat2/src/orxonox/ChatHistory.cc
===================================================================
--- /code/branches/chat2/src/orxonox/ChatHistory.cc	(revision 6845)
+++ /code/branches/chat2/src/orxonox/ChatHistory.cc	(revision 6846)
@@ -80,5 +80,5 @@
     std::string text;
 
-    COUT(0) << "Meow.\n";
+    //COUT(0) << "Meow.\n";
 
 #ifndef CHATTEST
Index: /code/branches/chat2/src/orxonox/ChatInputHandler.cc
===================================================================
--- /code/branches/chat2/src/orxonox/ChatInputHandler.cc	(revision 6845)
+++ /code/branches/chat2/src/orxonox/ChatInputHandler.cc	(revision 6846)
@@ -31,4 +31,11 @@
 #include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
+#include "core/CorePrereqs.h"
+#include <CEGUIWindow.h>
+#include <CEGUI/elements/CEGUIListbox.h>
+#include <CEGUI/elements/CEGUIListboxItem.h>
+#include <CEGUI/elements/CEGUIListboxTextItem.h>
+#include <CEGUIWindowManager.h>
 #include <string>
 
@@ -40,4 +47,5 @@
     true );
 
+
   /* constructor */
   ChatInputHandler::ChatInputHandler()
@@ -48,4 +56,8 @@
     /* create necessary objects */
     this->inpbuf = new InputBuffer();
+    assert( this->inpbuf != NULL );
+
+    /* MARK add generation of ChatBox thingy here */
+    GUIManager::getInstance().loadGUI( "ChatBox" );
 
     /* configure the input buffer */
@@ -62,26 +74,34 @@
   void ChatInputHandler::configureInputBuffer()
   {
-	  /* input has changed */
+    /* input has changed */
     this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
-		
-		/* add a line */
+
+    /* add a line */
     this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
     this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
 
-		/* backspace */
+    /* backspace */
     this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
     this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
 
-		/* exit the chatinputhandler thingy (tbd) */
+    /* exit the chatinputhandler thingy (tbd) */
     this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
 
-		/* delete character */
+    /* delete character */
     this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
 
-		/* cursor movement */
+    /* cursor movement */
     this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
     this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
     this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
     this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
+
+    /* get window pointers */
+    input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
+    CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
+    lb_history = dynamic_cast<CEGUI::Listbox*>(history); 
+
+    /* assert wee */
+    assert( lb_history );
   }
 
@@ -94,6 +114,9 @@
   {
     /* start listening */
-    COUT(0) << "chatinput activated." << std::endl;
+    //COUT(0) << "chatinput activated." << std::endl;
     InputManager::getInstance().enterState("chatinput");
+
+    /* MARK add spawning of chat widget stuff here.*/
+    GUIManager::getInstance().showGUI( "ChatBox" );
   }
 
@@ -102,22 +125,38 @@
     /* stop listening */
     InputManager::getInstance().leaveState("chatinput");
-  }
-
-
+
+    /* MARK add un-spawning of chat widget stuff here. */
+    GUIManager::getInstance().hideGUI( "ChatBox" );
+  }
 
   /* callbacks for InputBuffer */
   void ChatInputHandler::inputChanged()
   {
-
+    /* update the cursor and the window */
+    std::string raw = this->inpbuf->get();
+    
+    /* get string before cursor */
+    std::string left = raw.substr( 0, this->inpbuf->getCursorPosition() );
+
+    /* see if there's a string after the cursor */
+    std::string right = "";
+    if( raw.length() >= left.length()+1 )
+      right = raw.substr( this->inpbuf->getCursorPosition() );
+      
+    /* set the text */
+    this->input->setProperty( "Text", left + "|" + right );
   }
 
   void ChatInputHandler::addline()
   {
-    /* MARK MARK */
-
     /* actually do send what was input */
     /* a) get the string out of the inputbuffer */
     std::string msgtosend = this->inpbuf->get();
 
+    if( msgtosend.length() == 0 )
+    { this->deactivate();
+      return;
+    }
+
     /* b) clear the input buffer */
     if (this->inpbuf->getSize() > 0)
@@ -129,40 +168,34 @@
     /* d) stop listening to input  */
     this->deactivate();
+
+    /* e) create item and add to history */
+    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( msgtosend );
+    this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+    this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+
+    /* f) make sure the history handles it */
+    this->lb_history->handleUpdatedItemData();
   }
 
   void ChatInputHandler::backspace()
-  {
-    this->inpbuf->removeBehindCursor();
-  }
+  { this->inpbuf->removeBehindCursor(); }
 
   void ChatInputHandler::deleteChar()
-  {
-    this->inpbuf->removeAtCursor();
-  }
+  { this->inpbuf->removeAtCursor(); }
 
   void ChatInputHandler::cursorRight()
-  {
-    this->inpbuf->increaseCursor();
-  }
+  { this->inpbuf->increaseCursor(); }
   
   void ChatInputHandler::cursorLeft()
-  {
-    this->inpbuf->decreaseCursor();
-  }
+  { this->inpbuf->decreaseCursor(); }
   
   void ChatInputHandler::cursorEnd()
-  {
-    this->inpbuf->setCursorToEnd();
-  }
+  { this->inpbuf->setCursorToEnd(); }
 
   void ChatInputHandler::cursorHome()
-  {
-    this->inpbuf->setCursorToBegin();
-  }
+  { this->inpbuf->setCursorToBegin(); }
 
   void ChatInputHandler::exit()
-  {
-
-  }
+  { }
 
 }
Index: /code/branches/chat2/src/orxonox/ChatInputHandler.h
===================================================================
--- /code/branches/chat2/src/orxonox/ChatInputHandler.h	(revision 6845)
+++ /code/branches/chat2/src/orxonox/ChatInputHandler.h	(revision 6846)
@@ -36,4 +36,5 @@
 #include <iostream>
 #include <cassert>
+#include <CEGUIForwardRefs.h>
 
 /* project includes */
@@ -71,4 +72,8 @@
       static ChatInputHandler* singletonPtr_s;
 
+      /* cegui stuff */
+      CEGUI::Window *input;
+      CEGUI::Listbox *lb_history;
+
     public:
       /** constructor */
