00001 // Class QCaptionButton 00002 // Filename QCaptionButton.h 00003 // FaPra 2003-2004, A5, Alexander Kramer 00004 00005 #ifndef QCaptionButton_h 00006 #define QCaptionButton_h 00007 00008 #include "QButton.h" 00009 00010 //! Pre-declaration of QCaptionButton 00011 class QCaptionButton; 00012 00013 00014 00015 #include "QFont.h" 00016 00017 //! Button with Caption 00018 class QCaptionButton : public QButton 00019 { 00020 private: 00021 //! x position of the caption (centered) 00022 int CaptionPositionX; 00023 00024 protected: 00025 //! caption of the button 00026 string Caption; 00027 00028 //! used to draw caption 00029 QFont* Font; 00030 00031 public: 00032 //! overwrite this to recalculate caption position 00033 virtual void updateCaptionPosition(); 00034 00035 //! draws itself with OpenGL. Here is the OpenGL drawing code 00036 virtual void draw( QEvent* e ); 00037 00038 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes 00039 virtual void layout(); 00040 00041 //! 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 00042 virtual bool canDrag( QEvent* e ); 00043 00044 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner 00045 virtual bool processEvent( QEvent* e ); 00046 00047 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner 00048 virtual bool processMouseOwner( QEvent* e ); 00049 00050 //! called if a child is added/removed 00051 virtual void childrenChanged(); 00052 00053 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus 00054 virtual bool canFocus( QEvent* e ); 00055 00056 //! initialization code 00057 virtual void Init(); 00058 00059 //! clean up code 00060 virtual void CleanUp(); 00061 00062 //! getter method for Caption 00063 virtual string getCaption(); 00064 00065 //! setter method for Caption 00066 virtual void setCaption( string newValue ); 00067 00068 //! getter method for Font 00069 QFont* getFont(); 00070 00071 //! prints itself to the cout 00072 void print(); 00073 00074 //! Constructor 00075 QCaptionButton( QWidget* aOwner ); 00076 00077 //! Destructor 00078 virtual ~QCaptionButton(); 00079 00080 00081 }; 00082 #endif 00083
1.2.18