OpenWalnut  1.4.0
WOSGButton.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 
00026 #ifndef WOSGBUTTON_H
00027 #define WOSGBUTTON_H
00028 
00029 #include <string>
00030 
00031 #include <osgWidget/Box> //NOLINT
00032 
00033 #include "../../common/WProperties.h"
00034 
00035 #include "WOSGButtonLabel.h"
00036 
00037 
00038 /**
00039  * Class implements an osgWidget::Box with a label that can be used as a button in the 3D scene
00040  */
00041 class WOSGButton : public osgWidget::Box // NOLINT
00042 {
00043 public:
00044     /**
00045      * constructor
00046      *
00047      * \param name name of the button, will also be displayed on the label
00048      * \param type taken from the osgWidget::Box
00049      * \param resize_hint
00050      * \param pushable denotes if the button is pushable, i.e. keeps a pushed state or not
00051      */
00052     WOSGButton( std::string name, osgWidget::Box::BoxType type, bool resize_hint, bool pushable );
00053 
00054     /**
00055      * destructor
00056      */
00057     virtual ~WOSGButton();
00058 
00059     /**
00060      * setter for id
00061      *
00062      * \param id
00063      */
00064     void setId( size_t id );
00065 
00066     /**
00067      * getter
00068      *
00069      * \return id
00070      */
00071     size_t getId();
00072 
00073     /**
00074      * setter
00075      * \param label
00076      */
00077     void setLabel( std::string label );
00078 
00079     /**
00080      * getter
00081      * \return true when button was clicked
00082      */
00083     bool clicked();
00084 
00085     /**
00086      * getter
00087      * \return true when button was pushed
00088      */
00089     bool pushed();
00090 
00091     /**
00092      * setter
00093      * \param pushed if true the button is pushed
00094      */
00095     void setPushed( bool pushed );
00096 
00097     /**
00098      * setter for the background color of the label
00099      *
00100      * \param color the color
00101      */
00102     void setBackgroundColor( const WColor& color );
00103 
00104 
00105 private:
00106     WOSGButtonLabel* m_label; //!< stores pointer to the label object
00107 
00108     size_t m_id; //!< id
00109 };
00110 
00111 inline bool WOSGButton::clicked()
00112 {
00113     return m_label->clicked();
00114 }
00115 
00116 inline bool WOSGButton::pushed()
00117 {
00118     return m_label->pushed();
00119 }
00120 
00121 inline void WOSGButton::setPushed( bool pushed )
00122 {
00123     return m_label->setPushed( pushed );
00124 }
00125 
00126 inline size_t WOSGButton::getId()
00127 {
00128     return m_id;
00129 }
00130 
00131 #endif  // WOSGBUTTON_H