ComponentTransitPtr DefaultTreeCellEditor::getComponent(void) const
{
    if(_EditingValue.type() == typeid(std::string))
    {
        return ComponentTransitPtr(getDefaultStringEditor());
    }
    else
    {
        return ComponentTransitPtr(getDefaultEditor());
    }
}
ComponentTransitPtr SceneNodeTreeComponentGenerator::getTreeComponent(Tree* const Parent, 
                                                                            const boost::any& Value, 
                                                                            bool IsSelected, 
                                                                            bool Expanded, 
                                                                            bool Leaf, 
                                                                            UInt32 Row, 
                                                                            bool HasFocus)
{
    NodeUnrecPtr TheNode;
    try
    {
        TheNode = boost::any_cast<NodeUnrecPtr>(Value);
    }
    catch (boost::bad_any_cast &)
    {
        //Could not convert to FieldContinerFieldPath
        return ComponentTransitPtr(NULL);
    }

    //Get the text for the label
    std::string LabelText("");
    if(TheNode != NULL)
    {
        const Char8* name(getName(TheNode));
        if(name)
        {
            LabelText += std::string(name) + " ";
        }
        if(TheNode->getCore() != NULL)
        {
            LabelText += std::string("[") + TheNode->getCore()->getType().getCName() + "]";
        }
        else
        {
            LabelText += "[NULL core]";
        }
    }
    else
    {
        LabelText += "NULL";
    }

    ComponentRecPtr GenComp = getTreeComponentText(Parent, LabelText, IsSelected, Expanded, Leaf, Row, HasFocus);
    if(TheNode != NULL &&
       !(TheNode->getTravMask() & getTravMask()))
    {
        GenComp->setEnabled(false);
    }

    return ComponentTransitPtr(GenComp);
}
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 DefaultTreeCellEditor::getTreeCellEditorComponent(Tree* const TheTree, const boost::any& Value, bool IsSelected, bool IsExpanded, UInt32 row)
{
    _EditingValue = Value;

    if(_EditingValue.empty()){
        return ComponentTransitPtr(NULL);
    }

    if(_EditingValue.type() == typeid(std::string))
    {
        //Use String Text Field As Editing Component
        std::string tempString;
        try
        {
            tempString = lexical_cast(_EditingValue);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }
        getDefaultStringEditor()->setText(tempString);
        getDefaultStringEditor()->selectAll();
        getDefaultStringEditor()->setCaretPosition(getDefaultStringEditor()->getText().size());

        _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultStringEditor());
    }
    else
    {
        //Use Default Text Field As Editing Component
        std::string tempString;
        getDefaultEditor()->setText(tempString);
        getDefaultEditor()->selectAll();
        getDefaultEditor()->setCaretPosition(getDefaultEditor()->getText().size());

        _EditorActionConnection = getDefaultEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultEditor());
    }
}
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return ComponentTransitPtr(NULL);
    }
    TextFieldRefPtr TheTextField = TextField::create();
    std::string tempString;
    try
    {
        tempString = lexical_cast(value);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    TheTextField->setText(tempString);
    TheTextField->setPreferredSize(Vec2f(100,30));
    TheTextField->setAlignment(Vec2f(0.5,0.5));
    TheTextField->selectAll();
    TheTextField->setCaretPosition(TheTextField->getText().size());
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheTextField->setBackground(tempBackground);

    //if(isSelected){
    //	tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    //}
    //else{
    tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    //}

    LineBorderRefPtr tempBorder;

    tempBorder = LineBorder::create();
    tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));

    TheTextField->setBorder(tempBorder);

    setDefaultStringEditor(TheTextField);
    _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
    _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
    _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
    return ComponentTransitPtr(getDefaultStringEditor());
}
Esempio n. 6
0
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);
}
ComponentTransitPtr FieldContainerFieldPathComponentGenerator::getTreeComponent(Tree* const Parent, 
                                                                            const boost::any& Value, 
                                                                            bool IsSelected, 
                                                                            bool Expanded, 
                                                                            bool Leaf, 
                                                                            UInt32 Row, 
                                                                            bool HasFocus)
{
    FieldContainerTreeModel::ContainerFieldIdPair ThePair;
    try
    {
        ThePair = boost::any_cast<FieldContainerTreeModel::ContainerFieldIdPair>(Value);
    }
    catch (boost::bad_any_cast &)
    {
        //Could not convert to FieldContinerFieldPath
        return ComponentTransitPtr(NULL);
    }

    //Get the text for the label
    std::string LabelText("");
    if(ThePair._FieldID == 0)
    {
        if(ThePair._Container != NULL)
        {
            if(ThePair._Container->getType().isDerivedFrom(AttachmentContainer::getClassType()))
            {
                const Char8* name(getName(dynamic_cast<AttachmentContainer*>(ThePair._Container)));
                if(name)
                {
                    LabelText += std::string(name) + " ";
                }
            }
            LabelText += std::string("[") + ThePair._Container->getType().getCName() + "]";
        }
        else
        {
            LabelText += "NULL";
        }
    }
    else
    {
        LabelText = ThePair._Container->getFieldDescription(ThePair._FieldID)->getCName() +
                    std::string(" [") + ThePair._Container->getFieldDescription(ThePair._FieldID)->getFieldType().getContentType().getCName() + "]";
    }


    return getTreeComponentText(Parent, LabelText, IsSelected, Expanded, Leaf, Row, HasFocus);
}
Esempio n. 8
0
ComponentTransitPtr Spinner::createEditor(SpinnerModelPtr model)
{
    //TODO: Implement
    SpinnerDefaultEditorRefPtr TheEditor;
    if(model->getModelName().compare(ListSpinnerModel::getClassModelName()) == 0)
    {
        TheEditor = SpinnerDefaultEditor::create();
    }
    else if(model->getModelName().compare(getNumberSpinnerModelClassModelName()) == 0)
    {
        TheEditor = SpinnerNumberEditor::create();
    }
    else
    {
        TheEditor = SpinnerDefaultEditor::create();
    }
    TheEditor->setSpinner(this);
    return ComponentTransitPtr(TheEditor.get());
}
ComponentTransitPtr createPanel(void)
{
    // Function to create a panel to be rotated
    ButtonRecPtr button1 = Button::create();
    ButtonRecPtr button2 = Button::create();
    ButtonRecPtr button3 = Button::create();
    ButtonRecPtr button4 = Button::create();
    FlowLayoutRecPtr panel1Layout = FlowLayout::create();
    PanelRecPtr panel1 = Panel::create();
    panel1->pushToChildren(button1);    
    panel1->pushToChildren(button2);
    panel1->pushToChildren(button3);
    panel1->pushToChildren(button4);
    panel1->setLayout(panel1Layout);
    panel1->setPreferredSize(Vec2f(100, 220));
    button1->setText("This");
    button2->setText("Can");
    button3->setText("Be");
    button4->setText("Rotated!");

    return ComponentTransitPtr(panel1);
}
ComponentTransitPtr ColorChooserComboBoxComponentGenerator::getComboBoxComponent(ComboBox* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	PanelRefPtr TheComponent = Panel::create();//dynamic_pointer_cast<Component>(getDrawObjectPrototype()->shallowCopy());
	TheComponent->setLayout(LayoutRefPtr(FlowLayout::create()));

	LabelRefPtr theColorLabel = Label::create();
	//theColorLabel->setPreferredSize(Vec2f(50.0f,50.0f));
	theColorLabel->setBorders(NULL);

	try
	{
		Color4f theColor = boost::any_cast<Color4f>(Value);

		if(theColor != NULL)
		{
			ColorLayerRefPtr theColorLabelBackground = ColorLayer::create();
			theColorLabelBackground->setColor(theColor);
			theColorLabel->setBackgrounds(theColorLabelBackground);
		}
	}
	catch(boost::bad_any_cast &)
	{
		std::string ValueString;

		try
		{
			ValueString = lexical_cast(Value);
		}
		catch (boost::bad_lexical_cast &)
		{
			//Could not convert to string
			SWARNING << "ColorChooserComboBoxComponentGenerator::getComboBoxComponent - The elements should either be a Color4f value or a std::string\n";
		}

		theColorLabel->setText(ValueString);

		if(IsSelected && HasFocus)
		{
			if(getFocusedTextColorHasPriority())
			{
				theColorLabel->setTextColors(getFocusedTextColor());
			}
			else
			{
				theColorLabel->setTextColors(getSelectedTextColor());
			}
		}
		else if(IsSelected)
		{
				theColorLabel->setTextColors(getSelectedTextColor());
		}
		else if(HasFocus)
		{
				theColorLabel->setTextColors(getFocusedTextColor());
		}
	}

	TheComponent->pushToChildren(theColorLabel);
    
	if(IsSelected && HasFocus)
	{
			if(getFocusedBorderHasPriority())
			{
				TheComponent->setBorders(getFocusedBorder());
			}
			else
			{
				TheComponent->setBorders(getSelectedBorder());
			}
			if(getFocusedBackgroundHasPriority())
			{
				TheComponent->setBackgrounds(getFocusedBackground());
			    TheComponent->setForegrounds(getFocusedForeground());
			}
			else
			{
				TheComponent->setBackgrounds(getSelectedBackground());
			    TheComponent->setForegrounds(getSelectedForeground());
			}
	}
	else if(IsSelected)
	{
			TheComponent->setBorders(getSelectedBorder());
			TheComponent->setBackgrounds(getSelectedBackground());
			TheComponent->setForegrounds(getSelectedForeground());
	}
	else if(HasFocus)
	{
			TheComponent->setBorders(getFocusedBorder());
			TheComponent->setBackgrounds(getFocusedBackground());
			TheComponent->setForegrounds(getFocusedForeground());
	}
	return ComponentTransitPtr(TheComponent.get());
}
ComponentTransitPtr GenericFieldContainerEditor::createFCToolTip(const FieldContainerType &FCType)
{
    std::string FieldDoc(doxygenToPlainFormatting(FCType.getDocumentation()));

    //TypeName
    LabelRecPtr TypeLabel = Label::create();
    TypeLabel->setText(FCType.getName());
    TypeLabel->setAlignment(Vec2f(0.5f,0.5f));
    TypeLabel->setBackgrounds(NULL);

    //Separator
    SeparatorRecPtr MainSeparator = Separator::create();
    MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION);
    MainSeparator->setSeparatorSize(1.0f);
    MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f));
    MainSeparator->setBackgrounds(NULL);

    //Inheritance Panel Layout
    //LabelRecPtr InheritanceLabel = Label::create();
    //InheritanceLabel->setText("Inheritance");

    //FlowLayoutRecPtr InheritancePanelLayout = FlowLayout::create();
    //InheritancePanelLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
    //InheritancePanelLayout->setVerticalGap(3.0f);
    //InheritancePanelLayout->setMajorAxisAlignment(0.0f);
    //InheritancePanelLayout->setMinorAxisAlignment(0.5f);
    //InheritancePanelLayout->setComponentAlignment(0.5f);

    ////Inheritance Panel
    //PanelRecPtr InheritancePanel = Panel::createEmpty();
    //InheritancePanel->setAllInsets(5.0f);
    //InheritancePanel->setLayout(InheritancePanelLayout);

    //const TypeBase *ParentType(&FCType);
    ////while()
    ////{
        ////ToolTipPanel->pushToChildren(DescriptionTextArea);
    ////}
    //LabelRecPtr TypeNameLabel = Label::create();
    //TypeNameLabel->setText(FCType.getName());
    //TypeNameLabel->setAlignment(Vec2f(0.5f,0.5f));

    //InheritancePanel->pushToChildren(TypeNameLabel);

    //Set the layout constraints
    BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create();
    CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    //Description Panel
    LabelRecPtr DescriptionLabel = Label::create();
    DescriptionLabel->setText("Description:");
    DescriptionLabel->setBackgrounds(NULL);

    TextAreaRecPtr DescriptionTextArea = TextArea::create();
    DescriptionTextArea->setText(FieldDoc);
    DescriptionTextArea->setEditable(false);
    DescriptionTextArea->setBorders(NULL);
    DescriptionTextArea->setBackgrounds(NULL);
    DescriptionTextArea->setConstraints(CenterConstraints);

    //Description Panel
    PanelRecPtr DescriptionPanel = Panel::create();
    BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create();
    DescriptionPanel->setAllInsets(5.0f);
    DescriptionPanel->setLayout(DescriptionPanelLayout);
    DescriptionPanel->pushToChildren(DescriptionTextArea);
    DescriptionPanel->setBackgrounds(NULL);


    //ToolTip Layout
    PanelRecPtr ToolTipPanel = Panel::createEmpty();

    SpringLayoutRecPtr MainLayout = SpringLayout::create();

    //TypeLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //MainSeparator    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, TypeLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    ////InheritancePanel
    //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritanceLabel, 1,
                              //SpringLayoutConstraints::SOUTH_EDGE, MainSeparator);
    //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritanceLabel, 0,
                              //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritanceLabel, 0,
                              //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    ////InheritancePanel
    //MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, InheritancePanel, 1,
                              //SpringLayoutConstraints::SOUTH_EDGE, InheritanceLabel);
    //MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, InheritancePanel, 0,
                              //SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    //MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, InheritancePanel, 0,
                              //SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);


    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, MainSeparator);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //ToolTip Panel

    Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip());
    ToolTipPanel->setBorders(DefaultToolTip->getBorder());
    ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground());
    ToolTipPanel->setForegrounds(DefaultToolTip->getForeground());
    ToolTipPanel->setLayout(MainLayout);
    ToolTipPanel->pushToChildren(TypeLabel);
    ToolTipPanel->pushToChildren(MainSeparator);
    //ToolTipPanel->pushToChildren(InheritanceLabel);
    //ToolTipPanel->pushToChildren(InheritancePanel);
    ToolTipPanel->pushToChildren(DescriptionLabel);
    ToolTipPanel->pushToChildren(DescriptionPanel);

    Real32 Height(100.0f + DescriptionTextArea->getLineHeight()
                  * (DescriptionTextArea->getText().size()/40));
    ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height));

    return ComponentTransitPtr(ToolTipPanel);
}
ComponentTransitPtr GenericFieldContainerEditor::createEventToolTip(const EventDescription *EventDesc)
{
    std::string FieldDoc(doxygenToPlainFormatting(EventDesc->getDescription()));

    //TypeName
    LabelRecPtr TypeLabel = Label::create();
    TypeLabel->setText(EventDesc->getName());
    TypeLabel->setAlignment(Vec2f(0.5f,0.5f));
    TypeLabel->setBackgrounds(NULL);

    //Separator
    SeparatorRecPtr MainSeparator = Separator::create();
    MainSeparator->setOrientation(Separator::HORIZONTAL_ORIENTATION);
    MainSeparator->setSeparatorSize(1.0f);
    MainSeparator->setPreferredSize(Vec2f(1.0f,5.0f));
    MainSeparator->setBackgrounds(NULL);

    //Consumable Label
    LabelRecPtr ConsumableLabel = Label::create();
    ConsumableLabel->setText(EventDesc->getConsumable() ? "Consumable" : "Not Consumable");
    ConsumableLabel->setAlignment(Vec2f(0.0f,0.5f));
    ConsumableLabel->setBackgrounds(NULL);

    //Set the layout constraints
    BorderLayoutConstraintsRecPtr CenterConstraints = BorderLayoutConstraints::create();
    CenterConstraints->setRegion(BorderLayoutConstraints::BORDER_CENTER);

    //Description Panel
    LabelRecPtr DescriptionLabel = Label::create();
    DescriptionLabel->setText("Description:");
    DescriptionLabel->setBackgrounds(NULL);

    TextAreaRecPtr DescriptionTextArea = TextArea::create();
    DescriptionTextArea->setText(FieldDoc);
    DescriptionTextArea->setEditable(false);
    DescriptionTextArea->setBorders(NULL);
    DescriptionTextArea->setBackgrounds(NULL);
    DescriptionTextArea->setConstraints(CenterConstraints);

    //Description Panel
    PanelRecPtr DescriptionPanel = Panel::create();
    BorderLayoutRecPtr DescriptionPanelLayout = BorderLayout::create();
    DescriptionPanel->setAllInsets(5.0f);
    DescriptionPanel->setLayout(DescriptionPanelLayout);
    DescriptionPanel->pushToChildren(DescriptionTextArea);
    DescriptionPanel->setBackgrounds(NULL);


    //ToolTip Layout
    PanelRecPtr ToolTipPanel = Panel::createEmpty();

    SpringLayoutRecPtr MainLayout = SpringLayout::create();

    //TypeLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::NORTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TypeLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TypeLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //MainSeparator    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MainSeparator, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, TypeLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MainSeparator, -15,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MainSeparator, 15,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);
    //ConsumableLabel    
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, ConsumableLabel, 1,
                              SpringLayoutConstraints::NORTH_EDGE, MainSeparator);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, ConsumableLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, ConsumableLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::SOUTH_EDGE, ConsumableLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionLabel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionLabel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //DescriptionTextArea
    MainLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, DescriptionPanel, 1,
                              SpringLayoutConstraints::SOUTH_EDGE, DescriptionLabel);
    MainLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::SOUTH_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, DescriptionPanel, -5,
                              SpringLayoutConstraints::EAST_EDGE, ToolTipPanel);
    MainLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, DescriptionPanel, 5,
                              SpringLayoutConstraints::WEST_EDGE, ToolTipPanel);

    //ToolTip Panel

    Component* DefaultToolTip(LookAndFeelManager::the()->getLookAndFeel()->getDefaultToolTip());
    ToolTipPanel->setBorders(DefaultToolTip->getBorder());
    ToolTipPanel->setBackgrounds(DefaultToolTip->getBackground());
    ToolTipPanel->setForegrounds(DefaultToolTip->getForeground());
    ToolTipPanel->setLayout(MainLayout);
    ToolTipPanel->pushToChildren(TypeLabel);
    ToolTipPanel->pushToChildren(MainSeparator);
    ToolTipPanel->pushToChildren(ConsumableLabel);
    ToolTipPanel->pushToChildren(DescriptionLabel);
    ToolTipPanel->pushToChildren(DescriptionPanel);

    Real32 Height(130.0f + DescriptionTextArea->getLineHeight()
                  * (DescriptionTextArea->getText().size()/40));
    ToolTipPanel->setPreferredSize(Vec2f(300.0f,Height));

    return ComponentTransitPtr(ToolTipPanel);
}
OSG_BEGIN_NAMESPACE

/***************************************************************************\
 *                            Description                                  *
\***************************************************************************/

/*! \class OSG::DefaultBoolTableCellRenderer
A DefaultBoolTableCellRenderer.
*/

/***************************************************************************\
 *                           Class variables                               *
\***************************************************************************/

/***************************************************************************\
 *                           Class methods                                 *
\***************************************************************************/


/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/

ComponentTransitPtr DefaultBoolTableCellRenderer::getTableCellRendererComponent(Table* const table, const boost::any& value, bool isSelected, bool hasFocus, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return ComponentTransitPtr(NULL);
    }
    LabelRefPtr TheLabel = Label::create();
    std::string tempString;
    try
    {
        if(boost::any_cast<bool>(value))
        {
            tempString = "True";
        }
        else
        {
            tempString = "False";
        }
    }
    catch (boost::bad_any_cast &)
    {
        //Not a bool
    }
    TheLabel->setText(tempString);
    TheLabel->setPreferredSize(Vec2f(100,30));
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheLabel->setBackgrounds(tempBackground);

    if(isSelected){
        tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    }
    else{
        tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    }

    if(hasFocus){
        LineBorderRefPtr tempBorder;

        tempBorder = LineBorder::create();
        TheLabel->setBorders(tempBorder);

        tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
    }
    else{
        EmptyBorderRefPtr tempBorder;

        tempBorder = EmptyBorder::create();
        TheLabel->setBorders(tempBorder);
    }
    return ComponentTransitPtr(TheLabel.get());


}
/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/
ComponentTransitPtr SceneComponentTreeComponentGenerator::getTreeComponent(Tree* const Parent, 
                                                                            const boost::any& Value, 
                                                                            bool IsSelected, 
                                                                            bool Expanded, 
                                                                            bool Leaf, 
                                                                            UInt32 Row, 
                                                                            bool HasFocus)
{
    std::string Text;
    if(Value.type() == typeid(Scene* const))
    {
        Text = "Scene";
    }
    else if(Value.type() == typeid(UInt32))
    {
        switch(boost::any_cast<UInt32>(Value))
        {
        case SceneTreeModel::BasicComponent:              //Basic
            Text = "Basic";
            break;
        case SceneTreeModel::BackgroundComponent:              //Background
            Text = "Background";
            break;
        case SceneTreeModel::CameraComponent:              //Camera
            Text = "Camera";
            break;
        case SceneTreeModel::ForegroundsComponent:              //Foregrounds
            Text = "Foregrounds";
            break;
        case SceneTreeModel::SceneObjectsComponent:              //Models
            Text = "SceneObjects";
            break;
        case SceneTreeModel::LightsComponent:              //Models
            Text = "Lights";
            break;
        case SceneTreeModel::DynamicsComponent:              //Dynamics
            Text = "Dynamics";
            break;
        case SceneTreeModel::ScriptsComponent:              //Scripts
            Text = "Scripts";
            break;
        case SceneTreeModel::BehavioursComponent:              //Behaviours
            Text = "Behaviours";
            break;
        case SceneTreeModel::AnimationsComponent:              //Animations
            Text = "Animations";
            break;
        }
    }
    else if(Value.type() == typeid(Foreground* const))
    {
        ForegroundRecPtr FG= boost::any_cast<Foreground* const>(Value);
        const Char8* Name(getName(FG));
        Text = std::string(Name ? Name : "No Name" ) + " [" + FG->getType().getName() + "]";
    }
    else if(Value.type() == typeid(SceneObject* const))
    {
        SceneObjectRecPtr SO= boost::any_cast<SceneObject* const>(Value);
        const Char8* Name(getName(SO));
        Text = (Name ? Name : "No Name" );
    }
    else if(Value.type() == typeid(Light* const))
    {
        LightRecPtr SceneLight= boost::any_cast<Light* const>(Value);
        const Char8* Name(getName(SceneLight));
        Text = std::string(Name ? Name : "No Name" ) + " [" + SceneLight->getType().getName() + "]";
    }

    ComponentRecPtr LabelComp = getTreeComponentText(Parent, Text, IsSelected, Expanded, Leaf, Row, HasFocus);

    if(Value.type() == typeid(UInt32))
    {
        switch(boost::any_cast<UInt32>(Value))
        {
        case SceneTreeModel::ForegroundsComponent:              //Foregrounds
            {
                if(_AddForegroundButton == NULL)
                {
                    _AddForegroundButton = MenuButton::create();
                    _AddForegroundButton->setText("+");
                    _AddForegroundButton->setToolTipText("Create new Foreground");
                    _AddForegroundButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddForegroundButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddForegroundButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());

                    //Fill with all of the foreground types
                    DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create();
                    MenuModel->editMFDerivedFieldContainerTypes()->push_back(Foreground::getClassType().getCName());
                    MenuModel->setIncludeAbstract(false);

                    _AddForegroundButton->setModel(MenuModel);

                    //Connect
                    _AddForegroundConnection.disconnect();
                    _AddForegroundConnection = _AddForegroundButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddForeground, _SceneComponentTree, _1, _AddForegroundButton.get()));
                }

                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, _AddForegroundButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddForegroundButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddForegroundButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        case SceneTreeModel::SceneObjectsComponent:              //Models
            {
                if(_AddSceneObjectButton == NULL)
                {
                    _AddSceneObjectButton = Button::create();
                    _AddSceneObjectButton->setText("+");
                    _AddSceneObjectButton->setToolTipText("Create new Scene Object");
                    _AddSceneObjectButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddSceneObjectButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddSceneObjectButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());

                    //Connect
                    _AddSceneObjectConnection.disconnect();
                    _AddSceneObjectConnection = _AddSceneObjectButton->connectActionPerformed(boost::bind(&SceneComponentTree::handleAddSceneObject, _SceneComponentTree, _1));
                }

                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, _AddSceneObjectButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddSceneObjectButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddSceneObjectButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        case SceneTreeModel::LightsComponent:              //Lights
            {
                if(_AddLightButton == NULL)
                {
                    _AddLightButton = MenuButton::create();
                    _AddLightButton->setText("+");
                    _AddLightButton->setToolTipText("Create new Light");
                    _AddLightButton->setPreferredSize(Vec2f(17.0f,17.0f));
                    _AddLightButton->setAlignment(Vec2f(0.5f,0.5f));
                    _AddLightButton->setFont(dynamic_pointer_cast<Label>(LabelComp)->getFont());
                    //Connect
                    _AddLightConnection.disconnect();
                    _AddLightConnection = _AddLightButton->connectMenuActionPerformed(boost::bind(&SceneComponentTree::handleAddLight, _SceneComponentTree, _1, _AddLightButton.get()));
                }

                //Fill with all of the light types
                DerivedFieldContainerComboBoxModelRecPtr MenuModel = DerivedFieldContainerComboBoxModel::create();
                MenuModel->editMFDerivedFieldContainerTypes()->push_back(Light::getClassType().getCName());
                MenuModel->setIncludeAbstract(false);

                _AddLightButton->setModel(MenuModel);

                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, _AddLightButton, -5, SpringLayoutConstraints::EAST_EDGE, CompPanel);
                TreeCompLayout->putConstraint(SpringLayoutConstraints::VERTICAL_CENTER_EDGE, _AddLightButton, 0, SpringLayoutConstraints::VERTICAL_CENTER_EDGE, CompPanel);

                CompPanel->setLayout(TreeCompLayout);
                CompPanel->pushToChildren(LabelComp);
                CompPanel->pushToChildren(_AddLightButton);
                
                return ComponentTransitPtr(CompPanel);
            }
            break;
        }
    }
    else if(Value.type() == typeid(Foreground* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveForeground, _SceneComponentTree, _1, boost::any_cast<Foreground* const>(Value)));
    }
    else if(Value.type() == typeid(SceneObject* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveSceneObject, _SceneComponentTree, _1, boost::any_cast<SceneObject* const>(Value)));
    }
    else if(Value.type() == typeid(Light* const))
    {
        return createButtonedComp(LabelComp, boost::bind(&SceneComponentTree::handleRemoveLight, _SceneComponentTree, _1, boost::any_cast<Light* const>(Value)));
    }

    return ComponentTransitPtr(LabelComp);
}
ComponentTransitPtr PanelListComponentGenerator::getListComponent(List* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	std::string ValueString;

    try
    {
        ValueString = lexical_cast(Value);
		PanelRefPtr theComponent = Panel::create();
	
		GridLayoutRefPtr PanelLayout = OSG::GridLayout::create();
		PanelLayout->setRows(3);
		PanelLayout->setColumns(1);
		PanelLayout->setHorizontalGap(0);
		PanelLayout->setVerticalGap(2);

		

		std::stringstream is;
		is<<Index;
		std::string iss;
		is>>iss;
		TextFieldRefPtr theName = TextField::create();
		theName->setText("Group"+iss);
		theName->setPreferredSize(Vec2f(146,20));
		

		PanelRefPtr rangePanel = Panel::create();
		
		GridLayoutRefPtr rangePanelLayout = OSG::GridLayout::create();
		rangePanelLayout->setRows(1);
		rangePanelLayout->setColumns(4);
		rangePanelLayout->setHorizontalGap(2);
		rangePanelLayout->setVerticalGap(0);

		
		LabelRefPtr rangeLabel = Label::create();
		rangeLabel->setText("Range:");
		rangeLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr from = TextField::create();
		from->setEmptyDescText("From");
		from->setPreferredSize(Vec2f(35,20));

		LabelRefPtr hiphenLabel = Label::create();
		hiphenLabel->setText(" - ");
		hiphenLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr to = TextField::create();
		to->setPreferredSize(Vec2f(35,20));
		to->setEmptyDescText("To");

		rangePanel->pushToChildren(rangeLabel);
		rangePanel->pushToChildren(from);
		rangePanel->pushToChildren(hiphenLabel);
		rangePanel->pushToChildren(to);
		rangePanel->setLayout(rangePanelLayout);
		rangePanel->setPreferredSize(Vec2f(146,20));

		DefaultMutableComboBoxModelRefPtr TheComboBoxModel = DefaultMutableComboBoxModel::create();
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(std::string("More Colors")));

		ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
		
		//Create the ComboBox
		ComboBoxRefPtr TheComboBox = ComboBox::create();
		TheComboBox->setModel(TheComboBoxModel);
		TheComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
		TheComboBox->setEditable(false);
		TheComboBox->setSelectedIndex(0);
		TheComboBox->setPreferredSize(Vec2f(146,20));

		theComponent->pushToChildren(theName);
		theComponent->pushToChildren(rangePanel);
		theComponent->pushToChildren(TheComboBox);
		theComponent->setLayout(PanelLayout);
		theComponent->setPreferredSize(Vec2f(146,66));

		Parent->setCellMajorAxisLength(66);

		return ComponentTransitPtr(theComponent.get());

    }
    catch (boost::bad_lexical_cast &)
    {
        return ComponentTransitPtr(NULL);
    }

}