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

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

Go to the documentation of this file.
00001 // Class QToolBar 
00002 // Tool bar which is movable and layouts its widgets horizontal
00003 // Filename QToolBar.cpp
00004 // FaPra 2003-2004, A5,  Alexander Kramer
00005 
00006 
00007 #include "QToolBar.h"
00008 #include <iostream>
00009 using namespace std;
00010 
00011 // ----------------------------------------------------------
00012 
00013 //! brings the given widget to the front. Must be a child widget
00014 void QToolBar::bringToFront( QWidget*  widget )
00015 {
00016   
00017 } // end of bringToFront()
00018 
00019 //! draws itself with OpenGL. Here is the OpenGL drawing code
00020 void QToolBar::draw( QEvent*  e )
00021 {
00022   // clear region with background color
00023   LookAndFeel->getBackGroundColor()->setAsCurrent();
00024   glBegin(GL_POLYGON);
00025   LookAndFeel->drawRect(0,0,Width,Height);
00026   glEnd();
00027   
00028   LookAndFeel->drawBevel(0,0,Width,Height,bsUp);
00029 
00030   // draw Mover on the left side
00031   LookAndFeel->drawBevel(2,2,2,Height-4,bsUp);
00032   LookAndFeel->drawBevel(5,2,2,Height-4,bsUp);
00033 
00034 } // end of draw()
00035 
00036 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes
00037 void QToolBar::layout()
00038 {
00039   if (Children.size() > 0)
00040   {
00041     int WidgetWidth = ((Width - MoverWidth) / Children.size()) - 2;
00042     int border = 2;
00043     int WidgetHeight = Height - (border*2);
00044     int i = 0;
00045 
00046     list<QWidget*>::reverse_iterator iter;
00047 
00048     // Iterate through list
00049     for (iter=Children.rbegin(); iter != Children.rend(); iter++)
00050     {
00051       (*iter)->setTop(border);
00052       (*iter)->setHeight(WidgetHeight);
00053       (*iter)->setWidth(WidgetWidth);
00054       (*iter)->setLeft(MoverWidth+((WidgetWidth+2)*i));
00055       i++;
00056     }
00057   }
00058 } // end of layout()
00059 
00060 //! 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
00061 bool QToolBar::canDrag( QEvent*  e )
00062 {
00063  return e->getX()-Left < MoverWidth;
00064 } // end of canDrag()
00065 
00066 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner
00067 bool QToolBar::processEvent( QEvent*  e )
00068 {
00069  return false;
00070 } // end of processEvent()
00071 
00072 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
00073 bool QToolBar::processMouseOwner( QEvent*  e )
00074 {
00075  return false;
00076 } // end of processMouseOwner()
00077 
00078 //! called if a child is added/removed
00079 void QToolBar::childrenChanged()
00080 {
00081   layout();
00082 } // end of childrenChanged()
00083 
00084 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00085 bool QToolBar::canFocus( QEvent*  e )
00086 {
00087  return false;
00088 } // end of canFocus()
00089 
00090 //! initialization code
00091 void QToolBar::Init()
00092 {
00093   Width = 100;
00094   Height = 25;
00095 } // end of Init()
00096 
00097 //! clean up code
00098 void QToolBar::CleanUp()
00099 {
00100  
00101 } // end of CleanUp()
00102 
00103 //! getter method for MoverWidth
00104 int QToolBar::getMoverWidth()
00105 {
00106 return MoverWidth;
00107 } // end of getMoverWidth()
00108 
00109 //! setter method for MoverWidth
00110 void QToolBar::setMoverWidth( int  newValue )
00111 {
00112 MoverWidth = newValue;
00113 } // end of setMoverWidth()
00114 
00115 // WARNING : The implementation of this method will be automatically generated with code generator.
00116 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00117 //! prints itself to the cout
00118 void QToolBar::print()
00119 {
00120 cout << "Class : QToolBar" << endl;
00121 cout << "MoverWidth = " << MoverWidth << endl;
00122 } // end of print()
00123 
00124 // WARNING : The implementation of this method will be automatically generated with code generator.
00125 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00126 //! Constructor
00127  QToolBar::QToolBar( QWidget*  aOwner ):QWidget(aOwner)
00128 {
00129 MoverWidth = 10;
00130 Init();
00131 layout();
00132 } // end of QToolBar()
00133 
00134 // WARNING : The implementation of this method will be automatically generated with code generator.
00135 // To prevent this add '//KEEP' at the first line of the implementation.(first line after '{')
00136 //! Destructor
00137  QToolBar::~QToolBar()
00138 {
00139 CleanUp();
00140 } // end of ~QToolBar()
00141 
00142 // end of implementation of QToolBar
00143 
00144 

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