GL Studio C++ Runtime API
gls_button.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsButton 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 _GLS_BUTTON_H
42 #define _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  typedef Group _BaseClass;
85 
86  /* See base class */
87  virtual void SetValue( int spec, va_list& args );
88 
89  bool _toggle; // The push button behavior (true=toggle, false=momentary)
90  int _whichObjectPosUp; // The object index to be the button up position
91  int _whichObjectPosDown; // The object index to be the button down position
92  int _state; // The button state: 0=up, 1=down
93  bool _emitStateChangeEvent;
94 
95  bool _mouseIsDown; // True when the mouse has been pushed down on this button
96  unsigned int _currentCursor; // the current cursor used for interaction. Any other cursors are ignored while interacting.
97 public:
98  friend class GlsPushButtonEditor;
99 
100  /** Create a new GlsPushButton.
101  * \param generateInstance Whether or not to generate an instance name
102  * for this inputdevice */
103  GLSGEN_GlsPushButton_EXPORT GlsPushButton( bool generateInstance = false );
104 
105  GLSGEN_GlsPushButton_EXPORT GlsPushButton( const GlsPushButton& that, const bool generateNames );
106 
107  /** Destroy a GlsPushButton object */
108  virtual GLSGEN_GlsPushButton_EXPORT ~GlsPushButton();
109 
110  static GLSGEN_GlsPushButton_EXPORT DisplayObject* CreateInstance();
111 
112  virtual GLSGEN_GlsPushButton_EXPORT void SetAvailableAttributes( unsigned int value );
113 
114  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* CloneObject( bool generateNames = false );
115 
116  virtual GLSGEN_GlsPushButton_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
117 
118  virtual GLSGEN_GlsPushButton_EXPORT void Draw( void );
119 
120  virtual GLSGEN_GlsPushButton_EXPORT void CopyProperties( DisplayObject* src );
121 
122  /* See base class */
123  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
124  const Vector& logicalCoords,
125  float scale,
126  const Vector& directionVector,
127  Vector& collisionWinLoc /*Returned*/,
128  const OpenGLMatrices& drawnMatrices );
129 #ifndef GLES
130  /* See base class */
131  virtual GLSGEN_GlsPushButton_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
132  virtual GLSGEN_GlsPushButton_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
133 #endif
134 
135  //////////////////////////////////////////////////
136  // Push Button specific operations
137  //////////////////////////////////////////////////
138 public:
140 
141  /** Sets the push button state (0=up, 1=down)
142  * \param state New button state (0=up, 1=down)
143  */
144  virtual void State( const int& state );
145 
146  /** Returns the current push button state (0=up, 1=down)
147  * \return Current push button state (0=up, 1=down)
148  */
149  virtual int State();
150 
151 private:
152  DisplayObject* GetPickedObject( bool firstPick,
153  const Vector& winLoc,
154  const Vector& logicalCoords,
155  float scale, const Vector& directionVector,
156  Vector& collisionWinLoc /*Returned*/,
157  const OpenGLMatrices& drawnMatrices );
158 
159 protected:
160 #ifdef GLES
161  /** Set a single attribute from the GLO file.
162  * \param data The attribute to set and its associated data.
163  */
164  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
165 #endif
166 };
167 
168 } // namespace disti
169 
170 #endif
Definition: cull.h:49
virtual void SetAvailableAttributes(unsigned int value)
virtual ~GlsPushButton()
Definition: dynamic_array.h:62
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:278
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
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:97
virtual void Draw(void)
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
Definition: gls_glo_file.h:835
DisplayObject * handle(DisplayEvent *ev)
virtual int State()
Definition: events.h:110
virtual DisplayObject * CloneObject(bool generateNames=false)
The gls_auto_lib.
Definition: group.h:52
Definition: vertex.h:83
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
virtual void SetValue(int spec, va_list &args)
Definition: gls_button.h:77