int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

    // Set up Window
    TutorialWindow = createNativeWindow();
    TutorialWindow->initWindow();

    TutorialWindow->setDisplayCallback(display);
    TutorialWindow->setReshapeCallback(reshape);

    TutorialKeyListener TheKeyListener;
    TutorialWindow->addKeyListener(&TheKeyListener);

    // Make Torus Node (creates Torus in background of scene)
    NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);

    // Make Main Scene Node and add the Torus
    NodeRefPtr scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
        scene->addChild(TorusGeometryNode);

    // Create the Graphics
    GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();

    // Initialize the LookAndFeelManager to enable default settings
    LookAndFeelManager::the()->getLookAndFeel()->init();

    // Create a simple Font to be used with the ExampleTextArea
    UIFontRefPtr ExampleFont = OSG::UIFont::create();
        ExampleFont->setSize(16);

    /******************************************************


        Create and edit the TextArea and determine its 
        characteristics.  A TextArea is a component 
        that allows you to enter text into the box via 
        keyboard input.  You can select text by    using 
        your mouse or pressing shift and the left and 
        right arrow keys.

        The only difference between a TextArea and
        TextField is that a TextArea can have 
        multiple lines of text 
        within it.

        -setTextColor(Color4f): Determine color of 
            text within TextArea.
        -setSelectionBoxColor(Color4f): Determine the
			color that highlighting around the 
			selected text appears.
        -setSelectionTextColor(Color4f): Determine the 
            color the selected text appears.
        -setText("TextToBeDisplayed"): Determine  
            initial text within TextArea.
        -setFont(FontName): Determine the Font 
			used within TextArea
        -setSelectionStart(StartCharacterNumber):
            Determine the character which the 
            selection will initially start after.
        -setSelectionEnd(EndCharacterNumber): 
            Determine the character which the 
            selection will end before.
        -setCaretPosition(Location): Determine the 
            location of the Caret within the TextArea.
			Note: this does not do too much
            currently because the only way 
            to cause the TextArea to gain focus is
            to click within it, causing the 
            Caret to move.
            
    ******************************************************/

    // Create a TextArea component
    TextAreaRefPtr ExampleTextArea = OSG::TextArea::create();

        ExampleTextArea->setPreferredSize(Vec2f(300, 200));
        ExampleTextArea->setMinSize(Vec2f(300, 200));
        ExampleTextArea->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
        ExampleTextArea->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
        ExampleTextArea->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
        // Determine the font and initial text
        ExampleTextArea->setText("What");
        ExampleTextArea->setFont(ExampleFont);
        // This will select the "a" from above
        ExampleTextArea->setSelectionStart(2);
        ExampleTextArea->setSelectionEnd(3);
        ExampleTextArea->setCaretPosition(2);
        //ExampleTextArea->setLineWrap(false);
        
    // Create a ScrollPanel
    ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
        TextAreaScrollPanel->setPreferredSize(Vec2f(200,200));
        TextAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
	TextAreaScrollPanel->setViewComponent(ExampleTextArea);

    
    // Create The Main InternalWindow
    // Create Background to be used with the Main InternalWindow
    ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

    LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();

    InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
       MainInternalWindow->pushToChildren(TextAreaScrollPanel);
       MainInternalWindow->setLayout(MainInternalWindowLayout);
       MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
	   MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
	   MainInternalWindow->setDrawTitlebar(false);
	   MainInternalWindow->setResizable(false);

    // Create the Drawing Surface
    UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
        TutorialDrawingSurface->setGraphics(TutorialGraphics);
        TutorialDrawingSurface->setEventProducer(TutorialWindow);
	
	TutorialDrawingSurface->openWindow(MainInternalWindow);

    // Create the UI Foreground Object
    UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();

        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


    // Create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // Tell the Manager what to manage
    mgr->setWindow(TutorialWindow);
    mgr->setRoot(scene);

    // Add the UI Foreground Object to the Scene
    ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
        TutorialViewport->addForeground(TutorialUIForeground);

    // Show the whole Scene
    mgr->showAll();


    //Open Window
    Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
    Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
    TutorialWindow->openWindow(WinPos,
            WinSize,
            "22TextArea");

    //Enter main Loop
    TutorialWindow->mainLoop();

    osgExit();

    return 0;
}
void LuaDebuggerInterface::createUtilTabs(void)
{
    //Create the Error Text Area
    _ErrorTextArea = TextArea::create();

    _ErrorTextArea->setPreferredSize(Vec2f(600, 150));
    _ErrorTextArea->setText("");
    _ErrorTextArea->setMinSize(Vec2f(300, 150));
    _ErrorTextArea->setFont(_CodeFont);
    _ErrorTextArea->setTextColors(Color4f(0.2,0.0,0.0,1.0));
    _ErrorTextArea->setEditable(false);
    setName(_ErrorTextArea,"Error TextArea");
    TheLuaManager->connectLuaError(boost::bind(&LuaDebuggerInterface::handlLuaError,
                                                this,
                                                _1));

    // Create a ScrollPanel
    ScrollPanelRefPtr ErrorAreaScrollPanel = ScrollPanel::create();
    ErrorAreaScrollPanel->setPreferredSize(Vec2f(200,150));
    ErrorAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
    ErrorAreaScrollPanel->setViewComponent(_ErrorTextArea);

    //Create the StackTrace Text Area
    _StackTraceTextArea = TextArea::create();

    _StackTraceTextArea->setPreferredSize(Vec2f(600, 150));
    _StackTraceTextArea->setText("");
    _StackTraceTextArea->setMinSize(Vec2f(300, 150));
    _StackTraceTextArea->setFont(_CodeFont);
    _StackTraceTextArea->setTextColors(Color4f(0.2,0.0,0.0,1.0));
    _StackTraceTextArea->setEditable(false);
    setName(_StackTraceTextArea,"Stack Trace TextArea");

    // Create a ScrollPanel
    ScrollPanelRefPtr StackTraceAreaScrollPanel = ScrollPanel::create();
    StackTraceAreaScrollPanel->setPreferredSize(Vec2f(200,150));
    StackTraceAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
    StackTraceAreaScrollPanel->setViewComponent(_StackTraceTextArea);

    //Create the Message Text Area
    _MessageTextArea = TextArea::create();

    _MessageTextArea->setPreferredSize(Vec2f(600, 150));
    _MessageTextArea->setText("");
    _MessageTextArea->setMinSize(Vec2f(300, 150));
    _MessageTextArea->setFont(_CodeFont);
    _MessageTextArea->setTextColors(Color4f(0.2,0.0,0.0,1.0));
    _MessageTextArea->setEditable(false);
    setName(_MessageTextArea,"Message TextArea");

    // Create a ScrollPanel
    ScrollPanelRefPtr MessageAreaScrollPanel = ScrollPanel::create();
    MessageAreaScrollPanel->setPreferredSize(Vec2f(200,150));
    MessageAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
    MessageAreaScrollPanel->setViewComponent(_MessageTextArea);

    //Create the Message Text Area
    _HelpTextArea = TextArea::create();

    _HelpTextArea->setPreferredSize(Vec2f(600, 150));
    _HelpTextArea->setText("");
    _HelpTextArea->setMinSize(Vec2f(300, 150));
    _HelpTextArea->setFont(_CodeFont);
    _HelpTextArea->setTextColors(Color4f(0.2,0.0,0.0,1.0));
    _HelpTextArea->setEditable(false);
    setName(_HelpTextArea,"Help TextArea");

    // Create a ScrollPanel
    ScrollPanelRefPtr HelpAreaScrollPanel = ScrollPanel::create();
    HelpAreaScrollPanel->setPreferredSize(Vec2f(200,150));
    HelpAreaScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
    // Add the TextArea to the ScrollPanel so it is displayed
    HelpAreaScrollPanel->setViewComponent(_HelpTextArea);

    //Tab Panel
    LabelRefPtr MessageTabLabel = Label::create();
    MessageTabLabel->setText("Output");

    LabelRefPtr ErrorTabLabel = Label::create();
    ErrorTabLabel->setText("Error");

    LabelRefPtr StackTraceTabLabel = Label::create();
    StackTraceTabLabel->setText("Stack");

    LabelRefPtr HelpTabLabel = Label::create();
    HelpTabLabel->setText("Help");

    _InfoTabPanel = TabPanel::create();
    _InfoTabPanel->addTab(MessageTabLabel, MessageAreaScrollPanel);
    _InfoTabPanel->addTab(ErrorTabLabel, ErrorAreaScrollPanel);
    _InfoTabPanel->addTab(StackTraceTabLabel, StackTraceAreaScrollPanel);
    _InfoTabPanel->addTab(HelpTabLabel, HelpAreaScrollPanel);
#ifdef OSG_WITH_LUA_DEBUGGER
    addIntrospectionTreeTab(_InfoTabPanel);
#endif
    _InfoTabPanel->setTabAlignment(0.5f);
    _InfoTabPanel->setTabPlacement(TabPanel::PLACEMENT_NORTH);
    _InfoTabPanel->setSelectedIndex(0);
    setName(_InfoTabPanel,"Info Tab Panel");
}