Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgui/pgButton.h

Go to the documentation of this file.
00001 // Filename: pgButton.h
00002 // Created by:  drose (13Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //       Class : PGButton
00030 // Description : This is a particular kind of PGItem that is
00031 //               specialized to behave like a normal button object.
00032 //               It keeps track of its own state, and handles mouse
00033 //               events sensibly.
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 &copy);
00042 
00043 public:
00044   virtual PandaNode *make_copy() const;
00045 
00046   virtual void enter(const MouseWatcherParameter &param);
00047   virtual void exit(const MouseWatcherParameter &param);
00048   virtual void press(const MouseWatcherParameter &param, bool background);
00049   virtual void release(const MouseWatcherParameter &param, bool background);
00050 
00051   virtual void click(const MouseWatcherParameter &param);
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

Generated on Fri May 2 00:42:36 2003 for Panda by doxygen1.3