00001 // Filename: mouseWatcher.I 00002 // Created by: drose (12Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: MouseWatcher::has_mouse 00018 // Access: Published 00019 // Description: Returns true if the mouse is anywhere within the 00020 // window, false otherwise. Also see is_mouse_open(). 00021 //////////////////////////////////////////////////////////////////// 00022 INLINE bool MouseWatcher:: 00023 has_mouse() const { 00024 return _has_mouse; 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: MouseWatcher::is_mouse_open 00029 // Access: Published 00030 // Description: Returns true if the mouse is within the window and 00031 // not over some particular MouseWatcherRegion that is 00032 // marked to suppress mouse events; that is, that the 00033 // mouse is in open space within the window. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE bool MouseWatcher:: 00036 is_mouse_open() const { 00037 return _has_mouse && (_internal_suppress & MouseWatcherRegion::SF_mouse_position) == 0; 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: MouseWatcher::get_mouse 00042 // Access: Published 00043 // Description: It is only valid to call this if has_mouse() returns 00044 // true. If so, this returns the current position of 00045 // the mouse within the window. 00046 //////////////////////////////////////////////////////////////////// 00047 INLINE const LPoint2 &MouseWatcher:: 00048 get_mouse() const { 00049 #ifndef NDEBUG 00050 static LPoint2 bogus_mouse(0.0f, 0.0f); 00051 nassertr(_has_mouse, bogus_mouse); 00052 #endif 00053 return _mouse; 00054 } 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Function: MouseWatcher::get_mouse_x 00058 // Access: Published 00059 // Description: It is only valid to call this if has_mouse() returns 00060 // true. If so, this returns the current X position of 00061 // the mouse within the window. 00062 //////////////////////////////////////////////////////////////////// 00063 INLINE PN_stdfloat MouseWatcher:: 00064 get_mouse_x() const { 00065 nassertr(_has_mouse, 0.0f); 00066 return _mouse[0]; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: MouseWatcher::get_mouse_y 00071 // Access: Published 00072 // Description: It is only valid to call this if has_mouse() returns 00073 // true. If so, this returns the current Y position of 00074 // the mouse within the window. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE PN_stdfloat MouseWatcher:: 00077 get_mouse_y() const { 00078 nassertr(_has_mouse, 0.0f); 00079 return _mouse[1]; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: MouseWatcher::set_frame 00084 // Access: Published 00085 // Description: Sets the frame of the MouseWatcher. See the next 00086 // flavor of this method for a more verbose explanation. 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE void MouseWatcher:: 00089 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { 00090 set_frame(LVecBase4(left, right, bottom, top)); 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: MouseWatcher::set_frame 00095 // Access: Published 00096 // Description: Sets the frame of the MouseWatcher. This determines 00097 // the coordinate space in which the MouseWatcherRegions 00098 // should be expected to live. Normally, this is left 00099 // at -1, 1, -1, 1, which is the default setting, and 00100 // matches the mouse coordinate range. 00101 // 00102 // Whatever values you specify here indicate the shape 00103 // of the full screen, and the MouseWatcherRegions will 00104 // be given in coordinate space matching it. For 00105 // instance, if you specify (0, 1, 0, 1), then a 00106 // MouseWatcherRegion with the frame (0, 1, 0, .5) will 00107 // cover the lower half of the screen. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE void MouseWatcher:: 00110 set_frame(const LVecBase4 &frame) { 00111 _frame = frame; 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: MouseWatcher::get_frame 00116 // Access: Published 00117 // Description: Returns the frame of the MouseWatcher. See 00118 // set_frame(). 00119 //////////////////////////////////////////////////////////////////// 00120 INLINE const LVecBase4 &MouseWatcher:: 00121 get_frame() const { 00122 return _frame; 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: MouseWatcher::is_over_region 00127 // Access: Published 00128 // Description: Returns true if the mouse is over any rectangular 00129 // region, false otherwise. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE bool MouseWatcher:: 00132 is_over_region() const { 00133 return get_over_region() != (MouseWatcherRegion *)NULL; 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: MouseWatcher::is_over_region 00138 // Access: Published 00139 // Description: Returns true if the mouse is over any rectangular 00140 // region, false otherwise. 00141 //////////////////////////////////////////////////////////////////// 00142 INLINE bool MouseWatcher:: 00143 is_over_region(PN_stdfloat x, PN_stdfloat y) const { 00144 return get_over_region(x, y) != (MouseWatcherRegion *)NULL; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: MouseWatcher::is_over_region 00149 // Access: Published 00150 // Description: Returns true if the mouse is over any rectangular 00151 // region, false otherwise. 00152 //////////////////////////////////////////////////////////////////// 00153 INLINE bool MouseWatcher:: 00154 is_over_region(const LPoint2 &pos) const { 00155 return get_over_region(pos) != (MouseWatcherRegion *)NULL; 00156 } 00157 00158 //////////////////////////////////////////////////////////////////// 00159 // Function: MouseWatcher::get_over_region 00160 // Access: Published 00161 // Description: Returns the smallest region the mouse is currently 00162 // over, or NULL if it is over no region. 00163 //////////////////////////////////////////////////////////////////// 00164 INLINE MouseWatcherRegion *MouseWatcher:: 00165 get_over_region() const { 00166 return _preferred_region; 00167 } 00168 00169 //////////////////////////////////////////////////////////////////// 00170 // Function: MouseWatcher::get_over_region 00171 // Access: Published 00172 // Description: Returns the smallest region the indicated point is 00173 // over, or NULL if it is over no region. 00174 //////////////////////////////////////////////////////////////////// 00175 INLINE MouseWatcherRegion *MouseWatcher:: 00176 get_over_region(PN_stdfloat x, PN_stdfloat y) const { 00177 return get_over_region(LPoint2(x, y)); 00178 } 00179 00180 //////////////////////////////////////////////////////////////////// 00181 // Function: MouseWatcher::is_button_down 00182 // Access: Published 00183 // Description: Returns true if the indicated button is currently 00184 // being held down, false otherwise. 00185 //////////////////////////////////////////////////////////////////// 00186 INLINE bool MouseWatcher:: 00187 is_button_down(ButtonHandle button) const { 00188 return _inactivity_state != IS_inactive && _current_buttons_down.get_bit(button.get_index()); 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function: MouseWatcher::set_button_down_pattern 00193 // Access: Published 00194 // Description: Sets the pattern string that indicates how the event 00195 // names are generated when a button is depressed. This 00196 // is a string that may contain any of the following: 00197 // 00198 // %r - the name of the region the mouse is over 00199 // %b - the name of the button pressed. 00200 // 00201 // The event name will be based on the in_pattern 00202 // string specified here, with all occurrences of the 00203 // above strings replaced with the corresponding values. 00204 //////////////////////////////////////////////////////////////////// 00205 INLINE void MouseWatcher:: 00206 set_button_down_pattern(const string &pattern) { 00207 _button_down_pattern = pattern; 00208 } 00209 00210 //////////////////////////////////////////////////////////////////// 00211 // Function: MouseWatcher::get_button_down_pattern 00212 // Access: Published 00213 // Description: Returns the string that indicates how event names are 00214 // generated when a button is depressed. See 00215 // set_button_down_pattern(). 00216 //////////////////////////////////////////////////////////////////// 00217 INLINE const string &MouseWatcher:: 00218 get_button_down_pattern() const { 00219 return _button_down_pattern; 00220 } 00221 00222 //////////////////////////////////////////////////////////////////// 00223 // Function: MouseWatcher::set_button_up_pattern 00224 // Access: Published 00225 // Description: Sets the pattern string that indicates how the event 00226 // names are generated when a button is released. See 00227 // set_button_down_pattern(). 00228 //////////////////////////////////////////////////////////////////// 00229 INLINE void MouseWatcher:: 00230 set_button_up_pattern(const string &pattern) { 00231 _button_up_pattern = pattern; 00232 } 00233 00234 //////////////////////////////////////////////////////////////////// 00235 // Function: MouseWatcher::get_button_up_pattern 00236 // Access: Published 00237 // Description: Returns the string that indicates how event names are 00238 // generated when a button is released. See 00239 // set_button_down_pattern(). 00240 //////////////////////////////////////////////////////////////////// 00241 INLINE const string &MouseWatcher:: 00242 get_button_up_pattern() const { 00243 return _button_up_pattern; 00244 } 00245 00246 //////////////////////////////////////////////////////////////////// 00247 // Function: MouseWatcher::set_button_repeat_pattern 00248 // Access: Published 00249 // Description: Sets the pattern string that indicates how the event 00250 // names are generated when a button is continuously 00251 // held and generates keyrepeat "down" events. This is 00252 // a string that may contain any of the following: 00253 // 00254 // %r - the name of the region the mouse is over 00255 // %b - the name of the button pressed. 00256 // 00257 // The event name will be based on the in_pattern 00258 // string specified here, with all occurrences of the 00259 // above strings replaced with the corresponding values. 00260 //////////////////////////////////////////////////////////////////// 00261 INLINE void MouseWatcher:: 00262 set_button_repeat_pattern(const string &pattern) { 00263 _button_repeat_pattern = pattern; 00264 } 00265 00266 //////////////////////////////////////////////////////////////////// 00267 // Function: MouseWatcher::get_button_repeat_pattern 00268 // Access: Published 00269 // Description: Returns the string that indicates how event names are 00270 // names are generated when a button is continuously 00271 // held and generates keyrepeat "down" events. See 00272 // set_button_repeat_pattern(). 00273 //////////////////////////////////////////////////////////////////// 00274 INLINE const string &MouseWatcher:: 00275 get_button_repeat_pattern() const { 00276 return _button_repeat_pattern; 00277 } 00278 00279 //////////////////////////////////////////////////////////////////// 00280 // Function: MouseWatcher::set_enter_pattern 00281 // Access: Published 00282 // Description: Sets the pattern string that indicates how the event 00283 // names are generated when the mouse enters a region. 00284 // This is different from within_pattern, in that a 00285 // mouse is only "entered" in the topmost region at a 00286 // given time, while it might be "within" multiple 00287 // nested regions. 00288 //////////////////////////////////////////////////////////////////// 00289 INLINE void MouseWatcher:: 00290 set_enter_pattern(const string &pattern) { 00291 _enter_pattern = pattern; 00292 } 00293 00294 //////////////////////////////////////////////////////////////////// 00295 // Function: MouseWatcher::get_enter_pattern 00296 // Access: Published 00297 // Description: Returns the string that indicates how event names are 00298 // generated when the mouse enters a region. This is 00299 // different from within_pattern, in that a mouse is 00300 // only "entered" in the topmost region at a given time, 00301 // while it might be "within" multiple nested regions. 00302 //////////////////////////////////////////////////////////////////// 00303 INLINE const string &MouseWatcher:: 00304 get_enter_pattern() const { 00305 return _enter_pattern; 00306 } 00307 00308 //////////////////////////////////////////////////////////////////// 00309 // Function: MouseWatcher::set_leave_pattern 00310 // Access: Published 00311 // Description: Sets the pattern string that indicates how the event 00312 // names are generated when the mouse leaves a region. 00313 // This is different from without_pattern, in that a 00314 // mouse is only "entered" in the topmost region at a 00315 // given time, while it might be "within" multiple 00316 // nested regions. 00317 //////////////////////////////////////////////////////////////////// 00318 INLINE void MouseWatcher:: 00319 set_leave_pattern(const string &pattern) { 00320 _leave_pattern = pattern; 00321 } 00322 00323 //////////////////////////////////////////////////////////////////// 00324 // Function: MouseWatcher::get_leave_pattern 00325 // Access: Published 00326 // Description: Returns the string that indicates how event names are 00327 // generated when the mouse leaves a region. This is 00328 // different from without_pattern, in that a mouse is 00329 // only "entered" in the topmost region at a given time, 00330 // while it might be "within" multiple nested regions. 00331 //////////////////////////////////////////////////////////////////// 00332 INLINE const string &MouseWatcher:: 00333 get_leave_pattern() const { 00334 return _leave_pattern; 00335 } 00336 00337 //////////////////////////////////////////////////////////////////// 00338 // Function: MouseWatcher::set_within_pattern 00339 // Access: Published 00340 // Description: Sets the pattern string that indicates how the event 00341 // names are generated when the mouse wanders over a 00342 // region. This is different from enter_pattern, in 00343 // that a mouse is only "entered" in the topmost region 00344 // at a given time, while it might be "within" multiple 00345 // nested regions. 00346 //////////////////////////////////////////////////////////////////// 00347 INLINE void MouseWatcher:: 00348 set_within_pattern(const string &pattern) { 00349 _within_pattern = pattern; 00350 } 00351 00352 //////////////////////////////////////////////////////////////////// 00353 // Function: MouseWatcher::get_within_pattern 00354 // Access: Published 00355 // Description: Returns the string that indicates how event names are 00356 // generated when the mouse wanders over a region. This 00357 // is different from enter_pattern, in that a mouse is 00358 // only "entered" in the topmost region at a given time, 00359 // while it might be "within" multiple nested regions. 00360 //////////////////////////////////////////////////////////////////// 00361 INLINE const string &MouseWatcher:: 00362 get_within_pattern() const { 00363 return _within_pattern; 00364 } 00365 00366 //////////////////////////////////////////////////////////////////// 00367 // Function: MouseWatcher::set_without_pattern 00368 // Access: Published 00369 // Description: Sets the pattern string that indicates how the event 00370 // names are generated when the mouse wanders out of a 00371 // region. This is different from leave_pattern, in 00372 // that a mouse is only "entered" in the topmost region 00373 // at a given time, while it might be "within" multiple 00374 // nested regions. 00375 //////////////////////////////////////////////////////////////////// 00376 INLINE void MouseWatcher:: 00377 set_without_pattern(const string &pattern) { 00378 _without_pattern = pattern; 00379 } 00380 00381 //////////////////////////////////////////////////////////////////// 00382 // Function: MouseWatcher::get_without_pattern 00383 // Access: Published 00384 // Description: Returns the string that indicates how event names are 00385 // generated when the mouse wanders out of a region. 00386 // This is different from leave_pattern, in that a mouse 00387 // is only "entered" in the topmost region at a given 00388 // time, while it might be "within" multiple nested 00389 // regions. 00390 //////////////////////////////////////////////////////////////////// 00391 INLINE const string &MouseWatcher:: 00392 get_without_pattern() const { 00393 return _without_pattern; 00394 } 00395 00396 //////////////////////////////////////////////////////////////////// 00397 // Function: MouseWatcher::set_geometry 00398 // Access: Published 00399 // Description: Sets the node that will be transformed each frame by 00400 // the mouse's coordinates. It will also be hidden when 00401 // the mouse goes outside the window. This can be used 00402 // to implement a software mouse pointer for when a 00403 // hardware (or system) mouse pointer is unavailable. 00404 //////////////////////////////////////////////////////////////////// 00405 INLINE void MouseWatcher:: 00406 set_geometry(PandaNode *node) { 00407 _geometry = node; 00408 } 00409 00410 //////////////////////////////////////////////////////////////////// 00411 // Function: MouseWatcher::has_geometry 00412 // Access: Published 00413 // Description: Returns true if a software mouse pointer has been 00414 // setup via set_geometry(), or false otherwise. See 00415 // set_geometry(). 00416 //////////////////////////////////////////////////////////////////// 00417 INLINE bool MouseWatcher:: 00418 has_geometry() const { 00419 return !_geometry.is_null(); 00420 } 00421 00422 //////////////////////////////////////////////////////////////////// 00423 // Function: MouseWatcher::get_geometry 00424 // Access: Published 00425 // Description: Returns the node that has been set as the software 00426 // mouse pointer, or NULL if no node has been set. See 00427 // has_geometry() and set_geometry(). 00428 //////////////////////////////////////////////////////////////////// 00429 INLINE PandaNode *MouseWatcher:: 00430 get_geometry() const { 00431 return _geometry; 00432 } 00433 00434 //////////////////////////////////////////////////////////////////// 00435 // Function: MouseWatcher::clear_geometry 00436 // Access: Published 00437 // Description: Stops the use of the software cursor set up via 00438 // set_geometry(). 00439 //////////////////////////////////////////////////////////////////// 00440 INLINE void MouseWatcher:: 00441 clear_geometry() { 00442 _geometry.clear(); 00443 } 00444 00445 //////////////////////////////////////////////////////////////////// 00446 // Function: MouseWatcher::set_extra_handler 00447 // Access: Published 00448 // Description: As an optimization for the C++ Gui, an extra handler 00449 // can be registered with a mouseWatcher so that events 00450 // can be dealt with much sooner. 00451 //////////////////////////////////////////////////////////////////// 00452 INLINE void MouseWatcher:: 00453 set_extra_handler(EventHandler *eh) { 00454 _eh = eh; 00455 } 00456 00457 //////////////////////////////////////////////////////////////////// 00458 // Function: MouseWatcher::get_extra_handler 00459 // Access: Published 00460 // Description: As an optimization for the C++ Gui, an extra handler 00461 // can be registered with a mouseWatcher so that events 00462 // can be dealt with much sooner. 00463 //////////////////////////////////////////////////////////////////// 00464 INLINE EventHandler *MouseWatcher:: 00465 get_extra_handler() const { 00466 return _eh; 00467 } 00468 00469 //////////////////////////////////////////////////////////////////// 00470 // Function: MouseWatcher::set_modifier_buttons 00471 // Access: Public 00472 // Description: Sets the buttons that should be monitored as modifier 00473 // buttons for generating events to the 00474 // MouseWatcherRegions. 00475 //////////////////////////////////////////////////////////////////// 00476 INLINE void MouseWatcher:: 00477 set_modifier_buttons(const ModifierButtons &mods) { 00478 _mods = mods; 00479 } 00480 00481 //////////////////////////////////////////////////////////////////// 00482 // Function: MouseWatcher::get_modifier_buttons 00483 // Access: Published 00484 // Description: Returns the set of buttons that are being monitored 00485 // as modifier buttons, as well as their current state. 00486 //////////////////////////////////////////////////////////////////// 00487 INLINE ModifierButtons MouseWatcher:: 00488 get_modifier_buttons() const { 00489 return _mods; 00490 } 00491 00492 //////////////////////////////////////////////////////////////////// 00493 // Function: MouseWatcher::set_display_region 00494 // Access: Published 00495 // Description: Constrains the MouseWatcher to watching the mouse 00496 // within a particular indicated region of the screen. 00497 // DataNodes parented under the MouseWatcher will 00498 // observe the mouse and keyboard events only when the 00499 // mouse is within the indicated region, and the 00500 // observed range will be from -1 .. 1 across the 00501 // region. 00502 // 00503 // Do not delete the DisplayRegion while it is owned by 00504 // the MouseWatcher. 00505 //////////////////////////////////////////////////////////////////// 00506 INLINE void MouseWatcher:: 00507 set_display_region(DisplayRegion *dr) { 00508 _display_region = dr; 00509 } 00510 00511 //////////////////////////////////////////////////////////////////// 00512 // Function: MouseWatcher::clear_display_region 00513 // Access: Published 00514 // Description: Removes the display region constraint from the 00515 // MouseWatcher, and restores it to the default behavior 00516 // of watching the whole window. 00517 //////////////////////////////////////////////////////////////////// 00518 INLINE void MouseWatcher:: 00519 clear_display_region() { 00520 _display_region = NULL; 00521 } 00522 00523 //////////////////////////////////////////////////////////////////// 00524 // Function: MouseWatcher::get_display_region 00525 // Access: Published 00526 // Description: Returns the display region the MouseWatcher is 00527 // constrained to by set_display_region(), or NULL if it 00528 // is not constrained. 00529 //////////////////////////////////////////////////////////////////// 00530 INLINE DisplayRegion *MouseWatcher:: 00531 get_display_region() const { 00532 return _display_region; 00533 } 00534 00535 //////////////////////////////////////////////////////////////////// 00536 // Function: MouseWatcher::has_display_region 00537 // Access: Published 00538 // Description: Returns true if the MouseWatcher has been constrained 00539 // to a particular region of the screen via 00540 // set_display_region(), or false otherwise. If this 00541 // returns true, get_display_region() may be used to 00542 // return the particular region. 00543 //////////////////////////////////////////////////////////////////// 00544 INLINE bool MouseWatcher:: 00545 has_display_region() const { 00546 return (_display_region != (DisplayRegion *)NULL); 00547 } 00548 00549 //////////////////////////////////////////////////////////////////// 00550 // Function: MouseWatcher::set_inactivity_timeout 00551 // Access: Published 00552 // Description: Sets an inactivity timeout on the mouse activity. 00553 // When this timeout (in seconds) is exceeded with no 00554 // keyboard or mouse activity, all currently-held 00555 // buttons are automatically released. This is intended 00556 // to help protect against people who inadvertently (or 00557 // intentionally) leave a keyboard key stuck down and 00558 // then wander away from the keyboard. 00559 // 00560 // Also, when this timeout expires, the event specified 00561 // by set_inactivity_timeout_event() will be generated. 00562 //////////////////////////////////////////////////////////////////// 00563 INLINE void MouseWatcher:: 00564 set_inactivity_timeout(double timeout) { 00565 _has_inactivity_timeout = true; 00566 _inactivity_timeout = timeout; 00567 note_activity(); 00568 } 00569 00570 //////////////////////////////////////////////////////////////////// 00571 // Function: MouseWatcher::has_inactivity_timeout 00572 // Access: Published 00573 // Description: Returns true if an inactivity timeout has been set, 00574 // false otherwise. 00575 //////////////////////////////////////////////////////////////////// 00576 INLINE bool MouseWatcher:: 00577 has_inactivity_timeout() const { 00578 return _has_inactivity_timeout; 00579 } 00580 00581 //////////////////////////////////////////////////////////////////// 00582 // Function: MouseWatcher::get_inactivity_timeout 00583 // Access: Published 00584 // Description: Returns the inactivity timeout that has been set. 00585 // It is an error to call this if 00586 // has_inactivity_timeout() returns false. 00587 //////////////////////////////////////////////////////////////////// 00588 INLINE double MouseWatcher:: 00589 get_inactivity_timeout() const { 00590 nassertr(_has_inactivity_timeout, 0.0); 00591 return _inactivity_timeout; 00592 } 00593 00594 //////////////////////////////////////////////////////////////////// 00595 // Function: MouseWatcher::clear_inactivity_timeout 00596 // Access: Published 00597 // Description: Removes the inactivity timeout and restores the 00598 // MouseWatcher to its default behavior of allowing a 00599 // key to be held indefinitely. 00600 //////////////////////////////////////////////////////////////////// 00601 INLINE void MouseWatcher:: 00602 clear_inactivity_timeout() { 00603 _has_inactivity_timeout = false; 00604 _inactivity_timeout = 0.0; 00605 note_activity(); 00606 } 00607 00608 //////////////////////////////////////////////////////////////////// 00609 // Function: MouseWatcher::set_inactivity_timeout_event 00610 // Access: Published 00611 // Description: Specifies the event string that will be generated 00612 // when the inactivity timeout counter expires. See 00613 // set_inactivity_timeout(). 00614 //////////////////////////////////////////////////////////////////// 00615 INLINE void MouseWatcher:: 00616 set_inactivity_timeout_event(const string &event) { 00617 _inactivity_timeout_event = event; 00618 } 00619 00620 //////////////////////////////////////////////////////////////////// 00621 // Function: MouseWatcher::get_inactivity_timeout_event 00622 // Access: Published 00623 // Description: Returns the event string that will be generated 00624 // when the inactivity timeout counter expires. See 00625 // set_inactivity_timeout(). 00626 //////////////////////////////////////////////////////////////////// 00627 INLINE const string &MouseWatcher:: 00628 get_inactivity_timeout_event() const { 00629 return _inactivity_timeout_event; 00630 } 00631 00632 //////////////////////////////////////////////////////////////////// 00633 // Function: MouseWatcher::within_region 00634 // Access: Protected 00635 // Description: Called internally to indicate the mouse pointer has 00636 // moved within the indicated region's boundaries. 00637 //////////////////////////////////////////////////////////////////// 00638 INLINE void MouseWatcher:: 00639 within_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { 00640 region->within_region(param); 00641 throw_event_pattern(_within_pattern, region, ButtonHandle::none()); 00642 if (_enter_multiple) { 00643 enter_region(region, param); 00644 } 00645 } 00646 00647 //////////////////////////////////////////////////////////////////// 00648 // Function: MouseWatcher::without_region 00649 // Access: Protected 00650 // Description: Called internally to indicate the mouse pointer has 00651 // moved outside of the indicated region's boundaries. 00652 //////////////////////////////////////////////////////////////////// 00653 INLINE void MouseWatcher:: 00654 without_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { 00655 if (_enter_multiple) { 00656 exit_region(region, param); 00657 } 00658 region->without_region(param); 00659 throw_event_pattern(_without_pattern, region, ButtonHandle::none()); 00660 } 00661 00662 //////////////////////////////////////////////////////////////////// 00663 // Function: MouseWatcher::clear_trail_log 00664 // Access: Published 00665 // Description: Clears the mouse trail log. This does not prevent 00666 // further accumulation of the log given future events. 00667 //////////////////////////////////////////////////////////////////// 00668 INLINE void MouseWatcher:: 00669 clear_trail_log() { 00670 _trail_log->clear(); 00671 } 00672 00673 //////////////////////////////////////////////////////////////////// 00674 // Function: MouseWatcher::get_trail_log 00675 // Access: Published 00676 // Description: Obtain the mouse trail log. This is a PointerEventList. 00677 // Does not make a copy, therefore, this PointerEventList 00678 // will be updated each time process_events gets called. 00679 // 00680 // To use trail logging, you need to enable the 00681 // generation of pointer events in the 00682 // GraphicsWindowInputDevice and set the trail log 00683 // duration in the MouseWatcher. Otherwise, the 00684 // trail log will be empty. 00685 //////////////////////////////////////////////////////////////////// 00686 INLINE CPT(PointerEventList) MouseWatcher:: 00687 get_trail_log() const { 00688 return _trail_log; 00689 } 00690 00691 //////////////////////////////////////////////////////////////////// 00692 // Function: MouseWatcher::num_trail_recent 00693 // Access: Published 00694 // Description: This counter indicates how many events were added 00695 // to the trail log this frame. The trail log is 00696 // updated once per frame, during the process_events 00697 // operation. 00698 //////////////////////////////////////////////////////////////////// 00699 INLINE int MouseWatcher:: 00700 num_trail_recent() const { 00701 return _num_trail_recent; 00702 }