root/OpenSceneGraph/trunk/include/osgWidget/Label @ 9438

Revision 9438, 1.9 kB (checked in by robert, 5 years ago)

From Cedric Pinson, added non const getText() method

Line 
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
14// Code by: Jeremy Moles (cubicool) 2007-2008
15
16#ifndef OSGWIDGET_LABEL
17#define OSGWIDGET_LABEL
18
19#include <osgText/Text>
20#include <osgWidget/Widget>
21#include <osgWidget/Window>
22
23namespace osgWidget {
24
25class OSGWIDGET_EXPORT Label: public Widget
26{
27    public:
28
29        META_Object   (osgWidget, Label);
30
31        Label (const std::string& = "", const std::string& = "");
32        Label (const Label&, const osg::CopyOp&);
33
34        virtual void parented   (Window*);
35        virtual void unparented (Window*);
36        virtual void positioned ();
37
38        void setLabel     (const std::string&);
39        void setFont      (const std::string&);
40        void setFontSize  (unsigned int);
41        void setFontColor (const Color&);
42        void setShadow    (point_type);
43
44        XYCoord getTextSize() const;
45
46        std::string getLabel() const { return _text->getText().createUTF8EncodedString(); }
47
48        void setFontColor(point_type r, point_type g, point_type b, point_type a) { setFontColor(Color(r, g, b, a)); }
49
50        osgText::Text* getText() { return _text.get(); }
51
52        const osgText::Text* getText() const { return _text.get(); }
53
54    protected:
55
56        osg::ref_ptr<osgText::Text> _text;
57        unsigned int _textIndex;
58
59        virtual void _calculateSize(const XYCoord&);
60
61};
62
63}
64
65#endif
Note: See TracBrowser for help on using the browser.