00001 // Filename: buttonHandle.I 00002 // Created by: drose (01Mar00) 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: ButtonHandle::Constructor 00022 // Access: Published 00023 // Description: The default constructor must do nothing, because we 00024 // can't guarantee ordering of static initializers. If 00025 // the constructor tried to initialize its value, it 00026 // might happen after the value had already been set 00027 // previously by another static initializer! 00028 //////////////////////////////////////////////////////////////////// 00029 INLINE ButtonHandle:: 00030 ButtonHandle() { 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function: ButtonHandle::Copy Constructor 00035 // Access: Published 00036 // Description: 00037 //////////////////////////////////////////////////////////////////// 00038 INLINE ButtonHandle:: 00039 ButtonHandle(const ButtonHandle ©) : _index(copy._index) { 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: ButtonHandle::Equality Operator 00044 // Access: Published 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 INLINE bool ButtonHandle:: 00048 operator == (const ButtonHandle &other) const { 00049 return (_index == other._index); 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: ButtonHandle::Inequality Operator 00054 // Access: Published 00055 // Description: 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE bool ButtonHandle:: 00058 operator != (const ButtonHandle &other) const { 00059 return (_index != other._index); 00060 } 00061 00062 //////////////////////////////////////////////////////////////////// 00063 // Function: ButtonHandle::Ordering Operator 00064 // Access: Published 00065 // Description: 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE bool ButtonHandle:: 00068 operator < (const ButtonHandle &other) const { 00069 return (_index < other._index); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: ButtonHandle::has_ascii_equivalent 00074 // Access: Published 00075 // Description: Returns true if the button was created with an ASCII 00076 // equivalent code (e.g. for a standard keyboard 00077 // button). 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE bool ButtonHandle:: 00080 has_ascii_equivalent() const { 00081 return (_index > 0 && _index < 128); 00082 } 00083 00084 //////////////////////////////////////////////////////////////////// 00085 // Function: ButtonHandle::get_ascii_equivalent 00086 // Access: Published 00087 // Description: Returns the character code associated with the 00088 // button, or '\0' if no ASCII code was associated. 00089 //////////////////////////////////////////////////////////////////// 00090 INLINE char ButtonHandle:: 00091 get_ascii_equivalent() const { 00092 return has_ascii_equivalent() ? (char)_index : '\0'; 00093 } 00094 00095 //////////////////////////////////////////////////////////////////// 00096 // Function: ButtonHandle::get_index 00097 // Access: Published 00098 // Description: Returns the integer index associated with this 00099 // ButtonHandle. Each different ButtonHandle will have a 00100 // different index. However, you probably shouldn't be 00101 // using this method; you should just treat the 00102 // ButtonHandles as opaque classes. This is provided 00103 // for the convenience of non-C++ scripting languages to 00104 // build a hashtable of ButtonHandles. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE int ButtonHandle:: 00107 get_index() const { 00108 return _index; 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: ButtonHandle::output 00113 // Access: Published 00114 // Description: 00115 //////////////////////////////////////////////////////////////////// 00116 INLINE void ButtonHandle:: 00117 output(ostream &out) const { 00118 out << get_name(); 00119 } 00120 00121 //////////////////////////////////////////////////////////////////// 00122 // Function: ButtonHandle::none 00123 // Access: Published, Static 00124 // Description: Returns a special zero-valued ButtonHandle that is 00125 // used to indicate no button. 00126 //////////////////////////////////////////////////////////////////// 00127 INLINE ButtonHandle ButtonHandle:: 00128 none() { 00129 return _none; 00130 }