19#ifndef __kivio_canvas_h__
20#define __kivio_canvas_h__
24#include <tqlineedit.h>
31#include <KoQueryTrader.h>
35#include <koffice_export.h>
36#include "kivio_intra_stencil_data.h"
43class KivioGuideLineData;
45class KivioScreenPainter;
57#define YBORDER_WIDTH 50
58#define XBORDER_HEIGHT 20
60class KIVIO_EXPORT KivioCanvas :
public TQWidget
64 friend class KivioView;
66 KivioCanvas( TQWidget*, KivioView*, KivioDoc*, TQScrollBar*, TQScrollBar* );
69 int xOffset()
const {
return m_iXOffset; }
70 int yOffset()
const {
return m_iYOffset; }
72 const KivioPage* activePage()
const;
73 KivioPage* activePage();
74 KivioPage* findPage(
const TQString& _name );
76 KivioView* view()
const {
return m_pView; }
77 KivioDoc* doc()
const {
return m_pDoc; }
79 TQSize actualSize()
const;
81 virtual bool event(TQEvent*);
83 enum RectType { Insert, Rubber };
84 void startRectDraw(
const TQPoint &p, RectType t );
85 void continueRectDraw(
const TQPoint &p, RectType t );
87 TQRect rect()
const {
return currRect; }
89 void startSpawnerDragDraw(
const TQPoint &p );
90 void continueSpawnerDragDraw(
const TQPoint &p );
91 void endSpawnerDragDraw();
93 void drawSelectedStencilsXOR();
94 void drawStencilXOR( KivioStencil * );
96 KoPoint snapToGrid(
const KoPoint&);
97 KoPoint snapToGuides(
const KoPoint&,
bool &,
bool &);
98 KoPoint snapToGridAndGuides(
const KoPoint&);
100 KoPoint mapFromScreen(
const TQPoint&);
101 TQPoint mapToScreen(
const KoPoint&);
103 void beginUnclippedSpawnerPainter();
104 void endUnclippedSpawnerPainter();
106 void setViewCenterPoint(
const KoPoint &);
108 KoRect visibleArea();
109 void setVisibleArea(KoRect,
int margin = 0);
110 void setVisibleAreaByWidth(KoRect,
int margin = 0);
111 void setVisibleAreaByHeight(KoRect,
int margin = 0);
113 KoGuides& guideLines() {
return m_guides; }
115 int pageOffsetX()
const {
return m_pageOffsetX; }
116 int pageOffsetY()
const {
return m_pageOffsetY; }
118 void setShowConnectorTargets(
bool state) { m_showConnectorTargets = state; }
119 bool showConnectorTargets()
const {
return m_showConnectorTargets; }
122 void visibleAreaChanged();
125 virtual void setUpdatesEnabled(
bool);
127 void zoomIn(
const TQPoint&);
128 void zoomOut(
const TQPoint&);
130 void scrollDx(
int dx);
131 void scrollDy(
int dy);
133 void scrollV(
int value);
134 void scrollH(
int value);
136 void updateScrollBars();
138 void startPasteMoving();
140 void updateAutoGuideLines();
143 virtual void mousePressEvent( TQMouseEvent* );
144 virtual void mouseReleaseEvent( TQMouseEvent* );
145 virtual void mouseMoveEvent( TQMouseEvent* );
147 virtual void enterEvent( TQEvent* );
148 virtual void leaveEvent( TQEvent* );
150 virtual void resizeEvent( TQResizeEvent* );
151 virtual void paintEvent( TQPaintEvent* );
152 virtual void wheelEvent( TQWheelEvent* );
154 virtual void dragEnterEvent( TQDragEnterEvent * );
155 virtual void dragMoveEvent( TQDragMoveEvent * );
156 virtual void dragLeaveEvent( TQDragLeaveEvent * );
157 virtual void dropEvent( TQDropEvent * );
159 virtual void keyPressEvent( TQKeyEvent * );
161 void beginUnclippedPainter();
162 void endUnclippedPainter();
164 void paintSelectedXOR();
166 void continuePasteMoving(
const TQPoint &pos);
167 void endPasteMoving();
170 void borderTimerTimeout();
176 TQScrollBar* m_pVertScrollBar;
177 TQScrollBar* m_pHorzScrollBar;
186 TQPointArray gridLines;
191 TQPainter* unclippedPainter;
192 TQPoint sizePreviewPos;
194 KivioScreenPainter* unclippedSpawnerPainter;
195 KivioIntraStencilData m_dragStencilData;
196 KivioStencil* m_pDragStencil;
198 TQTimer* m_borderTimer;
200 bool delegateThisEvent;
204 TQPtrList<KoRect> m_lstOldGeometry;
212 bool m_showConnectorTargets;