]> Shamusworld >> Repos - architektonas/blob - src/widgets/qg_graphicview.h
Initial import
[architektonas] / src / widgets / qg_graphicview.h
1 #ifndef QG_GRAPHICVIEW_H
2 #define QG_GRAPHICVIEW_H
3
4 #include <QtGui>
5 #include "rs_graphicview.h"
6 #include "rs_layerlistlistener.h"
7 #include "rs_blocklistlistener.h"
8 #include "qg_scrollbar.h"
9
10 class RS_Preview;
11 class PaintInterface;
12
13 /**
14  * This is the Qt implementation of a widget which can view a
15  * graphic.
16  *
17  * Instances of this class can be linked to layer lists using
18  * addLayerListListener().
19  */
20 class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePreview,
21         public RS_LayerListListener, public RS_BlockListListener
22 {
23         Q_OBJECT
24
25         public:
26                 QG_GraphicView(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = 0);
27                 virtual ~QG_GraphicView();
28
29                 virtual int getWidth();
30                 virtual int getHeight();
31                 virtual void redraw();
32                 virtual void adjustOffsetControls();
33                 virtual void adjustZoomControls();
34 //              virtual RS_Painter * createPainter();
35 //              virtual RS_Painter * createDirectPainter();
36 #warning "!!! Need to scrub out all instances of createPainter and createDirectPainter !!!"
37                 virtual PaintInterface * createPainter();
38                 virtual PaintInterface * createDirectPainter();
39                 virtual void destroyPainter();
40                 virtual void setBackground(const RS_Color & bg);
41                 virtual void setMouseCursor(RS2::CursorType c);
42                 virtual void updateGridStatusWidget(const QString & text);
43
44                 // Methods from RS_LayerListListener Interface:
45                 virtual void layerEdited(RS_Layer *);
46                 virtual void layerRemoved(RS_Layer *);
47                 virtual void layerToggled(RS_Layer *);
48
49         protected:
50                 virtual void emulateMouseMoveEvent();
51                 virtual void mousePressEvent(QMouseEvent * e);
52                 virtual void mouseReleaseEvent(QMouseEvent * e);
53                 virtual void mouseMoveEvent(QMouseEvent * e);
54                 virtual void tabletEvent(QTabletEvent * e);
55                 virtual void leaveEvent(QEvent *);
56                 virtual void enterEvent(QEvent *);
57                 virtual void focusInEvent(QFocusEvent *);
58                 virtual void focusOutEvent(QFocusEvent *);
59                 virtual void wheelEvent(QWheelEvent * e);
60                 virtual void keyPressEvent(QKeyEvent * e);
61                 virtual void keyReleaseEvent(QKeyEvent * e);
62
63                 void paintEvent(QPaintEvent *);
64                 virtual void resizeEvent(QResizeEvent * e);
65
66 #warning "!!! File preview needs porting to Qt4 !!!"
67 //              void previewUrl(const Q3Url &u);
68
69         private slots:
70                 void slotHScrolled(int value);
71                 void slotVScrolled(int value);
72
73         private:
74 #warning "!!! Double buffering is not necessary anymore !!!"
75                 //! Buffer for double-buffering
76                 QPixmap * buffer;
77 //              int refCount;
78
79         protected:
80                 int lastWidth;
81                 int lastHeight;
82                 //! Horizontal scrollbar.
83                 QG_ScrollBar * hScrollBar;
84                 //! Vertical scrollbar.
85                 QG_ScrollBar * vScrollBar;
86                 //! Layout used to fit in the view and the scrollbars.
87                 QGridLayout * layout;
88                 //! Label for grid spacing.
89                 QLabel * gridStatus;
90                 //! CAD mouse cursor
91                 QCursor * curCad;
92                 //! Delete mouse cursor
93                 QCursor * curDel;
94                 //! Select mouse cursor
95                 QCursor * curSelect;
96                 //! Magnifying glass mouse cursor
97                 QCursor * curMagnifier;
98                 //! Hand mouse cursor
99                 QCursor * curHand;
100 };
101
102 #endif