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

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

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