Panda3D
 All Classes Functions Variables Enumerations
mouseWatcherRegion.h
1 // Filename: mouseWatcherRegion.h
2 // Created by: drose (13Jul00)
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 
15 #ifndef MOUSEWATCHERREGION_H
16 #define MOUSEWATCHERREGION_H
17 
18 #include "pandabase.h"
19 
20 #include "namable.h"
21 #include "typedWritableReferenceCount.h"
22 #include "luse.h"
23 #include "buttonHandle.h"
24 #include "modifierButtons.h"
25 
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : MouseWatcherRegion
30 // Description : This is the class that defines a rectangular region
31 // on the screen for the MouseWatcher.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDA_TFORM MouseWatcherRegion : public TypedWritableReferenceCount, public Namable {
34 PUBLISHED:
35  INLINE MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right,
36  PN_stdfloat bottom, PN_stdfloat top);
37  INLINE MouseWatcherRegion(const string &name, const LVecBase4 &frame);
38 
39  INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
40  INLINE void set_frame(const LVecBase4 &frame);
41  INLINE const LVecBase4 &get_frame() const;
42  INLINE PN_stdfloat get_area() const;
43 
44  INLINE void set_sort(int sort);
45  INLINE int get_sort() const;
46 
47  INLINE void set_active(bool active);
48  INLINE bool get_active() const;
49 
50  INLINE void set_keyboard(bool keyboard);
51  INLINE bool get_keyboard() const;
52 
53  enum SuppressFlags {
54  SF_mouse_button = 0x001,
55  SF_other_button = 0x002,
56  SF_any_button = 0x003,
57  SF_mouse_position = 0x004,
58  };
59 
60  INLINE void set_suppress_flags(int suppress_flags);
61  INLINE int get_suppress_flags() const;
62 
63  void output(ostream &out) const;
64  void write(ostream &out, int indent_level = 0) const;
65 
66 public:
67  INLINE bool operator < (const MouseWatcherRegion &other) const;
68 
69  virtual void enter_region(const MouseWatcherParameter &param);
70  virtual void exit_region(const MouseWatcherParameter &param);
71  virtual void within_region(const MouseWatcherParameter &param);
72  virtual void without_region(const MouseWatcherParameter &param);
73  virtual void press(const MouseWatcherParameter &param);
74  virtual void release(const MouseWatcherParameter &param);
75  virtual void keystroke(const MouseWatcherParameter &param);
76  virtual void candidate(const MouseWatcherParameter &param);
77  virtual void move(const MouseWatcherParameter &param);
78 
79 private:
80  LVecBase4 _frame;
81  PN_stdfloat _area;
82  int _sort;
83 
84  enum Flags {
85  // F_suppress_flags is the union of all of the SuppressFlags,
86  // above. Presently, we reserve 8 bits for suppress flags.
87  F_suppress_flags = 0x0ff,
88  F_active = 0x100,
89  F_keyboard = 0x200,
90  };
91  int _flags;
92 
93 public:
94  static TypeHandle get_class_type() {
95  return _type_handle;
96  }
97  static void init_type() {
98  TypedWritableReferenceCount::init_type();
99  Namable::init_type();
100  register_type(_type_handle, "MouseWatcherRegion",
101  TypedWritableReferenceCount::get_class_type(),
102  Namable::get_class_type());
103  }
104  virtual TypeHandle get_type() const {
105  return get_class_type();
106  }
107  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
108 
109 private:
110  static TypeHandle _type_handle;
111 };
112 
113 INLINE ostream &operator << (ostream &out, const MouseWatcherRegion &region) {
114  region.output(out);
115  return out;
116 }
117 
118 #include "mouseWatcherRegion.I"
119 
120 #endif
A base class for all things which can have a name.
Definition: namable.h:29
This is the class that defines a rectangular region on the screen for the MouseWatcher.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void output(ostream &out) const
Outputs the Namable.
Definition: namable.I:97
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is sent along as a parameter to most events generated for a region to indicate the mouse and but...