lib

KoView.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
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 #ifndef __koView_h__
00020 #define __koView_h__
00021 
00022 #include <qwidget.h>
00023 #include <qguardedptr.h>
00024 
00025 #include <kparts/part.h>
00026 
00027 #include <KoChild.h>
00028 #include <koffice_export.h>
00029 
00030 class KAction;
00031 class KActionCollection;
00032 class QCustomEvent;
00033 class KoDocument;
00034 class KoMainWindow;
00035 class KMainWindow;
00036 class KoViewPrivate;
00037 class KoViewChild;
00038 class KoFrame;
00039 class KStatusBar;
00040 class KInstance;
00041 class KPrinter;
00042 class KoDocumentChild;
00043 class DCOPObject;
00044 
00045 namespace KParts
00046 {
00047   class PartManager;
00048   class PartActivateEvent;
00049   class PartSelectEvent;
00050 }
00051 
00057 class KOFFICECORE_EXPORT KoView : public QWidget, public KParts::PartBase
00058 {
00059   Q_OBJECT
00060 public:
00075   KoView( KoDocument *document, QWidget *parent = 0, const char *name = 0 );
00079   virtual ~KoView();
00080 
00084   KoDocument *koDocument() const;
00085 
00089   void setDocumentDeleted();
00095   bool documentDeleted() const;
00096 
00097   virtual void setPartManager( KParts::PartManager *manager );
00098   virtual KParts::PartManager *partManager() const;
00099 
00111   virtual KAction *action( const QDomElement &element ) const;
00112 
00123   virtual KoDocument *hitTest( const QPoint &pos );
00124 
00143   virtual int leftBorder() const;
00147   virtual int rightBorder() const;
00151   virtual int topBorder() const;
00155   virtual int bottomBorder() const;
00156 
00167   virtual void setZoom( double zoom );
00173   virtual double zoom() const;
00174 
00181   virtual QWidget *canvas() const;
00182 
00190   virtual int canvasXOffset() const;
00191 
00199   virtual int canvasYOffset() const;
00200 
00209   virtual void canvasAddChild( KoViewChild *child );
00210 
00215    virtual KoDocumentChild *selectedChild();
00216 
00221   virtual KoDocumentChild *activeChild();
00222 
00226   void enableAutoScroll();
00227 
00231   void disableAutoScroll();
00232 
00236   virtual void paintEverything( QPainter &painter, const QRect &rect, bool transparent = false );
00237 
00244   bool hasDocumentInWindow( KoDocument *doc );
00245 
00254   virtual QWMatrix matrix() const KDE_DEPRECATED;
00255 
00262   virtual QPoint applyViewTransformations( const QPoint& ) const;
00263 
00271   virtual QPoint reverseViewTransformations( const QPoint& ) const;
00272 
00276   virtual QRect applyViewTransformations( const QRect& ) const;
00277 
00281   virtual QRect reverseViewTransformations( const QRect& ) const;
00282 
00288   KoViewChild *child( KoView *view );
00293   KoViewChild *child( KoDocument *document );
00294 
00300   virtual DCOPObject * dcopObject();
00301 
00307   virtual void setupPrinter( KPrinter &printer );
00308 
00309   // BCI: make it return a bool, so that aborting doesn't still fire up the print preview afterwards
00313   virtual void print( KPrinter &printer );
00314 
00320   KoMainWindow * shell() const;
00321 
00326   KMainWindow* mainWindow() const;
00327 
00333   KStatusBar * statusBar() const;
00334 
00346   void addStatusBarItem( QWidget * widget, int stretch = 0, bool permanent = false );
00347 
00351   void removeStatusBarItem( QWidget * widget );
00352 
00356   void showAllStatusBarItems( bool show );
00357 
00362   virtual void updateReadWrite( bool readwrite ) = 0;
00363 
00369   bool isInOperation() const;
00370 
00371 public slots:
00375     virtual void newView();
00376 
00383     virtual void beginOperation();
00384 
00391     virtual void endOperation();
00392 
00397     void slotActionStatusText( const QString &text );
00398 
00403     void slotClearStatusText();
00404 
00405 protected:
00411   virtual void customEvent( QCustomEvent *ev );
00412 
00416   virtual void partActivateEvent( KParts::PartActivateEvent *event );
00420   virtual void partSelectEvent( KParts::PartSelectEvent *event );
00424   virtual void guiActivateEvent( KParts::GUIActivateEvent * );
00425 
00426 signals:
00427   void activated( bool active );
00428   void selected( bool select );
00429 
00430   void autoScroll(const QPoint &scrollDistance);
00431 
00432   void childSelected( KoDocumentChild *child );
00433   void childUnselected( KoDocumentChild *child );
00434 
00435   void childActivated( KoDocumentChild *child );
00436   void childDeactivated( KoDocumentChild *child );
00437 
00438   void regionInvalidated( const QRegion &region, bool erase );
00439 
00440   void invalidated();
00441 
00442 // KDE invents public signals :)
00443 #undef signals
00444 #define signals public
00445 signals:
00446 
00452   void embeddImage(const QString &filename);
00453 
00454 #undef signals
00455 #define signals protected
00456 
00457 protected slots:
00458   virtual void slotChildActivated( bool a );
00459   virtual void slotChildChanged( KoDocumentChild *child );
00460   virtual void slotAutoScroll( );
00461 
00462 private:
00463   KAction *actionNewView;
00464   virtual void setupGlobalActions( void );
00465   KoViewPrivate *d;
00466   int autoScrollAcceleration( int offset ) const;
00467 };
00468 
00472 class KoViewChild : public KoChild
00473 {
00474   Q_OBJECT
00475 public:
00476   KoViewChild( KoDocumentChild *child, KoView *_parentView );
00477   virtual ~KoViewChild();
00478 
00479   KoDocumentChild *documentChild() const { return m_child; }
00480   KoView *parentView() const { return m_parentView; }
00481   KoFrame *frame() const { return m_frame; }
00482 
00483   void setInitialFrameGeometry();
00484 
00485 public slots:
00486 
00487   // Call this when the view transformations change
00488   void reposition() { slotDocGeometryChanged(); }
00489 
00490 private slots:
00491   void slotFrameGeometryChanged();
00492   void slotDocGeometryChanged();
00493 
00494 private:
00495   QGuardedPtr<KoDocumentChild> m_child;
00496   QGuardedPtr<KoFrame> m_frame;
00497   QGuardedPtr<KoView> m_parentView;
00498   class KoViewChildPrivate;
00499   KoViewChildPrivate *d;
00500 };
00501 
00502 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys