00001 // Class QButton 00002 // Filename QButton.h 00003 // FaPra 2003-2004, A5, Alexander Kramer 00004 00005 #ifndef QButton_h 00006 #define QButton_h 00007 00008 #include "QWidget.h" 00009 00010 //! Pre-declaration of QButton 00011 class QButton; 00012 00013 00014 00015 00016 //! Generic Button. Generates OnPress event if clicked or space bar pressed 00017 class QButton : public QWidget 00018 { 00019 protected: 00020 //! bevel state 00021 QBevelState State; 00022 00023 public: 00024 //! event handler for press (either mouse click or spacebar or return 00025 void (*onPress)(QWidget*,QEvent*); 00026 00027 //! draws itself with OpenGL. Here is the OpenGL drawing code 00028 virtual void draw( QEvent* e ); 00029 00030 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes 00031 virtual void layout(); 00032 00033 //! have to return true if widget should be dragged with mouse. This method is overwritten in sub classes. If returns true, widget will be dragged 00034 virtual bool canDrag( QEvent* e ); 00035 00036 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner 00037 virtual bool processEvent( QEvent* e ); 00038 00039 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner 00040 virtual bool processMouseOwner( QEvent* e ); 00041 00042 //! called if a child is added/removed 00043 virtual void childrenChanged(); 00044 00045 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus 00046 virtual bool canFocus( QEvent* e ); 00047 00048 //! initialization code 00049 virtual void Init(); 00050 00051 //! clean up code 00052 virtual void CleanUp(); 00053 00054 //! getter method for State 00055 virtual QBevelState getState(); 00056 00057 //! setter method for State 00058 virtual void setState( QBevelState newValue ); 00059 00060 //! prints itself to the cout 00061 void print(); 00062 00063 //! Constructor 00064 QButton( QWidget* aOwner ); 00065 00066 //! Destructor 00067 virtual ~QButton(); 00068 00069 00070 }; 00071 #endif 00072
1.2.18