OpenSceneGraph 3.6.5
Input
Go to the documentation of this file.
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_INPUT
17#define OSGWIDGET_INPUT
18
19#include <osgWidget/Label>
20
21namespace osgWidget {
22
23// This is a string of values we use to try and determine the best Y
24// descent value (yoffset); you're welcome to use what works best for
25// your font.
26const std::string DESCENT_STRING("qpl");
27
29{
30 public:
31
32 Input(const std::string& = "", const std::string& = "", unsigned int = 20);
33
34 virtual void parented (Window*);
35 virtual void positioned ();
36
37 virtual bool focus (const WindowManager*);
38 virtual bool unfocus (const WindowManager*);
39 virtual bool keyUp (int, int, const WindowManager*);
40 virtual bool keyDown (int, int, const WindowManager*);
41 virtual bool mouseDrag (double, double, const WindowManager*);
42 virtual bool mousePush (double x, double y, const WindowManager*);
43 virtual bool mouseRelease (double, double, const WindowManager*);
44
46 unsigned int calculateBestYOffset (const std::string& = "qgl");
47 void clear();
48
50 _xoff = xo;
51 }
52
54 _yoff = yo;
55 }
56
58 _xoff = xo;
59 _yoff = yo;
60 }
61
63 return _cursor.get();
64 }
65
66 const osg::Drawable* getCursor() const {
67 return _cursor.get();
68 }
69
71 return _xoff;
72 }
73
75 return _yoff;
76 }
77
79 return XYCoord(_xoff, _yoff);
80 }
81
82 protected:
83 virtual void _calculateSize(const XYCoord&);
84
86
89
90 unsigned int _index;
91 unsigned int _size;
92 unsigned int _cursorIndex;
93 unsigned int _maxSize;
94
95 std::vector<point_type> _offsets;
96 std::vector<unsigned int> _wordsOffsets;
97 std::vector<point_type> _widths;
99
100 bool _insertMode; // Insert was pressed --> true --> typing will overwrite existing text
101
104 unsigned int _selectionEndIndex;
105 unsigned int _selectionIndex;
106
108};
109
110}
111
112#endif
The osgWidget library is a NodeKit that extends the core scene graph to support a 2D (and eventually ...
Definition Box:21
Point::value_type point_type
Definition Types:33
osg::Vec2 XYCoord
Definition Types:36
const std::string DESCENT_STRING("qpl")
Pure virtual base class for drawable geometry.
Definition Drawable:89
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
std::vector< point_type > _widths
Definition Input:97
void setXOffset(point_type xo)
Definition Input:49
unsigned int calculateBestYOffset(const std::string &="qgl")
virtual bool keyDown(int, int, const WindowManager *)
unsigned int _index
Definition Input:90
std::vector< point_type > _offsets
Definition Input:95
virtual bool unfocus(const WindowManager *)
virtual void parented(Window *)
virtual void positioned()
virtual void _calculateSize(const XYCoord &)
unsigned int _selectionEndIndex
Definition Input:104
XYCoord getXYOffset() const
Definition Input:78
const osg::Drawable * getCursor() const
Definition Input:66
point_type getXOffset() const
Definition Input:70
virtual bool mouseRelease(double, double, const WindowManager *)
point_type _mouseClickX
Definition Input:107
std::vector< unsigned int > _wordsOffsets
Definition Input:96
osg::ref_ptr< Widget > _selection
Definition Input:102
unsigned int _selectionStartIndex
Definition Input:103
void setYOffset(point_type yo)
Definition Input:53
osg::ref_ptr< Widget > _cursor
Definition Input:98
virtual bool keyUp(int, int, const WindowManager *)
virtual bool mouseDrag(double, double, const WindowManager *)
unsigned int _selectionIndex
Definition Input:105
unsigned int _size
Definition Input:91
point_type getYOffset() const
Definition Input:74
void setXYOffset(point_type xo, point_type yo)
Definition Input:57
unsigned int _cursorIndex
Definition Input:92
unsigned int _maxSize
Definition Input:93
virtual bool focus(const WindowManager *)
point_type _xoff
Definition Input:87
void setCursor(Widget *)
Input(const std::string &="", const std::string &="", unsigned int=20)
osg::Drawable * getCursor()
Definition Input:62
virtual bool mousePush(double x, double y, const WindowManager *)
void _calculateCursorOffsets()
bool _insertMode
Definition Input:100
point_type _yoff
Definition Input:88
Label(const std::string &="", const std::string &="")
Definition Widget:35
Definition Window:44
Definition WindowManager:39
#define OSGWIDGET_EXPORT
Definition Export:42

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.