kivio
kivio_canvas.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __kivio_canvas_h__
00020 #define __kivio_canvas_h__
00021
00022 #include <qpainter.h>
00023 #include <qbitmap.h>
00024 #include <qlineedit.h>
00025 #include <qwidget.h>
00026 #include <qpoint.h>
00027 #include <qrect.h>
00028 #include <qstring.h>
00029 #include <qptrlist.h>
00030
00031 #include <KoQueryTrader.h>
00032 #include <KoPoint.h>
00033 #include <KoRect.h>
00034 #include <KoGuides.h>
00035 #include <koffice_export.h>
00036 #include "kivio_intra_stencil_data.h"
00037
00038 class KivioView;
00039 class KivioCanvas;
00040 class KivioPage;
00041 class KivioDoc;
00042 class KivioRuler;
00043 class KivioGuideLineData;
00044
00045 class KivioScreenPainter;
00046 class KivioStencil;
00047
00048 class QPainter;
00049 class QLabel;
00050 class QPixmap;
00051 class QScrollBar;
00052 class QTimer;
00053
00054 class KoSize;
00055 class KoRect;
00056
00057 #define YBORDER_WIDTH 50
00058 #define XBORDER_HEIGHT 20
00059
00060 class KIVIO_EXPORT KivioCanvas : public QWidget
00061 {
00062 Q_OBJECT
00063 friend class KivioView;
00064 public:
00065 KivioCanvas( QWidget*, KivioView*, KivioDoc*, QScrollBar*, QScrollBar* );
00066 ~KivioCanvas();
00067
00068 int xOffset() const { return m_iXOffset; }
00069 int yOffset() const { return m_iYOffset; }
00070
00071 const KivioPage* activePage() const;
00072 KivioPage* activePage();
00073 KivioPage* findPage( const QString& _name );
00074
00075 KivioView* view()const { return m_pView; }
00076 KivioDoc* doc()const { return m_pDoc; }
00077
00078 QSize actualSize() const;
00079
00080 virtual bool event(QEvent*);
00081
00082 enum RectType { Insert, Rubber };
00083 void startRectDraw( const QPoint &p, RectType t );
00084 void continueRectDraw( const QPoint &p, RectType t );
00085 void endRectDraw();
00086 QRect rect()const { return currRect; }
00087
00088 void startSpawnerDragDraw( const QPoint &p );
00089 void continueSpawnerDragDraw( const QPoint &p );
00090 void endSpawnerDragDraw();
00091
00092 void drawSelectedStencilsXOR();
00093 void drawStencilXOR( KivioStencil * );
00094
00095 KoPoint snapToGrid(const KoPoint&);
00096 KoPoint snapToGuides(const KoPoint&, bool &, bool &);
00097 KoPoint snapToGridAndGuides(const KoPoint&);
00098
00099 KoPoint mapFromScreen(const QPoint&);
00100 QPoint mapToScreen(const KoPoint&);
00101
00102 void beginUnclippedSpawnerPainter();
00103 void endUnclippedSpawnerPainter();
00104
00105 void setViewCenterPoint(const KoPoint &);
00106
00107 KoRect visibleArea();
00108 void setVisibleArea(KoRect, int margin = 0);
00109 void setVisibleAreaByWidth(KoRect, int margin = 0);
00110 void setVisibleAreaByHeight(KoRect, int margin = 0);
00111
00112 KoGuides& guideLines() { return m_guides; }
00113
00114 int pageOffsetX() const { return m_pageOffsetX; }
00115 int pageOffsetY() const { return m_pageOffsetY; }
00116
00117 void setShowConnectorTargets(bool state) { m_showConnectorTargets = state; }
00118 bool showConnectorTargets() const { return m_showConnectorTargets; }
00119
00120 signals:
00121 void visibleAreaChanged();
00122
00123 public slots:
00124 virtual void setUpdatesEnabled(bool);
00125
00126 void zoomIn(const QPoint&);
00127 void zoomOut(const QPoint&);
00128
00129 void scrollDx(int dx);
00130 void scrollDy(int dy);
00131
00132 void scrollV(int value);
00133 void scrollH(int value);
00134
00135 void updateScrollBars();
00136
00137 void startPasteMoving();
00138
00139 void updateAutoGuideLines();
00140
00141 protected:
00142 virtual void mousePressEvent( QMouseEvent* );
00143 virtual void mouseReleaseEvent( QMouseEvent* );
00144 virtual void mouseMoveEvent( QMouseEvent* );
00145
00146 virtual void enterEvent( QEvent* );
00147 virtual void leaveEvent( QEvent* );
00148
00149 virtual void resizeEvent( QResizeEvent* );
00150 virtual void paintEvent( QPaintEvent* );
00151 virtual void wheelEvent( QWheelEvent* );
00152
00153 virtual void dragEnterEvent( QDragEnterEvent * );
00154 virtual void dragMoveEvent( QDragMoveEvent * );
00155 virtual void dragLeaveEvent( QDragLeaveEvent * );
00156 virtual void dropEvent( QDropEvent * );
00157
00158 virtual void keyPressEvent( QKeyEvent * );
00159
00160 void beginUnclippedPainter();
00161 void endUnclippedPainter();
00162
00163 void paintSelectedXOR();
00164
00165 void continuePasteMoving(const QPoint &pos);
00166 void endPasteMoving();
00167
00168 protected slots:
00169 void borderTimerTimeout();
00170
00171 private:
00172 KivioView* m_pView;
00173 KivioDoc* m_pDoc;
00174
00175 QScrollBar* m_pVertScrollBar;
00176 QScrollBar* m_pHorzScrollBar;
00177
00178 int m_iXOffset;
00179 int m_iYOffset;
00180
00181 QPixmap* m_buffer;
00182
00183 int m_pScrollX;
00184 int m_pScrollY;
00185 QPointArray gridLines;
00186
00187 bool oldRectValid;
00188 QRect currRect;
00189 QPoint rectAnchor;
00190 QPainter* unclippedPainter;
00191 QPoint sizePreviewPos;
00192
00193 KivioScreenPainter* unclippedSpawnerPainter;
00194 KivioIntraStencilData m_dragStencilData;
00195 KivioStencil* m_pDragStencil;
00196
00197 QTimer* m_borderTimer;
00198
00199 bool delegateThisEvent;
00200 QPoint lastPoint;
00201
00202 bool m_pasteMoving;
00203 QPtrList<KoRect> m_lstOldGeometry;
00204 KoPoint m_origPoint;
00205
00206 KoGuides m_guides;
00207
00208 int m_pageOffsetX;
00209 int m_pageOffsetY;
00210
00211 bool m_showConnectorTargets;
00212 };
00213
00214 #endif
|