karbon

vtext.h
1/* This file is part of the KDE project
2 Copyright (C) 2002, The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __VTEXT_H__
21#define __VTEXT_H__
22
23#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
27#include <tqptrlist.h>
28#include <tqstring.h>
29#include <tqfont.h>
30#include <koffice_export.h>
31
32#include "vpath.h"
33#include "vcomposite.h"
34
35class VGroup;
36
37typedef TQPtrList<VPath> VPathList;
38typedef TQPtrListIterator<VPath> VPathListIterator;
39
40#ifdef Above
41#undef Above
42#endif
43
44class KARBONBASE_EXPORT VText : public VObject
45{
46public:
47 enum Position {
48 Above,
49 On,
50 Under
51 };
52
53 enum Alignment {
54 Left,
55 Center,
56 Right
57 };
58
59 VText( VObject* parent, VState state = normal );
60 VText( const TQFont &font, const VSubpath& basePath, Position position, Alignment alignment, const TQString& text );
61 VText( const VText& text );
62 virtual ~VText();
63 virtual DCOPObject* dcopObject();
64
65 virtual void setText( const TQString& text );
66 virtual const TQString& text() { return m_text; }
67 virtual void setFont( const TQFont& font ) { m_font = font; }
68 virtual const TQFont& font() { return m_font; }
69 virtual void setBasePath( const VSubpath& path ) { m_basePath = path; }
70 virtual VSubpath& basePath() { return m_basePath; }
71 virtual void setPosition( Position position ) { m_position = position; }
72 virtual Position position() { return m_position; }
73 virtual void setAlignment( Alignment alignment ) { m_alignment = alignment; }
74 virtual Alignment alignment() { return m_alignment; }
75 virtual void setUseShadow( bool state ) { m_shadow = state; }
76 virtual bool useShadow() { return m_shadow; }
77 virtual void setShadow( int angle, int distance, bool translucent )
78 { m_translucentShadow = translucent; m_shadowAngle = angle; m_shadowDistance = distance; }
79 virtual bool translucentShadow() { return m_translucentShadow; }
80 virtual int shadowAngle() { return m_shadowAngle; }
81 virtual int shadowDistance() { return m_shadowDistance; }
82 virtual void setOffset( double offset );
83 virtual double offset() { return m_offset; }
84
88 const VPathList& glyphs() const
89 {
90 return m_glyphs;
91 }
92
93 virtual void draw( VPainter *painter, const KoRect* rect = 0L ) const;
94
95 virtual const KoRect& boundingBox() const;
96
97 virtual void save( TQDomElement& element ) const;
98 virtual void load( const TQDomElement& element );
99
100 virtual VText* clone() const;
101 virtual VGroup* toVGroup() const;
102
103 virtual void setState( const VState state );
104
105 virtual void accept( VVisitor& visitor );
106
107#ifdef HAVE_KARBONTEXT
108 void traceText();
109
110protected:
111 TQString buildRequest( TQString family, int weight, int slant, double size, int &id );
112#endif // HAVE_KARBONTEXT
113
114private:
115 // The font to use to draw the text.
116 TQFont m_font;
117 // The base path. Doesn't belong to the document.
118 VSubpath m_basePath;
119 // The text position
120 Position m_position;
121 // The text alignment
122 Alignment m_alignment;
123 // The text to draw
124 TQString m_text;
125 // Shadow parameters
126 bool m_shadow;
127 bool m_translucentShadow;
128 int m_shadowDistance;
129 int m_shadowAngle;
130 // The glyphs (allow to keep a font even if not present on the computer. works as long as you don't edit the text.)
131 VPathList m_glyphs;
132 // the position offset
133 double m_offset;
134};
135
136#endif
Base class for all sort of VObject conglomerats.
Definition vgroup.h:35
The base class for all karbon objects.
Definition vobject.h:50
virtual VObject * clone() const =0
Create an exact copy of this object.
virtual void setState(const VState state)
Sets the state to a specified new state.
Definition vobject.h:163
virtual void accept(VVisitor &)
Accept a VVisitor.
Definition vobject.h:236
virtual DCOPObject * dcopObject()
Returns pointer to internal DCOP object.
Definition vobject.cpp:75
virtual const KoRect & boundingBox() const
Calculates the tightest bounding box around the object.
Definition vobject.h:111
virtual void load(const TQDomElement &element)
Load this object's state from xml and initialize this object accordingly.
Definition vobject.cpp:157
virtual void save(TQDomElement &element) const
Save this object's state to xml.
Definition vobject.cpp:102
virtual void draw(VPainter *painter, const KoRect *rect=0L) const
Draw the object to a painting device.
Definition vobject.h:100