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

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/src/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 
00009 
00010 #include <iostream>
00011 using namespace std;
00012 
00013 
00014 // implementation of QScreen
00015 
00016 //! draws itself with OpenGL. Here is the OpenGL drawing code
00017 void QScreen::draw( QEvent*  e )
00018 {
00019   glColor3f(0.3,0.3,0.5);
00020   glBegin(GL_POLYGON);
00021   LookAndFeel->drawRect(0,0,Width,Height);
00022   glEnd();
00023 } // end of draw()
00024 
00025 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes
00026 void QScreen::layout()
00027 {
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 QScreen::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 QScreen::processEvent( QEvent*  e )
00038 {
00039  return false;
00040 } // end of processEvent()
00041 
00042 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
00043 bool QScreen::processMouseOwner( QEvent*  e )
00044 {
00045  return false;
00046 } // end of processMouseOwner()
00047 
00048 //! called if a child is added/removed
00049 void QScreen::childrenChanged()
00050 {
00051 } // end of childrenChanged()
00052 
00053 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00054 bool QScreen::canFocus( QEvent*  e )
00055 {
00056  return false;
00057 } // end of canFocus()
00058 
00059 //! initialization code
00060 void QScreen::Init()
00061 {
00062   LookAndFeel = new QLookAndFeel();
00063 } // end of Init()
00064 
00065 //! clean up code
00066 void QScreen::CleanUp()
00067 {
00068   delete LookAndFeel;
00069 } // end of CleanUp()
00070 
00071 //! overwritten method which adds the widget to the list for freeing
00072 void QScreen::freeWidget( QWidget*  widget )
00073 {
00074   // make sure it is not already there
00075   WidgetsToRemove.remove(widget);
00076 
00077   //add widget
00078   WidgetsToRemove.push_front(widget);
00079 
00080 } // end of freeWidget()
00081 
00082 //! removes a widget from the children
00083 void QScreen::remove( QWidget*  widget )
00084 {
00085   if (FocusPath == widget) this->ScreenFocusedWidget = 0;
00086   QWidget::remove(widget);
00087 } // end of remove()
00088 
00089 //! sends current event
00090 void QScreen::sendEvent()
00091 {
00092  QWidget* w;
00093  // first remove widgets that are marked for deletion
00094  while (WidgetsToRemove.size() > 0)
00095  {
00096     w = WidgetsToRemove.front();
00097     if (w->getOwner()) w->getOwner()->remove(w);
00098     delete w;
00099     WidgetsToRemove.pop_front();
00100  }
00101  event(LastEvent);
00102 } // end of sendEvent()
00103 
00104 //! post request for redisplay
00105 void QScreen::redraw()
00106 {
00107   glutPostRedisplay();
00108 } // end of redraw()
00109 
00110 //! method for handling glut resize function
00111 void QScreen::glutResize( int  width , int  height )
00112 {
00113 } // end of glutResize()
00114 
00115 //! method for handling glut keyboard down function
00116 void QScreen::glutKeyboard( unsigned  char  key , int  x , int  y )
00117 {
00118   LastEvent->setType(etKeyboard);
00119   LastEvent->setKey(key);
00120   LastEvent->setX(x);
00121   LastEvent->setY(y);
00122   sendEvent();
00123   redraw();
00124 } // end of glutKeyboard()
00125 
00126 //! method for handling glut keyboard up function 
00127 void QScreen::glutKeyboardUp( unsigned  char  key , int  x , int  y )
00128 {
00129   LastEvent->setType(etKeyboardUp);
00130   LastEvent->setKey(key);
00131   LastEvent->setX(x);
00132   LastEvent->setY(y);
00133   sendEvent();
00134   redraw();
00135 } // end of glutKeyboardUp()
00136 
00137 //! method for handling glut special key functions
00138 void QScreen::glutSpecialFunc( int  key , int  x , int  y )
00139 {
00140   LastEvent->setType(etSpecialKey);
00141   LastEvent->setKey(key);
00142   LastEvent->setX(x);
00143   LastEvent->setY(y);
00144   sendEvent();
00145   redraw();
00146 } // end of glutSpecialFunc()
00147 
00148 //! method for handling glut mouse motion function
00149 void QScreen::glutMotion( int  x , int  y )
00150 {
00151   LastEvent->setType(etMouseMotion);
00152   LastEvent->setX(x);
00153   LastEvent->setY(y);
00154   sendEvent();
00155   redraw();
00156 } // end of glutMotion()
00157 
00158 //! method for handling glut mouse button function
00159 void QScreen::glutMouse( int  button , int  state , int  x , int  y )
00160 {
00161   LastEvent->setX(x);
00162   LastEvent->setY(y);
00163 
00164   switch (button)
00165    {
00166     case GLUT_LEFT_BUTTON: LastEvent->setButton(mbLeft);
00167     break;
00168     case GLUT_RIGHT_BUTTON: LastEvent->setButton(mbRight);
00169     break;
00170     case GLUT_MIDDLE_BUTTON: LastEvent->setButton(mbCenter);
00171     break;
00172    }
00173 
00174   if (state == GLUT_DOWN)
00175   {
00176      LastEvent->setType(etMouseDown);
00177      sendEvent();
00178   }
00179   else if (state == GLUT_UP)
00180   {
00181      LastEvent->setType(etMouseUp);
00182      sendEvent();
00183      LastEvent->setType(etMouseClick);
00184      sendEvent();
00185   }
00186   redraw();
00187 } // end of glutMouse()
00188 
00189 //! method for handling glut display function
00190 void QScreen::glutDisplay()
00191 {
00192   LastEvent->setType(etDraw);
00193   sendEvent();
00194 } // end of glutDisplay()
00195 
00196 //! called if Sender wants to announce new focused control
00197 void QScreen::requestFocus( QWidget*  Sender , QWidget*  FocusedWidget )
00198 {
00199   if ((FocusPath != 0) && (FocusPath != Sender))
00200    {
00201       FocusPath->clearFocusPath();
00202    }
00203    
00204   //if (ScreenFocusedWidget) ScreenFocusedWidget->setFocused(false);
00205   FocusPath = Sender;
00206   ScreenFocusedWidget = FocusedWidget;
00207  // FocusedWidget->setFocused(true);
00208   redraw();
00209 } // end of requestFocus()
00210 
00211 //! getter method for ScreenFocusedWidget
00212 QWidget* QScreen::getScreenFocusedWidget()
00213 {
00214 return ScreenFocusedWidget;
00215 } // end of getScreenFocusedWidget()
00216 
00217 //! setter method for ScreenFocusedWidget
00218 void QScreen::setScreenFocusedWidget( QWidget*  newValue )
00219 {
00220 ScreenFocusedWidget = newValue;
00221 } // end of setScreenFocusedWidget()
00222 
00223 //! getter method for LastEvent
00224 QEvent* QScreen::getLastEvent()
00225 {
00226 return LastEvent;
00227 } // end of getLastEvent()
00228 
00229 // WARNING : The implementation of this method will be automatically generated with code generator.
00230 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00231 //! prints itself to the cout
00232 void QScreen::print()
00233 {
00234  //KEEP
00235 cout << "Class : QScreen" << endl;
00236 //cout << "WidgetsToRemove = " << WidgetsToRemove << endl;
00237 cout << "ScreenFocusedWidget = " << ScreenFocusedWidget << endl;
00238 } // end of print()
00239 
00240 // WARNING : The implementation of this method will be automatically generated with code generator.
00241 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00242 //! Constructor
00243  QScreen::QScreen( QWidget*  aOwner ):QWidget(aOwner)
00244 {
00245 ScreenFocusedWidget = 0;
00246 LastEvent = new QEvent;
00247 Init();
00248 layout();
00249 } // end of QScreen()
00250 
00251 // WARNING : The implementation of this method will be automatically generated with code generator.
00252 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00253 //! Destructor
00254  QScreen::~QScreen()
00255 {
00256 delete LastEvent;
00257 CleanUp();
00258 } // end of ~QScreen()
00259 
00260 // end of implementation of QScreen
00261 
00262 

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