Crazy Eddies GUI System: CEGUIButtonBase.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# CEGUIButtonBase.h

    00001 /************************************************************************
    00002         filename:       CEGUIButtonBase.h
    00003         created:        13/4/2004
    00004         author:         Paul D Turner
    00005
    00006         purpose:        Interface to base class for ButtonBase widget
    00007 *************************************************************************/
    00008 /*************************************************************************
    00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUIButtonBase_h_
    00027 #define _CEGUIButtonBase_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIWindow.h"
    00031 #include "elements/CEGUIButtonBaseProperties.h"
    00032
    00033
    00034 #if defined(_MSC_VER)
    00035 #       pragma warning(push)
    00036 #       pragma warning(disable : 4251)
    00037 #endif
    00038
    00039
    00040 // Start of CEGUI namespace section
    00041 namespace CEGUI
    00042 {
    00043
    00048 class CEGUIEXPORT ButtonBase : public Window
    00049 {
    00050 public:
    00051         /*************************************************************************
    00052                 Constants
    00053         *************************************************************************/
    00054         // default colours for text label rendering
    00055         static const colour             DefaultNormalLabelColour;
    00056         static const colour             DefaultHoverLabelColour;
    00057         static const colour             DefaultPushedLabelColour;
    00058         static const colour             DefaultDisabledLabelColour;
    00059
    00060
    00061         /*************************************************************************
    00062                 Accessor type functions
    00063         *************************************************************************/
    00071         bool    isHovering(void) const                  {return d_hovering;}
    00072
    00073
    00081         bool    isPushed(void) const                    {return d_pushed;}
    00082
    00083
    00091         colour  getNormalTextColour(void) const                 {return d_normalColour;}
    00092
    00093
    00101         colour  getHoverTextColour(void) const                  {return d_hoverColour;}
    00102
    00103
    00111         colour  getPushedTextColour(void) const                 {return d_pushedColour;}
    00112
    00113
    00121         colour  getDisabledTextColour(void) const               {return d_disabledColour;}
    00122
    00123         /*************************************************************************
    00124                 Manipulators
    00125         *************************************************************************/
    00136         void    setNormalTextColour(const colour& colour);
    00137
    00138
    00149         void    setHoverTextColour(const colour& colour);
    00150
    00151
    00162         void    setPushedTextColour(const colour& colour);
    00163
    00164
    00175         void    setDisabledTextColour(const colour& colour);
    00176
    00177         /*************************************************************************
    00178                 Construction and Destruction
    00179         *************************************************************************/
    00184         ButtonBase(const String& type, const String& name);
    00185
    00186
    00191         virtual ~ButtonBase(void);
    00192
    00193
    00194 protected:
    00195         /*************************************************************************
    00196                 Overridden event handlers
    00197         *************************************************************************/
    00198         virtual void    onMouseMove(MouseEventArgs& e);
    00199         virtual void    onMouseButtonDown(MouseEventArgs& e);
    00200         virtual void    onMouseButtonUp(MouseEventArgs& e);
    00201         virtual void    onCaptureLost(WindowEventArgs& e);
    00202         virtual void    onMouseLeaves(MouseEventArgs& e);
    00203
    00204
    00205         /*************************************************************************
    00206                 Implementation Functions
    00207         *************************************************************************/
    00218         void    updateInternalState(const Point& mouse_pos);
    00219
    00220
    00231         virtual bool    testClassName_impl(const String& class_name) const
    00232         {
    00233                 if (class_name==(const utf8*)"ButtonBase")      return true;
    00234                 return Window::testClassName_impl(class_name);
    00235         }
    00236
    00237
    00238         /*************************************************************************
    00239                 Implementation Rendering Functions
    00240         *************************************************************************/
    00251         virtual void    drawSelf(float z);
    00252
    00253
    00264         virtual void    drawNormal(float z)             = 0;
    00265
    00266
    00277         virtual void    drawHover(float z)                      {drawNormal(z);}
    00278
    00279
    00290         virtual void    drawPushed(float z)             {drawNormal(z);}
    00291
    00292
    00303         virtual void    drawDisabled(float z)           {drawNormal(z);}
    00304
    00305
    00306         /*************************************************************************
    00307                 Implementation Data
    00308         *************************************************************************/
    00309         bool    d_pushed;
    00310         bool    d_hovering;
    00311
    00312         // common rendering setting data
    00313         colour  d_normalColour;
    00314         colour  d_hoverColour;
    00315         colour  d_pushedColour;
    00316         colour  d_disabledColour;
    00317
    00318 private:
    00319         /*************************************************************************
    00320                 Static Properties for this class
    00321         *************************************************************************/
    00322         static ButtonBaseProperties::NormalTextColour   d_normalTextColourProperty;
    00323         static ButtonBaseProperties::HoverTextColour    d_hoverTextColourProperty;
    00324         static ButtonBaseProperties::PushedTextColour   d_pushedTextColourProperty;
    00325         static ButtonBaseProperties::DisabledTextColour d_disabledTextColourProperty;
    00326
    00327         /*************************************************************************
    00328                 Private methods
    00329         *************************************************************************/
    00330         void    addButtonBaseProperties(void);
    00331 };
    00332
    00333 } // End of  CEGUI namespace section
    00334
    00335 #if defined(_MSC_VER)
    00336 #       pragma warning(pop)
    00337 #endif
    00338
    00339 #endif  // end of guard _CEGUIButtonBase_h_