00001
00002
00003
00004
00005
00006
00007 #include "QScreen.h"
00008 #include <iostream>
00009 using namespace std;
00010
00011
00012
00013
00014 void QScreen::draw( QEvent* e )
00015 {
00016 glColor3f(0.3,0.3,0.5);
00017 glBegin(GL_POLYGON);
00018 LookAndFeel->drawRect(0,0,Width,Height);
00019 glEnd();
00020 }
00021
00022
00023 void QScreen::layout()
00024 {
00025 }
00026
00027
00028 bool QScreen::canDrag( QEvent* e )
00029 {
00030 return false;
00031 }
00032
00033
00034 bool QScreen::processEvent( QEvent* e )
00035 {
00036 return false;
00037 }
00038
00039
00040 bool QScreen::processMouseOwner( QEvent* e )
00041 {
00042 return false;
00043 }
00044
00045
00046 void QScreen::childrenChanged()
00047 {
00048 }
00049
00050
00051 bool QScreen::canFocus( QEvent* e )
00052 {
00053 return false;
00054 }
00055
00056
00057 void QScreen::Init()
00058 {
00059 LookAndFeel = new QLookAndFeel();
00060 }
00061
00062
00063 void QScreen::CleanUp()
00064 {
00065 delete LookAndFeel;
00066 }
00067
00068
00069 void QScreen::freeWidget( QWidget* widget )
00070 {
00071
00072 WidgetsToRemove.remove(widget);
00073
00074
00075 WidgetsToRemove.push_back(widget);
00076
00077 }
00078
00079
00080 void QScreen::remove( QWidget* widget )
00081 {
00082 if (FocusPath == widget) this->ScreenFocusedWidget = 0;
00083 QWidget::remove(widget);
00084 }
00085
00086
00087 void QScreen::sendEvent()
00088 {
00089 QWidget* w;
00090
00091
00092 while (WidgetsToRemove.size() > 0)
00093 {
00094
00095 w = WidgetsToRemove.front();
00096
00097 if (w->getOwner()) w->getOwner()->remove(w);
00098
00099 delete w;
00100
00101 WidgetsToRemove.pop_front();
00102 }
00103
00104 event(LastEvent);
00105 }
00106
00107
00108 void QScreen::redraw()
00109 {
00110 glutPostRedisplay();
00111 }
00112
00113
00114 void QScreen::glutResize( int width , int height )
00115 {
00116 }
00117
00118
00119 void QScreen::glutKeyboard( unsigned char key , int x , int y )
00120 {
00121 LastEvent->setType(etKeyboard);
00122 LastEvent->setKey(key);
00123 LastEvent->setX(x);
00124 LastEvent->setY(y);
00125 sendEvent();
00126 redraw();
00127 }
00128
00129
00130 void QScreen::glutKeyboardUp( unsigned char key , int x , int y )
00131 {
00132 LastEvent->setType(etKeyboardUp);
00133 LastEvent->setKey(key);
00134 LastEvent->setX(x);
00135 LastEvent->setY(y);
00136 sendEvent();
00137 redraw();
00138 }
00139
00140
00141 void QScreen::glutSpecialFunc( int key , int x , int y )
00142 {
00143 LastEvent->setType(etSpecialKey);
00144 LastEvent->setKey(key);
00145 LastEvent->setX(x);
00146 LastEvent->setY(y);
00147 sendEvent();
00148 redraw();
00149 }
00150
00151
00152 void QScreen::glutMotion( int x , int y )
00153 {
00154 LastEvent->setType(etMouseMotion);
00155 LastEvent->setX(x);
00156 LastEvent->setY(y);
00157 sendEvent();
00158 redraw();
00159 }
00160
00161
00162 void QScreen::glutMouse( int button , int state , int x , int y )
00163 {
00164 LastEvent->setX(x);
00165 LastEvent->setY(y);
00166
00167 switch (button)
00168 {
00169 case GLUT_LEFT_BUTTON: LastEvent->setButton(mbLeft);
00170 break;
00171 case GLUT_RIGHT_BUTTON: LastEvent->setButton(mbRight);
00172 break;
00173 case GLUT_MIDDLE_BUTTON: LastEvent->setButton(mbCenter);
00174 break;
00175 }
00176
00177 if (state == GLUT_DOWN)
00178 {
00179 LastEvent->setType(etMouseDown);
00180 sendEvent();
00181 }
00182 else if (state == GLUT_UP)
00183 {
00184 LastEvent->setType(etMouseUp);
00185 sendEvent();
00186 LastEvent->setType(etMouseClick);
00187 sendEvent();
00188 }
00189 redraw();
00190 }
00191
00192
00193 void QScreen::glutDisplay()
00194 {
00195 LastEvent->setType(etDraw);
00196 sendEvent();
00197 }
00198
00199
00200 void QScreen::requestFocus( QWidget* Sender , QWidget* FocusedWidget )
00201 {
00202 if ((FocusPath != 0) && (FocusPath != Sender))
00203 {
00204 FocusPath->clearFocusPath();
00205 }
00206
00207
00208 FocusPath = Sender;
00209 ScreenFocusedWidget = FocusedWidget;
00210
00211 redraw();
00212 }
00213
00214
00215 QWidget* QScreen::getScreenFocusedWidget()
00216 {
00217 return ScreenFocusedWidget;
00218 }
00219
00220
00221 void QScreen::setScreenFocusedWidget( QWidget* newValue )
00222 {
00223 ScreenFocusedWidget = newValue;
00224 }
00225
00226
00227 QEvent* QScreen::getLastEvent()
00228 {
00229 return LastEvent;
00230 }
00231
00232
00233
00234
00235 void QScreen::print()
00236 {
00237
00238 cout << "Class : QScreen" << endl;
00239
00240 cout << "ScreenFocusedWidget = " << ScreenFocusedWidget << endl;
00241 }
00242
00243
00244
00245
00246 QScreen::QScreen( QWidget* aOwner ):QWidget(aOwner)
00247 {
00248 ScreenFocusedWidget = 0;
00249 LastEvent = new QEvent;
00250 Init();
00251 layout();
00252 }
00253
00254
00255
00256
00257 QScreen::~QScreen()
00258 {
00259 delete LastEvent;
00260 CleanUp();
00261 }
00262
00263
00264
00265