- Timestamp:
- 12/16/08 21:29:00 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgwidgetstyled/osgwidgetstyled.cpp
r8588 r9370 10 10 11 11 const std::string& STYLE1 = 12 "color 0 0 0 128\n"13 "padding 5\n"12 "color 0 0 0 128\n" 13 "padding 5\n" 14 14 ; 15 15 16 16 const std::string& STYLE2 = 17 "color 1.0 0.5 0.0\n"17 "color 1.0 0.5 0.0\n" 18 18 ; 19 19 20 20 const std::string& STYLE3 = 21 "fill true\n"21 "fill true\n" 22 22 ; 23 23 24 24 const std::string& STYLE4 = 25 "pos 100.0 100.0\n"26 "size 600 600\n"25 "pos 100.0 100.0\n" 26 "size 600 600\n" 27 27 ; 28 28 … … 31 31 32 32 class CustomStyle: public osgWidget::Style { 33 virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) {34 CustomStyled* cs = dynamic_cast<CustomStyled*>(w);33 virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) { 34 CustomStyled* cs = dynamic_cast<CustomStyled*>(w); 35 35 36 if(!cs) return false;36 if(!cs) return false; 37 37 38 osgWidget::warn() << "Here, okay." << std::endl;38 osgWidget::warn() << "Here, okay." << std::endl; 39 39 40 return true;41 }40 return true; 41 } 42 42 }; 43 43 44 44 int main(int argc, char** argv) { 45 osgViewer::Viewer viewer;45 osgViewer::Viewer viewer; 46 46 47 osgWidget::WindowManager* wm = new osgWidget::WindowManager(48 &viewer,49 1280.0f,50 1024.0f,51 MASK_2D52 );47 osgWidget::WindowManager* wm = new osgWidget::WindowManager( 48 &viewer, 49 1280.0f, 50 1024.0f, 51 MASK_2D 52 ); 53 53 54 osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL);54 osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL); 55 55 56 osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f);57 osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f);58 osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f);59 CustomStyled* cs = new CustomStyled();56 osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f); 57 osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f); 58 osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f); 59 CustomStyled* cs = new CustomStyled(); 60 60 61 // Yep.62 wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1));63 wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2));64 wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3));65 wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4));66 // wm->getStyleManager()->addStyle(new CustomStyle("widget", ""));61 // Yep. 62 wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1)); 63 wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2)); 64 wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3)); 65 wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4)); 66 // wm->getStyleManager()->addStyle(new CustomStyle("widget", "")); 67 67 68 widget1->setStyle("widget.style1");69 widget2->setStyle("widget.style2");70 widget3->setStyle("spacer");68 widget1->setStyle("widget.style1"); 69 widget2->setStyle("widget.style2"); 70 widget3->setStyle("spacer"); 71 71 72 box->setStyle("window");72 box->setStyle("window"); 73 73 74 box->addWidget(widget1);75 box->addWidget(widget2);76 box->addWidget(widget3);74 box->addWidget(widget1); 75 box->addWidget(widget2); 76 box->addWidget(widget3); 77 77 78 wm->addChild(box);78 wm->addChild(box); 79 79 80 // box->resizePercent(0.0f, 100.0f);80 // box->resizePercent(0.0f, 100.0f); 81 81 82 return osgWidget::createExample(viewer, wm);82 return osgWidget::createExample(viewer, wm); 83 83 }
