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

panda/src/tform/mouseWatcherRegion.h

Go to the documentation of this file.
00001 // Filename: mouseWatcherRegion.h
00002 // Created by:  drose (13Jul00)
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 MOUSEWATCHERREGION_H
00020 #define MOUSEWATCHERREGION_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "namable.h"
00025 #include "typedReferenceCount.h"
00026 #include "luse.h"
00027 #include "buttonHandle.h"
00028 #include "modifierButtons.h"
00029 
00030 class MouseWatcherParameter;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : MouseWatcherRegion
00034 // Description : This is the class that defines a rectangular region
00035 //               on the screen for the MouseWatcher.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA MouseWatcherRegion : public TypedReferenceCount, public Namable {
00038 PUBLISHED:
00039   INLINE MouseWatcherRegion(const string &name, float left, float right,
00040                             float bottom, float top);
00041   INLINE MouseWatcherRegion(const string &name, const LVecBase4f &frame);
00042 
00043   INLINE void set_frame(float left, float right, float bottom, float top);
00044   INLINE void set_frame(const LVecBase4f &frame);
00045   INLINE const LVecBase4f &get_frame() const;
00046   INLINE float get_area() const;
00047 
00048   INLINE void set_sort(int sort);
00049   INLINE int get_sort() const;
00050 
00051   INLINE void set_active(bool active);
00052   INLINE bool get_active() const;
00053 
00054   INLINE void set_keyboard(bool keyboard);
00055   INLINE bool get_keyboard() const;
00056 
00057   enum SuppressFlags {
00058     SF_mouse_button       = 0x001,
00059     SF_other_button       = 0x002,
00060     SF_any_button         = 0x003,
00061     SF_mouse_position     = 0x004,
00062   };
00063 
00064   INLINE void set_suppress_flags(int suppress_flags);
00065   INLINE int get_suppress_flags() const;
00066 
00067   void output(ostream &out) const;
00068   void write(ostream &out, int indent_level = 0) const;
00069 
00070 public:
00071   INLINE bool operator < (const MouseWatcherRegion &other) const;
00072 
00073   virtual void enter(const MouseWatcherParameter &param);
00074   virtual void exit(const MouseWatcherParameter &param);
00075   virtual void within(const MouseWatcherParameter &param);
00076   virtual void without(const MouseWatcherParameter &param);
00077   virtual void press(const MouseWatcherParameter &param);
00078   virtual void release(const MouseWatcherParameter &param);
00079   virtual void keystroke(const MouseWatcherParameter &param);
00080 
00081 private:
00082   LVecBase4f _frame;
00083   float _area;
00084   int _sort;
00085 
00086   enum Flags {
00087     // F_suppress_flags is the union of all of the SuppressFlags,
00088     // above.  Presently, we reserve 8 bits for suppress flags.
00089     F_suppress_flags = 0x0ff,
00090     F_active         = 0x100,
00091     F_keyboard       = 0x200,
00092   };
00093   int _flags;
00094   ModifierButtons _mods;
00095 
00096 public:
00097   static TypeHandle get_class_type() {
00098     return _type_handle;
00099   }
00100   static void init_type() {
00101     TypedReferenceCount::init_type();
00102     Namable::init_type();
00103     register_type(_type_handle, "MouseWatcherRegion",
00104                   TypedReferenceCount::get_class_type(),
00105                   Namable::get_class_type());
00106   }
00107   virtual TypeHandle get_type() const {
00108     return get_class_type();
00109   }
00110   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00111 
00112 private:
00113   static TypeHandle _type_handle;
00114 };
00115 
00116 INLINE ostream &operator << (ostream &out, const MouseWatcherRegion &region) {
00117   region.output(out);
00118   return out;
00119 }
00120 
00121 #include "mouseWatcherRegion.I"
00122 
00123 #endif

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