GL Studio 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) 2015 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 "group.h"
45 #include "gls_cpp_lang_support.h"
46 
47 //////////////////// Provides support for creating DLLs ////////////////////////
48 #if (defined(GLSGEN_EXPORT_GlsPushButton) || \
49  defined(GLSGEN_IMPORT_GlsPushButton) || \
50  defined(GLS_EXPORT_GENERATED) || \
51  defined(GLS_IMPORT_GENERATED)) \
52  && defined(_MSC_VER)
53 # if defined(GLSGEN_EXPORT_GlsPushButton) || defined(GLS_EXPORT_GENERATED)
54 # define GLSGEN_GlsPushButton_EXPORT __declspec(dllexport)
55 # else
56 # define GLSGEN_GlsPushButton_EXPORT __declspec(dllimport)
57 # endif
58 #else
59 # define GLSGEN_GlsPushButton_EXPORT
60 #endif
61 ///////////////////////////////////////////////////////////////////////////////
62 
63 # define LIB_BASE_NAME "gls_push_button"
64 # include "gls_auto_lib.h"
65 # undef LIB_BASE_NAME
66 
67 namespace disti
68 {
69 
70 enum {
71  GLS_GLSBUTTON_CHANGE_CALLBACK = GLS_LAST_INITIALIZER+1,
72  GLS_GLSBUTTON_TOGGLE,
73  GLS_GLSBUTTON_WHICH_OBJ_POS_UP,
74  GLS_GLSBUTTON_WHICH_OBJ_POS_DOWN,
75  GLS_GLSBUTTON_STATE,
76  GLS_GLSBUTTON_EMIT_STATE_CHANGE_EVENT
77 };
78 
79 /** Runtime implementation of a push button */
80 class GlsPushButton : public Group
81 {
82 private:
83  GlsPushButton& operator=( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
84  GlsPushButton( const GlsPushButton& ) DISTI_SPECIAL_MEM_FUN_DELETE;
85 
86 public:
87  typedef Group _BaseClass;
88 
89  /* See base class */
90  virtual void SetValue(int spec,va_list &args);
91 
92  bool _toggle; // The push button behavior (true=toggle, false=momentary)
93  int _whichObjectPosUp; // The object index to be the button up position
94  int _whichObjectPosDown; // The object index to be the button down position
95  int _state; // The button state: 0=up, 1=down
96  bool _emitStateChangeEvent;
97 
98  bool _mouseIsDown; // True when the mouse has been pushed down on this button
99  unsigned int _currentCursor; // the current cursor used for interaction. Any other cursors are ignored while interacting.
100 public:
101  friend class GlsPushButtonEditor;
102 
103  /** Create a new GlsPushButton.
104  * \param generateInstance Whether or not to generate an instance name
105  * for this inputdevice */
106  GLSGEN_GlsPushButton_EXPORT GlsPushButton(bool generateInstance=false);
107 
108  GLSGEN_GlsPushButton_EXPORT GlsPushButton( const GlsPushButton& that, const bool generateNames );
109 
110  /** Destroy a GlsPushButton object */
111  virtual GLSGEN_GlsPushButton_EXPORT ~GlsPushButton();
112 
113  static GLSGEN_GlsPushButton_EXPORT DisplayObject *CreateInstance();
114 
115  virtual GLSGEN_GlsPushButton_EXPORT void SetAvailableAttributes(unsigned int value);
116 
117  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject *CloneObject(bool generateNames = false);
118 
119  virtual GLSGEN_GlsPushButton_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices,Culler &culler );
120 
121  virtual GLSGEN_GlsPushButton_EXPORT void Draw(void);
122 
123  virtual GLSGEN_GlsPushButton_EXPORT void CopyProperties(DisplayObject *src);
124 
125  /* See base class */
126  virtual GLSGEN_GlsPushButton_EXPORT DisplayObject *Pick3D(const Vector& winLoc,
127  const Vector& logicalCoords,
128  float scale,
129  const Vector& directionVector,
130  Vector& collisionWinLoc /*Returned*/,
131  const OpenGLMatrices& drawnMatrices);
132 #ifndef GLES
133  /* See base class */
134  virtual GLSGEN_GlsPushButton_EXPORT InterfaceListType* GetCppInterfaceDescription(InterfaceListType* addToThisList= NULL );
135  virtual GLSGEN_GlsPushButton_EXPORT void GetCppInterfaceDescriptionFree(InterfaceListType* array);
136 #endif
137 
138  //////////////////////////////////////////////////
139  // Push Button specific operations
140  //////////////////////////////////////////////////
141  public:
143 
144  /** Sets the push button state (0=up, 1=down)
145  * \param state New button state (0=up, 1=down)
146  */
147  virtual void State( const int& state );
148 
149  /** Returns the current push button state (0=up, 1=down)
150  * \return Current push button state (0=up, 1=down)
151  */
152  virtual int State();
153 
154  private:
155  DisplayObject* GetPickedObject( bool firstPick,
156  const Vector& winLoc,
157  const Vector& logicalCoords,
158  float scale, const Vector& directionVector,
159  Vector& collisionWinLoc /*Returned*/,
160  const OpenGLMatrices& drawnMatrices );
161  protected:
162 #ifdef GLES
163  /** Set a single attribute from the GLO file.
164  * \param data The attribute to set and its associated data.
165  */
166  virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data);
167 #endif
168 };
169 
170 } // namespace disti
171 
172 #endif
173 
Definition: cull.h:50
virtual void SetAvailableAttributes(unsigned int value)
virtual ~GlsPushButton()
Definition: dynamic_array.h:63
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:289
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:98
virtual void Draw(void)
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
DisplayObject * handle(DisplayEvent *ev)
virtual int State()
Definition: events.h:111
virtual DisplayObject * CloneObject(bool generateNames=false)
The gls_auto_lib.
Definition: group.h:53
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:80