00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #ifndef SVIEWEL_H
00079 #define SVIEWEL_H
00080
00081
00082
00083
00084 #include "SView.h"
00085 #include "../general/SObserver.h"
00086
00087
00088 #include <qobject.h>
00089 #include <qpainter.h>
00090 #include <qpaintdevice.h>
00091 #include <qevent.h>
00092 #include <qpoint.h>
00093 #include <qregion.h>
00094
00095 class STaskSystem;
00102 class SViewEl : public QObject, public SObserver
00103 {
00104 Q_OBJECT
00105 public:
00111 SViewEl() : _pTaskSystem(NULL), _pView(NULL) {};
00112 SViewEl( STaskSystem *ts ) : _pTaskSystem( ts ), _pView(NULL) {};
00118 virtual void setView( SView &view ) { _pView = &view; };
00126 virtual void paint( QPaintDevice *pd, QRect rect ) = 0;
00131 enum SMarkStyles {STANDARD, MARKED, MARKED1, MARKED2, MARKED3, MARKED4};
00139 virtual bool isAffectedBy(QMouseEvent *ev) { return TRUE; };
00145 virtual bool mouseEvent(QMouseEvent *ev) { return TRUE; };
00150 virtual void setPos( QPoint p ) {};
00151
00152
00153 virtual const QRect &getBoundBox() const {
00154 ((SViewEl *) this)->_bBox =
00155 ((SViewEl *) this)->getRegion().boundingRect();
00156 return _bBox;
00157 };
00161 virtual QRegion getRegion() = 0;
00162
00163 protected:
00164 QColor lighterGray() { return QColor(220, 220, 225); };
00165
00168 void draw3DRect(QPainter &p, int x, int y, int w, int h);
00169 void draw3DRect(QPainter &p, const QRect &r) {
00170 draw3DRect(p, r.x(), r.y(), r.width(), r.height()); };
00171
00172
00178 SView &getView() { return *_pView; };
00184 void requestRepaint() {
00185 if( _pView != NULL ) _pView->repaint( QRect(0, 0, 30000, 30000) );
00186 };
00187
00188 void requestRepaint(const QRect &rect) {
00189 if( _pView != NULL ) _pView->repaint( rect );
00190 };
00194 virtual void update( const class SEvent & ) {};
00200 STaskSystem *_pTaskSystem;
00201
00202 private:
00207 SView *_pView;
00208
00209 QRect _bBox;
00210 };
00211
00212 #endif //SVIEWEL_H