Kig Python Scripting API Documentation

object_imp.h

00001 // Copyright (C)  2002  Dominique Devriese <devriese@kde.org>
00002 
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00016 // 02110-1301, USA.
00017 
00018 #ifndef KIG_OBJECTS_OBJECT_IMP_H
00019 #define KIG_OBJECTS_OBJECT_IMP_H
00020 
00021 #include "common.h"
00022 
00023 class IntImp;
00024 class DoubleImp;
00025 class StringImp;
00026 class InvalidImp;
00027 class HierarchyImp;
00028 class TransformationImp;
00029 class TestResultImp;
00030 class CurveImp;
00031 class LineImp;
00032 class PointImp;
00033 class TextImp;
00034 class AngleImp;
00035 class VectorImp;
00036 class LocusImp;
00037 class CircleImp;
00038 class ConicImp;
00039 class CubicImp;
00040 class SegmentImp;
00041 class RayImp;
00042 class ArcImp;
00043 class PolygonImp;
00044 
00053 class ObjectImpVisitor
00054 {
00055 public:
00056   virtual ~ObjectImpVisitor();
00057   void visit( const ObjectImp* imp );
00058   virtual void visit( const IntImp* imp );
00059   virtual void visit( const DoubleImp* imp );
00060   virtual void visit( const StringImp* imp );
00061   virtual void visit( const InvalidImp* imp );
00062   virtual void visit( const HierarchyImp* imp );
00063   virtual void visit( const TransformationImp* imp );
00064   virtual void visit( const TestResultImp* imp );
00065   virtual void visit( const LineImp* imp );
00066   virtual void visit( const PointImp* imp );
00067   virtual void visit( const TextImp* imp );
00068   virtual void visit( const AngleImp* imp );
00069   virtual void visit( const VectorImp* imp );
00070   virtual void visit( const LocusImp* imp );
00071   virtual void visit( const CircleImp* imp );
00072   virtual void visit( const ConicImp* imp );
00073   virtual void visit( const CubicImp* imp );
00074   virtual void visit( const SegmentImp* imp );
00075   virtual void visit( const RayImp* imp );
00076   virtual void visit( const ArcImp* imp );
00077   virtual void visit( const PolygonImp* imp );
00078 };
00079 
00080 typedef unsigned int uint;
00081 
00088 class ObjectImpType
00089 {
00090   const ObjectImpType* mparent;
00091   const char* minternalname;
00092   const char* mtranslatedname;
00093   const char* mselectstatement;
00094   const char* mselectnamestatement;
00095   const char* mremoveastatement;
00096   const char* maddastatement;
00097   const char* mmoveastatement;
00098   const char* mattachtothisstatement;
00099   const char* mshowastatement;
00100   const char* mhideastatement;
00101   class StaticPrivate;
00102   static StaticPrivate* sd();
00103 public:
00111   static const ObjectImpType* typeFromInternalName( const char* n );
00112 
00133   ObjectImpType(
00134     const ObjectImpType* parent, const char* internalname,
00135     const char* translatedname,
00136     const char* selectstatement,
00137     const char* selectnamestatement,
00138     const char* removeastatement,
00139     const char* addastatement,
00140     const char* moveastatement,
00141     const char* attachtothisstatement,
00142     const char* showastatement,
00143     const char* hideastatement );
00144   ~ObjectImpType();
00145 
00150   bool inherits( const ObjectImpType* t ) const;
00151 
00157   const char* internalName() const;
00161   TQString translatedName() const;
00167   const char* selectStatement() const;
00168 
00175   const char* selectNameStatement() const;
00176 
00181   TQString removeAStatement() const;
00186   TQString addAStatement() const;
00191   TQString moveAStatement() const;
00197   TQString attachToThisStatement() const;
00198 
00203   TQString showAStatement() const;
00204 
00209   TQString hideAStatement() const;
00210 };
00211 
00218 class ObjectImp
00219 {
00220 protected:
00221   ObjectImp();
00222 public:
00227   static const ObjectImpType* stype();
00228 
00229   virtual ~ObjectImp();
00230 
00245   bool inherits( const ObjectImpType* t ) const;
00246 
00263   virtual Coordinate attachPoint( ) const = 0;
00264 
00268   virtual ObjectImp* transform( const Transformation& t ) const = 0;
00269 
00270   virtual void draw( KigPainter& p ) const = 0;
00271   virtual bool contains( const Coordinate& p, int width,
00272                          const KigWidget& si ) const = 0;
00273   virtual bool inRect( const Rect& r, int width,
00274                        const KigWidget& si ) const = 0;
00275   virtual Rect surroundingRect() const = 0;
00276 
00282   bool valid() const;
00283 
00284   virtual const uint numberOfProperties() const;
00285   // the names of the properties as perceived by the user..  put
00286   // I18N_NOOP's around them here..
00287   virtual const QCStringList properties() const;
00288   // the names of the properties as known only by kig internally.  No
00289   // need for I18N_NOOP.  Preferably choose some lowercase name with
00290   // only letters and dashes, no spaces..
00291   virtual const QCStringList propertiesInternalNames() const;
00292   virtual ObjectImp* property( uint which, const KigDocument& d ) const;
00293   // Sometimes we need to know which type an imp needs to be at least
00294   // in order to have the imp with number which.  Macro's need it
00295   // foremost.  This function answers that question..
00296   virtual const ObjectImpType* impRequirementForProperty( uint which ) const;
00297   // Return whether the property with number which is by construction
00298   // always a point on this curve ( if this is a curve ), or always a
00299   // curve through this point ( if this is a curve ).
00300   virtual bool isPropertyDefinedOnOrThroughThisImp( uint which ) const;
00301   // What icon should be shown when talking about this property ?
00302   virtual const char* iconForProperty( uint which ) const;
00303 
00319   virtual const ObjectImpType* type() const = 0;
00320   virtual void visit( ObjectImpVisitor* vtor ) const = 0;
00321 
00327   virtual ObjectImp* copy() const = 0;
00328 
00329   // s is a string with at least one escape ( "%N" where N is a
00330   // number ) somewhere.  This function replaces the first escape it
00331   // sees with the "value" of this imp ( using the TQString::arg
00332   // functions ).  This is e.g. used by TextType to turn its variable
00333   // args into strings..
00334   // if you implement this, then you should return true in
00335   // canFillInEscape() ( standard implementation returns false ), and
00336   // override fillInNextEscape() ( standard implementation does an
00337   // assert( false ) )..
00338   virtual bool canFillInNextEscape() const;
00339   virtual void fillInNextEscape( TQString& s, const KigDocument& ) const;
00340 
00348   virtual bool equals( const ObjectImp& rhs ) const = 0;
00349 
00358   virtual bool isCache() const;
00359 };
00360 #endif
KDE Logo
This file is part of the documentation for tdelibs 0.10.7.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Fri Mar 15 2019 03:57:05 by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2001