openscenegraph
TabWidget
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_TABWIDGET
15#define OSGUI_TABWIDGET
16
17#include <osgUI/Popup>
18#include <osg/Switch>
19#include <osgText/Text>
20
21namespace osgUI
22{
23
25{
26public:
27
28 Tab() {}
29 Tab(const std::string& str) : _text(str) {}
30
31 Tab(const Tab& item, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(item,copyop), _text(item._text) {}
32
34
35 void setText(const std::string& text) { _text = text; }
36 std::string& getText() { return _text; }
37 const std::string& getText() const { return _text; }
38
39 void setWidget(osgUI::Widget* widget) { _widget = widget; }
40 osgUI::Widget* getWidget() { return _widget.get(); }
41 const osgUI::Widget* getWidget() const { return _widget.get(); }
42
43protected:
44 virtual ~Tab() {}
45
46 std::string _text;
48};
49
51{
52public:
56
57 void addTab(Tab* item) { _tabs.push_back(item); dirty(); }
58
59 void setTab(unsigned int i, Tab* item) { _tabs[i] = item; dirty(); }
60 Tab* getTab(unsigned int i) { return _tabs[i].get(); }
61 const Tab* getTab(unsigned int i) const { return _tabs[i].get(); }
62
63 void clear() { _tabs.clear(); dirty(); }
64 void removeTab(unsigned int i) { _tabs.erase(_tabs.begin()+i); dirty(); }
65 unsigned int getNumTabs() { return static_cast<unsigned int>(_tabs.size()); }
66
67 typedef std::vector< osg::ref_ptr<Tab> > Tabs;
68
69 void setTabs(const Tabs& items) { _tabs = items; }
70 Tabs& getTabs() { return _tabs; }
71 const Tabs& getTabs() const { return _tabs; }
72
73 void setCurrentIndex(unsigned int i);
74 unsigned int getCurrentIndex() const { return _currentIndex; }
75
76 virtual void currrentIndexChanged(unsigned int i);
77 virtual void currentIndexChangedImplementation(unsigned int i);
78
79
82 virtual void enterImplementation();
83 virtual void leaveImplementation();
84
85protected:
86 virtual ~TabWidget() {}
87
89
92
94 unsigned int _currentIndex;
95
99};
100
101}
102
103#endif
Definition EventVisitor:42
Definition Event:27
Definition FrameSettings:25
Definition TabWidget:51
virtual void createGraphicsImplementation()
std::vector< osg::ref_ptr< Tab > > Tabs
Definition TabWidget:67
virtual ~TabWidget()
Definition TabWidget:86
unsigned int _currentIndex
Definition TabWidget:94
void clear()
Definition TabWidget:63
Tabs & getTabs()
Definition TabWidget:70
osg::ref_ptr< osg::Switch > _inactiveHeaderSwitch
Definition TabWidget:96
virtual void enterImplementation()
virtual void currrentIndexChanged(unsigned int i)
META_Node(osgUI, TabWidget)
const Tabs & getTabs() const
Definition TabWidget:71
void _activateWidgets()
void removeTab(unsigned int i)
Definition TabWidget:64
osg::ref_ptr< osg::Switch > _tabWidgetSwitch
Definition TabWidget:98
Tabs _tabs
Definition TabWidget:93
virtual bool handleImplementation(osgGA::EventVisitor *ev, osgGA::Event *event)
virtual void currentIndexChangedImplementation(unsigned int i)
void setTab(unsigned int i, Tab *item)
Definition TabWidget:59
unsigned int getCurrentIndex() const
Definition TabWidget:74
osg::Node * _createTabHeader(const osg::BoundingBox &extents, osgUI::FrameSettings *fs, const osg::Vec4 &color)
Tab * getTab(unsigned int i)
Definition TabWidget:60
void addTab(Tab *item)
Definition TabWidget:57
const Tab * getTab(unsigned int i) const
Definition TabWidget:61
void setTabs(const Tabs &items)
Definition TabWidget:69
osg::Node * _createTabFrame(const osg::BoundingBox &extents, osgUI::FrameSettings *fs, const osg::Vec4 &color)
osg::ref_ptr< osg::Switch > _activeHeaderSwitch
Definition TabWidget:97
virtual void leaveImplementation()
TabWidget(const TabWidget &combobox, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void setCurrentIndex(unsigned int i)
unsigned int getNumTabs()
Definition TabWidget:65
Definition TabWidget:25
std::string _text
Definition TabWidget:46
virtual ~Tab()
Definition TabWidget:44
void setText(const std::string &text)
Definition TabWidget:35
const osgUI::Widget * getWidget() const
Definition TabWidget:41
osgUI::Widget * getWidget()
Definition TabWidget:40
Tab(const std::string &str)
Definition TabWidget:29
osg::ref_ptr< osgUI::Widget > _widget
Definition TabWidget:47
std::string & getText()
Definition TabWidget:36
void setWidget(osgUI::Widget *widget)
Definition TabWidget:39
Tab()
Definition TabWidget:28
const std::string & getText() const
Definition TabWidget:37
Tab(const Tab &item, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition TabWidget:31
META_Object(osgUI, Tab)
Definition osgUI/Widget:29
Definition BoundingBox:34
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Node:72
Definition Object:61
Definition Vec4f:28
Definition ref_ptr:32
Definition AlignmentSettings:23
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSGUI_EXPORT
Definition osgUI/Export:40