本文整理汇总了C++中PanelRefPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ PanelRefPtr::get方法的具体用法?C++ PanelRefPtr::get怎么用?C++ PanelRefPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PanelRefPtr
的用法示例。
在下文中一共展示了PanelRefPtr::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getComboBoxComponent
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());
}
示例2: getListComponent
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);
}
}