forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgButton.h
More file actions
105 lines (83 loc) · 2.74 KB
/
pgButton.h
File metadata and controls
105 lines (83 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file pgButton.h
* @author drose
* @date 2002-03-13
*/
#ifndef PGBUTTON_H
#define PGBUTTON_H
#include "pandabase.h"
#include "pgItem.h"
#include "pgButtonNotify.h"
#include "nodePath.h"
#include "pset.h"
/**
* This is a particular kind of PGItem that is specialized to behave like a
* normal button object. It keeps track of its own state, and handles mouse
* events sensibly.
*/
class EXPCL_PANDA_PGUI PGButton : public PGItem {
PUBLISHED:
explicit PGButton(const string &name);
virtual ~PGButton();
protected:
PGButton(const PGButton ©);
public:
virtual PandaNode *make_copy() const;
virtual void enter_region(const MouseWatcherParameter ¶m);
virtual void exit_region(const MouseWatcherParameter ¶m);
virtual void press(const MouseWatcherParameter ¶m, bool background);
virtual void release(const MouseWatcherParameter ¶m, bool background);
virtual void click(const MouseWatcherParameter ¶m);
INLINE void set_notify(PGButtonNotify *notify);
INLINE PGButtonNotify *get_notify() const;
PUBLISHED:
enum State {
S_ready = 0,
S_depressed,
S_rollover,
S_inactive
};
void setup(const string &label, PN_stdfloat bevel = 0.1f);
INLINE void setup(const NodePath &ready);
INLINE void setup(const NodePath &ready, const NodePath &depressed);
INLINE void setup(const NodePath &ready, const NodePath &depressed,
const NodePath &rollover);
void setup(const NodePath &ready, const NodePath &depressed,
const NodePath &rollover, const NodePath &inactive);
virtual void set_active(bool active);
bool add_click_button(const ButtonHandle &button);
bool remove_click_button(const ButtonHandle &button);
bool has_click_button(const ButtonHandle &button);
INLINE bool is_button_down();
INLINE static string get_click_prefix();
INLINE string get_click_event(const ButtonHandle &button) const;
MAKE_PROPERTY(click_prefix, get_click_prefix);
private:
typedef pset<ButtonHandle> Buttons;
Buttons _click_buttons;
bool _button_down;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
PGItem::init_type();
register_type(_type_handle, "PGButton",
PGItem::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#include "pgButton.I"
#endif