OpenWalnut  1.5.0dev
WOSGButtonLabel.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 #ifndef WOSGBUTTONLABEL_H
26 #define WOSGBUTTONLABEL_H
27 
28 #include <osgWidget/Label>
29 #include <osgWidget/Util>
30 #include <osgWidget/WindowManager>
31 
32 /**
33  * implements mouse interaction for a osgWidget label
34  */
35 class WOSGButtonLabel : public osgWidget::Label
36 {
37 public:
38  /**
39  * constructor
40  * \param pushable denotes if the button is pushable, i.e. keeps a pushed state or not
41  */
42  explicit WOSGButtonLabel( bool pushable );
43 
44  /**
45  * destructor
46  */
48 
49  /**
50  * function handles mouse click on label, the function was copied from an osg example, as everything in
51  * the osg it wasn't documented, so it's not entirely sure what the params are for and what they do
52  *
53  * \return bool
54  */
55  virtual bool mousePush( double, double, const osgWidget::WindowManager* );
56 
57  /**
58  * getter for clicked flag, resets the flag to false
59  *
60  * \return true if the label has been clicked
61  */
62  bool clicked();
63 
64  /**
65  * getter for pushed flag
66  *
67  * \return true if the button is pushed
68  */
69  bool pushed();
70 
71  /**
72  * setter
73  * \param pushed if true the button is pushed
74  */
75  void setPushed( bool pushed );
76 
77 protected:
78 private:
79  bool m_clicked; //!< if true the label has been clicked since it was last checked for
80 
81  bool m_pushable; //!< button is pushable or not
82 
83  bool m_pushed; //!< true if button is pushable and was clicked
84 };
85 
87 {
88  bool tmp = m_clicked;
89  m_clicked = false;
90  return tmp;
91 }
92 
94 {
95  return m_pushed;
96 }
97 
98 inline void WOSGButtonLabel::setPushed( bool pushed )
99 {
100  m_pushed = pushed;
101 }
102 
103 #endif // WOSGBUTTONLABEL_H
implements mouse interaction for a osgWidget label
void setPushed(bool pushed)
setter
virtual bool mousePush(double, double, const osgWidget::WindowManager *)
function handles mouse click on label, the function was copied from an osg example,...
bool m_pushed
true if button is pushable and was clicked
bool clicked()
getter for clicked flag, resets the flag to false
bool pushed()
getter for pushed flag
WOSGButtonLabel(bool pushable)
constructor
bool m_pushable
button is pushable or not
~WOSGButtonLabel()
destructor
bool m_clicked
if true the label has been clicked since it was last checked for