karbon

vtext.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002, The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VTEXT_H__
00021 #define __VTEXT_H__
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include <qptrlist.h>
00028 #include <qstring.h>
00029 #include <qfont.h>
00030 #include <koffice_export.h>
00031 
00032 #include "vpath.h"
00033 #include "vcomposite.h"
00034 
00035 class VGroup;
00036 
00037 typedef QPtrList<VPath> VPathList;
00038 typedef QPtrListIterator<VPath> VPathListIterator;
00039 
00040 #ifdef Above
00041 #undef Above
00042 #endif
00043 
00044 class KARBONBASE_EXPORT VText : public VObject
00045 {
00046 public:
00047     enum Position {
00048         Above,
00049         On,
00050         Under
00051     };
00052 
00053     enum Alignment {
00054         Left,
00055         Center,
00056         Right
00057     };
00058 
00059     VText( VObject* parent, VState state = normal );
00060     VText( const QFont &font, const VSubpath& basePath, Position position, Alignment alignment, const QString& text );
00061     VText( const VText& text );
00062     virtual ~VText();
00063     virtual DCOPObject* dcopObject();
00064 
00065     virtual void setText( const QString& text );
00066     virtual const QString& text() { return m_text; }
00067     virtual void setFont( const QFont& font ) { m_font = font; }
00068     virtual const QFont& font() { return m_font; }
00069     virtual void setBasePath( const VSubpath& path ) { m_basePath = path; }
00070     virtual VSubpath& basePath() { return m_basePath; }
00071     virtual void setPosition( Position position ) { m_position = position; }
00072     virtual Position position() { return m_position; }
00073     virtual void setAlignment( Alignment alignment ) { m_alignment = alignment; }
00074     virtual Alignment alignment() { return m_alignment; }
00075     virtual void setUseShadow( bool state ) { m_shadow = state; }
00076     virtual bool useShadow() { return m_shadow; }
00077     virtual void setShadow( int angle, int distance, bool translucent ) 
00078         { m_translucentShadow = translucent; m_shadowAngle = angle; m_shadowDistance = distance; }
00079     virtual bool translucentShadow() { return m_translucentShadow; }
00080     virtual int shadowAngle() { return m_shadowAngle; }
00081     virtual int shadowDistance() { return m_shadowDistance; }
00082     virtual void setOffset( double offset );
00083     virtual double offset() { return m_offset; }
00084 
00088     const VPathList& glyphs() const
00089     {
00090         return m_glyphs;
00091     }
00092 
00093     virtual void draw( VPainter *painter, const KoRect* rect = 0L ) const;
00094 
00095     virtual const KoRect& boundingBox() const;
00096 
00097     virtual void save( QDomElement& element ) const;
00098     virtual void load( const QDomElement& element );
00099 
00100     virtual VText* clone() const;
00101     virtual VGroup* toVGroup() const;
00102 
00103     virtual void setState( const VState state );
00104 
00105     virtual void accept( VVisitor& visitor );
00106 
00107 #ifdef HAVE_KARBONTEXT
00108     void traceText();
00109 
00110 protected:
00111     QString buildRequest( QString family, int weight, int slant, double size, int &id );
00112 #endif // HAVE_KARBONTEXT
00113 
00114 private:
00115         // The font to use to draw the text.
00116     QFont       m_font;
00117         // The base path. Doesn't belong to the document.
00118     VSubpath       m_basePath;
00119         // The text position 
00120     Position    m_position;
00121         // The text alignment
00122     Alignment   m_alignment;
00123         // The text to draw
00124     QString     m_text;
00125         // Shadow parameters
00126     bool        m_shadow;
00127     bool        m_translucentShadow;
00128     int         m_shadowDistance;
00129     int         m_shadowAngle;
00130         // The glyphs (allow to keep a font even if not present on the computer. works as long as you don't edit the text.)
00131     VPathList   m_glyphs;
00132         // the position offset
00133     double      m_offset;
00134 };
00135 
00136 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys