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

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/src/QButton.cpp

Go to the documentation of this file.
00001 // Class QButton
00002 // Generic Button. Generates OnPress event if clicked or space bar pressed
00003 // Filename QButton.cpp
00004 // FaPra 2003-2004, A5,  Alexander Kramer
00005 
00006 
00007 #include "QButton.h"
00008 
00009 
00010 #include <iostream>
00011 using namespace std;
00012 
00013 
00014 // implementation of QButton
00015 
00016 //! draws itself with OpenGL. Here is the OpenGL drawing code
00017 void QButton::draw( QEvent*  e )
00018 {
00019  //
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 QButton::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 QButton::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 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 } // end of processEvent()
00070 
00071 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
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 } // end of processMouseOwner()
00082 
00083 //! called if a child is added/removed
00084 void QButton::childrenChanged()
00085 {
00086 } // end of childrenChanged()
00087 
00088 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00089 bool QButton::canFocus( QEvent*  e )
00090 {
00091  return true;
00092 } // end of canFocus()
00093 
00094 //! initialization code
00095 void QButton::Init()
00096 {
00097 } // end of Init()
00098 
00099 //! clean up code
00100 void QButton::CleanUp()
00101 {
00102 } // end of CleanUp()
00103 
00104 //! getter method for State
00105 QBevelState QButton::getState()
00106 {
00107 return State;
00108 } // end of getState()
00109 
00110 //! setter method for State
00111 void QButton::setState( QBevelState  newValue )
00112 {
00113 State = newValue;
00114 } // end of setState()
00115 
00116 // WARNING : The implementation of this method will be automatically generated with code generator.
00117 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00118 //! prints itself to the cout
00119 void QButton::print()
00120 {
00121 cout << "Class : QButton" << endl;
00122 cout << "State = " << State << endl;
00123 } // end of print()
00124 
00125 // WARNING : The implementation of this method will be automatically generated with code generator.
00126 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00127 //! Constructor
00128  QButton::QButton( QWidget*  aOwner ):QWidget(aOwner)
00129 {
00130 onPress = 0;
00131 State = bsUp;
00132 Init();
00133 layout();
00134 } // end of QButton()
00135 
00136 // WARNING : The implementation of this method will be automatically generated with code generator.
00137 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00138 //! Destructor
00139  QButton::~QButton()
00140 {
00141 CleanUp(); 
00142 } // end of ~QButton()
00143 
00144 // end of implementation of QButton
00145 
00146 

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