00001
00002
00003
00004
00005
00006
00007 #include "QButton.h"
00008
00009
00010 #include <iostream>
00011 using namespace std;
00012
00013
00014
00015
00016
00017 void QButton::draw( QEvent* e )
00018 {
00019
00020 }
00021
00022
00023 void QButton::layout()
00024 {
00025 }
00026
00027
00028 bool QButton::canDrag( QEvent* e )
00029 {
00030 return false;
00031 }
00032
00033
00034 bool QButton::processEvent( QEvent* e )
00035 {
00036
00037 if (e->getType() == etMouseDown)
00038 {
00039 if (e->getButton() == mbLeft)
00040 {
00041 State = bsDown;
00042
00043 }
00044 }
00045 else if (e->getType() == etMouseUp)
00046 {
00047 if ((e->getButton() == mbLeft) && (State == bsDown))
00048 {
00049 State = bsUp;
00050 if (onPress) (*onPress)(this,e);
00051 }
00052 }
00053 else if (e->getType() == etKeyboard)
00054 {
00055 if ((e->getKey() == 32) || (e->getKey() == 13))
00056 {
00057 State = bsDown;
00058 }
00059 }
00060 else if (e->getType() == etKeyboardUp)
00061 {
00062 if ((e->getKey() == 32) || (e->getKey() == 13))
00063 {
00064 State = bsUp;
00065 if (onPress) (*onPress)(this,e);
00066 }
00067 }
00068 return false;
00069 }
00070
00071
00072 bool QButton::processMouseOwner( QEvent* e )
00073 {
00074 if (State == bsDown)
00075 {
00076 if ((e->getX() < Left) || (e->getX() > Left+Width) || (e->getY() < Top) || (e->getY() > Top+Height)
00077 )
00078 State = bsUp;
00079 }
00080 return false;
00081 }
00082
00083
00084 void QButton::childrenChanged()
00085 {
00086 }
00087
00088
00089 bool QButton::canFocus( QEvent* e )
00090 {
00091 return true;
00092 }
00093
00094
00095 void QButton::Init()
00096 {
00097 }
00098
00099
00100 void QButton::CleanUp()
00101 {
00102 }
00103
00104
00105 QBevelState QButton::getState()
00106 {
00107 return State;
00108 }
00109
00110
00111 void QButton::setState( QBevelState newValue )
00112 {
00113 State = newValue;
00114 }
00115
00116
00117
00118
00119 void QButton::print()
00120 {
00121 cout << "Class : QButton" << endl;
00122 cout << "State = " << State << endl;
00123 }
00124
00125
00126
00127
00128 QButton::QButton( QWidget* aOwner ):QWidget(aOwner)
00129 {
00130 onPress = 0;
00131 State = bsUp;
00132 Init();
00133 layout();
00134 }
00135
00136
00137
00138
00139 QButton::~QButton()
00140 {
00141 CleanUp();
00142 }
00143
00144
00145
00146