1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
18#include <osg/BoundingBox>
20#include <osgGA/EventVisitor>
25class OSGGA_EXPORT Widget : public osg::Group
29 Widget(const Widget& tfw, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
30 META_Node(osgGA, Widget);
32 virtual void traverse(osg::NodeVisitor& nv);
33 virtual void traverseImplementation(osg::NodeVisitor& nv);
35 virtual bool handle(osgGA::EventVisitor* ev, osgGA::Event* event);
36 virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event);
38 virtual bool computePositionInLocalCoordinates(osgGA::EventVisitor* ev, osgGA::GUIEventAdapter* event, osg::Vec3& localPosition) const;
40 virtual void createGraphics();
41 virtual void createGraphicsImplementation();
43 virtual void setExtents(const osg::BoundingBoxf& bb);
44 const osg::BoundingBoxf& getExtents() const { return _extents; }
49 FOCUS_FOLLOWS_POINTER,
50 EVENT_DRIVEN_FOCUS_DISABLED
53 void setFocusBehaviour(FocusBehaviour behaviour) { _focusBehaviour = behaviour; }
54 FocusBehaviour getFocusBehaviour() const { return _focusBehaviour; }
56 /** update the focus according to events.*/
57 virtual void updateFocus(osg::NodeVisitor& nv);
59 /** set whether the widget has focus or not.*/
60 virtual void setHasEventFocus(bool focus);
62 /** get whether the widget has focus or not.*/
63 virtual bool getHasEventFocus() const;
65 virtual osg::BoundingSphere computeBound() const;
67 /** update any focus related graphics+state to the focused state.*/
69 virtual void enterImplementation();
71 /** update any focus related graphics+state to the unfocused state.*/
73 virtual void leaveImplementation();
79 FocusBehaviour _focusBehaviour;
81 bool _graphicsInitialized;
83 osg::BoundingBoxf _extents;