Torque3D Documentation / _generateds / guiButtonBaseCtrl.h

guiButtonBaseCtrl.h

Engine/source/gui/buttons/guiButtonBaseCtrl.h

More...

Classes:

class

Base class for all button controls.

Public Typedefs

Public Functions

Detailed Description

Public Typedefs

typedef GuiButtonBaseCtrl::ButtonType GuiButtonType 

Public Functions

DefineEnumType(GuiButtonType )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GUIBUTTONBASECTRL_H_
 25#define _GUIBUTTONBASECTRL_H_
 26
 27#ifndef _GUICONTROL_H_
 28   #include "gui/core/guiControl.h"
 29#endif
 30
 31
 32/// Base class for all button controls.  Subclasses are mostly for specific
 33/// rendering types.
 34///
 35class GuiButtonBaseCtrl : public GuiControl
 36{
 37   public:
 38   
 39      typedef GuiControl Parent;
 40
 41      enum ButtonType
 42      {
 43         ButtonTypePush,
 44         ButtonTypeCheck,
 45         ButtonTypeRadio,
 46      };
 47
 48   protected:
 49   
 50      StringTableEntry mButtonText;
 51      StringTableEntry mButtonTextID;
 52      bool mDepressed;
 53      bool mMouseOver;
 54      bool mStateOn;
 55      S32 mButtonType;
 56      S32 mRadioGroup;
 57      bool mUseMouseEvents;
 58      
 59      /// Point where left mouse button was pressed down.  Used to find when to start
 60      /// a mouse drag.
 61      Point2I mMouseDownPoint;
 62      
 63      ///
 64      bool mMouseDragged;
 65      
 66      /// @name Callbacks
 67      /// @{
 68
 69      DECLARE_CALLBACK( void, onMouseDown, () );   
 70      DECLARE_CALLBACK( void, onMouseUp, () );
 71      DECLARE_CALLBACK( void, onClick, () );
 72      DECLARE_CALLBACK( void, onRightClick, () );
 73      DECLARE_CALLBACK( void, onDoubleClick, () );    
 74      DECLARE_CALLBACK( void, onMouseEnter, () );   
 75      DECLARE_CALLBACK( void, onMouseLeave, () );      
 76      DECLARE_CALLBACK( void, onMouseDragged, () );   
 77
 78      /// @}
 79
 80   public:
 81
 82      GuiButtonBaseCtrl();
 83      bool onWake();
 84
 85      DECLARE_CONOBJECT( GuiButtonBaseCtrl );
 86      DECLARE_CATEGORY( "Gui Buttons" );
 87      DECLARE_DESCRIPTION( "A basic button control." );
 88      
 89      static void initPersistFields();
 90
 91      void setText(const char *text);
 92      void setTextID(S32 id);
 93      void setTextID(const char *id);
 94      const char *getText();
 95      void setStateOn( bool bStateOn );
 96      bool getStateOn() const { return mStateOn; }
 97
 98      void setDepressed( bool depressed ) { mDepressed = depressed; }
 99      void resetState() {mDepressed = false; mMouseOver = false;}
100
101      void acceleratorKeyPress(U32 index);
102      void acceleratorKeyRelease(U32 index);
103
104      void onMouseDown(const GuiEvent &);
105      void onMouseUp(const GuiEvent &);
106      void onMouseDragged( const GuiEvent& event );
107      void onRightMouseUp(const GuiEvent &);
108
109      void onMouseEnter(const GuiEvent &);
110      void onMouseLeave(const GuiEvent &);
111
112      bool onKeyDown(const GuiEvent &event);
113      bool onKeyUp(const GuiEvent &event);
114
115      void setScriptValue(const char *value);
116      const char *getScriptValue();
117
118      void onMessage(GuiControl *,S32 msg);
119      void onAction();
120      
121      bool usesMouseEvents() const { return mUseMouseEvents; }
122      void setUseMouseEvents( bool val ) { mUseMouseEvents = val; }
123};
124
125typedef GuiButtonBaseCtrl::ButtonType GuiButtonType;
126DefineEnumType( GuiButtonType );
127
128#endif
129