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