kivio

kivio_shape_data.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program 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
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 #ifndef KIVIO_SHAPE_DATA_H
00020 #define KIVIO_SHAPE_DATA_H
00021 
00022 #include <qfont.h>
00023 #include <qcolor.h>
00024 #include <qdom.h>
00025 #include <qptrlist.h>
00026 #include <qstring.h>
00027 
00028 #include "kivio_point.h"
00029 
00030 class KivioFillStyle;
00031 class KivioLineStyle;
00032 class KivioTextStyle;
00033 
00034 class KivioTextShapeData
00035 {
00036 public:
00037     KivioTextShapeData();
00038 
00039     QString m_text;                                 // The text inside this shape
00040     QColor m_textColor;                             // The text color
00041     QFont m_textFont;                               // The text font
00042     bool m_isHtml;                                  // Is the text HTML formatted?
00043     int m_hTextAlign, m_vTextAlign;                 // Horizontal and vertical text alignment flags
00044 };
00045 
00051 class KivioShapeData
00052 {
00053 public:
00057     typedef enum {
00058         kstNone = 0,
00059         kstArc,
00060         kstPie,
00061         kstLineArray,
00062         kstPolyline,
00063         kstPolygon,
00064         kstBezier,
00065         kstRectangle,
00066         kstRoundRectangle,
00067         kstEllipse,
00068         kstOpenPath,
00069         kstClosedPath,
00070         kstTextBox
00071     } KivioShapeType;
00072 
00073 protected:
00074     friend class KivioShape;
00075 
00076     QPtrList <KivioPoint> *m_pOriginalPointList;       // Original point list loaded from an SML file
00077 
00078     KivioShapeType m_shapeType;                     // The shape type
00079     KivioPoint m_position, m_dimensions;            // The position and dimensions
00080     KivioFillStyle *m_pFillStyle;                   // The fill style
00081 
00082 //    QColor m_fgColor;                               // The foreground color
00083 //    float m_lineWidth;                              // The line width
00084     KivioLineStyle *m_pLineStyle;
00085 
00086     QString m_name;                                 // The name of this shape
00087 
00088     KivioTextStyle *m_pTextData;                    // A pointer to text data (if applicable, e.g. TextBox)
00089 
00090 public:
00091     KivioShapeData();
00092     KivioShapeData( const KivioShapeData & );
00093     virtual ~KivioShapeData();
00094 
00095     virtual void copyInto( KivioShapeData *pTarget ) const;
00096 
00097     virtual bool loadXML( const QDomElement & );
00098     virtual QDomElement saveXML( QDomDocument & );
00099 
00100 
00101     KivioShapeType shapeType() const { return m_shapeType; }
00102     void setShapeType( KivioShapeType st );
00103 
00104     static KivioShapeType shapeTypeFromString( const QString & );
00105 
00106     QPtrList<KivioPoint> *pointList() { return m_pOriginalPointList; }
00107 
00108     KivioFillStyle *fillStyle() const { return m_pFillStyle; }
00109     KivioLineStyle *lineStyle() const { return m_pLineStyle; }
00110     void setLineStyle(KivioLineStyle ls);
00111 
00112 
00113     const QString &name() const { return m_name; }
00114     void setName( const QString &newName ) { m_name=newName; }
00115 
00116 
00117     // Dimensions / Position
00118     KivioPoint *position() { return &m_position; }
00119     KivioPoint *dimensions() { return &m_dimensions; }
00120 
00121     double x() { return m_position.x(); }
00122     double y() { return m_position.y(); }
00123     double w() { return m_dimensions.x(); }
00124     double h() { return m_dimensions.y(); }
00125 
00126 
00127 
00128     // Text functions
00129     QString text();
00130     void setText( const QString &newText );
00131 
00132     bool isHtml() const;
00133     void setIsHtml( bool b );
00134 
00135     int hTextAlign() const;
00136     void setHTextAlign( int i );
00137 
00138     int vTextAlign() const;
00139     void setVTextAlign( int i );
00140 
00141     QFont textFont();
00142     void setTextFont( const QFont &f );
00143 
00144     QColor textColor();
00145     void setTextColor( QColor c );
00146 
00147     void setTextStyle( KivioTextStyle * );
00148 };
00149 
00150 #endif
00151 
00152 
KDE Home | KDE Accessibility Home | Description of Access Keys