OpenWalnut  1.4.0
WOSGButtonLabel.cpp
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 #include "WOSGButtonLabel.h"
26 
28  osgWidget::Label( "", "" ),
29  m_clicked( false ),
30  m_pushable( pushable ),
31  m_pushed( false )
32 {
33  setFontSize( 14 );
34  setFontColor( 1.0f, 1.0f, 1.0f, 1.0f );
35  setColor( 0.3f, 0.3f, 0.3f, 1.0f );
36  addHeight( 18.0f );
37  setCanFill( true );
38  setEventMask( osgWidget::EVENT_MOUSE_PUSH );
39 }
40 
42 {
43 }
44 
45 bool WOSGButtonLabel::mousePush( double, double, osgWidget::WindowManager* )
46 {
47  m_clicked = true;
48  if( m_pushable )
49  {
50  m_pushed = !m_pushed;
51 
52  if( m_pushed )
53  {
54  setFontColor( 0.0f, 0.0f, 0.0f, 1.0f );
55  }
56  else
57  {
58  setFontColor( 1.0f, 1.0f, 1.0f, 1.0f );
59  }
60  }
61  return true;
62 }
bool m_pushed
true if button is pushable and was clicked
bool m_pushable
button is pushable or not
~WOSGButtonLabel()
destructor
WOSGButtonLabel(bool pushable)
constructor
bool mousePush(double, double, osgWidget::WindowManager *)
function handles mouse click on label, the function was copied from an osg example, as everything in the osg it wasn't documented, so it's not entirely sure what the params are for and what they do
bool m_clicked
if true the label has been clicked since it was last checked for