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

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

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