00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KOCANVASVIEW_H
00021 #define KOCANVASVIEW_H
00022
00023 #include <koffice_export.h>
00024
00025 #include "KoCanvasBase.h"
00026
00027 #include <QWidget>
00028 #include <QScrollArea>
00029
00030 class QGridLayout;
00031 class QPaintEvent;
00032 class QEvent;
00033 class KoShape;
00034
00048 class FLAKE_EXPORT KoCanvasController : public QScrollArea {
00049 Q_OBJECT
00050 public:
00055 KoCanvasController(QWidget *parent);
00056 virtual ~KoCanvasController() {}
00057
00065 void setCanvas(KoCanvasBase *canvas);
00070 KoCanvasBase* canvas() const;
00071
00076 int visibleHeight() const;
00081 int visibleWidth() const;
00086 int canvasOffsetX() const;
00091 int canvasOffsetY() const;
00092
00100 void centerCanvas(bool centered);
00105 bool isCanvasCentered() const;
00106
00107 virtual bool eventFilter(QObject* watched, QEvent* event);
00108
00117 void ensureVisible( const QRectF &rect );
00118
00126 void ensureVisible( KoShape *shape );
00127
00128 signals:
00133 void canvasRemoved(KoCanvasController* cv);
00138 void canvasSet(KoCanvasController* cv);
00139
00144 void canvasOffsetXChanged(int offset);
00145
00150 void canvasOffsetYChanged(int offset);
00151
00152 protected slots:
00154 void updateCanvasOffsetX();
00156 void updateCanvasOffsetY();
00157
00158 private:
00159 class Viewport : public QWidget {
00160 public:
00161 Viewport();
00162 ~Viewport() {};
00163 void setCanvas(QWidget *canvas);
00164 void removeCanvas(QWidget *canvas);
00165 void centerCanvas(bool centered);
00166 private:
00167 QGridLayout *m_layout;
00168 };
00169
00170 private:
00171 KoCanvasBase *m_canvas;
00172 QWidget *m_canvasWidget;
00173 Viewport *m_viewport;
00174 bool m_centerCanvas;
00175
00176 };
00177
00178 #endif