OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TabWidget.h
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 
21 namespace osgUI
22 {
23 
25 {
26 public:
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 
43 protected:
44  virtual ~Tab() {}
45 
46  std::string _text;
48 };
49 
51 {
52 public:
53  TabWidget();
54  TabWidget(const TabWidget& combobox, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
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 
80  virtual bool handleImplementation(osgGA::EventVisitor* ev, osgGA::Event* event);
81  virtual void createGraphicsImplementation();
82  virtual void enterImplementation();
83  virtual void leaveImplementation();
84 
85 protected:
86  virtual ~TabWidget() {}
87 
88  void _activateWidgets();
89 
90  osg::Node* _createTabFrame(const osg::BoundingBox& extents, osgUI::FrameSettings* fs, const osg::Vec4& color);
91  osg::Node* _createTabHeader(const osg::BoundingBox& extents, osgUI::FrameSettings* fs, const osg::Vec4& color);
92 
93  Tabs _tabs;
94  unsigned int _currentIndex;
95 
99 };
100 
101 }
102 
103 #endif
virtual ~Tab()
Definition: TabWidget.h:44
osg::ref_ptr< osg::Switch > _tabWidgetSwitch
Definition: TabWidget.h:98
std::vector< osg::ref_ptr< Tab > > Tabs
Definition: TabWidget.h:67
void addTab(Tab *item)
Definition: TabWidget.h:57
unsigned int getCurrentIndex() const
Definition: TabWidget.h:74
osgUI::Widget * getWidget()
Definition: TabWidget.h:40
virtual ~TabWidget()
Definition: TabWidget.h:86
std::string _text
Definition: TabWidget.h:46
Tab * getTab(unsigned int i)
Definition: TabWidget.h:60
#define META_Node(library, name)
Definition: Node.h:59
osg::ref_ptr< osg::Switch > _inactiveHeaderSwitch
Definition: TabWidget.h:96
void setText(const std::string &text)
Definition: TabWidget.h:35
Tab(const std::string &str)
Definition: TabWidget.h:29
osg::ref_ptr< osg::Switch > _activeHeaderSwitch
Definition: TabWidget.h:97
void setTab(unsigned int i, Tab *item)
Definition: TabWidget.h:59
#define META_Object(library, name)
Definition: Object.h:42
void removeTab(unsigned int i)
Definition: TabWidget.h:64
unsigned int getNumTabs()
Definition: TabWidget.h:65
const Tabs & getTabs() const
Definition: TabWidget.h:71
std::string & getText()
Definition: TabWidget.h:36
const std::string & getText() const
Definition: TabWidget.h:37
unsigned int _currentIndex
Definition: TabWidget.h:94
osg::ref_ptr< osgUI::Widget > _widget
Definition: TabWidget.h:47
Definition: Node.h:71
Definition: AlphaFunc.h:19
void setTabs(const Tabs &items)
Definition: TabWidget.h:69
Tabs & getTabs()
Definition: TabWidget.h:70
const Tab * getTab(unsigned int i) const
Definition: TabWidget.h:61
Tab(const Tab &item, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition: TabWidget.h:31
void setWidget(osgUI::Widget *widget)
Definition: TabWidget.h:39
const osgUI::Widget * getWidget() const
Definition: TabWidget.h:41
#define OSGUI_EXPORT
Definition: Widget.h:22