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

panda/src/display/graphicsWindowInputDevice.h

Go to the documentation of this file.
00001 // Filename: graphicsWindowInputDevice.h
00002 // Created by:  drose (24May00)
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 GRAPHICSWINDOWINPUTDEVICE_H
00020 #define GRAPHICSWINDOWINPUTDEVICE_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "buttonEvent.h"
00025 #include "mouseData.h"
00026 
00027 #include "pdeque.h"
00028 #include "pvector.h"
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : GraphicsWindowInputDevice
00032 // Description : This is a structure representing a single input
00033 //               device that may be associated with a window.
00034 //               Typically this will be a keyboard/mouse pair, and
00035 //               there will be exactly one of these associated with
00036 //               each window, but other variants are possible.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA GraphicsWindowInputDevice {
00039 private:
00040   GraphicsWindowInputDevice(const string &name, int flags);
00041 
00042 public:
00043   static GraphicsWindowInputDevice pointer_only(const string &name);
00044   static GraphicsWindowInputDevice keyboard_only(const string &name);
00045   static GraphicsWindowInputDevice pointer_and_keyboard(const string &name);
00046 
00047   INLINE GraphicsWindowInputDevice();
00048   GraphicsWindowInputDevice(const GraphicsWindowInputDevice &copy);
00049   void operator = (const GraphicsWindowInputDevice &copy);
00050   ~GraphicsWindowInputDevice();
00051 
00052   INLINE string get_name() const;
00053   INLINE bool has_pointer() const;
00054   INLINE bool has_keyboard() const;
00055 
00056   INLINE const MouseData &get_mouse_data() const;
00057 
00058   bool has_button_event() const;
00059   ButtonEvent get_button_event();
00060 
00061 public:
00062   // The following interface is for the various kinds of
00063   // GraphicsWindows to record the data incoming on the device.
00064   void button_down(ButtonHandle button);
00065   void button_resume_down(ButtonHandle button);
00066   void button_up(ButtonHandle button);
00067   void keystroke(int keycode);
00068   INLINE void set_pointer_in_window(int x, int y);
00069   INLINE void set_pointer_out_of_window();
00070 
00071 public:
00072   // We need these methods to make VC++ happy when we try to
00073   // instantiate a pvector<GraphicsWindowInputDevice>.  They don't do
00074   // anything useful.
00075   INLINE bool operator == (const GraphicsWindowInputDevice &other) const;
00076   INLINE bool operator != (const GraphicsWindowInputDevice &other) const;
00077   INLINE bool operator < (const GraphicsWindowInputDevice &other) const;
00078 
00079 private:
00080   enum InputDeviceFlags {
00081     IDF_has_pointer    = 0x01,
00082     IDF_has_keyboard   = 0x02
00083   };
00084   typedef pdeque<ButtonEvent> ButtonEvents;
00085 
00086   string _name;
00087   int _flags;
00088   MouseData _mouse_data;
00089   ButtonEvents _button_events;
00090 };
00091 
00092 #include "graphicsWindowInputDevice.I"
00093 
00094 #define EXPCL EXPCL_PANDA
00095 #define EXPTP EXPTP_PANDA
00096 #define TYPE GraphicsWindowInputDevice
00097 #define NAME vector_GraphicsWindowInputDevice
00098 
00099 #include <vector_src.h>
00100 
00101 // Tell GCC that we'll take care of the instantiation explicitly here.
00102 #ifdef __GNUC__
00103 #pragma interface
00104 #endif
00105 
00106 #endif

Generated on Fri May 2 00:36:34 2003 for Panda by doxygen1.3