OpenWalnut  1.5.0dev
WOSGButton.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 
26 #ifndef WOSGBUTTON_H
27 #define WOSGBUTTON_H
28 
29 #include <string>
30 
31 #include <osgWidget/Box> //NOLINT
32 
33 #include "../../common/WProperties.h"
34 
35 #include "WOSGButtonLabel.h"
36 
37 
38 /**
39  * Class implements an osgWidget::Box with a label that can be used as a button in the 3D scene
40  */
41 class WOSGButton : public osgWidget::Box // NOLINT
42 {
43 public:
44  /**
45  * constructor
46  *
47  * \param name name of the button, will also be displayed on the label
48  * \param type taken from the osgWidget::Box
49  * \param resize_hint
50  * \param pushable denotes if the button is pushable, i.e. keeps a pushed state or not
51  */
52  WOSGButton( std::string name, osgWidget::Box::BoxType type, bool resize_hint, bool pushable );
53 
54  /**
55  * destructor
56  */
57  virtual ~WOSGButton();
58 
59  /**
60  * setter for id
61  *
62  * \param id
63  */
64  void setId( size_t id );
65 
66  /**
67  * getter
68  *
69  * \return id
70  */
71  size_t getId();
72 
73  /**
74  * setter
75  * \param label
76  */
77  void setLabel( std::string label );
78 
79  /**
80  * getter
81  * \return true when button was clicked
82  */
83  bool clicked();
84 
85  /**
86  * getter
87  * \return true when button was pushed
88  */
89  bool pushed();
90 
91  /**
92  * setter
93  * \param pushed if true the button is pushed
94  */
95  void setPushed( bool pushed );
96 
97  /**
98  * setter for the background color of the label
99  *
100  * \param color the color
101  */
102  void setBackgroundColor( const WColor& color );
103 
104 
105 private:
106  WOSGButtonLabel* m_label; //!< stores pointer to the label object
107 
108  size_t m_id; //!< id
109 };
110 
111 inline bool WOSGButton::clicked()
112 {
113  return m_label->clicked();
114 }
115 
116 inline bool WOSGButton::pushed()
117 {
118  return m_label->pushed();
119 }
120 
121 inline void WOSGButton::setPushed( bool pushed )
122 {
123  return m_label->setPushed( pushed );
124 }
125 
126 inline size_t WOSGButton::getId()
127 {
128  return m_id;
129 }
130 
131 #endif // WOSGBUTTON_H
implements mouse interaction for a osgWidget label
void setPushed(bool pushed)
setter
bool clicked()
getter for clicked flag, resets the flag to false
bool pushed()
getter for pushed flag
Class implements an osgWidget::Box with a label that can be used as a button in the 3D scene.
Definition: WOSGButton.h:42
void setLabel(std::string label)
setter
Definition: WOSGButton.cpp:47
void setId(size_t id)
setter for id
Definition: WOSGButton.cpp:52
size_t getId()
getter
Definition: WOSGButton.h:126
WOSGButton(std::string name, osgWidget::Box::BoxType type, bool resize_hint, bool pushable)
constructor
Definition: WOSGButton.cpp:31
void setPushed(bool pushed)
setter
Definition: WOSGButton.h:121
void setBackgroundColor(const WColor &color)
setter for the background color of the label
Definition: WOSGButton.cpp:57
virtual ~WOSGButton()
destructor
Definition: WOSGButton.cpp:43
bool clicked()
getter
Definition: WOSGButton.h:111
WOSGButtonLabel * m_label
stores pointer to the label object
Definition: WOSGButton.h:106
size_t m_id
id
Definition: WOSGButton.h:108
bool pushed()
getter
Definition: WOSGButton.h:116