karbon

karbon_view.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003 The Karbon Developers
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
20#ifndef __KARBON_VIEW__
21#define __KARBON_VIEW__
22
23#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
27#include <KoView.h>
28#include <KoPoint.h>
29#include <ksharedptr.h>
30#include <kxmlguibuilder.h>
31#include <kdualcolorbutton.h>
32#include <KoUnit.h>
33#include <koffice_export.h>
34class DCOPObject;
35class TQLabel;
36
37class TDEAction;
38class KarbonPart;
39class TDESelectAction;
40class TDEToggleAction;
41class KoContextHelpAction;
42class KoLineStyleAction;
43
44class KoUnitDoubleSpinComboBox;
45class KoRect;
46class VRuler;
47
48class KoPaletteManager;
49class VDocumentTab;
50class VLayersTab;
51class VHistoryTab;
52class VStrokeDocker;
53class VColorDocker;
54class VStyleDocker;
55class VTransformDocker;
56
57class VFill;
58class VPainterFactory;
59class VSelectToolBar;
60class VSmallPreview;
61class VStateButton;
62class VStroke;
63class VStrokeFillPreview;
64class VCanvas;
65class VStrokeFillPreview;
66class VTypeButtonBox;
67
68class VTool;
69class VToolBox;
70class VToolController;
71
72class VCommand;
73
74class KARBONCOMMON_EXPORT KarbonView : public KoView, public KXMLGUIBuilder
75{
76 TQ_OBJECT
77
78
79public:
80 KarbonView( KarbonPart* part, TQWidget* parent = 0L,
81 const char* name = 0L );
82 virtual ~KarbonView();
83
84 virtual DCOPObject* dcopObject();
85
86 KarbonPart *part() const { return m_part; }
87
88 virtual void paintEverything( TQPainter &p, const TQRect &rect, bool transparent = false );
89
90 bool mouseEvent( TQMouseEvent* event, const KoPoint & );
91 bool keyEvent( TQEvent* event );
92 void dropEvent( TQDropEvent *e );
93
94 virtual TQWidget* canvas() const;
95
96 VCanvas* canvasWidget() const { return m_canvas; }
97
98 virtual VPainterFactory* painterFactory() const { return m_painterFactory; }
99
100 KoPaletteManager* paletteManager() { return m_pPaletteManager; };
101
102 // printing support, override from KoView
103 virtual void setupPrinter( KPrinter &/*printer*/ ) {}
104 virtual void print( KPrinter& printer );
105
106 KoContextHelpAction* contextHelpAction() const { return m_contextHelpAction; }
107
108 void reorganizeGUI();
109 void setNumberOfRecentFiles( unsigned int number );
110 void setLineWidth( double val );
111
112 TQLabel* statusMessage() const { return m_status; }
113
114 void setCursor( const TQCursor & );
115
116 void repaintAll( const KoRect & );
117 void repaintAll( bool = true );
118
119 void setPos( const KoPoint& p );
120
121 void setViewportRect( const KoRect &rect );
122 void setZoomAt( double zoom, const KoPoint & = KoPoint() );
123
124 VToolController *toolController();
125
126 VStrokeFillPreview* strokeFillPreview()
127 { return m_strokeFillPreview; }
128
129public slots:
130 // editing:
131 void editCut();
132 void editCopy();
133 void editPaste();
134 void editSelectAll();
135 void editDeselectAll();
136 void editDeleteSelection();
137 void editPurgeHistory();
138
139 void selectionDuplicate();
140 void selectionBringToFront();
141 void selectionSendToBack();
142 void selectionMoveUp();
143 void selectionMoveDown();
144 void selectionAlignHorizontalLeft();
145 void selectionAlignHorizontalCenter();
146 void selectionAlignHorizontalRight();
147 void selectionAlignVerticalTop();
148 void selectionAlignVerticalCenter();
149 void selectionAlignVerticalBottom();
150
151 void selectionDistributeHorizontalCenter();
152 void selectionDistributeHorizontalGap();
153 void selectionDistributeHorizontalLeft();
154 void selectionDistributeHorizontalRight();
155 void selectionDistributeVerticalCenter();
156 void selectionDistributeVerticalGap();
157 void selectionDistributeVerticalBottom();
158 void selectionDistributeVerticalTop();
159
160 void fileImportGraphic();
161
162 void groupSelection();
163 void ungroupSelection();
164
165 void closePath();
166
167 //View:
168 void viewZoomIn();
169 void viewZoomOut();
170
171 void setUnit( KoUnit::Unit _unit );
172
173 void configure();
174
175 void pageLayout();
176
177 void setLineWidth();
178 void selectionChanged();
179
180 void slotActiveToolChanged( VTool * );
181
182 void togglePageMargins(bool);
183 void showRuler();
184 void showGrid();
185 bool showPageMargins();
186 void snapToGrid();
187
188 void showSelectionPopupMenu( const TQPoint &pos );
189
190protected slots:
191 // Object related operations.
192
193 // View.
194 void viewModeChanged();
195 void zoomChanged( const KoPoint & = KoPoint() );
196 void setLineStyle( int );
197
198 // Toolbox dialogs.
199 void slotStrokeChanged( const VStroke& );
200 void slotFillChanged( const VFill & );
201
202 void canvasContentsMoving( int x, int y );
203 void commandExecuted( VCommand *command );
204 void strokeFillSelectionChanged( KDualColorButton::DualColor s );
205 void colorChanged( const TQColor &c );
206signals:
207 void zoomChanged( double );
208 void selectionChange();
209 void pageLayoutChanged();
210
211protected:
212 virtual void updateReadWrite( bool ) {}
213 virtual void resizeEvent( TQResizeEvent* event );
214
215 void createDocumentTabDock();
216 void createLayersTabDock();
217 void createHistoryTabDock();
218 void createStrokeDock();
219 void createColorDock();
220 void createTransformDock();
221 void createResourceDock();
222
223 //KXMLGUIBuilder
224 virtual TQWidget *createContainer( TQWidget *parent, int index, const TQDomElement &element, int &id );
225 virtual void removeContainer( TQWidget *container, TQWidget *parent, TQDomElement &element, int id );
226 void addSelectionToClipboard() const;
227
228private:
229 void initActions();
230 void updateRuler();
231
232 KarbonPart *m_part;
233 VCanvas *m_canvas;
234 VRuler *m_horizRuler;
235 VRuler *m_vertRuler;
236
237 VPainterFactory *m_painterFactory;
238 VStrokeFillPreview *m_strokeFillPreview;
239 VTypeButtonBox *m_typeButtonBox;
240
241 VToolBox *m_toolbox;
242
243 TDEAction *m_groupObjects;
244 TDEAction *m_ungroupObjects;
245
246 TDEAction *m_closePath;
247
248 // actions:
249 TDESelectAction *m_zoomAction;
250 TDESelectAction *m_viewAction;
251 TDEAction *m_configureAction;
252 TDEToggleAction *m_showRulerAction;
253 TDEToggleAction *m_showGridAction;
254 TDEToggleAction *m_snapGridAction;
255 TDEToggleAction *m_showPageMargins;
256 KoContextHelpAction *m_contextHelpAction;
257 TDEAction *m_deleteSelectionAction;
258 // line width
259 KoUnitDoubleSpinComboBox *m_setLineWidth;
260 KoLineStyleAction *m_lineStyleAction;
261
262 //dockers
263 KoPaletteManager *m_pPaletteManager;
264 VDocumentTab *m_DocumentTab;
265 VLayersTab *m_LayersTab;
266 VHistoryTab *m_HistoryTab;
267 VColorDocker *m_ColorManager;
268 VStrokeDocker *m_strokeDocker;
269 VStyleDocker *m_styleDocker;
270 VTransformDocker *m_TransformDocker;
271
272 VSelectToolBar *m_selectToolBar;
273
274 // dcop
275 DCOPObject *m_dcop;
276
277 //Status Bar
278 TQLabel *m_status; // Ordinary status
279 TQLabel *m_cursorCoords; // Cursor coordinates
280 VSmallPreview *m_smallPreview; // Stroke and Fill
281 VToolController *m_toolController;
282};
283
284#endif
285
Keeps track of visual per document properties.
Definition karbon_part.h:46
The base class for all karbon commands.
Definition vcommand.h:42
Manages the fill of shapes.
Definition vfill.h:45
Manages stroke properties.
Definition vstroke.h:49
This class...
Definition vtoolbox.h:29
The base class for all karbon tools.
Definition vtool.h:52