ComponentTransitPtr createButtonedComp(Component* const LabelComp,
                                       const Button::ActionPerformedEventType::slot_type &listener)
{
    ButtonRecPtr CompRemoveButton = Button::create();
    CompRemoveButton->setText("-");
    //CompRemoveButton->setToolTipText("Remove");
    CompRemoveButton->setPreferredSize(Vec2f(17.0f,17.0f));
    CompRemoveButton->setAlignment(Vec2f(0.5f,0.5f));
    CompRemoveButton->setFont(dynamic_cast<Label*>(LabelComp)->getFont());

    //Connect
    CompRemoveButton->connectActionPerformed(listener);

    SpringLayoutRecPtr TreeCompLayout = SpringLayout::create();
    PanelRecPtr CompPanel = Panel::createEmpty();

    TreeCompLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, LabelComp, 0, SpringLayoutConstraints::NORTH_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, LabelComp, 0, SpringLayoutConstraints::SOUTH_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, LabelComp, 0, SpringLayoutConstraints::EAST_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, LabelComp, 0, SpringLayoutConstraints::WEST_EDGE, CompPanel);

    TreeCompLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, CompRemoveButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
    TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompRemoveButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

    CompPanel->setLayout(TreeCompLayout);
    CompPanel->pushToChildren(LabelComp);
    CompPanel->pushToChildren(CompRemoveButton);

    return ComponentTransitPtr(CompPanel);
}
ComponentTransitPtr LuaDebuggerInterface::generateSplitOptionListComponent(List* const Parent,
                                                     const boost::any& Value,
                                                     UInt32 Index,
                                                     bool IsSelected,
                                                     bool HasFocus)
{
    ButtonRecPtr TheComponent = Button::create();
    TheComponent->setBackgrounds(NULL);
    TheComponent->setAlignment(Vec2f(0.0f,0.5f));

    std::string ValueString;
    try
    {
        ValueString = boost::any_cast<std::string>(Value);

        BoostPath IconPath;
        if(ValueString.compare("Horizontal") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-left-right.png"));
        }
        else if(ValueString.compare("Vertical") == 0)
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-top-bottom.png"));
        }
        else
        {
            IconPath = BoostPath(_BaseIconDir / BoostPath("view-split-none.png"));
        }

        TheComponent->setImages(IconPath.string());
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }

    TheComponent->setText(ValueString);

    if(IsSelected)
    {
        LineBorderRecPtr LabelBorder = LineBorder::create();
        LabelBorder->setWidth(1.0f);
        LabelBorder->setColor(Color4f(0.0f,0.0f,0.0f,1.0f));
        TheComponent->setBorders(LabelBorder);
    }
    else
    {
        TheComponent->setBorders(NULL);
    }

    return ComponentTransitPtr(TheComponent);
}
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc,argv);

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

        // Create the SimpleSceneManager helper
        SimpleSceneManager sceneManager;
        TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager));
        TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager));

        // Tell the Manager what to manage
        sceneManager.setWindow(TutorialWindow);

        TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1));

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

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

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

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

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

          Create an Button Component and
          a simple Font.
          See 17Label_Font for more
          information about Fonts.

         ******************************************************/
        ButtonRecPtr ExampleButton = Button::create();

        UIFontRecPtr ExampleFont = UIFont::create();
        ExampleFont->setSize(16);

        ExampleButton->setMinSize(Vec2f(50, 25));
        ExampleButton->setMaxSize(Vec2f(200, 100));
        ExampleButton->setPreferredSize(Vec2f(100, 50));
        ExampleButton->setToolTipText("Button 1 ToolTip");

        ExampleButton->setText("Button 1");
        ExampleButton->setFont(ExampleFont);
        ExampleButton->setTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
        ExampleButton->setRolloverTextColor(Color4f(1.0, 0.0, 1.0, 1.0));
        ExampleButton->setActiveTextColor(Color4f(1.0, 0.0, 0.0, 1.0));
        ExampleButton->setAlignment(Vec2f(1.0,0.0));


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

          Create a ToggleButton and determine its 
          characteristics.  ToggleButton inherits
          off of Button, so all characteristsics
          used above can be used with ToggleButtons
          as well.

          The only difference is that when pressed,
          ToggleButton remains pressed until pressed 
          again.

          -setSelected(bool): Determine whether the 
          ToggleButton is Selected (true) or
          deselected (false).  

         ******************************************************/
        ToggleButtonRecPtr ExampleToggleButton = ToggleButton::create();

        ExampleToggleButton->setSelected(false);
        ExampleToggleButton->setText("ToggleMe");
        ExampleToggleButton->setToolTipText("Toggle Button ToolTip");


        // Create Background to be used with the MainInternalWindow
        ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create();
        MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));

        // Create The Internal Window
        InternalWindowRecPtr MainInternalWindow = InternalWindow::create();
        LayoutRecPtr MainInternalWindowLayout = FlowLayout::create();
        // Assign the Button to the MainInternalWindow so it will be displayed
        // when the view is rendered.
        MainInternalWindow->pushToChildren(ExampleButton);
        MainInternalWindow->setLayout(MainInternalWindowLayout);
        MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow->setPosition(Pnt2f(50,50));
        MainInternalWindow->setPreferredSize(Vec2f(300,300));
        MainInternalWindow->setTitle(std::string("Internal Window 1"));

        // Create The Internal Window
        InternalWindowRecPtr MainInternalWindow2 = InternalWindow::create();
        LayoutRecPtr MainInternalWindowLayout2 = FlowLayout::create();
        // Assign the Button to the MainInternalWindow so it will be displayed
        // when the view is rendered.
        MainInternalWindow2->pushToChildren(ExampleToggleButton);
        MainInternalWindow2->setLayout(MainInternalWindowLayout2);
        MainInternalWindow2->setBackgrounds(MainInternalWindowBackground);
        MainInternalWindow2->setPosition(Pnt2f(150,150));
        MainInternalWindow2->setPreferredSize(Vec2f(300,300));
        MainInternalWindow2->setTitle(std::string("Allways on top window"));
        MainInternalWindow2->setIconable(false);
        MainInternalWindow2->setAllwaysOnTop(true);

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

        TutorialDrawingSurface->openWindow(MainInternalWindow);
        TutorialDrawingSurface->openWindow(MainInternalWindow2);
        // Create the UI Foreground Object
        UIForegroundRecPtr TutorialUIForeground = UIForeground::create();
        TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);


        // Tell the Manager what to manage
        sceneManager.setRoot(scene);

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

        // Show the whole Scene
        sceneManager.showAll();


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

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

    osgExit();

    return 0;
}
void LuaDebuggerInterface::createExecutionToolbar(void)
{
    //Execute Button
    BoostPath ExecuteIconPath(_BaseIconDir / BoostPath("execute.png"));
    BoostPath ExecuteDisabledIconPath(_BaseIconDir / BoostPath("execute-disabled.png"));
    _ExecuteButton = Button::create();
    _ExecuteButton->setPreferredSize(_ToolButtonSize);
    _ExecuteButton->setImages(ExecuteIconPath.string());
    _ExecuteButton->setDisabledImage(ExecuteDisabledIconPath.string());
    _ExecuteButton->setAlignment(Vec2f(0.5f,0.5f));
    _ExecuteButton->setToolTipText("Execute");
    _ExecuteButton->connectActionPerformed(boost::bind(&LuaDebuggerInterface::executeScriptButtonAction,this));

    //Step Into Button
    BoostPath StepInIconPath(_BaseIconDir / BoostPath("basicstepinto.png"));
    BoostPath StepInDisabledIconPath(_BaseIconDir / BoostPath("basicstepinto-disabled.png"));
    _StepInButton = Button::create();
    _StepInButton->setPreferredSize(_ToolButtonSize);
    _StepInButton->setImages(StepInIconPath.string());
    _StepInButton->setDisabledImage(StepInDisabledIconPath.string());
    _StepInButton->setAlignment(Vec2f(0.5f,0.5f));
    _StepInButton->setToolTipText("Step In");

    //Step Out Button
    BoostPath StepOutIconPath(_BaseIconDir / BoostPath("basicstepout.png"));
    BoostPath StepOutDisabledIconPath(_BaseIconDir / BoostPath("basicstepout-disabled.png"));
    _StepOutButton = Button::create();
    _StepOutButton->setPreferredSize(_ToolButtonSize);
    _StepOutButton->setImages(StepOutIconPath.string());
    _StepOutButton->setDisabledImage(StepOutDisabledIconPath.string());
    _StepOutButton->setAlignment(Vec2f(0.5f,0.5f));
    _StepOutButton->setToolTipText("Step Out");

    //Step Over Button
    BoostPath StepOverIconPath(_BaseIconDir / BoostPath("basicstepover.png"));
    BoostPath StepOverDisabledIconPath(_BaseIconDir / BoostPath("basicstepover-disabled.png"));
    _StepOverButton = Button::create();
    _StepOverButton->setPreferredSize(_ToolButtonSize);
    _StepOverButton->setImages(StepOverIconPath.string());
    _StepOverButton->setDisabledImage(StepOverDisabledIconPath.string());
    _StepOverButton->setAlignment(Vec2f(0.5f,0.5f));
    _StepOverButton->setToolTipText("Step Over");

    //Stop Button
    BoostPath StopExecutionIconPath(_BaseIconDir / BoostPath("stop.png"));
    BoostPath StopExecutionDisabledIconPath(_BaseIconDir / BoostPath("stop-disabled.png"));
    _StopExecutionButton = Button::create();
    _StopExecutionButton->setPreferredSize(_ToolButtonSize);
    _StopExecutionButton->setImages(StopExecutionIconPath.string());
    _StopExecutionButton->setDisabledImage(StopExecutionDisabledIconPath.string());
    _StopExecutionButton->setAlignment(Vec2f(0.5f,0.5f));
    _StopExecutionButton->setToolTipText("Stop");

    //Code Execution Toolbar
    //Layout
    FlowLayoutRecPtr ToolbarLayout = FlowLayout::create();
    ToolbarLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
    ToolbarLayout->setHorizontalGap(3.0f);
    ToolbarLayout->setMajorAxisAlignment(0.0f);
    ToolbarLayout->setMinorAxisAlignment(0.5);

    _CodeExecutionToolbar = Panel::createEmpty();
    _CodeExecutionToolbar->setPreferredSize(Vec2f(45.0f, 45.0f));
    _CodeExecutionToolbar->setLayout(ToolbarLayout);
    _CodeExecutionToolbar->pushToChildren(_ExecuteButton);
    _CodeExecutionToolbar->pushToChildren(_StopExecutionButton);
    _CodeExecutionToolbar->pushToChildren(_StepOverButton);
    _CodeExecutionToolbar->pushToChildren(_StepInButton);
    _CodeExecutionToolbar->pushToChildren(_StepOutButton);

    updateExecutionToolbar();
}