00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PGBUTTON_H
00016 #define PGBUTTON_H
00017
00018 #include "pandabase.h"
00019
00020 #include "pgItem.h"
00021 #include "pgButtonNotify.h"
00022 #include "nodePath.h"
00023 #include "pset.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032 class EXPCL_PANDA_PGUI PGButton : public PGItem {
00033 PUBLISHED:
00034 PGButton(const string &name);
00035 virtual ~PGButton();
00036
00037 protected:
00038 PGButton(const PGButton ©);
00039
00040 public:
00041 virtual PandaNode *make_copy() const;
00042
00043 virtual void enter_region(const MouseWatcherParameter ¶m);
00044 virtual void exit_region(const MouseWatcherParameter ¶m);
00045 virtual void press(const MouseWatcherParameter ¶m, bool background);
00046 virtual void release(const MouseWatcherParameter ¶m, bool background);
00047
00048 virtual void click(const MouseWatcherParameter ¶m);
00049
00050 INLINE void set_notify(PGButtonNotify *notify);
00051 INLINE PGButtonNotify *get_notify() const;
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, PN_stdfloat bevel = 0.1f);
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 bool is_button_down();
00076
00077 INLINE static string get_click_prefix();
00078 INLINE string get_click_event(const ButtonHandle &button) const;
00079
00080 private:
00081 typedef pset<ButtonHandle> Buttons;
00082 Buttons _click_buttons;
00083
00084 bool _button_down;
00085
00086 public:
00087 static TypeHandle get_class_type() {
00088 return _type_handle;
00089 }
00090 static void init_type() {
00091 PGItem::init_type();
00092 register_type(_type_handle, "PGButton",
00093 PGItem::get_class_type());
00094 }
00095 virtual TypeHandle get_type() const {
00096 return get_class_type();
00097 }
00098 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00099
00100 private:
00101 static TypeHandle _type_handle;
00102
00103 };
00104
00105 #include "pgButton.I"
00106
00107 #endif