Panda3D
|
00001 // Filename: pgButton.I 00002 // Created by: drose (13Mar02) 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: PGButton::set_notify 00018 // Access: Published 00019 // Description: Sets the object which will be notified when the 00020 // PGButton changes. Set this to NULL to disable 00021 // this effect. The PGButton does not retain 00022 // ownership of the pointer; it is your responsibility 00023 // to ensure that the notify object does not destruct. 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE void PGButton:: 00026 set_notify(PGButtonNotify *notify) { 00027 PGItem::set_notify(notify); 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: PGButton::get_notify 00032 // Access: Published 00033 // Description: Returns the object which will be notified when the 00034 // PGButton changes, if any. Returns NULL if there 00035 // is no such object configured. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE PGButtonNotify *PGButton:: 00038 get_notify() const { 00039 return (PGButtonNotify *)PGItem::get_notify(); 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: PGButton::setup 00044 // Access: Published 00045 // Description: Sets up the button using the indicated NodePath as 00046 // arbitrary geometry. 00047 //////////////////////////////////////////////////////////////////// 00048 INLINE void PGButton:: 00049 setup(const NodePath &ready) { 00050 setup(ready, ready, ready, ready); 00051 } 00052 00053 //////////////////////////////////////////////////////////////////// 00054 // Function: PGButton::setup 00055 // Access: Published 00056 // Description: Sets up the button using the indicated NodePath as 00057 // arbitrary geometry. 00058 //////////////////////////////////////////////////////////////////// 00059 INLINE void PGButton:: 00060 setup(const NodePath &ready, const NodePath &depressed) { 00061 setup(ready, depressed, ready, ready); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: PGButton::setup 00066 // Access: Published 00067 // Description: Sets up the button using the indicated NodePath as 00068 // arbitrary geometry. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE void PGButton:: 00071 setup(const NodePath &ready, const NodePath &depressed, 00072 const NodePath &rollover) { 00073 setup(ready, depressed, rollover, ready); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: PGButton::get_click_prefix 00078 // Access: Published, Static 00079 // Description: Returns the prefix that is used to define the click 00080 // event for all PGButtons. The click event is the 00081 // concatenation of this string followed by get_id(). 00082 //////////////////////////////////////////////////////////////////// 00083 INLINE string PGButton:: 00084 get_click_prefix() { 00085 return "click-"; 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: PGButton::get_click_event 00090 // Access: Published 00091 // Description: Returns the event name that will be thrown when the 00092 // button is clicked normally. 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE string PGButton:: 00095 get_click_event(const ButtonHandle &button) const { 00096 LightReMutexHolder holder(_lock); 00097 return get_click_prefix() + button.get_name() + "-" + get_id(); 00098 } 00099 00100 //////////////////////////////////////////////////////////////////// 00101 // Function: PGButton::is_button_down 00102 // Access: Published 00103 // Description: Returns true if the user is currently holding the 00104 // mouse button down on the button, false otherwise. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE bool PGButton:: 00107 is_button_down() { 00108 LightReMutexHolder holder(_lock); 00109 return _button_down; 00110 }