Panda3D
|
00001 // Filename: modifierButtons.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 MODIFIERBUTTONS_H 00016 #define MODIFIERBUTTONS_H 00017 00018 #include "pandabase.h" 00019 00020 #include "buttonHandle.h" 00021 #include "pointerToArray.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : ModifierButtons 00025 // Description : This class monitors the state of a number of 00026 // individual buttons and tracks whether each button is 00027 // known to be down or up. 00028 //////////////////////////////////////////////////////////////////// 00029 class EXPCL_PANDA_PUTIL ModifierButtons { 00030 PUBLISHED: 00031 ModifierButtons(); 00032 ModifierButtons(const ModifierButtons ©); 00033 ~ModifierButtons(); 00034 INLINE void operator = (const ModifierButtons ©); 00035 00036 INLINE bool operator == (const ModifierButtons &other) const; 00037 INLINE bool operator != (const ModifierButtons &other) const; 00038 INLINE bool operator < (const ModifierButtons &other) const; 00039 00040 INLINE ModifierButtons operator & (const ModifierButtons &other) const; 00041 INLINE ModifierButtons operator | (const ModifierButtons &other) const; 00042 00043 void operator &= (const ModifierButtons &other); 00044 void operator |= (const ModifierButtons &other); 00045 00046 void set_button_list(const ModifierButtons &other); 00047 00048 bool matches(const ModifierButtons &other) const; 00049 00050 bool add_button(ButtonHandle button); 00051 bool has_button(ButtonHandle button) const; 00052 bool remove_button(ButtonHandle button); 00053 00054 INLINE int get_num_buttons() const; 00055 INLINE ButtonHandle get_button(int index) const; 00056 MAKE_SEQ(get_buttons, get_num_buttons, get_button); 00057 00058 bool button_down(ButtonHandle button); 00059 bool button_up(ButtonHandle button); 00060 INLINE void all_buttons_up(); 00061 00062 bool is_down(ButtonHandle button) const; 00063 INLINE bool is_down(int index) const; 00064 INLINE bool is_any_down() const; 00065 00066 string get_prefix() const; 00067 00068 void output(ostream &out) const; 00069 void write(ostream &out) const; 00070 00071 private: 00072 void modify_button_list(); 00073 00074 PTA(ButtonHandle) _button_list; 00075 typedef unsigned long BitmaskType; 00076 BitmaskType _state; 00077 }; 00078 00079 INLINE ostream &operator << (ostream &out, const ModifierButtons &mb) { 00080 mb.output(out); 00081 return out; 00082 } 00083 00084 #include "modifierButtons.I" 00085 00086 #endif 00087