lib

KoView.h
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19#ifndef __koView_h__
20#define __koView_h__
21
22#include <tqwidget.h>
23#include <tqguardedptr.h>
24
25#include <tdeparts/part.h>
26
27#include <KoChild.h>
28#include <koffice_export.h>
29
30class TDEAction;
32class TQCustomEvent;
33class KoDocument;
34class KoMainWindow;
35class TDEMainWindow;
36class KoViewPrivate;
37class KoViewChild;
38class KoFrame;
39class KStatusBar;
40class TDEInstance;
41class KPrinter;
42class KoDocumentChild;
43class DCOPObject;
44
45namespace KParts
46{
47 class PartManager;
49 class PartSelectEvent;
50}
51
57class KOFFICECORE_EXPORT KoView : public TQWidget, public KParts::PartBase
58{
59 TQ_OBJECT
60
61public:
76 KoView( KoDocument *document, TQWidget *parent = 0, const char *name = 0 );
80 virtual ~KoView();
81
85 KoDocument *koDocument() const;
86
90 void setDocumentDeleted();
96 bool documentDeleted() const;
97
98 virtual void setPartManager( KParts::PartManager *manager );
99 virtual KParts::PartManager *partManager() const;
100
112 virtual TDEAction *action( const TQDomElement &element ) const;
113
124 virtual KoDocument *hitTest( const TQPoint &pos );
125
144 virtual int leftBorder() const;
148 virtual int rightBorder() const;
152 virtual int topBorder() const;
156 virtual int bottomBorder() const;
157
168 virtual void setZoom( double zoom );
174 virtual double zoom() const;
175
182 virtual TQWidget *canvas() const;
183
191 virtual int canvasXOffset() const;
192
200 virtual int canvasYOffset() const;
201
210 virtual void canvasAddChild( KoViewChild *child );
211
217
222 virtual KoDocumentChild *activeChild();
223
227 void enableAutoScroll();
228
232 void disableAutoScroll();
233
237 virtual void paintEverything( TQPainter &painter, const TQRect &rect, bool transparent = false );
238
245 bool hasDocumentInWindow( KoDocument *doc );
246
255 virtual TQWMatrix matrix() const TDE_DEPRECATED;
256
263 virtual TQPoint applyViewTransformations( const TQPoint& ) const;
264
272 virtual TQPoint reverseViewTransformations( const TQPoint& ) const;
273
277 virtual TQRect applyViewTransformations( const TQRect& ) const;
278
282 virtual TQRect reverseViewTransformations( const TQRect& ) const;
283
289 KoViewChild *child( KoView *view );
294 KoViewChild *child( KoDocument *document );
295
301 virtual DCOPObject * dcopObject();
302
308 virtual void setupPrinter( KPrinter &printer );
309
310 // BCI: make it return a bool, so that aborting doesn't still fire up the print preview afterwards
314 virtual void print( KPrinter &printer );
315
321 KoMainWindow * shell() const;
322
327 TDEMainWindow* mainWindow() const;
328
334 KStatusBar * statusBar() const;
335
347 void addStatusBarItem( TQWidget * widget, int stretch = 0, bool permanent = false );
348
352 void removeStatusBarItem( TQWidget * widget );
353
357 void showAllStatusBarItems( bool show );
358
363 virtual void updateReadWrite( bool readwrite ) = 0;
364
370 bool isInOperation() const;
371
372public slots:
376 virtual void newView();
377
384 virtual void beginOperation();
385
392 virtual void endOperation();
393
398 void slotActionStatusText( const TQString &text );
399
404 void slotClearStatusText();
405
406protected:
412 virtual void customEvent( TQCustomEvent *ev );
413
417 virtual void partActivateEvent( KParts::PartActivateEvent *event );
421 virtual void partSelectEvent( KParts::PartSelectEvent *event );
426
427signals:
428 void activated( bool active );
429 void selected( bool select );
430
431 void autoScroll(const TQPoint &scrollDistance);
432
433 void childSelected( KoDocumentChild *child );
434 void childUnselected( KoDocumentChild *child );
435
436 void childActivated( KoDocumentChild *child );
437 void childDeactivated( KoDocumentChild *child );
438
439 void regionInvalidated( const TQRegion &region, bool erase );
440
441 void invalidated();
442
443// KDE invents public signals :)
444#undef signals
445#define signals public
446signals:
447
453 void embeddImage(const TQString &filename);
454
455#undef signals
456#define signals protected
457
458protected slots:
459 virtual void slotChildActivated( bool a );
460 virtual void slotChildChanged( KoDocumentChild *child );
461 virtual void slotAutoScroll( );
462
463private:
464 TDEAction *actionNewView;
465 virtual void setupGlobalActions( void );
466 KoViewPrivate *d;
467 int autoScrollAcceleration( int offset ) const;
468};
469
473class KoViewChild : public KoChild
474{
475 TQ_OBJECT
476
477public:
478 KoViewChild( KoDocumentChild *child, KoView *_parentView );
479 virtual ~KoViewChild();
480
481 KoDocumentChild *documentChild() const { return m_child; }
482 KoView *parentView() const { return m_parentView; }
483 KoFrame *frame() const { return m_frame; }
484
485 void setInitialFrameGeometry();
486
487public slots:
488
489 // Call this when the view transformations change
490 void reposition() { slotDocGeometryChanged(); }
491
492private slots:
493 void slotFrameGeometryChanged();
494 void slotDocGeometryChanged();
495
496private:
497 TQGuardedPtr<KoDocumentChild> m_child;
498 TQGuardedPtr<KoFrame> m_frame;
499 TQGuardedPtr<KoView> m_parentView;
500 class KoViewChildPrivate;
501 KoViewChildPrivate *d;
502};
503
504#endif
TDEAction * action(const char *name) const
Holds an embedded object.
The KOffice document class.
Definition KoDocument.h:61
Main window for a KOffice application.
This class represents an active embedded document.
Definition KoView.h:474
This class is used to display a KoDocument.
Definition KoView.h:58
virtual void guiActivateEvent(KParts::GUIActivateEvent *)
Handles the event KParts::GUIActivateEvent.
Definition KoView.cpp:399
void removeStatusBarItem(TQWidget *widget)
Remove a widget from the statusbar for this view.
Definition KoView.cpp:428
void embeddImage(const TQString &filename)
Make it possible for plugins to request the embedding of an image into the current document.
TDEMainWindow * mainWindow() const
Definition KoView.cpp:674
virtual int leftBorder() const
Retrieves the left border width that is displayed around the content if the view is active.
Definition KoView.cpp:268
virtual double zoom() const
Definition KoView.cpp:294
virtual DCOPObject * dcopObject()
Return a DCOP interface for this view KOffice Applications are strongly recommended to reimplement th...
Definition KoView.cpp:699
KoDocument * koDocument() const
Retrieves the document object of this view.
Definition KoView.cpp:182
virtual void endOperation()
Slot to allow code to signal the end of an operation where the screen should not have been updating.
Definition KoView.cpp:661
bool hasDocumentInWindow(KoDocument *doc)
Definition KoView.cpp:197
virtual int bottomBorder() const
Definition KoView.cpp:283
virtual TQWidget * canvas() const
Overload this function if the content will be displayed on some child widget instead of the view dire...
Definition KoView.cpp:299
virtual int topBorder() const
Definition KoView.cpp:278
virtual void partActivateEvent(KParts::PartActivateEvent *event)
Handles the event KParts::PartActivateEvent.
Definition KoView.cpp:330
virtual TQPoint reverseViewTransformations(const TQPoint &) const
Reverse the transformations that the view makes to its contents, i.e.
Definition KoView.cpp:830
virtual int canvasYOffset() const
Overload this function if the content will be displayed with an offset relative to the upper left cor...
Definition KoView.cpp:311
KoViewChild * child(KoView *view)
Definition KoView.cpp:485
void setDocumentDeleted()
Tells this view that its document has got deleted (called internally).
Definition KoView.cpp:187
virtual int canvasXOffset() const
Overload this function if the content will be displayed with an offset relative to the upper left cor...
Definition KoView.cpp:306
virtual void setZoom(double zoom)
Scales the view on the content.
Definition KoView.cpp:288
virtual void customEvent(TQCustomEvent *ev)
This method handles three events: KParts::PartActivateEvent, KParts::PartSelectEvent and KParts::GUIA...
Definition KoView.cpp:320
void addStatusBarItem(TQWidget *widget, int stretch=0, bool permanent=false)
This adds a widget to the statusbar for this view.
Definition KoView.cpp:417
virtual KoDocumentChild * activeChild()
Definition KoView.cpp:457
virtual void partSelectEvent(KParts::PartSelectEvent *event)
Handles the event KParts::PartSelectEvent.
Definition KoView.cpp:370
void enableAutoScroll()
Sets up so that autoScroll signals are emitted when the mouse pointer is outside the view.
Definition KoView.cpp:470
void slotActionStatusText(const TQString &text)
Display a message in the status bar (calls TQStatusBar::message()).
Definition KoView.cpp:685
virtual KoDocumentChild * selectedChild()
Definition KoView.cpp:444
virtual void canvasAddChild(KoViewChild *child)
Overload this function if you need to perform some actions after KoView (the part widget) is inserted...
Definition KoView.cpp:316
virtual TQWMatrix matrix() const TDE_DEPRECATED
Returns the matrix which is used by the view to transform the content.
Definition KoView.cpp:505
virtual void print(KPrinter &printer)
Overload this method with your own printing code.
Definition KoView.cpp:636
virtual int rightBorder() const
Definition KoView.cpp:273
virtual TQPoint applyViewTransformations(const TQPoint &) const
Apply the transformations that the view makes to its contents.
Definition KoView.cpp:825
virtual void newView()
Slot to create a new view around the contained koDocument.
Definition KoView.cpp:641
bool isInOperation() const
Check to see if the view is currently in the middle of an operation which means that there will be no...
Definition KoView.cpp:650
KStatusBar * statusBar() const
Definition KoView.cpp:679
void disableAutoScroll()
Stops the emitting of autoScroll signals.
Definition KoView.cpp:475
virtual void beginOperation()
Slot to allow code to signal the beginning of an operation where the screen should not update until i...
Definition KoView.cpp:655
KoMainWindow * shell() const
Definition KoView.cpp:669
virtual void paintEverything(TQPainter &painter, const TQRect &rect, bool transparent=false)
calls KoDocument::paintEverything()
Definition KoView.cpp:480
void showAllStatusBarItems(bool show)
Show or hide all statusbar items.
Definition KoView.cpp:404
virtual KoDocument * hitTest(const TQPoint &pos)
Retrieves the document that is hit.
Definition KoView.cpp:233
virtual void setupPrinter(KPrinter &printer)
Overload this method to setup KPrinter before the actual printing.
Definition KoView.cpp:631
virtual void updateReadWrite(bool readwrite)=0
You have to implement this method and disable/enable certain functionality (actions for example) in y...
KoView(KoDocument *document, TQWidget *parent=0, const char *name=0)
Creates a new view for the document.
Definition KoView.cpp:109
void slotClearStatusText()
End of the message in the status bar (calls TQStatusBar::clear()).
Definition KoView.cpp:692
bool documentDeleted() const
Definition KoView.cpp:192