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

panda/src/tform/mouseWatcherRegion.I

Go to the documentation of this file.
00001 // Filename: mouseWatcherRegion.I
00002 // Created by:  drose (13Jul00)
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: MouseWatcherRegion::Constructor
00022 //       Access: Published
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 INLINE MouseWatcherRegion::
00026 MouseWatcherRegion(const string &name, float left, float right,
00027                    float bottom, float top) :
00028   Namable(name),
00029   _frame(left, right, bottom, top)
00030 {
00031   _sort = 0;
00032   _flags = F_active;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: MouseWatcherRegion::Constructor
00037 //       Access: Published
00038 //  Description:
00039 ////////////////////////////////////////////////////////////////////
00040 INLINE MouseWatcherRegion::
00041 MouseWatcherRegion(const string &name, const LVecBase4f &frame) :
00042   Namable(name),
00043   _frame(frame)
00044 {
00045   _sort = 0;
00046   _flags = F_active;
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: MouseWatcherRegion::set_frame
00051 //       Access: Published
00052 //  Description:
00053 ////////////////////////////////////////////////////////////////////
00054 INLINE void MouseWatcherRegion::
00055 set_frame(float left, float right, float bottom, float top) {
00056   set_frame(LVecBase4f(left, right, bottom, top));
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: MouseWatcherRegion::set_frame
00061 //       Access: Published
00062 //  Description:
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void MouseWatcherRegion::
00065 set_frame(const LVecBase4f &frame) {
00066   _frame = frame;
00067   _area = (_frame[1] - _frame[0]) * (_frame[3] - _frame[2]);
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: MouseWatcherRegion::get_frame
00072 //       Access: Published
00073 //  Description:
00074 ////////////////////////////////////////////////////////////////////
00075 INLINE const LVecBase4f &MouseWatcherRegion::
00076 get_frame() const {
00077   return _frame;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: MouseWatcherRegion::get_area
00082 //       Access: Published
00083 //  Description: Returns the area of the rectangular region.
00084 ////////////////////////////////////////////////////////////////////
00085 INLINE float MouseWatcherRegion::
00086 get_area() const {
00087   return _area;
00088 }
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: MouseWatcherRegion::set_sort
00092 //       Access: Published
00093 //  Description: Changes the sorting order of this particular region.
00094 //               The sorting order is used to resolve conflicts in the
00095 //               case of overlapping region; the region with the
00096 //               highest sort value will be preferred, and between
00097 //               regions of the same sort value, the smallest region
00098 //               will be preferred.  The default sorting order, if
00099 //               none is explicitly specified, is 0.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE void MouseWatcherRegion::
00102 set_sort(int sort) {
00103   _sort = sort;
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: MouseWatcherRegion::get_sort
00108 //       Access: Published
00109 //  Description: Returns the current sorting order of this region.
00110 //               See set_sort().
00111 ////////////////////////////////////////////////////////////////////
00112 INLINE int MouseWatcherRegion::
00113 get_sort() const {
00114   return _sort;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: MouseWatcherRegion::set_active
00119 //       Access: Published
00120 //  Description: Sets whether the region is active or not.  If it is
00121 //               not active, the MouseWatcher will never consider the
00122 //               mouse to be over the region.  The region might still
00123 //               receive keypress events if its set_keyboard() flag is
00124 //               true.
00125 ////////////////////////////////////////////////////////////////////
00126 INLINE void MouseWatcherRegion::
00127 set_active(bool active) {
00128   if (active) {
00129     _flags |= F_active;
00130   } else {
00131     _flags &= ~F_active;
00132   }
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: MouseWatcherRegion::get_active
00137 //       Access: Published
00138 //  Description: Returns whether the region is active or not.  See
00139 //               set_active().
00140 ////////////////////////////////////////////////////////////////////
00141 INLINE bool MouseWatcherRegion::
00142 get_active() const {
00143   return ((_flags & F_active) != 0);
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: MouseWatcherRegion::set_keyboard
00148 //       Access: Published
00149 //  Description: Sets whether the region is interested in global
00150 //               keyboard events.  If this is true, then any keyboard
00151 //               button events will be passed to press() and release()
00152 //               regardless of the position of the mouse onscreen;
00153 //               otherwise, these events will only be passed if the
00154 //               mouse is over the region.
00155 ////////////////////////////////////////////////////////////////////
00156 INLINE void MouseWatcherRegion::
00157 set_keyboard(bool keyboard) {
00158   if (keyboard) {
00159     _flags |= F_keyboard;
00160   } else {
00161     _flags &= ~F_keyboard;
00162   }
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: MouseWatcherRegion::get_keyboard
00167 //       Access: Published
00168 //  Description: Returns whether the region is interested in global
00169 //               keyboard events; see set_keyboard().
00170 ////////////////////////////////////////////////////////////////////
00171 INLINE bool MouseWatcherRegion::
00172 get_keyboard() const {
00173   return ((_flags & F_keyboard) != 0);
00174 }
00175 
00176 ////////////////////////////////////////////////////////////////////
00177 //     Function: MouseWatcherRegion::set_suppress_flags
00178 //       Access: Published
00179 //  Description: Sets which events are suppressed when the mouse is
00180 //               over the region.  This is the union of zero or more
00181 //               various SF_* values.  Normally, this is 0, indicating
00182 //               that no events are suppressed.
00183 //
00184 //               If you set this to a non-zero value, for instance
00185 //               SF_mouse_position, then the mouse position will not
00186 //               be sent along the data graph when the mouse is over
00187 //               this particular region.
00188 ////////////////////////////////////////////////////////////////////
00189 INLINE void MouseWatcherRegion::
00190 set_suppress_flags(int suppress_flags) {
00191   _flags = ((_flags & ~F_suppress_flags) | (suppress_flags & F_suppress_flags));
00192 }
00193 
00194 ////////////////////////////////////////////////////////////////////
00195 //     Function: MouseWatcherRegion::get_suppress_flags
00196 //       Access: Published
00197 //  Description: Returns the current suppress_flags.  See
00198 //               set_suppress_flags().
00199 ////////////////////////////////////////////////////////////////////
00200 INLINE int MouseWatcherRegion::
00201 get_suppress_flags() const {
00202   return (_flags & F_suppress_flags);
00203 }
00204 
00205 ////////////////////////////////////////////////////////////////////
00206 //     Function: MouseWatcherRegion::Ordering Operator
00207 //       Access: Public
00208 //  Description: Returns true if this region should be preferred over
00209 //               the other region when they overlap, false otherwise.
00210 ////////////////////////////////////////////////////////////////////
00211 INLINE bool MouseWatcherRegion::
00212 operator < (const MouseWatcherRegion &other) const {
00213   if (_sort != other._sort) {
00214     return _sort > other._sort;
00215   }
00216   return _area < other._area;
00217 }

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