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  /** Sets the child index that represents the up state of the button
123  * \param which New child index for the up state
124  */
125  virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosUp( int which );
126 
127  /** Returns the child index that represents the up state of the button
128  * \return Current child index for the up state
129  */
130  virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosUp( void ) const;
131 
132  /** Sets the child index that represents the down state of the button
133  * \param state New child index for the down state
134  */
135  virtual GLSGEN_GlsPushButton_EXPORT void WhichObjectPosDown( int which );
136 
137  /** Returns the index that represents the down state of the button
138  * \return Current child index for the down state
139  */
140  virtual GLSGEN_GlsPushButton_EXPORT int WhichObjectPosDown( void ) const;
141 
142  /** Sets if the object should hold its state(true) or return to the up state(false)
143  * \param state New bevahiour of if the object should hold its state(true) or return to the up state(false)
144  */
145  virtual GLSGEN_GlsPushButton_EXPORT void Toggle( bool toggle );
146 
147  /** Returns if the object should hold its state(true) or return to the up state(false)
148  * \return Current bevahiour of if the object should hold its state(true) or return to the up state(false)
149  */
150  virtual GLSGEN_GlsPushButton_EXPORT bool Toggle( void ) const;
151 
152  /* See base class */
153  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
154  const Vector& logicalCoords,
155  float scale,
156  const Vector& directionVector,
157  Vector& collisionWinLoc /*Returned*/,
158  const OpenGLMatrices& drawnMatrices );
159 #ifndef GLES
160  /* See base class */
161  virtual GLSGEN_GlsPushButton_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
162  virtual GLSGEN_GlsPushButton_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
163 #endif
164 
165  //////////////////////////////////////////////////
166  // Push Button specific operations
167  //////////////////////////////////////////////////
168 public:
170 
171  /** Sets the push button state (0=up, 1=down)
172  * \param state New button state (0=up, 1=down)
173  */
174  virtual void State( const int& state );
175 
176  /** Returns the current push button state (0=up, 1=down)
177  * \return Current push button state (0=up, 1=down)
178  */
179  virtual int State();
180 
181 private:
182  DisplayObject* GetPickedObject( bool firstPick,
183  const Vector& winLoc,
184  const Vector& logicalCoords,
185  float scale, const Vector& directionVector,
186  Vector& collisionWinLoc /*Returned*/,
187  const OpenGLMatrices& drawnMatrices );
188 
189 protected:
190 #ifdef GLES
191  /** Set a single attribute from the GLO file.
192  * \param data The attribute to set and its associated data.
193  */
194  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
195 #endif
196 };
197 
198 } // namespace disti
199 
200 #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:301
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
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:982
DisplayObject * handle(DisplayEvent *ev)
virtual bool Toggle(void) const
virtual int State()
Definition: events.h:111
virtual DisplayObject * CloneObject(bool generateNames=false)
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
virtual void SetValue(int spec, va_list &args)
Definition: gls_button.h:77