00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef BUTTONTHROWER_H
00016 #define BUTTONTHROWER_H
00017
00018 #include "pandabase.h"
00019
00020 #include "dataNode.h"
00021 #include "modifierButtons.h"
00022 #include "buttonEventList.h"
00023 #include "pvector.h"
00024 #include "pmap.h"
00025 #include "eventParameter.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA_TFORM ButtonThrower : public DataNode {
00040 PUBLISHED:
00041 ButtonThrower(const string &name);
00042 ~ButtonThrower();
00043
00044 INLINE void set_button_down_event(const string &button_down_event);
00045 INLINE const string &get_button_down_event() const;
00046 INLINE void set_button_up_event(const string &button_up_event);
00047 INLINE const string &get_button_up_event() const;
00048 INLINE void set_button_repeat_event(const string &button_repeat_event);
00049 INLINE const string &get_button_repeat_event() const;
00050 INLINE void set_keystroke_event(const string &keystroke_event);
00051 INLINE const string &get_keystroke_event() const;
00052 INLINE void set_candidate_event(const string &candidate_event);
00053 INLINE const string &get_candidate_event() const;
00054 INLINE void set_move_event(const string &move_event);
00055 INLINE const string &get_move_event() const;
00056
00057 INLINE void set_prefix(const string &prefix);
00058 INLINE const string &get_prefix() const;
00059 INLINE void set_specific_flag(bool specific_flag);
00060 INLINE bool get_specific_flag() const;
00061
00062 INLINE void set_time_flag(bool time_flag);
00063 INLINE bool get_time_flag() const;
00064
00065
00066 void add_parameter(const EventParameter &obj);
00067 int get_num_parameters() const;
00068 EventParameter get_parameter(int n) const;
00069 MAKE_SEQ(get_parameters, get_num_parameters, get_parameter);
00070
00071 INLINE const ModifierButtons &get_modifier_buttons() const;
00072 INLINE void set_modifier_buttons(const ModifierButtons &mods);
00073
00074 INLINE void set_throw_buttons_active(bool flag);
00075 INLINE bool get_throw_buttons_active() const;
00076
00077 bool add_throw_button(const ModifierButtons &mods, const ButtonHandle &button);
00078 bool remove_throw_button(const ModifierButtons &mods, const ButtonHandle &button);
00079 bool has_throw_button(const ModifierButtons &mods, const ButtonHandle &button) const;
00080 bool has_throw_button(const ButtonHandle &button) const;
00081 void clear_throw_buttons();
00082
00083 public:
00084 virtual void write(ostream &out, int indent_level = 0) const;
00085
00086 private:
00087 void do_specific_event(const string &event_name, double time);
00088 void do_general_event(const ButtonEvent &button_event,
00089 const string &event_name);
00090
00091 private:
00092 string _button_down_event;
00093 string _button_up_event;
00094 string _button_repeat_event;
00095 string _keystroke_event;
00096 string _candidate_event;
00097 string _move_event;
00098 bool _specific_flag;
00099 string _prefix;
00100 bool _time_flag;
00101 ModifierButtons _mods;
00102
00103 typedef pvector<EventParameter> ParameterList;
00104 ParameterList _parameters;
00105
00106 typedef pvector<ModifierButtons> ThrowButtonDef;
00107 typedef pmap<ButtonHandle, ThrowButtonDef> ThrowButtons;
00108 ThrowButtons _throw_buttons;
00109 bool _throw_buttons_active;
00110
00111 protected:
00112
00113 virtual void do_transmit_data(DataGraphTraverser *trav,
00114 const DataNodeTransmit &input,
00115 DataNodeTransmit &output);
00116
00117 private:
00118
00119 int _button_events_input;
00120
00121
00122 int _button_events_output;
00123 PT(ButtonEventList) _button_events;
00124
00125 public:
00126 static TypeHandle get_class_type() {
00127 return _type_handle;
00128 }
00129 static void init_type() {
00130 DataNode::init_type();
00131 register_type(_type_handle, "ButtonThrower",
00132 DataNode::get_class_type());
00133 }
00134 virtual TypeHandle get_type() const {
00135 return get_class_type();
00136 }
00137 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00138
00139 private:
00140 static TypeHandle _type_handle;
00141 };
00142
00143 #include "buttonThrower.I"
00144
00145 #endif