SelectionMoveResizer.h
Go to the documentation of this file.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 #ifndef SELECTION_MOVE_RESIZER_H
00031 #define SELECTION_MOVE_RESIZER_H
00032
00033 #include <QWidget>
00034 #include <QList>
00035 #include <QRect>
00036
00037 class QPoint;
00038 class QwtPlotMarker;
00039 class LegendWidget;
00040 class ArrowMarker;
00041 class ImageMarker;
00042
00089 class SelectionMoveResizer : public QWidget
00090 {
00091 Q_OBJECT
00092
00093 public:
00095 SelectionMoveResizer(LegendWidget *target);
00097 SelectionMoveResizer(ArrowMarker *target);
00099 SelectionMoveResizer(ImageMarker *target);
00101 SelectionMoveResizer(QWidget *target);
00103 ~SelectionMoveResizer();
00106 virtual bool eventFilter(QObject *o, QEvent *e);
00108 bool contains(QWidget *w) const { return d_widgets.contains(w); };
00110 bool contains(LegendWidget *m) const { return d_legend_markers.contains(m); };
00112 bool contains(ArrowMarker *m) const { return d_line_markers.contains(m); };
00114 bool contains(ImageMarker *m) const { return d_image_markers.contains(m); };
00115
00116 public slots:
00118 void add(LegendWidget *target);
00120 void add(ArrowMarker *target);
00122 void add(ImageMarker *target);
00124 void add(QWidget *target);
00126 int removeAll(LegendWidget *target);
00128 int removeAll(ArrowMarker *target);
00130 int removeAll(ImageMarker *target);
00132 int removeAll(QWidget *target);
00134 void recalcBoundingRect();
00135
00136 signals:
00138 void targetsChanged();
00139
00140 protected:
00142 enum Operation { None=-2, Move, Resize_N, Resize_NE, Resize_E, Resize_SE, Resize_S, Resize_SW, Resize_W, Resize_NW };
00143
00149 virtual void paintEvent(QPaintEvent *e);
00155 virtual void mousePressEvent(QMouseEvent *e);
00161 virtual void mouseMoveEvent(QMouseEvent *e);
00166 virtual void mouseReleaseEvent(QMouseEvent *e);
00171 virtual void keyPressEvent(QKeyEvent *e);
00173 virtual void mouseDoubleClickEvent(QMouseEvent *e);
00174
00175 private:
00177 static const int handler_size = 10;
00179 static const QRect handlerRect(QRect rect, Operation op);
00181 QRect operateOn(const QRect in);
00183 void operateOnTargets();
00185 void init();
00187 QRect boundingRectOf(QwtPlotMarker *target) const;
00188
00190 QList <LegendWidget *> d_legend_markers;
00192 QList <ArrowMarker *> d_line_markers;
00194 QList <ImageMarker *> d_image_markers;
00196 QList <QWidget *> d_widgets;
00198 QRect d_bounding_rect;
00200 Operation d_op;
00202 QPoint d_op_start;
00204 QPoint d_op_dp;
00205
00206 private slots:
00208 void removeWidget(QObject* w) { removeAll((QWidget*) w); }
00209 void removeLegend(QObject* w) { removeAll((LegendWidget*) w); };
00210 };
00211
00212 #endif // ifndef SELECTION_MOVE_RESIZER_H