PageRenderTime 31ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/koffice-trinity-20100511/karbon/karbon_view.h

#
C Header | 284 lines | 191 code | 63 blank | 30 comment | 0 complexity | 0b68bd69c350535288931ed1bea76cd4 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1
  1. /* This file is part of the KDE project
  2. Copyright (C) 2001, 2002, 2003 The Karbon Developers
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Library General Public
  5. License as published by the Free Software Foundation; either
  6. version 2 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. * Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef __KARBON_VIEW__
  17. #define __KARBON_VIEW__
  18. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #include <KoView.h>
  22. #include <KoPoint.h>
  23. #include <ksharedptr.h>
  24. #include <kxmlguibuilder.h>
  25. #include <kdualcolorbutton.h>
  26. #include <KoUnit.h>
  27. #include <koffice_export.h>
  28. class DCOPObject;
  29. class QLabel;
  30. class KAction;
  31. class KarbonPart;
  32. class KSelectAction;
  33. class KToggleAction;
  34. class KoContextHelpAction;
  35. class KoLineStyleAction;
  36. class KoUnitDoubleSpinComboBox;
  37. class KoRect;
  38. class VRuler;
  39. class KoPaletteManager;
  40. class VDocumentTab;
  41. class VLayersTab;
  42. class VHistoryTab;
  43. class VStrokeDocker;
  44. class VColorDocker;
  45. class VStyleDocker;
  46. class VTransformDocker;
  47. class VFill;
  48. class VPainterFactory;
  49. class VSelectToolBar;
  50. class VSmallPreview;
  51. class VStateButton;
  52. class VStroke;
  53. class VStrokeFillPreview;
  54. class VCanvas;
  55. class VStrokeFillPreview;
  56. class VTypeButtonBox;
  57. class VTool;
  58. class VToolBox;
  59. class VToolController;
  60. class VCommand;
  61. class KARBONCOMMON_EXPORT KarbonView : public KoView, public KXMLGUIBuilder
  62. {
  63. Q_OBJECT
  64. public:
  65. KarbonView( KarbonPart* part, QWidget* parent = 0L,
  66. const char* name = 0L );
  67. virtual ~KarbonView();
  68. virtual DCOPObject* dcopObject();
  69. KarbonPart *part() const { return m_part; }
  70. virtual void paintEverything( QPainter &p, const QRect &rect, bool transparent = false );
  71. bool mouseEvent( QMouseEvent* event, const KoPoint & );
  72. bool keyEvent( QEvent* event );
  73. void dropEvent( QDropEvent *e );
  74. virtual QWidget* canvas() const;
  75. VCanvas* canvasWidget() const { return m_canvas; }
  76. virtual VPainterFactory* painterFactory() const { return m_painterFactory; }
  77. KoPaletteManager* paletteManager() { return m_pPaletteManager; };
  78. // printing support, override from KoView
  79. virtual void setupPrinter( KPrinter &/*printer*/ ) {}
  80. virtual void print( KPrinter& printer );
  81. KoContextHelpAction* contextHelpAction() const { return m_contextHelpAction; }
  82. void reorganizeGUI();
  83. void setNumberOfRecentFiles( unsigned int number );
  84. void setLineWidth( double val );
  85. QLabel* statusMessage() const { return m_status; }
  86. void setCursor( const QCursor & );
  87. void repaintAll( const KoRect & );
  88. void repaintAll( bool = true );
  89. void setPos( const KoPoint& p );
  90. void setViewportRect( const KoRect &rect );
  91. void setZoomAt( double zoom, const KoPoint & = KoPoint() );
  92. VToolController *toolController();
  93. VStrokeFillPreview* strokeFillPreview()
  94. { return m_strokeFillPreview; }
  95. public slots:
  96. // editing:
  97. void editCut();
  98. void editCopy();
  99. void editPaste();
  100. void editSelectAll();
  101. void editDeselectAll();
  102. void editDeleteSelection();
  103. void editPurgeHistory();
  104. void selectionDuplicate();
  105. void selectionBringToFront();
  106. void selectionSendToBack();
  107. void selectionMoveUp();
  108. void selectionMoveDown();
  109. void selectionAlignHorizontalLeft();
  110. void selectionAlignHorizontalCenter();
  111. void selectionAlignHorizontalRight();
  112. void selectionAlignVerticalTop();
  113. void selectionAlignVerticalCenter();
  114. void selectionAlignVerticalBottom();
  115. void selectionDistributeHorizontalCenter();
  116. void selectionDistributeHorizontalGap();
  117. void selectionDistributeHorizontalLeft();
  118. void selectionDistributeHorizontalRight();
  119. void selectionDistributeVerticalCenter();
  120. void selectionDistributeVerticalGap();
  121. void selectionDistributeVerticalBottom();
  122. void selectionDistributeVerticalTop();
  123. void fileImportGraphic();
  124. void groupSelection();
  125. void ungroupSelection();
  126. void closePath();
  127. //View:
  128. void viewZoomIn();
  129. void viewZoomOut();
  130. void setUnit( KoUnit::Unit _unit );
  131. void configure();
  132. void pageLayout();
  133. void setLineWidth();
  134. void selectionChanged();
  135. void slotActiveToolChanged( VTool * );
  136. void togglePageMargins(bool);
  137. void showRuler();
  138. void showGrid();
  139. bool showPageMargins();
  140. void snapToGrid();
  141. void showSelectionPopupMenu( const QPoint &pos );
  142. protected slots:
  143. // Object related operations.
  144. // View.
  145. void viewModeChanged();
  146. void zoomChanged( const KoPoint & = KoPoint() );
  147. void setLineStyle( int );
  148. // Toolbox dialogs.
  149. void slotStrokeChanged( const VStroke& );
  150. void slotFillChanged( const VFill & );
  151. void canvasContentsMoving( int x, int y );
  152. void commandExecuted( VCommand *command );
  153. void strokeFillSelectionChanged( KDualColorButton::DualColor s );
  154. void colorChanged( const QColor &c );
  155. signals:
  156. void zoomChanged( double );
  157. void selectionChange();
  158. void pageLayoutChanged();
  159. protected:
  160. virtual void updateReadWrite( bool ) {}
  161. virtual void resizeEvent( QResizeEvent* event );
  162. void createDocumentTabDock();
  163. void createLayersTabDock();
  164. void createHistoryTabDock();
  165. void createStrokeDock();
  166. void createColorDock();
  167. void createTransformDock();
  168. void createResourceDock();
  169. //KXMLGUIBuilder
  170. virtual QWidget *createContainer( QWidget *parent, int index, const QDomElement &element, int &id );
  171. virtual void removeContainer( QWidget *container, QWidget *parent, QDomElement &element, int id );
  172. void addSelectionToClipboard() const;
  173. private:
  174. void initActions();
  175. void updateRuler();
  176. KarbonPart *m_part;
  177. VCanvas *m_canvas;
  178. VRuler *m_horizRuler;
  179. VRuler *m_vertRuler;
  180. VPainterFactory *m_painterFactory;
  181. VStrokeFillPreview *m_strokeFillPreview;
  182. VTypeButtonBox *m_typeButtonBox;
  183. VToolBox *m_toolbox;
  184. KAction *m_groupObjects;
  185. KAction *m_ungroupObjects;
  186. KAction *m_closePath;
  187. // actions:
  188. KSelectAction *m_zoomAction;
  189. KSelectAction *m_viewAction;
  190. KAction *m_configureAction;
  191. KToggleAction *m_showRulerAction;
  192. KToggleAction *m_showGridAction;
  193. KToggleAction *m_snapGridAction;
  194. KToggleAction *m_showPageMargins;
  195. KoContextHelpAction *m_contextHelpAction;
  196. KAction *m_deleteSelectionAction;
  197. // line width
  198. KoUnitDoubleSpinComboBox *m_setLineWidth;
  199. KoLineStyleAction *m_lineStyleAction;
  200. //dockers
  201. KoPaletteManager *m_pPaletteManager;
  202. VDocumentTab *m_DocumentTab;
  203. VLayersTab *m_LayersTab;
  204. VHistoryTab *m_HistoryTab;
  205. VColorDocker *m_ColorManager;
  206. VStrokeDocker *m_strokeDocker;
  207. VStyleDocker *m_styleDocker;
  208. VTransformDocker *m_TransformDocker;
  209. VSelectToolBar *m_selectToolBar;
  210. // dcop
  211. DCOPObject *m_dcop;
  212. //Status Bar
  213. QLabel *m_status; // Ordinary status
  214. QLabel *m_cursorCoords; // Cursor coordinates
  215. VSmallPreview *m_smallPreview; // Stroke and Fill
  216. VToolController *m_toolController;
  217. };
  218. #endif