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

panda/src/tform/buttonThrower.h

Go to the documentation of this file.
00001 // Filename: buttonThrower.h
00002 // Created by:  drose (12Mar02)
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 BUTTONTHROWER_H
00020 #define BUTTONTHROWER_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "dataNode.h"
00025 #include "modifierButtons.h"
00026 #include "buttonEventList.h"
00027 #include "pvector.h"
00028 #include "pmap.h"
00029 #include "eventParameter.h"
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //       Class : ButtonThrower
00033 // Description : Throws Panda Events for button down/up events
00034 //               generated within the data graph.
00035 //
00036 //               This is a DataNode which is intended to be parented
00037 //               to the data graph below a device which is generating
00038 //               a sequence of button events, like a MouseAndKeyboard
00039 //               device.  It simply takes each button it finds and
00040 //               throws a corresponding event based on the button name
00041 //               via the throw_event() call.
00042 ////////////////////////////////////////////////////////////////////
00043 class EXPCL_PANDA ButtonThrower : public DataNode {
00044 PUBLISHED:
00045   ButtonThrower(const string &name);
00046   ~ButtonThrower();
00047 
00048   void set_prefix(const string &prefix);
00049   bool has_prefix() const;
00050   string get_prefix() const;
00051 
00052   void add_parameter(const EventParameter &obj);
00053   int get_num_parameters() const;
00054   EventParameter get_parameter(int n) const;
00055 
00056   const ModifierButtons &get_modifier_buttons() const;
00057   void set_modifier_buttons(const ModifierButtons &mods);
00058 
00059   void set_throw_buttons_active(bool flag);
00060   bool get_throw_buttons_active() const;
00061 
00062   bool add_throw_button(const ModifierButtons &mods, const ButtonHandle &button);
00063   bool remove_throw_button(const ModifierButtons &mods, const ButtonHandle &button);
00064   bool has_throw_button(const ModifierButtons &mods, const ButtonHandle &button) const;
00065   bool has_throw_button(const ButtonHandle &button) const;
00066   void clear_throw_buttons();
00067 
00068 public:
00069   virtual void write(ostream &out, int indent_level = 0) const;
00070 
00071 private:
00072   void do_throw_event(const string &event_name);
00073 
00074 private:
00075   string _prefix;
00076   ModifierButtons _mods;
00077 
00078   typedef pvector<EventParameter> ParameterList;
00079   ParameterList _parameters;
00080 
00081   typedef pvector<ModifierButtons> ThrowButtonDef;
00082   typedef pmap<ButtonHandle, ThrowButtonDef> ThrowButtons;
00083   ThrowButtons _throw_buttons;
00084   bool _throw_buttons_active;
00085 
00086 protected:
00087   // Inherited from DataNode
00088   virtual void do_transmit_data(const DataNodeTransmit &input,
00089                                 DataNodeTransmit &output);
00090 
00091 private:
00092   // inputs
00093   int _button_events_input;
00094 
00095   // outputs
00096   int _button_events_output;
00097   PT(ButtonEventList) _button_events;
00098 
00099 public:
00100   static TypeHandle get_class_type() {
00101     return _type_handle;
00102   }
00103   static void init_type() {
00104     DataNode::init_type();
00105     register_type(_type_handle, "ButtonThrower",
00106                   DataNode::get_class_type());
00107   }
00108   virtual TypeHandle get_type() const {
00109     return get_class_type();
00110   }
00111   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00112 
00113 private:
00114   static TypeHandle _type_handle;
00115 };
00116 
00117 #endif

Generated on Fri May 2 00:44:24 2003 for Panda by doxygen1.3