buttonEventDataAttribute.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Filename: buttonEventDataAttribute.h
  2. // Created by: drose (27Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef BUTTONEVENTDATAATTRIBUTE_H
  19. #define BUTTONEVENTDATAATTRIBUTE_H
  20. #include <pandabase.h>
  21. #include <nodeAttribute.h>
  22. #include <buttonEvent.h>
  23. #include "pvector.h"
  24. class ButtonEventDataTransition;
  25. class ModifierButtons;
  26. ////////////////////////////////////////////////////////////////////
  27. // Class : ButtonEventDataAttribute
  28. // Description : This data graph attribute stores a collection of
  29. // button events that have been generated by the user
  30. // since the last time the data graph pulsed, in the
  31. // order they were generated.
  32. ////////////////////////////////////////////////////////////////////
  33. class EXPCL_PANDA ButtonEventDataAttribute : public NodeAttribute {
  34. private:
  35. typedef pvector<ButtonEvent> Buttons;
  36. public:
  37. INLINE ButtonEventDataAttribute();
  38. INLINE ButtonEventDataAttribute(const ButtonEventDataAttribute &copy);
  39. INLINE void operator = (const ButtonEventDataAttribute &copy);
  40. public:
  41. // Functions to access and manipulate the set of buttons.
  42. typedef Buttons::const_iterator const_iterator;
  43. typedef Buttons::const_iterator iterator;
  44. INLINE const_iterator begin() const;
  45. INLINE const_iterator end() const;
  46. INLINE void clear();
  47. INLINE void push_back(const ButtonEvent &event);
  48. void update_mods(ModifierButtons &mods) const;
  49. public:
  50. virtual NodeAttribute *make_copy() const;
  51. virtual NodeAttribute *make_initial() const;
  52. virtual TypeHandle get_handle() const;
  53. virtual NodeAttribute *merge(const NodeAttribute *other) const;
  54. virtual void output(ostream &out) const;
  55. virtual void write(ostream &out, int indent_level = 0) const;
  56. protected:
  57. virtual int internal_compare_to(const NodeAttribute *other) const;
  58. private:
  59. Buttons _buttons;
  60. public:
  61. virtual TypeHandle get_type() const {
  62. return get_class_type();
  63. }
  64. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  65. static TypeHandle get_class_type() {
  66. return _type_handle;
  67. }
  68. static void init_type() {
  69. NodeAttribute::init_type();
  70. register_type(_type_handle, "ButtonEventDataAttribute",
  71. NodeAttribute::get_class_type());
  72. }
  73. private:
  74. static TypeHandle _type_handle;
  75. friend class ButtonEventDataTransition;
  76. };
  77. #include "buttonEventDataAttribute.I"
  78. #endif