osgEarth 2.1.1
|
Public Member Functions | |
CheckBoxControl (bool checked=false) | |
CheckBoxControl (bool checked, ControlEventHandler *callback) | |
void | setValue (bool value) |
bool | getValue () const |
virtual void | draw (const ControlContext &cx, DrawableList &out) |
Protected Member Functions | |
virtual bool | handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, ControlContext &cx) |
void | fireValueChanged () |
Private Attributes | |
bool | _value |
CheckBoxControl::CheckBoxControl | ( | bool | checked = false | ) |
CheckBoxControl::CheckBoxControl | ( | bool | checked, |
ControlEventHandler * | callback | ||
) |
Definition at line 920 of file Controls.cpp.
: _value( value ) { this->addEventHandler( handler ); setWidth( 16 ); setHeight( 16 ); }
void CheckBoxControl::draw | ( | const ControlContext & | cx, |
DrawableList & | out | ||
) | [virtual] |
Reimplemented from osgEarth::Util::Controls::Control.
Definition at line 949 of file Controls.cpp.
{ Control::draw( cx, out ); if ( visible() == true ) { osg::Geometry* g = new osg::Geometry(); float rx = osg::round( _renderPos.x() ); float ry = osg::round( _renderPos.y() ); float rw = _renderSize.x() - padding().x(); float rh = _renderSize.y() - padding().y(); float vph = cx._vp->height(); // - padding().bottom(); osg::Vec3Array* verts = new osg::Vec3Array(4); g->setVertexArray( verts ); (*verts)[0].set( rx, vph - ry, 0 ); (*verts)[1].set( rx + rw, vph - ry, 0 ); (*verts)[2].set( rx + rw, vph - (ry + rh), 0 ); (*verts)[3].set( rx, vph - (ry + rh), 0 ); g->addPrimitiveSet( new osg::DrawArrays( GL_LINE_LOOP, 0, 4 ) ); if ( _value ) { osg::DrawElementsUByte* e = new osg::DrawElementsUByte( GL_LINES ); e->push_back( 0 ); e->push_back( 2 ); e->push_back( 1 ); e->push_back( 3 ); g->addPrimitiveSet( e ); } osg::Vec4Array* c = new osg::Vec4Array(1); (*c)[0] = *foreColor(); g->setColorArray( c ); g->setColorBinding( osg::Geometry::BIND_OVERALL ); out.push_back( g ); } }
void CheckBoxControl::fireValueChanged | ( | ) | [protected] |
Definition at line 929 of file Controls.cpp.
{ for( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i ) { i->get()->onValueChanged( this, _value ); } }
bool osgEarth::Util::Controls::CheckBoxControl::getValue | ( | ) | const [inline] |
bool CheckBoxControl::handle | ( | const osgGA::GUIEventAdapter & | ea, |
osgGA::GUIActionAdapter & | aa, | ||
ControlContext & | cx | ||
) | [protected, virtual] |
Reimplemented from osgEarth::Util::Controls::Control.
Definition at line 993 of file Controls.cpp.
{ if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH ) { setValue( !_value ); return true; } return Control::handle( ea, aa, cx ); }
void CheckBoxControl::setValue | ( | bool | value | ) |
Definition at line 938 of file Controls.cpp.
{ if ( value != _value ) { _value = value; fireValueChanged(); dirty(); } }
bool osgEarth::Util::Controls::CheckBoxControl::_value [private] |