Panda3D

- Main Page
- Packages
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions

# PGItem Class Reference

This is the base class for all the various kinds of gui widget objects. More...

Inheritance diagram for PGItem:

List of all members.

## Public Member Functions
| PGItem (string name)
| clearFrame ()
| Removes the bounding rectangle from the item.
| clearSound (string event)
| Removes the sound associated with the indicated event.
| clearStateDef (int state)
| Resets the NodePath assigned to the indicated state to its initial default, with only a frame representation if appropriate.
bool | getActive ()
| Returns whether the PGItem is currently active for mouse events.
bool | getBackgroundFocus ()
| Returns whether background_focus is currently enabled.
string | getEnterEvent ()
| Returns the event name that will be thrown when the item is active and the mouse enters its frame, but not any nested frames.
string | getExitEvent ()
| Returns the event name that will be thrown when the item is active and the mouse exits its frame, or enters a nested frame.
bool | getFocus ()
| Returns whether the PGItem currently has focus for keyboard events.
string | getFocusInEvent ()
| Returns the event name that will be thrown when the item gets the keyboard focus.
string | getFocusOutEvent ()
| Returns the event name that will be thrown when the item loses the keyboard focus.
VBase4 const | getFrame ()
| Returns the bounding rectangle of the item.
Mat4 | getFrameInvXform ()
| Returns the inverse of the frame transform matrix.
PGFrameStyle | getFrameStyle (int state)
| Returns the kind of frame that will be drawn behind the item when it is in the indicated state.
string | getId ()
| Returns the unique ID assigned to this PGItem.
string | getKeystrokeEvent ()
| Returns the event name that will be thrown when the item is active and any key is pressed by the user.
int | getNumStateDefs ()
| Returns one more than the highest-numbered state def that was ever assigned to the PGItem.
string | getPressEvent (ButtonHandle const button)
| Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is depressed while the mouse is within the frame.
string | getReleaseEvent (ButtonHandle const button)
| Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button, formerly clicked down is within the frame, is released.
string | getRepeatEvent (ButtonHandle const button)
| Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is continuously held down while the mouse is within the frame.
AudioSound | getSound (string event)
| Returns the sound associated with the indicated event, or NULL if there is no associated sound.
int | getState ()
| Returns the "state" of this particular PGItem.
NodePath | getStateDef (int state)
| Returns the Node that is the root of the subgraph that will be drawn when the PGItem is in the indicated state.
list | getStateDefs ()
int | getSuppressFlags ()
| This is just an interface to get the suppress flags on the underlying MouseWatcherRegion.
string | getWithinEvent ()
| Returns the event name that will be thrown when the item is active and the mouse moves within the boundaries of the frame.
string | getWithoutEvent ()
| Returns the event name that will be thrown when the item is active and the mouse moves completely outside the boundaries of the frame.
bool | hasFrame ()
| Returns true if the item has a bounding rectangle; see set_frame().
bool | hasSound (string event)
| Returns true if there is a sound associated with the indicated event, or false otherwise.
bool | hasStateDef (int state)
| Returns true if get_state_def() has ever been called for the indicated state (thus defining a render subgraph for this state index), false otherwise.
NodePath | instanceToStateDef (int state, NodePath const path)
| Parents an instance of the bottom node of the indicated NodePath to the indicated state index.
| setActive (bool active)
| Sets whether the PGItem is active for mouse watching.
| setBackgroundFocus (bool focus)
| Sets the background_focus flag for this item.
| setFocus (bool focus)
| Sets whether the PGItem currently has keyboard focus.
| setFrame (float left, float right, float bottom, float top)
| Sets the bounding rectangle of the item, in local coordinates.
| setFrame (VBase4 const frame)
| Sets the bounding rectangle of the item, in local coordinates.
| setFrameStyle (int state, PGFrameStyle const style)
| Changes the kind of frame that will be drawn behind the item when it is in the indicated state.
| setId (string id)
| Set the unique ID assigned to this PGItem.
| setName (string name)
| setSound (string event, AudioSound sound)
| Sets the sound that will be played whenever the indicated event occurs.
| setState (int state)
| Sets the "state" of this particular PGItem.
| setSuppressFlags (int suppress_flags)
| This is just an interface to set the suppress flags on the underlying MouseWatcherRegion.
## Static Public Member Functions
static TypeHandle | getClassType ()
static string | getEnterPrefix ()
| Returns the prefix that is used to define the enter event for all PGItems.
static string | getExitPrefix ()
| Returns the prefix that is used to define the exit event for all PGItems.
static string | getFocusInPrefix ()
| Returns the prefix that is used to define the focus_in event for all PGItems.
static PGItem | getFocusItem ()
| Returns the one PGItem in the world that currently has keyboard focus, if any, or NULL if no item has keyboard focus.
static string | getFocusOutPrefix ()
| Returns the prefix that is used to define the focus_out event for all PGItems.
static string | getKeystrokePrefix ()
| Returns the prefix that is used to define the keystroke event for all PGItems.
static string | getPressPrefix ()
| Returns the prefix that is used to define the press event for all PGItems.
static string | getReleasePrefix ()
| Returns the prefix that is used to define the release event for all PGItems.
static string | getRepeatPrefix ()
| Returns the prefix that is used to define the repeat event for all PGItems.
static TextNode | getTextNode ()
| Returns the TextNode object that will be used by all PGItems to generate default labels given a string.
static string | getWithinPrefix ()
| Returns the prefix that is used to define the within event for all PGItems.
static string | getWithoutPrefix ()
| Returns the prefix that is used to define the without event for all PGItems.
static | setTextNode (TextNode node)
| Changes the TextNode object that will be used by all PGItems to generate default labels given a string.

## Detailed Description

This is the base class for all the various kinds of gui widget objects.

It is a Node which corresponds to a rectangular region on the screen, and it may have any number of "state" subgraphs, one of which is rendered at any given time according to its current state.

The PGItem node must be parented to the scene graph somewhere beneath a PGTop node in order for this behavior to work.

## Constructor & Destructor Documentation

PGItem | ( | string | name | ) |

## Member Function Documentation

clearFrame | ( |  | ) |

Removes the bounding rectangle from the item.

It will no longer be possible to position the mouse within the item; see set_frame().

clearSound | ( | string | event | ) |

Removes the sound associated with the indicated event.

clearStateDef | ( | int | state | ) |

Resets the NodePath assigned to the indicated state to its initial default, with only a frame representation if appropriate.

bool getActive | ( |  | ) |

Returns whether the PGItem is currently active for mouse events.

See set_active().

bool getBackgroundFocus | ( |  | ) |

Returns whether background_focus is currently enabled.

See set_background_focus().

static TypeHandle getClassType | ( |  | ) | `[static]`

Reimplemented from PandaNode.

Reimplemented in PGButton, PGEntry, PGVirtualFrame, PGSliderBar, PGScrollFrame, and PGWaitBar.

string getEnterEvent | ( |  | ) |

Returns the event name that will be thrown when the item is active and the mouse enters its frame, but not any nested frames.

static string getEnterPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the enter event for all PGItems.

The enter event is the concatenation of this string followed by get_id().

string getExitEvent | ( |  | ) |

Returns the event name that will be thrown when the item is active and the mouse exits its frame, or enters a nested frame.

static string getExitPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the exit event for all PGItems.

The exit event is the concatenation of this string followed by get_id().

bool getFocus | ( |  | ) |

Returns whether the PGItem currently has focus for keyboard events.

See set_focus().

string getFocusInEvent | ( |  | ) |

Returns the event name that will be thrown when the item gets the keyboard focus.

static string getFocusInPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the focus_in event for all PGItems.

The focus_in event is the concatenation of this string followed by get_id().

Unlike most item events, this event is thrown with no parameters.

static PGItem getFocusItem | ( |  | ) | `[static]`

Returns the one PGItem in the world that currently has keyboard focus, if any, or NULL if no item has keyboard focus.

Use PGItem.set_focus() to activate or deactivate keyboard focus on a particular item.

string getFocusOutEvent | ( |  | ) |

Returns the event name that will be thrown when the item loses the keyboard focus.

static string getFocusOutPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the focus_out event for all PGItems.

The focus_out event is the concatenation of this string followed by get_id().

Unlike most item events, this event is thrown with no parameters.

VBase4 const getFrame | ( |  | ) |

Returns the bounding rectangle of the item.

See set_frame(). It is an error to call this if has_frame() returns false.

Mat4 getFrameInvXform | ( |  | ) |

Returns the inverse of the frame transform matrix.

PGFrameStyle getFrameStyle | ( | int | state | ) |

Returns the kind of frame that will be drawn behind the item when it is in the indicated state.

string getId | ( |  | ) |

Returns the unique ID assigned to this PGItem.

This will be assigned to the region created with the MouseWatcher, and will thus be used to generate event names.

string getKeystrokeEvent | ( |  | ) |

Returns the event name that will be thrown when the item is active and any key is pressed by the user.

static string getKeystrokePrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the keystroke event for all PGItems.

The keystroke event is the concatenation of this string followed by a hyphen and get_id().

int getNumStateDefs | ( |  | ) |

Returns one more than the highest-numbered state def that was ever assigned to the PGItem.

The complete set of state defs assigned may then be retrieved by indexing from 0 to (get_num_state_defs() - 1).

This is only an upper limit on the actual number of state defs, since there may be holes in the list.

string getPressEvent | ( | ButtonHandle const | button | ) |

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is depressed while the mouse is within the frame.

static string getPressPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the press event for all PGItems.

The press event is the concatenation of this string followed by a button name, followed by a hyphen and get_id().

string getReleaseEvent | ( | ButtonHandle const | button | ) |

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button, formerly clicked down is within the frame, is released.

static string getReleasePrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the release event for all PGItems.

The release event is the concatenation of this string followed by a button name, followed by a hyphen and get_id().

string getRepeatEvent | ( | ButtonHandle const | button | ) |

Returns the event name that will be thrown when the item is active and the indicated mouse or keyboard button is continuously held down while the mouse is within the frame.

static string getRepeatPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the repeat event for all PGItems.

The repeat event is the concatenation of this string followed by a button name, followed by a hyphen and get_id().

AudioSound getSound | ( | string | event | ) |

Returns the sound associated with the indicated event, or NULL if there is no associated sound.

int getState | ( |  | ) |

Returns the "state" of this particular PGItem.

See set_state().

Reimplemented from PandaNode.

NodePath getStateDef | ( | int | state | ) |

Returns the Node that is the root of the subgraph that will be drawn when the PGItem is in the indicated state.

The first time this is called for a particular state index, it may create the Node.

list getStateDefs | ( |  | ) |

int getSuppressFlags | ( |  | ) |

This is just an interface to get the suppress flags on the underlying MouseWatcherRegion.

See MouseWatcherRegion.get_suppress_flags().

static TextNode getTextNode | ( |  | ) | `[static]`

Returns the TextNode object that will be used by all PGItems to generate default labels given a string.

This can be loaded with the default font, etc.

string getWithinEvent | ( |  | ) |

Returns the event name that will be thrown when the item is active and the mouse moves within the boundaries of the frame.

This is different from the enter_event in that the mouse is considered within the frame even if it is also within a nested frame.

static string getWithinPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the within event for all PGItems.

The within event is the concatenation of this string followed by get_id().

string getWithoutEvent | ( |  | ) |

Returns the event name that will be thrown when the item is active and the mouse moves completely outside the boundaries of the frame.

This is different from the exit_event in that the mouse is considered within the frame even if it is also within a nested frame.

static string getWithoutPrefix | ( |  | ) | `[static]`

Returns the prefix that is used to define the without event for all PGItems.

The without event is the concatenation of this string followed by get_id().

bool hasFrame | ( |  | ) |

Returns true if the item has a bounding rectangle; see set_frame().

bool hasSound | ( | string | event | ) |

Returns true if there is a sound associated with the indicated event, or false otherwise.

bool hasStateDef | ( | int | state | ) |

Returns true if get_state_def() has ever been called for the indicated state (thus defining a render subgraph for this state index), false otherwise.

NodePath instanceToStateDef | ( | int | state,
|  | NodePath const | path
| ) |  |

Parents an instance of the bottom node of the indicated NodePath to the indicated state index.

setActive | ( | bool | active | ) |

Sets whether the PGItem is active for mouse watching.

This is not necessarily related to the active/inactive appearance of the item, which is controlled by set_state(), but it does affect whether it responds to mouse events.

Reimplemented in PGSliderBar.

setBackgroundFocus | ( | bool | focus | ) |

Sets the background_focus flag for this item.

When background_focus is enabled, the item will receive keypress events even if it is not in focus; in fact, even if it is not onscreen. Unlike normal focus, many items may have background_focus simultaneously.

setFocus | ( | bool | focus | ) |

Sets whether the PGItem currently has keyboard focus.

This simply means that the item may respond to keyboard events as well as to mouse events; precisely what this means is up to the individual item.

Only one PGItem in the world is allowed to have focus at any given time. Setting the focus on any other item automatically disables the focus from the previous item.

setFrame | ( | VBase4 const | frame | ) |

Sets the bounding rectangle of the item, in local coordinates.

This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.

setFrame | ( | float | left,
|  | float | right,
|  | float | bottom,
|  | float | top
| ) |  |

Sets the bounding rectangle of the item, in local coordinates.

This is the region on screen within which the mouse will be considered to be within the item. Normally, it should correspond to the bounding rectangle of the visible geometry of the item.

setFrameStyle | ( | int | state,
|  | PGFrameStyle const | style
| ) |  |

Changes the kind of frame that will be drawn behind the item when it is in the indicated state.

setId | ( | string | id | ) |

Set the unique ID assigned to this PGItem.

It is the user's responsibility to ensure that this ID is unique.

Normally, this should not need to be called, as the PGItem will assign itself an ID when it is created, but this function allows the user to decide to redefine the ID to be something possibly more meaningful.

setName | ( | string | name | ) |

Reimplemented from Namable.

setSound | ( | string | event,
|  | AudioSound | sound
| ) |  |

Sets the sound that will be played whenever the indicated event occurs.

setState | ( | int | state | ) |

Sets the "state" of this particular PGItem.

The PGItem node will render as if it were the subgraph assigned to the corresponding index via set_state_def().

setSuppressFlags | ( | int | suppress_flags | ) |

This is just an interface to set the suppress flags on the underlying MouseWatcherRegion.

See MouseWatcherRegion.set_suppress_flags().

static setTextNode | ( | TextNode | node | ) | `[static]`

Changes the TextNode object that will be used by all PGItems to generate default labels given a string.

This can be loaded with the default font, etc.

All Classes Namespaces Functions Variables Enumerations Enumerator Properties