18set_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);
81set_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();
238set_id(
const std::string &
id) {
240 _region->set_name(
id);
477 return _frame_inv_xform;
483INLINE PN_stdfloat PGItem::
484compute_area(
const LVecBase4 &frame) {
485 return (frame[1] - frame[0]) * (frame[3] - frame[2]);
494compare_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;
506INLINE PGItem::StateDef::
void set_name(const std::string &name)
The mutex name is only defined when compiling in DEBUG_THREADS mode.
Similar to MutexHolder, but for a light reentrant mutex.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Objects that inherit from this class can receive specialized messages when PGItems change in certain ...
This is the base class for all the various kinds of gui widget objects.
void set_notify(PGItemNotify *notify)
Sets the object which will be notified when the PGItem changes.
const LVecBase4 & get_frame() const
Returns the bounding rectangle of the item.
bool get_active() const
Returns whether the PGItem is currently active for mouse events.
static std::string get_press_prefix()
Returns the prefix that is used to define the press event for all PGItems.
void clear_frame()
Removes the bounding rectangle from the item.
static std::string get_focus_out_prefix()
Returns the prefix that is used to define the focus_out event for all PGItems.
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...
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...
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.
static std::string get_within_prefix()
Returns the prefix that is used to define the within event for all PGItems.
int get_suppress_flags() const
This is just an interface to get the suppress flags on the underlying MouseWatcherRegion.
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,...
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_in_prefix()
Returns the prefix that is used to define the focus_in event for all PGItems.
static std::string get_keystroke_prefix()
Returns the prefix that is used to define the keystroke event for all PGItems.
LMatrix4 get_frame_inv_xform() const
Returns the inverse of the frame transform matrix.
bool get_focus() const
Returns whether the PGItem currently has focus for keyboard events.
bool get_background_focus() const
Returns whether background_focus is currently enabled.
PGMouseWatcherRegion * get_region() const
Returns the MouseWatcherRegion associated with this item.
int get_state() const
Returns the "state" of this particular PGItem.
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_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...
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...
const std::string & get_id() const
Returns the unique ID assigned to this PGItem.
void set_suppress_flags(int suppress_flags)
This is just an interface to set the suppress flags on the underlying MouseWatcherRegion.
get_state_def
Returns the Node that is the root of the subgraph that will be drawn when the PGItem is in the indica...
static std::string get_enter_prefix()
Returns the prefix that is used to define the enter event for all PGItems.
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_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...
bool has_notify() const
Returns true if there is an object configured to be notified when the PGItem changes,...
static std::string get_release_prefix()
Returns the prefix that is used to define the release event for all PGItems.
static std::string get_exit_prefix()
Returns the prefix that is used to define the exit event for all PGItems.
bool has_frame() const
Returns true if the item has a bounding rectangle; see set_frame().
static std::string get_without_prefix()
Returns the prefix that is used to define the without event for all PGItems.
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...
void set_id(const std::string &id)
Set 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 std::string get_repeat_prefix()
Returns the prefix that is used to define the repeat event for all PGItems.
std::string get_focus_in_event() const
Returns the event name that will be thrown when the item gets the keyboard focus.
This is a specialization on MouseWatcherRegion, to add a bit more fields that are relevant to the PG ...
set_state
Sets the complete RenderState that will be applied to all nodes at this level and below.
The primary interface to this module.