18 set_name(
const std::string &name) {
19 Namable::set_name(name);
45 if (_notify !=
nullptr) {
46 _notify->remove_item(
this);
49 if (_notify !=
nullptr) {
50 _notify->add_item(
this);
61 return (_notify !=
nullptr);
81 set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) {
82 set_frame(LVecBase4(left, right, bottom, top));
94 if (!_has_frame || _frame != frame) {
162 return (_flags & F_active) != 0;
172 return (_flags & F_focus) != 0;
182 return (_flags & F_background_focus) != 0;
192 _region->set_suppress_flags(suppress_flags);
202 return _region->get_suppress_flags();
215 return do_get_state_def(state);
226 return _region->get_name();
240 _region->set_name(
id);
477 return _frame_inv_xform;
483 INLINE PN_stdfloat PGItem::
484 compute_area(
const LVecBase4 &frame) {
485 return (frame[1] - frame[0]) * (frame[3] - frame[2]);
494 compare_largest(
const LVecBase4 *&largest, PN_stdfloat &largest_area,
495 const LVecBase4 *new_frame) {
496 PN_stdfloat new_area = compute_area(*new_frame);
497 if (new_area > largest_area) {
499 largest_area = new_area;
506 INLINE PGItem::StateDef::
bool get_background_focus() const
Returns whether background_focus is currently enabled.
static std::string get_repeat_prefix()
Returns the prefix that is used to define the repeat event for all PGItems.
This is the base class for all the various kinds of gui widget objects.
int get_state() const
Returns the "state" of this particular PGItem.
bool get_active() const
Returns whether the PGItem is currently active for mouse events.
std::string get_focus_in_event() const
Returns the event name that will be thrown when the item gets the keyboard focus.
static std::string get_enter_prefix()
Returns the prefix that is used to define the enter event for all PGItems.
void clear_frame()
Removes the bounding rectangle from the item.
void set_id(const std::string &id)
Set the unique ID assigned to this PGItem.
static std::string get_exit_prefix()
Returns the prefix that is used to define the exit event for all PGItems.
void set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top)
Sets the bounding rectangle of the item, in local coordinates.
static std::string get_focus_out_prefix()
Returns the prefix that is used to define the focus_out event for all PGItems.
const std::string & get_id() const
Returns the unique ID assigned to this PGItem.
std::string get_enter_event() const
Returns the event name that will be thrown when the item is active and the mouse enters its frame,...
static PGItem * get_focus_item()
Returns the one PGItem in the world that currently has keyboard focus, if any, or NULL if no item has...
std::string get_press_event(const ButtonHandle &button) const
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboar...
int get_suppress_flags() const
This is just an interface to get the suppress flags on the underlying MouseWatcherRegion.
PGMouseWatcherRegion * get_region() const
Returns the MouseWatcherRegion associated with this item.
std::string get_exit_event() const
Returns the event name that will be thrown when the item is active and the mouse exits its frame,...
bool has_notify() const
Returns true if there is an object configured to be notified when the PGItem changes,...
static std::string get_keystroke_prefix()
Returns the prefix that is used to define the keystroke event for all PGItems.
static void set_text_node(TextNode *node)
Changes the TextNode object that will be used by all PGItems to generate default labels given a strin...
std::string get_keystroke_event() const
Returns the event name that will be thrown when the item is active and any key is pressed by the user...
static std::string get_press_prefix()
Returns the prefix that is used to define the press event for all PGItems.
LMatrix4 get_frame_inv_xform() const
Returns the inverse of the frame transform matrix.
std::string get_focus_out_event() const
Returns the event name that will be thrown when the item loses the keyboard focus.
PGItemNotify * get_notify() const
Returns the object which will be notified when the PGItem changes, if any.
This is a specialization on MouseWatcherRegion, to add a bit more fields that are relevant to the PG ...
static std::string get_focus_in_prefix()
Returns the prefix that is used to define the focus_in event for all PGItems.
bool get_focus() const
Returns whether the PGItem currently has focus for keyboard events.
static std::string get_release_prefix()
Returns the prefix that is used to define the release event for all PGItems.
Similar to MutexHolder, but for a light reentrant mutex.
std::string get_repeat_event(const ButtonHandle &button) const
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboar...
void set_state(int state)
Sets the "state" of this particular PGItem.
The primary interface to this module.
bool has_frame() const
Returns true if the item has a bounding rectangle; see set_frame().
Objects that inherit from this class can receive specialized messages when PGItems change in certain ...
static std::string get_within_prefix()
Returns the prefix that is used to define the within event for all PGItems.
const LVecBase4 & get_frame() const
Returns the bounding rectangle of the item.
std::string get_release_event(const ButtonHandle &button) const
Returns the event name that will be thrown when the item is active and the indicated mouse or keyboar...
static std::string get_without_prefix()
Returns the prefix that is used to define the without event for all PGItems.
get_state_def
Returns the Node that is the root of the subgraph that will be drawn when the PGItem is in the indica...
void set_suppress_flags(int suppress_flags)
This is just an interface to set the suppress flags on the underlying MouseWatcherRegion.
std::string get_within_event() const
Returns the event name that will be thrown when the item is active and the mouse moves within the bou...
std::string get_without_event() const
Returns the event name that will be thrown when the item is active and the mouse moves completely out...
void set_name(const std::string &name)
The mutex name is only defined when compiling in DEBUG_THREADS mode.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void set_notify(PGItemNotify *notify)
Sets the object which will be notified when the PGItem changes.