GL Studio C++ Runtime API
gls_button.h
Go to the documentation of this file.
1 /*! \file
2  \brief The GlsPushButton runtime class.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 
41 #ifndef INCLUDED_GLS_BUTTON_H
42 #define INCLUDED_GLS_BUTTON_H
43 
44 #include "gls_cpp_lang_support.h"
45 #include "group.h"
46 
47 //////////////////// Provides support for creating DLLs ////////////////////////
48 #if( defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLSGEN_IMPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
49  && defined( _MSC_VER )
50 # if defined( GLSGEN_EXPORT_GlsPushButton ) || defined( GLS_EXPORT_GENERATED )
51 # define GLSGEN_GlsPushButton_EXPORT __declspec( dllexport )
52 # else
53 # define GLSGEN_GlsPushButton_EXPORT __declspec( dllimport )
54 # endif
55 #else
56 # define GLSGEN_GlsPushButton_EXPORT
57 #endif
58 ///////////////////////////////////////////////////////////////////////////////
59 
60 #define LIB_BASE_NAME "gls_push_button"
61 #include "gls_auto_lib.h"
62 #undef LIB_BASE_NAME
63 
64 namespace disti
65 {
66 enum
67 {
68  GLS_GLSBUTTON_CHANGE_CALLBACK = GLS_LAST_INITIALIZER + 1,
69  GLS_GLSBUTTON_TOGGLE,
70  GLS_GLSBUTTON_WHICH_OBJ_POS_UP,
71  GLS_GLSBUTTON_WHICH_OBJ_POS_DOWN,
72  GLS_GLSBUTTON_STATE,
73  GLS_GLSBUTTON_EMIT_STATE_CHANGE_EVENT
74 };
75 
76 /** Runtime implementation of a push button */
77 class GlsPushButton : public Group
78 {
79 private:
80  GlsPushButton& operator=( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
81  GlsPushButton( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
82 
83 public:
84  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
85  typedef Group _BaseClass;
86  typedef Group BaseClass;
87 
88  /* See base class */
89  GLSGEN_GlsPushButton_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
90 
91  bool _toggle; // The push button behavior (true=toggle, false=momentary)
92  int _whichObjectPosUp; // The object index to be the button up position
93  int _whichObjectPosDown; // The object index to be the button down position
94  int _state; // The button state: 0=up, 1=down
95  bool _emitStateChangeEvent;
96 
97  bool _mouseIsDown; // True when the mouse has been pushed down on this button
98  unsigned int _currentCursor; // the current cursor used for interaction. Any other cursors are ignored while interacting.
99 
100  friend class GlsPushButtonEditor;
101 
102  /** Create a new GlsPushButton.
103  * \param generateInstance Whether or not to generate an instance name
104  * for this inputdevice */
105  GLSGEN_GlsPushButton_EXPORT GlsPushButton( bool generateInstance = false );
106 
107  GLSGEN_GlsPushButton_EXPORT GlsPushButton( const GlsPushButton& that, const bool generateNames );
108 
109  /** Destroy a GlsPushButton object */
110  virtual GLSGEN_GlsPushButton_EXPORT ~GlsPushButton();
111 
112  static GLSGEN_GlsPushButton_EXPORT DisplayObject* CreateInstance();
113 
114  virtual GLSGEN_GlsPushButton_EXPORT void SetAvailableAttributes( unsigned int value );
115 
116  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* CloneObject( bool generateNames = false );
117 
118  virtual GLSGEN_GlsPushButton_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
119 
120  virtual GLSGEN_GlsPushButton_EXPORT void Draw( void );
121 
122  virtual GLSGEN_GlsPushButton_EXPORT void CopyProperties( DisplayObject* src );
123 
124  /** Sets the child index that represents the up state of the button
125  * \param which New child index for the up state
126  */
127  virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosUp( int which );
128 
129  /** Returns the child index that represents the up state of the button
130  * \return Current child index for the up state
131  */
132  virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosUp( void ) const;
133 
134  /** Sets the child index that represents the down state of the button
135  * \param state New child index for the down state
136  */
137  virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosDown( int which );
138 
139  /** Returns the index that represents the down state of the button
140  * \return Current child index for the down state
141  */
142  virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosDown( void ) const;
143 
144  /** Sets if the object should hold its state(true) or return to the up state(false)
145  * \param state New bevahiour of if the object should hold its state(true) or return to the up state(false)
146  */
147  virtual GLSGEN_GlsPushButton_EXPORT void Toggle( bool toggle );
148 
149  /** Returns if the object should hold its state(true) or return to the up state(false)
150  * \return Current bevahiour of if the object should hold its state(true) or return to the up state(false)
151  */
152  virtual GLSGEN_GlsPushButton_EXPORT bool Toggle( void ) const;
153 
154  /* See base class */
155  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
156  const Vector& logicalCoords,
157  float scale,
158  const Vector& directionVector,
159  Vector& collisionWinLoc /*Returned*/,
160  const OpenGLMatrices& drawnMatrices );
161 #ifndef GLES
162  /* See base class */
163  virtual GLSGEN_GlsPushButton_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
164  virtual GLSGEN_GlsPushButton_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
165 #endif
166 
167  /** Traverses upward in the hierarchy to determine if this object is visible in the scene.
168  */
169  GLSGEN_GlsPushButton_EXPORT bool IsVisibleInScene( const DisplayObject* obj = NULL ) const DISTI_METHOD_OVERRIDE;
170 
171  //////////////////////////////////////////////////
172  // Push Button specific operations
173  //////////////////////////////////////////////////
174  GLSGEN_GlsPushButton_EXPORT DisplayObject* handle( DisplayEvent* ev );
175 
176  /** Sets the push button state (0=up, 1=down)
177  * \param state New button state (0=up, 1=down)
178  */
179  virtual GLSGEN_GlsPushButton_EXPORT void State( const int& state );
180 
181  /** Returns the current push button state (0=up, 1=down)
182  * \return Current push button state (0=up, 1=down)
183  */
184  virtual GLSGEN_GlsPushButton_EXPORT int State() const;
185 
186  /** Returns the current push button state (0=up, 1=down)
187  * \deprecated this method is not const correct, use const version instead
188  * \return Current push button state (0=up, 1=down)
189  */
190  DISTI_DEPRECATED( "Use the const version instead." )
191  virtual int State() DISTI_FINAL
192  {
193  return const_cast<const GlsPushButton*>( this )->State();
194  }
195 
196 private:
197  DisplayObject* GetPickedObject( bool firstPick,
198  const Vector& winLoc,
199  const Vector& logicalCoords,
200  float scale, const Vector& directionVector,
201  Vector& collisionWinLoc /*Returned*/,
202  const OpenGLMatrices& drawnMatrices );
203 
204 protected:
205 #ifdef GLES
206  /** Set a single attribute from the GLO file.
207  * \param data The attribute to set and its associated data.
208  */
209  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
210 #endif
211 };
212 
213 } // namespace disti
214 
215 #endif
Definition: cull.h:49
virtual void SetAvailableAttributes(unsigned int value)
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
virtual ~GlsPushButton()
Definition: dynamic_array.h:66
The disti::Group class. Implements groups of objects.
virtual void CopyProperties(DisplayObject *src)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:296
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual int State() const
virtual int WhichObjectPosUp(void) const
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
Definition: display.h:98
virtual void Draw(void)
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
Definition: gls_glo_file.h:988
DisplayObject * handle(DisplayEvent *ev)
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
virtual bool Toggle(void) const
Definition: events.h:112
virtual DisplayObject * CloneObject(bool generateNames=false)
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
The gls_auto_lib.
Definition: group.h:52
virtual int WhichObjectPosDown(void) const
Definition: vertex.h:84
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
Definition: gls_button.h:77