LineEdit 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
  2. *
  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.
  7. *
  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.
  12. */
  13. #ifndef OSGUI_LINEEDIT
  14. #define OSGUI_LINEEDIT
  15. #include <osgUI/Widget>
  16. #include <osgUI/Validator>
  17. #include <osgText/Text>
  18. namespace osgUI
  19. {
  20. class OSGUI_EXPORT LineEdit : public osgUI::Widget
  21. {
  22. public:
  23. LineEdit();
  24. LineEdit(const LineEdit& label, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  25. META_Node(osgUI, LineEdit);
  26. void setText(const std::string& text);
  27. const std::string& getText() const { return _text; }
  28. virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event);
  29. virtual void createGraphicsImplementation();
  30. virtual void enterImplementation();
  31. virtual void leaveImplementation();
  32. void setValidator(Validator* validator) { _validator = validator; }
  33. Validator* getValidator() { return _validator.get(); }
  34. const Validator* getValidator() const { return _validator.get(); }
  35. virtual void textChanged(const std::string& text);
  36. virtual void textChangedImplementation(const std::string& text);
  37. virtual void returnPressed() { if (!runCallbacks("returnPressed")) returnPressedImplementation(); }
  38. virtual void returnPressedImplementation();
  39. protected:
  40. virtual ~LineEdit() {}
  41. osg::ref_ptr<Validator> _validator;
  42. std::string _text;
  43. // implementation detail
  44. osg::ref_ptr<osg::Switch> _backgroundSwitch;
  45. osg::ref_ptr<osgText::Text> _textDrawable;
  46. };
  47. }
  48. #endif