OpenSceneGraph 3.6.5
ComboBox
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 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#ifndef OSGUI_COMBOBOX
15#define OSGUI_COMBOBOX
16
17#include <osgUI/Popup>
18#include <osg/Switch>
19#include <osgText/Text>
20
21namespace osgUI
22{
23
25{
26public:
27
28 Item() : _color(1.0f,1.0f,1.0f,0.0f) {}
29 Item(const std::string& str) : _text(str), _color(1.0f,1.0f,1.0f,0.0f) {}
30 Item(const std::string& str, const osg::Vec4& col) : _text(str), _color(col) {}
31 Item(const osg::Vec4& col) : _color(col) {}
32
33 Item(const Item& item, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(item,copyop), _text(item._text), _color(item._color) {}
34
36
37 void setText(const std::string& text) { _text = text; }
38 std::string& getText() { return _text; }
39 const std::string& getText() const { return _text; }
40
41 void setColor(const osg::Vec4f& color) { _color = color; }
42 osg::Vec4f& getColor() { return _color; }
43 const osg::Vec4f& getColor() const { return _color; }
44
45protected:
46 virtual ~Item() {}
47
48 std::string _text;
50};
51
53{
54public:
56 ComboBox(const ComboBox& combobox, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
58
59 void addItem(Item* item) { _items.push_back(item); dirty(); }
60
61 void setItem(unsigned int i, Item* item) { _items[i] = item; dirty(); }
62 Item* getItem(unsigned int i) { return _items[i].get(); }
63 const Item* getItem(unsigned int i) const { return _items[i].get(); }
64
65 void clear() { _items.clear(); dirty(); }
66 void removeItem(unsigned int i) { _items.erase(_items.begin()+i); dirty(); }
67 unsigned int getNumItems() { return static_cast<unsigned int>(_items.size()); }
68
69 typedef std::vector< osg::ref_ptr<Item> > Items;
70
71 void setItems(const Items& items) { _items = items; }
72 Items& getItems() { return _items; }
73 const Items& getItems() const { return _items; }
74
75 void setCurrentIndex(unsigned int i);
76 unsigned int getCurrentIndex() const { return _currentIndex; }
77
78 virtual void currrentIndexChanged(unsigned int i);
79 virtual void currentIndexChangedImplementation(unsigned int i);
80
81
84 virtual void enterImplementation();
85 virtual void leaveImplementation();
86
87protected:
88 virtual ~ComboBox() {}
89
91 unsigned int _currentIndex;
94
98};
99
100}
101
102#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec4f Vec4
Definition Vec4:21
Definition AlignmentSettings:23
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Object()
Construct an object.
Definition Object:69
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
General purpose float quad.
Definition Vec4f:28
Base Event class.
Definition Event:27
Basic EventVisitor implementation for animating a scene.
Definition EventVisitor:42
Definition ComboBox:25
const osg::Vec4f & getColor() const
Definition ComboBox:43
Item(const osg::Vec4 &col)
Definition ComboBox:31
Item()
Definition ComboBox:28
Item(const std::string &str, const osg::Vec4 &col)
Definition ComboBox:30
std::string _text
Definition ComboBox:48
void setText(const std::string &text)
Definition ComboBox:37
Item(const std::string &str)
Definition ComboBox:29
std::string & getText()
Definition ComboBox:38
osg::Vec4f & getColor()
Definition ComboBox:42
void setColor(const osg::Vec4f &color)
Definition ComboBox:41
Item(const Item &item, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition ComboBox:33
virtual ~Item()
Definition ComboBox:46
const std::string & getText() const
Definition ComboBox:39
META_Object(osgUI, Item)
osg::Vec4 _color
Definition ComboBox:49
osg::ref_ptr< osg::Switch > _backgroundSwitch
Definition ComboBox:96
META_Node(osgUI, ComboBox)
const Items & getItems() const
Definition ComboBox:73
virtual void leaveImplementation()
void addItem(Item *item)
Definition ComboBox:59
std::vector< osg::ref_ptr< Item > > Items
Definition ComboBox:69
void setCurrentIndex(unsigned int i)
Items & getItems()
Definition ComboBox:72
osg::Vec3d _popupItemOrigin
Definition ComboBox:92
unsigned int _currentIndex
Definition ComboBox:91
virtual ~ComboBox()
Definition ComboBox:88
void removeItem(unsigned int i)
Definition ComboBox:66
Item * getItem(unsigned int i)
Definition ComboBox:62
virtual void currrentIndexChanged(unsigned int i)
const Item * getItem(unsigned int i) const
Definition ComboBox:63
virtual void currentIndexChangedImplementation(unsigned int i)
unsigned int getCurrentIndex() const
Definition ComboBox:76
void setItem(unsigned int i, Item *item)
Definition ComboBox:61
Items _items
Definition ComboBox:90
ComboBox(const ComboBox &combobox, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
virtual void createGraphicsImplementation()
createGraphicsImplementation method that creates the subgraph that will render the widget and assigns...
osg::ref_ptr< osgUI::Popup > _popup
Definition ComboBox:97
osg::Vec3d _popupItemSize
Definition ComboBox:93
virtual void enterImplementation()
osg::ref_ptr< osg::Switch > _buttonSwitch
Definition ComboBox:95
virtual bool handleImplementation(osgGA::EventVisitor *ev, osgGA::Event *event)
void clear()
Definition ComboBox:65
void setItems(const Items &items)
Definition ComboBox:71
unsigned int getNumItems()
Definition ComboBox:67
Definition Widget:29
virtual void dirty()
#define OSGUI_EXPORT
Definition Export:40

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.