Panda3D
 All Classes Functions Variables Enumerations
buttonHandle.h
1 // Filename: buttonHandle.h
2 // Created by: drose (01Mar00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BUTTONHANDLE_H
16 #define BUTTONHANDLE_H
17 
18 #include "pandabase.h"
19 #include "typeHandle.h"
20 #include "register_type.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ButtonHandle
24 // Description : A ButtonHandle represents a single button from any
25 // device, including keyboard buttons and mouse buttons
26 // (but see KeyboardButton and MouseButton).
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDA_PUTIL ButtonHandle {
29 PUBLISHED:
30  INLINE ButtonHandle();
31  INLINE ButtonHandle(int index);
32  INLINE ButtonHandle(const ButtonHandle &copy);
33  ButtonHandle(const string &name);
34 
35 PUBLISHED:
36  INLINE bool operator == (const ButtonHandle &other) const;
37  INLINE bool operator != (const ButtonHandle &other) const;
38  INLINE bool operator < (const ButtonHandle &other) const;
39  INLINE bool operator <= (const ButtonHandle &other) const;
40  INLINE bool operator > (const ButtonHandle &other) const;
41  INLINE bool operator >= (const ButtonHandle &other) const;
42  INLINE int compare_to(const ButtonHandle &other) const;
43  INLINE size_t get_hash() const;
44 
45  string get_name() const;
46  INLINE bool has_ascii_equivalent() const;
47  INLINE char get_ascii_equivalent() const;
48 
49  ButtonHandle get_alias() const;
50 
51  INLINE bool matches(const ButtonHandle &other) const;
52 
53  INLINE int get_index() const;
54  INLINE void output(ostream &out) const;
55  INLINE static ButtonHandle none();
56 
57  INLINE operator bool () const;
58 
59 private:
60  int _index;
61  static ButtonHandle _none;
62 
63 public:
64  static TypeHandle get_class_type() {
65  return _type_handle;
66  }
67  static void init_type() {
68  register_type(_type_handle, "ButtonHandle");
69  }
70 
71 private:
72  static TypeHandle _type_handle;
73 
74 friend class ButtonRegistry;
75 };
76 
77 // It's handy to be able to output a ButtonHandle directly, and see the
78 // button name.
79 INLINE ostream &operator << (ostream &out, ButtonHandle button) {
80  button.output(out);
81  return out;
82 }
83 
84 #include "buttonHandle.I"
85 
86 #endif
87 
The ButtonRegistry class maintains all the assigned ButtonHandles in a given system.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:79
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85