openscenegraph
include
osgWidget
osgWidget/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
21
namespace
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.
26
const
std::string
DESCENT_STRING
(
"qpl"
);
27
28
class
OSGWIDGET_EXPORT
Input
:
public
Label
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
45
void
setCursor
(
Widget
*);
46
unsigned
int
calculateBestYOffset
(
const
std::string& =
"qgl"
);
47
void
clear
();
48
49
void
setXOffset
(
point_type
xo) {
50
_xoff = xo;
51
}
52
53
void
setYOffset
(
point_type
yo) {
54
_yoff = yo;
55
}
56
57
void
setXYOffset
(
point_type
xo,
point_type
yo) {
58
_xoff = xo;
59
_yoff = yo;
60
}
61
62
osg::Drawable
*
getCursor
() {
63
return
_cursor.get();
64
}
65
66
const
osg::Drawable
*
getCursor
()
const
{
67
return
_cursor.get();
68
}
69
70
point_type
getXOffset
()
const
{
71
return
_xoff;
72
}
73
74
point_type
getYOffset
()
const
{
75
return
_yoff;
76
}
77
78
XYCoord
getXYOffset
()
const
{
79
return
XYCoord
(_xoff, _yoff);
80
}
81
82
protected
:
83
virtual
void
_calculateSize
(
const
XYCoord
&);
84
85
void
_calculateCursorOffsets
();
86
87
point_type
_xoff
;
88
point_type
_yoff
;
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
;
98
osg::ref_ptr<Widget>
_cursor
;
99
100
bool
_insertMode
;
// Insert was pressed --> true --> typing will overwrite existing text
101
102
osg::ref_ptr<Widget>
_selection
;
103
unsigned
int
_selectionStartIndex
;
104
unsigned
int
_selectionEndIndex
;
105
unsigned
int
_selectionIndex
;
106
107
point_type
_mouseClickX
;
108
};
109
110
}
111
112
#endif
osgWidget::Input
Definition
osgWidget/Input:29
osgWidget::Input::_widths
std::vector< point_type > _widths
Definition
osgWidget/Input:97
osgWidget::Input::setXOffset
void setXOffset(point_type xo)
Definition
osgWidget/Input:49
osgWidget::Input::calculateBestYOffset
unsigned int calculateBestYOffset(const std::string &="qgl")
osgWidget::Input::keyDown
virtual bool keyDown(int, int, const WindowManager *)
osgWidget::Input::_index
unsigned int _index
Definition
osgWidget/Input:90
osgWidget::Input::_offsets
std::vector< point_type > _offsets
Definition
osgWidget/Input:95
osgWidget::Input::unfocus
virtual bool unfocus(const WindowManager *)
osgWidget::Input::parented
virtual void parented(Window *)
osgWidget::Input::positioned
virtual void positioned()
osgWidget::Input::_calculateSize
virtual void _calculateSize(const XYCoord &)
osgWidget::Input::_selectionEndIndex
unsigned int _selectionEndIndex
Definition
osgWidget/Input:104
osgWidget::Input::getXYOffset
XYCoord getXYOffset() const
Definition
osgWidget/Input:78
osgWidget::Input::getCursor
const osg::Drawable * getCursor() const
Definition
osgWidget/Input:66
osgWidget::Input::getXOffset
point_type getXOffset() const
Definition
osgWidget/Input:70
osgWidget::Input::mouseRelease
virtual bool mouseRelease(double, double, const WindowManager *)
osgWidget::Input::_mouseClickX
point_type _mouseClickX
Definition
osgWidget/Input:107
osgWidget::Input::_wordsOffsets
std::vector< unsigned int > _wordsOffsets
Definition
osgWidget/Input:96
osgWidget::Input::_selection
osg::ref_ptr< Widget > _selection
Definition
osgWidget/Input:102
osgWidget::Input::_selectionStartIndex
unsigned int _selectionStartIndex
Definition
osgWidget/Input:103
osgWidget::Input::setYOffset
void setYOffset(point_type yo)
Definition
osgWidget/Input:53
osgWidget::Input::_cursor
osg::ref_ptr< Widget > _cursor
Definition
osgWidget/Input:98
osgWidget::Input::keyUp
virtual bool keyUp(int, int, const WindowManager *)
osgWidget::Input::mouseDrag
virtual bool mouseDrag(double, double, const WindowManager *)
osgWidget::Input::_selectionIndex
unsigned int _selectionIndex
Definition
osgWidget/Input:105
osgWidget::Input::_size
unsigned int _size
Definition
osgWidget/Input:91
osgWidget::Input::getYOffset
point_type getYOffset() const
Definition
osgWidget/Input:74
osgWidget::Input::setXYOffset
void setXYOffset(point_type xo, point_type yo)
Definition
osgWidget/Input:57
osgWidget::Input::_cursorIndex
unsigned int _cursorIndex
Definition
osgWidget/Input:92
osgWidget::Input::_maxSize
unsigned int _maxSize
Definition
osgWidget/Input:93
osgWidget::Input::focus
virtual bool focus(const WindowManager *)
osgWidget::Input::_xoff
point_type _xoff
Definition
osgWidget/Input:87
osgWidget::Input::setCursor
void setCursor(Widget *)
osgWidget::Input::clear
void clear()
osgWidget::Input::Input
Input(const std::string &="", const std::string &="", unsigned int=20)
osgWidget::Input::getCursor
osg::Drawable * getCursor()
Definition
osgWidget/Input:62
osgWidget::Input::mousePush
virtual bool mousePush(double x, double y, const WindowManager *)
osgWidget::Input::_calculateCursorOffsets
void _calculateCursorOffsets()
osgWidget::Input::_insertMode
bool _insertMode
Definition
osgWidget/Input:100
osgWidget::Input::_yoff
point_type _yoff
Definition
osgWidget/Input:88
osgWidget::Label
Definition
osgWidget/Label:26
osgWidget::Widget
Definition
osgWidget/Widget:35
osgWidget::WindowManager
Definition
WindowManager:39
osgWidget::Window
Definition
Window:44
osg::Drawable
Definition
Drawable:89
osg::Vec2f
Definition
Vec2f:29
osg::ref_ptr
Definition
ref_ptr:32
osgWidget
Definition
Box:21
osgWidget::point_type
Point::value_type point_type
Definition
osgWidget/Types:33
osgWidget::DESCENT_STRING
const std::string DESCENT_STRING("qpl")
OSGWIDGET_EXPORT
#define OSGWIDGET_EXPORT
Definition
osgWidget/Export:42
Label
Generated by
1.9.8