本文整理汇总了C++中InternalWindowRefPtr::setDrawTitlebar方法的典型用法代码示例。如果您正苦于以下问题:C++ InternalWindowRefPtr::setDrawTitlebar方法的具体用法?C++ InternalWindowRefPtr::setDrawTitlebar怎么用?C++ InternalWindowRefPtr::setDrawTitlebar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternalWindowRefPtr
的用法示例。
在下文中一共展示了InternalWindowRefPtr::setDrawTitlebar方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
ExampleButton2->setText("Previous Card");
ExampleButton2->setConstraints(ExampleButton2Constraints);
// Add ActionListener
BackCardActionListener TheBackCardActionListener;
ExampleButton2->addActionListener( &TheBackCardActionListener);
ExampleButton3->setText("This");
ExampleButton4->setText("is");
ExampleButton5->setText("Card");
ExampleButton6->setText("Layout");
ExampleButton7->setText("First Card");
ExampleButton7->setConstraints(ExampleButton7Constraints);
// Add ActionListener
FirstCardActionListener TheFirstCardActionListener;
ExampleButton7->addActionListener( &TheFirstCardActionListener);
ExampleButton8->setText("Last Card");
ExampleButton8->setConstraints(ExampleButton8Constraints);
// Add ActionListener
LastCardActionListener TheLastCardActionListener;
ExampleButton8->addActionListener( &TheLastCardActionListener);
ExampleCardPanel->setLayout(ExampleCardLayout);
ExampleCardPanel->pushToChildren(ExampleButton3);
ExampleCardPanel->pushToChildren(ExampleButton4);
ExampleCardPanel->pushToChildren(ExampleButton5);
ExampleCardPanel->pushToChildren(ExampleButton6);
ExampleCardPanel->setConstraints(ExampleCardPanelConstraints);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton7);
MainInternalWindow->pushToChildren(ExampleButton8);
MainInternalWindow->pushToChildren(ExampleCardPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"11CardLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例2: main
//.........这里部分代码省略.........
of pixels between each row.
******************************************************/
GridLayoutRefPtr MainInternalWindowLayout = OSG::GridLayout::create();
MainInternalWindowLayout->setRows(3);
MainInternalWindowLayout->setColumns(2);
MainInternalWindowLayout->setHorizontalGap(4);
MainInternalWindowLayout->setVerticalGap(4);
/******************************************************
Create and edit some Button Components.
Note that as with BoxLayout, Components
are resized to fit their respective
grid boxes. Unless a MaxSize is set,
this will be the case. This will
override even PreferredSizes (see
ExampleButton3).
******************************************************/
ButtonRefPtr ExampleButton1 = OSG::Button::create();
ButtonRefPtr ExampleButton2 = OSG::Button::create();
ButtonRefPtr ExampleButton3 = OSG::Button::create();
ButtonRefPtr ExampleButton4 = OSG::Button::create();
ButtonRefPtr ExampleButton5 = OSG::Button::create();
ButtonRefPtr ExampleButton6 = OSG::Button::create();
ExampleButton1->setPreferredSize(Vec2f(50,50));
ExampleButton1->setMaxSize(Vec2f(50,50)); //if MaxSize is commented out, this button then will revert to being the same size as the others in the grid.
ExampleButton2->setPreferredSize(Vec2f(200,100)); //<----
// |
ExampleButton3->setPreferredSize(Vec2f(50,100)); //Notice that even though these two differ in size they appear the same on the grid
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"07GridLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例3: main
// Initialize WIN32 & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
//TutorialKeyListener TheKeyListener;
//TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr graphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create the DefaultMutableComboBoxModel and
add Elements to it (several Colors
in this case). These will be the data
values shown in the ComboBox.
******************************************************/
DefaultMutableComboBoxModelRefPtr ExampleComboBoxModel = DefaultMutableComboBoxModel::create();
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
ExampleComboBoxModel->addElement(boost::any(std::string("More Colors")));
/******************************************************
Create an editable ComboBox. A ComboBox
has a Model just like various other
Components.
******************************************************/
ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
ExampleComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
ExampleComboBox->setEditable(false);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->setDrawingSurface(TutorialDrawingSurface);
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
ButtonRecPtr UndoButton = OSG::Button::create();
UndoButton->setText("Undo");
UndoButton->setEnabled(false);
UndoButton->connectActionPerformed(boost::bind(&handleUndoButtonAction, _1, TheUndoManager));
ButtonRecPtr RedoButton = OSG::Button::create();
RedoButton->setText("Redo");
RedoButton->setEnabled(false);
RedoButton->connectActionPerformed(boost::bind(&handleRedoButtonActionPerformed, _1, TheUndoManager));
TheUndoManager->connectStateChanged(boost::bind(&handleUndoManagerStateChanged, _1, UndoButton.get(), RedoButton.get(), UndoRedoListModel.get(), TheUndoManager));
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
UndoRedoScrollPanel->setViewComponent(UndoRedoList);
//Background Editor Field
FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(TutorialBackground, TheCommandManager);
//FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(RedoButton, TheCommandManager);
//FieldContainerEditorComponentRefPtr TheEditor = FieldContainerEditorFactory::the()->createDefaultEditor(dynamic_cast<Geometry*>(TorusGeometryNode->getCore())->getMaterial(), TheCommandManager);
ScrollPanelRefPtr EditorScrollPanel = ScrollPanel::create();
EditorScrollPanel->setPreferredSize(Vec2f(300,400));
EditorScrollPanel->setViewComponent(TheEditor);
//Undo Panel
LabelRecPtr UndoPanelLabel = Label::create();
UndoPanelLabel->setText("Undo Panel");
UndoPanelLabel->setPreferredSize(Vec2f(100.0f, 20.0f));
LayoutRefPtr UndoPanelLayout = OSG::FlowLayout::create();
PanelRecPtr UndoPanel = Panel::create();
UndoPanel->setPreferredSize(Vec2f(300.0f,300.0f));
UndoPanel->pushToChildren(UndoPanelLabel);
UndoPanel->pushToChildren(UndoRedoScrollPanel);
UndoPanel->pushToChildren(UndoButton);
UndoPanel->pushToChildren(RedoButton);
UndoPanel->setLayout(UndoPanelLayout);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(EditorScrollPanel);
MainInternalWindow->pushToChildren(UndoPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Add the UI Foreground Object to the Scene
TutorialViewport->addForeground(TutorialUIForeground);
TutorialViewport->setBackground(TutorialBackground);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager.showAll();
//sceneManager.setStatistics(true);
TutorialWindow->connectKeyTyped(boost::bind(keyTyped, _1, TheCommandManager, TutorialViewport.get(), UndoRedoList.get()));
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"03GenericFieldContainerEditor");
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例5: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
/******************************************************
Create and edit a CheckboxButton.
Note: the only function call shown
specific to CheckboxButton is setSelected.
In DefaultLookAndFeel, the options
for changing the style of the CheckBox
are shown. CheckboxButton also
inherits off Button so all features
of Button may be used.
-setSelected(bool): Determines if the
CheckboxButton is checked(true) or
not checked(false).
******************************************************/
CheckboxButtonRefPtr ExampleCheckboxButton = OSG::CheckboxButton::create();
ExampleCheckboxButton->setMinSize(Vec2f(50, 25));
ExampleCheckboxButton->setMaxSize(Vec2f(300, 100));
ExampleCheckboxButton->setPreferredSize(Vec2f(200, 50));
ExampleCheckboxButton->setEnabled(true);
ExampleCheckboxButton->setText("Checkbox Button");
ExampleCheckboxButton->setAlignment(Vec2f(0.5,0.5));
ExampleCheckboxButton->setSelected(true);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleCheckboxButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
ExampleTextDomArea->setWrapStyleWord(false);
ExampleTextDomArea->setMinSize(Vec2f(600,400));
ExampleTextDomArea->setFont(_Font);
ExampleAdvancedTextDomArea = OSG::AdvancedTextDomArea::create();
ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setGutterVisible(true);
ExampleAdvancedTextDomArea->pushToChildren(ExampleTextDomArea);
ExampleAdvancedTextDomArea->setLayout(LayoutRefPtr(OSG::FlowLayout::create()));
ExampleAdvancedTextDomArea->setPreferredSize(Vec2f(600,400));
ExampleAdvancedTextDomArea->setMinSize(Vec2f(600,400));
ScrollPanelRefPtr TextAreaScrollPanel = ScrollPanel::create();
TextAreaScrollPanel->setPreferredSize(Vec2f(600,400));
TextAreaScrollPanel->setMinSize(Vec2f(600,400));
TextAreaScrollPanel->setViewComponent(ExampleAdvancedTextDomArea);
*/
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(theTextEditor);
MainInternalWindow->pushToChildren(LoadButton);
MainInternalWindow->pushToChildren(SaveButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.85f,0.85f));
MainInternalWindow->setDrawTitlebar(true);
MainInternalWindow->setResizable(false);
/******************************************************
The Drawing Surface is created the
same as with previous Tutorials
(however the MainInternalWindow is created
in a function below).
******************************************************/
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
/******************************************************
Create the 3D UIRectangle. This allows
the DrawingSurface to be rotated relative
to the screen, allowing a 3D aspect to
the DrawingSurface. The Surface
can still be interacted with, so Buttons,
Menus, etc. all will still function
normally.
-setPoint(Pnt3f): Determine the location
of the UIRectangle in 3D space. Keep
in mind that (0,0,0) is located
directly in the center of the sceen.
示例7: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
{
// Set up Window
WindowEventProducerRecPtr TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
// Create the SimpleSceneManager helper
SimpleSceneManagerRefPtr sceneManager = SimpleSceneManager::create();
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(keyTyped, _1));
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
ButtonRefPtr ExampleButton = OSG::Button::create();
ExampleButton->setMinSize(Vec2f(50, 25));
ExampleButton->setMaxSize(Vec2f(200, 100));
ExampleButton->setPreferredSize(Vec2f(100, 50));
ExampleButton->setText("Button 1");
// Create an ActionListener and assign it to ExampleButton
// This Class is defined above, and will cause the output
// window to display "Button 1 Action" when pressed
ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1));
//Toggle Button
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
//Text Field
TextFieldRefPtr ExampleTextField = OSG::TextField::create();
//Password Field
PasswordFieldRefPtr ExamplePasswordField = OSG::PasswordField::create();
LayoutRefPtr MainLayout = OSG::FlowLayout::create();
//Panel
PanelRecPtr ExamplePanel = Panel::create();
ExamplePanel->setPreferredSize(Vec2f(200.0f,200.0f));
ExamplePanel->setLayout(MainLayout);
ExamplePanel->pushToChildren(ExampleTextField);
ExamplePanel->pushToChildren(ExamplePasswordField);
//Text Field 2
TextFieldRefPtr ExampleTextField2 = OSG::TextField::create();
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton);
MainInternalWindow->pushToChildren(ExampleToggleButton);
MainInternalWindow->pushToChildren(ExamplePanel);
MainInternalWindow->pushToChildren(ExampleTextField2);
MainInternalWindow->setLayout(MainLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
sceneManager->setRoot(scene);
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
LeftPanelLabel1->setBorders(emptyBorder);
LeftPanelLabel1->setBackgrounds(GreyBackground);
LeftPanelLabel1->setFont(LeftPanelLabel1Font);
LeftPanelLabel1->setText("OSG Gui");
LeftPanelLabel1->setPreferredSize(Vec2f(300, 100));
LeftPanelLabel1->setAlignment(Vec2f(0.0f, 0.5f));
/******************************************************
Create some Layouts
******************************************************/
BoxLayoutRefPtr MainInternalWindowLayout = OSG::BoxLayout::create();
FlowLayoutRefPtr LeftPanelLayout = OSG::FlowLayout::create();
BoxLayoutRefPtr RightPanelLayout = OSG::BoxLayout::create();
MainInternalWindowLayout->setOrientation(BoxLayout::HORIZONTAL_ORIENTATION);
LeftPanelLayout->setOrientation(FlowLayout::HORIZONTAL_ORIENTATION);
LeftPanelLayout->setMinorAxisAlignment(1.0f);
RightPanelLayout->setOrientation(BoxLayout::VERTICAL_ORIENTATION);
/******************************************************
Create MainFrame and Panels
******************************************************/
PanelRefPtr LeftPanel = OSG::Panel::create();
PanelRefPtr RightPanel = OSG::Panel::create();
// LeftPanel stuff
LeftPanel->setPreferredSize(Vec2f(400, 500));
LeftPanel->pushToChildren(LeftPanelLabel1);
LeftPanel->pushToChildren(createLeftPanelButtonPanel());
LeftPanel->pushToChildren(createLeftPanelRadioTextPanel());
LeftPanel->setLayout(LeftPanelLayout);
LeftPanel->setBackgrounds(GreyBackground);
LeftPanel->setBorders(Panel1Border);
//RightPanel stuff
RightPanel->setPreferredSize(Vec2f(200, 620));
RightPanel->pushToChildren(createRightPanelButtonPanel());
RightPanel->pushToChildren(createRightPanelCheckPanel());
RightPanel->setLayout(RightPanelLayout);
RightPanel->setBackgrounds(GreyBackground);
RightPanel->setBorders(Panel2Border);
// Create The Main InternalWindow
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(LeftPanel);
MainInternalWindow->pushToChildren(RightPanel);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(GreyBackground);
MainInternalWindow->setBorders(PanelBorder);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Make A 3D Rectangle to draw the UI on
UIRectangleRefPtr UIRectCore = UIRectangle::create();
UIRectCore->setPoint(Pnt3f(-310.0,-310.0,370.0));
UIRectCore->setWidth(620);
UIRectCore->setHeight(620);
UIRectCore->setDrawingSurface(TutorialDrawingSurface);
NodeRefPtr UIRectNode = OSG::Node::create();
UIRectNode->setCore(UIRectCore);
// add the UIRect as a child
scene->addChild(UIRectNode);
mgr->setRoot(scene);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"21ExampleInterface");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例9: main
//.........这里部分代码省略.........
// Create an Action and assign it to ExampleButton
// This Class is defined above, and will cause the output
// window to display "Button 1 Action" when pressed
ExampleButton->connectActionPerformed(boost::bind(actionPerformed, _1));
/******************************************************
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).
******************************************************/
ToggleButtonRefPtr ExampleToggleButton = OSG::ToggleButton::create();
ExampleToggleButton->setSelected(false);
ExampleToggleButton->setText("ToggleMe");
ExampleToggleButton->setToolTipText("Toggle Button ToolTip");
//Button with Image
ButtonRefPtr ExampleDrawObjectButton = OSG::Button::create();
ExampleDrawObjectButton->setDrawObjectToTextAlignment(Button::ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT);
ExampleDrawObjectButton->setText("Icon");
ExampleDrawObjectButton->setImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setActiveImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setFocusedImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setRolloverImage(std::string("./Data/Icon.png"));
ExampleDrawObjectButton->setDisabledImage(std::string("./Data/Icon.png"));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(ExampleButton);
MainInternalWindow->pushToChildren(ExampleToggleButton);
MainInternalWindow->pushToChildren(ExampleDrawObjectButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
sceneManager->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = sceneManager->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
//Create the Documentation Foreground and add it to the viewport
SimpleScreenDoc TheSimpleScreenDoc(sceneManager, TutorialWindow);
// Show the whole Scene
sceneManager->showAll();
//Attach key controls
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"01Button");
commitChanges();
//Enter main Loop
TutorialWindow->mainLoop();
}
osgExit();
return 0;
}
示例10: main
//.........这里部分代码省略.........
******************************************************/
//Create the ComboBox
ComboBoxRefPtr ExampleComboBox = ComboBox::create();
// Set the Model created above to the ComboBox
ExampleComboBox->setModel(ExampleComboBoxModel);
// Determine where the ComboBox starts
ExampleComboBox->setSelectedIndex(0);
/******************************************************
Create a non-editable ComboBox.
-setEditable(bool): Determine whether
the user can type in the ComboBox
or if it is uneditable. In this
case, it is set to false.
When creating a non-editable ComboBox,
a Renderer must also be assigned. For
editable ComboBoxes, the ComboBox
automatically shows its text due to the
nature of the ComboBox. However, when
uneditable, this aspect of the ComboBox
is disabled, and so to display the
selection, a renderer must be created and
assigned to the ComboBox.
Note: as with Sliders and ScrollBars,
having the same Model assigned causes
the ComboBoxes to be tied together.
******************************************************/
// Create another ComboBox
ComboBoxRefPtr ExampleUneditableComboBox = ComboBox::create();
// Set it to be uneditable
ExampleUneditableComboBox->setEditable(false);
ExampleUneditableComboBox->setModel(ExampleComboBoxModel);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleComboBox);
MainInternalWindow->pushToChildren(ExampleUneditableComboBox);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(graphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr foreground = OSG::UIForeground::create();
foreground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr viewport = mgr->getWindow()->getPort(0);
viewport->addForeground(foreground);
// Show the whole scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"33ComboBox");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例11: main
//.........这里部分代码省略.........
-setText("TextToBeDisplayed"): Determine
initial Text within TextField.
-setFont(FontName): Determine the Font
used within TextField.
-setSelectionStart(StartCharacterNumber):
Determine the character with which
the selection will initially start.
-setSelectionEnd(EndCharacterNumber):
Determine the character which the
selection ends before.
-setAlignment(float): Determine
the alignment of the text.
The float is a percentage is from the
top of the text [0.0-1.0]. Note: be
sure to visually verify this, as due
to font size and line size this does
not always place it exactly
at the percentage point.
******************************************************/
// Create a TextField component
TextFieldRefPtr ExampleTextField = OSG::TextField::create();
ExampleTextField->setPreferredSize(Vec2f(100, 50));
ExampleTextField->setTextColor(Color4f(0.0, 0.0, 0.0, 1.0));
ExampleTextField->setSelectionBoxColor(Color4f(0.0, 0.0, 1.0, 1.0));
ExampleTextField->setSelectionTextColor(Color4f(1.0, 1.0, 1.0, 1.0));
ExampleTextField->setText("What");
ExampleTextField->setFont(sampleFont);
// The next two functions will select the "a" from above
ExampleTextField->setSelectionStart(2);
ExampleTextField->setSelectionEnd(3);
ExampleTextField->setAlignment(Vec2f(0.0,0.5));
// Create another TextField Component
TextFieldRefPtr ExampleTextField2 = OSG::TextField::create();
ExampleTextField2->setText("");
ExampleTextField2->setEmptyDescText("Write in me, please");
ExampleTextField2->setPreferredSize(Vec2f(200.0f,ExampleTextField2->getPreferredSize().y()));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleTextField);
MainInternalWindow->pushToChildren(ExampleTextField2);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"16TextField");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例12: main
//.........这里部分代码省略.........
distorted. For Layouts which will often
be dynamically changed, FlowLayout is not
the best choice.
-setHorizontalGap(int): Determine the Horizontal
gap in pixels between Components in
FlowLayout.
-setVerticalGap(int): Determine the Vertical
gap in pixels between Components in
FlowLayout.
-setOrientation(ENUM): Determine whether the
Layout is arranged Vertically or
Horizontally. Takes HORIZONTAL_ORIENTATION
or VERTICAL_ORIENTATION arguments.
-setMajorAxisAlignment(ENUM): Determines
the alignment of the entire Layout
within its ComponentContainer. See below.
-setMinorAxistAlignment(ENUM): Determines
the alignment of Components within
the Layout. See below.
Both of the last two functions take the
following arguments: AXIS_MAX_ALIGNMENT,
AXIS_CENTER_ALIGNMENT, and AXIS_MIN_ALIGNMENT.
MAX puts it to the bottom/right, CENTER
centers it, and MIN puts it to the
top/left (for Vertical/Horizontal as
set above, respectively).
******************************************************/
FlowLayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindowLayout->setHorizontalGap(3.0f);
MainInternalWindowLayout->setVerticalGap(3.0f);
MainInternalWindowLayout->setOrientation(FlowLayout::VERTICAL_ORIENTATION);
MainInternalWindowLayout->setMajorAxisAlignment(0.5f);
MainInternalWindowLayout->setMinorAxisAlignment(1.0f);
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleButton1);
MainInternalWindow->pushToChildren(ExampleButton2);
MainInternalWindow->pushToChildren(ExampleButton3);
MainInternalWindow->pushToChildren(ExampleButton4);
MainInternalWindow->pushToChildren(ExampleButton5);
MainInternalWindow->pushToChildren(ExampleButton6);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Add a 10 pixel "padding" inside the MainFrame
MainInternalWindow->setAllInsets(10);
//Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"05FlowLayout");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}
示例13: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindow = createNativeWindow();
TutorialWindow->initWindow();
TutorialWindow->setDisplayCallback(display);
TutorialWindow->setReshapeCallback(reshape);
TutorialKeyListener TheKeyListener;
TutorialWindow->addKeyListener(&TheKeyListener);
// Make Torus Node (creates Torus in background of scene)
NodeRefPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16);
// Make Main Scene Node and add the Torus
NodeRefPtr scene = OSG::Node::create();
scene->setCore(OSG::Group::create());
scene->addChild(TorusGeometryNode);
// Create the Graphics
GraphicsRefPtr TutorialGraphics = OSG::Graphics2D::create();
// Initialize the LookAndFeelManager to enable default settings
LookAndFeelManager::the()->getLookAndFeel()->init();
//Background
SolidBackgroundRefPtr TutorialBackground = SolidBackground::create();
TutorialBackground->setColor(Color3f(1.0,0.0,0.0));
TheUndoManager = UndoManager::create();
UndoManagerChangeListener TheUndoManagerChangeListener;
TheUndoManager->addChangeListener(&TheUndoManagerChangeListener);
TheCommandManager = CommandManager::create(TheUndoManager);
//UndoList
UndoRedoListModel = DefaultListModel::create();
UndoRedoListModel->pushBack(boost::any(std::string("Top")));
ListSelectionModelPtr UndoRedoListSelectionModel(new DefaultListSelectionModel());
UndoRedoList = List::create();
UndoRedoList->setPreferredSize(Vec2f(200, 300));
UndoRedoList->setOrientation(List::VERTICAL_ORIENTATION);
UndoRedoList->setModel(UndoRedoListModel);
UndoRedoList->setSelectionModel(UndoRedoListSelectionModel);
UndoRedoListListener TheUndoRedoListListener;
UndoRedoList->getSelectionModel()->addListSelectionListener(&TheUndoRedoListListener);
UndoButton = OSG::Button::create();
UndoButton->setText("Undo");
UndoButton->setEnabled(TheUndoManager->numberOfUndos() != 0);
UndoButtonActionListener TheUndoButtonActionListener;
UndoButton->addActionListener(&TheUndoButtonActionListener);
RedoButton = OSG::Button::create();
RedoButton->setText("Redo");
RedoButton->setEnabled(TheUndoManager->numberOfRedos() != 0);
RedoButtonActionListener TheRedoButtonActionListener;
RedoButton->addActionListener(&TheRedoButtonActionListener);
// Create a ScrollPanel for easier viewing of the List (see 27ScrollPanel)
ScrollPanelRefPtr UndoRedoScrollPanel = ScrollPanel::create();
UndoRedoScrollPanel->setPreferredSize(Vec2f(200,200));
UndoRedoScrollPanel->setHorizontalResizePolicy(ScrollPanel::RESIZE_TO_VIEW);
UndoRedoScrollPanel->setViewComponent(UndoRedoList);
//Background Editor Field
//FieldEditorComponentRefPtr TheEditor = FieldEditorFactory::the()->createDefaultEditor(TutorialBackground, SolidBackground::ColorFieldId, TheCommandManager);
FieldEditorComponentRefPtr TheEditor = FieldEditorFactory::the()->createDefaultEditor(RedoButton, Button::TextFieldId, TheCommandManager);
TheEditor->setPreferredSize(Vec2f(100.0f, 20.0f));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
ColorLayerRefPtr MainInternalWindowBackground = OSG::ColorLayer::create();
MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
MainInternalWindow->pushToChildren(TheEditor);
MainInternalWindow->pushToChildren(UndoRedoScrollPanel);
MainInternalWindow->pushToChildren(UndoButton);
MainInternalWindow->pushToChildren(RedoButton);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.95f,0.95f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
//.........这里部分代码省略.........
示例14: main
//.........这里部分代码省略.........
/******************************************************
Create MainMenuBar and adds the Menus
created above to it.
Also creates several Backgrounds
to improve MenuBar overall look.
Both the MenuBar and Menu can have
Backgrounds; the set up currently
is to have EmptyBackgrounds in
each Menu allowing a single
overall MenuBar Background which
is given to the MenuBar itself.
This can be easily changed by adding
different Backgrounds to the
File and Edit Menus.
Note: The MenuBar is added to the
MainFrame below.
******************************************************/
// Creates two Backgrounds
MenuBarRefPtr MainMenuBar = MenuBar::create();
// Adds the two Menus to the MainMenuBar
MainMenuBar->addMenu(FileMenu);
MainMenuBar->addMenu(EditMenu);
// Create two Labels
LabelRefPtr ExampleLabel1 = OSG::Label::create();
LabelRefPtr ExampleLabel2 = OSG::Label::create();
ExampleLabel1->setText("Look up in the corner!");
ExampleLabel1->setPreferredSize(Vec2f(150, 25));
ExampleLabel2->setText("Hit Control + Z");
ExampleLabel2->setPreferredSize(Vec2f(150, 25));
// Create The Main InternalWindow
// Create Background to be used with the Main InternalWindow
EmptyLayerRefPtr MainInternalWindowBackground = OSG::EmptyLayer::create();
EmptyBorderRefPtr MainInternalWindowBorder = OSG::EmptyBorder::create();
LayoutRefPtr MainInternalWindowLayout = OSG::FlowLayout::create();
InternalWindowRefPtr MainInternalWindow = OSG::InternalWindow::create();
MainInternalWindow->pushToChildren(ExampleLabel1);
MainInternalWindow->pushToChildren(ExampleLabel2);
MainInternalWindow->setLayout(MainInternalWindowLayout);
MainInternalWindow->setMenuBar(MainMenuBar);
MainInternalWindow->setBackgrounds(MainInternalWindowBackground);
MainInternalWindow->setBorders(MainInternalWindowBorder);
MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f));
MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f));
MainInternalWindow->setDrawTitlebar(false);
MainInternalWindow->setResizable(false);
// Create the Drawing Surface
UIDrawingSurfaceRefPtr TutorialDrawingSurface = UIDrawingSurface::create();
TutorialDrawingSurface->setGraphics(TutorialGraphics);
TutorialDrawingSurface->setEventProducer(TutorialWindow);
TutorialDrawingSurface->openWindow(MainInternalWindow);
// Create the UI Foreground Object
UIForegroundRefPtr TutorialUIForeground = OSG::UIForeground::create();
TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(TutorialWindow);
mgr->setRoot(scene);
// Add the UI Foreground Object to the Scene
ViewportRefPtr TutorialViewport = mgr->getWindow()->getPort(0);
TutorialViewport->addForeground(TutorialUIForeground);
// Show the whole Scene
mgr->showAll();
//Open Window
Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f);
Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5);
TutorialWindow->openWindow(WinPos,
WinSize,
"26MenuBar");
//Enter main Loop
TutorialWindow->mainLoop();
osgExit();
return 0;
}