1 #include <osgUI/ComboBox> 2 #include <osg/ValueObject> 3 #include <osgDB/ObjectWrapper> 4 #include <osgDB/InputStream> 5 #include <osgDB/OutputStream> 6 7 struct ComboBoxCurrentIndexChangedImplementation : public osgDB::MethodObject 8 { runComboBoxCurrentIndexChangedImplementation9 virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const 10 { 11 if (inputParameters.empty()) return false; 12 13 osg::Object* indexObject = inputParameters[0].get(); 14 15 unsigned int index = 0; 16 osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject); 17 if (dvo) index = static_cast<unsigned int>(dvo->getValue()); 18 else 19 { 20 osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject); 21 if (uivo) index = uivo->getValue(); 22 } 23 osgUI::ComboBox* cb = reinterpret_cast<osgUI::ComboBox*>(objectPtr); 24 cb->currentIndexChangedImplementation(index); 25 26 return true; 27 } 28 }; 29 30 REGISTER_OBJECT_WRAPPER( ComboBox, 31 new osgUI::ComboBox, 32 osgUI::ComboBox, 33 "osg::Object osg::Node osg::Group osgUI::Widget osgUI::ComboBox" ) 34 { 35 ADD_UINT_SERIALIZER(CurrentIndex, 0); 36 ADD_VECTOR_SERIALIZER( Items, osgUI::ComboBox::Items, osgDB::BaseSerializer::RW_OBJECT, 0 ); 37 ADD_METHOD_OBJECT( "currentIndexChangedImplementation", ComboBoxCurrentIndexChangedImplementation ); 38 } 39