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

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/src/QWidget.h

Go to the documentation of this file.
00001 // Class QWidget 
00002 // Filename QWidget.h 
00003 // FaPra 2003-2004, A5, Alexander Kramer
00004 
00005 #ifndef QWidget_h 
00006 #define QWidget_h 
00007 
00008 
00009 //! Pre-declaration of QWidget
00010 class QWidget;
00011 
00012 #include "QLookAndFeel.h"
00013 #include <GL/glut.h>
00014 #include <list>
00015 using namespace std;
00016 #include "QEvent.h"
00017 
00018 
00019 
00020 //! Common super class for all widgets. Here is also the basic implementation of event passing and dragging
00021 class QWidget
00022 {
00023 private:
00024 //! dragging position x
00025 int DragStartX;
00026 
00027 //! dragging position y
00028 int DragStartY;
00029 
00030 protected:
00031 //! width of widget
00032 int Width;
00033 
00034 //! height of widget
00035 int Height;
00036 
00037 //! top offset
00038 int Top;
00039 
00040 //! left offset
00041 int Left;
00042 
00043 //! minimum width of widget
00044 int MinWidth;
00045 
00046 //! minimum height of widget
00047 int MinHeight;
00048 
00049 //! left border to client region
00050 int ClientBorderLeft;
00051 
00052 //! right border to client region
00053 int ClientBorderRight;
00054 
00055 //! top border to client region
00056 int ClientBorderTop;
00057 
00058 //! botom border to client region
00059 int ClientBorderBottom;
00060 
00061 //! enabled status
00062 bool Enabled;
00063 
00064 //! visible status
00065 bool Visible;
00066 
00067 //! dragging status
00068 bool Dragging;
00069 
00070 //! Look and Feel
00071 QLookAndFeel* LookAndFeel;
00072 
00073 //! Owner of this widget
00074 QWidget* Owner;
00075 
00076 //! Defines the child widget to which keyboard events should be passed
00077 QWidget* FocusPath;
00078 
00079 //! list of children widgets
00080 list<QWidget*> Children;
00081 
00082 public:
00083 //! event handler for mouse click
00084  void (*onClick)(QWidget*,QEvent*);
00085 
00086 //! event handler for mouse down
00087  void (*onMouseDown)(QWidget*,QEvent*);
00088 
00089 //! event handler for mouse up
00090  void (*onMouseUp)(QWidget*,QEvent*);
00091 
00092 //! event handler for mouse up
00093  void (*onMouseMove)(QWidget*,QEvent*);
00094 
00095 //! event handler for keyboard
00096  void (*onKey)(QWidget*,QEvent*);
00097 
00098 //! event handler for custom drawings
00099  void (*onCustomDraw)(QWidget*,QEvent*);
00100 
00101 //! event handler for handling the changes of position and size
00102  void (*onResize)(QWidget*);
00103 
00104 //! adds given widget to the children
00105 virtual void add( QWidget*  widget );
00106 
00107 //! removes given widget from the children
00108 virtual void remove( QWidget*  widget );
00109 
00110 //! sends request for freeing a widget to parent
00111 virtual void freeWidget( QWidget*  widget );
00112 
00113 //! clears the focus path by setting it to 0 recursively
00114  void clearFocusPath();
00115 
00116 //! returns true if widget has keyboard focus
00117  bool getFocused();
00118 
00119 //! frees the widget and all resources. This method must be used insted of explicit delete
00120  void free();
00121 
00122 //! primary event receiver method. Returns true, if event was handled. In this case the event won't be passed to next child
00123  bool event( QEvent*  e );
00124 
00125 //! post request for redisplay
00126 virtual void redraw();
00127 
00128 //! sends the event to each child. Returns true if event was handled
00129  bool eventToChildren( QEvent*  e );
00130 
00131 //! sends the event to each child in reversed order. Returns true if event was handled
00132  bool eventToChildrenReversed( QEvent*  e );
00133 
00134 //! brings the given widget to the front. Must be a child widget
00135 virtual void bringToFront( QWidget*  widget );
00136 
00137 //! Returns true if a given widget is in front
00138  bool isInFront( QWidget*  widget );
00139 
00140 //! handles the keyboard event
00141  bool handleKeyboardEvent( QEvent*  e );
00142 
00143 //! handles the mouse event for this widget
00144  bool handleMouseEvent( QEvent*  e );
00145 
00146 //! handles the dragging
00147  void handleDragging( QEvent*  e );
00148 
00149 //! tries to set focus to the current widget
00150  void doFocus( QEvent*  e );
00151 
00152 //! called if Sender wants to announce new focused control
00153 virtual void requestFocus( QWidget*  Sender , QWidget*  FocusedWidget );
00154 
00155 //! changes the global drawing context
00156  void changeContext();
00157 
00158 //! restores the global drawing context
00159  void restoreContext();
00160 
00161 //! calls delete for every child widget
00162  void freeChildren();
00163 
00164 //! draws itself with OpenGL. Here is the OpenGL drawing code
00165 virtual void draw( QEvent*  e );
00166 
00167 //! layout the children widgets. This method is called every time the size is changed. Have to be overwritten for respond on size changes
00168 virtual void layout();
00169 
00170 //! 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
00171 virtual bool canDrag( QEvent*  e );
00172 
00173 //! processing mouse/keyboard events which are in widgets region. Mouse coordinates are relative to Owner
00174 virtual bool processEvent( QEvent*  e );
00175 
00176 //! processing mouse events which are in Owner widget region. Mouse coordinates are relative to Owner
00177 virtual bool processMouseOwner( QEvent*  e );
00178 
00179 //! called if a child is added/removed
00180 virtual void childrenChanged();
00181 
00182 //! defines whether control can have keyboard focus. Should return true if Widget wants to get keyboard focus
00183 virtual bool canFocus( QEvent*  e );
00184 
00185 //! initialization code
00186 virtual void Init();
00187 
00188 //! clean up code
00189 virtual void CleanUp();
00190 
00191 //! getter method for Width
00192 virtual int getWidth();
00193 
00194 //! setter method for Width
00195 virtual void setWidth( int  newValue );
00196 
00197 //! getter method for Height
00198 virtual int getHeight();
00199 
00200 //! setter method for Height
00201 virtual void setHeight( int  newValue );
00202 
00203 //! getter method for Top
00204 virtual int getTop();
00205 
00206 //! setter method for Top
00207 virtual void setTop( int  newValue );
00208 
00209 //! getter method for Left
00210 virtual int getLeft();
00211 
00212 //! setter method for Left
00213 virtual void setLeft( int  newValue );
00214 
00215 //! getter method for MinWidth
00216 virtual int getMinWidth();
00217 
00218 //! setter method for MinWidth
00219 virtual void setMinWidth( int  newValue );
00220 
00221 //! getter method for MinHeight
00222 virtual int getMinHeight();
00223 
00224 //! setter method for MinHeight
00225 virtual void setMinHeight( int  newValue );
00226 
00227 //! getter method for ClientBorderLeft
00228 virtual int getClientBorderLeft();
00229 
00230 //! setter method for ClientBorderLeft
00231 virtual void setClientBorderLeft( int  newValue );
00232 
00233 //! getter method for ClientBorderRight
00234 virtual int getClientBorderRight();
00235 
00236 //! setter method for ClientBorderRight
00237 virtual void setClientBorderRight( int  newValue );
00238 
00239 //! getter method for ClientBorderTop
00240 virtual int getClientBorderTop();
00241 
00242 //! setter method for ClientBorderTop
00243 virtual void setClientBorderTop( int  newValue );
00244 
00245 //! getter method for ClientBorderBottom
00246 virtual int getClientBorderBottom();
00247 
00248 //! setter method for ClientBorderBottom
00249 virtual void setClientBorderBottom( int  newValue );
00250 
00251 //! getter method for Enabled
00252 virtual bool getEnabled();
00253 
00254 //! setter method for Enabled
00255 virtual void setEnabled( bool  newValue );
00256 
00257 //! getter method for Visible
00258 virtual bool getVisible();
00259 
00260 //! setter method for Visible
00261 virtual void setVisible( bool  newValue );
00262 
00263 //! getter method for LookAndFeel
00264 virtual QLookAndFeel* getLookAndFeel();
00265 
00266 //! setter method for LookAndFeel
00267 virtual void setLookAndFeel( QLookAndFeel*  newValue );
00268 
00269 //! getter method for Owner
00270 virtual QWidget* getOwner();
00271 
00272 //! setter method for Owner
00273 virtual void setOwner( QWidget*  newValue );
00274 
00275 //! getter method for FocusPath
00276 virtual QWidget* getFocusPath();
00277 
00278 //! setter method for FocusPath
00279 virtual void setFocusPath( QWidget*  newValue );
00280 
00281 //! prints itself to the cout
00282  void print();
00283 
00284 //! Constructor
00285   QWidget( QWidget*  aOwner );
00286 
00287 //! Destructor
00288 virtual  ~QWidget();
00289 
00290 
00291 };
00292 #endif
00293 

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