karbon

vobject.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, The Karbon Developers
00003    Copyright (C) 2002, The Karbon Developers
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __VOBJECT_H__
00022 #define __VOBJECT_H__
00023 
00024 
00025 #include <KoRect.h>
00026 #include <dcopobject.h>
00027 #include <koffice_export.h>
00028 
00029 class QDomElement;
00030 class VDocument;
00031 class VFill;
00032 class VPainter;
00033 class VStroke;
00034 class VVisitor;
00035 class DCOPObject;
00036 class KoStore;
00037 class KoXmlWriter;
00038 class KoOasisLoadingContext;
00039 class KoGenStyles;
00040 class KoGenStyle;
00041 
00049 class KARBONBASE_EXPORT VObject
00050 {
00051 public:
00052     enum VState
00053     {
00054         normal        = 0,  
00055         normal_locked = 1,  
00056         hidden        = 2,  
00057         hidden_locked = 3,  
00058         deleted       = 4,  
00060         // shape specific states:
00061         selected      = 5,  
00062         edit          = 6   
00063     };
00064 
00071     VObject( VObject* parent, VState state = edit );
00072     
00079     VObject( const VObject& obj );
00080 
00084     virtual ~VObject();
00085 
00091     virtual DCOPObject* dcopObject();
00092 
00100     virtual void draw( VPainter* painter, const KoRect* rect = 0L ) const 
00101     { 
00102         Q_UNUSED( painter );
00103         Q_UNUSED( rect );
00104     }
00105 
00111     virtual const KoRect& boundingBox() const
00112         { return m_boundingBox; }
00113 
00119     bool boundingBoxIsInvalid() const
00120         { return m_boundingBoxIsInvalid; }
00121 
00127     void invalidateBoundingBox()
00128     {
00129         m_boundingBoxIsInvalid = true;
00130 
00131         if( m_parent )
00132             m_parent->invalidateBoundingBox();
00133     }
00134 
00140     void setParent( VObject* parent ) { m_parent = parent; }
00141 
00147     VObject* parent() const { return m_parent; }
00148 
00154     VState state() const { return m_state; }
00155 
00163     virtual void setState( const VState state ) { m_state = state; }
00164 
00170     virtual VStroke* stroke() const { return m_stroke; }
00171 
00177     virtual VFill* fill() const { return m_fill; }
00178 
00184     virtual void setStroke( const VStroke& stroke );
00185 
00191     virtual void setFill( const VFill& fill );
00192 
00198     virtual void save( QDomElement& element ) const;
00199 
00207     virtual void saveOasis( KoStore *store, KoXmlWriter *docWriter, KoGenStyles &mainStyles, int &index ) const;
00208 
00215     virtual void load( const QDomElement& element );
00216 
00224     virtual bool loadOasis( const QDomElement &element, KoOasisLoadingContext &context );
00225 
00231     virtual VObject* clone() const = 0;
00232 
00236     virtual void accept( VVisitor& /*visitor*/ ) 
00237         { }
00238 
00246     virtual void insertInfrontOf( VObject* newObject, VObject* oldObject )
00247     { 
00248         Q_UNUSED( newObject );
00249         Q_UNUSED( oldObject );
00250     }
00251 
00257     virtual QString name() const;
00258     
00264     void setName( const QString &s );
00265 
00271     VDocument *document() const;
00272 
00273 protected:
00280     void addStyles( const QDomElement* style, KoOasisLoadingContext & context );
00281 
00282     virtual void saveOasisFill( KoGenStyles &mainStyles, KoGenStyle &stylesojectauto ) const;
00283 
00284 protected:
00285     mutable KoRect m_boundingBox; 
00286     mutable VState m_state              : 8; 
00287     mutable bool m_boundingBoxIsInvalid : 1; 
00289     VStroke* m_stroke; 
00290     VFill* m_fill; 
00292     DCOPObject *m_dcop; 
00294 private:
00295     VObject* m_parent;
00296 };
00297 
00298 #endif
00299 
KDE Home | KDE Accessibility Home | Description of Access Keys