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

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/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 #include <iostream>
00009 using namespace std;
00010 
00011 // ----------------------------------------------------------
00012 
00013 //! draws itself with OpenGL. Here is the OpenGL drawing code
00014 void QButton::draw( QEvent*  e )
00015 {
00016  //
00017 } // end of draw()
00018 
00019 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes
00020 void QButton::layout()
00021 {
00022 } // end of layout()
00023 
00024 //! 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
00025 bool QButton::canDrag( QEvent*  e )
00026 {
00027  return false;
00028 } // end of canDrag()
00029 
00030 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner
00031 bool QButton::processEvent( QEvent*  e )
00032 {
00033  
00034   if (e->getType() == etMouseDown)
00035   {
00036      if (e->getButton() == mbLeft)
00037      {
00038       State = bsDown;
00039 
00040      }
00041   }
00042   else  if (e->getType() == etMouseUp)
00043    {
00044      if ((e->getButton() == mbLeft) && (State == bsDown))
00045       {
00046          State = bsUp;
00047          if (onPress) (*onPress)(this,e);
00048       }
00049    }
00050   else if (e->getType() == etKeyboard)
00051   {
00052      if ((e->getKey() == 32) || (e->getKey() == 13))
00053      {
00054        State = bsDown;
00055      }
00056   }
00057   else if (e->getType() == etKeyboardUp)
00058    {
00059      if ((e->getKey() == 32) || (e->getKey() == 13))
00060      {
00061         State = bsUp;
00062         if (onPress) (*onPress)(this,e);
00063      }
00064    }
00065   return false;
00066 } // end of processEvent()
00067 
00068 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
00069 bool QButton::processMouseOwner( QEvent*  e )
00070 {
00071   if (State == bsDown)
00072    {
00073      if ((e->getX() < Left) || (e->getX() > Left+Width) || (e->getY() < Top) || (e->getY() > Top+Height)
00074         )
00075        State = bsUp;
00076    }
00077  return false;
00078 } // end of processMouseOwner()
00079 
00080 //! called if a child is added/removed
00081 void QButton::childrenChanged()
00082 {
00083 } // end of childrenChanged()
00084 
00085 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00086 bool QButton::canFocus( QEvent*  e )
00087 {
00088  return true;
00089 } // end of canFocus()
00090 
00091 //! initialization code
00092 void QButton::Init()
00093 {
00094 } // end of Init()
00095 
00096 //! clean up code
00097 void QButton::CleanUp()
00098 {
00099 } // end of CleanUp()
00100 
00101 //! getter method for State
00102 QBevelState QButton::getState()
00103 {
00104 return State;
00105 } // end of getState()
00106 
00107 //! setter method for State
00108 void QButton::setState( QBevelState  newValue )
00109 {
00110 State = newValue;
00111 } // end of setState()
00112 
00113 // WARNING : The implementation of this method will be automatically generated with code generator.
00114 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00115 //! prints itself to the cout
00116 void QButton::print()
00117 {
00118 cout << "Class : QButton" << endl;
00119 cout << "State = " << State << endl;
00120 } // end of print()
00121 
00122 // WARNING : The implementation of this method will be automatically generated with code generator.
00123 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00124 //! Constructor
00125  QButton::QButton( QWidget*  aOwner ):QWidget(aOwner)
00126 {
00127 onPress = 0;
00128 State = bsUp;
00129 Init();
00130 layout();
00131 } // end of QButton()
00132 
00133 // WARNING : The implementation of this method will be automatically generated with code generator.
00134 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00135 //! Destructor
00136  QButton::~QButton()
00137 {
00138 CleanUp();
00139 } // end of ~QButton()
00140 
00141 // end of implementation of QButton
00142 
00143 

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