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