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