00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PGBUTTON_H
00020 #define PGBUTTON_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pgItem.h"
00025 #include "nodePath.h"
00026 #include "pset.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035 class EXPCL_PANDA PGButton : public PGItem {
00036 PUBLISHED:
00037 PGButton(const string &name);
00038 virtual ~PGButton();
00039
00040 protected:
00041 PGButton(const PGButton ©);
00042
00043 public:
00044 virtual PandaNode *make_copy() const;
00045
00046 virtual void enter(const MouseWatcherParameter ¶m);
00047 virtual void exit(const MouseWatcherParameter ¶m);
00048 virtual void press(const MouseWatcherParameter ¶m, bool background);
00049 virtual void release(const MouseWatcherParameter ¶m, bool background);
00050
00051 virtual void click(const MouseWatcherParameter ¶m);
00052
00053 PUBLISHED:
00054 enum State {
00055 S_ready = 0,
00056 S_depressed,
00057 S_rollover,
00058 S_inactive
00059 };
00060
00061 void setup(const string &label);
00062 INLINE void setup(const NodePath &ready);
00063 INLINE void setup(const NodePath &ready, const NodePath &depressed);
00064 INLINE void setup(const NodePath &ready, const NodePath &depressed,
00065 const NodePath &rollover);
00066 void setup(const NodePath &ready, const NodePath &depressed,
00067 const NodePath &rollover, const NodePath &inactive);
00068
00069 virtual void set_active(bool active);
00070
00071 bool add_click_button(const ButtonHandle &button);
00072 bool remove_click_button(const ButtonHandle &button);
00073 bool has_click_button(const ButtonHandle &button);
00074
00075 INLINE static string get_click_prefix();
00076 INLINE string get_click_event(const ButtonHandle &button) const;
00077
00078 private:
00079 typedef pset<ButtonHandle> Buttons;
00080 Buttons _click_buttons;
00081
00082 bool _button_down;
00083
00084 public:
00085 static TypeHandle get_class_type() {
00086 return _type_handle;
00087 }
00088 static void init_type() {
00089 PGItem::init_type();
00090 register_type(_type_handle, "PGButton",
00091 PGItem::get_class_type());
00092 }
00093 virtual TypeHandle get_type() const {
00094 return get_class_type();
00095 }
00096 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00097
00098 private:
00099 static TypeHandle _type_handle;
00100 };
00101
00102 #include "pgButton.I"
00103
00104 #endif