1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #include "object_imp.h"
22 #include "../misc/object_hierarchy.h"
23 #include "../misc/kigtransform.h"
28 * This is the base class for the so-called BogusImp's. These
29 * ObjectImp's are not really ObjectImp's, in that they don't
30 * represent objects. They exist because ObjectImp's also serve
31 * another purpose, namely containing data. They can all be loaded
32 * and saved, and the only difference between these objects and normal
33 * objects are that these serve *only* to be loaded and saved. This
34 * approach adds a lot of flexibility to the Kig system, and has
35 * certainly proven itself very valuable.
40 typedef ObjectImp Parent
;
43 * Returns the ObjectImpType representing the BogusImp type.
45 static const ObjectImpType
* stype();
47 Coordinate
attachPoint( ) const;
48 void draw( KigPainter
& p
) const;
49 bool contains( const Coordinate
& p
, int width
, const KigWidget
& w
) const;
50 bool inRect( const Rect
& r
, int width
, const KigWidget
& w
) const;
51 Rect
surroundingRect() const;
53 ObjectImp
* transform( const Transformation
& ) const;
57 * This ObjectImp represents an invalid object. If a calculation
58 * fails, then often an InvalidImp is returned, indicating that the
59 * generated object is invalid.
66 * Returns the ObjectImpType representing the InvalidImp type.
68 static const ObjectImpType
* stype();
69 typedef BogusImp Parent
;
72 * Construct a new InvalidImp.
75 InvalidImp
* copy() const;
77 const ObjectImpType
* type() const;
78 void visit( ObjectImpVisitor
* vtor
) const;
80 bool canFillInNextEscape() const;
81 void fillInNextEscape( QString
& s
, const KigDocument
& ) const;
83 bool equals( const ObjectImp
& rhs
) const;
87 * This ObjectImp is a BogusImp containing only a double value.
95 * Returns the ObjectImpType representing the DoubleImp type.
97 static const ObjectImpType
* stype();
98 typedef BogusImp Parent
;
101 * Construct a new DoubleImp containing the value d.
103 DoubleImp( const double d
);
106 * Get hold of the contained data.
108 double data() const { return mdata
; };
110 * Set the contained data to d.
112 void setData( double d
) { mdata
= d
; };
114 DoubleImp
* copy() const;
116 const ObjectImpType
* type() const;
117 void visit( ObjectImpVisitor
* vtor
) const;
119 bool canFillInNextEscape() const;
120 void fillInNextEscape( QString
& s
, const KigDocument
& ) const;
122 bool equals( const ObjectImp
& rhs
) const;
126 * This ObjectImp is a BogusImp containing only an int value.
134 * Returns the ObjectImpType representing the IntImp type..
136 static const ObjectImpType
* stype();
137 typedef BogusImp Parent
;
140 * Construct a new IntImp containing the value d.
142 IntImp( const int d
);
145 * Get hold of the contained data.
147 int data() const { return mdata
; };
149 * Set the contained data to d.
151 void setData( int d
) { mdata
= d
; }
153 IntImp
* copy() const;
155 const ObjectImpType
* type() const;
156 void visit( ObjectImpVisitor
* vtor
) const;
158 bool canFillInNextEscape() const;
159 void fillInNextEscape( QString
& s
, const KigDocument
& ) const;
161 bool equals( const ObjectImp
& rhs
) const;
165 * This ObjectImp is a BogusImp containing only a string value.
173 * Returns the ObjectImpType representing the StringImp type..
175 static const ObjectImpType
* stype();
176 typedef BogusImp Parent
;
179 * Construct a new StringImp containing the string d.
181 StringImp( const QString
& d
);
184 * Get hold of the contained data.
186 const QString
& data() const { return mdata
; };
188 * Set the contained data.
190 void setData( const QString
& s
) { mdata
= s
; }
192 StringImp
* copy() const;
194 const ObjectImpType
* type() const;
195 void visit( ObjectImpVisitor
* vtor
) const;
197 bool canFillInNextEscape() const;
198 void fillInNextEscape( QString
& s
, const KigDocument
& ) const;
200 bool equals( const ObjectImp
& rhs
) const;
206 ObjectHierarchy mdata
;
208 static const ObjectImpType
* stype();
209 typedef BogusImp Parent
;
211 HierarchyImp( const ObjectHierarchy
& h
);
213 const ObjectHierarchy
& data() const { return mdata
; };
214 void setData( const ObjectHierarchy
& h
) { mdata
= h
; };
216 HierarchyImp
* copy() const;
217 const char* baseName() const;
219 const ObjectImpType
* type() const;
220 void visit( ObjectImpVisitor
* vtor
) const;
222 bool equals( const ObjectImp
& rhs
) const;
226 * \internal Don't mistake this imp for something that draws a
227 * transformed object. It does something completely different. It's
228 * a pure data Imp, like DoubleImp and friends that serves only to
229 * store the data of a transformation ( see the Transformation class
230 * in ../misc/kigtransform.h
232 class TransformationImp
235 Transformation mdata
;
237 static const ObjectImpType
* stype();
238 typedef BogusImp Parent
;
240 TransformationImp( const Transformation
& h
);
242 const Transformation
& data() const { return mdata
; };
243 void setData( const Transformation
& h
) { mdata
= h
; };
245 TransformationImp
* copy() const;
247 const ObjectImpType
* type() const;
248 void visit( ObjectImpVisitor
* vtor
) const;
250 bool equals( const ObjectImp
& rhs
) const;
258 static const ObjectImpType
* stype();
259 typedef BogusImp Parent
;
261 TestResultImp( const QString
& s
);
263 TestResultImp
* copy() const;
265 const QString
& data() const { return mdata
; };
267 const ObjectImpType
* type() const;
268 void visit( ObjectImpVisitor
* vtor
) const;
270 const uint
numberOfProperties() const;
271 const QCStringList
properties() const;
272 const QCStringList
propertiesInternalNames() const;
273 ObjectImp
* property( uint which
, const KigDocument
& d
) const;
274 const char* iconForProperty( uint which
) const;
275 const ObjectImpType
* impRequirementForProperty( uint which
) const;
276 bool isPropertyDefinedOnOrThroughThisImp( uint which
) const;
278 bool equals( const ObjectImp
& rhs
) const;