OpenWalnut  1.5.0dev
WOSGButton.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 <string>
26 
27 #include "WOSGButtonLabel.h"
28 
29 #include "WOSGButton.h"
30 
31 WOSGButton::WOSGButton( std::string name, osgWidget::Box::BoxType type, bool resize_hint, bool pushable ) :
32  osgWidget::Box( name, type, resize_hint ),
33  m_id( 0 )
34 {
35  getBackground()->setColor( 0.8f, 0.8f, 0.8f, 0.8f );
36 
37  m_label = new WOSGButtonLabel( pushable );
38  m_label->setLabel( name );
39  m_label->setName( std::string( "Button_" ) + name );
40  addWidget( m_label );
41 }
42 
44 {
45 }
46 
47 void WOSGButton::setLabel( std::string label )
48 {
49  m_label->setLabel( label );
50 }
51 
52 void WOSGButton::setId( size_t id )
53 {
54  m_id = id;
55 }
56 
57 void WOSGButton::setBackgroundColor( const WColor& color )
58 {
59  m_label->setColor( color[0], color[1], color[2], 1.0f );
60 }
implements mouse interaction for a osgWidget label
void setLabel(std::string label)
setter
Definition: WOSGButton.cpp:47
void setId(size_t id)
setter for id
Definition: WOSGButton.cpp:52
WOSGButton(std::string name, osgWidget::Box::BoxType type, bool resize_hint, bool pushable)
constructor
Definition: WOSGButton.cpp:31
void setBackgroundColor(const WColor &color)
setter for the background color of the label
Definition: WOSGButton.cpp:57
virtual ~WOSGButton()
destructor
Definition: WOSGButton.cpp:43
WOSGButtonLabel * m_label
stores pointer to the label object
Definition: WOSGButton.h:106
size_t m_id
id
Definition: WOSGButton.h:108