Kig Python Scripting API Documentation

object_imp.h
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 CurveImp;
31 class LineImp;
32 class PointImp;
33 class TextImp;
34 class AngleImp;
35 class VectorImp;
36 class LocusImp;
37 class CircleImp;
38 class ConicImp;
39 class CubicImp;
40 class SegmentImp;
41 class RayImp;
42 class ArcImp;
43 class PolygonImp;
44 
53 class ObjectImpVisitor
54 {
55 public:
56  virtual ~ObjectImpVisitor();
57  void visit( const ObjectImp* imp );
58  virtual void visit( const IntImp* imp );
59  virtual void visit( const DoubleImp* imp );
60  virtual void visit( const StringImp* imp );
61  virtual void visit( const InvalidImp* imp );
62  virtual void visit( const HierarchyImp* imp );
63  virtual void visit( const TransformationImp* imp );
64  virtual void visit( const TestResultImp* imp );
65  virtual void visit( const LineImp* imp );
66  virtual void visit( const PointImp* imp );
67  virtual void visit( const TextImp* imp );
68  virtual void visit( const AngleImp* imp );
69  virtual void visit( const VectorImp* imp );
70  virtual void visit( const LocusImp* imp );
71  virtual void visit( const CircleImp* imp );
72  virtual void visit( const ConicImp* imp );
73  virtual void visit( const CubicImp* imp );
74  virtual void visit( const SegmentImp* imp );
75  virtual void visit( const RayImp* imp );
76  virtual void visit( const ArcImp* imp );
77  virtual void visit( const PolygonImp* imp );
78 };
79 
80 typedef unsigned int uint;
81 
88 class ObjectImpType
89 {
90  const ObjectImpType* mparent;
91  const char* minternalname;
92  const char* mtranslatedname;
93  const char* mselectstatement;
94  const char* mselectnamestatement;
95  const char* mremoveastatement;
96  const char* maddastatement;
97  const char* mmoveastatement;
98  const char* mattachtothisstatement;
99  const char* mshowastatement;
100  const char* mhideastatement;
101  class StaticPrivate;
102  static StaticPrivate* sd();
103 public:
111  static const ObjectImpType* typeFromInternalName( const char* n );
112 
133  ObjectImpType(
134  const ObjectImpType* parent, const char* internalname,
135  const char* translatedname,
136  const char* selectstatement,
137  const char* selectnamestatement,
138  const char* removeastatement,
139  const char* addastatement,
140  const char* moveastatement,
141  const char* attachtothisstatement,
142  const char* showastatement,
143  const char* hideastatement );
144  ~ObjectImpType();
145 
150  bool inherits( const ObjectImpType* t ) const;
151 
157  const char* internalName() const;
161  TQString translatedName() const;
167  const char* selectStatement() const;
168 
175  const char* selectNameStatement() const;
176 
181  TQString removeAStatement() const;
186  TQString addAStatement() const;
191  TQString moveAStatement() const;
197  TQString attachToThisStatement() const;
198 
203  TQString showAStatement() const;
204 
209  TQString hideAStatement() const;
210 };
211 
218 class ObjectImp
219 {
220 protected:
221  ObjectImp();
222 public:
227  static const ObjectImpType* stype();
228 
229  virtual ~ObjectImp();
230 
245  bool inherits( const ObjectImpType* t ) const;
246 
263  virtual Coordinate attachPoint( ) const = 0;
264 
268  virtual ObjectImp* transform( const Transformation& t ) const = 0;
269 
270  virtual void draw( KigPainter& p ) const = 0;
271  virtual bool contains( const Coordinate& p, int width,
272  const KigWidget& si ) const = 0;
273  virtual bool inRect( const Rect& r, int width,
274  const KigWidget& si ) const = 0;
275  virtual Rect surroundingRect() const = 0;
276 
282  bool valid() const;
283 
284  virtual const uint numberOfProperties() const;
285  // the names of the properties as perceived by the user.. put
286  // I18N_NOOP's around them here..
287  virtual const QCStringList properties() const;
288  // the names of the properties as known only by kig internally. No
289  // need for I18N_NOOP. Preferably choose some lowercase name with
290  // only letters and dashes, no spaces..
291  virtual const QCStringList propertiesInternalNames() const;
292  virtual ObjectImp* property( uint which, const KigDocument& d ) const;
293  // Sometimes we need to know which type an imp needs to be at least
294  // in order to have the imp with number which. Macro's need it
295  // foremost. This function answers that question..
296  virtual const ObjectImpType* impRequirementForProperty( uint which ) const;
297  // Return whether the property with number which is by construction
298  // always a point on this curve ( if this is a curve ), or always a
299  // curve through this point ( if this is a curve ).
300  virtual bool isPropertyDefinedOnOrThroughThisImp( uint which ) const;
301  // What icon should be shown when talking about this property ?
302  virtual const char* iconForProperty( uint which ) const;
303 
319  virtual const ObjectImpType* type() const = 0;
320  virtual void visit( ObjectImpVisitor* vtor ) const = 0;
321 
327  virtual ObjectImp* copy() const = 0;
328 
329  // s is a string with at least one escape ( "%N" where N is a
330  // number ) somewhere. This function replaces the first escape it
331  // sees with the "value" of this imp ( using the TQString::arg
332  // functions ). This is e.g. used by TextType to turn its variable
333  // args into strings..
334  // if you implement this, then you should return true in
335  // canFillInEscape() ( standard implementation returns false ), and
336  // override fillInNextEscape() ( standard implementation does an
337  // assert( false ) )..
338  virtual bool canFillInNextEscape() const;
339  virtual void fillInNextEscape( TQString& s, const KigDocument& ) const;
340 
348  virtual bool equals( const ObjectImp& rhs ) const = 0;
349 
358  virtual bool isCache() const;
359 };
360 #endif
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
Class representing a transformation.
Definition: kigtransform.h:37
KDE Logo
This file is part of the documentation for tdelibs .
Documentation copyright © 1996-2002 the KDE developers.
Generated on Tue Feb 25 2025 13:46:37 by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001