karbon

vcanvas.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VCANVAS_H__
00021 #define __VCANVAS_H__
00022 
00023 
00024 #include <qscrollview.h>
00025 #include <koffice_export.h>
00026 class KarbonPart;
00027 class KarbonView;
00028 class KoRect;
00029 class KoPoint;
00030 class VPainter;
00031 
00032 // The canvas is a QScrollView.
00033 
00034 class KARBONCOMMON_EXPORT VCanvas : public QScrollView
00035 {
00036     Q_OBJECT
00037 public:
00038     VCanvas( QWidget *parent, KarbonView* view, KarbonPart* part );
00039     virtual ~VCanvas();
00040 
00041     void repaintAll( const KoRect & );
00042     void repaintAll( bool drawVObjects = true );
00043 
00044     QPixmap *pixmap() { return m_pixmap; }
00045 
00049     void setPos( const KoPoint& p );
00050 
00051     KoPoint toViewport( const KoPoint & ) const;
00052     KoPoint toContents( const KoPoint & ) const;
00053     KoRect boundingBox() const;
00054 
00061     void setViewport( double centerX, double centerY );
00062 
00067     void setViewportRect( const KoRect &rect );
00068 
00069     int pageOffsetX() const;
00070     int pageOffsetY() const;
00071 
00072     KoPoint snapToGrid( const KoPoint & );
00073 
00074 protected:
00075     virtual void dragEnterEvent( QDragEnterEvent * );
00076     virtual void dropEvent( QDropEvent * );
00077     virtual void focusInEvent( QFocusEvent * );
00078     virtual void viewportPaintEvent( QPaintEvent* );
00079     virtual void drawContents( QPainter* painter, int clipx, int clipy,
00080         int clipw, int cliph  );
00081     void drawDocument( QPainter* painter, const KoRect& rect, bool drawVObjects = true );
00082 
00083     virtual void resizeEvent( QResizeEvent* event );
00084 
00085     virtual bool eventFilter( QObject* object, QEvent* event );
00086 
00087     void setYMirroring( VPainter * );
00088 
00089 private slots:
00090     void slotContentsMoving( int , int );
00091 
00092 signals:
00093     void viewportChanged();
00094 
00095 private:
00096     QPixmap *m_pixmap;
00097     KarbonPart* m_part;
00098     KarbonView* m_view;
00099 };
00100 
00101 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys