osgEarth 2.1.1
Public Member Functions | Protected Member Functions | Private Attributes

osgEarth::Util::Controls::CheckBoxControl Class Reference

Inheritance diagram for osgEarth::Util::Controls::CheckBoxControl:
Collaboration diagram for osgEarth::Util::Controls::CheckBoxControl:

List of all members.

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

Detailed Description

A check box toggle.

Definition at line 366 of file Controls.


Constructor & Destructor Documentation

CheckBoxControl::CheckBoxControl ( bool  checked = false)

Definition at line 913 of file Controls.cpp.

                                             :
_value( value )
{
    setWidth( 16 );
    setHeight( 16 );
}

Here is the call graph for this function:

CheckBoxControl::CheckBoxControl ( bool  checked,
ControlEventHandler callback 
)

Definition at line 920 of file Controls.cpp.

                                                                           :
_value( value )
{
    this->addEventHandler( handler );
    setWidth( 16 );
    setHeight( 16 );
}

Here is the call graph for this function:


Member Function Documentation

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 );
    }
}

Here is the call graph for this function:

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 );
    }
}

Here is the caller graph for this function:

bool osgEarth::Util::Controls::CheckBoxControl::getValue ( ) const [inline]

Definition at line 373 of file Controls.

{ return _value; }
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 );
}

Here is the call graph for this function:

void CheckBoxControl::setValue ( bool  value)

Definition at line 938 of file Controls.cpp.

{
    if ( value != _value )
    {
        _value = value;
        fireValueChanged();
        dirty();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 384 of file Controls.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines