Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/tform/mouseWatcherParameter.I

Go to the documentation of this file.
00001 // Filename: mouseWatcherParameter.I
00002 // Created by:  drose (06Jul01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: MouseWatcherParameter::Constructor
00022 //       Access: Public
00023 //  Description: 
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE MouseWatcherParameter::
00026 MouseWatcherParameter() {
00027   _flags = 0;
00028 }
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //     Function: MouseWatcherParameter::Copy Constructor
00032 //       Access: Public
00033 //  Description: 
00034 ////////////////////////////////////////////////////////////////////
00035 INLINE MouseWatcherParameter::
00036 MouseWatcherParameter(const MouseWatcherParameter &copy) :
00037   _button(copy._button),
00038   _keycode(copy._keycode),
00039   _mods(copy._mods),
00040   _mouse(copy._mouse),
00041   _flags(copy._flags)
00042 {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: MouseWatcherParameter::Copy Assignment Operator
00047 //       Access: Public
00048 //  Description: 
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE void MouseWatcherParameter::
00051 operator = (const MouseWatcherParameter &copy) {
00052   _button = copy._button;
00053   _keycode = copy._keycode;
00054   _mods = copy._mods;
00055   _mouse = copy._mouse;
00056   _flags = copy._flags;
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: MouseWatcherParameter::Destructor
00061 //       Access: Public
00062 //  Description: 
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE MouseWatcherParameter::
00065 ~MouseWatcherParameter() {
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: MouseWatcherParameter::set_button
00070 //       Access: Public
00071 //  Description: Sets the mouse or keyboard button that generated this
00072 //               event, if any.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE void MouseWatcherParameter::
00075 set_button(const ButtonHandle &button) {
00076   _button = button;
00077   _flags |= F_has_button;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: MouseWatcherParameter::set_keycode
00082 //       Access: Public
00083 //  Description: Sets the keycode associated with this event, if any.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE void MouseWatcherParameter::
00086 set_keycode(int keycode) {
00087   _keycode = keycode;
00088   _flags |= F_has_keycode;
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: MouseWatcherParameter::set_modifier_buttons
00093 //       Access: Public
00094 //  Description: Sets the modifier buttons that were being held while
00095 //               this event was generated.
00096 ////////////////////////////////////////////////////////////////////
00097 INLINE void MouseWatcherParameter::
00098 set_modifier_buttons(const ModifierButtons &mods) {
00099   _mods = mods;
00100 }
00101 
00102 ////////////////////////////////////////////////////////////////////
00103 //     Function: MouseWatcherParameter::set_mouse
00104 //       Access: Public
00105 //  Description: Sets the mouse position that was current at the time
00106 //               the event was generated.
00107 ////////////////////////////////////////////////////////////////////
00108 INLINE void MouseWatcherParameter::
00109 set_mouse(const LPoint2f &mouse) {
00110   _mouse = mouse;
00111   _flags |= F_has_mouse;
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: MouseWatcherParameter::set_outside
00116 //       Access: Public
00117 //  Description: Sets the state of the "outside" flag.  This is true
00118 //               if the mouse was outside the region at the time the
00119 //               event was generated, false otherwise.  This only has
00120 //               meaning for "release" events.
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE void MouseWatcherParameter::
00123 set_outside(bool flag) {
00124   if (flag) {
00125     _flags |= F_is_outside;
00126   } else {
00127     _flags &= ~F_is_outside;
00128   }
00129 }
00130 
00131 ////////////////////////////////////////////////////////////////////
00132 //     Function: MouseWatcherParameter::has_button
00133 //       Access: Published
00134 //  Description: Returns true if this parameter has an associated
00135 //               mouse or keyboard button, false otherwise.
00136 ////////////////////////////////////////////////////////////////////
00137 INLINE bool MouseWatcherParameter::
00138 has_button() const {
00139   return (_flags & F_has_button) != 0;
00140 }
00141 
00142 ////////////////////////////////////////////////////////////////////
00143 //     Function: MouseWatcherParameter::get_button
00144 //       Access: Published
00145 //  Description: Returns the mouse or keyboard button associated with
00146 //               this event.  If has_button(), above, returns false,
00147 //               this returns ButtonHandle::none().
00148 ////////////////////////////////////////////////////////////////////
00149 INLINE ButtonHandle MouseWatcherParameter::
00150 get_button() const {
00151   return _button;
00152 }
00153 
00154 ////////////////////////////////////////////////////////////////////
00155 //     Function: MouseWatcherParameter::has_keycode
00156 //       Access: Published
00157 //  Description: Returns true if this parameter has an associated
00158 //               keycode, false otherwise.
00159 ////////////////////////////////////////////////////////////////////
00160 INLINE bool MouseWatcherParameter::
00161 has_keycode() const {
00162   return (_flags & F_has_keycode) != 0;
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: MouseWatcherParameter::get_keycode
00167 //       Access: Published
00168 //  Description: Returns the keycode associated with this event.  If
00169 //               has_keycode(), above, returns false, this returns 0.
00170 ////////////////////////////////////////////////////////////////////
00171 INLINE int MouseWatcherParameter::
00172 get_keycode() const {
00173   return _keycode;
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: MouseWatcherParameter::get_modifier_buttons
00178 //       Access: Published
00179 //  Description: Returns the set of modifier buttons that were being
00180 //               held down while the event was generated.
00181 ////////////////////////////////////////////////////////////////////
00182 INLINE const ModifierButtons &MouseWatcherParameter::
00183 get_modifier_buttons() const {
00184   return _mods;
00185 }
00186 
00187 ////////////////////////////////////////////////////////////////////
00188 //     Function: MouseWatcherParameter::has_mouse
00189 //       Access: Published
00190 //  Description: Returns true if this parameter has an associated
00191 //               mouse position, false otherwise.
00192 ////////////////////////////////////////////////////////////////////
00193 INLINE bool MouseWatcherParameter::
00194 has_mouse() const {
00195   return (_flags & F_has_mouse) != 0;
00196 }
00197 
00198 ////////////////////////////////////////////////////////////////////
00199 //     Function: MouseWatcherParameter::get_mouse
00200 //       Access: Published
00201 //  Description: Returns the mouse position at the time the event was
00202 //               generated, in the normalized range (-1 .. 1).  It is
00203 //               valid to call this only if has_mouse() returned true.
00204 ////////////////////////////////////////////////////////////////////
00205 INLINE const LPoint2f &MouseWatcherParameter::
00206 get_mouse() const {
00207   nassertr(has_mouse(), _mouse);
00208   return _mouse;
00209 }
00210 
00211 ////////////////////////////////////////////////////////////////////
00212 //     Function: MouseWatcherParameter::is_outside
00213 //       Access: Published
00214 //  Description: Returns true if the mouse was outside the region at
00215 //               the time the event was generated, false otherwise.
00216 //               This is only valid for "release" type events.
00217 ////////////////////////////////////////////////////////////////////
00218 INLINE bool MouseWatcherParameter::
00219 is_outside() const {
00220   return (_flags & F_is_outside) != 0;
00221 }
00222 
00223 INLINE ostream &
00224 operator << (ostream &out, const MouseWatcherParameter &parm) {
00225   parm.output(out);
00226   return out;
00227 }

Generated on Fri May 2 00:44:29 2003 for Panda by doxygen1.3