karbon

karbon_view.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 __KARBON_VIEW__
00021 #define __KARBON_VIEW__
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <KoView.h>
00028 #include <KoPoint.h>
00029 #include <ksharedptr.h>
00030 #include <kxmlguibuilder.h>
00031 #include <kdualcolorbutton.h>
00032 #include <KoUnit.h>
00033 #include <koffice_export.h>
00034 class DCOPObject;
00035 class QLabel;
00036 
00037 class KAction;
00038 class KarbonPart;
00039 class KSelectAction;
00040 class KToggleAction;
00041 class KoContextHelpAction;
00042 class KoLineStyleAction;
00043 
00044 class KoUnitDoubleSpinComboBox;
00045 class KoRect;
00046 class VRuler;
00047 
00048 class KoPaletteManager;
00049 class VDocumentTab;
00050 class VLayersTab;
00051 class VHistoryTab;
00052 class VStrokeDocker;
00053 class VColorDocker;
00054 class VStyleDocker;
00055 class VTransformDocker;
00056 
00057 class VFill;
00058 class VPainterFactory;
00059 class VSelectToolBar;
00060 class VSmallPreview;
00061 class VStateButton;
00062 class VStroke;
00063 class VStrokeFillPreview;
00064 class VCanvas;
00065 class VStrokeFillPreview;
00066 class VTypeButtonBox;
00067 
00068 class VTool;
00069 class VToolBox;
00070 class VToolController;
00071 
00072 class VCommand;
00073 
00074 class KARBONCOMMON_EXPORT KarbonView : public KoView, public KXMLGUIBuilder
00075 {
00076     Q_OBJECT
00077 
00078 public:
00079     KarbonView( KarbonPart* part, QWidget* parent = 0L,
00080                 const char* name = 0L );
00081     virtual ~KarbonView();
00082 
00083     virtual DCOPObject* dcopObject();
00084 
00085     KarbonPart *part() const { return m_part; }
00086 
00087     virtual void paintEverything( QPainter &p, const QRect &rect, bool transparent = false );
00088 
00089     bool mouseEvent( QMouseEvent* event, const KoPoint & );
00090     bool keyEvent( QEvent* event );
00091     void dropEvent( QDropEvent *e );
00092 
00093     virtual QWidget* canvas() const;
00094 
00095     VCanvas* canvasWidget() const { return m_canvas; }
00096 
00097     virtual VPainterFactory* painterFactory() const { return m_painterFactory; }
00098 
00099     KoPaletteManager* paletteManager() { return m_pPaletteManager; };
00100 
00101     // printing support, override from KoView
00102     virtual void setupPrinter( KPrinter &/*printer*/ ) {}
00103     virtual void print( KPrinter& printer );
00104 
00105     KoContextHelpAction* contextHelpAction() const { return m_contextHelpAction; }
00106 
00107     void reorganizeGUI();
00108     void setNumberOfRecentFiles( unsigned int number );
00109     void setLineWidth( double val );
00110 
00111     QLabel* statusMessage() const { return m_status; }
00112 
00113     void setCursor( const QCursor & );
00114 
00115     void repaintAll( const KoRect & );
00116     void repaintAll( bool = true );
00117 
00118     void setPos( const KoPoint& p );
00119 
00120     void setViewportRect( const KoRect &rect );
00121     void setZoomAt( double zoom, const KoPoint & = KoPoint() );
00122 
00123     VToolController *toolController();
00124 
00125     VStrokeFillPreview* strokeFillPreview()
00126         { return m_strokeFillPreview; }
00127 
00128 public slots:
00129     // editing:
00130     void editCut();
00131     void editCopy();
00132     void editPaste();
00133     void editSelectAll();
00134     void editDeselectAll();
00135     void editDeleteSelection();
00136     void editPurgeHistory();
00137 
00138     void selectionDuplicate();
00139     void selectionBringToFront();
00140     void selectionSendToBack();
00141     void selectionMoveUp();
00142     void selectionMoveDown();
00143     void selectionAlignHorizontalLeft();
00144     void selectionAlignHorizontalCenter();
00145     void selectionAlignHorizontalRight();
00146     void selectionAlignVerticalTop();
00147     void selectionAlignVerticalCenter();
00148     void selectionAlignVerticalBottom();
00149 
00150     void selectionDistributeHorizontalCenter();
00151     void selectionDistributeHorizontalGap();
00152     void selectionDistributeHorizontalLeft();
00153     void selectionDistributeHorizontalRight();
00154     void selectionDistributeVerticalCenter();
00155     void selectionDistributeVerticalGap();
00156     void selectionDistributeVerticalBottom();
00157     void selectionDistributeVerticalTop();
00158 
00159     void fileImportGraphic();
00160 
00161     void groupSelection();
00162     void ungroupSelection();
00163 
00164     void closePath();
00165 
00166     //View:
00167     void viewZoomIn();
00168     void viewZoomOut();
00169 
00170     void setUnit( KoUnit::Unit _unit );
00171 
00172     void configure();
00173 
00174     void pageLayout();
00175 
00176     void setLineWidth();
00177     void selectionChanged();
00178 
00179     void slotActiveToolChanged( VTool * );
00180 
00181     void togglePageMargins(bool);
00182     void showRuler();
00183     void showGrid();
00184     bool showPageMargins();
00185     void snapToGrid();
00186 
00187     void showSelectionPopupMenu( const QPoint &pos );
00188 
00189 protected slots:
00190     // Object related operations.
00191 
00192     // View.
00193     void viewModeChanged();
00194     void zoomChanged( const KoPoint & = KoPoint() );
00195     void setLineStyle( int );
00196 
00197     // Toolbox dialogs.
00198     void slotStrokeChanged( const VStroke& );
00199     void slotFillChanged( const VFill & );
00200 
00201     void canvasContentsMoving( int x, int y );
00202     void commandExecuted( VCommand *command );
00203     void strokeFillSelectionChanged( KDualColorButton::DualColor s );
00204     void colorChanged( const QColor &c );
00205 signals:
00206     void zoomChanged( double );
00207     void selectionChange();
00208     void pageLayoutChanged();
00209 
00210 protected:
00211     virtual void updateReadWrite( bool ) {}
00212     virtual void resizeEvent( QResizeEvent* event );
00213 
00214     void createDocumentTabDock();
00215     void createLayersTabDock();
00216     void createHistoryTabDock();
00217     void createStrokeDock();
00218     void createColorDock();
00219     void createTransformDock();
00220     void createResourceDock();
00221 
00222     //KXMLGUIBuilder
00223     virtual QWidget *createContainer( QWidget *parent, int index, const QDomElement &element, int &id );
00224     virtual void removeContainer( QWidget *container, QWidget *parent, QDomElement &element, int id );
00225     void addSelectionToClipboard() const;
00226 
00227 private:
00228     void initActions();
00229     void updateRuler();
00230 
00231     KarbonPart      *m_part;
00232     VCanvas         *m_canvas;
00233     VRuler          *m_horizRuler;
00234     VRuler          *m_vertRuler;
00235 
00236     VPainterFactory     *m_painterFactory;
00237     VStrokeFillPreview  *m_strokeFillPreview;
00238     VTypeButtonBox      *m_typeButtonBox;
00239 
00240     VToolBox        *m_toolbox;
00241 
00242     KAction         *m_groupObjects;
00243     KAction         *m_ungroupObjects;
00244 
00245     KAction         *m_closePath;
00246 
00247     // actions:
00248     KSelectAction       *m_zoomAction;
00249     KSelectAction       *m_viewAction;
00250     KAction             *m_configureAction;
00251     KToggleAction       *m_showRulerAction;
00252     KToggleAction       *m_showGridAction;
00253     KToggleAction       *m_snapGridAction;
00254     KToggleAction       *m_showPageMargins;
00255     KoContextHelpAction *m_contextHelpAction;
00256     KAction             *m_deleteSelectionAction;
00257     // line width
00258     KoUnitDoubleSpinComboBox *m_setLineWidth;
00259     KoLineStyleAction   *m_lineStyleAction;
00260 
00261     //dockers
00262     KoPaletteManager    *m_pPaletteManager;
00263     VDocumentTab        *m_DocumentTab;
00264     VLayersTab          *m_LayersTab;
00265     VHistoryTab         *m_HistoryTab;
00266     VColorDocker        *m_ColorManager;
00267     VStrokeDocker       *m_strokeDocker;
00268     VStyleDocker        *m_styleDocker;
00269     VTransformDocker    *m_TransformDocker;
00270 
00271     VSelectToolBar      *m_selectToolBar;
00272 
00273     // dcop
00274     DCOPObject      *m_dcop;
00275 
00276     //Status Bar
00277     QLabel              *m_status;       // Ordinary status
00278     QLabel              *m_cursorCoords; // Cursor coordinates
00279     VSmallPreview       *m_smallPreview; // Stroke and Fill
00280     VToolController *m_toolController;
00281 };
00282 
00283 #endif
00284 
KDE Home | KDE Accessibility Home | Description of Access Keys