TextAreaRefPtr DialogWindow::createTransparentTextArea(const std::string& Message) { TextAreaRefPtr TransparentTextArea = OSG::TextArea::create(); EmptyLayerRefPtr TransparentTextAreaBackground = OSG::EmptyLayer::create(); EmptyBorderRefPtr TransparentTextAreaBorder = OSG::EmptyBorder::create(); TransparentTextArea->setBorders(TransparentTextAreaBorder); TransparentTextArea->setBackgrounds(TransparentTextAreaBackground); TransparentTextArea->setWrapStyleWord(true); TransparentTextArea->setText(Message); TransparentTextArea->setEditable(false); return TransparentTextArea; }
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"); }
DialogWindowUnrecPtr DialogWindow::createColorChooserDialog(const std::string& Title, const std::string& Message, bool showAlpha, ColorSelectionModelPtr colorModel, bool showCancel, const std::string& ConfirmBtnText, const std::string& CancelBtnText) { ButtonRefPtr ConfirmationButton = OSG::Button::create(); ButtonRefPtr CancelButton; //Confirm Button ConfirmationButton->setText(ConfirmBtnText); ConfirmationButton->setMinSize(ConfirmationButton->getPreferredSize()); ConfirmationButton->setPreferredSize(ConfirmationButton->getRequestedSize()); if(showCancel) { //Cancel Button CancelButton = OSG::Button::create(); CancelButton->setText(CancelBtnText); CancelButton->setMinSize(CancelButton->getPreferredSize()); CancelButton->setPreferredSize(CancelButton->getRequestedSize()); } // Create Panel for top half of SplitPanel TextAreaRefPtr MessagePanelText = OSG::TextArea::create(); MessagePanelText->setBorders(NULL); MessagePanelText->setPreferredSize(Vec2f(100.0f, 100.0f)); MessagePanelText->setBackgrounds(NULL); MessagePanelText->setWrapStyleWord(true); MessagePanelText->setText(Message); MessagePanelText->setEditable(false); // Create Panel for bottom half of SplitPanel PanelRefPtr MessageButtonPanel = OSG::Panel::createEmpty(); FlowLayoutRefPtr MessagePanelBottomLayout = OSG::FlowLayout::create(); MessageButtonPanel->pushToChildren(ConfirmationButton); if(showCancel) MessageButtonPanel->pushToChildren(CancelButton); MessageButtonPanel->setLayout(MessagePanelBottomLayout); MessageButtonPanel->setPreferredSize(Vec2f(450,75)); PanelRefPtr MessagePanel = OSG::Panel::createEmpty(); SpringLayoutRefPtr MessagePanelLayout = SpringLayout::create(); MessagePanel->pushToChildren(MessagePanelText); MessagePanel->pushToChildren(MessageButtonPanel); MessagePanel->setLayout(MessagePanelLayout); ColorChooserRefPtr TheColorChooser = ColorChooser::create(); TheColorChooser->setSelectionModel(colorModel); //Internals Layout and constraints DialogWindowUnrecPtr TheDialog = DialogWindow::create(); SpringLayoutRefPtr DialogLayout = SpringLayout::create(); //Message Text DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, MessagePanelText, 5, SpringLayoutConstraints::NORTH_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessagePanelText, -5, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessagePanelText, 5, SpringLayoutConstraints::WEST_EDGE, TheDialog); //Color Chooser DialogLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, TheColorChooser, 5, SpringLayoutConstraints::SOUTH_EDGE, MessagePanelText); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, TheColorChooser, -5, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, TheColorChooser, 5, SpringLayoutConstraints::WEST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, TheColorChooser, -5, SpringLayoutConstraints::NORTH_EDGE, MessageButtonPanel); //Button Panel DialogLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::WEST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, MessageButtonPanel, 0, SpringLayoutConstraints::EAST_EDGE, TheDialog); DialogLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, MessageButtonPanel, 20, SpringLayoutConstraints::SOUTH_EDGE, TheDialog); //Create the Dialog box TheDialog->setLayout(DialogLayout); TheDialog->setPreferredSize(Vec2f(350,400)); TheDialog->pushToChildren(MessagePanelText); TheDialog->pushToChildren(TheColorChooser); TheDialog->pushToChildren(MessageButtonPanel); TheDialog->setTitle(Title); //Attach listener to the Confirm button ConfirmationButton->addActionListener(&TheDialog->_ConfirmButtonListener); if(showCancel) { //Attach listener to the Cancel button CancelButton->addActionListener(&TheDialog->_CancelButtonListener); } return DialogWindowTransitPtr(TheDialog); }