buttonEventList.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Filename: buttonEventList.h
  2. // Created by: drose (12Mar02)
  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. #ifndef BUTTONEVENTLIST_H
  15. #define BUTTONEVENTLIST_H
  16. #include "pandabase.h"
  17. #include "buttonEvent.h"
  18. #include "typedReferenceCount.h"
  19. #include "eventParameter.h"
  20. #include "pvector.h"
  21. class ModifierButtons;
  22. class Datagram;
  23. class DatagramIterator;
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : ButtonEventList
  26. // Description : Records a set of button events that happened
  27. // recently. This class is usually used only in the
  28. // data graph, to transmit the recent button presses,
  29. // but it may be used anywhere a list of ButtonEvents
  30. // is desired.
  31. ////////////////////////////////////////////////////////////////////
  32. class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase {
  33. public:
  34. INLINE ButtonEventList();
  35. INLINE ButtonEventList(const ButtonEventList &copy);
  36. INLINE void operator = (const ButtonEventList &copy);
  37. INLINE void add_event(ButtonEvent event);
  38. INLINE int get_num_events() const;
  39. INLINE const ButtonEvent &get_event(int n) const;
  40. INLINE void clear();
  41. void add_events(const ButtonEventList &other);
  42. void update_mods(ModifierButtons &mods) const;
  43. virtual void output(ostream &out) const;
  44. void write(ostream &out, int indent_level = 0) const;
  45. private:
  46. typedef pvector<ButtonEvent> Events;
  47. Events _events;
  48. public:
  49. static void register_with_read_factory();
  50. virtual void write_datagram(BamWriter *manager, Datagram &dg);
  51. protected:
  52. static TypedWritable *make_from_bam(const FactoryParams &params);
  53. public:
  54. void fillin(DatagramIterator &scan, BamReader *manager);
  55. public:
  56. static TypeHandle get_class_type() {
  57. return _type_handle;
  58. }
  59. static void init_type() {
  60. ParamValueBase::init_type();
  61. register_type(_type_handle, "ButtonEventList",
  62. ParamValueBase::get_class_type());
  63. }
  64. virtual TypeHandle get_type() const {
  65. return get_class_type();
  66. }
  67. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  68. private:
  69. static TypeHandle _type_handle;
  70. };
  71. INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) {
  72. buttonlist.output(out);
  73. return out;
  74. }
  75. #include "buttonEventList.I"
  76. #endif