00001 // Filename: buttonThrower.I 00002 // Created by: drose (26Dec03) 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: ButtonThrower::set_button_down_event 00018 // Access: Published 00019 // Description: Specifies the generic event that is generated (if 00020 // any) each time a key or button is depressed. Unlike 00021 // the specific events that are unique to each key, this 00022 // same event name is used for *all* button events, and 00023 // the name of the button pressed (possibly with 00024 // modifier prefixes) will be sent as a parameter. 00025 // 00026 // If this string is empty, no event is generated. It 00027 // is possible to generate both generic events and 00028 // specific events for the same button. 00029 // 00030 // See also set_keystroke_event(). 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE void ButtonThrower:: 00033 set_button_down_event(const string &button_down_event) { 00034 _button_down_event = button_down_event; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: ButtonThrower::get_button_down_event 00039 // Access: Published 00040 // Description: Returns the button_down_event that has been set on 00041 // this ButtonThrower. See set_button_down_event(). 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE const string &ButtonThrower:: 00044 get_button_down_event() const { 00045 return _button_down_event; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: ButtonThrower::set_button_up_event 00050 // Access: Published 00051 // Description: Specifies the generic event that is generated (if 00052 // any) each time a key or button is released. See 00053 // set_button_down_event(). 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE void ButtonThrower:: 00056 set_button_up_event(const string &button_up_event) { 00057 _button_up_event = button_up_event; 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: ButtonThrower::get_button_up_event 00062 // Access: Published 00063 // Description: Returns the button_up_event that has been set on 00064 // this ButtonThrower. See set_button_up_event(). 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE const string &ButtonThrower:: 00067 get_button_up_event() const { 00068 return _button_up_event; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: ButtonThrower::set_button_repeat_event 00073 // Access: Published 00074 // Description: Specifies the generic event that is generated (if 00075 // any) repeatedly while a key or button is held down. 00076 // Unlike the specific events that are unique to each 00077 // key, this same event name is used for *all* button 00078 // events, and the name of the button pressed (possibly 00079 // with modifier prefixes) will be sent as a parameter. 00080 // 00081 // If this string is empty, no event is generated. It 00082 // is possible to generate both generic events and 00083 // specific events for the same button. 00084 // 00085 // See also set_keystroke_event(). 00086 //////////////////////////////////////////////////////////////////// 00087 INLINE void ButtonThrower:: 00088 set_button_repeat_event(const string &button_repeat_event) { 00089 _button_repeat_event = button_repeat_event; 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: ButtonThrower::get_button_repeat_event 00094 // Access: Published 00095 // Description: Returns the button_repeat_event that has been set on 00096 // this ButtonThrower. See set_button_repeat_event(). 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE const string &ButtonThrower:: 00099 get_button_repeat_event() const { 00100 return _button_repeat_event; 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: ButtonThrower::set_keystroke_event 00105 // Access: Published 00106 // Description: Specifies the event that is generated (if any) for 00107 // each keystroke that is received. A keystroke is 00108 // different than a button event: it represents the 00109 // semantic meaning of the sequence of keys that have 00110 // been pressed. For instance, pressing shift and 4 00111 // together will generate the button event "shift-4", 00112 // but it will generate the keystroke "$". 00113 // 00114 // If a key is held down, keyrepeat will cause the same 00115 // keystroke event to be generated repeatedly. This is 00116 // different from the corresponding down event, which 00117 // will only be generated once, followed by a number of 00118 // button repeat events. 00119 // 00120 // This event is generated with a single wstring 00121 // parameter, which is a one-character string that 00122 // contains the keystroke generated. If this event 00123 // string is empty, no event is generated. 00124 // 00125 // See also set_button_down_event(). 00126 //////////////////////////////////////////////////////////////////// 00127 INLINE void ButtonThrower:: 00128 set_keystroke_event(const string &keystroke_event) { 00129 _keystroke_event = keystroke_event; 00130 } 00131 00132 //////////////////////////////////////////////////////////////////// 00133 // Function: ButtonThrower::get_keystroke_event 00134 // Access: Published 00135 // Description: Returns the keystroke_event that has been set on this 00136 // ButtonThrower. See set_keystroke_event(). 00137 //////////////////////////////////////////////////////////////////// 00138 INLINE const string &ButtonThrower:: 00139 get_keystroke_event() const { 00140 return _keystroke_event; 00141 } 00142 00143 //////////////////////////////////////////////////////////////////// 00144 // Function: ButtonThrower::set_candidate_event 00145 // Access: Published 00146 // Description: Specifies the event that is generated (if any) for 00147 // each IME candidate string event received. Events of 00148 // this nature are received only when the user is 00149 // entering data using a Microsoft Input Method Editor, 00150 // typically used for Asian languages such as Japanese 00151 // or Korean. 00152 // 00153 // If you are designing a typing user interface, you 00154 // should track this event to support the use of the 00155 // IME. In response to this event, you should display 00156 // the candidate string in the entry box, with the 00157 // appropriate sections highlighted, so the user can 00158 // scroll through the available choices. 00159 // 00160 // This event is generated with four parameters, in 00161 // order: the candidate string, the character at which 00162 // to start the highlight, the character at which to end 00163 // the highlight, and the current cursor position. 00164 //////////////////////////////////////////////////////////////////// 00165 INLINE void ButtonThrower:: 00166 set_candidate_event(const string &candidate_event) { 00167 _candidate_event = candidate_event; 00168 } 00169 00170 //////////////////////////////////////////////////////////////////// 00171 // Function: ButtonThrower::get_candidate_event 00172 // Access: Published 00173 // Description: Returns the candidate_event that has been set on this 00174 // ButtonThrower. See set_candidate_event(). 00175 //////////////////////////////////////////////////////////////////// 00176 INLINE const string &ButtonThrower:: 00177 get_candidate_event() const { 00178 return _candidate_event; 00179 } 00180 00181 //////////////////////////////////////////////////////////////////// 00182 // Function: ButtonThrower::set_move_event 00183 // Access: Published 00184 // Description: Specifies the event that is generated (if any) each 00185 // time the mouse is moved within the window. 00186 //////////////////////////////////////////////////////////////////// 00187 INLINE void ButtonThrower:: 00188 set_move_event(const string &move_event) { 00189 _move_event = move_event; 00190 } 00191 00192 //////////////////////////////////////////////////////////////////// 00193 // Function: ButtonThrower::get_move_event 00194 // Access: Published 00195 // Description: Returns the move_event that has been set on this 00196 // ButtonThrower. See set_move_event(). 00197 //////////////////////////////////////////////////////////////////// 00198 INLINE const string &ButtonThrower:: 00199 get_move_event() const { 00200 return _move_event; 00201 } 00202 00203 //////////////////////////////////////////////////////////////////// 00204 // Function: ButtonThrower::set_prefix 00205 // Access: Published 00206 // Description: Sets the prefix which is prepended to all specific 00207 // event names (that is, event names generated from the 00208 // button name itself, as opposed to the generic event 00209 // names like set_button_down_event) thrown by this 00210 // object. 00211 //////////////////////////////////////////////////////////////////// 00212 INLINE void ButtonThrower:: 00213 set_prefix(const string &prefix) { 00214 _prefix = prefix; 00215 } 00216 00217 //////////////////////////////////////////////////////////////////// 00218 // Function: ButtonThrower::get_prefix 00219 // Access: Published 00220 // Description: Returns the prefix that has been set on this 00221 // ButtonThrower. See set_prefix(). 00222 //////////////////////////////////////////////////////////////////// 00223 INLINE const string &ButtonThrower:: 00224 get_prefix() const { 00225 return _prefix; 00226 } 00227 00228 //////////////////////////////////////////////////////////////////// 00229 // Function: ButtonThrower::set_specific_flag 00230 // Access: Published 00231 // Description: Sets the flag that indicates whether specific events 00232 // (events prefixed by set_prefix, and based on the 00233 // event name) should be generated at all. This is true 00234 // by default, but may be disabled if you are only 00235 // interested in the generic events (for instance, 00236 // events like set_button_down_event). 00237 //////////////////////////////////////////////////////////////////// 00238 INLINE void ButtonThrower:: 00239 set_specific_flag(bool specific_flag) { 00240 _specific_flag = specific_flag; 00241 } 00242 00243 //////////////////////////////////////////////////////////////////// 00244 // Function: ButtonThrower::get_specific_flag 00245 // Access: Published 00246 // Description: Returns the flag that indicates whether specific 00247 // events should be generated. See set_specific_flag(). 00248 //////////////////////////////////////////////////////////////////// 00249 INLINE bool ButtonThrower:: 00250 get_specific_flag() const { 00251 return _specific_flag; 00252 } 00253 00254 //////////////////////////////////////////////////////////////////// 00255 // Function: ButtonThrower::set_time_flag 00256 // Access: Published 00257 // Description: Sets the flag that indicates whether the time of the 00258 // button event should be passed as a parameter or not. 00259 // When this is true, an additional parameter is 00260 // generated on each event (before all the parameters 00261 // named by add_parameter) that consists of a single 00262 // double value, and reflects the time the button was 00263 // pressed or released, as a value from 00264 // ClockObject::get_global_clock(). 00265 //////////////////////////////////////////////////////////////////// 00266 INLINE void ButtonThrower:: 00267 set_time_flag(bool time_flag) { 00268 _time_flag = time_flag; 00269 } 00270 00271 //////////////////////////////////////////////////////////////////// 00272 // Function: ButtonThrower::get_time_flag 00273 // Access: Published 00274 // Description: Returns the flag that indicates whether the time of 00275 // the button event should be passed as a parameter. 00276 //////////////////////////////////////////////////////////////////// 00277 INLINE bool ButtonThrower:: 00278 get_time_flag() const { 00279 return _time_flag; 00280 } 00281 00282 //////////////////////////////////////////////////////////////////// 00283 // Function: ButtonThrower::get_modifier_buttons 00284 // Access: Published 00285 // Description: Returns the set of ModifierButtons that the 00286 // ButtonThrower will consider important enough to 00287 // prepend the event name with. Normally, this set will 00288 // be empty, and the ButtonThrower will therefore ignore 00289 // all ModifierButtons attached to the key events, but 00290 // if one or more buttons have been added to this set, 00291 // and those modifier buttons are set on the button 00292 // event, then the event name will be prepended with the 00293 // names of the modifier buttons. 00294 //////////////////////////////////////////////////////////////////// 00295 INLINE const ModifierButtons &ButtonThrower:: 00296 get_modifier_buttons() const { 00297 return _mods; 00298 } 00299 00300 //////////////////////////////////////////////////////////////////// 00301 // Function: ButtonThrower::set_modifier_buttons 00302 // Access: Published 00303 // Description: Changes the set of ModifierButtons that the 00304 // ButtonThrower will consider important enough to 00305 // prepend the event name with. Normally, this set will 00306 // be empty, and the ButtonThrower will therefore ignore 00307 // all ModifierButtons attached to the key events, but 00308 // if one or more buttons have been added to this set, 00309 // then the event name will be prepended with the names 00310 // of the modifier buttons. 00311 // 00312 // It is recommended that you change this setting by 00313 // first calling get_modifier_buttons(), making 00314 // adjustments, and passing the new value to 00315 // set_modifier_buttons(). This way the current state 00316 // of the modifier buttons will not be lost. 00317 //////////////////////////////////////////////////////////////////// 00318 INLINE void ButtonThrower:: 00319 set_modifier_buttons(const ModifierButtons &mods) { 00320 _mods = mods; 00321 } 00322 00323 //////////////////////////////////////////////////////////////////// 00324 // Function: ButtonThrower::set_throw_buttons_active 00325 // Access: Published 00326 // Description: Sets the flag that indicates whether the 00327 // ButtonThrower will only process events for the 00328 // explicitly named buttons or not. Normally this is 00329 // false, meaning all buttons are processed; set it true 00330 // to indicate that only some buttons should be 00331 // processed. See add_throw_button(). 00332 //////////////////////////////////////////////////////////////////// 00333 INLINE void ButtonThrower:: 00334 set_throw_buttons_active(bool flag) { 00335 _throw_buttons_active = flag; 00336 } 00337 00338 //////////////////////////////////////////////////////////////////// 00339 // Function: ButtonThrower::get_throw_buttons_active 00340 // Access: Published 00341 // Description: Returns the flag that indicates whether the 00342 // ButtonThrower will only process events for the 00343 // explicitly named buttons or not. See 00344 // set_throw_buttons_active(). 00345 //////////////////////////////////////////////////////////////////// 00346 INLINE bool ButtonThrower:: 00347 get_throw_buttons_active() const { 00348 return _throw_buttons_active; 00349 }