void ContentPanel::addTabWithText(BoostPath file) { PanelRefPtr _NewLeftTabLabelPanel = Panel::createEmpty(); ButtonRefPtr _NewLeftTabLabelCloseButtonRefPtr = dynamic_pointer_cast<Button>(dynamic_cast<InternalWindow*>(InternalWindow::getClassType().getPrototype())->getTitlebar()->getCloseButton()->shallowCopy()); //ButtonRefPtr _NewLeftTabLabelCloseButtonRefPtr = Button::create(); _NewLeftTabLabelCloseButtonRefPtr->setPreferredSize(Vec2f(100,20)); _NewLeftTabLabelCloseButtonRefPtr->setText("X"); _NewLeftTabLabelCloseButtonRefPtr->addActionListener(&_CloseButtonListener); LabelRefPtr _NewLeftTabLabelLabel=Label::create(); _NewLeftTabLabelLabel->setText(file.leaf()); _NewLeftTabLabelLabel->setBorders(NULL); _NewLeftTabLabelLabel->setBackgrounds(NULL); SpringLayoutRefPtr _NewLeftTabLabelPanelSpringLayout = OSG::SpringLayout::create(); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _NewLeftTabLabelCloseButtonRefPtr, 2, SpringLayoutConstraints::NORTH_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _NewLeftTabLabelCloseButtonRefPtr, -2, SpringLayoutConstraints::EAST_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _NewLeftTabLabelCloseButtonRefPtr, -20, SpringLayoutConstraints::EAST_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _NewLeftTabLabelCloseButtonRefPtr, -2, SpringLayoutConstraints::SOUTH_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _NewLeftTabLabelLabel, 2, SpringLayoutConstraints::NORTH_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _NewLeftTabLabelLabel, -5, SpringLayoutConstraints::WEST_EDGE, _NewLeftTabLabelCloseButtonRefPtr); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _NewLeftTabLabelLabel, 2, SpringLayoutConstraints::WEST_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _NewLeftTabLabelLabel, -2, SpringLayoutConstraints::SOUTH_EDGE, _NewLeftTabLabelPanel); _NewLeftTabLabelPanel->setPreferredSize(Vec2f(120,20)); _NewLeftTabLabelPanel->pushToChildren(_NewLeftTabLabelLabel); _NewLeftTabLabelPanel->pushToChildren(_NewLeftTabLabelCloseButtonRefPtr); _NewLeftTabLabelPanel->setLayout(_NewLeftTabLabelPanelSpringLayout); std::string sent; std::string para=""; std::ifstream inputFile((file.string()).c_str()); while(std::getline(inputFile,sent))para+=sent+"\n"; inputFile.close(); TextAreaRefPtr _NewLeftTabTextArea = OSG::TextArea::create(); _NewLeftTabTextArea->setText(para); _NewLeftTabTextArea->setEditable(true); ScrollPanelRefPtr _NewLeftTabContent = ScrollPanel::create(); _NewLeftTabContent->setPreferredSize(Vec2f(200,1200)); _NewLeftTabContent->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); _NewLeftTabContent->setViewComponent(_NewLeftTabTextArea); PanelRefPtr _NewRightTabLabelPanel = Panel::createEmpty(); ButtonRefPtr _RightTabLabelCloseButtonRefPtr = dynamic_pointer_cast<Button>(dynamic_cast<InternalWindow*>(InternalWindow::getClassType().getPrototype())->getTitlebar()->getCloseButton()->shallowCopy()); _RightTabLabelCloseButtonRefPtr->setPreferredSize(Vec2f(20,10)); _RightTabLabelCloseButtonRefPtr->setText("X"); _RightTabLabelCloseButtonRefPtr->addActionListener(&_CloseButtonListener); LabelRefPtr _NewRightTabLabel=Label::create(); _NewRightTabLabel->setText(file.leaf()); _NewRightTabLabel->setBorders(NULL); _NewRightTabLabel->setBackgrounds(NULL); SpringLayoutRefPtr _NewRightTabLabelPanelSpringLayout = OSG::SpringLayout::create(); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _RightTabLabelCloseButtonRefPtr, 2, SpringLayoutConstraints::NORTH_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _RightTabLabelCloseButtonRefPtr, -2, SpringLayoutConstraints::EAST_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _RightTabLabelCloseButtonRefPtr, -20, SpringLayoutConstraints::EAST_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _RightTabLabelCloseButtonRefPtr, -2, SpringLayoutConstraints::SOUTH_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::NORTH_EDGE, _NewRightTabLabel, 2, SpringLayoutConstraints::NORTH_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::EAST_EDGE, _NewRightTabLabel, -5, SpringLayoutConstraints::WEST_EDGE, _RightTabLabelCloseButtonRefPtr); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::WEST_EDGE, _NewRightTabLabel, 2, SpringLayoutConstraints::WEST_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanelSpringLayout->putConstraint(SpringLayoutConstraints::SOUTH_EDGE, _NewRightTabLabel, -2, SpringLayoutConstraints::SOUTH_EDGE, _NewRightTabLabelPanel); _NewRightTabLabelPanel->setPreferredSize(Vec2f(120,20)); _NewRightTabLabelPanel->pushToChildren(_RightTabLabelCloseButtonRefPtr); _NewRightTabLabelPanel->pushToChildren(_NewRightTabLabel); _NewRightTabLabelPanel->setLayout(_NewRightTabLabelPanelSpringLayout); TextAreaRefPtr _NewRightTabTextArea = OSG::TextArea::create(); _NewRightTabTextArea->setText(para); _NewRightTabTextArea->setEditable(true); ScrollPanelRefPtr _NewRightTabContent = ScrollPanel::create(); _NewRightTabContent->setPreferredSize(Vec2f(200,1200)); _NewRightTabContent->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW); _NewRightTabContent->setViewComponent(_NewRightTabTextArea); _RightTabPanel->addTab(_NewLeftTabLabelPanel, _NewLeftTabContent); _RightTabPanel->setSelectedIndex((_RightTabPanel->getMFTabs()->size())-1); _LeftTabPanel->addTab(_NewRightTabLabelPanel, _NewRightTabContent); _LeftTabPanel->setSelectedIndex((_LeftTabPanel->getMFTabs()->size())-1); }