Label 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 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. // Code by: Jeremy Moles (cubicool) 2007-2008
  14. #ifndef OSGWIDGET_LABEL
  15. #define OSGWIDGET_LABEL
  16. #include <osgText/Text>
  17. #include <osgWidget/Widget>
  18. #include <osgWidget/Window>
  19. namespace osgWidget {
  20. class OSGWIDGET_EXPORT Label: public Widget
  21. {
  22. public:
  23. META_Object (osgWidget, Label);
  24. Label (const std::string& = "", const std::string& = "");
  25. Label (const Label&, const osg::CopyOp&);
  26. virtual void parented (Window*);
  27. virtual void unparented (Window*);
  28. virtual void positioned ();
  29. void setLabel (const std::string&);
  30. void setLabel (const osgText::String&);
  31. void setFont (const std::string&);
  32. void setFontSize (unsigned int);
  33. void setFontColor (const Color&);
  34. void setShadow (point_type);
  35. XYCoord getTextSize() const;
  36. std::string getLabel() const { return _text->getText().createUTF8EncodedString(); }
  37. void setFontColor(point_type r, point_type g, point_type b, point_type a) { setFontColor(Color(r, g, b, a)); }
  38. osgText::Text* getText() { return _text.get(); }
  39. const osgText::Text* getText() const { return _text.get(); }
  40. protected:
  41. osg::ref_ptr<osgText::Text> _text;
  42. unsigned int _textIndex;
  43. virtual void _calculateSize(const XYCoord&);
  44. };
  45. }
  46. #endif