Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/modifierButtons.h

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

Generated on Fri May 2 00:43:40 2003 for Panda by doxygen1.3