00001 // Class QRadioButton 00002 // Radio Button 00003 // Filename QRadioButton.cpp 00004 // FaPra 2003-2004, A5, Alexander Kramer 00005 00006 00007 #include "QRadioButton.h" 00008 00009 00010 #include <iostream> 00011 using namespace std; 00012 00013 00014 // implementation of QRadioButton 00015 00016 //! draws itself with OpenGL. Here is the OpenGL drawing code 00017 void QRadioButton::draw( QEvent* e ) 00018 { 00019 LookAndFeel->drawRadioButton(State == cbChecked); 00020 glTranslatef(BoxSize+2,(BoxSize-Font->getSize())/2,0); 00021 Font->drawInternal(Caption.c_str(),-1); 00022 } // end of draw() 00023 00024 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes 00025 void QRadioButton::layout() 00026 { 00027 QCheckBox::layout(); 00028 } // end of layout() 00029 00030 //! 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 00031 bool QRadioButton::canDrag( QEvent* e ) 00032 { 00033 return false; 00034 } // end of canDrag() 00035 00036 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner 00037 bool QRadioButton::processEvent( QEvent* e ) 00038 { 00039 if (e->getType() == etMouseDown) 00040 { 00041 if (RadioButtonGroup != 0) 00042 { 00043 RadioButtonGroup->setAsSelected(this); 00044 } 00045 else 00046 { 00047 QCheckBox::processEvent(e); 00048 } 00049 return true; 00050 } 00051 return false; 00052 } // end of processEvent() 00053 00054 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner 00055 bool QRadioButton::processMouseOwner( QEvent* e ) 00056 { 00057 return false; 00058 } // end of processMouseOwner() 00059 00060 //! called if a child is added/removed 00061 void QRadioButton::childrenChanged() 00062 { 00063 } // end of childrenChanged() 00064 00065 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus 00066 bool QRadioButton::canFocus( QEvent* e ) 00067 { 00068 return true; 00069 } // end of canFocus() 00070 00071 //! initialization code 00072 void QRadioButton::Init() 00073 { 00074 QCheckBox::Init(); 00075 } // end of Init() 00076 00077 //! clean up code 00078 void QRadioButton::CleanUp() 00079 { 00080 } // end of CleanUp() 00081 00082 //! getter method for RadioButtonGroup 00083 QRadioButtonGroup* QRadioButton::getRadioButtonGroup() 00084 { 00085 return RadioButtonGroup; 00086 } // end of getRadioButtonGroup() 00087 00088 //! setter method for RadioButtonGroup 00089 void QRadioButton::setRadioButtonGroup( QRadioButtonGroup* newValue ) 00090 { 00091 if (RadioButtonGroup != newValue) 00092 { 00093 if (RadioButtonGroup != 0) 00094 { 00095 RadioButtonGroup->remove(this); 00096 } 00097 00098 RadioButtonGroup = newValue; 00099 00100 if (RadioButtonGroup != 0) 00101 { 00102 RadioButtonGroup->add(this); 00103 } 00104 } 00105 } // end of setRadioButtonGroup() 00106 00107 // WARNING : The implementation of this method will be automatically generated with code generator. 00108 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{') 00109 //! prints itself to the cout 00110 void QRadioButton::print() 00111 { 00112 cout << "Class : QRadioButton" << endl; 00113 cout << "RadioButtonGroup = " << RadioButtonGroup << endl; 00114 } // end of print() 00115 00116 // WARNING : The implementation of this method will be automatically generated with code generator. 00117 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{') 00118 //! Constructor 00119 QRadioButton::QRadioButton( QWidget* aOwner ):QCheckBox(aOwner) 00120 { 00121 RadioButtonGroup = 0; 00122 Init(); 00123 layout(); 00124 } // end of QRadioButton() 00125 00126 // WARNING : The implementation of this method will be automatically generated with code generator. 00127 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{') 00128 //! Destructor 00129 QRadioButton::~QRadioButton() 00130 { 00131 CleanUp(); 00132 } // end of ~QRadioButton() 00133 00134 // end of implementation of QRadioButton 00135 00136
1.2.18