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