Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/QScreen.cpp

Go to the documentation of this file.
00001 // Class QScreen 
00002 // Screen which manages the windows
00003 // Filename QScreen.cpp
00004 // FaPra 2003-2004, A5,  Alexander Kramer
00005 
00006 
00007 #include "QScreen.h"
00008 #include <iostream>
00009 using namespace std;
00010 
00011 // ----------------------------------------------------------
00012 
00013 //! draws itself with OpenGL. Here is the OpenGL drawing code
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 } // end of draw()
00021 
00022 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes
00023 void QScreen::layout()
00024 {
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 QScreen::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 QScreen::processEvent( QEvent*  e )
00035 {
00036  return false;
00037 } // end of processEvent()
00038 
00039 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
00040 bool QScreen::processMouseOwner( QEvent*  e )
00041 {
00042  return false;
00043 } // end of processMouseOwner()
00044 
00045 //! called if a child is added/removed
00046 void QScreen::childrenChanged()
00047 {
00048 } // end of childrenChanged()
00049 
00050 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00051 bool QScreen::canFocus( QEvent*  e )
00052 {
00053  return false;
00054 } // end of canFocus()
00055 
00056 //! initialization code
00057 void QScreen::Init()
00058 {
00059   LookAndFeel = new QLookAndFeel();
00060 } // end of Init()
00061 
00062 //! clean up code
00063 void QScreen::CleanUp()
00064 {
00065   delete LookAndFeel;
00066 } // end of CleanUp()
00067 
00068 //! overwritten method which adds the widget to the list for freeing
00069 void QScreen::freeWidget( QWidget*  widget )
00070 {
00071   // make sure it is not already there
00072   WidgetsToRemove.remove(widget);
00073 
00074   //add widget
00075   WidgetsToRemove.push_back(widget);
00076 
00077 } // end of freeWidget()
00078 
00079 //! removes a widget from the children
00080 void QScreen::remove( QWidget*  widget )
00081 {
00082   if (FocusPath == widget) this->ScreenFocusedWidget = 0;
00083   QWidget::remove(widget);
00084 } // end of remove()
00085 
00086 //! sends current event
00087 void QScreen::sendEvent()
00088 {
00089  QWidget* w;
00090  
00091  // first remove widgets that are marked for deletion
00092  while (WidgetsToRemove.size() > 0)
00093  {
00094     // get first widget
00095     w = WidgetsToRemove.front();
00096     // if widget has a parent tell parent to remove it
00097     if (w->getOwner()) w->getOwner()->remove(w);
00098     // delete widget
00099     delete w;
00100     // remove the deleted widget from deletion list
00101     WidgetsToRemove.pop_front();
00102  }
00103  
00104  event(LastEvent);
00105 } // end of sendEvent()
00106 
00107 //! post request for redisplay
00108 void QScreen::redraw()
00109 {
00110   glutPostRedisplay();
00111 } // end of redraw()
00112 
00113 //! method for handling glut resize function
00114 void QScreen::glutResize( int  width , int  height )
00115 {
00116 } // end of glutResize()
00117 
00118 //! method for handling glut keyboard down function
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 } // end of glutKeyboard()
00128 
00129 //! method for handling glut keyboard up function 
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 } // end of glutKeyboardUp()
00139 
00140 //! method for handling glut special key functions
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 } // end of glutSpecialFunc()
00150 
00151 //! method for handling glut mouse motion function
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 } // end of glutMotion()
00160 
00161 //! method for handling glut mouse button function
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 } // end of glutMouse()
00191 
00192 //! method for handling glut display function
00193 void QScreen::glutDisplay()
00194 {
00195   LastEvent->setType(etDraw);
00196   sendEvent();
00197 } // end of glutDisplay()
00198 
00199 //! called if Sender wants to announce new focused control
00200 void QScreen::requestFocus( QWidget*  Sender , QWidget*  FocusedWidget )
00201 {
00202   if ((FocusPath != 0) && (FocusPath != Sender))
00203    {
00204       FocusPath->clearFocusPath();
00205    }
00206    
00207   //if (ScreenFocusedWidget) ScreenFocusedWidget->setFocused(false);
00208   FocusPath = Sender;
00209   ScreenFocusedWidget = FocusedWidget;
00210  // FocusedWidget->setFocused(true);
00211   redraw();
00212 } // end of requestFocus()
00213 
00214 //! getter method for ScreenFocusedWidget
00215 QWidget* QScreen::getScreenFocusedWidget()
00216 {
00217 return ScreenFocusedWidget;
00218 } // end of getScreenFocusedWidget()
00219 
00220 //! setter method for ScreenFocusedWidget
00221 void QScreen::setScreenFocusedWidget( QWidget*  newValue )
00222 {
00223 ScreenFocusedWidget = newValue;
00224 } // end of setScreenFocusedWidget()
00225 
00226 //! getter method for LastEvent
00227 QEvent* QScreen::getLastEvent()
00228 {
00229 return LastEvent;
00230 } // end of getLastEvent()
00231 
00232 // WARNING : The implementation of this method will be automatically generated with code generator.
00233 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00234 //! prints itself to the cout
00235 void QScreen::print()
00236 {
00237  //KEEP
00238 cout << "Class : QScreen" << endl;
00239 //cout << "WidgetsToRemove = " << WidgetsToRemove << endl;
00240 cout << "ScreenFocusedWidget = " << ScreenFocusedWidget << endl;
00241 } // end of print()
00242 
00243 // WARNING : The implementation of this method will be automatically generated with code generator.
00244 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00245 //! Constructor
00246  QScreen::QScreen( QWidget*  aOwner ):QWidget(aOwner)
00247 {
00248 ScreenFocusedWidget = 0;
00249 LastEvent = new QEvent;
00250 Init();
00251 layout();
00252 } // end of QScreen()
00253 
00254 // WARNING : The implementation of this method will be automatically generated with code generator.
00255 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00256 //! Destructor
00257  QScreen::~QScreen()
00258 {
00259 delete LastEvent;
00260 CleanUp();
00261 } // end of ~QScreen()
00262 
00263 // end of implementation of QScreen
00264 
00265 

Generated on Thu Mar 18 18:33:48 2004 for miniQT by doxygen1.2.18