Panda3D
mouseWatcherRegion.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file mouseWatcherRegion.h
10  * @author drose
11  * @date 2000-07-13
12  */
13 
14 #ifndef MOUSEWATCHERREGION_H
15 #define MOUSEWATCHERREGION_H
16 
17 #include "pandabase.h"
18 
19 #include "namable.h"
21 #include "luse.h"
22 #include "buttonHandle.h"
23 #include "modifierButtons.h"
24 
26 
27 /**
28  * This is the class that defines a rectangular region on the screen for the
29  * MouseWatcher.
30  */
31 class EXPCL_PANDA_TFORM MouseWatcherRegion : public TypedWritableReferenceCount, public Namable {
32 PUBLISHED:
33  INLINE explicit MouseWatcherRegion(const std::string &name, PN_stdfloat left, PN_stdfloat right,
34  PN_stdfloat bottom, PN_stdfloat top);
35  INLINE explicit MouseWatcherRegion(const std::string &name, const LVecBase4 &frame);
36 
37  INLINE void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
38  INLINE void set_frame(const LVecBase4 &frame);
39  INLINE const LVecBase4 &get_frame() const;
40  INLINE PN_stdfloat get_area() const;
41 
42  INLINE void set_sort(int sort);
43  INLINE int get_sort() const;
44 
45  INLINE void set_active(bool active);
46  INLINE bool get_active() const;
47 
48  INLINE void set_keyboard(bool keyboard);
49  INLINE bool get_keyboard() const;
50 
51  enum SuppressFlags {
52  SF_mouse_button = 0x001,
53  SF_other_button = 0x002,
54  SF_any_button = 0x003,
55  SF_mouse_position = 0x004,
56  };
57 
58  INLINE void set_suppress_flags(int suppress_flags);
59  INLINE int get_suppress_flags() const;
60 
61  void output(std::ostream &out) const;
62  void write(std::ostream &out, int indent_level = 0) const;
63 
64 PUBLISHED:
65  MAKE_PROPERTY(frame, get_frame, set_frame);
66  MAKE_PROPERTY(area, get_area);
67 
68  MAKE_PROPERTY(sort, get_sort, set_sort);
69  MAKE_PROPERTY(active, get_active, set_active);
70  MAKE_PROPERTY(keyboard, get_keyboard, set_keyboard);
71  MAKE_PROPERTY(suppress_flags, get_suppress_flags, set_suppress_flags);
72 
73 public:
74  INLINE bool operator < (const MouseWatcherRegion &other) const;
75 
76  virtual void enter_region(const MouseWatcherParameter &param);
77  virtual void exit_region(const MouseWatcherParameter &param);
78  virtual void within_region(const MouseWatcherParameter &param);
79  virtual void without_region(const MouseWatcherParameter &param);
80  virtual void press(const MouseWatcherParameter &param);
81  virtual void release(const MouseWatcherParameter &param);
82  virtual void keystroke(const MouseWatcherParameter &param);
83  virtual void candidate(const MouseWatcherParameter &param);
84  virtual void move(const MouseWatcherParameter &param);
85 
86 private:
87  LVecBase4 _frame;
88  PN_stdfloat _area;
89  int _sort;
90 
91  enum Flags {
92  // F_suppress_flags is the union of all of the SuppressFlags, above.
93  // Presently, we reserve 8 bits for suppress flags.
94  F_suppress_flags = 0x0ff,
95  F_active = 0x100,
96  F_keyboard = 0x200,
97  };
98  int _flags;
99 
100 public:
101  static TypeHandle get_class_type() {
102  return _type_handle;
103  }
104  static void init_type() {
105  TypedWritableReferenceCount::init_type();
106  Namable::init_type();
107  register_type(_type_handle, "MouseWatcherRegion",
108  TypedWritableReferenceCount::get_class_type(),
109  Namable::get_class_type());
110  }
111  virtual TypeHandle get_type() const {
112  return get_class_type();
113  }
114  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
115 
116 private:
117  static TypeHandle _type_handle;
118 };
119 
120 INLINE std::ostream &operator << (std::ostream &out, const MouseWatcherRegion &region) {
121  region.output(out);
122  return out;
123 }
124 
125 #include "mouseWatcherRegion.I"
126 
127 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is sent along as a parameter to most events generated for a region to indicate the mouse and but...
This is the class that defines a rectangular region on the screen for the MouseWatcher.
A base class for all things which can have a name.
Definition: namable.h:26
void output(std::ostream &out) const
Outputs the Namable.
Definition: namable.I:61
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.