karbon

vobject.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, The Karbon Developers
3 Copyright (C) 2002, The Karbon Developers
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef __VOBJECT_H__
22#define __VOBJECT_H__
23
24
25#include <KoRect.h>
26#include <dcopobject.h>
27#include <koffice_export.h>
28
29class TQDomElement;
30class VDocument;
31class VFill;
32class VPainter;
33class VStroke;
34class VVisitor;
35class DCOPObject;
36class KoStore;
37class KoXmlWriter;
38class KoOasisLoadingContext;
39class KoGenStyles;
40class KoGenStyle;
41
49class KARBONBASE_EXPORT VObject
50{
51public:
52 enum VState
53 {
54 normal = 0,
55 normal_locked = 1,
56 hidden = 2,
57 hidden_locked = 3,
58 deleted = 4,
60 // shape specific states:
61 selected = 5,
62 edit = 6
63 };
64
71 VObject( VObject* parent, VState state = edit );
72
79 VObject( const VObject& obj );
80
84 virtual ~VObject();
85
91 virtual DCOPObject* dcopObject();
92
100 virtual void draw( VPainter* painter, const KoRect* rect = 0L ) const
101 {
102 Q_UNUSED( painter );
103 Q_UNUSED( rect );
104 }
105
111 virtual const KoRect& boundingBox() const
112 { return m_boundingBox; }
113
120 { return m_boundingBoxIsInvalid; }
121
128 {
129 m_boundingBoxIsInvalid = true;
130
131 if( m_parent )
132 m_parent->invalidateBoundingBox();
133 }
134
140 void setParent( VObject* parent ) { m_parent = parent; }
141
147 VObject* parent() const { return m_parent; }
148
154 VState state() const { return m_state; }
155
163 virtual void setState( const VState state ) { m_state = state; }
164
170 virtual VStroke* stroke() const { return m_stroke; }
171
177 virtual VFill* fill() const { return m_fill; }
178
184 virtual void setStroke( const VStroke& stroke );
185
191 virtual void setFill( const VFill& fill );
192
198 virtual void save( TQDomElement& element ) const;
199
207 virtual void saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles, int &index ) const;
208
215 virtual void load( const TQDomElement& element );
216
224 virtual bool loadOasis( const TQDomElement &element, KoOasisLoadingContext &context );
225
231 virtual VObject* clone() const = 0;
232
236 virtual void accept( VVisitor& /*visitor*/ )
237 { }
238
246 virtual void insertInfrontOf( VObject* newObject, VObject* oldObject )
247 {
248 Q_UNUSED( newObject );
249 Q_UNUSED( oldObject );
250 }
251
257 virtual TQString name() const;
258
264 void setName( const TQString &s );
265
271 VDocument *document() const;
272
273protected:
280 void addStyles( const TQDomElement* style, KoOasisLoadingContext & context );
281
282 virtual void saveOasisFill( KoGenStyles &mainStyles, KoGenStyle &stylesojectauto ) const;
283
284protected:
285 mutable KoRect m_boundingBox;
286 mutable VState m_state : 8;
287 mutable bool m_boundingBoxIsInvalid : 1;
292 DCOPObject *m_dcop;
294private:
295 VObject* m_parent;
296};
297
298#endif
299
All non-visual, static doc info is in here.
Definition vdocument.h:53
Manages the fill of shapes.
Definition vfill.h:45
The base class for all karbon objects.
Definition vobject.h:50
bool m_boundingBoxIsInvalid
the flag stating if the bounding box is valid
Definition vobject.h:287
DCOPObject * m_dcop
the object's DCOP object
Definition vobject.h:292
bool boundingBoxIsInvalid() const
Checks if the bounding box is invalid and needs to be recalculated.
Definition vobject.h:119
virtual VObject * clone() const =0
Create an exact copy of this object.
virtual void setState(const VState state)
Sets the state to a specified new state.
Definition vobject.h:163
VObject * parent() const
Returns pointer to current parent object.
Definition vobject.h:147
virtual void accept(VVisitor &)
Accept a VVisitor.
Definition vobject.h:236
VState m_state
the object's state
Definition vobject.h:286
VStroke * m_stroke
the object's stroke
Definition vobject.h:289
void setParent(VObject *parent)
Sets a new parent object.
Definition vobject.h:140
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
Definition vobject.h:111
VFill * m_fill
the object's fill
Definition vobject.h:290
void invalidateBoundingBox()
Invalidates the bounding box, so it has to be recalculated.
Definition vobject.h:127
virtual VFill * fill() const
Gets the object's actual fill.
Definition vobject.h:177
KoRect m_boundingBox
the object's bounding box
Definition vobject.h:285
virtual VStroke * stroke() const
Gets the object's actual stroke.
Definition vobject.h:170
virtual void insertInfrontOf(VObject *newObject, VObject *oldObject)
This function is important for undo/redo.
Definition vobject.h:246
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
Definition vobject.h:100
VState state() const
Get the state the object is in.
Definition vobject.h:154
Manages stroke properties.
Definition vstroke.h:49
The abstract visitor class.
Definition vvisitor.h:51