• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • objects
object_imp.h
Go to the documentation of this file.
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
2 
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.
7 
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.
12 
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., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #ifndef KIG_OBJECTS_OBJECT_IMP_H
19 #define KIG_OBJECTS_OBJECT_IMP_H
20 
21 #include "common.h"
22 
23 class IntImp;
24 class DoubleImp;
25 class StringImp;
26 class InvalidImp;
27 class HierarchyImp;
28 class TransformationImp;
29 class TestResultImp;
30 class LineImp;
31 class PointImp;
32 class TextImp;
33 class AngleImp;
34 class VectorImp;
35 class LocusImp;
36 class CircleImp;
37 class ConicImp;
38 class CubicImp;
39 class SegmentImp;
40 class RayImp;
41 class ArcImp;
42 class FilledPolygonImp;
43 class ClosedPolygonalImp;
44 class OpenPolygonalImp;
45 class BezierImp;
46 class RationalBezierImp;
47 
56 class ObjectImpVisitor
57 {
58 public:
59  virtual ~ObjectImpVisitor();
60  void visit( const ObjectImp* imp );
61  virtual void visit( const IntImp* imp );
62  virtual void visit( const DoubleImp* imp );
63  virtual void visit( const StringImp* imp );
64  virtual void visit( const InvalidImp* imp );
65  virtual void visit( const HierarchyImp* imp );
66  virtual void visit( const TransformationImp* imp );
67  virtual void visit( const TestResultImp* imp );
68  virtual void visit( const LineImp* imp );
69  virtual void visit( const PointImp* imp );
70  virtual void visit( const TextImp* imp );
71  virtual void visit( const AngleImp* imp );
72  virtual void visit( const VectorImp* imp );
73  virtual void visit( const LocusImp* imp );
74  virtual void visit( const CircleImp* imp );
75  virtual void visit( const ConicImp* imp );
76  virtual void visit( const CubicImp* imp );
77  virtual void visit( const SegmentImp* imp );
78  virtual void visit( const RayImp* imp );
79  virtual void visit( const ArcImp* imp );
80  virtual void visit( const FilledPolygonImp* imp );
81  virtual void visit( const ClosedPolygonalImp* imp );
82  virtual void visit( const OpenPolygonalImp* imp );
83  virtual void visit( const BezierImp* imp );
84  virtual void visit( const RationalBezierImp* imp );
85 };
86 
87 typedef unsigned int uint;
88 
95 class ObjectImpType
96 {
97  const ObjectImpType* mparent;
98  const char* minternalname;
99  const char* mtranslatedname;
100  const char* mselectstatement;
101  const char* mselectnamestatement;
102  const char* mremoveastatement;
103  const char* maddastatement;
104  const char* mmoveastatement;
105  const char* mattachtothisstatement;
106  const char* mshowastatement;
107  const char* mhideastatement;
108  class StaticPrivate;
109  static StaticPrivate* sd();
110 public:
118  static const ObjectImpType* typeFromInternalName( const char* n );
119 
140  ObjectImpType(
141  const ObjectImpType* parent, const char* internalname,
142  const char* translatedname,
143  const char* selectstatement,
144  const char* selectnamestatement,
145  const char* removeastatement,
146  const char* addastatement,
147  const char* moveastatement,
148  const char* attachtothisstatement,
149  const char* showastatement,
150  const char* hideastatement );
151  virtual ~ObjectImpType();
152 
157  bool inherits( const ObjectImpType* t ) const;
158  virtual bool match( const ObjectImpType* t ) const;
159 
165  const char* internalName() const;
169  QString translatedName() const;
175  const char* selectStatement() const;
176 
183  const char* selectNameStatement() const;
184 
189  QString removeAStatement() const;
194  QString addAStatement() const;
199  QString moveAStatement() const;
205  QString attachToThisStatement() const;
206 
211  QString showAStatement() const;
212 
217  QString hideAStatement() const;
218 };
219 
226 class ObjectImp
227 {
228 protected:
229  ObjectImp();
230 public:
235  static const ObjectImpType* stype();
236 
275  int getPropLid( int propgid ) const;
276  int getPropGid( const char *pname ) const;
277  const char* getPropName( int propgid ) const;
278 
279  virtual ~ObjectImp();
280 
295  bool inherits( const ObjectImpType* t ) const;
296 
313  virtual Coordinate attachPoint( ) const = 0;
314 
318  virtual ObjectImp* transform( const Transformation& t ) const = 0;
319 
320  virtual void draw( KigPainter& p ) const = 0;
321  virtual bool contains( const Coordinate& p, int width,
322  const KigWidget& si ) const = 0;
323  virtual bool inRect( const Rect& r, int width,
324  const KigWidget& si ) const = 0;
325  virtual Rect surroundingRect() const = 0;
326 
332  bool valid() const;
333 
334  virtual int numberOfProperties() const;
335  // the names of the properties as perceived by the user.. put
336  // I18N_NOOP's around them here..
337  virtual const QByteArrayList properties() const;
338  // the names of the properties as known only by kig internally. No
339  // need for I18N_NOOP. Preferably choose some lowercase name with
340  // only letters and dashes, no spaces..
341  virtual const QByteArrayList propertiesInternalNames() const;
342  virtual ObjectImp* property( int which, const KigDocument& d ) const;
343  // Sometimes we need to know which type an imp needs to be at least
344  // in order to have the imp with number which. Macro's need it
345  // foremost. This function answers that question..
346  virtual const ObjectImpType* impRequirementForProperty( int which ) const;
347  // Return whether the property with number which is by construction
348  // always a point on this curve ( if this is a curve ), or always a
349  // curve through this point ( if this is a curve ).
350  virtual bool isPropertyDefinedOnOrThroughThisImp( int which ) const;
351  // What icon should be shown when talking about this property ?
352  virtual const char* iconForProperty( int which ) const;
353 
369  virtual const ObjectImpType* type() const = 0;
370  virtual void visit( ObjectImpVisitor* vtor ) const = 0;
371 
377  virtual ObjectImp* copy() const = 0;
378 
379  // s is a string with at least one escape ( "%N" where N is a
380  // number ) somewhere. This function replaces the first escape it
381  // sees with the "value" of this imp ( using the QString::arg
382  // functions ). This is e.g. used by TextType to turn its variable
383  // args into strings..
384  // if you implement this, then you should return true in
385  // canFillInEscape() ( standard implementation returns false ), and
386  // override fillInNextEscape() ( standard implementation does an
387  // assert( false ) )..
388  virtual bool canFillInNextEscape() const;
389  virtual void fillInNextEscape( QString& s, const KigDocument& ) const;
390 
398  virtual bool equals( const ObjectImp& rhs ) const = 0;
399 
408  virtual bool isCache() const;
409 };
410 #endif
ClosedPolygonalImp
An ObjectImp representing a closed polygonal.
Definition: polygon_imp.h:130
BezierImp
An ObjectImp representing polynomial Bézier Curve.
Definition: bezier_imp.h:31
ObjectImpVisitor::~ObjectImpVisitor
virtual ~ObjectImpVisitor()
Definition: object_imp.cc:174
CubicImp
An ObjectImp representing a cubic.
Definition: cubic_imp.h:29
LocusImp
LocusImp is an imp that consists of a copy of the curveimp that the moving point moves over...
Definition: locus_imp.h:57
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
ObjectImp::inherits
bool inherits(const ObjectImpType *t) const
Returns true if this ObjectImp inherits the ObjectImp type represented by t.
Definition: object_imp.cc:279
StringImp
This ObjectImp is a BogusImp containing only a string value.
Definition: bogus_imp.h:167
OpenPolygonalImp
An ObjectImp representing an open polygonal.
Definition: polygon_imp.h:157
ObjectImpType::match
virtual bool match(const ObjectImpType *t) const
Definition: object_imp.cc:230
ObjectImp::~ObjectImp
virtual ~ObjectImp()
Definition: object_imp.cc:37
ObjectImpVisitor::visit
void visit(const ObjectImp *imp)
Definition: object_imp.cc:81
CircleImp
An ObjectImp representing a circle.
Definition: circle_imp.h:27
ObjectImp::impRequirementForProperty
virtual const ObjectImpType * impRequirementForProperty(int which) const
Definition: object_imp.cc:76
ObjectImp::visit
virtual void visit(ObjectImpVisitor *vtor) const =0
TextImp
Definition: text_imp.h:26
ObjectImp::property
virtual ObjectImp * property(int which, const KigDocument &d) const
Definition: object_imp.cc:70
ObjectImpType::internalName
const char * internalName() const
Returns an internal name for this ObjectImp type.
Definition: object_imp.cc:235
RayImp
An ObjectImp representing a ray.
Definition: line_imp.h:136
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
ObjectImp::getPropLid
int getPropLid(int propgid) const
mp: The following three methods (getPropLid, getPropGid, getPropName) deal with the properties of Obj...
Definition: object_imp.cc:347
RationalBezierImp
An ObjectImp representing a rational Bézier curve.
Definition: bezier_imp.h:100
ObjectImpType::inherits
bool inherits(const ObjectImpType *t) const
Does the ObjectImp type represented by this instance inherit the ObjectImp type represented by t ...
Definition: object_imp.cc:224
ObjectImp::propertiesInternalNames
virtual const QByteArrayList propertiesInternalNames() const
Definition: object_imp.cc:63
ObjectImp::stype
static const ObjectImpType * stype()
The ObjectImpType representing the base ObjectImp class.
Definition: object_imp.cc:284
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
VectorImp
An ObjectImp representing a vector.
Definition: other_imp.h:99
ObjectImp::canFillInNextEscape
virtual bool canFillInNextEscape() const
Definition: object_imp.cc:192
ObjectImp::type
virtual const ObjectImpType * type() const =0
Returns the lowermost ObjectImpType that this object is an instantiation of.
common.h
ObjectImp::iconForProperty
virtual const char * iconForProperty(int which) const
Definition: object_imp.cc:187
ObjectImpType::translatedName
QString translatedName() const
The name of this type, translated to the currently used language.
Definition: object_imp.cc:240
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
ObjectImpType::selectStatement
const char * selectStatement() const
Returns a translatable string of the form "Select this %1".
Definition: object_imp.cc:245
PointImp
An ObjectImp representing a point.
Definition: point_imp.h:27
ObjectImpType::selectNameStatement
const char * selectNameStatement() const
Returns a translatable string of the form "Select point %1".
Definition: object_imp.cc:250
Transformation
Class representing a transformation.
Definition: kigtransform.h:37
ObjectImpType::moveAStatement
QString moveAStatement() const
Returns a translated string of the form "Move a xxx".
Definition: object_imp.cc:265
ObjectImpType::hideAStatement
QString hideAStatement() const
Returns a translated string of the form "Hide a xxx".
Definition: object_imp.cc:321
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
TransformationImp
Definition: bogus_imp.h:232
HierarchyImp
Definition: bogus_imp.h:203
ObjectImp::isPropertyDefinedOnOrThroughThisImp
virtual bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: object_imp.cc:326
ObjectImp::attachPoint
virtual Coordinate attachPoint() const =0
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
ConicImp
An ObjectImp representing a conic.
Definition: conic_imp.h:39
ObjectImp::inRect
virtual bool inRect(const Rect &r, int width, const KigWidget &si) const =0
ObjectImpType::typeFromInternalName
static const ObjectImpType * typeFromInternalName(const char *n)
Returns the type with name n.
Definition: object_imp.cc:270
ObjectImp::getPropName
const char * getPropName(int propgid) const
Definition: object_imp.cc:356
ObjectImpType::removeAStatement
QString removeAStatement() const
Returns a translated string of the form "Remove a xxx".
Definition: object_imp.cc:255
ObjectImp::ObjectImp
ObjectImp()
Definition: object_imp.cc:33
ObjectImp::surroundingRect
virtual Rect surroundingRect() const =0
DoubleImp
This ObjectImp is a BogusImp containing only a double value.
Definition: bogus_imp.h:89
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
LineImp
An ObjectImp representing a line.
Definition: line_imp.h:184
ObjectImp::copy
virtual ObjectImp * copy() const =0
Returns a copy of this ObjectImp.
ObjectImp::draw
virtual void draw(KigPainter &p) const =0
ObjectImp::contains
virtual bool contains(const Coordinate &p, int width, const KigWidget &si) const =0
ArcImp
An ObjectImp representing an arc.
Definition: other_imp.h:169
ObjectImpType::~ObjectImpType
virtual ~ObjectImpType()
Definition: object_imp.cc:220
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
ObjectImpType::attachToThisStatement
QString attachToThisStatement() const
Returns a translated string of the form "Attach to this xxx".
Definition: object_imp.cc:311
ObjectImp::valid
bool valid() const
Returns true if this is a valid ObjectImp.
Definition: object_imp.cc:41
ObjectImp::isCache
virtual bool isCache() const
Definition: object_imp.cc:306
ObjectImpType::ObjectImpType
ObjectImpType(const ObjectImpType *parent, const char *internalname, const char *translatedname, const char *selectstatement, const char *selectnamestatement, const char *removeastatement, const char *addastatement, const char *moveastatement, const char *attachtothisstatement, const char *showastatement, const char *hideastatement)
Definition: object_imp.cc:197
ObjectImpType::addAStatement
QString addAStatement() const
Returns a translated string of the form "Add a xxx".
Definition: object_imp.cc:260
FilledPolygonImp
An ObjectImp representing a filled polygon.
Definition: polygon_imp.h:101
ObjectImp::fillInNextEscape
virtual void fillInNextEscape(QString &s, const KigDocument &) const
Definition: object_imp.cc:46
ObjectImp::equals
virtual bool equals(const ObjectImp &rhs) const =0
Returns true if this ObjectImp is equal to rhs.
ObjectImpType::showAStatement
QString showAStatement() const
Returns a translated string of the form "Show a xxx".
Definition: object_imp.cc:316
ObjectImp::transform
virtual ObjectImp * transform(const Transformation &t) const =0
Return this ObjectImp, transformed by the transformation t.
TestResultImp
Definition: bogus_imp.h:253
ObjectImp::numberOfProperties
virtual int numberOfProperties() const
Definition: object_imp.cc:58
uint
unsigned int uint
Definition: object_imp.h:87
ObjectImp::getPropGid
int getPropGid(const char *pname) const
Definition: object_imp.cc:333
ObjectImpVisitor
Definition: object_imp.h:56
ObjectImp::properties
virtual const QByteArrayList properties() const
Definition: object_imp.cc:51
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
AngleImp
An ObjectImp representing an angle.
Definition: other_imp.h:28
SegmentImp
An ObjectImp representing a segment.
Definition: line_imp.h:81
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal