Panda3D
|
00001 // Filename: buttonHandle.h 00002 // Created by: drose (01Mar00) 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 #ifndef BUTTONHANDLE_H 00016 #define BUTTONHANDLE_H 00017 00018 #include "pandabase.h" 00019 #include "typeHandle.h" 00020 #include "register_type.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : ButtonHandle 00024 // Description : A ButtonHandle represents a single button from any 00025 // device, including keyboard buttons and mouse buttons 00026 // (but see KeyboardButton and MouseButton). 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDA_PUTIL ButtonHandle { 00029 PUBLISHED: 00030 INLINE ButtonHandle(); 00031 INLINE ButtonHandle(int index); 00032 00033 public: 00034 INLINE ButtonHandle(const ButtonHandle ©); 00035 00036 INLINE bool operator == (const ButtonHandle &other) const; 00037 INLINE bool operator != (const ButtonHandle &other) const; 00038 INLINE bool operator < (const ButtonHandle &other) const; 00039 00040 PUBLISHED: 00041 string get_name() const; 00042 INLINE bool has_ascii_equivalent() const; 00043 INLINE char get_ascii_equivalent() const; 00044 00045 ButtonHandle get_alias() const; 00046 00047 INLINE bool matches(const ButtonHandle &other) const; 00048 00049 INLINE int get_index() const; 00050 INLINE void output(ostream &out) const; 00051 INLINE static ButtonHandle none(); 00052 00053 private: 00054 int _index; 00055 static ButtonHandle _none; 00056 00057 public: 00058 static TypeHandle get_class_type() { 00059 return _type_handle; 00060 } 00061 static void init_type() { 00062 register_type(_type_handle, "ButtonHandle"); 00063 } 00064 00065 private: 00066 static TypeHandle _type_handle; 00067 00068 friend class ButtonRegistry; 00069 }; 00070 00071 // It's handy to be able to output a ButtonHandle directly, and see the 00072 // button name. 00073 INLINE ostream &operator << (ostream &out, ButtonHandle button) { 00074 button.output(out); 00075 return out; 00076 } 00077 00078 #include "buttonHandle.I" 00079 00080 #endif 00081