3
$Id: Canvas.h,v 1.41 2001/07/25 12:23:49 rm Exp $
5
This file is part of KIllustrator.
6
Copyright (C) 1998-99 Kai-Uwe Sattler (kus@iti.cs.uni-magdeburg.de)
7
Copyright (C) 2000-2001 Igor Janssen (rm@linux.ru.net)
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU Library General Public License as
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU Library General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30
#include <qvaluelist.h>
31
#include <qscrollview.h>
32
#include <koprinter.h>
47
class Canvas : public QWidget {
50
Canvas (GDocument *doc, float res, QScrollBar *hb, QScrollBar *vb, QWidget *parent = 0, const char *name = 0);
53
void setDocument (GDocument* doc);
54
GDocument* getDocument () const { return document; };
56
void setZoomFactor (float factor, int centerX, int centerY);
57
void setZoomFactor (float factor);
58
float getZoomFactor () const { return zoomFactor; };
60
float scaleFactor () const { return resolution * zoomFactor / 72.0; };
62
//int xOffset () const {return mXOffset; };
63
//int yOffset () const {return mYOffset; };
65
//put the given point in the center of the canvas
66
//x and y are relative to the center of the paper
67
void center(int x=0, int y=0);
69
//return the rectangle covered by the paper in points on the screen
70
//upper left corner is always (0,0)
71
//it changes only when zooming or chaning the paper size
72
QRect paperArea() {return m_paperArea;};
73
//return the currently visible rectangle
74
//coordinates are relative to the upper left corner of the paper
75
//it changes when scrolling, zooming, resizing, alex
76
QRect visibleArea() {return m_visibleArea;};
78
//return the coordinates of the paper relative to current canvas size
79
//((-10,-10),(-10,-10)) means that the paper is on every edge
80
//10 points bigger than the current canvas
81
//it changes when scrolling, zooming, resizing and changing the paper size, alex
82
QRect relativePaperArea() {return m_relativePaperArea;};
84
void snapPositionToGrid (float& x, float& y);
85
Rect snapTranslatedBoxToGrid (const Rect& r);
86
Rect snapScaledBoxToGrid (const Rect& r, int hmask);
88
void setToolController (ToolController *tc);
91
void setupPrinter( KPrinter &printer );
92
void print( KPrinter &printer );
94
void showBasePoints (bool flag = true);
95
void setOutlineMode (bool flag);
97
void setXimPosition(int x, int y, int w, int h);
102
QRect m_relativePaperArea;
104
//if you call more than one of them, thy should be called in the order
105
//of the prepended numbers, since they depend on each other
106
//(this doesn't mean you have to call all of them), alex
107
//none of the adjust*() functions emits any signal to avoid multiple signals
108
void adjustPaperArea1();
109
void adjustScrollBarRanges2();
110
void adjustScrollBarPositions3(int x, int y);
111
void adjustVisibleArea4();
112
void adjustRelativePaperArea5();
114
float snapXPositionToGrid (float pos);
115
float snapYPositionToGrid (float pos);
117
bool eventFilter (QObject *, QEvent *);
119
void mousePressEvent (QMouseEvent *e);
120
void mouseReleaseEvent (QMouseEvent *e);
121
void mouseMoveEvent (QMouseEvent *e);
122
void wheelEvent (QWheelEvent *e);
123
void keyPressEvent (QKeyEvent *e);
124
void paintEvent (QPaintEvent *e);
125
void moveEvent (QMoveEvent *e);
126
void resizeEvent (QResizeEvent *e);
129
void rightButtonAtObjectClicked (int x, int y, GObject *obj);
130
void rightButtonAtSelectionClicked (int x, int y);
131
void rightButtonClicked (int x, int y);
133
void visibleAreaChanged (const QRect& area);
134
//void visibleAreaChanged (int x, int y);
135
void zoomFactorChanged (float zoom);
137
void mousePositionChanged (int x, int y);
139
void backSpaceCalled();
141
void updateRegion (const Rect& r);
142
void ensureVisibility (bool flag);
143
void docSizeChanged();
145
void addHelpline (int x, int y, bool horizH);
146
void drawTmpHelpline (int x, int y, bool horizH);
149
void retryUpdateRegion ();
156
void propagateMouseEvent (QMouseEvent *e);
157
void drawGrid (QPainter& p);
158
void drawHelplines (QPainter& p);
164
int m_width, m_height;
168
ToolController *toolController;
170
Rect regionForUpdate, region;
172
float tmpHorizHelpline, tmpVertHelpline;
176
bool ensureVisibilityFlag:1;
177
bool drawBasePoints:1;