Panda3D
|
00001 // Filename: pgMouseWatcherRegion.cxx 00002 // Created by: drose (02Jul01) 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 #include "pgMouseWatcherRegion.h" 00016 #include "pgItem.h" 00017 00018 #include "string_utils.h" 00019 00020 int PGMouseWatcherRegion::_next_index = 0; 00021 TypeHandle PGMouseWatcherRegion::_type_handle; 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: PGMouseWatcherRegion::Constructor 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 PGMouseWatcherRegion:: 00029 PGMouseWatcherRegion(PGItem *item) : 00030 #ifndef CPPPARSER 00031 MouseWatcherRegion("pg" + format_string(_next_index++), 0, 0, 0, 0), 00032 #endif 00033 _item(item) 00034 { 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: PGMouseWatcherRegion::Destructor 00039 // Access: Public, Virtual 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 PGMouseWatcherRegion:: 00043 ~PGMouseWatcherRegion() { 00044 } 00045 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: PGMouseWatcherRegion::enter_region 00049 // Access: Public, Virtual 00050 // Description: This is a callback hook function, called whenever the 00051 // mouse enters the region. The mouse is only 00052 // considered to be "entered" in one region at a time; 00053 // in the case of nested regions, it exits the outer 00054 // region before entering the inner one. 00055 //////////////////////////////////////////////////////////////////// 00056 void PGMouseWatcherRegion:: 00057 enter_region(const MouseWatcherParameter ¶m) { 00058 if (_item != (PGItem *)NULL) { 00059 _item->enter_region(param); 00060 } 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: PGMouseWatcherRegion::exit_region 00065 // Access: Public, Virtual 00066 // Description: This is a callback hook function, called whenever the 00067 // mouse exits the region. The mouse is only considered 00068 // to be "entered" in one region at a time; in the case 00069 // of nested regions, it exits the outer region before 00070 // entering the inner one. 00071 //////////////////////////////////////////////////////////////////// 00072 void PGMouseWatcherRegion:: 00073 exit_region(const MouseWatcherParameter ¶m) { 00074 if (_item != (PGItem *)NULL) { 00075 _item->exit_region(param); 00076 } 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function: PGMouseWatcherRegion::within_region 00081 // Access: Public, Virtual 00082 // Description: This is a callback hook function, called whenever the 00083 // mouse moves within the boundaries of the region, even 00084 // if it is also within the boundaries of a nested 00085 // region. This is different from "enter", which is 00086 // only called whenever the mouse is within only that 00087 // region. 00088 //////////////////////////////////////////////////////////////////// 00089 void PGMouseWatcherRegion:: 00090 within_region(const MouseWatcherParameter ¶m) { 00091 if (_item != (PGItem *)NULL) { 00092 _item->within_region(param); 00093 } 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: PGMouseWatcherRegion::without_region 00098 // Access: Public, Virtual 00099 // Description: This is a callback hook function, called whenever the 00100 // mouse moves completely outside the boundaries of the 00101 // region. See within_region(). 00102 //////////////////////////////////////////////////////////////////// 00103 void PGMouseWatcherRegion:: 00104 without_region(const MouseWatcherParameter ¶m) { 00105 if (_item != (PGItem *)NULL) { 00106 _item->without_region(param); 00107 } 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: PGMouseWatcherRegion::press 00112 // Access: Public, Virtual 00113 // Description: This is a callback hook function, called whenever a 00114 // mouse or keyboard button is depressed while the mouse 00115 // is within the region. 00116 //////////////////////////////////////////////////////////////////// 00117 void PGMouseWatcherRegion:: 00118 press(const MouseWatcherParameter ¶m) { 00119 if (_item != (PGItem *)NULL) { 00120 _item->press(param, false); 00121 } 00122 } 00123 00124 //////////////////////////////////////////////////////////////////// 00125 // Function: PGMouseWatcherRegion::release 00126 // Access: Public, Virtual 00127 // Description: This is a callback hook function, called whenever a 00128 // mouse or keyboard button previously depressed with 00129 // press() is released. 00130 //////////////////////////////////////////////////////////////////// 00131 void PGMouseWatcherRegion:: 00132 release(const MouseWatcherParameter ¶m) { 00133 if (_item != (PGItem *)NULL) { 00134 _item->release(param, false); 00135 } 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: PGMouseWatcherRegion::keystroke 00140 // Access: Public, Virtual 00141 // Description: This is a callback hook function, called whenever 00142 // the user presses a key. 00143 //////////////////////////////////////////////////////////////////// 00144 void PGMouseWatcherRegion:: 00145 keystroke(const MouseWatcherParameter ¶m) { 00146 if (_item != (PGItem *)NULL) { 00147 _item->keystroke(param, false); 00148 } 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: PGMouseWatcherRegion::candidate 00153 // Access: Public, Virtual 00154 // Description: This is a callback hook function, called whenever 00155 // the user selects an option from the IME menu. 00156 //////////////////////////////////////////////////////////////////// 00157 void PGMouseWatcherRegion:: 00158 candidate(const MouseWatcherParameter ¶m) { 00159 if (_item != (PGItem *)NULL) { 00160 _item->candidate(param, false); 00161 } 00162 } 00163 00164 //////////////////////////////////////////////////////////////////// 00165 // Function: PGMouseWatcherRegion::move 00166 // Access: Public, Virtual 00167 // Description: This is a callback hook function, called whenever 00168 // the user moves the mouse within the region 00169 //////////////////////////////////////////////////////////////////// 00170 void PGMouseWatcherRegion:: 00171 move(const MouseWatcherParameter ¶m) { 00172 if (_item != (PGItem *)NULL) { 00173 _item->move(param); 00174 } 00175 }