Panda3D
 All Classes Functions Variables Enumerations
pgButton.I
1 // Filename: pgButton.I
2 // Created by: drose (13Mar02)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PGButton::set_notify
18 // Access: Published
19 // Description: Sets the object which will be notified when the
20 // PGButton changes. Set this to NULL to disable
21 // this effect. The PGButton does not retain
22 // ownership of the pointer; it is your responsibility
23 // to ensure that the notify object does not destruct.
24 ////////////////////////////////////////////////////////////////////
25 INLINE void PGButton::
27  PGItem::set_notify(notify);
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: PGButton::get_notify
32 // Access: Published
33 // Description: Returns the object which will be notified when the
34 // PGButton changes, if any. Returns NULL if there
35 // is no such object configured.
36 ////////////////////////////////////////////////////////////////////
38 get_notify() const {
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PGButton::setup
44 // Access: Published
45 // Description: Sets up the button using the indicated NodePath as
46 // arbitrary geometry.
47 ////////////////////////////////////////////////////////////////////
48 INLINE void PGButton::
49 setup(const NodePath &ready) {
50  setup(ready, ready, ready, ready);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: PGButton::setup
55 // Access: Published
56 // Description: Sets up the button using the indicated NodePath as
57 // arbitrary geometry.
58 ////////////////////////////////////////////////////////////////////
59 INLINE void PGButton::
60 setup(const NodePath &ready, const NodePath &depressed) {
61  setup(ready, depressed, ready, ready);
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: PGButton::setup
66 // Access: Published
67 // Description: Sets up the button using the indicated NodePath as
68 // arbitrary geometry.
69 ////////////////////////////////////////////////////////////////////
70 INLINE void PGButton::
71 setup(const NodePath &ready, const NodePath &depressed,
72  const NodePath &rollover) {
73  setup(ready, depressed, rollover, ready);
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: PGButton::get_click_prefix
78 // Access: Published, Static
79 // Description: Returns the prefix that is used to define the click
80 // event for all PGButtons. The click event is the
81 // concatenation of this string followed by get_id().
82 ////////////////////////////////////////////////////////////////////
83 INLINE string PGButton::
85  return "click-";
86 }
87 
88 ////////////////////////////////////////////////////////////////////
89 // Function: PGButton::get_click_event
90 // Access: Published
91 // Description: Returns the event name that will be thrown when the
92 // button is clicked normally.
93 ////////////////////////////////////////////////////////////////////
94 INLINE string PGButton::
95 get_click_event(const ButtonHandle &button) const {
96  LightReMutexHolder holder(_lock);
97  return get_click_prefix() + button.get_name() + "-" + get_id();
98 }
99 
100 ////////////////////////////////////////////////////////////////////
101 // Function: PGButton::is_button_down
102 // Access: Published
103 // Description: Returns true if the user is currently holding the
104 // mouse button down on the button, false otherwise.
105 ////////////////////////////////////////////////////////////////////
106 INLINE bool PGButton::
108  LightReMutexHolder holder(_lock);
109  return _button_down;
110 }
void set_notify(PGButtonNotify *notify)
Sets the object which will be notified when the PGButton changes.
Definition: pgButton.I:26
bool is_button_down()
Returns true if the user is currently holding the mouse button down on the button, false otherwise.
Definition: pgButton.I:107
Objects that inherit from this class can receive notify messages when a slider bar moves or otherwise...
const string & get_id() const
Returns the unique ID assigned to this PGItem.
Definition: pgItem.I:263
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
string get_click_event(const ButtonHandle &button) const
Returns the event name that will be thrown when the button is clicked normally.
Definition: pgButton.I:95
PGItemNotify * get_notify() const
Returns the object which will be notified when the PGItem changes, if any.
Definition: pgItem.I:85
static string get_click_prefix()
Returns the prefix that is used to define the click event for all PGButtons.
Definition: pgButton.I:84
string get_name() const
Returns the name of the button.
Similar to MutexHolder, but for a light reentrant mutex.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
PGButtonNotify * get_notify() const
Returns the object which will be notified when the PGButton changes, if any.
Definition: pgButton.I:38
void set_notify(PGItemNotify *notify)
Sets the object which will be notified when the PGItem changes.
Definition: pgItem.I:54
void setup(const string &label, PN_stdfloat bevel=0.1f)
Sets up the button as a default text button using the indicated label string.
Definition: pgButton.cxx:178