Panda3D
pgMouseWatcherRegion.cxx
1 // Filename: pgMouseWatcherRegion.cxx
2 // Created by: drose (02Jul01)
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 #include "pgMouseWatcherRegion.h"
16 #include "pgItem.h"
17 
18 #include "string_utils.h"
19 
20 int PGMouseWatcherRegion::_next_index = 0;
21 TypeHandle PGMouseWatcherRegion::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: PGMouseWatcherRegion::Constructor
25 // Access: Public
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 PGMouseWatcherRegion::
29 PGMouseWatcherRegion(PGItem *item) :
30 #ifndef CPPPARSER
31  MouseWatcherRegion("pg" + format_string(_next_index++), 0, 0, 0, 0),
32 #endif
33  _item(item)
34 {
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: PGMouseWatcherRegion::Destructor
39 // Access: Public, Virtual
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 PGMouseWatcherRegion::
43 ~PGMouseWatcherRegion() {
44 }
45 
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: PGMouseWatcherRegion::enter_region
49 // Access: Public, Virtual
50 // Description: This is a callback hook function, called whenever the
51 // mouse enters the region. The mouse is only
52 // considered to be "entered" in one region at a time;
53 // in the case of nested regions, it exits the outer
54 // region before entering the inner one.
55 ////////////////////////////////////////////////////////////////////
58  if (_item != (PGItem *)NULL) {
59  _item->enter_region(param);
60  }
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: PGMouseWatcherRegion::exit_region
65 // Access: Public, Virtual
66 // Description: This is a callback hook function, called whenever the
67 // mouse exits the region. The mouse is only considered
68 // to be "entered" in one region at a time; in the case
69 // of nested regions, it exits the outer region before
70 // entering the inner one.
71 ////////////////////////////////////////////////////////////////////
74  if (_item != (PGItem *)NULL) {
75  _item->exit_region(param);
76  }
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: PGMouseWatcherRegion::within_region
81 // Access: Public, Virtual
82 // Description: This is a callback hook function, called whenever the
83 // mouse moves within the boundaries of the region, even
84 // if it is also within the boundaries of a nested
85 // region. This is different from "enter", which is
86 // only called whenever the mouse is within only that
87 // region.
88 ////////////////////////////////////////////////////////////////////
91  if (_item != (PGItem *)NULL) {
92  _item->within_region(param);
93  }
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: PGMouseWatcherRegion::without_region
98 // Access: Public, Virtual
99 // Description: This is a callback hook function, called whenever the
100 // mouse moves completely outside the boundaries of the
101 // region. See within_region().
102 ////////////////////////////////////////////////////////////////////
105  if (_item != (PGItem *)NULL) {
106  _item->without_region(param);
107  }
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: PGMouseWatcherRegion::press
112 // Access: Public, Virtual
113 // Description: This is a callback hook function, called whenever a
114 // mouse or keyboard button is depressed while the mouse
115 // is within the region.
116 ////////////////////////////////////////////////////////////////////
119  if (_item != (PGItem *)NULL) {
120  _item->press(param, false);
121  }
122 }
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: PGMouseWatcherRegion::release
126 // Access: Public, Virtual
127 // Description: This is a callback hook function, called whenever a
128 // mouse or keyboard button previously depressed with
129 // press() is released.
130 ////////////////////////////////////////////////////////////////////
133  if (_item != (PGItem *)NULL) {
134  _item->release(param, false);
135  }
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: PGMouseWatcherRegion::keystroke
140 // Access: Public, Virtual
141 // Description: This is a callback hook function, called whenever
142 // the user presses a key.
143 ////////////////////////////////////////////////////////////////////
146  if (_item != (PGItem *)NULL) {
147  _item->keystroke(param, false);
148  }
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: PGMouseWatcherRegion::candidate
153 // Access: Public, Virtual
154 // Description: This is a callback hook function, called whenever
155 // the user selects an option from the IME menu.
156 ////////////////////////////////////////////////////////////////////
159  if (_item != (PGItem *)NULL) {
160  _item->candidate(param, false);
161  }
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: PGMouseWatcherRegion::move
166 // Access: Public, Virtual
167 // Description: This is a callback hook function, called whenever
168 // the user moves the mouse within the region
169 ////////////////////////////////////////////////////////////////////
172  if (_item != (PGItem *)NULL) {
173  _item->move(param);
174  }
175 }
virtual void exit_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse exits the region.
This is the base class for all the various kinds of gui widget objects.
Definition: pgItem.h:58
virtual void move(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the user moves the mouse within the region...
virtual void without_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves completely outside the boundaries o...
Definition: pgItem.cxx:623
virtual void enter_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse enters the region.
Definition: pgItem.cxx:541
virtual void within_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves within the boundaries of the region...
virtual void keystroke(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the user presses a key.
virtual void release(const MouseWatcherParameter &param)
This is a callback hook function, called whenever a mouse or keyboard button previously depressed wit...
virtual void release(const MouseWatcherParameter &param, bool background)
This is a callback hook function, called whenever a mouse or keyboard button previously depressed wit...
Definition: pgItem.cxx:726
This is the class that defines a rectangular region on the screen for the MouseWatcher.
virtual void without_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves completely outside the boundaries o...
virtual void within_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse moves within the boundaries of the region...
Definition: pgItem.cxx:598
virtual void candidate(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the user selects an option from the IME menu...
virtual void move(const MouseWatcherParameter &param)
This is a callback hook function, called whenever a mouse is moved while within the region...
Definition: pgItem.cxx:800
virtual void enter_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse enters the region.
virtual void candidate(const MouseWatcherParameter &param, bool background)
This is a callback hook function, called whenever the user highlights an option in the IME window...
Definition: pgItem.cxx:778
virtual void keystroke(const MouseWatcherParameter &param, bool background)
This is a callback hook function, called whenever the user presses a key.
Definition: pgItem.cxx:752
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...
virtual void exit_region(const MouseWatcherParameter &param)
This is a callback hook function, called whenever the mouse exits the region.
Definition: pgItem.cxx:568
virtual void press(const MouseWatcherParameter &param)
This is a callback hook function, called whenever a mouse or keyboard button is depressed while the m...
virtual void press(const MouseWatcherParameter &param, bool background)
This is a callback hook function, called whenever a mouse or keyboard button is depressed while the m...
Definition: pgItem.cxx:694